stat-time.m4 3.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. # Checks for stat-related time functions.
  2. # Copyright (C) 1998-1999, 2001, 2003, 2005-2007, 2009-2012 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. dnl From Paul Eggert.
  8. # st_atim.tv_nsec - Linux, Solaris, Cygwin
  9. # st_atimespec.tv_nsec - FreeBSD, NetBSD, if ! defined _POSIX_SOURCE
  10. # st_atimensec - FreeBSD, NetBSD, if defined _POSIX_SOURCE
  11. # st_atim.st__tim.tv_nsec - UnixWare (at least 2.1.2 through 7.1)
  12. # st_birthtimespec - FreeBSD, NetBSD (hidden on OpenBSD 3.9, anyway)
  13. # st_birthtim - Cygwin 1.7.0+
  14. AC_DEFUN([gl_STAT_TIME],
  15. [
  16. AC_REQUIRE([AC_C_INLINE])
  17. AC_REQUIRE([gl_USE_SYSTEM_EXTENSIONS])
  18. AC_CHECK_HEADERS_ONCE([sys/time.h])
  19. AC_CHECK_MEMBERS([struct stat.st_atim.tv_nsec],
  20. [AC_CACHE_CHECK([whether struct stat.st_atim is of type struct timespec],
  21. [ac_cv_typeof_struct_stat_st_atim_is_struct_timespec],
  22. [AC_COMPILE_IFELSE([AC_LANG_PROGRAM(
  23. [[
  24. #include <sys/types.h>
  25. #include <sys/stat.h>
  26. #if HAVE_SYS_TIME_H
  27. # include <sys/time.h>
  28. #endif
  29. #include <time.h>
  30. struct timespec ts;
  31. struct stat st;
  32. ]],
  33. [[
  34. st.st_atim = ts;
  35. ]])],
  36. [ac_cv_typeof_struct_stat_st_atim_is_struct_timespec=yes],
  37. [ac_cv_typeof_struct_stat_st_atim_is_struct_timespec=no])])
  38. if test $ac_cv_typeof_struct_stat_st_atim_is_struct_timespec = yes; then
  39. AC_DEFINE([TYPEOF_STRUCT_STAT_ST_ATIM_IS_STRUCT_TIMESPEC], [1],
  40. [Define to 1 if the type of the st_atim member of a struct stat is
  41. struct timespec.])
  42. fi],
  43. [AC_CHECK_MEMBERS([struct stat.st_atimespec.tv_nsec], [],
  44. [AC_CHECK_MEMBERS([struct stat.st_atimensec], [],
  45. [AC_CHECK_MEMBERS([struct stat.st_atim.st__tim.tv_nsec], [], [],
  46. [#include <sys/types.h>
  47. #include <sys/stat.h>])],
  48. [#include <sys/types.h>
  49. #include <sys/stat.h>])],
  50. [#include <sys/types.h>
  51. #include <sys/stat.h>])],
  52. [#include <sys/types.h>
  53. #include <sys/stat.h>])
  54. ])
  55. # Check for st_birthtime, a feature from UFS2 (FreeBSD, NetBSD, OpenBSD, etc.)
  56. # and NTFS (Cygwin).
  57. # There was a time when this field was named st_createtime (21 June
  58. # 2002 to 16 July 2002) But that window is very small and applied only
  59. # to development code, so systems still using that configuration are
  60. # not supported. See revisions 1.10 and 1.11 of FreeBSD's
  61. # src/sys/ufs/ufs/dinode.h.
  62. #
  63. AC_DEFUN([gl_STAT_BIRTHTIME],
  64. [
  65. AC_REQUIRE([AC_C_INLINE])
  66. AC_REQUIRE([gl_USE_SYSTEM_EXTENSIONS])
  67. AC_CHECK_HEADERS_ONCE([sys/time.h])
  68. AC_CHECK_MEMBERS([struct stat.st_birthtimespec.tv_nsec], [],
  69. [AC_CHECK_MEMBERS([struct stat.st_birthtimensec], [],
  70. [AC_CHECK_MEMBERS([struct stat.st_birthtim.tv_nsec], [], [],
  71. [#include <sys/types.h>
  72. #include <sys/stat.h>])],
  73. [#include <sys/types.h>
  74. #include <sys/stat.h>])],
  75. [#include <sys/types.h>
  76. #include <sys/stat.h>])
  77. ])