* lib/utime.in.h: Include next <utime.h> if it exists.
(utimbuf): Define to _utimbuf on native Windows.
* m4/utime-h.m4 (gl_UTIME_H): Check for prerequisites of include_next.
Set UTIME_H on native Windows.
(gl_UTIME_MODULE_INDICATOR, gl_HEADER_UTIME_H_DEFAULTS): New macros.
* modules/utime-h (Depends-on): Add include_next.
(Makefile.am): Substitute also HAVE_UTIME_H, INCLUDE_NEXT,
PRAGMA_SYSTEM_HEADER, PRAGMA_COLUMNS, NEXT_UTIME_H.
* lib/utimens.c (utimbuf): Remove fallback definition.
* m4/utimens.m4 (gl_UTIMENS): Don't require
gl_CHECK_TYPE_STRUCT_UTIMBUF.
* m4/utimbuf.m4: Remove file.
* modules/utimens (Files): Remove m4/utimbuf.m4.
+2017-04-29 Bruno Haible <bruno@clisp.org>
+
+ utime-h: Modernize handling of 'struct utimbuf'.
+ * lib/utime.in.h: Include next <utime.h> if it exists.
+ (utimbuf): Define to _utimbuf on native Windows.
+ * m4/utime_h.m4 (gl_UTIME_H): Check for prerequisites of include_next.
+ Set UTIME_H on native Windows.
+ (gl_UTIME_MODULE_INDICATOR, gl_HEADER_UTIME_H_DEFAULTS): New macros.
+ * modules/utime-h (Depends-on): Add include_next.
+ (Makefile.am): Substitute also HAVE_UTIME_H, INCLUDE_NEXT,
+ PRAGMA_SYSTEM_HEADER, PRAGMA_COLUMNS, NEXT_UTIME_H.
+
+ * lib/utimens.c (utimbuf): Remove fallback definition.
+ * m4/utimens.m4 (gl_UTIMENS): Don't require
+ gl_CHECK_TYPE_STRUCT_UTIMBUF.
+ * m4/utimbuf.m4: Remove file.
+ * modules/utimens (Files): Remove m4/utimbuf.m4.
+
2017-04-29 Bruno Haible <bruno@clisp.org>
Make use of module 'utime-h'.
-/* Substitute for <utime.h>
+/* Substitute for and wrapper around <utime.h>.
Copyright (C) 2017 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
You should have received a copy of the GNU General Public License
along with this program; if not, see <http://www.gnu.org/licenses/>. */
+#ifndef _@GUARD_PREFIX@_UTIME_H
+
+#if __GNUC__ >= 3
+@PRAGMA_SYSTEM_HEADER@
+#endif
+@PRAGMA_COLUMNS@
+
+/* The include_next requires a split double-inclusion guard. */
+#if @HAVE_UTIME_H@
+# @INCLUDE_NEXT@ @NEXT_UTIME_H@
+#endif
+
#ifndef _@GUARD_PREFIX@_UTIME_H
#define _@GUARD_PREFIX@_UTIME_H
-#include <sys/utime.h>
+#if !@HAVE_UTIME_H@
+# include <sys/utime.h>
+#endif
+#if (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__
+
+/* Define 'struct utimbuf' as an alias of 'struct _utimbuf'
+ (or possibly, if present, 'struct __utimbuf64'). */
+# define utimbuf _utimbuf
+
+#endif
+
+#endif /* _@GUARD_PREFIX@_UTIME_H */
#endif /* _@GUARD_PREFIX@_UTIME_H */
#include "stat-time.h"
#include "timespec.h"
-/* Some systems (even some that do have <utime.h>) don't declare this
- structure anywhere. */
-#ifndef HAVE_STRUCT_UTIMBUF
-struct utimbuf
-{
- long actime;
- long modtime;
-};
-#endif
-
/* Avoid recursion with rpl_futimens or rpl_utimensat. */
#undef futimens
#undef utimensat
+++ /dev/null
-# serial 9
-
-# Copyright (C) 1998-2001, 2003-2004, 2007, 2009-2017 Free Software Foundation,
-# Inc.
-#
-# This file is free software; the Free Software Foundation
-# gives unlimited permission to copy and/or distribute it,
-# with or without modifications, as long as this notice is preserved.
-
-dnl From Jim Meyering
-
-dnl Define HAVE_STRUCT_UTIMBUF if 'struct utimbuf' is declared --
-dnl usually in <utime.h>.
-dnl Some systems have utime.h but don't declare the struct anywhere.
-
-AC_DEFUN([gl_CHECK_TYPE_STRUCT_UTIMBUF],
-[
- AC_CHECK_HEADERS_ONCE([sys/time.h utime.h])
- AC_CACHE_CHECK([for struct utimbuf], [gl_cv_sys_struct_utimbuf],
- [AC_COMPILE_IFELSE(
- [AC_LANG_PROGRAM(
- [[#if HAVE_SYS_TIME_H
- #include <sys/time.h>
- #endif
- #include <time.h>
- #ifdef HAVE_UTIME_H
- #include <utime.h>
- #endif
- ]],
- [[static struct utimbuf x; x.actime = x.modtime;]])],
- [gl_cv_sys_struct_utimbuf=yes],
- [gl_cv_sys_struct_utimbuf=no])])
-
- if test $gl_cv_sys_struct_utimbuf = yes; then
- AC_DEFINE([HAVE_STRUCT_UTIMBUF], [1],
- [Define if struct utimbuf is declared -- usually in <utime.h>.
- Some systems have utime.h but don't declare the struct anywhere. ])
- fi
-])
AC_DEFUN([gl_UTIME_H],
[
- UTIME_H=''
+ AC_REQUIRE([AC_CANONICAL_HOST])
+ AC_REQUIRE([gl_UTIME_H_DEFAULTS])
AC_CHECK_HEADERS_ONCE([utime.h])
+ gl_CHECK_NEXT_HEADERS([utime.h])
+
+ if test $ac_cv_header_utime_h = yes; then
+ HAVE_UTIME_H=1
+ else
+ HAVE_UTIME_H=0
+ fi
+ AC_SUBST([HAVE_UTIME_H])
+
+ UTIME_H=''
if test $ac_cv_header_utime_h != yes; then
dnl Provide a substitute <utime.h> file.
UTIME_H=utime.h
+ else
+ case "$host_os" in
+ mingw*) dnl Need special handling of 'struct utimbuf'.
+ UTIME_H=utime.h
+ ;;
+ esac
fi
AC_SUBST([UTIME_H])
AM_CONDITIONAL([GL_GENERATE_UTIME_H], [test -n "$UTIME_H"])
])
+
+AC_DEFUN([gl_UTIME_MODULE_INDICATOR],
+[
+ dnl Use AC_REQUIRE here, so that the default settings are expanded once only.
+ AC_REQUIRE([gl_UTIME_H_DEFAULTS])
+ gl_MODULE_INDICATOR_SET_VARIABLE([$1])
+ dnl Define it also as a C macro, for the benefit of the unit tests.
+ gl_MODULE_INDICATOR_FOR_TESTS([$1])
+])
+
+AC_DEFUN([gl_UTIME_H_DEFAULTS],
+[
+ dnl Assume POSIX behavior unless another module says otherwise.
+])
dnl gives unlimited permission to copy and/or distribute it,
dnl with or without modifications, as long as this notice is preserved.
-dnl serial 7
+dnl serial 8
AC_DEFUN([gl_UTIMENS],
[
dnl Prerequisites of lib/utimens.c.
AC_REQUIRE([gl_FUNC_UTIMES])
AC_REQUIRE([gl_CHECK_TYPE_STRUCT_TIMESPEC])
- AC_REQUIRE([gl_CHECK_TYPE_STRUCT_UTIMBUF])
AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles
AC_CHECK_FUNCS_ONCE([futimes futimesat futimens utimensat lutimes])
m4/utime_h.m4
Depends-on:
+include_next
configure.ac:
gl_UTIME_H
$(AM_V_GEN)rm -f $@-t $@ && \
{ echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */' && \
sed -e 's|@''GUARD_PREFIX''@|${gl_include_guard_prefix}|g' \
+ -e 's/@''HAVE_UTIME_H''@/$(HAVE_UTIME_H)/g' \
+ -e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \
+ -e 's|@''PRAGMA_SYSTEM_HEADER''@|@PRAGMA_SYSTEM_HEADER@|g' \
+ -e 's|@''PRAGMA_COLUMNS''@|@PRAGMA_COLUMNS@|g' \
+ -e 's|@''NEXT_UTIME_H''@|$(NEXT_UTIME_H)|g' \
< $(srcdir)/utime.in.h; \
} > $@-t && \
mv $@-t $@
Files:
lib/utimens.c
lib/utimens.h
-m4/utimbuf.m4
m4/utimens.m4
m4/utimes.m4