summaryrefslogtreecommitdiff
path: root/lib/pthread.in.h
diff options
context:
space:
mode:
authorBruno Haible <bruno@clisp.org>2020-02-22 20:57:30 +0100
committerBruno Haible <bruno@clisp.org>2020-02-22 23:47:59 +0100
commit182afcba2635cbff91240656c7fb3742dd23ab6f (patch)
tree127b2f7f6ce012a80623c59627c7309db4df3c53 /lib/pthread.in.h
parent0f3fc07d96e8ac1cea19d7e3200b57b03bbc8013 (diff)
downloadgnulib-182afcba2635cbff91240656c7fb3742dd23ab6f.tar.gz
Use 'restrict' in all POSIX function declarations.
* lib/iconv.in.h (iconv): Use 'restrict'. * lib/inttypes.in.h (strtoimax, strtoumax): Likewise. * lib/monetary.in.h (strfmon_l): Likewise. * lib/pthread.in.h (pthread_create, pthread_mutex_init, pthread_mutexattr_gettype, pthread_mutexattr_getrobust, pthread_mutex_timedlock, pthread_rwlock_init, pthread_rwlock_timedrdlock, pthread_rwlock_timedwrlock, pthread_cond_init, pthread_cond_wait, pthread_cond_timedwait): Likewise. * lib/search.in.h (tdelete): Likewise. * lib/signal.in.h (pthread_sigmask, sigprocmask): Likewise. * lib/stdio.in.h (dprintf, fgets, fopen, fprintf, fputs, fread, freopen, fscanf, fwrite, getdelim, getline, printf, scanf, snprintf, sprintf, vdprintf, vfprintf, vfscanf, vprintf, vscanf, vsnprintf, vsprintf): Likewise. * lib/stdlib.in.h (mbtowc, realpath, strtod, strtold, strtoll, strtoull): Likewise. * lib/string.in.h (strncat): Likewise. * lib/sys_socket.in.h (accept, getpeername, getsockname, getsockopt, recvfrom): Likewise. * lib/sys_stat.in.h (fstatat, lstat, stat): Likewise. * lib/time.in.h (strftime): Likewise. * lib/unistd.in.h (readlink, readlinkat): Likewise. * lib/wchar.in.h (mbrtowc, mbrlen, mbsrtowcs, mbsnrtowcs, wcrtomb, wcsrtombs, wcsnrtombs, wmemcpy, wcscpy, wcpcpy, wcsncpy, wcpncpy, wcscat, wcsncat, wcsxfrm, wcsstr, wcstok, wcsftime): Likewise. * m4/iconv_h.m4 (gl_ICONV_H): Require AC_C_RESTRICT. * m4/inttypes.m4 (gl_INTTYPES_INCOMPLETE): Likewise. * m4/monetary_h.m4 (gl_MONETARY_H): Likewise. * m4/search_h.m4 (gl_SEARCH_H): Likewise. * m4/signal_h.m4 (gl_SIGNAL_H): Likewise. * m4/stdio_h.m4 (gl_STDIO_H): Likewise. * m4/stdlib_h.m4 (gl_STDLIB_H): Likewise. * m4/sys_socket_h.m4 (gl_HEADER_SYS_SOCKET): Likewise. * m4/sys_stat_h.m4 (gl_HEADER_SYS_STAT_H): Likewise. * m4/unistd_h.m4 (gl_UNISTD_H): Likewise. * m4/wchar_h.m4 (gl_WCHAR_H): Likewise. * m4/string_h.m4 (gl_HEADER_STRING_H_BODY): Make consistent with the other *_h.m4 files. * m4/time_h.m4 (gl_HEADER_TIME_H): Likewise.
Diffstat (limited to 'lib/pthread.in.h')
-rw-r--r--lib/pthread.in.h150
1 files changed, 98 insertions, 52 deletions
diff --git a/lib/pthread.in.h b/lib/pthread.in.h
index 8f1f13c101..0f743ca474 100644
--- a/lib/pthread.in.h
+++ b/lib/pthread.in.h
@@ -449,28 +449,34 @@ typedef unsigned int pthread_barrierattr_t;
/* =========== Thread functions =========== */
#if @GNULIB_PTHREAD_THREAD@
+/* The 'restrict' qualifier on ARG is nonsense, but POSIX specifies it this way.
+ Sigh. */
# if @REPLACE_PTHREAD_CREATE@
# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
# undef pthread_create
# define pthread_create rpl_pthread_create
# endif
_GL_FUNCDECL_RPL (pthread_create, int,
- (pthread_t *threadp, const pthread_attr_t *attr,
- void * (*mainfunc) (void *), void *arg)
+ (pthread_t *restrict threadp,
+ const pthread_attr_t *restrict attr,
+ void * (*mainfunc) (void *), void *restrict arg)
_GL_ARG_NONNULL ((1, 3)));
_GL_CXXALIAS_RPL (pthread_create, int,
- (pthread_t *threadp, const pthread_attr_t *attr,
- void * (*mainfunc) (void *), void *arg));
+ (pthread_t *restrict threadp,
+ const pthread_attr_t *restrict attr,
+ void * (*mainfunc) (void *), void *restrict arg));
# else
# if !@HAVE_PTHREAD_CREATE@
_GL_FUNCDECL_SYS (pthread_create, int,
- (pthread_t *threadp, const pthread_attr_t *attr,
- void * (*mainfunc) (void *), void *arg)
+ (pthread_t *restrict threadp,
+ const pthread_attr_t *restrict attr,
+ void * (*mainfunc) (void *), void *restrict arg)
_GL_ARG_NONNULL ((1, 3)));
# endif
_GL_CXXALIAS_SYS_CAST (pthread_create, int,
- (pthread_t *threadp, const pthread_attr_t *attr,
- void * (*mainfunc) (void *), void *arg));
+ (pthread_t *restrict threadp,
+ const pthread_attr_t *restrict attr,
+ void * (*mainfunc) (void *), void *restrict arg));
# endif
_GL_CXXALIASWARN (pthread_create);
#elif defined GNULIB_POSIXCHECK
@@ -746,18 +752,22 @@ _GL_WARN_ON_USE (pthread_once, "pthread_once is not portable - "
# define pthread_mutex_init rpl_pthread_mutex_init
# endif
_GL_FUNCDECL_RPL (pthread_mutex_init, int,
- (pthread_mutex_t *mutex, const pthread_mutexattr_t *attr)
+ (pthread_mutex_t *restrict mutex,
+ const pthread_mutexattr_t *restrict attr)
_GL_ARG_NONNULL ((1)));
_GL_CXXALIAS_RPL (pthread_mutex_init, int,
- (pthread_mutex_t *mutex, const pthread_mutexattr_t *attr));
+ (pthread_mutex_t *restrict mutex,
+ const pthread_mutexattr_t *restrict attr));
# else
# if !@HAVE_PTHREAD_MUTEX_INIT@
_GL_FUNCDECL_SYS (pthread_mutex_init, int,
- (pthread_mutex_t *mutex, const pthread_mutexattr_t *attr)
+ (pthread_mutex_t *restrict mutex,
+ const pthread_mutexattr_t *restrict attr)
_GL_ARG_NONNULL ((1)));
# endif
_GL_CXXALIAS_SYS (pthread_mutex_init, int,
- (pthread_mutex_t *mutex, const pthread_mutexattr_t *attr));
+ (pthread_mutex_t *restrict mutex,
+ const pthread_mutexattr_t *restrict attr));
# endif
_GL_CXXALIASWARN (pthread_mutex_init);
#elif defined GNULIB_POSIXCHECK
@@ -800,20 +810,24 @@ _GL_WARN_ON_USE (pthread_mutexattr_init, "pthread_mutexattr_init is not portable
# define pthread_mutexattr_gettype rpl_pthread_mutexattr_gettype
# endif
_GL_FUNCDECL_RPL (pthread_mutexattr_gettype, int,
- (const pthread_mutexattr_t *attr, int *typep)
+ (const pthread_mutexattr_t *restrict attr,
+ int *restrict typep)
_GL_ARG_NONNULL ((1, 2)));
_GL_CXXALIAS_RPL (pthread_mutexattr_gettype, int,
- (const pthread_mutexattr_t *attr, int *typep));
+ (const pthread_mutexattr_t *restrict attr,
+ int *restrict typep));
# else
# if !@HAVE_PTHREAD_MUTEXATTR_GETTYPE@
_GL_FUNCDECL_SYS (pthread_mutexattr_gettype, int,
- (const pthread_mutexattr_t *attr, int *typep)
+ (const pthread_mutexattr_t *restrict attr,
+ int *restrict typep)
_GL_ARG_NONNULL ((1, 2)));
# endif
/* Need to cast, because on FreeBSD the first parameter is
pthread_mutexattr_t *attr. */
_GL_CXXALIAS_SYS_CAST (pthread_mutexattr_gettype, int,
- (const pthread_mutexattr_t *attr, int *typep));
+ (const pthread_mutexattr_t *restrict attr,
+ int *restrict typep));
# endif
_GL_CXXALIASWARN (pthread_mutexattr_gettype);
#elif defined GNULIB_POSIXCHECK
@@ -858,20 +872,24 @@ _GL_WARN_ON_USE (pthread_mutexattr_settype, "pthread_mutexattr_settype is not po
# define pthread_mutexattr_getrobust rpl_pthread_mutexattr_getrobust
# endif
_GL_FUNCDECL_RPL (pthread_mutexattr_getrobust, int,
- (const pthread_mutexattr_t *attr, int *robustp)
+ (const pthread_mutexattr_t *restrict attr,
+ int *restrict robustp)
_GL_ARG_NONNULL ((1, 2)));
_GL_CXXALIAS_RPL (pthread_mutexattr_getrobust, int,
- (const pthread_mutexattr_t *attr, int *robustp));
+ (const pthread_mutexattr_t *restrict attr,
+ int *restrict robustp));
# else
# if !@HAVE_PTHREAD_MUTEXATTR_GETROBUST@
_GL_FUNCDECL_SYS (pthread_mutexattr_getrobust, int,
- (const pthread_mutexattr_t *attr, int *robustp)
+ (const pthread_mutexattr_t *restrict attr,
+ int *restrict robustp)
_GL_ARG_NONNULL ((1, 2)));
# endif
/* Need to cast, because on FreeBSD the first parameter is
pthread_mutexattr_t *attr. */
_GL_CXXALIAS_SYS_CAST (pthread_mutexattr_getrobust, int,
- (const pthread_mutexattr_t *attr, int *robustp));
+ (const pthread_mutexattr_t *restrict attr,
+ int *restrict robustp));
# endif
# if __GLIBC__ >= 2
_GL_CXXALIASWARN (pthread_mutexattr_getrobust);
@@ -999,18 +1017,22 @@ _GL_WARN_ON_USE (pthread_mutex_trylock, "pthread_mutex_trylock is not portable -
# define pthread_mutex_timedlock rpl_pthread_mutex_timedlock
# endif
_GL_FUNCDECL_RPL (pthread_mutex_timedlock, int,
- (pthread_mutex_t *mutex, const struct timespec *abstime)
+ (pthread_mutex_t *restrict mutex,
+ const struct timespec *restrict abstime)
_GL_ARG_NONNULL ((1, 2)));
_GL_CXXALIAS_RPL (pthread_mutex_timedlock, int,
- (pthread_mutex_t *mutex, const struct timespec *abstime));
+ (pthread_mutex_t *restrict mutex,
+ const struct timespec *restrict abstime));
# else
# if !@HAVE_PTHREAD_MUTEX_TIMEDLOCK@
_GL_FUNCDECL_SYS (pthread_mutex_timedlock, int,
- (pthread_mutex_t *mutex, const struct timespec *abstime)
+ (pthread_mutex_t *restrict mutex,
+ const struct timespec *restrict abstime)
_GL_ARG_NONNULL ((1, 2)));
# endif
_GL_CXXALIAS_SYS (pthread_mutex_timedlock, int,
- (pthread_mutex_t *mutex, const struct timespec *abstime));
+ (pthread_mutex_t *restrict mutex,
+ const struct timespec *restrict abstime));
# endif
_GL_CXXALIASWARN (pthread_mutex_timedlock);
#elif defined GNULIB_POSIXCHECK
@@ -1080,18 +1102,22 @@ _GL_WARN_ON_USE (pthread_mutex_destroy, "pthread_mutex_destroy is not portable -
# define pthread_rwlock_init rpl_pthread_rwlock_init
# endif
_GL_FUNCDECL_RPL (pthread_rwlock_init, int,
- (pthread_rwlock_t *lock, const pthread_rwlockattr_t *attr)
+ (pthread_rwlock_t *restrict lock,
+ const pthread_rwlockattr_t *restrict attr)
_GL_ARG_NONNULL ((1)));
_GL_CXXALIAS_RPL (pthread_rwlock_init, int,
- (pthread_rwlock_t *lock, const pthread_rwlockattr_t *attr));
+ (pthread_rwlock_t *restrict lock,
+ const pthread_rwlockattr_t *restrict attr));
# else
# if !@HAVE_PTHREAD_RWLOCK_INIT@
_GL_FUNCDECL_SYS (pthread_rwlock_init, int,
- (pthread_rwlock_t *lock, const pthread_rwlockattr_t *attr)
+ (pthread_rwlock_t *restrict lock,
+ const pthread_rwlockattr_t *restrict attr)
_GL_ARG_NONNULL ((1)));
# endif
_GL_CXXALIAS_SYS (pthread_rwlock_init, int,
- (pthread_rwlock_t *lock, const pthread_rwlockattr_t *attr));
+ (pthread_rwlock_t *restrict lock,
+ const pthread_rwlockattr_t *restrict attr));
# endif
_GL_CXXALIASWARN (pthread_rwlock_init);
#elif defined GNULIB_POSIXCHECK
@@ -1261,18 +1287,22 @@ _GL_WARN_ON_USE (pthread_rwlock_trywrlock, "pthread_rwlock_trywrlock is not port
# define pthread_rwlock_timedrdlock rpl_pthread_rwlock_timedrdlock
# endif
_GL_FUNCDECL_RPL (pthread_rwlock_timedrdlock, int,
- (pthread_rwlock_t *lock, const struct timespec *abstime)
+ (pthread_rwlock_t *restrict lock,
+ const struct timespec *restrict abstime)
_GL_ARG_NONNULL ((1, 2)));
_GL_CXXALIAS_RPL (pthread_rwlock_timedrdlock, int,
- (pthread_rwlock_t *lock, const struct timespec *abstime));
+ (pthread_rwlock_t *restrict lock,
+ const struct timespec *restrict abstime));
# else
# if !@HAVE_PTHREAD_RWLOCK_TIMEDRDLOCK@
_GL_FUNCDECL_SYS (pthread_rwlock_timedrdlock, int,
- (pthread_rwlock_t *lock, const struct timespec *abstime)
+ (pthread_rwlock_t *restrict lock,
+ const struct timespec *restrict abstime)
_GL_ARG_NONNULL ((1, 2)));
# endif
_GL_CXXALIAS_SYS (pthread_rwlock_timedrdlock, int,
- (pthread_rwlock_t *lock, const struct timespec *abstime));
+ (pthread_rwlock_t *restrict lock,
+ const struct timespec *restrict abstime));
# endif
_GL_CXXALIASWARN (pthread_rwlock_timedrdlock);
#elif defined GNULIB_POSIXCHECK
@@ -1290,18 +1320,22 @@ _GL_WARN_ON_USE (pthread_rwlock_timedrdlock, "pthread_rwlock_timedrdlock is not
# define pthread_rwlock_timedwrlock rpl_pthread_rwlock_timedwrlock
# endif
_GL_FUNCDECL_RPL (pthread_rwlock_timedwrlock, int,
- (pthread_rwlock_t *lock, const struct timespec *abstime)
+ (pthread_rwlock_t *restrict lock,
+ const struct timespec *restrict abstime)
_GL_ARG_NONNULL ((1, 2)));
_GL_CXXALIAS_RPL (pthread_rwlock_timedwrlock, int,
- (pthread_rwlock_t *lock, const struct timespec *abstime));
+ (pthread_rwlock_t *restrict lock,
+ const struct timespec *restrict abstime));
# else
# if !@HAVE_PTHREAD_RWLOCK_TIMEDWRLOCK@
_GL_FUNCDECL_SYS (pthread_rwlock_timedwrlock, int,
- (pthread_rwlock_t *lock, const struct timespec *abstime)
+ (pthread_rwlock_t *restrict lock,
+ const struct timespec *restrict abstime)
_GL_ARG_NONNULL ((1, 2)));
# endif
_GL_CXXALIAS_SYS (pthread_rwlock_timedwrlock, int,
- (pthread_rwlock_t *lock, const struct timespec *abstime));
+ (pthread_rwlock_t *restrict lock,
+ const struct timespec *restrict abstime));
# endif
_GL_CXXALIASWARN (pthread_rwlock_timedwrlock);
#elif defined GNULIB_POSIXCHECK
@@ -1371,18 +1405,22 @@ _GL_WARN_ON_USE (pthread_rwlock_destroy, "pthread_rwlock_destroy is not portable
# define pthread_cond_init rpl_pthread_cond_init
# endif
_GL_FUNCDECL_RPL (pthread_cond_init, int,
- (pthread_cond_t *cond, const pthread_condattr_t *attr)
+ (pthread_cond_t *restrict cond,
+ const pthread_condattr_t *restrict attr)
_GL_ARG_NONNULL ((1)));
_GL_CXXALIAS_RPL (pthread_cond_init, int,
- (pthread_cond_t *cond, const pthread_condattr_t *attr));
+ (pthread_cond_t *restrict cond,
+ const pthread_condattr_t *restrict attr));
# else
# if !@HAVE_PTHREAD_COND_INIT@
_GL_FUNCDECL_SYS (pthread_cond_init, int,
- (pthread_cond_t *cond, const pthread_condattr_t *attr)
+ (pthread_cond_t *restrict cond,
+ const pthread_condattr_t *restrict attr)
_GL_ARG_NONNULL ((1)));
# endif
_GL_CXXALIAS_SYS (pthread_cond_init, int,
- (pthread_cond_t *cond, const pthread_condattr_t *attr));
+ (pthread_cond_t *restrict cond,
+ const pthread_condattr_t *restrict attr));
# endif
_GL_CXXALIASWARN (pthread_cond_init);
#elif defined GNULIB_POSIXCHECK
@@ -1450,18 +1488,22 @@ _GL_WARN_ON_USE (pthread_condattr_destroy, "pthread_condattr_destroy is not port
# define pthread_cond_wait rpl_pthread_cond_wait
# endif
_GL_FUNCDECL_RPL (pthread_cond_wait, int,
- (pthread_cond_t *cond, pthread_mutex_t *mutex)
+ (pthread_cond_t *restrict cond,
+ pthread_mutex_t *restrict mutex)
_GL_ARG_NONNULL ((1, 2)));
_GL_CXXALIAS_RPL (pthread_cond_wait, int,
- (pthread_cond_t *cond, pthread_mutex_t *mutex));
+ (pthread_cond_t *restrict cond,
+ pthread_mutex_t *restrict mutex));
# else
# if !@HAVE_PTHREAD_COND_WAIT@
_GL_FUNCDECL_SYS (pthread_cond_wait, int,
- (pthread_cond_t *cond, pthread_mutex_t *mutex)
+ (pthread_cond_t *restrict cond,
+ pthread_mutex_t *restrict mutex)
_GL_ARG_NONNULL ((1, 2)));
# endif
_GL_CXXALIAS_SYS (pthread_cond_wait, int,
- (pthread_cond_t *cond, pthread_mutex_t *mutex));
+ (pthread_cond_t *restrict cond,
+ pthread_mutex_t *restrict mutex));
# endif
_GL_CXXALIASWARN (pthread_cond_wait);
#elif defined GNULIB_POSIXCHECK
@@ -1479,22 +1521,26 @@ _GL_WARN_ON_USE (pthread_cond_wait, "pthread_cond_wait is not portable - "
# define pthread_cond_timedwait rpl_pthread_cond_timedwait
# endif
_GL_FUNCDECL_RPL (pthread_cond_timedwait, int,
- (pthread_cond_t *cond, pthread_mutex_t *mutex,
- const struct timespec *abstime)
+ (pthread_cond_t *restrict cond,
+ pthread_mutex_t *restrict mutex,
+ const struct timespec *restrict abstime)
_GL_ARG_NONNULL ((1, 2, 3)));
_GL_CXXALIAS_RPL (pthread_cond_timedwait, int,
- (pthread_cond_t *cond, pthread_mutex_t *mutex,
- const struct timespec *abstime));
+ (pthread_cond_t *restrict cond,
+ pthread_mutex_t *restrict mutex,
+ const struct timespec *restrict abstime));
# else
# if !@HAVE_PTHREAD_COND_TIMEDWAIT@
_GL_FUNCDECL_SYS (pthread_cond_timedwait, int,
- (pthread_cond_t *cond, pthread_mutex_t *mutex,
- const struct timespec *abstime)
+ (pthread_cond_t *restrict cond,
+ pthread_mutex_t *restrict mutex,
+ const struct timespec *restrict abstime)
_GL_ARG_NONNULL ((1, 2, 3)));
# endif
_GL_CXXALIAS_SYS (pthread_cond_timedwait, int,
- (pthread_cond_t *cond, pthread_mutex_t *mutex,
- const struct timespec *abstime));
+ (pthread_cond_t *restrict cond,
+ pthread_mutex_t *restrict mutex,
+ const struct timespec *restrict abstime));
# endif
_GL_CXXALIASWARN (pthread_cond_timedwait);
#elif defined GNULIB_POSIXCHECK