Skip to contentSkip to conversation

man3: SYNOPSIS: Use 'restrict' in prototypes (batch 4)

PATCH New Alejandro Colomar 1 participant 24 messages Mar 8, 2021 Man-pages: manual pages for Linux -- Sections 2, 3, 4, 5, and 7

lore
Share & tools
lore
#0 lore raw

cover man3: SYNOPSIS: Use 'restrict' in prototypes (batch 4)

Hi Michael,

This fixes up til scandir.3.
I hope there aren't many more left :)

Please have a special look at two of them, because you may prefer a different formatting. I'm referring to the previous email about "Formatting very long function parameters". The functions are pthread_mutexattr_getpshared(3) and another one which I don't remember (there are only 2, and as I've finished with pthread_*() I highly doubt there will be any more).

Cheers,

A

Alejandro Colomar (23):
pthread_attr_setschedpolicy.3: SYNOPSIS: Use 'restrict' in prototypes pthread_attr_setscope.3: SYNOPSIS: Use 'restrict' in prototypes pthread_attr_setstackaddr.3: SYNOPSIS: Use 'restrict' in prototypes pthread_attr_setstacksize.3: SYNOPSIS: Use 'restrict' in prototypes pthread_attr_setstack.3: SYNOPSIS: Use 'restrict' in prototypes pthread_create.3: SYNOPSIS: Use 'restrict' in prototypes pthread_getattr_default_np.3: SYNOPSIS: Add missing 'const' pthread_mutexattr_getpshared.3: SYNOPSIS: Use 'restrict' in prototypes pthread_mutexattr_setrobust.3: SYNOPSIS: Remove incorrect 'const' pthread_rwlockattr_setkind_np.3: SYNOPSIS: Use 'restrict' in
prototypes
pthread_setschedparam.3: SYNOPSIS: Use 'restrict' in prototypes putgrent.3: SYNOPSIS: Use 'restrict' in prototypes putpwent.3: SYNOPSIS: Use 'restrict' in prototypes
puts.3: SYNOPSIS: Use 'restrict' in prototypes
qecvt.3: SYNOPSIS: Use 'restrict' in prototypes random_r.3: SYNOPSIS: Use 'restrict' in prototypes
rcmd.3: SYNOPSIS: Use 'restrict' in prototypes readdir_r.3: SYNOPSIS: Use 'restrict' in prototypes realpath.3: SYNOPSIS: Use 'restrict' in prototypes regex.3: SYNOPSIS: Use 'restrict' in prototypes
rexec.3: SYNOPSIS: Use 'restrict' in prototypes
scandir.3: SYNOPSIS: Use 'restrict' in prototypes scandir.3: SYNOPSIS: Use 'restrict' in prototypes

 man3/pthread_attr_setschedpolicy.3   |  7 +++----
 man3/pthread_attr_setscope.3         |  7 +++----
 man3/pthread_attr_setstack.3         |  5 +++--
 man3/pthread_attr_setstackaddr.3     |  4 ++--
 man3/pthread_attr_setstacksize.3     |  4 ++--
 man3/pthread_create.3                |  6 ++++--
 man3/pthread_getattr_default_np.3    |  2 +-
 man3/pthread_mutexattr_getpshared.3  |  7 ++++---
 man3/pthread_mutexattr_setrobust.3   |  2 +-
 man3/pthread_rwlockattr_setkind_np.3 |  7 ++++---
 man3/pthread_setschedparam.3         |  4 ++--
 man3/putgrent.3                      |  3 ++-
 man3/putpwent.3                      |  3 ++-
 man3/puts.3                          |  4 ++--
 man3/qecvt.3                         |  8 ++++++--
 man3/random_r.3                      | 10 ++++++----
 man3/rcmd.3                          | 26 ++++++++++++++------------
 man3/readdir_r.3                     |  4 ++--
 man3/realpath.3                      |  3 ++-
 man3/regex.3                         | 14 ++++++++------
 man3/rexec.3                         | 10 ++++++----
 man3/scandir.3                       |  4 ++--
 22 files changed, 81 insertions(+), 63 deletions(-)
Signature · 1 line
2.30.1
#1 lore raw

PATCH 1/23 pthread_attr_setschedpolicy.3: SYNOPSIS: Use 'restrict' in prototypes

Both POSIX and glibc use 'restrict' in pthread_attr_getschedpolicy(). Let's use it here too.

.../glibc$ grep_glibc_prototype pthread_attr_getschedpolicy sysdeps/htl/pthread.h:113:
extern int pthread_attr_getschedpolicy (const pthread_attr_t *__restrict __attr,

					int *__restrict __policy)
	__THROW __nonnull ((1, 2));
sysdeps/nptl/pthread.h:304:
extern int pthread_attr_getschedpolicy (const pthread_attr_t *__restrict
					__attr, int *__restrict __policy)
     __THROW __nonnull ((1, 2));

.../glibc$

---
 man3/pthread_attr_setschedpolicy.3 | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)
man3/pthread_attr_setschedpolicy.3 +3 -4
index 34fdc8631..e062fe685 100644
@@ -31,10 +31,9 @@ scheduling policy attribute in thread attributes object
 .nf
 .B #include <pthread.h>
 .PP
