Debian Codegraph @

m4/sys_stat_h.m4

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