stat-time.m4 3.0 KB

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