-.BI "int pthread_attr_setschedpolicy(pthread_attr_t *" attr \
-", int " policy );
-.BI "int pthread_attr_getschedpolicy(const pthread_attr_t *" attr ,
-.BI "                                int " *policy );
+.BI "int pthread_attr_setschedpolicy(pthread_attr_t *" attr ", int " policy );
+.BI "int pthread_attr_getschedpolicy(const pthread_attr_t *restrict " attr ,
+.BI "                                int *restrict " policy );
 .PP
 Compile and link with \fI\-pthread\fP.
 .fi
Signature · 1 line
2.30.1
#2 lore raw

PATCH 2/23 pthread_attr_setscope.3: SYNOPSIS: Use 'restrict' in prototypes

In reply to Alejandro Colomar

Both POSIX and glibc use 'restrict' in pthread_attr_getscope(). Let's use it here too.

.../glibc$ grep_glibc_prototype pthread_attr_getscope sysdeps/htl/pthread.h:125:
extern int pthread_attr_getscope (const pthread_attr_t *__restrict __attr,

				  int *__restrict __contentionscope)
	__THROW __nonnull ((1, 2));
sysdeps/nptl/pthread.h:324:
extern int pthread_attr_getscope (const pthread_attr_t *__restrict __attr,
				  int *__restrict __scope)
     __THROW __nonnull ((1, 2));

.../glibc$

---
 man3/pthread_attr_setscope.3 | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)
man3/pthread_attr_setscope.3 +3 -4
index 301ed1fef..835c9b514 100644
@@ -31,10 +31,9 @@ attribute in thread attributes object
 .nf
 .B #include <pthread.h>
 .PP
-.BI "int pthread_attr_setscope(pthread_attr_t *" attr \
-", int " scope );
-.BI "int pthread_attr_getscope(const pthread_attr_t *" attr \
-", int *" scope );
+.BI "int pthread_attr_setscope(pthread_attr_t *" attr ", int " scope );
+.BI "int pthread_attr_getscope(const pthread_attr_t *restrict " attr ,
+.BI "                          int *restrict " scope );
 .PP
 Compile and link with \fI\-pthread\fP.
 .fi
Signature · 1 line
2.30.1
#3 lore raw

PATCH 3/23 pthread_attr_setstackaddr.3: SYNOPSIS: Use 'restrict' in prototypes

In reply to Alejandro Colomar

Both POSIX and glibc use 'restrict' in pthread_attr_getstackaddr(). Let's use it here too.

.../glibc$ grep_glibc_prototype pthread_attr_getstackaddr sysdeps/htl/pthread.h:138:
extern int pthread_attr_getstackaddr (const pthread_attr_t *__restrict __attr,

				      void **__restrict __stackaddr)
	__THROW __nonnull ((1, 2));
sysdeps/nptl/pthread.h:333:
extern int pthread_attr_getstackaddr (const pthread_attr_t *__restrict
				      __attr, void **__restrict __stackaddr)
     __THROW __nonnull ((1, 2)) __attribute_deprecated__;

.../glibc$

---
 man3/pthread_attr_setstackaddr.3 | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
man3/pthread_attr_setstackaddr.3 +2 -2
index bf626c7cb..f926c16f2 100644
@@ -33,8 +33,8 @@ set/get stack address attribute in thread attributes object
 .PP
 .BI "int pthread_attr_setstackaddr(pthread_attr_t *" attr \
 ", void *" stackaddr );
-.BI "int pthread_attr_getstackaddr(const pthread_attr_t *" attr ,
-.BI "                              void **" stackaddr );
+.BI "int pthread_attr_getstackaddr(const pthread_attr_t *restrict " attr ,
+.BI "                              void **restrict " stackaddr );
 .PP
 Compile and link with \fI\-pthread\fP.
 .fi
Signature · 1 line
2.30.1
#4 lore raw

PATCH 4/23 pthread_attr_setstacksize.3: SYNOPSIS: Use 'restrict' in prototypes

In reply to Alejandro Colomar

Both POSIX and glibc use 'restrict' in pthread_attr_getstacksize(). Let's use it here too.

.../glibc$ grep_glibc_prototype pthread_attr_getstacksize sysdeps/htl/pthread.h:192:
extern int pthread_attr_getstacksize (const pthread_attr_t *__restrict __attr,

				      size_t *__restrict __stacksize)
	__THROW __nonnull ((1, 2));
sysdeps/nptl/pthread.h:346:
extern int pthread_attr_getstacksize (const pthread_attr_t *__restrict
				      __attr, size_t *__restrict __stacksize)
     __THROW __nonnull ((1, 2));

.../glibc$

---
 man3/pthread_attr_setstacksize.3 | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
man3/pthread_attr_setstacksize.3 +2 -2
index 824dbc5f7..e1e56aeee 100644
@@ -33,8 +33,8 @@ attribute in thread attributes object
 .PP
 .BI "int pthread_attr_setstacksize(pthread_attr_t *" attr \
 ", size_t " stacksize );
