public inbox for libc-alpha@sourceware.org
 help / color / mirror / Atom feed
* [PATCH] gettimeofday.2: Use restrict in prototypes
@ 2021-02-03 21:52 Alejandro Colomar
  2021-02-06 20:39 ` Michael Kerrisk (man-pages)
  0 siblings, 1 reply; 2+ messages in thread
From: Alejandro Colomar @ 2021-02-03 21:52 UTC (permalink / raw)
  To: mtk.manpages; +Cc: Alejandro Colomar, linux-man, libc-alpha

POSIX specifies that the parameters of gettimeofday() shall be
'restrict'.  Glibc uses 'restrict' too.
Let's use it here too.

......

.../glibc$ grep_syscall_wrapper gettimeofday
time/sys/time.h:66:
extern int gettimeofday (struct timeval *__restrict __tv,
			 void *__restrict __tz) __THROW __nonnull ((1));
.../glibc$

function grep_syscall_wrapper()
{
	if ! [ -v 1 ]; then
		>&2 echo "Usage: ${FUNCNAME[0]} <syscall>";
		return ${EX_USAGE};
	fi

	find * -type f \
	|grep '\.h$' \
	|sort -V \
	|xargs pcregrep -Mn \
	  "(?s)^[^\s#][\w\s]+\s+\**${1}\s*\([\w\s()[\]*,]*?(...)?\)[\w\s()]*;" \
	|sed -E 's/^[^:]+:[0-9]+:/&\n/';
}

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

Hi Michael,

Actually, both POSIX and Glibc specify the 2nd parameter of gettimeofday()
to be 'void *restrict' and not 'struct timezone *restrict'.
However, I didn't fix that for now.
You may want to have a look at that.

Cheers,

Alex

 man2/gettimeofday.2 | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/man2/gettimeofday.2 b/man2/gettimeofday.2
index 085b86ad0..7e2726ed9 100644
--- a/man2/gettimeofday.2
+++ b/man2/gettimeofday.2
@@ -44,9 +44,10 @@ gettimeofday, settimeofday \- get / set time
 .nf
 .B #include <sys/time.h>
 .PP
-.BI "int gettimeofday(struct timeval *" tv ", struct timezone *" tz );
-.BI "int settimeofday(const struct timeval *" tv \
-", const struct timezone *" tz );
+.BI "int gettimeofday(struct timeval *restrict " tv ,
+.BI "                 struct timezone *restrict " tz );
+.BI "int settimeofday(const struct timeval *" tv ,
+.BI "                 const struct timezone *" tz );
 .fi
 .PP
 .RS -4
-- 
2.30.0


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH] gettimeofday.2: Use restrict in prototypes
  2021-02-03 21:52 [PATCH] gettimeofday.2: Use restrict in prototypes Alejandro Colomar
@ 2021-02-06 20:39 ` Michael Kerrisk (man-pages)
  0 siblings, 0 replies; 2+ messages in thread
From: Michael Kerrisk (man-pages) @ 2021-02-06 20:39 UTC (permalink / raw)
  To: Alejandro Colomar; +Cc: mtk.manpages, linux-man, libc-alpha

Hi Alex,

On 2/3/21 10:52 PM, Alejandro Colomar wrote:
> POSIX specifies that the parameters of gettimeofday() shall be
> 'restrict'.  Glibc uses 'restrict' too.
> Let's use it here too.

Thanks. Patch applied.

Cheers,

Michael

> 
> ......
> 
> .../glibc$ grep_syscall_wrapper gettimeofday
> time/sys/time.h:66:
> extern int gettimeofday (struct timeval *__restrict __tv,
> 			 void *__restrict __tz) __THROW __nonnull ((1));
> .../glibc$
> 
> function grep_syscall_wrapper()
> {
> 	if ! [ -v 1 ]; then
> 		>&2 echo "Usage: ${FUNCNAME[0]} <syscall>";
> 		return ${EX_USAGE};
> 	fi
> 
> 	find * -type f \
> 	|grep '\.h$' \
> 	|sort -V \
> 	|xargs pcregrep -Mn \
> 	  "(?s)^[^\s#][\w\s]+\s+\**${1}\s*\([\w\s()[\]*,]*?(...)?\)[\w\s()]*;" \
> 	|sed -E 's/^[^:]+:[0-9]+:/&\n/';
> }
> 
> Signed-off-by: Alejandro Colomar <alx.manpages@gmail.com>
> ---
> 
> Hi Michael,
> 
> Actually, both POSIX and Glibc specify the 2nd parameter of gettimeofday()
> to be 'void *restrict' and not 'struct timezone *restrict'.
> However, I didn't fix that for now.
> You may want to have a look at that.
> 
> Cheers,
> 
> Alex
> 
>  man2/gettimeofday.2 | 7 ++++---
>  1 file changed, 4 insertions(+), 3 deletions(-)
> 
> diff --git a/man2/gettimeofday.2 b/man2/gettimeofday.2
> index 085b86ad0..7e2726ed9 100644
> --- a/man2/gettimeofday.2
> +++ b/man2/gettimeofday.2
> @@ -44,9 +44,10 @@ gettimeofday, settimeofday \- get / set time
>  .nf
>  .B #include <sys/time.h>
>  .PP
> -.BI "int gettimeofday(struct timeval *" tv ", struct timezone *" tz );
> -.BI "int settimeofday(const struct timeval *" tv \
> -", const struct timezone *" tz );
> +.BI "int gettimeofday(struct timeval *restrict " tv ,
> +.BI "                 struct timezone *restrict " tz );
> +.BI "int settimeofday(const struct timeval *" tv ,
> +.BI "                 const struct timezone *" tz );
>  .fi
>  .PP
>  .RS -4
> 


-- 
Michael Kerrisk
Linux man-pages maintainer; http://www.kernel.org/doc/man-pages/
Linux/UNIX System Programming Training: http://man7.org/training/

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2021-02-06 20:39 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-02-03 21:52 [PATCH] gettimeofday.2: Use restrict in prototypes Alejandro Colomar
2021-02-06 20:39 ` Michael Kerrisk (man-pages)

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).