time_r.m4 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. dnl Reentrant time functions: localtime_r, gmtime_r.
  2. dnl Copyright (C) 2003, 2006-2011 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. dnl Some systems don't declare localtime_r() and gmtime_r() if _REENTRANT is
  14. dnl not defined.
  15. AC_CHECK_DECLS_ONCE([localtime_r])
  16. if test $ac_cv_have_decl_localtime_r = no; then
  17. HAVE_DECL_LOCALTIME_R=0
  18. fi
  19. AC_CHECK_FUNCS_ONCE([localtime_r])
  20. if test $ac_cv_func_localtime_r = yes; then
  21. HAVE_LOCALTIME_R=1
  22. AC_CACHE_CHECK([whether localtime_r is compatible with its POSIX signature],
  23. [gl_cv_time_r_posix],
  24. [AC_COMPILE_IFELSE(
  25. [AC_LANG_PROGRAM(
  26. [[#include <time.h>]],
  27. [[/* We don't need to append 'restrict's to the argument types,
  28. even though the POSIX signature has the 'restrict's,
  29. since C99 says they can't affect type compatibility. */
  30. struct tm * (*ptr) (time_t const *, struct tm *) = localtime_r;
  31. if (ptr) return 0;
  32. /* Check the return type is a pointer.
  33. On HP-UX 10 it is 'int'. */
  34. *localtime_r (0, 0);]])
  35. ],
  36. [gl_cv_time_r_posix=yes],
  37. [gl_cv_time_r_posix=no])
  38. ])
  39. if test $gl_cv_time_r_posix = yes; then
  40. REPLACE_LOCALTIME_R=0
  41. else
  42. REPLACE_LOCALTIME_R=1
  43. fi
  44. else
  45. HAVE_LOCALTIME_R=0
  46. fi
  47. ])
  48. # Prerequisites of lib/time_r.c.
  49. AC_DEFUN([gl_PREREQ_TIME_R], [
  50. :
  51. ])