-.BI "int pthread_attr_getstacksize(const pthread_attr_t *" attr ,
-.BI "                              size_t *" stacksize );
+.BI "int pthread_attr_getstacksize(const pthread_attr_t *restrict " attr ,
+.BI "                              size_t *restrict " stacksize );
 .PP
 Compile and link with \fI\-pthread\fP.
 .fi
Signature · 1 line
2.30.1
#5 lore raw

PATCH 5/23 pthread_attr_setstack.3: SYNOPSIS: Use 'restrict' in prototypes

In reply to Alejandro Colomar

Both POSIX and glibc use 'restrict' in pthread_attr_setstack(). Let's use it here too.

.../glibc$ grep_glibc_prototype pthread_attr_setstack sysdeps/htl/pthread.h:158:
extern int pthread_attr_setstack (pthread_attr_t *__attr,

				  void *__stackaddr,
				  size_t __stacksize)
	__THROW __nonnull ((1));
sysdeps/nptl/pthread.h:367:
extern int pthread_attr_setstack (pthread_attr_t *__attr, void *__stackaddr,
				  size_t __stacksize) __THROW __nonnull ((1));

.../glibc$

---
 man3/pthread_attr_setstack.3 | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
man3/pthread_attr_setstack.3 +3 -2
index 23b95cb32..6d0488a8b 100644
@@ -33,8 +33,9 @@ attributes in thread attributes object
 .PP
 .BI "int pthread_attr_setstack(pthread_attr_t *" attr ,
 .BI "                          void *" stackaddr ", size_t " stacksize );
-.BI "int pthread_attr_getstack(const pthread_attr_t *" attr ,
-.BI "                          void **" stackaddr ", size_t *" stacksize );
+.BI "int pthread_attr_getstack(const pthread_attr_t *restrict " attr ,
+.BI "                          void **restrict " stackaddr ,
+.BI "                          size_t *restrict " stacksize );
 .PP
 Compile and link with \fI\-pthread\fP.
 .fi
Signature · 1 line
2.30.1
#6 lore raw

PATCH 6/23 pthread_create.3: SYNOPSIS: Use 'restrict' in prototypes

In reply to Alejandro Colomar

Both POSIX and glibc use 'restrict' in pthread_create(). Let's use it here too.

.../glibc$ grep_glibc_prototype pthread_create sysdeps/htl/pthread.h:212:
extern int pthread_create (pthread_t *__restrict __threadp,

			   __const pthread_attr_t *__restrict __attr,
			   void *(*__start_routine)(void *),
			   void *__restrict __arg) __THROWNL __nonnull ((1, 3));
sysdeps/nptl/pthread.h:200:
extern int pthread_create (pthread_t *__restrict __newthread,
			   const pthread_attr_t *__restrict __attr,
			   void *(*__start_routine) (void *),
			   void *__restrict __arg) __THROWNL __nonnull ((1, 3));

.../glibc$

---
 man3/pthread_create.3 | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
man3/pthread_create.3 +4 -2
index a1ede6e96..14fd37220 100644
@@ -30,8 +30,10 @@ pthread_create \- create a new thread
 .nf
 .B #include <pthread.h>
 .PP
-.BI "int pthread_create(pthread_t *" thread ", const pthread_attr_t *" attr ,
-.BI "                   void *(*" start_routine ")(void *), void *" arg );
+.BI "int pthread_create(pthread_t *restrict " thread ,
+.BI "                   const pthread_attr_t *restrict " attr ,
+.BI "                   void *(*" start_routine ")(void *),"
+.BI "                   void *restrict " arg );
 .fi
 .PP
 Compile and link with \fI\-pthread\fP.
Signature · 1 line
2.30.1
#7 lore raw

PATCH 7/23 pthread_getattr_default_np.3: SYNOPSIS: Add missing 'const'

In reply to Alejandro Colomar

glibc uses 'const' in pthread_setattr_default_np(). Let's use it here too.

.../glibc$ grep_glibc_prototype pthread_setattr_default_np sysdeps/nptl/pthread.h:406:
extern int pthread_setattr_default_np (const pthread_attr_t *__attr)

     __THROW __nonnull ((1));

.../glibc$

---
 man3/pthread_getattr_default_np.3 | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
man3/pthread_getattr_default_np.3 +1 -1
index ad2a92f52..6a24006bf 100644
@@ -32,7 +32,7 @@ get or set default thread-creation attributes
 .B #include <pthread.h>
 .PP
 .BI "int pthread_getattr_default_np(pthread_attr_t *" attr );
-.BI "int pthread_setattr_default_np(pthread_attr_t *" attr );
+.BI "int pthread_setattr_default_np(const pthread_attr_t *" attr );
 .PP
 Compile and link with \fI\-pthread\fP.
 .fi
Signature · 1 line
2.30.1
#8 lore raw

PATCH 8/23 pthread_mutexattr_getpshared.3: SYNOPSIS: Use 'restrict' in prototypes

In reply to Alejandro Colomar

Both POSIX and glibc use 'restrict' in
pthread_mutexattr_getpshared().
Let's use it here too.

.../glibc$ grep_glibc_prototype pthread_mutexattr_getpshared sysdeps/htl/pthread.h:368:
extern int pthread_mutexattr_getpshared(const pthread_mutexattr_t *__restrict __attr,

					int *__restrict __pshared)
	__THROW __nonnull ((1, 2));
