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