]> git.ipfire.org Git - thirdparty/man-pages.git/commitdiff
man/: SYNOPSIS: Use typeof() to improve readability of function pointer types
authorAlejandro Colomar <alx@kernel.org>
Fri, 13 Dec 2024 13:19:28 +0000 (14:19 +0100)
committerAlejandro Colomar <alx@kernel.org>
Fri, 13 Dec 2024 22:51:12 +0000 (23:51 +0100)
Suggested-by: Jorenar <dev@jorenar.com>
Signed-off-by: Alejandro Colomar <alx@kernel.org>
27 files changed:
man/man2/clone.2
man/man2/signal.2
man/man3/atexit.3
man/man3/bsd_signal.3
man/man3/bsearch.3
man/man3/dl_iterate_phdr.3
man/man3/error.3
man/man3/fts.3
man/man3/ftw.3
man/man3/glob.3
man/man3/gsignal.3
man/man3/lsearch.3
man/man3/makecontext.3
man/man3/malloc_hook.3
man/man3/mcheck.3
man/man3/mpool.3
man/man3/on_exit.3
man/man3/pthread_atfork.3
man/man3/pthread_cleanup_push.3
man/man3/pthread_cleanup_push_defer_np.3
man/man3/pthread_create.3
man/man3/qsort.3
man/man3/scandir.3
man/man3/sigset.3
man/man3/sysv_signal.3
man/man3/tsearch.3
man/man3type/sigevent.3type

index 88e79225716c59300e8ef2cc8cbf96a7c2d216a7..9428a56450c101bdeecb36b7c70944d91706e89b 100644 (file)
@@ -51,12 +51,13 @@ Standard C library
 .B #define _GNU_SOURCE
 .B #include <sched.h>
 .P
-.BI "int clone(int (*" "fn" ")(void *_Nullable), void *" stack \
-", int " flags ,
-.BI "          void *_Nullable " "arg" ", ..." \
-"  \fR/*\fP" " pid_t *_Nullable " parent_tid ,
-.BI "                                       void *_Nullable " tls ,
-.BI "                                       pid_t *_Nullable " child_tid " \fR*/\fP );"
+.BI "int clone(typeof(int (void *_Nullable)) *" fn ,
+.BI "          void *" stack ,
+.BI "          int " flags ,
+.BI "          void *_Nullable " arg ", ..."
+.BI "          \f[R]/*\f[] pid_t *_Nullable " parent_tid ,
+.BI "             void *_Nullable " tls ,
+.BI "             pid_t *_Nullable " child_tid " \f[R]*/\f[] );"
 .P
 /* For the prototype of the raw clone() system call, see VERSIONS. */
 .P
index 22526e94203c2a4e3bc1fe4ae65cef5cbfce1017..b4ac3922a79861e5b34e933d4b52c422a2a478c1 100644 (file)
@@ -23,7 +23,7 @@ Standard C library
 .nf
 .B #include <signal.h>
 .P
-.B typedef void (*sighandler_t)(int);
+.B "typedef typeof(void (int))  *sighandler_t;"
 .P
 .BI "sighandler_t signal(int " signum ", sighandler_t " handler );
 .fi
index ab2e916f717a5663abff790dfab5b8e73c9a8f49..f35d268074b7b5f7603e3943f0dd5a0a2d7f9783 100644 (file)
@@ -21,7 +21,7 @@ Standard C library
 .nf
 .B #include <stdlib.h>
 .P
-.BI "int atexit(void (*" function )(void));
+.BI "int atexit(typeof(void (void)) *" function );
 .fi
 .SH DESCRIPTION
 The
index 0f859f908c82ac4de93e2810ec004daed8515837..face18609bea1aca8bfecdb68c431d91f046633d 100644 (file)
@@ -13,7 +13,7 @@ Standard C library
 .nf
 .B #include <signal.h>
 .P
-.B typedef void (*sighandler_t)(int);
+.B "typedef typeof(void (int))  *sighandler_t;"
 .P
 .BI "sighandler_t bsd_signal(int " signum ", sighandler_t " handler );
 .fi
index 23e864c5c4e6cce00a82ca6c444d336c73858172..40c719e36b56d25fdd9f9c9079593bdc0b809d00 100644 (file)
@@ -22,8 +22,8 @@ Standard C library
 .BI "void *bsearch(const void " key [. size "], \
 const void " base [. size " * ." n ],
 .BI "              size_t " n ", size_t " size ,
-.BI "              int (*" compar ")(const void [." size "], \
-const void [." size ]));
+.BI "              typeof(int (const void [." size "], const void [." size ]))
+.BI "                  *" compar );
 .fi
 .SH DESCRIPTION
 The