sysdeps/nptl/pthread.h:830:
extern int pthread_mutexattr_getpshared (const pthread_mutexattr_t *
					 __restrict __attr,
					 int *__restrict __pshared)
     __THROW __nonnull ((1, 2));

.../glibc$

---
 man3/pthread_mutexattr_getpshared.3 | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)
man3/pthread_mutexattr_getpshared.3 +4 -3
index 2fd48012e..0ae3c05ea 100644
@@ -30,10 +30,11 @@ process-shared mutex attribute
 .nf
 .B #include <pthread.h>
 .PP
-.BI "int pthread_mutexattr_getpshared(const pthread_mutexattr_t *" attr ,
-.BI "                                 int *" pshared );
+.BI "int pthread_mutexattr_getpshared("
+.BI "                              const pthread_mutexattr_t *restrict " attr ,
+.BI "                              int *restrict " pshared );
 .BI "int pthread_mutexattr_setpshared(pthread_mutexattr_t *" attr ,
-.BI "                                 int " pshared );
+.BI "                              int " pshared );
 .fi
 .PP
 Compile and link with \fI\-pthread\fP.
Signature · 1 line
2.30.1
#9 lore raw

PATCH 9/23 pthread_mutexattr_setrobust.3: SYNOPSIS: Remove incorrect 'const'

In reply to Alejandro Colomar

Neither POSIX or glibc use 'const' in
pthread_mutexattr_setrobust().
Remove it.

.../glibc$ grep_glibc_prototype pthread_mutexattr_setrobust sysdeps/htl/pthread.h:355:
extern int pthread_mutexattr_setrobust (pthread_mutexattr_t *__attr,

					int __robustness)
     __THROW __nonnull ((1));
sysdeps/nptl/pthread.h:888:
extern int pthread_mutexattr_setrobust (pthread_mutexattr_t *__attr,
					int __robustness)
     __THROW __nonnull ((1));

.../glibc$

---
 man3/pthread_mutexattr_setrobust.3 | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
man3/pthread_mutexattr_setrobust.3 +1 -1
index 9034d6faf..d2df02b00 100644
@@ -33,7 +33,7 @@ pthread_mutexattr_getrobust, pthread_mutexattr_setrobust
 .PP
 .BI "int pthread_mutexattr_getrobust(const pthread_mutexattr_t *" attr ,
 .BI "                                int *" robustness ");"
-.BI "int pthread_mutexattr_setrobust(const pthread_mutexattr_t *" attr ,
+.BI "int pthread_mutexattr_setrobust(pthread_mutexattr_t *" attr ,
 .BI "                                int " robustness ");"
 .fi
 .PP
Signature · 1 line
2.30.1
#10 lore raw

PATCH 10/23 pthread_rwlockattr_setkind_np.3: SYNOPSIS: Use 'restrict' in prototypes

In reply to Alejandro Colomar

glibc uses 'restrict' in pthread_rwlockattr_getkind_np(). Let's use it here too.

.../glibc$ grep_glibc_prototype pthread_rwlockattr_getkind_np sysdeps/htl/pthread.h:633:
extern int pthread_rwlockattr_getkind_np (const pthread_rwlockattr_t *

					  __restrict __attr,
					  int *__restrict __pref)
     __THROW __nonnull ((1, 2));
sysdeps/nptl/pthread.h:983:
extern int pthread_rwlockattr_getkind_np (const pthread_rwlockattr_t *
					  __restrict __attr,
					  int *__restrict __pref)
     __THROW __nonnull ((1, 2));

.../glibc$

---
 man3/pthread_rwlockattr_setkind_np.3 | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)
man3/pthread_rwlockattr_setkind_np.3 +4 -3
index eb2dc19bf..7ade3ba7d 100644
@@ -31,9 +31,10 @@ the read-write lock kind of the thread read-write lock attribute object
 .B #include <pthread.h>
 .PP
 .BI "int pthread_rwlockattr_setkind_np(pthread_rwlockattr_t *" attr ,
-.BI "                                   int " pref );
-.BI "int pthread_rwlockattr_getkind_np(const pthread_rwlockattr_t *" attr ,
-.BI "                                   int *" pref );
+.BI "                             int " pref );
+.BI "int pthread_rwlockattr_getkind_np("
+.BI "                             const pthread_rwlockattr_t *restrict " attr ,
+.BI "                             int *restrict " pref );
 .PP
 Compile and link with \fI\-pthread\fP.
 .PP
Signature · 1 line
2.30.1
#11 lore raw

PATCH 11/23 pthread_setschedparam.3: SYNOPSIS: Use 'restrict' in prototypes

In reply to Alejandro Colomar

Both POSIX and glibc use 'restrict' in pthread_getschedparam(). Let's use it here too.

.../glibc$ grep_glibc_prototype pthread_getschedparam sysdeps/htl/pthread.h:882:
extern int pthread_getschedparam (pthread_t __thr, int *__restrict __policy,

				  struct sched_param *__restrict __param)
	__THROW __nonnull ((2, 3));

