From: Alejandro Colomar Date: Sun, 5 Jan 2025 19:22:04 +0000 (+0100) Subject: man/: Use typeof() to improve readability of function pointer types X-Git-Tag: man-pages-6.10~22 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=aea90dfadab8995e4276bfddd272f2c935dd1422;p=thirdparty%2Fman-pages.git man/: Use typeof() to improve readability of function pointer types An exception of good taste is structure members. There, for alignment reasons, traditional syntax seems more appropriate usually. Suggested-by: Jorenar Cc: Martin Uecker Signed-off-by: Alejandro Colomar --- diff --git a/man/man2/clone.2 b/man/man2/clone.2 index 9428a5645..3ffe8e7b8 100644 --- a/man/man2/clone.2 +++ b/man/man2/clone.2 @@ -1683,7 +1683,7 @@ On ia64, a different interface is used: .P .in +4n .EX -.BI "int __clone2(int (*" "fn" ")(void *)," +.BI "int __clone2(typeof(int (void *)) *" fn , .BI " void *" stack_base ", size_t " stack_size , .BI " int " flags ", void *" "arg" ", ..." .BI " \fR/*\fP pid_t *" parent_tid ", struct user_desc *" tls , diff --git a/man/man2/init_module.2 b/man/man2/init_module.2 index b00b5a50c..5aed13e2c 100644 --- a/man/man2/init_module.2 +++ b/man/man2/init_module.2 @@ -358,8 +358,8 @@ struct module { struct module_symbol *syms; struct module_ref *deps; struct module_ref *refs; - int (*init)(void); - void (*cleanup)(void); + typeof(int (void)) *init; + typeof(void (void)) *cleanup; const struct exception_table_entry *ex_table_start; const struct exception_table_entry *ex_table_end; #ifdef __alpha__ diff --git a/man/man2/signal.2 b/man/man2/signal.2 index b4ac3922a..1e0e5f6c1 100644 --- a/man/man2/signal.2 +++ b/man/man2/signal.2 @@ -116,7 +116,7 @@ is the somewhat harder to read: .P .in +4n .EX -.BI "void ( *" signal "(int " signum ", void (*" handler ")(int)) ) (int);" +.BI "typeof(void (int)) *signal(int " signum ", typeof(void (int)) *" handler ); .EE .in .SS Portability diff --git a/man/man3/dlopen.3 b/man/man3/dlopen.3 index c3c6a9a91..2c4ab2c25 100644 --- a/man/man3/dlopen.3 +++ b/man/man3/dlopen.3 @@ -564,7 +564,7 @@ int main(void) { void *handle; - double (*cosine)(double); + typeof(double (double)) *cosine; char *error; \& handle = dlopen(LIBM_SO, RTLD_LAZY); @@ -575,7 +575,7 @@ main(void) \& dlerror(); /* Clear any existing error */ \& - cosine = (double (*)(double)) dlsym(handle, "cos"); + cosine = (typeof(double (double)) *) dlsym(handle, "cos"); \& /* According to the ISO C standard, casting between function pointers and \[aq]void *\[aq], as done above, produces undefined results. diff --git a/man/man3/malloc_hook.3 b/man/man3/malloc_hook.3 index afb253ea2..0305f3ea8 100644 --- a/man/man3/malloc_hook.3 +++ b/man/man3/malloc_hook.3 @@ -52,7 +52,7 @@ the application with a definition like the following: .P .in +4n .EX -void (*__malloc_initialize_hook)(void) = my_init_hook; +typeof(void (void)) *__malloc_initialize_hook = my_init_hook; .EE .in .P @@ -112,10 +112,10 @@ static void my_init_hook(void); static void *my_malloc_hook(size_t, const void *); \& /* Variables to save original hooks */ -static void *(*old_malloc_hook)(size_t, const void *); +static typeof(void *(size_t, const void *)) *old_malloc_hook; \& /* Override initializing hook from the C library */ -void (*__malloc_initialize_hook)(void) = my_init_hook; +typeof(void (void)) *__malloc_initialize_hook = my_init_hook; \& static void my_init_hook(void) diff --git a/man/man3/rpc.3 b/man/man3/rpc.3 index 74a0c9313..b5d7d84c4 100644 --- a/man/man3/rpc.3 +++ b/man/man3/rpc.3 @@ -37,10 +37,10 @@ The prototypes below make use of the following types: .EX .BI "typedef int " bool_t ; .P -.BI "typedef bool_t (*" xdrproc_t ")(XDR *, void *, ...);" +.BI "typedef typeof(bool_t (XDR *, void *, ...)) *" xdrproc_t ; .P -.BI "typedef bool_t (*" resultproc_t ")(caddr_t " resp , -.BI " struct sockaddr_in *" raddr ); +.BI "typedef typeof(bool_t (caddr_t " resp ", struct sockaddr_in *" raddr ) +.BI " *" resultproc_t ; .EE .RE .P @@ -644,7 +644,7 @@ This routine returns one if it succeeds, zero otherwise. .P .nf .BI "int registerrpc(unsigned long " prognum ", unsigned long " versnum , -.BI " unsigned long " procnum ", char *(*" procname ")(char *)," +.BI " unsigned long " procnum ", typeof(char *(char *)) *" procname , .BI " xdrproc_t " inproc ", xdrproc_t " outproc ); .fi .IP @@ -785,7 +785,7 @@ This interface is obsoleted by .nf .BI "bool_t svc_register(SVCXPRT *" xprt ", unsigned long " prognum , .BI " unsigned long " versnum , -.BI " void (*" dispatch ")(struct svc_req *, SVCXPRT *)," +.BI " typeof(void (struct svc_req *, SVCXPRT *)) *" dispatch , .BI " unsigned long " protocol ); .fi .IP diff --git a/man/man3/xdr.3 b/man/man3/xdr.3 index a4c906526..25181f481 100644 --- a/man/man3/xdr.3 +++ b/man/man3/xdr.3 @@ -29,7 +29,7 @@ and make use of the following types: .EX .BI "typedef int " bool_t ; .P -.BI "typedef bool_t (*" xdrproc_t ")(XDR *, void *,...);" +.BI "typedef typeof(bool_t (XDR *, void *, ...)) *" xdrproc_t ; .EE .RE .P @@ -264,8 +264,8 @@ linked lists. .nf .BI "void xdrrec_create(XDR *" xdrs ", unsigned int " sendsize , .BI " unsigned int " recvsize ", char *" handle , -.BI " int (*" readit ")(char *, char *, int)," -.BI " int (*" writeit ")(char *, char *, int));" +.BI " typeof(int (char *, char *, int)) *" readit , +.BI " typeof(int (char *, char *, int)) *" writeit ); .fi .IP This routine initializes the XDR stream object pointed to by