index c19b3172a53e7be8c68ea761025f3dcbe7048878..082a130cf14b91ef413ab9b6f47da170feca6d69 100644 (file)
@@ -15,9 +15,9 @@ Standard C library
 .B #include <link.h>
 .P
 .B int dl_iterate_phdr(
-.BI "          int (*" callback ")(struct dl_phdr_info *" info ,
-.BI "                          size_t " size ", void *" data ),
-.BI "          void *" data );
+.BI "         typeof(int (struct dl_phdr_info *" info ", size_t " size ", void *" data ))
+.BI "             *" callback ,
+.BI "         void *" data );
 .fi
 .SH DESCRIPTION
 The
index 44853d1d3fef0c08de87e72e7513eee792611245..0e081560e56219a11db1712464decf3196b0b9bb 100644 (file)
@@ -43,7 +43,7 @@ Standard C library
 .BI "extern unsigned int " error_message_count ;
 .BI "extern int " error_one_per_line ;
 .P
-.BI "extern void (*" error_print_progname ")(void);"
+.BI "extern typeof(void (void))  *" error_print_progname ;
 .fi
 .SH DESCRIPTION
 .BR error ()
index 7c3f085955a6ecae3dfc1a80739e3106d7b9b859..c2f2dd5b28c3447cc8b7edbc8fbd487924cacf71 100644 (file)
@@ -24,7 +24,8 @@ Standard C library
 .B #include <fts.h>
 .P
 .BI "FTS *fts_open(char *const *" path_argv ", int " options ,
-.BI "              int (*_Nullable " compar ")(const FTSENT **, const FTSENT **));"
+.B  "              typeof(int (const FTSENT **, const FTSENT **))"
+.BI "                  *_Nullable " compar );
 .P
 .BI "FTSENT *fts_read(FTS *" ftsp );
 .P
index f2d45233fbe6f268cc70622bc05446d232baf027..71d6bd40b7245b850c44c1e13efd494873767e8a 100644 (file)
@@ -26,14 +26,16 @@ Standard C library
 .B #include <ftw.h>
 .P
 .BI "int nftw(const char *" dirpath ,
-.BI "        int (*" fn ")(const char *" fpath ", const struct stat *" sb ,
-.BI "                  int " typeflag ", struct FTW *" ftwbuf ),
+.BI "        typeof(int (const char *" fpath ", const struct stat *" sb,
+.BI "                    int " typeflag ", struct FTW *" ftwbuf ))
+.BI "            *" fn,
 .BI "        int " nopenfd ", int " flags );
 .P
 .B [[deprecated]]
 .BI "int ftw(const char *" dirpath ,
-.BI "        int (*" fn ")(const char *" fpath ", const struct stat *" sb ,
-.BI "                  int " typeflag ),
+.BI "        typeof(int (const char *" fpath ", const struct stat *" sb ,
+.BI "                    int " typeflag ))
+.BI "            *" fn,
 .BI "        int " nopenfd );
 .fi
 .P
index 42d4cbc87ec77330e964b36546f0fcfdb72802e0..d1a916f9e045c2c0d65e5021a1710b0e45f9b3e5 100644 (file)
@@ -23,7 +23,7 @@ Standard C library
 .B #include <glob.h>
 .P
 .BI "int glob(const char *restrict " pattern ", int " flags ,
-.BI "         int (*" errfunc ")(const char *" epath ", int " eerrno ),
+.BI "         typeof(int (const char *" epath ", int " eerrno ")) *" errfunc ,
 .BI "         glob_t *restrict " pglob );
 .BI "void globfree(glob_t *" pglob );
 .fi
index d87d9e4946ffd9ebe96536eed76d7c2bd13a2cab..5422945d36d0936461d7c1f5385b0b05af693cc2 100644 (file)
@@ -15,7 +15,7 @@ Standard C library
 .nf
 .B #include <signal.h>
 .P
-.B typedef void (*sighandler_t)(int);
+.B "typedef typeof(void (int))  *sighandler_t;"
 .P
 .BI "[[deprecated]] int gsignal(int " signum );
 .P