sysdeps/nptl/pthread.h:426:
extern int pthread_getschedparam (pthread_t __target_thread,
int *__restrict __policy, struct sched_param *__restrict __param)
__THROW __nonnull ((2, 3));
.../glibc$

---
 man3/pthread_setschedparam.3 | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
man3/pthread_setschedparam.3 +2 -2
index b3ec5009c..d96d911d9 100644
@@ -33,8 +33,8 @@ scheduling policy and parameters of a thread
 .PP
 .BI "int pthread_setschedparam(pthread_t " thread ", int " policy ,
 .BI "                          const struct sched_param *" param );
-.BI "int pthread_getschedparam(pthread_t " thread ", int *" policy ,
-.BI "                          struct sched_param *" param );
+.BI "int pthread_getschedparam(pthread_t " thread ", int *restrict " policy ,
+.BI "                          struct sched_param *restrict " param );
 .PP
 Compile and link with \fI\-pthread\fP.
 .fi
Signature · 1 line
2.30.1
#12 lore raw

PATCH 12/23 putgrent.3: SYNOPSIS: Use 'restrict' in prototypes

In reply to Alejandro Colomar

glibc uses 'restrict' in putgrent().
Let's use it here too.

.../glibc$ grep_glibc_prototype putgrent grp/grp.h:93:
extern int putgrent (const struct group *__restrict __p,

		     FILE *__restrict __f);

.../glibc$

---
 man3/putgrent.3 | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
man3/putgrent.3 +2 -1
index 6ce977cb1..2a2801a96 100644
@@ -12,7 +12,8 @@ putgrent \- write a group database entry to a file
 .BR "#define _GNU_SOURCE" "         /* See feature_test_macros(7) */"
 .B #include <grp.h>
 .PP
-.BI "int putgrent(const struct group *" grp ", FILE *" stream );
+.BI "int putgrent(const struct group *restrict " grp \
+", FILE *restrict " stream );
 .fi
 .SH DESCRIPTION
 The
Signature · 1 line
2.30.1
#13 lore raw

PATCH 13/23 putpwent.3: SYNOPSIS: Use 'restrict' in prototypes

In reply to Alejandro Colomar

glibc uses 'restrict' in putpwent().
Let's use it here too.

.../glibc$ grep_glibc_prototype putpwent pwd/pwd.h:102:
extern int putpwent (const struct passwd *__restrict __p,

		     FILE *__restrict __f);

.../glibc$

---
 man3/putpwent.3 | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
man3/putpwent.3 +2 -1
index 4db31a78d..85caca9c7 100644
@@ -36,7 +36,8 @@ putpwent \- write a password file entry
 .B #include <sys/types.h>
 .B #include <pwd.h>
 .PP
-.BI "int putpwent(const struct passwd *" p ", FILE *" stream );
+.BI "int putpwent(const struct passwd *restrict " p \
+", FILE *restrict " stream );
 .fi
 .PP
 .RS -4
Signature · 1 line
2.30.1
#14 lore raw

PATCH 14/23 puts.3: SYNOPSIS: Use 'restrict' in prototypes

In reply to Alejandro Colomar

Both POSIX and glibc use 'restrict' in fputs().
Let's use it here too.

.../glibc$ grep_glibc_prototype fputs
libio/stdio.h:631:
extern int fputs (const char *__restrict __s, FILE *__restrict __stream); .../glibc$

---
 man3/puts.3 | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
man3/puts.3 +2 -2
index 3b0fb9d2a..e9b0b0c8a 100644
@@ -34,8 +34,8 @@ fputc, fputs, putc, putchar, puts \- output of characters and strings
 .BI "int putc(int " c ", FILE *" stream );
 .BI "int putchar(int " c );
 .PP
-.BI "int fputs(const char *" "s" ", FILE *" "stream" );
-.BI "int puts(const char *" "s" );
+.BI "int fputs(const char *restrict " s ", FILE *restrict " stream );
+.BI "int puts(const char *" s );
 .fi
 .SH DESCRIPTION
 .BR fputc ()
Signature · 1 line
2.30.1
#15 lore raw

PATCH 15/23 qecvt.3: SYNOPSIS: Use 'restrict' in prototypes

In reply to Alejandro Colomar

glibc uses 'restrict' in qecvt(), qfcvt().
Let's use it here too.

.../glibc$ grep_glibc_prototype qecvt stdlib/stdlib.h:890:
extern char *qecvt (long double __value, int __ndigit,

		    int *__restrict __decpt, int *__restrict __sign)
     __THROW __nonnull ((3, 4)) __wur;
.../glibc$ grep_glibc_prototype qfcvt
stdlib/stdlib.h:893:
extern char *qfcvt (long double __value, int __ndigit,
		    int *__restrict __decpt, int *__restrict __sign)
     __THROW __nonnull ((3, 4)) __wur;

.../glibc$

---
 man3/qecvt.3 | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)
man3/qecvt.3 +6 -2
index e38922dbf..f904bad54 100644
@@ -32,8 +32,12 @@ qecvt, qfcvt, qgcvt \- convert a floating-point number to a string
 .nf
 .B #include <stdlib.h>
 .PP
