From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-io1-xd43.google.com (mail-io1-xd43.google.com [IPv6:2607:f8b0:4864:20::d43]) by sourceware.org (Postfix) with ESMTPS id C0D2B385782E for ; Fri, 25 Sep 2020 21:29:59 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org C0D2B385782E Received: by mail-io1-xd43.google.com with SMTP id y74so4508088iof.12 for ; Fri, 25 Sep 2020 14:29:59 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=S/zgwtqTWx+JdWtvS+fLKr76FcRLgAFqVe/TMu4Tcug=; b=GF95ewXeytfc2mTEHznH71RqqKOv9w86wjpfy4PHIXLUvXZ5xdUDhy59eMMzGkilWm js0NhKmls0WombssybaUm1OhX+Ymjnh/c0B4MG7fskbZTvVfK87mreEQ06p0U421uaM0 LMSs8z2j0USWcgNae4UspV30gBynxRky57ZrWTjS4EmBk9AbmuNhqazHu0N7TrrN1FI3 ri9b9JCuBLO7VaDiAPSkE/Vom20DHfbyNQj8NCVpyfbF2CDhx5MIYaw2QhZyuoOETs+5 NIZMQiLM2wX71zdGnuhdUch+39FdXUR1nQn5eUed/mVQ3J5A5KQ3dpyxbd4BLCVVZJI6 6w7A== X-Gm-Message-State: AOAM531uQny7HkNLThLhf7Ey1vO8Bn942EoRm9gED6tVym2Wk8uQ9DCG VsVqZsKadwpAO97VSfvk66Moz5IpB3JfV9bhlNg= X-Google-Smtp-Source: ABdhPJxVGT/CUY94IXi/xiEvvloZtwbHKSiikZb8oODuaPyNCpsWEl4uGbRnfnvoGo1ihSKFiLFmZKvWYH/mnd1FOIw= X-Received: by 2002:a05:6602:15c5:: with SMTP id f5mr436836iow.42.1601069398149; Fri, 25 Sep 2020 14:29:58 -0700 (PDT) MIME-Version: 1.0 References: <20200908145738.640039-1-adhemerval.zanella@linaro.org> <20200908145738.640039-11-adhemerval.zanella@linaro.org> In-Reply-To: <20200908145738.640039-11-adhemerval.zanella@linaro.org> From: Alistair Francis Date: Fri, 25 Sep 2020 14:18:39 -0700 Message-ID: Subject: Re: [PATCH v2 11/14] linux: Add time64 recvmmsg support To: Adhemerval Zanella Cc: GNU C Library Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-9.2 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_ENVFROM_END_DIGIT, FREEMAIL_FROM, GIT_PATCH_0, KAM_SHORT, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: libc-alpha@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 25 Sep 2020 21:30:01 -0000 On Tue, Sep 8, 2020 at 8:02 AM Adhemerval Zanella via Libc-alpha wrote: > > The wire-up syscall __NR_recvmmsg_time64 (for 32-bit) or > __NR_recvmmsg (for 64-bit) is used as default. The 32-bit fallback > is used iff __ASSUME_TIME64_SYSCALLS is not defined, which assumes the > kernel ABI provides either __NR_socketcall or __NR_recvmmsg > (32-bit time_t). > > It does not handle the timestamps on ancillary data (SCM_TIMESTAMPING > records). > > Checked on x86_64-linux-gnu and i686-linux-gnu. Reviewed-by: Alistair Francis Alistair > --- > include/sys/socket.h | 8 ++++ > sysdeps/unix/sysv/linux/recvmmsg.c | 63 ++++++++++++++++++++++++------ > 2 files changed, 60 insertions(+), 11 deletions(-) > > diff --git a/include/sys/socket.h b/include/sys/socket.h > index 26db0e0d77..0e39dd2a3a 100644 > --- a/include/sys/socket.h > +++ b/include/sys/socket.h > @@ -104,6 +104,14 @@ extern ssize_t __libc_recvmsg (int __fd, struct msghdr *__message, > int __flags); > extern ssize_t __recvmsg (int __fd, struct msghdr *__message, > int __flags) attribute_hidden; > +#if __TIMESIZE == 64 > +# define __recvmmsg64 __recvmmsg > +#else > +extern int __recvmmsg64 (int __fd, struct mmsghdr *vmessages, > + unsigned int vlen, int flags, > + struct __timespec64 *timeout); > +libc_hidden_proto (__recvmmsg64) > +#endif > > /* Set socket FD's option OPTNAME at protocol level LEVEL > to *OPTVAL (which is OPTLEN bytes long). > diff --git a/sysdeps/unix/sysv/linux/recvmmsg.c b/sysdeps/unix/sysv/linux/recvmmsg.c > index 42c80c59c3..a29c91fb76 100644 > --- a/sysdeps/unix/sysv/linux/recvmmsg.c > +++ b/sysdeps/unix/sysv/linux/recvmmsg.c > @@ -16,21 +16,62 @@ > License along with the GNU C Library; if not, see > . */ > > -#include > #include > - > -#include > -#include > +#include > #include > -#include > > int > -recvmmsg (int fd, struct mmsghdr *vmessages, unsigned int vlen, int flags, > - struct timespec *tmo) > +__recvmmsg64 (int fd, struct mmsghdr *vmessages, unsigned int vlen, int flags, > + struct __timespec64 *timeout) > { > -#ifdef __ASSUME_RECVMMSG_SYSCALL > - return SYSCALL_CANCEL (recvmmsg, fd, vmessages, vlen, flags, tmo); > -#else > - return SOCKETCALL_CANCEL (recvmmsg, fd, vmessages, vlen, flags, tmo); > +#ifndef __NR_recvmmsg_time64 > +# define __NR_recvmmsg_time64 __NR_recvmmsg > #endif > + int r = SYSCALL_CANCEL (recvmmsg_time64, fd, vmessages, vlen, flags, > + timeout); > +#ifndef __ASSUME_TIME64_SYSCALLS > + if (r >= 0 || errno != ENOSYS) > + return r; > + > + struct timespec ts32, *pts32 = NULL; > + if (timeout != NULL) > + { > + if (! in_time_t_range (timeout->tv_sec)) > + { > + __set_errno (EINVAL); > + return -1; > + } > + ts32 = valid_timespec64_to_timespec (*timeout); > + pts32 = &ts32; > + } > +# ifdef __ASSUME_RECVMMSG_SYSCALL > + r = SYSCALL_CANCEL (recvmmsg, fd, vmessages, vlen, flags, pts32); > +# else > + r = SOCKETCALL_CANCEL (recvmmsg, fd, vmessages, vlen, flags, pts32); > +# endif > + if (r >= 0 && timeout != NULL) > + *timeout = valid_timespec_to_timespec64 (ts32); > +#endif /* __ASSUME_TIME64_SYSCALLS */ > + return r; > } > +#if __TIMESIZE != 64 > +libc_hidden_def (__recvmmsg64) > + > +int > +__recvmmsg (int fd, struct mmsghdr *vmessages, unsigned int vlen, int flags, > + struct timespec *timeout) > +{ > + struct __timespec64 ts64, *pts64 = NULL; > + if (timeout != NULL) > + { > + ts64 = valid_timespec_to_timespec64 (*timeout); > + pts64 = &ts64; > + } > + int r = __recvmmsg64 (fd, vmessages, vlen, flags, pts64); > + if (r >= 0) > + /* The remanining timeout will be always less the input TIMEOUT. */ > + *timeout = valid_timespec64_to_timespec (ts64); > + return r; > +} > +#endif > +weak_alias (__recvmmsg, recvmmsg) > -- > 2.25.1 >