diff options
author | Eric Blake <ebb9@byu.net> | 2009-12-30 09:47:55 -0700 |
---|---|---|
committer | Eric Blake <ebb9@byu.net> | 2009-12-31 06:03:31 -0700 |
commit | f2f428037cd5dcf93c4cc8cfacf4dd92f0f250bd (patch) | |
tree | 460b6c226224b430c141f88954633f60b9b97289 | |
parent | 3542c9a082fdfb38d6ac7a051839bf70ccffef0f (diff) | |
download | gnulib-f2f428037cd5dcf93c4cc8cfacf4dd92f0f250bd.tar.gz |
sys_times, sys_utsname: use include_next
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>
-rw-r--r-- | ChangeLog | 14 | ||||
-rw-r--r-- | lib/sys_times.in.h | 13 | ||||
-rw-r--r-- | lib/sys_utsname.in.h | 44 | ||||
-rw-r--r-- | m4/sys_times_h.m4 | 13 | ||||
-rw-r--r-- | m4/sys_utsname_h.m4 | 18 | ||||
-rw-r--r-- | modules/sys_times | 11 | ||||
-rw-r--r-- | modules/sys_utsname | 10 | ||||
-rw-r--r-- | tests/test-sys_times.c | 5 |
8 files changed, 100 insertions, 28 deletions
@@ -1,5 +1,19 @@ 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. diff --git a/lib/sys_times.in.h b/lib/sys_times.in.h index 2af1e58a3a..31ab4ce37c 100644 --- a/lib/sys_times.in.h +++ b/lib/sys_times.in.h @@ -21,6 +21,15 @@ 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. */ @@ -34,6 +43,7 @@ extern "C" { # endif +# if !@HAVE_STRUCT_TMS@ /* Structure describing CPU time used by a process and its children. */ struct tms { @@ -43,9 +53,12 @@ extern "C" { 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) \ diff --git a/lib/sys_utsname.in.h b/lib/sys_utsname.in.h index 2a263485ce..0e3d7cd2b3 100644 --- a/lib/sys_utsname.in.h +++ b/lib/sys_utsname.in.h @@ -16,6 +16,15 @@ 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. */ @@ -27,25 +36,25 @@ 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 @@ -63,6 +72,7 @@ struct utsname /* Name of the hardware type the system is running on. */ char machine[_UTSNAME_MACHINE_LENGTH]; }; +#endif /* !@HAVE_STRUCT_UTSNAME@ */ #if @GNULIB_UNAME@ diff --git a/m4/sys_times_h.m4 b/m4/sys_times_h.m4 index aaff00aeeb..2fe9f24c1f 100644 --- a/m4/sys_times_h.m4 +++ b/m4/sys_times_h.m4 @@ -1,4 +1,5 @@ # 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 @@ -11,13 +12,21 @@ AC_DEFUN([gl_SYS_TIMES_H], [ 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], @@ -29,5 +38,7 @@ 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]) ]) diff --git a/m4/sys_utsname_h.m4 b/m4/sys_utsname_h.m4 index 2e688fb15e..84b781f85e 100644 --- a/m4/sys_utsname_h.m4 +++ b/m4/sys_utsname_h.m4 @@ -1,4 +1,4 @@ -# 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, @@ -12,10 +12,19 @@ AC_DEFUN([gl_SYS_UTSNAME_H], 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], @@ -27,8 +36,9 @@ 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]) ]) diff --git a/modules/sys_times b/modules/sys_times index 23af537414..8ccf5dab35 100644 --- a/modules/sys_times +++ b/modules/sys_times @@ -6,8 +6,9 @@ lib/sys_times.in.h m4/sys_times_h.m4 Depends-on: -link-warning arg-nonnull +include_next +link-warning configure.ac: gl_SYS_TIMES_H @@ -22,7 +23,13 @@ sys/times.h: sys_times.in.h $(LINK_WARNING_H) $(ARG_NONNULL_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; \ diff --git a/modules/sys_utsname b/modules/sys_utsname index 83e337d83f..cdb3468033 100644 --- a/modules/sys_utsname +++ b/modules/sys_utsname @@ -6,8 +6,9 @@ lib/sys_utsname.in.h m4/sys_utsname_h.m4 Depends-on: -link-warning arg-nonnull +include_next +link-warning configure.ac: gl_SYS_UTSNAME_H @@ -22,7 +23,12 @@ sys/utsname.h: sys_utsname.in.h $(LINK_WARNING_H) $(ARG_NONNULL_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)' \ diff --git a/tests/test-sys_times.c b/tests/test-sys_times.c index 5f367479c7..22e4bc6ad1 100644 --- a/tests/test-sys_times.c +++ b/tests/test-sys_times.c @@ -20,10 +20,11 @@ #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; } |