-.BI "char *qecvt(long double " number ", int " ndigits ", int *" decpt ", int *" sign );
-.BI "char *qfcvt(long double " number ", int " ndigits ", int *" decpt ",i int *" sign );
+.BI "char *qecvt(long double " number ", int " ndigits \
+", int *restrict " decpt ,
+.BI "            int *restrict " sign );
+.BI "char *qfcvt(long double " number ", int " ndigits \
+", int *restrict " decpt ,
+.BI "            int *restrict " sign );
 .BI "char *qgcvt(long double " number ", int " ndigit ", char *" buf );
 .fi
 .PP
Signature · 1 line
2.30.1
#16 lore raw

PATCH 16/23 random_r.3: SYNOPSIS: Use 'restrict' in prototypes

In reply to Alejandro Colomar

glibc uses 'restrict' in random_r(), initstate_r(), setstate_r(). Let's use it here too.

.../glibc$ grep_glibc_prototype random_r stdlib/stdlib.h:434:
extern int random_r (struct random_data *__restrict __buf,

		     int32_t *__restrict __result) __THROW __nonnull ((1, 2));
.../glibc$ grep_glibc_prototype initstate_r
stdlib/stdlib.h:440:
extern int initstate_r (unsigned int __seed, char *__restrict __statebuf,
			size_t __statelen,
			struct random_data *__restrict __buf)
     __THROW __nonnull ((2, 4));
.../glibc$ grep_glibc_prototype setstate_r
stdlib/stdlib.h:445:
extern int setstate_r (char *__restrict __statebuf,
		       struct random_data *__restrict __buf)
     __THROW __nonnull ((1, 2));

.../glibc$

---
 man3/random_r.3 | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)
man3/random_r.3 +6 -4
index 5363e5e78..882ba83a2 100644
@@ -31,12 +31,14 @@ random number generator
 .nf
 .B #include <stdlib.h>
 .PP
-.BI "int random_r(struct random_data *" buf ", int32_t *" result );
+.BI "int random_r(struct random_data *restrict " buf ,
+.BI "             int32_t *restrict " result );
 .BI "int srandom_r(unsigned int " seed ", struct random_data *" buf );
 .PP
-.BI "int initstate_r(unsigned int " seed ", char *" statebuf ,
-.BI "                size_t " statelen ", struct random_data *" buf );
-.BI "int setstate_r(char *" statebuf ", struct random_data *" buf );
+.BI "int initstate_r(unsigned int " seed ", char *restrict " statebuf ,
+.BI "             size_t " statelen ", struct random_data *restrict " buf );
+.BI "int setstate_r(char *restrict " statebuf ,
+.BI "             struct random_data *restrict " buf );
 .fi
 .PP
 .RS -4
Signature · 1 line
2.30.1
#17 lore raw

PATCH 17/23 rcmd.3: SYNOPSIS: Use 'restrict' in prototypes

In reply to Alejandro Colomar

glibc uses 'restrict' in rcmd(), rcmd_af(), iruserok_af(). Let's use it here too.

.../glibc$ grep_glibc_prototype rcmd
resolv/netdb.h:449:
extern int rcmd (char **__restrict __ahost, unsigned short int __rport,
const char *__restrict __locuser,
const char *__restrict __remuser,
const char *__restrict __cmd, int *__restrict __fd2p);
.../glibc$ grep_glibc_prototype rcmd_af
resolv/netdb.h:461:
extern int rcmd_af (char **__restrict __ahost, unsigned short int __rport,
const char *__restrict __locuser,
const char *__restrict __remuser,
const char *__restrict __cmd, int *__restrict __fd2p, sa_family_t __af);
.../glibc$ grep_glibc_prototype iruserok_af resolv/netdb.h:537:
extern int iruserok_af (const void *__raddr, int __suser,

			const char *__remuser, const char *__locuser,
			sa_family_t __af);

.../glibc$

---
 man3/rcmd.3 | 26 ++++++++++++++------------
 1 file changed, 14 insertions(+), 12 deletions(-)
man3/rcmd.3 +14 -12
index 0349646c7..d2df6b629 100644
@@ -49,28 +49,30 @@ stream to a remote command
 .nf
 .BR "#include <netdb.h>    " "/* Or <unistd.h> on some systems */"
 .PP
-.BI "int rcmd(char **" ahost ", unsigned short " inport ", const char *" locuser ,
-.BI "             const char *" remuser ", const char *" cmd ", int *" fd2p );
+.BI "int rcmd(char **restrict " ahost ", unsigned short " inport ,
+.BI "         const char *restrict " locuser ", const char *restrict " remuser ,
+.BI "         const char *restrict " cmd ", int *restrict " fd2p );
 .PP
 .BI "int rresvport(int *" port );
 .PP
 .BI "int iruserok(uint32_t " raddr ", int " superuser ,
-.BI "             const char *" ruser ", const char *" luser );
+.BI "         const char *" ruser ", const char *" luser );
 .BI "int ruserok(const char *" rhost ", int " superuser ,
-.BI "             const char *" ruser ", const char *" luser );
+.BI "         const char *" ruser ", const char *" luser );
 .PP