index dc18d8bf855b3d035c3ce0fa35fe3c9ad5cc372d..0dfda7bd420a5975e4f15bf440dafb0b34903121 100644 (file)
@@ -17,13 +17,13 @@ Standard C library
 .BI "void *lfind(const void " key [. size "], \
 const void " base [*. n " * ." size ],
 .BI "            size_t *" n ", size_t " size ,
-.BI "            int(*" compar ")(const void [." size "], \
-const void [." size ]));
+.BI "            typeof(int (const void [." size "], const void [." size ]))
+.BI "                *" compar );
 .BI "void *lsearch(const void " key [. size "], \
 void " base [*. n " * ." size ],
 .BI "            size_t *" n ", size_t " size ,
-.BI "            int(*" compar ")(const void [." size "], \
-const void [." size ]));
+.BI "            typeof(int (const void [." size "], const void [." size ]))
+.BI "                *" compar );
 .fi
 .SH DESCRIPTION
 .BR lfind ()
index 24cf78d7053c03e457edffa9ac71c91271c35c94..45009a7a6cc4031e00ef755b6f446dbac51dd04e 100644 (file)
@@ -16,7 +16,7 @@ Standard C library
 .nf
 .B #include <ucontext.h>
 .P
-.BI "void makecontext(ucontext_t *" ucp ", void (*" func ")(int " arg0 ", ...),"
+.BI "void makecontext(ucontext_t *" ucp ", typeof(void (int " arg0 ", ...)) *" func ,
 .BI "                 int " argc ", ...);"
 .BI "int swapcontext(ucontext_t *restrict " oucp ,
 .BI "                 const ucontext_t *restrict " ucp );
index ea50328afc7634306f85f987c31305b50312b83a..afb253ea2620b99caa5ebc303a45b0e0ab55c934 100644 (file)
@@ -17,19 +17,20 @@ Standard C library
 .nf
 .B "#include <malloc.h>"
 .P
-.BI "void *(*volatile __malloc_hook)(size_t " size ", const void *" caller );
+.BI "typeof(void *(size_t " size ", const void *" caller ))
+.B  "    *volatile  __malloc_hook;"
 .P
-.BI "void *(*volatile __realloc_hook)(void *" ptr ", size_t " size ,
-.BI "                         const void *" caller );
+.BI "typeof(void *(void *" p ", size_t " size ", const void *" caller ))
+.B  "    *volatile  __realloc_hook;"
 .P
-.BI "void *(*volatile __memalign_hook)(size_t " alignment ", size_t " size ,
-.BI "                         const void *" caller );
+.BI "typeof(void *(size_t " align ", size_t " size ", const void *" caller ))
+.B  "    *volatile  __memalign_hook;"
 .P
-.BI "void (*volatile __free_hook)(void *" ptr ", const void *" caller );
+.BI "typeof(void *(void *" p ", const void *" caller ))
+.B  "    *volatile  __free_hook;"
 .P
-.B "void (*__malloc_initialize_hook)(void);"
-.P
-.B "void (*volatile __after_morecore_hook)(void);"
+.B "typeof(void (void))            *__malloc_initialize_hook;"
+.B "typeof(void (void)) *volatile   __after_mrecore_hook;"
 .fi
 .SH DESCRIPTION
 The GNU C library lets you modify the behavior of
index bd9816bc69e3c0a4877412f98ba5190b761cba64..6e87cbe1f1036d3065fbc0ee29a398ddddd73a7f 100644 (file)
@@ -13,8 +13,9 @@ Standard C library
 .nf
 .B #include <mcheck.h>
 .P
-.BI "int mcheck(void (*" abortfunc ")(enum mcheck_status " mstatus ));
-.BI "int mcheck_pedantic(void (*" abortfunc ")(enum mcheck_status " mstatus ));
+.BI "int mcheck(typeof(void (enum mcheck_status " mstatus ")) *" abortfunc );
+.B  "int mcheck_pedantic("
+.BI "           typeof(void (enum mcheck_status " mstatus ")) *" abortfunc );
 .B void mcheck_check_all(void);
 .P
 .BI "enum mcheck_status mprobe(void *" ptr );
index f2e19a06da2106a18ceb25b297031291b019fd10..ef2d0ede6c31d1a5e9baf15b7fd76aa6d6915b45 100644 (file)
@@ -20,8 +20,9 @@ Standard C library
 .BI "MPOOL *mpool_open(DBT *" key ", int " fd ", pgno_t " pagesize \
 ", pgno_t " maxcache );
 .P
-.BI "void mpool_filter(MPOOL *" mp ", void (*pgin)(void *, pgno_t, void *),"
-.BI "                  void (*" pgout ")(void *, pgno_t, void *),"
+.BI "void mpool_filter(MPOOL *" mp ,
+.BI "                  typeof(void (void *, pgno_t, void *)) *" pgin ,
+.BI "                  typeof(void (void *, pgno_t, void *)) *" pgout ,
 .BI "                  void *" pgcookie );
 .P
 .BI "void *mpool_new(MPOOL *" mp ", pgno_t *" pgnoaddr );
