2010-02-01 Eric Blake <ebb9@byu.net>
+ sys_time: use link-warning
+ * m4/sys_time_h.m4 (gl_HEADER_SYS_TIME_H_BODY): Split defaults...
+ (gl_HEADER_SYS_TIME_H_DEFAULTS): ...into new macro.
+ (gl_SYS_TIME_MODULE_INDICATOR): New macro.
+ * modules/sys_time (Depends-on): Add warn-on-use.
+ (Makefile.am): Always build replacement.
+ (configure.ac): Update substitutions.
+ * m4/gettimeofday.m4 (gl_FUNC_GETTIMEOFDAY)
+ (gl_FUNC_GETTIMEOFDAY_CLOBBER): Include defaults, and no longer
+ bother with SYS_TIME_H.
+ * modules/gettimeofday (configure.ac): Declare indicator.
+ * lib/sys_time.in.h (gettimeofday): Warn if gnulib module is not
+ in use.
+
closein-tests: silence compiler warning
* tests/test-closein.c (main): Ignore fread result.
* modules/closein-tests (Depends-on): Add ignore-value.
/* The definition of _GL_ARG_NONNULL is copied here. */
+/* The definition of _GL_WARN_ON_USE is copied here. */
+
#ifdef __cplusplus
extern "C" {
#endif
};
# endif
-# if @REPLACE_GETTIMEOFDAY@
-# undef gettimeofday
-# define gettimeofday rpl_gettimeofday
+# if @GNULIB_GETTIMEOFDAY@
+# if @REPLACE_GETTIMEOFDAY@
+# undef gettimeofday
+# define gettimeofday rpl_gettimeofday
extern int gettimeofday (struct timeval *restrict, void *restrict)
_GL_ARG_NONNULL ((1));
+# endif
+# elif defined GNULIB_POSIXCHECK
+# undef gettimeofday
+# if HAVE_RAW_DECL_GETTIMEOFDAY
+_GL_WARN_ON_USE (gettimeofday, "gettimeofday is unportable - "
+ "use gnulib module gettimeofday for portability");
+# endif
# endif
#ifdef __cplusplus
-# serial 12
+# serial 13
# Copyright (C) 2001-2003, 2005, 2007, 2009-2010 Free Software Foundation, Inc.
# This file is free software; the Free Software Foundation
[
AC_REQUIRE([AC_C_RESTRICT])
AC_REQUIRE([gl_HEADER_SYS_TIME_H])
+ AC_REQUIRE([gl_HEADER_SYS_TIME_H_DEFAULTS])
AC_CHECK_FUNCS_ONCE([gettimeofday])
AC_CACHE_CHECK([for gettimeofday with POSIX signature],
if test $gl_cv_func_gettimeofday_posix_signature != yes; then
REPLACE_GETTIMEOFDAY=1
- SYS_TIME_H=sys/time.h
if test $gl_cv_func_gettimeofday_clobber != yes; then
AC_LIBOBJ([gettimeofday])
gl_PREREQ_GETTIMEOFDAY
if test $gl_cv_func_gettimeofday_clobber = yes; then
REPLACE_GETTIMEOFDAY=1
- SYS_TIME_H=sys/time.h
gl_GETTIMEOFDAY_REPLACE_LOCALTIME
AC_DEFINE([GETTIMEOFDAY_CLOBBERS_LOCALTIME], [1],
[Define if gettimeofday clobbers the localtime buffer.])
# Configure a replacement for <sys/time.h>.
-# serial 2
+# serial 3
# Copyright (C) 2007, 2009, 2010 Free Software Foundation, Inc.
# This file is free software; the Free Software Foundation
AC_DEFUN([gl_HEADER_SYS_TIME_H_BODY],
[
AC_REQUIRE([AC_C_RESTRICT])
+ AC_REQUIRE([gl_HEADER_SYS_TIME_H_DEFAULTS])
AC_CHECK_HEADERS_ONCE([sys/time.h])
gl_CHECK_NEXT_HEADERS([sys/time.h])
- if test $ac_cv_header_sys_time_h = yes; then
- HAVE_SYS_TIME_H=1
- else
+ if test $ac_cv_header_sys_time_h != yes; then
HAVE_SYS_TIME_H=0
fi
- AC_SUBST([HAVE_SYS_TIME_H])
AC_CACHE_CHECK([for struct timeval], [gl_cv_sys_struct_timeval],
[AC_COMPILE_IFELSE(
[[static struct timeval x; x.tv_sec = x.tv_usec;]])],
[gl_cv_sys_struct_timeval=yes],
[gl_cv_sys_struct_timeval=no])])
- if test $gl_cv_sys_struct_timeval = yes; then
- HAVE_STRUCT_TIMEVAL=1
- else
+ if test $gl_cv_sys_struct_timeval != yes; then
HAVE_STRUCT_TIMEVAL=0
fi
- AC_SUBST([HAVE_STRUCT_TIMEVAL])
+ dnl Check for declarations of anything we want to poison if the
+ dnl corresponding gnulib module is not in use.
+ gl_WARN_ON_USE_PREPARE([[
+#if HAVE_SYS_TIME_H
+# include <sys/time.h>
+#endif
+#include <time.h>
+ ]], [gettimeofday])
+])
+
+AC_DEFUN([gl_SYS_TIME_MODULE_INDICATOR],
+[
+ dnl Use AC_REQUIRE here, so that the default settings are expanded once only.
+ AC_REQUIRE([gl_HEADER_SYS_TIME_H_DEFAULTS])
+ GNULIB_[]m4_translit([$1],[abcdefghijklmnopqrstuvwxyz./-],[ABCDEFGHIJKLMNOPQRSTUVWXYZ___])=1
+])
+
+AC_DEFUN([gl_HEADER_SYS_TIME_H_DEFAULTS],
+[
+ GNULIB_GETTIMEOFDAY=0; AC_SUBST([GNULIB_GETTIMEOFDAY])
dnl Assume POSIX behavior unless another module says otherwise.
- REPLACE_GETTIMEOFDAY=0
- AC_SUBST([REPLACE_GETTIMEOFDAY])
- if test $HAVE_SYS_TIME_H = 0 || test $HAVE_STRUCT_TIMEVAL = 0; then
- SYS_TIME_H=sys/time.h
- else
- SYS_TIME_H=
- fi
- AC_SUBST([SYS_TIME_H])
+ HAVE_STRUCT_TIMEVAL=1; AC_SUBST([HAVE_STRUCT_TIMEVAL])
+ HAVE_SYS_TIME_H=1; AC_SUBST([HAVE_SYS_TIME_H])
+ REPLACE_GETTIMEOFDAY=0; AC_SUBST([REPLACE_GETTIMEOFDAY])
])
configure.ac:
gl_FUNC_GETTIMEOFDAY
+gl_SYS_TIME_MODULE_INDICATOR([gettimeofday])
Makefile.am:
Depends-on:
include_next
arg-nonnull
+warn-on-use
configure.ac:
gl_HEADER_SYS_TIME_H
AC_PROG_MKDIR_P
Makefile.am:
-BUILT_SOURCES += $(SYS_TIME_H)
+BUILT_SOURCES += sys/time.h
# We need the following in order to create <sys/time.h> when the system
# doesn't have one that works with the given compiler.
-sys/time.h: sys_time.in.h $(ARG_NONNULL_H)
+sys/time.h: sys_time.in.h $(WARN_ON_USE_H) $(ARG_NONNULL_H)
$(AM_V_at)$(MKDIR_P) sys
$(AM_V_GEN)rm -f $@-t $@ && \
{ echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \
-e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \
-e 's|@''PRAGMA_SYSTEM_HEADER''@|@PRAGMA_SYSTEM_HEADER@|g' \
-e 's|@''NEXT_SYS_TIME_H''@|$(NEXT_SYS_TIME_H)|g' \
- -e 's/@''REPLACE_GETTIMEOFDAY''@/$(REPLACE_GETTIMEOFDAY)/g' \
+ -e 's/@''GNULIB_GETTIMEOFDAY''@/$(GNULIB_GETTIMEOFDAY)/g' \
-e 's/@''HAVE_STRUCT_TIMEVAL''@/$(HAVE_STRUCT_TIMEVAL)/g' \
+ -e 's/@''REPLACE_GETTIMEOFDAY''@/$(REPLACE_GETTIMEOFDAY)/g' \
-e '/definition of _GL_ARG_NONNULL/r $(ARG_NONNULL_H)' \
+ -e '/definition of _GL_WARN_ON_USE/r $(WARN_ON_USE_H)' \
< $(srcdir)/sys_time.in.h; \
} > $@-t && \
mv $@-t $@