time_r.m4 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. dnl Reentrant time functions: localtime_r, gmtime_r.
  2. dnl Copyright (C) 2003, 2006-2010 Free Software Foundation, Inc.
  3. dnl This file is free software; the Free Software Foundation
  4. dnl gives unlimited permission to copy and/or distribute it,
  5. dnl with or without modifications, as long as this notice is preserved.
  6. dnl Written by Paul Eggert.
  7. AC_DEFUN([gl_TIME_R],
  8. [
  9. dnl Persuade glibc and Solaris <time.h> to declare localtime_r.
  10. AC_REQUIRE([gl_USE_SYSTEM_EXTENSIONS])
  11. AC_REQUIRE([gl_HEADER_TIME_H_DEFAULTS])
  12. AC_REQUIRE([AC_C_RESTRICT])
  13. AC_CHECK_FUNCS_ONCE([localtime_r])
  14. if test $ac_cv_func_localtime_r = yes; then
  15. AC_CACHE_CHECK([whether localtime_r is compatible with its POSIX signature],
  16. [gl_cv_time_r_posix],
  17. [AC_COMPILE_IFELSE(
  18. [AC_LANG_PROGRAM(
  19. [[#include <time.h>]],
  20. [[/* We don't need to append 'restrict's to the argument types,
  21. even though the POSIX signature has the 'restrict's,
  22. since C99 says they can't affect type compatibility. */
  23. struct tm * (*ptr) (time_t const *, struct tm *) = localtime_r;
  24. if (ptr) return 0;
  25. /* Check the return type is a pointer.
  26. On HP-UX 10 it is 'int'. */
  27. *localtime_r (0, 0);]])
  28. ],
  29. [gl_cv_time_r_posix=yes],
  30. [gl_cv_time_r_posix=no])
  31. ])
  32. if test $gl_cv_time_r_posix = yes; then
  33. REPLACE_LOCALTIME_R=0
  34. else
  35. REPLACE_LOCALTIME_R=1
  36. fi
  37. else
  38. HAVE_LOCALTIME_R=0
  39. fi
  40. if test $HAVE_LOCALTIME_R = 0 || test $REPLACE_LOCALTIME_R = 1; then
  41. AC_LIBOBJ([time_r])
  42. gl_PREREQ_TIME_R
  43. fi
  44. ])
  45. # Prerequisites of lib/time_r.c.
  46. AC_DEFUN([gl_PREREQ_TIME_R], [
  47. :
  48. ])