Another step towards being able to make GL_LINK_WARNING useful.
* m4/sys_times_h.m4 (gl_SYS_TIMES_H): Support wrapping an existing
header.
(gl_SYS_TIMES_H_DEFAULTS): Add another variable.
* m4/sys_utsname_h.m4 (gl_SYS_UTSNAME_H)
(gl_SYS_UTSNAME_H_DEFAULTS): Likewise.
* modules/sys_times (Depends-on): Add include_next.
(Makefile.am): Substitute additional values.
* modules/sys_utsname (Depends-on, Makefile.am): Likewise.
* lib/sys_times.in.h (includes): Include native header, if
available.
* lib/sys_utsname.in.h (includes): Likewise.
* tests/test-sys_times.c (main): Enhance test.
Signed-off-by: Eric Blake <ebb9@byu.net>
2009-12-31 Eric Blake <ebb9@byu.net>
+ sys_times, sys_utsname: use include_next
+ * m4/sys_times_h.m4 (gl_SYS_TIMES_H): Support wrapping an existing
+ header.
+ (gl_SYS_TIMES_H_DEFAULTS): Add another variable.
+ * m4/sys_utsname_h.m4 (gl_SYS_UTSNAME_H)
+ (gl_SYS_UTSNAME_H_DEFAULTS): Likewise.
+ * modules/sys_times (Depends-on): Add include_next.
+ (Makefile.am): Substitute additional values.
+ * modules/sys_utsname (Depends-on, Makefile.am): Likewise.
+ * lib/sys_times.in.h (includes): Include native header, if
+ available.
+ * lib/sys_utsname.in.h (includes): Likewise.
+ * tests/test-sys_times.c (main): Enhance test.
+
fdutimensat: revert prior patch
* modules/fdutimensat (Depends-on): Re-add inline; it is needed by
utimens.h.
is missing. */
#ifndef _GL_SYS_TIMES_H
+
+# if __GNUC__ >= 3
+@PRAGMA_SYSTEM_HEADER@
+# endif
+
+# if @HAVE_SYS_TIMES_H@
+# @INCLUDE_NEXT@ @NEXT_SYS_TIMES_H@
+# endif
+
# define _GL_SYS_TIMES_H
/* Get clock_t. */
extern "C" {
# endif
+# if !@HAVE_STRUCT_TMS@
/* Structure describing CPU time used by a process and its children. */
struct tms
{
clock_t tms_cutime; /* User CPU time of dead children. */
clock_t tms_cstime; /* System CPU time of dead children. */
};
+# endif
# if @GNULIB_TIMES@
+# if !@HAVE_TIMES@
extern clock_t times (struct tms *buffer) _GL_ARG_NONNULL ((1));
+# endif
# elif defined GNULIB_POSIXCHECK
# undef times
# define times(s) \
Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */
#ifndef _GL_SYS_UTSNAME_H
+
+#if __GNUC__ >= 3
+@PRAGMA_SYSTEM_HEADER@
+#endif
+
+#if @HAVE_SYS_UTSNAME_H@
+# @INCLUDE_NEXT@ @NEXT_SYS_UTSNAME_H@
+#endif
+
#define _GL_SYS_UTSNAME_H
/* The definition of GL_LINK_WARNING is copied here. */
extern "C" {
#endif
-
+#if !@HAVE_STRUCT_UTSNAME@
/* Length of the entries in 'struct utsname' is 256. */
-#define _UTSNAME_LENGTH 256
+# define _UTSNAME_LENGTH 256
-#ifndef _UTSNAME_NODENAME_LENGTH
-# define _UTSNAME_NODENAME_LENGTH _UTSNAME_LENGTH
-#endif
-#ifndef _UTSNAME_SYSNAME_LENGTH
-# define _UTSNAME_SYSNAME_LENGTH _UTSNAME_LENGTH
-#endif
-#ifndef _UTSNAME_RELEASE_LENGTH
-# define _UTSNAME_RELEASE_LENGTH _UTSNAME_LENGTH
-#endif
-#ifndef _UTSNAME_VERSION_LENGTH
-# define _UTSNAME_VERSION_LENGTH _UTSNAME_LENGTH
-#endif
-#ifndef _UTSNAME_MACHINE_LENGTH
-# define _UTSNAME_MACHINE_LENGTH _UTSNAME_LENGTH
-#endif
+# ifndef _UTSNAME_NODENAME_LENGTH
+# define _UTSNAME_NODENAME_LENGTH _UTSNAME_LENGTH
+# endif
+# ifndef _UTSNAME_SYSNAME_LENGTH
+# define _UTSNAME_SYSNAME_LENGTH _UTSNAME_LENGTH
+# endif
+# ifndef _UTSNAME_RELEASE_LENGTH
+# define _UTSNAME_RELEASE_LENGTH _UTSNAME_LENGTH
+# endif
+# ifndef _UTSNAME_VERSION_LENGTH
+# define _UTSNAME_VERSION_LENGTH _UTSNAME_LENGTH
+# endif
+# ifndef _UTSNAME_MACHINE_LENGTH
+# define _UTSNAME_MACHINE_LENGTH _UTSNAME_LENGTH
+# endif
/* Structure describing the system and machine. */
struct utsname
/* Name of the hardware type the system is running on. */
char machine[_UTSNAME_MACHINE_LENGTH];
};
+#endif /* !@HAVE_STRUCT_UTSNAME@ */
#if @GNULIB_UNAME@
# Configure a replacement for <sys/times.h>.
+# serial 2
# Copyright (C) 2008, 2009 Free Software Foundation, Inc.
# This file is free software; the Free Software Foundation
[
AC_REQUIRE([gl_SYS_TIMES_H_DEFAULTS])
+ gl_CHECK_NEXT_HEADERS([sys/times.h])
AC_CHECK_HEADERS_ONCE([sys/times.h])
if test $ac_cv_header_sys_times_h = yes; then
SYS_TIMES_H=
+ HAVE_SYS_TIMES_H=1
+ AC_CHECK_TYPES([struct tms], [], [HAVE_STRUCT_TMS=0], [[
+#include <sys/times.h>
+ ]])
else
SYS_TIMES_H=sys/times.h
+ HAVE_SYS_TIMES_H=0
+ HAVE_STRUCT_TMS=0
fi
AC_SUBST([SYS_TIMES_H])
+ AC_SUBST([HAVE_SYS_TIMES_H])
])
AC_DEFUN([gl_SYS_TIMES_MODULE_INDICATOR],
AC_DEFUN([gl_SYS_TIMES_H_DEFAULTS],
[
- GNULIB_TIMES=0; AC_SUBST([GNULIB_TIMES])
+ GNULIB_TIMES=0; AC_SUBST([GNULIB_TIMES])
+ HAVE_STRUCT_TMS=1; AC_SUBST([HAVE_STRUCT_TMS])
+ HAVE_TIMES=1; AC_SUBST([HAVE_TIMES])
])
-# sys_utsname_h.m4 serial 1
+# sys_utsname_h.m4 serial 2
dnl Copyright (C) 2009 Free Software Foundation, Inc.
dnl This file is free software; the Free Software Foundation
dnl gives unlimited permission to copy and/or distribute it,
dnl once only, before all statements that occur in other macros.
AC_REQUIRE([gl_SYS_UTSNAME_H_DEFAULTS])
+ gl_CHECK_NEXT_HEADERS([sys/utsname.h])
AC_CHECK_HEADERS_ONCE([sys/utsname.h])
if test $ac_cv_header_sys_utsname_h != yes; then
SYS_UTSNAME_H='sys/utsname.h'
+ HAVE_SYS_UTSNAME_H=0
+ HAVE_STRUCT_UTSNAME=0
+ else
+ HAVE_SYS_UTSNAME_H=1
+ AC_CHECK_TYPES([struct utsname], [], [HAVE_STRUCT_UTSNAME=0], [[
+#include <sys/utsname.h>
+ ]])
fi
+ AC_SUBST([HAVE_SYS_UTSNAME_H])
])
AC_DEFUN([gl_SYS_UTSNAME_MODULE_INDICATOR],
AC_DEFUN([gl_SYS_UTSNAME_H_DEFAULTS],
[
- GNULIB_UNAME=0; AC_SUBST([GNULIB_UNAME])
+ GNULIB_UNAME=0; AC_SUBST([GNULIB_UNAME])
dnl Assume proper GNU behavior unless another module says otherwise.
- HAVE_UNAME=1; AC_SUBST([HAVE_UNAME])
- SYS_UTSNAME_H=''; AC_SUBST([SYS_UTSNAME_H])
+ HAVE_UNAME=1; AC_SUBST([HAVE_UNAME])
+ HAVE_STRUCT_UTSNAME=1; AC_SUBST([HAVE_STRUCT_UTSNAME])
+ SYS_UTSNAME_H=''; AC_SUBST([SYS_UTSNAME_H])
])
m4/sys_times_h.m4
Depends-on:
-link-warning
arg-nonnull
+include_next
+link-warning
configure.ac:
gl_SYS_TIMES_H
$(AM_V_at)$(MKDIR_P) sys
$(AM_V_GEN)rm -f $@-t $@ && \
{ echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \
- sed -e 's|@''GNULIB_TIMES''@|$(GNULIB_TIMES)|g' \
+ sed -e 's/@''HAVE_SYS_TIMES_H''@/$(HAVE_SYS_TIMES_H)/g' \
+ -e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \
+ -e 's|@''PRAGMA_SYSTEM_HEADER''@|@PRAGMA_SYSTEM_HEADER@|g' \
+ -e 's|@''NEXT_SYS_TIMES_H''@|$(NEXT_SYS_TIMES_H)|g' \
+ -e 's|@''GNULIB_TIMES''@|$(GNULIB_TIMES)|g' \
+ -e 's|@''HAVE_STRUCT_TMS''@|$(HAVE_STRUCT_TMS)|g' \
+ -e 's|@''HAVE_TIMES''@|$(HAVE_TIMES)|g' \
-e '/definition of GL_LINK_WARNING/r $(LINK_WARNING_H)' \
-e '/definition of _GL_ARG_NONNULL/r $(ARG_NONNULL_H)' \
< $(srcdir)/sys_times.in.h; \
m4/sys_utsname_h.m4
Depends-on:
-link-warning
arg-nonnull
+include_next
+link-warning
configure.ac:
gl_SYS_UTSNAME_H
$(AM_V_at)$(MKDIR_P) sys
$(AM_V_GEN)rm -f $@-t $@ && \
{ echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \
- sed -e 's|@''GNULIB_UNAME''@|$(GNULIB_UNAME)|g' \
+ sed -e 's/@''HAVE_SYS_UTSNAME_H''@/$(HAVE_SYS_UTSNAME_H)/g' \
+ -e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \
+ -e 's|@''PRAGMA_SYSTEM_HEADER''@|@PRAGMA_SYSTEM_HEADER@|g' \
+ -e 's|@''NEXT_SYS_UTSNAME_H''@|$(NEXT_SYS_UTSNAME_H)|g' \
+ -e 's|@''GNULIB_UNAME''@|$(GNULIB_UNAME)|g' \
+ -e 's|@''HAVE_STRUCT_UTSNAME''@|$(HAVE_STRUCT_UTSNAME)|g' \
-e 's|@''HAVE_UNAME''@|$(HAVE_UNAME)|g' \
-e '/definition of GL_LINK_WARNING/r $(LINK_WARNING_H)' \
-e '/definition of _GL_ARG_NONNULL/r $(ARG_NONNULL_H)' \
#include <sys/times.h>
-struct tms tms;
+static struct tms tms;
int
main (void)
{
- return 0;
+ clock_t t = tms.tms_utime + tms.tms_stime + tms.tms_cutime + tms.tms_cstime;
+ return t;
}