On 9/18/18 11:37 AM, Bruno Haible wrote:
What is this code good for?

Nothing. Thanks, good catch. That code came from this FreeBSD man page:

https://www.freebsd.org/cgi/man.cgi?query=nanotime&manpath=FreeBSD+11.2-RELEASE+and+Ports

an earlier version of which I misread long ago as specifying a way to get nanosecond-resolution timestamps on FreeBSD variants that did not support clock_gettime. The man page documents FreeBSD internals; I misread it as documenting the C library. macOS (or whatever its name was back then) was the example that I was thinking of at the time; it did not support clock_gettime until 10.12 if <https://github.com/zeromq/libzmq/issues/2175> is to be believed.

I installed the attached two patches; the first fixes the problem you raised, and the second attempts to document the version 10.12 business better.

From ae43baf942b4bbe07a710f8c7a835f6c4854d05f Mon Sep 17 00:00:00 2001
From: Paul Eggert <[email protected]>
Date: Tue, 18 Sep 2018 12:19:02 -0700
Subject: [PATCH 1/2] gettime: nanotime never existed
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Problem reported by Bruno Haible in:
https://lists.gnu.org/r/bug-gnulib/2018-09/msg00082.html
* lib/gettime.c (gettime) [HAVE_NANOTIME]: Remove unused code.
* m4/gettime.m4 (gl_GETTIME): Don’t check for nanotime.
---
 ChangeLog     | 8 ++++++++
 lib/gettime.c | 2 --
 m4/gettime.m4 | 4 ++--
 3 files changed, 10 insertions(+), 4 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 2661001fe..ae7b010a3 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+2018-09-18  Paul Eggert  <[email protected]>
+
+       gettime: nanotime never existed
+       Problem reported by Bruno Haible in:
+       https://lists.gnu.org/r/bug-gnulib/2018-09/msg00082.html
+       * lib/gettime.c (gettime) [HAVE_NANOTIME]: Remove unused code.
+       * m4/gettime.m4 (gl_GETTIME): Don’t check for nanotime.
+
 2018-09-18  Bruno Haible  <[email protected]>
 
        doc: Update statement about target platforms.
diff --git a/lib/gettime.c b/lib/gettime.c
index 171f22476..bb59c44ff 100644
--- a/lib/gettime.c
+++ b/lib/gettime.c
@@ -30,8 +30,6 @@ gettime (struct timespec *ts)
 {
 #if defined CLOCK_REALTIME && HAVE_CLOCK_GETTIME
   clock_gettime (CLOCK_REALTIME, ts);
-#elif HAVE_NANOTIME
-  nanotime (ts);
 #else
   struct timeval tv;
   gettimeofday (&tv, NULL);
diff --git a/m4/gettime.m4 b/m4/gettime.m4
index ad355463c..671b70d5a 100644
--- a/m4/gettime.m4
+++ b/m4/gettime.m4
@@ -1,4 +1,4 @@
-# gettime.m4 serial 8
+# gettime.m4 serial 9
 dnl Copyright (C) 2002, 2004-2006, 2009-2018 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
@@ -9,5 +9,5 @@ AC_DEFUN([gl_GETTIME],
   dnl Prerequisites of lib/gettime.c.
   AC_REQUIRE([gl_CLOCK_TIME])
   AC_REQUIRE([gl_TIMESPEC])
-  AC_CHECK_FUNCS_ONCE([gettimeofday nanotime])
+  AC_CHECK_FUNCS_ONCE([gettimeofday])
 ])
-- 
2.17.1

From 9fd8e9d93920dc6fb90368cada95078e366c2601 Mon Sep 17 00:00:00 2001
From: Paul Eggert <[email protected]>
Date: Tue, 18 Sep 2018 12:19:02 -0700
Subject: [PATCH 2/2] doc: OS X 10.11 lacked ns time functions

According to <https://github.com/zeromq/libzmq/issues/2175>,
nanosecond-resolution timestamp functions were introduced
in macOS 10.12, so document the last version (OS X 10.11)
where they were absent.
---
 ChangeLog                                    | 6 ++++++
 doc/posix-functions/clock_getcpuclockid.texi | 2 +-
 doc/posix-functions/clock_getres.texi        | 2 +-
 doc/posix-functions/clock_gettime.texi       | 4 +++-
 doc/posix-functions/clock_nanosleep.texi     | 2 +-
 doc/posix-functions/clock_settime.texi       | 2 +-
 doc/posix-functions/timer_create.texi        | 2 +-
 doc/posix-functions/timer_delete.texi        | 2 +-
 doc/posix-functions/timer_getoverrun.texi    | 2 +-
 doc/posix-functions/timer_gettime.texi       | 2 +-
 doc/posix-functions/timer_settime.texi       | 2 +-
 11 files changed, 18 insertions(+), 10 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index ae7b010a3..ce41cca0f 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,11 @@
 2018-09-18  Paul Eggert  <[email protected]>
 
