man2: SYNOPSIS: Use 'restrict' in prototypes
cover man2: SYNOPSIS: Use 'restrict' in prototypes
Hi Michael
This patch set fixes man2 to add 'restrict' to the functions that use it.
Cheers,
Alex
---
Alejandro Colomar (14):
accept.2: SYNOPSIS: Use 'restrict' in prototypes getpeername.2: SYNOPSIS: Use 'restrict' in prototypes getsockopt.2: SYNOPSIS: Use 'restrict' in prototypes readlink.2: SYNOPSIS: Use 'restrict' in prototypes recv.2: SYNOPSIS: Use 'restrict' in prototypes select.2: SYNOPSIS: Use 'restrict' in prototypes sigaction.2: SYNOPSIS: Use 'restrict' in prototypes sigaltstack.2: SYNOPSIS: Use 'restrict' in prototypes sigprocmask.2: SYNOPSIS: Use 'restrict' in prototypes sigwaitinfo.2: SYNOPSIS: Use 'restrict' in prototypes statx.2: SYNOPSIS: Use 'restrict' in prototypes stat.2: SYNOPSIS: Use 'restrict' in prototypes timer_create.2: SYNOPSIS: Use 'restrict' in prototypes timer_settime.2: SYNOPSIS: Use 'restrict' in prototypes
man2/accept.2 | 7 ++++--- man2/getpeername.2 | 4 ++-- man2/getsockopt.2 | 2 +- man2/readlink.2 | 8 ++++---- man2/recv.2 | 6 ++++-- man2/select.2 | 12 +++++++----- man2/sigaction.2 | 4 ++-- man2/sigaltstack.2 | 3 ++- man2/sigprocmask.2 | 3 ++- man2/sigwaitinfo.2 | 8 +++++--- man2/stat.2 | 11 ++++++----- man2/statx.2 | 4 ++-- man2/timer_create.2 | 4 ++-- man2/timer_settime.2 | 4 ++-- 14 files changed, 45 insertions(+), 35 deletions(-)
Signature · 1 line
2.30.0
PATCH 1/14 accept.2: SYNOPSIS: Use 'restrict' in prototypes
POSIX specifies the parameters of accept() shall be 'restrict'. Glibc uses 'restrict' too (also for accept4()).
Let's use it here too.
......
.../glibc$ grep_glibc_prototype accept socket/sys/socket.h:232:
extern int accept (int __fd, __SOCKADDR_ARG __addr,
socklen_t *__restrict __addr_len); .../glibc$ grep_glibc_prototype accept4 socket/sys/socket.h:240: extern int accept4 (int __fd, __SOCKADDR_ARG __addr, socklen_t *__restrict __addr_len, int __flags);
.../glibc$
--- man2/accept.2 | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-)
man2/accept.2 +4 -3
@@ -46,13 +46,14 @@ accept, accept4 \- accept a connection on a socket .BR "#include <sys/types.h>" " /* See NOTES */" .B #include <sys/socket.h> .PP -.BI "int accept(int " sockfd ", struct sockaddr *" addr ", socklen_t *" addrlen ); +.BI "int accept(int " sockfd ", struct sockaddr *restrict " addr , +.BI " socklen_t *restrict " addrlen ); .PP .BR "#define _GNU_SOURCE" " /* See feature_test_macros(7) */" .B #include <sys/socket.h> .PP -.BI "int accept4(int " sockfd ", struct sockaddr *" addr , -.BI " socklen_t *" addrlen ", int " flags ); +.BI "int accept4(int " sockfd ", struct sockaddr *restrict " addr , +.BI " socklen_t *restrict " addrlen ", int " flags ); .fi .SH DESCRIPTION The
Signature · 1 line
2.30.0
PATCH 2/14 getpeername.2: SYNOPSIS: Use 'restrict' in prototypes
In reply to Alejandro ColomarPOSIX specifies that the parameters of getpeername() shall be 'restrict'. Glibc uses 'restrict' too. Let's use it here too.
......
.../glibc$ grep_glibc_prototype getpeername socket/sys/socket.h:130:
extern int getpeername (int __fd, __SOCKADDR_ARG __addr,
socklen_t *__restrict __len) __THROW;
.../glibc$
--- man2/getpeername.2 | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
man2/getpeername.2 +2 -2
@@ -46,8 +46,8 @@ getpeername \- get name of connected peer socket .nf .B #include <sys/socket.h> .PP -.BI "int getpeername(int " sockfd ", struct sockaddr *" addr \ -", socklen_t *" addrlen ); +.BI "int getpeername(int " sockfd ", struct sockaddr *restrict " addr , +.BI " socklen_t *restrict " addrlen ); .fi .SH DESCRIPTION .BR getpeername ()
Signature · 1 line
2.30.0
PATCH 3/14 getsockopt.2: SYNOPSIS: Use 'restrict' in prototypes
In reply to Alejandro ColomarPOSIX specifies that the parameters of getsockopt() shall be 'restrict'. Glibc uses 'restrict' too. Let's use it here too.
......
.../glibc$ grep_glibc_prototype getsockopt socket/sys/socket.h:208:
extern int getsockopt (int __fd, int __level, int __optname,
void *__restrict __optval, socklen_t *__restrict __optlen) __THROW;
.../glibc$
--- man2/getsockopt.2 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
man2/getsockopt.2 +1 -1
@@ -50,7 +50,7 @@ getsockopt, setsockopt \- get and set options on sockets .B #include <sys/socket.h> .PP .BI "int getsockopt(int " sockfd ", int " level ", int " optname , -.BI " void *" optval ", socklen_t *" optlen ); +.BI " void *restrict " optval ", socklen_t *restrict " optlen ); .BI "int setsockopt(int " sockfd ", int " level ", int " optname , .BI " const void *" optval ", socklen_t " optlen ); .fi
Signature · 1 line
2.30.0
PATCH 4/14 readlink.2: SYNOPSIS: Use 'restrict' in prototypes
In reply to Alejandro ColomarPOSIX specifies that the parameters of readlink() and readlinkat() shall be 'restrict'. Glibc uses 'restrict' too.
Let's use it here too.
......
.../glibc$ grep_glibc_prototype readlink posix/unistd.h:820:
extern ssize_t readlink (const char *__restrict __path,
char *__restrict __buf, size_t __len)
__THROW __nonnull ((1, 2)) __wur __attr_access ((__write_only__, 2, 3));
.../glibc$ grep_glibc_prototype readlinkat
posix/unistd.h:832:
extern ssize_t readlinkat (int __fd, const char *__restrict __path,
char *__restrict __buf, size_t __len)
__THROW __nonnull ((2, 3)) __wur __attr_access ((__write_only__, 3, 4));.../glibc$
--- man2/readlink.2 | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
man2/readlink.2 +4 -4
@@ -48,14 +48,14 @@ readlink, readlinkat \- read value of a symbolic link .nf .B #include <unistd.h> .PP -.BI "ssize_t readlink(const char *" pathname ", char *" buf \ -", size_t " bufsiz ); +.BI "ssize_t readlink(const char *restrict " pathname ", char *restrict " buf , +.BI " size_t " bufsiz ); .PP .BR "#include <fcntl.h> " "/* Definition of AT_* constants */" .B #include <unistd.h> .PP -.BI "ssize_t readlinkat(int " dirfd ", const char *" pathname , -.BI " char *" buf ", size_t " bufsiz ); +.BI "ssize_t readlinkat(int " dirfd ", const char *restrict " pathname , +.BI " char *restrict " buf ", size_t " bufsiz ); .PP .fi .RS -4
Signature · 1 line
2.30.0
PATCH 5/14 recv.2: SYNOPSIS: Use 'restrict' in prototypes
In reply to Alejandro ColomarPOSIX specifies that the parameters of recvfrom()
shall be 'restrict'. Glibc uses 'restrict' too.
Let's use it here too.
......
.../glibc$ grep_glibc_prototype recvfrom socket/sys/socket.h:163:
extern ssize_t recvfrom (int __fd, void *__restrict __buf, size_t __n,
int __flags, __SOCKADDR_ARG __addr, socklen_t *__restrict __addr_len);
.../glibc$
--- man2/recv.2 | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
man2/recv.2 +4 -2
@@ -47,8 +47,10 @@ recv, recvfrom, recvmsg \- receive a message from a socket .B #include <sys/socket.h> .PP .BI "ssize_t recv(int " sockfd ", void *" buf ", size_t " len ", int " flags ); -.BI "ssize_t recvfrom(int " sockfd ", void *" buf ", size_t " len ", int " flags , -.BI " struct sockaddr *" src_addr ", socklen_t *" addrlen ); +.BI "ssize_t recvfrom(int " sockfd ", void *restrict " buf ", size_t " len \ +", int " flags , +.BI " struct sockaddr *restrict " src_addr , +.BI " socklen_t *restrict " addrlen ); .BI "ssize_t recvmsg(int " sockfd ", struct msghdr *" msg ", int " flags ); .fi .SH DESCRIPTION
Signature · 1 line
2.30.0
PATCH 6/14 select.2: SYNOPSIS: Use 'restrict' in prototypes
In reply to Alejandro ColomarPOSIX specifies that the parameters of [p]select() shall be 'restrict'. Glibc uses 'restrict' too. Let's use it here too.
......
.../glibc$ grep_glibc_prototype select misc/sys/select.h:101:
extern int select (int __nfds, fd_set *__restrict __readfds,
fd_set *__restrict __writefds, fd_set *__restrict __exceptfds, struct timeval *__restrict __timeout);
.../glibc$ grep_glibc_prototype pselect misc/sys/select.h:113:
extern int pselect (int __nfds, fd_set *__restrict __readfds,
fd_set *__restrict __writefds, fd_set *__restrict __exceptfds, const struct timespec *__restrict __timeout, const __sigset_t *__restrict __sigmask);
.../glibc$
--- man2/select.2 | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-)
man2/select.2 +7 -5
@@ -45,17 +45,19 @@ synchronous I/O multiplexing .nf .B #include <sys/select.h> .PP -.BI "int select(int " nfds ", fd_set *" readfds ", fd_set *" writefds , -.BI " fd_set *" exceptfds ", struct timeval *" timeout ); +.BI "int select(int " nfds ", fd_set *restrict " readfds , +.BI " fd_set *restrict " writefds ", fd_set *restrict " exceptfds , +.BI " struct timeval *restrict " timeout ); .PP .BI "void FD_CLR(int " fd ", fd_set *" set ); .BI "int FD_ISSET(int " fd ", fd_set *" set ); .BI "void FD_SET(int " fd ", fd_set *" set ); .BI "void FD_ZERO(fd_set *" set ); .PP -.BI "int pselect(int " nfds ", fd_set *" readfds ", fd_set *" writefds , -.BI " fd_set *" exceptfds ", const struct timespec *" timeout , -.BI " const sigset_t *" sigmask ); +.BI "int pselect(int " nfds ", fd_set *restrict " readfds , +.BI " fd_set *restrict " writefds ", fd_set *restrict " exceptfds , +.BI " const struct timespec *restrict " timeout , +.BI " const sigset_t *restrict " sigmask ); .fi .PP .RS -4
Signature · 1 line
2.30.0
PATCH 7/14 sigaction.2: SYNOPSIS: Use 'restrict' in prototypes
In reply to Alejandro ColomarPOSIX specifies that the parameters of sigaction() shall be 'restrict'. Glibc uses 'restrict' too. Let's use it here too.
......
.../glibc$ grep_glibc_prototype sigactionsignal/signal.h:243:
extern int sigaction (int __sig, const struct sigaction *__restrict __act,
struct sigaction *__restrict __oact) __THROW;
.../glibc$
--- man2/sigaction.2 | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
man2/sigaction.2 +2 -2
@@ -52,8 +52,8 @@ sigaction, rt_sigaction \- examine and change a signal action .nf .B #include <signal.h> .PP -.BI "int sigaction(int " signum ", const struct sigaction *" act , -.BI " struct sigaction *" oldact ); +.BI "int sigaction(int " signum ", const struct sigaction *restrict " act , +.BI " struct sigaction *restrict " oldact ); .fi .PP .RS -4
Signature · 1 line
2.30.0
PATCH 8/14 sigaltstack.2: SYNOPSIS: Use 'restrict' in prototypes
In reply to Alejandro ColomarPOSIX specifies that the parameters of sigaltstack() shall be 'restrict'. Glibc uses 'restrict' too. Let's use it here too.
......
.../glibc$ grep_glibc_prototype sigaltstack signal/signal.h:320:
extern int sigaltstack (const stack_t *__restrict __ss,
stack_t *__restrict __oss) __THROW;
.../glibc$
--- man2/sigaltstack.2 | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
man2/sigaltstack.2 +2 -1
@@ -30,7 +30,8 @@ sigaltstack \- set and/or get signal stack context .nf .B #include <signal.h> .PP -.BI "int sigaltstack(const stack_t *" ss ", stack_t *" old_ss ); +.BI "int sigaltstack(const stack_t *restrict " ss \ +", stack_t *restrict " old_ss ); .fi .PP .RS -4
Signature · 1 line
2.30.0
PATCH 9/14 sigprocmask.2: SYNOPSIS: Use 'restrict' in prototypes
In reply to Alejandro ColomarPOSIX specifies that the parameters of sigprocmask() shall be 'restrict'. Glibc uses 'restrict' too. Let's use it here too.
......
.../glibc$ grep_glibc_prototype sigprocmask signal/signal.h:232:
extern int sigprocmask (int __how, const sigset_t *__restrict __set,
sigset_t *__restrict __oset) __THROW;
.../glibc$
--- man2/sigprocmask.2 | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
man2/sigprocmask.2 +2 -1
@@ -34,7 +34,8 @@ sigprocmask, rt_sigprocmask \- examine and change blocked signals .PP .nf /* Prototype for the glibc wrapper function */ -.BI "int sigprocmask(int " how ", const sigset_t *" set ", sigset_t *" oldset ); +.BI "int sigprocmask(int " how ", const sigset_t *restrict " set , +.BI " sigset_t *restrict " oldset ); .PP /* Prototype for the underlying system call */ .BI "int rt_sigprocmask(int " how ", const kernel_sigset_t *" set ,
Signature · 1 line
2.30.0
PATCH 10/14 sigwaitinfo.2: SYNOPSIS: Use 'restrict' in prototypes
In reply to Alejandro ColomarPOSIX specifies that the parameters of sigwaitinfo() and sigtimedwait() shall be 'restrict'. Glibc uses 'restrict' too. Let's use it here too.
......
.../glibc$ grep_glibc_prototype sigwaitinfo signal/signal.h:264:
extern int sigwaitinfo (const sigset_t *__restrict __set,
siginfo_t *__restrict __info) __nonnull ((1));
.../glibc$ grep_glibc_prototype sigtimedwait signal/signal.h:272:
extern int sigtimedwait (const sigset_t *__restrict __set,
siginfo_t *__restrict __info, const struct timespec *__restrict __timeout)
__nonnull ((1));
.../glibc$
--- man2/sigwaitinfo.2 | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-)
man2/sigwaitinfo.2 +5 -3
@@ -30,9 +30,11 @@ for queued signals .nf .B #include <signal.h> .PP -.BI "int sigwaitinfo(const sigset_t *" set ", siginfo_t *" info ");" -.BI "int sigtimedwait(const sigset_t *" set ", siginfo_t *" info , -.BI " const struct timespec *" timeout ");" +.BI "int sigwaitinfo(const sigset_t *restrict " set , +.BI " siginfo_t *restrict " info ); +.BI "int sigtimedwait(const sigset_t *restrict " set , +.BI " siginfo_t *restrict " info , +.BI " const struct timespec *restrict " timeout ); .fi .PP .RS -4
Signature · 1 line
2.30.0
PATCH 11/14 statx.2: SYNOPSIS: Use 'restrict' in prototypes
In reply to Alejandro ColomarGlibc uses 'restrict' for the types of the parameters of statx(). Let's use it here too.
......
.../glibc$ grep_glibc_prototype statx io/bits/statx-generic.h:60:
int statx (int __dirfd, const char *__restrict __path, int __flags,
unsigned int __mask, struct statx *__restrict __buf)
__THROW __nonnull ((2, 5));
.../glibc$
--- man2/statx.2 | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
man2/statx.2 +2 -2
@@ -37,8 +37,8 @@ statx \- get file status (extended) .B #include <unistd.h> .BR "#include <fcntl.h> " "/* Definition of AT_* constants */" .PP -.BI "int statx(int " dirfd ", const char *" pathname ", int " flags "," -.BI " unsigned int " mask ", struct statx *" statxbuf ); +.BI "int statx(int " dirfd ", const char *restrict " pathname ", int " flags , +.BI " unsigned int " mask ", struct statx *restrict " statxbuf ); .fi .SH DESCRIPTION This function returns information about a file, storing it in the buffer
Signature · 1 line
2.30.0
PATCH 12/14 stat.2: SYNOPSIS: Use 'restrict' in prototypes
In reply to Alejandro ColomarPOSIX specifies that the parameters of stat(), lstat(), and fstatat() shall be 'restrict'. Glibc uses 'restrict' too.
Let's use it here too.
......
.../glibc$ grep_glibc_prototype statio/sys/stat.h:205:
extern int stat (const char *__restrict __file,
struct stat *__restrict __buf) __THROW __nonnull ((1, 2));
.../glibc$ grep_glibc_prototype lstat
io/sys/stat.h:259:
extern int lstat (const char *__restrict __file,
struct stat *__restrict __buf) __THROW __nonnull ((1, 2));
.../glibc$ grep_glibc_prototype fstatat
io/sys/stat.h:234:
extern int fstatat (int __fd, const char *__restrict __file,
struct stat *__restrict __buf, int __flag)
__THROW __nonnull ((2, 3));.../glibc$
--- man2/stat.2 | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-)
man2/stat.2 +6 -5
@@ -44,16 +44,17 @@ stat, fstat, lstat, fstatat \- get file status .B #include <sys/types.h> .B #include <sys/stat.h> .PP -.BI "int stat(const char *" pathname ", struct stat *" statbuf ); +.BI "int stat(const char *restrict " pathname , +.BI " struct stat *restrict " statbuf ); .BI "int fstat(int " fd ", struct stat *" statbuf ); -.BI "int lstat(const char *" pathname ", struct stat *" statbuf ); +.BI "int lstat(const char *restrict " pathname , +.BI " struct stat *restrict " statbuf ); .PP .BR "#include <fcntl.h> " "/* Definition of AT_* constants */" .B #include <sys/stat.h> .PP -.BI "int fstatat(int " dirfd ", const char *" pathname ", struct stat *" \ -statbuf , -.BI " int " flags ); +.BI "int fstatat(int " dirfd ", const char *restrict " pathname , +.BI " struct stat *restrict " statbuf ", int " flags ); .fi .PP .RS -4
Signature · 1 line
2.30.0
PATCH 13/14 timer_create.2: SYNOPSIS: Use 'restrict' in prototypes
In reply to Alejandro ColomarPOSIX specifies that the parameters of timer_create() shall be 'restrict'. Glibc uses 'restrict' too. Let's use it here too.
......
.../glibc$ grep_glibc_prototype timer_createtime/time.h:234:
extern int timer_create (clockid_t __clock_id,
struct sigevent *__restrict __evp, timer_t *__restrict __timerid) __THROW;
.../glibc$
--- man2/timer_create.2 | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
man2/timer_create.2 +2 -2
@@ -31,8 +31,8 @@ timer_create \- create a POSIX per-process timer .B #include <signal.h> .B #include <time.h> .PP -.BI "int timer_create(clockid_t " clockid ", struct sigevent *" sevp , -.BI " timer_t *" timerid ); +.BI "int timer_create(clockid_t " clockid ", struct sigevent *restrict " sevp , +.BI " timer_t *restrict " timerid ); .fi .PP Link with \fI\-lrt\fP.
Signature · 1 line
2.30.0
PATCH 14/14 timer_settime.2: SYNOPSIS: Use 'restrict' in prototypes
In reply to Alejandro ColomarPOSIX specifies that the parameters of timer_settime() shall be 'restrict'. Glibc uses 'restrict' too. Let's use it here too.
......
.../glibc$ grep_glibc_prototype timer_settime time/time.h:242:
extern int timer_settime (timer_t __timerid, int __flags,
const struct itimerspec *__restrict __value, struct itimerspec *__restrict __ovalue) __THROW;
.../glibc$
--- man2/timer_settime.2 | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
man2/timer_settime.2 +2 -2
@@ -32,8 +32,8 @@ state of POSIX per-process timer .B #include <time.h> .PP .BI "int timer_settime(timer_t " timerid ", int " flags , -.BI " const struct itimerspec *" new_value , -.BI " struct itimerspec *" old_value ); +.BI " const struct itimerspec *restrict " new_value , +.BI " struct itimerspec *restrict " old_value ); .BI "int timer_gettime(timer_t " timerid ", struct itimerspec *" curr_value ); .fi .PP
Signature · 1 line
2.30.0
Hi Alex,
Quoted 3 lines · Alejandro Colomar
Hi Michael
This patch set fixes man2 to add 'restrict' to the functions that use it.
Nice work! I've applied all of these patches.
Cheers,
Michael
Quoted 33 lines
---
Alejandro Colomar (14):
accept.2: SYNOPSIS: Use 'restrict' in prototypes getpeername.2: SYNOPSIS: Use 'restrict' in prototypes getsockopt.2: SYNOPSIS: Use 'restrict' in prototypes readlink.2: SYNOPSIS: Use 'restrict' in prototypes recv.2: SYNOPSIS: Use 'restrict' in prototypes select.2: SYNOPSIS: Use 'restrict' in prototypes sigaction.2: SYNOPSIS: Use 'restrict' in prototypes sigaltstack.2: SYNOPSIS: Use 'restrict' in prototypes sigprocmask.2: SYNOPSIS: Use 'restrict' in prototypes sigwaitinfo.2: SYNOPSIS: Use 'restrict' in prototypes statx.2: SYNOPSIS: Use 'restrict' in prototypes stat.2: SYNOPSIS: Use 'restrict' in prototypes timer_create.2: SYNOPSIS: Use 'restrict' in prototypes timer_settime.2: SYNOPSIS: Use 'restrict' in prototypesman2/accept.2 | 7 ++++--- man2/getpeername.2 | 4 ++-- man2/getsockopt.2 | 2 +- man2/readlink.2 | 8 ++++---- man2/recv.2 | 6 ++++-- man2/select.2 | 12 +++++++----- man2/sigaction.2 | 4 ++-- man2/sigaltstack.2 | 3 ++- man2/sigprocmask.2 | 3 ++- man2/sigwaitinfo.2 | 8 +++++--- man2/stat.2 | 11 ++++++----- man2/statx.2 | 4 ++-- man2/timer_create.2 | 4 ++-- man2/timer_settime.2 | 4 ++-- 14 files changed, 45 insertions(+), 35 deletions(-)
Signature · 3 lines
Michael Kerrisk Linux man-pages maintainer; http://www.kernel.org/doc/man-pages/ Linux/UNIX System Programming Training: http://man7.org/training/