index 22bbb2c6f0e7a1fbbaa1477349ec1711a758c142..38df621e460813ae94b3fa1290e15b8793a425e5 100644 (file)
@@ -19,7 +19,7 @@ Standard C library
 .nf
 .B #include <stdlib.h>
 .P
-.BI "int on_exit(void (*" function ")(int, void *), void *" arg );
+.BI "int on_exit(typeof(void (int, void *)) *" function ", void *" arg );
 .fi
 .P
 .RS -4
index 156f565ddccd4f89e7caac8531819308c39c0c41..2f2cbfe23fbd387cc96106e61b990542f24bab89 100644 (file)
@@ -12,8 +12,9 @@ POSIX threads library
 .nf
 .B  #include <pthread.h>
 .P
-.BI "int pthread_atfork(void (*" prepare ")(void), void (*" parent ")(void),"
-.BI "                   void (*" child ")(void));"
+.BI "int pthread_atfork(typeof(void (void)) *" prepare ,
+.BI "                   typeof(void (void)) *" parent ,
+.BI "                   typeof(void (void)) *" child );
 .fi
 .SH DESCRIPTION
 The
index d5fd39486b516cb092e4c46c5976357ec11c871c..6cc80cd2285875e4820b105d998d991e9ad86924 100644 (file)
@@ -15,7 +15,7 @@ POSIX threads library
 .nf
 .B #include <pthread.h>
 .P
-.BI "void pthread_cleanup_push(void (*" routine ")(void *), void *" arg );
+.BI "void pthread_cleanup_push(typeof(void (void *)) *" routine ", void *" arg );
 .BI "void pthread_cleanup_pop(int " execute );
 .fi
 .SH DESCRIPTION
index 3535f01f886af40aa825ba3a4bdc2020e61e5dd3..6c69a34fc1aa71f0e5dbffa83dacac72d689b38b 100644 (file)
@@ -14,7 +14,8 @@ POSIX threads library
 .nf
 .B #include <pthread.h>
 .P
-.BI "void pthread_cleanup_push_defer_np(void (*" routine ")(void *), void *" arg );
+.BI "void pthread_cleanup_push_defer_np(typeof(void (void *)) *" routine ,
+.BI "                                   void *" arg );
 .BI "void pthread_cleanup_pop_restore_np(int " execute );
 .fi
 .P
index 96c229e7e6ece960b72621333de78d97197792ed..22926990edfbd47057827ceae195cc4fcebe3ef3 100644 (file)
@@ -16,7 +16,7 @@ POSIX threads library
 .P
 .BI "int pthread_create(pthread_t *restrict " thread ,
 .BI "                   const pthread_attr_t *restrict " attr ,
-.BI "                   void *(*" start_routine ")(void *),"
+.BI "                   typeof(void *(void *)) *" start_routine ,
 .BI "                   void *restrict " arg );
 .fi
 .SH DESCRIPTION
index 2ff1d3d32200e6b11d28540df646c8bcd40fecac..afc56082430e6a2f1bd10f8268f01e0042c448a6 100644 (file)
@@ -27,12 +27,12 @@ Standard C library
 .P
 .BI "void qsort(void " base [. size " * ." n "], size_t " n ", \
 size_t " size ,
-.BI "           int (*" compar ")(const void [." size "], \
-const void [." size ]));
+.BI "           typeof(int (const void [." size "], const void [." size "]))"
+.BI "               *" compar );
 .BI "void qsort_r(void " base [. size " * ." n "], size_t " n ", \
 size_t " size ,
-.BI "           int (*" compar ")(const void [." size "], \
-const void [." size "], void *),"
+.BI "           typeof(int (const void [." size "], const void [." size "], void *))"
+.BI "               *" compar ,
 .BI "           void *" arg ");"
 .fi
 .P
index 8e1833fdc67dbd8b2d5fdb19c89c0932cd7ae6fc..04793faba3c8386bf6fa400b57b002dfe3d7161c 100644 (file)
@@ -34,9 +34,9 @@ Standard C library
 .P
 .BI "int scandir(const char *restrict " dirp ,
 .BI "            struct dirent ***restrict " namelist ,
-.BI "            int (*" filter ")(const struct dirent *),"
-.BI "            int (*" compar ")(const struct dirent **,"
-.B "                          const struct dirent **));"
+.BI "            typeof(int (const struct dirent *)) *" filter ,
+.B  "            typeof(int (const struct dirent **, const struct dirent **))"
+.BI "                *" compar );
 .P
 .BI "int alphasort(const struct dirent **" a ", const struct dirent **" b );
 .BI "int versionsort(const struct dirent **" a ", const struct dirent **" b );
