sys_stat_h.m4 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130
  1. # sys_stat_h.m4 serial 42 -*- Autoconf -*-
  2. dnl Copyright (C) 2006-2023 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 From Eric Blake.
  7. dnl Provide a GNU-like <sys/stat.h>.
  8. AC_DEFUN_ONCE([gl_SYS_STAT_H],
  9. [
  10. AC_REQUIRE([gl_SYS_STAT_H_DEFAULTS])
  11. dnl Check for broken stat macros.
  12. AC_REQUIRE([AC_HEADER_STAT])
  13. gl_CHECK_NEXT_HEADERS([sys/stat.h])
  14. dnl Ensure the type mode_t gets defined.
  15. AC_REQUIRE([AC_TYPE_MODE_T])
  16. dnl Whether to enable precise timestamps in 'struct stat'.
  17. m4_ifdef([gl_WINDOWS_STAT_TIMESPEC], [
  18. AC_REQUIRE([gl_WINDOWS_STAT_TIMESPEC])
  19. ], [
  20. WINDOWS_STAT_TIMESPEC=0
  21. ])
  22. AC_SUBST([WINDOWS_STAT_TIMESPEC])
  23. dnl Whether to ensure that struct stat.st_size is 64-bit wide.
  24. m4_ifdef([gl_LARGEFILE], [
  25. AC_REQUIRE([gl_LARGEFILE])
  26. ], [
  27. WINDOWS_64_BIT_ST_SIZE=0
  28. ])
  29. AC_SUBST([WINDOWS_64_BIT_ST_SIZE])
  30. dnl Define types that are supposed to be defined in <sys/types.h> or
  31. dnl <sys/stat.h>.
  32. AC_CHECK_TYPE([nlink_t], [],
  33. [AC_DEFINE([nlink_t], [int],
  34. [Define to the type of st_nlink in struct stat, or a supertype.])],
  35. [#include <sys/types.h>
  36. #include <sys/stat.h>])
  37. dnl Check for declarations of anything we want to poison if the
  38. dnl corresponding gnulib module is not in use.
  39. gl_WARN_ON_USE_PREPARE([[#include <sys/stat.h>
  40. ]], [chmod fchmodat fstat fstatat futimens getumask lchmod lstat
  41. mkdirat mkfifo mkfifoat mknod mknodat stat utimensat])
  42. AC_REQUIRE([AC_C_RESTRICT])
  43. ])
  44. # gl_SYS_STAT_MODULE_INDICATOR([modulename])
  45. # sets the shell variable that indicates the presence of the given module
  46. # to a C preprocessor expression that will evaluate to 1.
  47. # This macro invocation must not occur in macros that are AC_REQUIREd.
  48. AC_DEFUN([gl_SYS_STAT_MODULE_INDICATOR],
  49. [
  50. dnl Ensure to expand the default settings once only.
  51. gl_SYS_STAT_H_REQUIRE_DEFAULTS
  52. gl_MODULE_INDICATOR_SET_VARIABLE([$1])
  53. dnl Define it also as a C macro, for the benefit of the unit tests.
  54. gl_MODULE_INDICATOR_FOR_TESTS([$1])
  55. ])
  56. # Initializes the default values for AC_SUBSTed shell variables.
  57. # This macro must not be AC_REQUIREd. It must only be invoked, and only
  58. # outside of macros or in macros that are not AC_REQUIREd.
  59. AC_DEFUN([gl_SYS_STAT_H_REQUIRE_DEFAULTS],
  60. [
  61. m4_defun(GL_MODULE_INDICATOR_PREFIX[_SYS_STAT_H_MODULE_INDICATOR_DEFAULTS], [
  62. gl_UNISTD_H_REQUIRE_DEFAULTS dnl for REPLACE_FCHDIR
  63. gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_CHMOD])
  64. gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_FCHMODAT])
  65. gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_FSTAT])
  66. gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_FSTATAT])
  67. gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_FUTIMENS])
  68. gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_GETUMASK])
  69. gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_LCHMOD])
  70. gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_LSTAT])
  71. gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_MKDIR])
  72. gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_MKDIRAT])
  73. gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_MKFIFO])
  74. gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_MKFIFOAT])
  75. gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_MKNOD])
  76. gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_MKNODAT])
  77. gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_STAT])
  78. gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_UTIMENSAT])
  79. gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_OVERRIDES_STRUCT_STAT])
  80. dnl Support Microsoft deprecated alias function names by default.
  81. gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_MDA_CHMOD], [1])
  82. gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_MDA_MKDIR], [1])
  83. gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_MDA_UMASK], [1])
  84. ])
  85. m4_require(GL_MODULE_INDICATOR_PREFIX[_SYS_STAT_H_MODULE_INDICATOR_DEFAULTS])
  86. AC_REQUIRE([gl_SYS_STAT_H_DEFAULTS])
  87. ])
  88. AC_DEFUN([gl_SYS_STAT_H_DEFAULTS],
  89. [
  90. dnl Assume proper GNU behavior unless another module says otherwise.
  91. HAVE_FCHMODAT=1; AC_SUBST([HAVE_FCHMODAT])
  92. HAVE_FSTATAT=1; AC_SUBST([HAVE_FSTATAT])
  93. HAVE_FUTIMENS=1; AC_SUBST([HAVE_FUTIMENS])
  94. HAVE_GETUMASK=1; AC_SUBST([HAVE_GETUMASK])
  95. HAVE_LCHMOD=1; AC_SUBST([HAVE_LCHMOD])
  96. HAVE_LSTAT=1; AC_SUBST([HAVE_LSTAT])
  97. HAVE_MKDIRAT=1; AC_SUBST([HAVE_MKDIRAT])
  98. HAVE_MKFIFO=1; AC_SUBST([HAVE_MKFIFO])
  99. HAVE_MKFIFOAT=1; AC_SUBST([HAVE_MKFIFOAT])
  100. HAVE_MKNOD=1; AC_SUBST([HAVE_MKNOD])
  101. HAVE_MKNODAT=1; AC_SUBST([HAVE_MKNODAT])
  102. HAVE_UTIMENSAT=1; AC_SUBST([HAVE_UTIMENSAT])
  103. REPLACE_CHMOD=0; AC_SUBST([REPLACE_CHMOD])
  104. REPLACE_FCHMODAT=0; AC_SUBST([REPLACE_FCHMODAT])
  105. REPLACE_FSTAT=0; AC_SUBST([REPLACE_FSTAT])
  106. REPLACE_FSTATAT=0; AC_SUBST([REPLACE_FSTATAT])
  107. REPLACE_FUTIMENS=0; AC_SUBST([REPLACE_FUTIMENS])
  108. REPLACE_LSTAT=0; AC_SUBST([REPLACE_LSTAT])
  109. REPLACE_MKDIR=0; AC_SUBST([REPLACE_MKDIR])
  110. REPLACE_MKFIFO=0; AC_SUBST([REPLACE_MKFIFO])
  111. REPLACE_MKFIFOAT=0; AC_SUBST([REPLACE_MKFIFOAT])
  112. REPLACE_MKNOD=0; AC_SUBST([REPLACE_MKNOD])
  113. REPLACE_MKNODAT=0; AC_SUBST([REPLACE_MKNODAT])
  114. REPLACE_STAT=0; AC_SUBST([REPLACE_STAT])
  115. REPLACE_UTIMENSAT=0; AC_SUBST([REPLACE_UTIMENSAT])
  116. ])