-.BI "int rcmd_af(char **" ahost ", unsigned short " inport ", const char *" locuser ,
-.BI "             const char *" remuser ", const char *" cmd ", int *" fd2p ,
-.BI "             sa_family_t " af );
+.BI "int rcmd_af(char **restrict " ahost ", unsigned short " inport ,
+.BI "         const char *restrict " locuser ", const char *restrict " remuser ,
+.BI "         const char *restrict " cmd ", int *restrict " fd2p ,
+.BI "         sa_family_t " af );
 .PP
 .BI "int rresvport_af(int *" port ", sa_family_t " af );
 .PP
-.BI "int iruserok_af(const void *" raddr ", int " superuser ,
-.BI "             const char *" ruser ", const char *" luser \
-", sa_family_t " af );
+.BI "int iruserok_af(const void *restrict " raddr ", int " superuser ,
+.BI "        const char *restrict " ruser ", const char *restrict " luser ,
+.BI "        sa_family_t " af );
 .BI "int ruserok_af(const char *" rhost ", int " superuser ,
-.BI "             const char *" ruser ", const char *" luser \
-", sa_family_t " af );
+.BI "        const char *" ruser ", const char *" luser ,
+.BI "        sa_family_t " af );
 .fi
 .PP
 .RS -4
Signature · 1 line
2.30.1
#18 lore raw

PATCH 18/23 readdir_r.3: SYNOPSIS: Use 'restrict' in prototypes

In reply to Alejandro Colomar

Both POSIX and glibc use 'restrict' in readdir_r(). Let's use it here too.

.../glibc$ grep_glibc_prototype readdir_r dirent/dirent.h:183:
extern int readdir_r (DIR *__restrict __dirp,
struct dirent *__restrict __entry, struct dirent **__restrict __result)
__nonnull ((1, 2, 3)) __attribute_deprecated__;
.../glibc$

---
 man3/readdir_r.3 | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
man3/readdir_r.3 +2 -2
index f330adb35..ad8f405f8 100644
@@ -30,8 +30,8 @@ readdir_r \- read a directory
 .nf
 .B #include <dirent.h>
 .PP
-.BI "int readdir_r(DIR *" dirp ", struct dirent *" entry \
-", struct dirent **" result );
+.BI "int readdir_r(DIR *restrict " dirp ", struct dirent *restrict " entry ,
+.BI "              struct dirent **restrict " result );
 .fi
 .PP
 .RS -4
Signature · 1 line
2.30.1
#19 lore raw

PATCH 19/23 realpath.3: SYNOPSIS: Use 'restrict' in prototypes

In reply to Alejandro Colomar

Both POSIX and glibc use 'restrict' in realpath(). Let's use it here too.

.../glibc$ grep_glibc_prototype realpath stdlib/stdlib.h:800:
extern char *realpath (const char *__restrict __name,

		       char *__restrict __resolved) __THROW __wur;

.../glibc$

---
 man3/realpath.3 | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
man3/realpath.3 +2 -1
index 643cdaaec..100567217 100644
@@ -33,7 +33,8 @@ realpath \- return the canonicalized absolute pathname
 .B #include <limits.h>
 .B #include <stdlib.h>
 .PP
-.BI "char *realpath(const char *" path ", char *" resolved_path );
+.BI "char *realpath(const char *restrict " path ,
+.BI "               char *restrict " resolved_path );
 .fi
 .PP
 .RS -4
Signature · 1 line
2.30.1
#20 lore raw

PATCH 20/23 regex.3: SYNOPSIS: Use 'restrict' in prototypes

In reply to Alejandro Colomar

Both POSIX and glibc use 'restrict' in regcomp(), regexec(), regerror().
Let's use it here too.

.../glibc$ grep_glibc_prototype regcomp
posix/regex.h:644:
extern int regcomp (regex_t *_Restrict_ __preg,

		    const char *_Restrict_ __pattern,
		    int __cflags);
.../glibc$ grep_glibc_prototype regexec
posix/regex.h:648:
extern int regexec (const regex_t *_Restrict_ __preg,
		    const char *_Restrict_ __String, size_t __nmatch,
		    regmatch_t __pmatch[_Restrict_arr_],
		    int __eflags);
.../glibc$ grep_glibc_prototype regerror
posix/regex.h:653:
extern size_t regerror (int __errcode, const regex_t *_Restrict_ __preg,
			char *_Restrict_ __errbuf, size_t __errbuf_size);

.../glibc$

---
 man3/regex.3 | 14 ++++++++------
 1 file changed, 8 insertions(+), 6 deletions(-)
man3/regex.3 +8 -6
index 79af42ff4..12e43b3f9 100644
@@ -34,13 +34,15 @@ regcomp, regexec, regerror, regfree \- POSIX regex functions
 .nf
 .B #include <regex.h>
 .PP
-.BI "int regcomp(regex_t *" preg ", const char *" regex ", int " cflags );
-.BI "int regexec(const regex_t *" preg ", const char *" string \
-", size_t " nmatch ,
-.BI "            regmatch_t " pmatch[] ", int " eflags );
+.BI "int regcomp(regex_t *restrict " preg ", const char *restrict " regex ,
+.BI "            int " cflags );
+.BI "int regexec(const regex_t *restrict " preg \
+", const char *restrict " string ,
+.BI "            size_t " nmatch ", regmatch_t " pmatch "[restrict]\
+, int " eflags );
 .PP