@@ -46,9 +46,9 @@ Standard C library
 .P
 .BI "int scandirat(int " dirfd ", const char *restrict " dirp ,
 .BI "            struct dirent ***restrict " namelist ,
-.BI "            int (*" filter ")(const struct dirent *),"
-.BI "            int (*" compar ")(const struct dirent **,"
-.B "                          const struct dirent **));"
+.BI "            typeof(int (const struct dirent *)) *" filter ,
+.B  "            typeof(int (const struct dirent **, const struct dirent **))"
+.BI "                *" compar );
 .fi
 .P
 .RS -4
index c5be34d51d3ae9eec72a95974991b47180c7935f..3495373cf0089c4c414faf4b27f25145f11241e5 100644 (file)
@@ -13,7 +13,7 @@ Standard C library
 .nf
 .B #include <signal.h>
 .P
-.B typedef void (*sighandler_t)(int);
+.B "typedef typeof(void (int))  *sighandler_t;"
 .P
 .BI "[[deprecated]] sighandler_t sigset(int " sig ", sighandler_t " disp );
 .P
index 27bb179f67a15ee472bc99b859112a200fb0a9b3..c51a64598b676794acde90c18e4ae825488d4f1e 100644 (file)
@@ -14,7 +14,7 @@ Standard C library
 .BR "#define _GNU_SOURCE" "         /* See feature_test_macros(7) */"
 .B #include <signal.h>
 .P
-.B typedef void (*sighandler_t)(int);
+.B "typedef typeof(void (int))  *sighandler_t;"
 .P
 .BI "sighandler_t sysv_signal(int " signum ", sighandler_t " handler );
 .fi
index cec543f5fa587b99a68866bc829537c90ff41ca7..f314461f29bd3961fc2a7b8dfe5db47cdbfaf55c 100644 (file)
@@ -15,24 +15,25 @@ Standard C library
 .P
 .B typedef enum { preorder, postorder, endorder, leaf } VISIT;
 .P
-.BI "void *tsearch(const void *" key ", void **" rootp ,
-.BI "                int (*" compar ")(const void *, const void *));"
 .BI "void *tfind(const void *" key ", void *const *" rootp ,
-.BI "                int (*" compar ")(const void *, const void *));"
+.BI "            typeof(int (const void *, const void *)) *" compar );
+.BI "void *tsearch(const void *" key ", void **" rootp ,
+.BI "            typeof(int (const void *, const void *)) *" compar );
 .BI "void *tdelete(const void *restrict " key ", void **restrict " rootp ,
-.BI "                int (*" compar ")(const void *, const void *));"
+.BI "            typeof(int (const void *, const void *)) *" compar );
 .BI "void twalk(const void *" root ,
-.BI "                void (*" action ")(const void *" nodep ", VISIT " which ,
-.BI "                               int " depth ));
+.BI "            typeof(void (const void *" nodep ", VISIT " which ", int " depth ))
+.BI "                *" action );
 .P
 .BR "#define _GNU_SOURCE" "         /* See feature_test_macros(7) */"
 .B #include <search.h>
 .P
 .BI "void twalk_r(const void *" root ,
-.BI "                void (*" action ")(const void *" nodep ", VISIT " which ,
-.BI "                               void *" closure ),
-.BI "                void *" closure );
-.BI "void tdestroy(void *" root ", void (*" free_node ")(void *" nodep ));
+.BI "            typeof(void (const void *" nodep ", VISIT " which ", void *" closure ))
+.BI "                *" action ,
+.BI "            void *" closure );
+.BI "void tdestroy(void *" root ,
+.BI "            typeof(void (void *" nodep ")) *" free_node );
 .fi
 .SH DESCRIPTION
 .BR tsearch (),
index 01ca76620f19dd4b5376b4d37db24106d1fad58d..f3f66a8c292d0a3936297782972eeb9d3387396a 100644 (file)
@@ -16,7 +16,7 @@ sigevent, sigval \- structure for notification from asynchronous routines
 .BR "    int             sigev_signo;" "   /* Signal number */"
 .BR "    union sigval    sigev_value;" "   /* Data passed with notification */"
 \&
-.B  "    void          (*sigev_notify_function)(union sigval);"
+.B  "    typeof(void (union sigval))  *sigev_notify_function;"
 .BR "                                " "   /* Notification function"
 .BR "                                " "      (SIGEV_THREAD) */"
 .B  "    pthread_attr_t *sigev_notify_attributes;"