time_h.m4 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. # Configure a more-standard replacement for <time.h>.
  2. # Copyright (C) 2000, 2001, 2003, 2004, 2005, 2006, 2007 Free Software
  3. # Foundation, Inc.
  4. # This file is free software; the Free Software Foundation
  5. # gives unlimited permission to copy and/or distribute it,
  6. # with or without modifications, as long as this notice is preserved.
  7. # Written by Paul Eggert and Jim Meyering.
  8. AC_DEFUN([gl_HEADER_TIME_H],
  9. [
  10. dnl Use AC_REQUIRE here, so that the default behavior below is expanded
  11. dnl once only, before all statements that occur in other macros.
  12. AC_REQUIRE([gl_HEADER_TIME_H_BODY])
  13. ])
  14. AC_DEFUN([gl_HEADER_TIME_H_BODY],
  15. [
  16. AC_REQUIRE([AC_C_RESTRICT])
  17. AC_REQUIRE([gl_HEADER_TIME_H_DEFAULTS])
  18. gl_CHECK_NEXT_HEADERS([time.h])
  19. AC_REQUIRE([gl_CHECK_TYPE_STRUCT_TIMESPEC])
  20. ])
  21. AC_DEFUN([gl_HEADER_TIME_H_DEFAULTS],
  22. [
  23. dnl If another module says to replace or to not replace, do that.
  24. dnl Otherwise, replace only if someone compiles with -DGNULIB_PORTCHECK;
  25. dnl this lets maintainers check for portability.
  26. REPLACE_LOCALTIME_R=GNULIB_PORTCHECK; AC_SUBST([REPLACE_LOCALTIME_R])
  27. REPLACE_NANOSLEEP=GNULIB_PORTCHECK; AC_SUBST([REPLACE_NANOSLEEP])
  28. REPLACE_STRPTIME=GNULIB_PORTCHECK; AC_SUBST([REPLACE_STRPTIME])
  29. REPLACE_TIMEGM=GNULIB_PORTCHECK; AC_SUBST([REPLACE_TIMEGM])
  30. ])
  31. dnl Define HAVE_STRUCT_TIMESPEC if `struct timespec' is declared
  32. dnl in time.h or sys/time.h.
  33. AC_DEFUN([gl_CHECK_TYPE_STRUCT_TIMESPEC],
  34. [
  35. AC_CHECK_HEADERS_ONCE([sys/time.h])
  36. AC_CACHE_CHECK([for struct timespec in <time.h>],
  37. [gl_cv_sys_struct_timespec_in_time_h],
  38. [AC_COMPILE_IFELSE(
  39. [AC_LANG_PROGRAM(
  40. [[#include <time.h>
  41. ]],
  42. [[static struct timespec x; x.tv_sec = x.tv_nsec;]])],
  43. [gl_cv_sys_struct_timespec_in_time_h=yes],
  44. [gl_cv_sys_struct_timespec_in_time_h=no])])
  45. TIME_H_DEFINES_STRUCT_TIMESPEC=0
  46. SYS_TIME_H_DEFINES_STRUCT_TIMESPEC=0
  47. if test $gl_cv_sys_struct_timespec_in_time_h = yes; then
  48. TIME_H_DEFINES_STRUCT_TIMESPEC=1
  49. else
  50. AC_CACHE_CHECK([for struct timespec in <sys/time.h>],
  51. [gl_cv_sys_struct_timespec_in_sys_time_h],
  52. [AC_COMPILE_IFELSE(
  53. [AC_LANG_PROGRAM(
  54. [[#include <sys/time.h>
  55. ]],
  56. [[static struct timespec x; x.tv_sec = x.tv_nsec;]])],
  57. [gl_cv_sys_struct_timespec_in_sys_time_h=yes],
  58. [gl_cv_sys_struct_timespec_in_sys_time_h=no])])
  59. if test $gl_cv_sys_struct_timespec_in_sys_time_h = yes; then
  60. SYS_TIME_H_DEFINES_STRUCT_TIMESPEC=1
  61. fi
  62. fi
  63. AC_SUBST([TIME_H_DEFINES_STRUCT_TIMESPEC])
  64. AC_SUBST([SYS_TIME_H_DEFINES_STRUCT_TIMESPEC])
  65. ])