[v4,19/35] futex.2: Use syscall(SYS_...); for system calls without a wrapper

Message ID 20210403194026.102818-20-alx.manpages@gmail.com
State Superseded
Headers show
  • SYNOPSIS: Use syscall(SYS_...); and fix '#include's
Related show

Commit Message

Noah Goldstein via Libc-alpha April 3, 2021, 7:40 p.m.
At the same time, document only headers that are required
for calling the function, or those that are specific to the

<unistd.h> is required for the syscall() prototype.
<sys/syscall.h> is required for the syscall name SYS_xxx.
<linux/futex.h> is specific to this syscall.

However, uint32_t is generic enough that it shouldn't be
documented here.  The system_data_types(7) page already documents
it, and is more precise about it.  The same goes for timespec.

As a general rule a man[23] page should document the header that
includes the prototype, and all of the headers that define macros
that should be used with the call.  However, the information about
types should be restricted to system_data_types(7) (and that page
should probably be improved by adding types), except for types
that are very specific to the call.  Otherwise, we're duplicating
info and it's then harder to maintain, and probably outdated in
the future.

Signed-off-by: Alejandro Colomar <alx.manpages@gmail.com>

 man2/futex.2 | 19 +++++++------------
 1 file changed, 7 insertions(+), 12 deletions(-)



diff --git a/man2/futex.2 b/man2/futex.2
index 389c25224..7a19e50d2 100644
--- a/man2/futex.2
+++ b/man2/futex.2
@@ -25,18 +25,16 @@  futex \- fast user-space locking
-.B #include <linux/futex.h>
-.B #include <stdint.h>
-.B #include <sys/time.h>
+.BR "#include <linux/futex.h>" "      /* Definition of " FUTEX_* " constants */"
+.BR "#include <sys/syscall.h>" "      /* Definition of " SYS_* " constants */"
+.B #include <unistd.h>
-.BI "long futex(uint32_t *" uaddr ", int " futex_op ", uint32_t " val ,
-.BI "          const struct timespec *" timeout , \
+.BI "long syscall(SYS_futex, uint32_t *" uaddr ", int " futex_op \
+", uint32_t " val ,
+.BI "             const struct timespec *" timeout , \
 " \fR  /* or: \fBuint32_t \fIval2\fP */"
-.BI "          uint32_t *" uaddr2 ", uint32_t " val3 );
+.BI "             uint32_t *" uaddr2 ", uint32_t " val3 );
-.IR Note :
-There is no glibc wrapper for this system call; see NOTES.
 .BR futex ()
@@ -1695,9 +1693,6 @@  and a sixth argument was added in Linux 2.6.7.
 This system call is Linux-specific.
-Glibc does not provide a wrapper for this system call; call it using
-.BR syscall (2).
 Several higher-level programming abstractions are implemented via futexes,
 including POSIX semaphores and
 various POSIX threads synchronization mechanisms