]> Savannah Git Hosting - gnulib.git/commitdiff
utimens: port to NetBSD-10.99.12/amd64
authorPaul Eggert <eggert@cs.ucla.edu>
Tue, 17 Sep 2024 06:55:37 +0000 (23:55 -0700)
committerPaul Eggert <eggert@cs.ucla.edu>
Tue, 17 Sep 2024 06:56:17 +0000 (23:56 -0700)
On this platform, <sys/time.h> declares utimens and lutimens and the
C library defines them, so we needn’t (and shouldn’t).
Problem reported privately by Thomas Klausner.
* lib/utimens.c (utimens) [HAVE_UTIMENS]: Don’t define.
(lutimens) [HAVE_LUTIMENS]: Don’t define.
* lib/utimens.h [HAVE_UTIMENS || HAVE_LUTIMENS]:
Include <sys/time.h>, for NetBSD’s declaration of utimens and lutimens.
(utimens) [HAVE_UTIMENS]: Don’t declare.
(lutimens) [HAVE_LUTIMENS]: Don’t declare.
* m4/utimens.m4 (gl_UTIMENS): Check for utimens, lutimens.

ChangeLog
lib/utimens.c
lib/utimens.h
m4/utimens.m4

index 9ba5d0a18400d3dfa956f393bc714ab4f6f12ad6..1270ac58c8c969d06f74ba63d4fee7ce3280bd1e 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,17 @@
+2024-09-16  Paul Eggert  <eggert@cs.ucla.edu>
+
+       utimens: port to NetBSD-10.99.12/amd64
+       On this platform, <sys/time.h> declares utimens and lutimens and the
+       C library defines them, so we needn’t (and shouldn’t).
+       Problem reported privately by Thomas Klausner.
+       * lib/utimens.c (utimens) [HAVE_UTIMENS]: Don’t define.
+       (lutimens) [HAVE_LUTIMENS]: Don’t define.
+       * lib/utimens.h [HAVE_UTIMENS || HAVE_LUTIMENS]:
+       Include <sys/time.h>, for NetBSD’s declaration of utimens and lutimens.
+       (utimens) [HAVE_UTIMENS]: Don’t declare.
+       (lutimens) [HAVE_LUTIMENS]: Don’t declare.
+       * m4/utimens.m4 (gl_UTIMENS): Check for utimens, lutimens.
+
 2024-09-16  Bruno Haible  <bruno@clisp.org>
 
        stdlib: Fix compilation error with Sun C++.
index 6b9f62a53c18bdd41519b41257d03a032cfe6ce3..cd86a44ea7653506777d71dc8e7e43bea9e0af9a 100644 (file)
@@ -516,6 +516,7 @@ fdutimens (int fd, char const *file, struct timespec const timespec[2])
   }
 }
 
+#if !HAVE_UTIMENS
 /* Set the access and modification timestamps of FILE to be
    TIMESPEC[0] and TIMESPEC[1], respectively.  */
 int
@@ -523,7 +524,9 @@ utimens (char const *file, struct timespec const timespec[2])
 {
   return fdutimens (-1, file, timespec);
 }
+#endif
 
+#if !HAVE_LUTIMENS
 /* Set the access and modification timestamps of FILE to be
    TIMESPEC[0] and TIMESPEC[1], respectively, without dereferencing
    symlinks.  Fail with ENOSYS if the platform does not support
@@ -646,3 +649,4 @@ lutimens (char const *file, struct timespec const timespec[2])
   errno = ENOSYS;
   return -1;
 }
+#endif
index b20d4f4f7ee4a17b4170eca158d036b109f28ee1..e85477b84936844b25454b32efb9beb2f770a056 100644 (file)
 
 #include <time.h>
 
+#if HAVE_UTIMENS || HAVE_LUTIMENS
+# include <sys/time.h>
+#endif
+
 #ifdef __cplusplus
 extern "C" {
 #endif
 
 int fdutimens (int, char const *, struct timespec const [2]);
+#if !HAVE_UTIMENS
 int utimens (char const *, struct timespec const [2]);
+#endif
+#if !HAVE_LUTIMENS
 int lutimens (char const *, struct timespec const [2]);
+#endif
 
 #ifdef __cplusplus
 }
index 9996e3ef3365b11ea551244e22d30db74d61329c..b8200deaa252f53c3684a5d9edae0dbc26ccde71 100644 (file)
@@ -1,5 +1,5 @@
 # utimens.m4
-# serial 16
+# serial 17
 dnl Copyright (C) 2003-2024 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
@@ -16,6 +16,7 @@ AC_DEFUN([gl_UTIMENS],
   gl_CHECK_FUNCS_ANDROID([lutimes], [[#include <sys/time.h>]])
   gl_CHECK_FUNCS_ANDROID([futimens], [[#include <sys/stat.h>]])
   gl_CHECK_FUNCS_ANDROID([utimensat], [[#include <sys/stat.h>]])
+  AC_CHECK_FUNCS_ONCE([utimens lutimens])
 
   if test $ac_cv_func_futimens = no && test $ac_cv_func_futimesat = yes; then
     dnl FreeBSD 8.0-rc2 mishandles futimesat(fd,NULL,time).  It is not