-.BI "size_t regerror(int " errcode ", const regex_t *" preg ", char *" errbuf ,
-.BI "            size_t " errbuf_size );
+.BI "size_t regerror(int " errcode ", const regex_t *restrict " preg ,
+.BI "            char *restrict " errbuf ", size_t " errbuf_size );
 .BI "void regfree(regex_t *" preg );
 .fi
 .SH DESCRIPTION
Signature · 1 line
2.30.1
#21 lore raw

PATCH 21/23 rexec.3: SYNOPSIS: Use 'restrict' in prototypes

In reply to Alejandro Colomar

glibc uses 'restrict' in rexec(), rexec_af().
Let's use it here too.

.../glibc$ grep_glibc_prototype rexec
resolv/netdb.h:477:
extern int rexec (char **__restrict __ahost, int __rport,
const char *__restrict __name,
const char *__restrict __pass,
const char *__restrict __cmd, int *__restrict __fd2p);
.../glibc$ grep_glibc_prototype rexec_af
resolv/netdb.h:489:
extern int rexec_af (char **__restrict __ahost, int __rport,
const char *__restrict __name,
const char *__restrict __pass,
const char *__restrict __cmd, int *__restrict __fd2p, sa_family_t __af);
.../glibc$

---
 man3/rexec.3 | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)
man3/rexec.3 +6 -4
index 6c46e0e34..56d1a2442 100644
@@ -45,10 +45,12 @@ rexec, rexec_af \- return stream to a remote command
 .nf
 .B #include <netdb.h>
 .PP
-.BI "int rexec(char **" ahost ", int " inport ", const char *" user ,
-.BI "          const char *" passwd ", const char *" cmd ", int *" fd2p );
-.BI "int rexec_af(char **" ahost ", int " inport ", const char *" user ,
-.BI "          const char *" passwd ", const char *" cmd ", int *" fd2p ,
+.BI "int rexec(char **restrict " ahost ", int " inport ,
+.BI "          const char *restrict " user ", const char *restrict " passwd ,
+.BI "          const char *restrict " cmd ", int *restrict " fd2p );
+.BI "int rexec_af(char **restrict " ahost ", int " inport ,
+.BI "          const char *restrict " user ", const char *restrict " passwd ,
+.BI "          const char *restrict " cmd ", int *restrict " fd2p ,
 .BI "          sa_family_t " af  );
 .fi
 .PP
Signature · 1 line
2.30.1
#22 lore raw

PATCH 22/23 scandir.3: SYNOPSIS: Use 'restrict' in prototypes

In reply to Alejandro Colomar

POSIX does NOT specify scandir() to use 'restrict'. However, glibc uses 'restrict'.
Users might be surprised by this! Let's use it here too!

.../glibc$ grep_glibc_prototype scandir dirent/dirent.h:255:
extern int scandir (const char *__restrict __dir,
struct dirent ***__restrict __namelist, int (*__selector) (const struct dirent *), int (*__cmp) (const struct dirent **,
const struct dirent **))
__nonnull ((1, 2));
.../glibc$

---
 man3/scandir.3 | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
man3/scandir.3 +1 -1
index 83a5eea7d..262e125c1 100644
@@ -67,7 +67,7 @@ a directory for matching entries
 .nf
 .B #include <dirent.h>
 .PP
-.BI "int scandir(const char *" dirp ", struct dirent ***" namelist ,
+.BI "int scandir(const char *restrict " dirp ", struct dirent ***restrict " namelist ,
 .BI "            int (*" filter ")(const struct dirent *),"
 .BI "            int (*" compar ")(const struct dirent **,"
 .BR "                          const struct dirent **));"
Signature · 1 line
2.30.1
#23 lore raw

PATCH 23/23 scandir.3: SYNOPSIS: Use 'restrict' in prototypes

In reply to Alejandro Colomar

glibc uses 'restrict' in scandirat().
Let's use it here too.

.../glibc$ grep_glibc_prototype scandirat dirent/dirent.h:293:
extern int scandirat (int __dfd, const char *__restrict __dir,
struct dirent ***__restrict __namelist, int (*__selector) (const struct dirent *), int (*__cmp) (const struct dirent **,
const struct dirent **))
__nonnull ((2, 3));
.../glibc$

---
 man3/scandir.3 | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
man3/scandir.3 +1 -1
index 262e125c1..50328130f 100644
@@ -78,7 +78,7 @@ a directory for matching entries
 .BR "#include <fcntl.h>" "          /* Definition of AT_* constants */"
 .B #include <dirent.h>
 .PP
-.BI "int scandirat(int " dirfd ", const char *" dirp ", struct dirent ***" namelist ,
+.BI "int scandirat(int " dirfd ", const char *restrict " dirp ", struct dirent ***restrict " namelist ,
 .BI "            int (*" filter ")(const struct dirent *),"
 .BI "            int (*" compar ")(const struct dirent **,"
 .BI "                          const struct dirent **));"
Signature · 1 line
2.30.1