+       doc: OS X 10.11 lacked ns time functions
+       According to <https://github.com/zeromq/libzmq/issues/2175>,
+       nanosecond-resolution timestamp functions were introduced
+       in macOS 10.12, so document the last version (OS X 10.11)
+       where they were absent.
+
        gettime: nanotime never existed
        Problem reported by Bruno Haible in:
        https://lists.gnu.org/r/bug-gnulib/2018-09/msg00082.html
diff --git a/doc/posix-functions/clock_getcpuclockid.texi 
b/doc/posix-functions/clock_getcpuclockid.texi
index 41b8ceace..abf97c4b6 100644
--- a/doc/posix-functions/clock_getcpuclockid.texi
+++ b/doc/posix-functions/clock_getcpuclockid.texi
@@ -14,5 +14,5 @@ Portability problems not fixed by Gnulib:
 @itemize
 @item
 This function is missing on some platforms:
-Mac OS X 10.5, FreeBSD 6.0, NetBSD 5.0, OpenBSD 3.8, Minix 3.1.8, AIX 5.1, 
HP-UX 11, IRIX 6.5, OSF/1 5.1, Solaris 11.3, Cygwin 1.7.9, mingw, MSVC 14, 
Interix 3.5, BeOS, Android 5.1.
+OS X 10.11, FreeBSD 6.0, NetBSD 5.0, OpenBSD 3.8, Minix 3.1.8, AIX 5.1, HP-UX 
11, IRIX 6.5, OSF/1 5.1, Solaris 11.3, Cygwin 1.7.9, mingw, MSVC 14, Interix 
3.5, BeOS, Android 5.1.
 @end itemize
diff --git a/doc/posix-functions/clock_getres.texi 
b/doc/posix-functions/clock_getres.texi
index 42aa297eb..04ed2da0c 100644
--- a/doc/posix-functions/clock_getres.texi
+++ b/doc/posix-functions/clock_getres.texi
@@ -14,5 +14,5 @@ Portability problems not fixed by Gnulib:
 @itemize
 @item
 This function is missing on some platforms:
-Mac OS X 10.5, Minix 3.1.8, IRIX 5.3, Solaris 2.4, mingw, MSVC 14, Interix 
3.5, BeOS.
+OS X 10.11, Minix 3.1.8, IRIX 5.3, Solaris 2.4, mingw, MSVC 14, Interix 3.5, 
BeOS.
 @end itemize
diff --git a/doc/posix-functions/clock_gettime.texi 
b/doc/posix-functions/clock_gettime.texi
index 2b7685369..b7d7686f0 100644
--- a/doc/posix-functions/clock_gettime.texi
+++ b/doc/posix-functions/clock_gettime.texi
@@ -14,5 +14,7 @@ Portability problems not fixed by Gnulib:
 @itemize
 @item
 This function is missing on some platforms:
-Mac OS X 10.5, Minix 3.1.8, IRIX 5.3, Solaris 2.4, mingw, MSVC 14, Interix 
3.5, BeOS.
+OS X 10.11, Minix 3.1.8, IRIX 5.3, Solaris 2.4, mingw, MSVC 14, Interix 3.5, 
BeOS.
+The Gnulib module @code{gettime} is a partial substitute; it
+implements the @code{CLOCK_REALTIME} functionality of @code{clock_gettime}.
 @end itemize
diff --git a/doc/posix-functions/clock_nanosleep.texi 
b/doc/posix-functions/clock_nanosleep.texi
index 28c4d55f7..cfdda7a29 100644
--- a/doc/posix-functions/clock_nanosleep.texi
+++ b/doc/posix-functions/clock_nanosleep.texi
@@ -14,5 +14,5 @@ Portability problems not fixed by Gnulib:
 @itemize
 @item
 This function is missing on some platforms:
-Mac OS X 10.5, FreeBSD 6.0, NetBSD 5.0, OpenBSD 3.8, Minix 3.1.8, AIX 5.1, 
HP-UX 11, IRIX 6.5, OSF/1 5.1, Solaris 9, Cygwin 1.7.9, mingw, MSVC 14, Interix 
3.5, BeOS.
+OS X 10.11, FreeBSD 6.0, NetBSD 5.0, OpenBSD 3.8, Minix 3.1.8, AIX 5.1, HP-UX 
11, IRIX 6.5, OSF/1 5.1, Solaris 9, Cygwin 1.7.9, mingw, MSVC 14, Interix 3.5, 
BeOS.
 @end itemize
diff --git a/doc/posix-functions/clock_settime.texi 
b/doc/posix-functions/clock_settime.texi
index b2643165d..05548743d 100644
--- a/doc/posix-functions/clock_settime.texi
+++ b/doc/posix-functions/clock_settime.texi
@@ -14,5 +14,5 @@ Portability problems not fixed by Gnulib:
 @itemize
 @item
 This function is missing on some platforms:
