time_r.m4 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. dnl Reentrant time functions like localtime_r.
  2. dnl Copyright (C) 2003, 2006, 2007, 2008 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_CACHE_CHECK([whether localtime_r is compatible with its POSIX signature],
  14. [gl_cv_time_r_posix],
  15. [AC_TRY_COMPILE(
  16. [#include <time.h>],
  17. [/* We don't need to append 'restrict's to the argument types,
  18. even though the POSIX signature has the 'restrict's,
  19. since C99 says they can't affect type compatibility. */
  20. struct tm * (*ptr) (time_t const *, struct tm *) = localtime_r;
  21. if (ptr) return 0;
  22. /* Check the return type is a pointer. On HP-UX 10 it is 'int'. */
  23. *localtime_r (0, 0);],
  24. [gl_cv_time_r_posix=yes],
  25. [gl_cv_time_r_posix=no])])
  26. if test $gl_cv_time_r_posix = yes; then
  27. REPLACE_LOCALTIME_R=0
  28. else
  29. REPLACE_LOCALTIME_R=1
  30. AC_LIBOBJ([time_r])
  31. gl_PREREQ_TIME_R
  32. fi
  33. ])
  34. # Prerequisites of lib/time_r.c.
  35. AC_DEFUN([gl_PREREQ_TIME_R], [
  36. :
  37. ])