Re: git: 1fd880742ace - main - libsys: add a libsys.h

From: Peter Holm <pho_at_FreeBSD.org>
Date: Tue, 23 Apr 2024 19:58:19 UTC
On Tue, Apr 16, 2024 at 04:48:21PM +0000, Brooks Davis wrote:
> The branch main has been updated by brooks:
> 
> URL: https://cgit.FreeBSD.org/src/commit/?id=1fd880742ace94e11fa60ee0b074f0b18e54c54f
> 
> commit 1fd880742ace94e11fa60ee0b074f0b18e54c54f
> Author:     Brooks Davis <brooks@FreeBSD.org>
> AuthorDate: 2024-04-16 16:48:07 +0000
> Commit:     Brooks Davis <brooks@FreeBSD.org>
> CommitDate: 2024-04-16 16:48:07 +0000
> 
>     libsys: add a libsys.h
>     
>     This declares an API for libsys which currently consists of
>     __sys_<foo>() declarations for system call stubs and function pointer
>     typedefs of the form __sys_<foo>_t.  The vast majority of the
>     implementation resides in a generated _libsys.h which ensures that all
>     system call stub declarations match syscalls.master.
>     
>     Reviewed by:    kib
>     Differential Revision:  https://reviews.freebsd.org/D44387
> ---
>  lib/libsys/Makefile    |   2 +
>  lib/libsys/_libsys.h   | 865 +++++++++++++++++++++++++++++++++++++++++++++++++
>  lib/libsys/libsys.h    |  25 ++
>  sys/kern/syscalls.conf |   1 +
>  4 files changed, 893 insertions(+)
> 

Shouldn't readv() and writev() return ssize_t? Like this:

diff --git a/lib/libsys/_libsys.h b/lib/libsys/_libsys.h
index d0dd144bc8f1..d4cd14ceb75f 100644
--- a/lib/libsys/_libsys.h
+++ b/lib/libsys/_libsys.h
@@ -141,8 +141,8 @@ typedef int (__sys_listen_t)(int, int);
 typedef int (__sys_gettimeofday_t)(struct timeval *, struct timezone *);
 typedef int (__sys_getrusage_t)(int, struct rusage *);
 typedef int (__sys_getsockopt_t)(int, int, int, void *, __socklen_t *);
-typedef int (__sys_readv_t)(int, const struct iovec *, u_int);
-typedef int (__sys_writev_t)(int, const struct iovec *, u_int);
+typedef ssize_t (__sys_readv_t)(int, const struct iovec *, u_int);
+typedef ssize_t (__sys_writev_t)(int, const struct iovec *, u_int);
 typedef int (__sys_settimeofday_t)(const struct timeval *, const struct timezone *);
 typedef int (__sys_fchown_t)(int, int, int);
 typedef int (__sys_fchmod_t)(int, mode_t);
@@ -540,8 +540,8 @@ int __sys_listen(int s, int backlog);
 int __sys_gettimeofday(struct timeval * tp, struct timezone * tzp);
 int __sys_getrusage(int who, struct rusage * rusage);
 int __sys_getsockopt(int s, int level, int name, void * val, __socklen_t * avalsize);
-int __sys_readv(int fd, const struct iovec * iovp, u_int iovcnt);
-int __sys_writev(int fd, const struct iovec * iovp, u_int iovcnt);
+ssize_t __sys_readv(int fd, const struct iovec * iovp, u_int iovcnt);
+ssize_t __sys_writev(int fd, const struct iovec * iovp, u_int iovcnt);
 int __sys_settimeofday(const struct timeval * tv, const struct timezone * tzp);
 int __sys_fchown(int fd, int uid, int gid);
 int __sys_fchmod(int fd, mode_t mode);

- Peter