-Mac OS X 10.5, Minix 3.1.8, IRIX 5.3, Solaris 2.4, Cygwin 1.7.9, mingw, MSVC 
14, Interix 3.5, BeOS.
+OS X 10.11, Minix 3.1.8, IRIX 5.3, Solaris 2.4, Cygwin 1.7.9, mingw, MSVC 14, 
Interix 3.5, BeOS.
 @end itemize
diff --git a/doc/posix-functions/timer_create.texi 
b/doc/posix-functions/timer_create.texi
index 00c037e39..aa72ac400 100644
--- a/doc/posix-functions/timer_create.texi
+++ b/doc/posix-functions/timer_create.texi
@@ -14,7 +14,7 @@ Portability problems not fixed by Gnulib:
 @itemize
 @item
 This function is missing on some platforms:
-Mac OS X 10.5, FreeBSD 6.4, Minix 3.1.8, IRIX 5.3, Solaris 2.4, mingw, MSVC 
14, Interix 3.5, BeOS, Tandem/NSK.
+OS X 10.11, FreeBSD 6.4, Minix 3.1.8, IRIX 5.3, Solaris 2.4, mingw, MSVC 14, 
Interix 3.5, BeOS, Tandem/NSK.
 @item
 This function fails with @code{ENOSYS} on some platforms:
 OpenBSD 4.9.
diff --git a/doc/posix-functions/timer_delete.texi 
b/doc/posix-functions/timer_delete.texi
index d9c5a7836..9d0f6cc0d 100644
--- a/doc/posix-functions/timer_delete.texi
+++ b/doc/posix-functions/timer_delete.texi
@@ -14,7 +14,7 @@ Portability problems not fixed by Gnulib:
 @itemize
 @item
 This function is missing on some platforms:
-Mac OS X 10.5, FreeBSD 6.4, Minix 3.1.8, IRIX 5.3, Solaris 2.4, mingw, MSVC 
14, Interix 3.5, BeOS, Tandem/NSK.
+OS X 10.11, FreeBSD 6.4, Minix 3.1.8, IRIX 5.3, Solaris 2.4, mingw, MSVC 14, 
Interix 3.5, BeOS, Tandem/NSK.
 @item
 This function fails with @code{ENOSYS} on some platforms:
 OpenBSD 4.9.
diff --git a/doc/posix-functions/timer_getoverrun.texi 
b/doc/posix-functions/timer_getoverrun.texi
index 3140bccac..e9c3f70c9 100644
--- a/doc/posix-functions/timer_getoverrun.texi
+++ b/doc/posix-functions/timer_getoverrun.texi
@@ -14,5 +14,5 @@ Portability problems not fixed by Gnulib:
 @itemize
 @item
 This function is missing on some platforms:
-Mac OS X 10.5, FreeBSD 6.0, Minix 3.1.8, IRIX 5.3, Solaris 2.4, Cygwin, mingw, 
MSVC 14, Interix 3.5, BeOS.
+OS X 10.11, FreeBSD 6.0, Minix 3.1.8, IRIX 5.3, Solaris 2.4, Cygwin, mingw, 
MSVC 14, Interix 3.5, BeOS.
 @end itemize
diff --git a/doc/posix-functions/timer_gettime.texi 
b/doc/posix-functions/timer_gettime.texi
index 924f6bf23..ae6dacc5c 100644
--- a/doc/posix-functions/timer_gettime.texi
+++ b/doc/posix-functions/timer_gettime.texi
@@ -14,7 +14,7 @@ Portability problems not fixed by Gnulib:
 @itemize
 @item
 This function is missing on some platforms:
-Mac OS X 10.5, FreeBSD 6.4, Minix 3.1.8, IRIX 5.3, mingw, MSVC 14, Interix 
3.5, BeOS, Tandem/NSK.
+OS X 10.11, FreeBSD 6.4, Minix 3.1.8, IRIX 5.3, mingw, MSVC 14, Interix 3.5, 
BeOS, Tandem/NSK.
 @item
 This function fails with @code{ENOSYS} on some platforms:
 OpenBSD 4.9.
diff --git a/doc/posix-functions/timer_settime.texi 
b/doc/posix-functions/timer_settime.texi
index f27122b05..73189f360 100644
--- a/doc/posix-functions/timer_settime.texi
+++ b/doc/posix-functions/timer_settime.texi
@@ -14,7 +14,7 @@ Portability problems not fixed by Gnulib:
 @itemize
 @item
 This function is missing on some platforms:
-Mac OS X 10.5, FreeBSD 6.4, Minix 3.1.8, IRIX 5.3, Solaris 2.4, mingw, MSVC 
14, Interix 3.5, BeOS, Tandem/NSK.
+OS X 10.11, FreeBSD 6.4, Minix 3.1.8, IRIX 5.3, Solaris 2.4, mingw, MSVC 14, 
Interix 3.5, BeOS, Tandem/NSK.
 @item
 This function fails with @code{ENOSYS} on some platforms:
 OpenBSD 4.9.
-- 
2.17.1

Reply via email to