Hi,

TL;DR: POSIX.1-2008 says gettimeofday(2) can't return anything but 0,
but we return -1 on invalid input.  We claim that our gettimeofday(2)
conforms to POSIX.1-2008.  Is something off here?

Also, gettimeofday(2) is an XSI extension, so I think at a
minimum the STANDARDS section needs to be tweaked (attached).

Long version:

POSIX.1-2008 [1] says:

> The gettimeofday() function shall return 0 and no value shall
> be reserved to indicate an error.

where "shall" is defined [2] as:

> For an implementation that conforms to POSIX.1-2008, describes a
> feature or behavior that is mandatory. [...]

But in our own gettimeofday(2):

> Upon successful completion, the value 0 is returned; otherwise the
> value -1 is returned and the global variable errno is set to indicate
> the error.

and looking at kern/kern_time.c, this is the case.

Does this make our implementation non-conforming and does something
in the manpage need to change?

I do note that gettimeofday(2) predates [3] POSIX (and me :p), so
perhaps this is just an ancient compromise between BSD and the
standards committees?

Thoughts?

--
Scott Cheloha

[1] http://pubs.opengroup.org/onlinepubs/9699919799/functions/gettimeofday.html
[2] 
http://pubs.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap01.html#tag_01_05_05
[3] 
https://github.com/dspinellis/unix-history-repo/blob/BSD-4_1c_2-Snapshot-Development/usr/man/man2/gettimeofday.2

Index: lib/libc/sys/gettimeofday.2
===================================================================
RCS file: /cvs/src/lib/libc/sys/gettimeofday.2,v
retrieving revision 1.29
diff -u -p -r1.29 gettimeofday.2
--- lib/libc/sys/gettimeofday.2 10 Sep 2015 17:55:21 -0000      1.29
+++ lib/libc/sys/gettimeofday.2 2 Dec 2017 17:38:40 -0000
@@ -133,8 +133,10 @@ A user other than the superuser attempte
 .Sh STANDARDS
 The
 .Fn gettimeofday
-function conforms to
-.St -p1003.1-2008 .
+function conforms to the
+X/Open System Interfaces option of the
+.St -p1003.1-2008
+specification.
 .Sh HISTORY
 As predecessors of these functions, former system calls
 .Fn time

Reply via email to