diff options
Diffstat (limited to 'gl/m4/gnulib-common.m4')
-rw-r--r-- | gl/m4/gnulib-common.m4 | 815 |
1 files changed, 694 insertions, 121 deletions
diff --git a/gl/m4/gnulib-common.m4 b/gl/m4/gnulib-common.m4 index 0ae5a9ec..12b19dbc 100644 --- a/gl/m4/gnulib-common.m4 +++ b/gl/m4/gnulib-common.m4 | |||
@@ -1,25 +1,54 @@ | |||
1 | # gnulib-common.m4 serial 33 | 1 | # gnulib-common.m4 serial 67 |
2 | dnl Copyright (C) 2007-2013 Free Software Foundation, Inc. | 2 | dnl Copyright (C) 2007-2021 Free Software Foundation, Inc. |
3 | dnl This file is free software; the Free Software Foundation | 3 | dnl This file is free software; the Free Software Foundation |
4 | dnl gives unlimited permission to copy and/or distribute it, | 4 | dnl gives unlimited permission to copy and/or distribute it, |
5 | dnl with or without modifications, as long as this notice is preserved. | 5 | dnl with or without modifications, as long as this notice is preserved. |
6 | 6 | ||
7 | AC_PREREQ([2.62]) | ||
8 | |||
7 | # gl_COMMON | 9 | # gl_COMMON |
8 | # is expanded unconditionally through gnulib-tool magic. | 10 | # is expanded unconditionally through gnulib-tool magic. |
9 | AC_DEFUN([gl_COMMON], [ | 11 | AC_DEFUN([gl_COMMON], [ |
10 | dnl Use AC_REQUIRE here, so that the code is expanded once only. | 12 | dnl Use AC_REQUIRE here, so that the code is expanded once only. |
11 | AC_REQUIRE([gl_00GNULIB]) | 13 | AC_REQUIRE([gl_00GNULIB]) |
12 | AC_REQUIRE([gl_COMMON_BODY]) | 14 | AC_REQUIRE([gl_COMMON_BODY]) |
15 | AC_REQUIRE([gl_ZZGNULIB]) | ||
13 | ]) | 16 | ]) |
14 | AC_DEFUN([gl_COMMON_BODY], [ | 17 | AC_DEFUN([gl_COMMON_BODY], [ |
18 | AH_VERBATIM([_GL_GNUC_PREREQ], | ||
19 | [/* True if the compiler says it groks GNU C version MAJOR.MINOR. */ | ||
20 | #if defined __GNUC__ && defined __GNUC_MINOR__ | ||
21 | # define _GL_GNUC_PREREQ(major, minor) \ | ||
22 | ((major) < __GNUC__ + ((minor) <= __GNUC_MINOR__)) | ||
23 | #else | ||
24 | # define _GL_GNUC_PREREQ(major, minor) 0 | ||
25 | #endif | ||
26 | ]) | ||
15 | AH_VERBATIM([_Noreturn], | 27 | AH_VERBATIM([_Noreturn], |
16 | [/* The _Noreturn keyword of C11. */ | 28 | [/* The _Noreturn keyword of C11. */ |
17 | #if ! (defined _Noreturn \ | 29 | #ifndef _Noreturn |
18 | || (defined __STDC_VERSION__ && 201112 <= __STDC_VERSION__)) | 30 | # if (defined __cplusplus \ |
19 | # if (3 <= __GNUC__ || (__GNUC__ == 2 && 8 <= __GNUC_MINOR__) \ | 31 | && ((201103 <= __cplusplus && !(__GNUC__ == 4 && __GNUC_MINOR__ == 7)) \ |
20 | || 0x5110 <= __SUNPRO_C) | 32 | || (defined _MSC_VER && 1900 <= _MSC_VER)) \ |
33 | && 0) | ||
34 | /* [[noreturn]] is not practically usable, because with it the syntax | ||
35 | extern _Noreturn void func (...); | ||
36 | would not be valid; such a declaration would only be valid with 'extern' | ||
37 | and '_Noreturn' swapped, or without the 'extern' keyword. However, some | ||
38 | AIX system header files and several gnulib header files use precisely | ||
39 | this syntax with 'extern'. */ | ||
40 | # define _Noreturn [[noreturn]] | ||
41 | # elif ((!defined __cplusplus || defined __clang__) \ | ||
42 | && (201112 <= (defined __STDC_VERSION__ ? __STDC_VERSION__ : 0) \ | ||
43 | || (!defined __STRICT_ANSI__ \ | ||
44 | && (_GL_GNUC_PREREQ (4, 7) \ | ||
45 | || (defined __apple_build_version__ \ | ||
46 | ? 6000000 <= __apple_build_version__ \ | ||
47 | : 3 < __clang_major__ + (5 <= __clang_minor__)))))) | ||
48 | /* _Noreturn works as-is. */ | ||
49 | # elif _GL_GNUC_PREREQ (2, 8) || defined __clang__ || 0x5110 <= __SUNPRO_C | ||
21 | # define _Noreturn __attribute__ ((__noreturn__)) | 50 | # define _Noreturn __attribute__ ((__noreturn__)) |
22 | # elif defined _MSC_VER && 1200 <= _MSC_VER | 51 | # elif 1200 <= (defined _MSC_VER ? _MSC_VER : 0) |
23 | # define _Noreturn __declspec (noreturn) | 52 | # define _Noreturn __declspec (noreturn) |
24 | # else | 53 | # else |
25 | # define _Noreturn | 54 | # define _Noreturn |
@@ -36,33 +65,437 @@ AC_DEFUN([gl_COMMON_BODY], [ | |||
36 | #if defined __APPLE__ && defined __MACH__ && __APPLE_CC__ >= 5465 && !defined __cplusplus && __STDC_VERSION__ >= 199901L && !defined __GNUC_STDC_INLINE__ | 65 | #if defined __APPLE__ && defined __MACH__ && __APPLE_CC__ >= 5465 && !defined __cplusplus && __STDC_VERSION__ >= 199901L && !defined __GNUC_STDC_INLINE__ |
37 | # define __GNUC_STDC_INLINE__ 1 | 66 | # define __GNUC_STDC_INLINE__ 1 |
38 | #endif]) | 67 | #endif]) |
39 | AH_VERBATIM([unused_parameter], | 68 | AH_VERBATIM([attribute], |
40 | [/* Define as a marker that can be attached to declarations that might not | 69 | [/* Attributes. */ |
41 | be used. This helps to reduce warnings, such as from | 70 | #if (defined __has_attribute \ |
42 | GCC -Wunused-parameter. */ | 71 | && (!defined __clang_minor__ \ |
43 | #if __GNUC__ >= 3 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 7) | 72 | || 3 < __clang_major__ + (5 <= __clang_minor__))) |
44 | # define _GL_UNUSED __attribute__ ((__unused__)) | 73 | # define _GL_HAS_ATTRIBUTE(attr) __has_attribute (__##attr##__) |
45 | #else | 74 | #else |
46 | # define _GL_UNUSED | 75 | # define _GL_HAS_ATTRIBUTE(attr) _GL_ATTR_##attr |
76 | # define _GL_ATTR_alloc_size _GL_GNUC_PREREQ (4, 3) | ||
77 | # define _GL_ATTR_always_inline _GL_GNUC_PREREQ (3, 2) | ||
78 | # define _GL_ATTR_artificial _GL_GNUC_PREREQ (4, 3) | ||
79 | # define _GL_ATTR_cold _GL_GNUC_PREREQ (4, 3) | ||
80 | # define _GL_ATTR_const _GL_GNUC_PREREQ (2, 95) | ||
81 | # define _GL_ATTR_deprecated _GL_GNUC_PREREQ (3, 1) | ||
82 | # define _GL_ATTR_diagnose_if 0 | ||
83 | # define _GL_ATTR_error _GL_GNUC_PREREQ (4, 3) | ||
84 | # define _GL_ATTR_externally_visible _GL_GNUC_PREREQ (4, 1) | ||
85 | # define _GL_ATTR_fallthrough _GL_GNUC_PREREQ (7, 0) | ||
86 | # define _GL_ATTR_format _GL_GNUC_PREREQ (2, 7) | ||
87 | # define _GL_ATTR_leaf _GL_GNUC_PREREQ (4, 6) | ||
88 | # define _GL_ATTR_malloc _GL_GNUC_PREREQ (3, 0) | ||
89 | # ifdef _ICC | ||
90 | # define _GL_ATTR_may_alias 0 | ||
91 | # else | ||
92 | # define _GL_ATTR_may_alias _GL_GNUC_PREREQ (3, 3) | ||
93 | # endif | ||
94 | # define _GL_ATTR_noinline _GL_GNUC_PREREQ (3, 1) | ||
95 | # define _GL_ATTR_nonnull _GL_GNUC_PREREQ (3, 3) | ||
96 | # define _GL_ATTR_nonstring _GL_GNUC_PREREQ (8, 0) | ||
97 | # define _GL_ATTR_nothrow _GL_GNUC_PREREQ (3, 3) | ||
98 | # define _GL_ATTR_packed _GL_GNUC_PREREQ (2, 7) | ||
99 | # define _GL_ATTR_pure _GL_GNUC_PREREQ (2, 96) | ||
100 | # define _GL_ATTR_returns_nonnull _GL_GNUC_PREREQ (4, 9) | ||
101 | # define _GL_ATTR_sentinel _GL_GNUC_PREREQ (4, 0) | ||
102 | # define _GL_ATTR_unused _GL_GNUC_PREREQ (2, 7) | ||
103 | # define _GL_ATTR_warn_unused_result _GL_GNUC_PREREQ (3, 4) | ||
47 | #endif | 104 | #endif |
48 | /* The name _UNUSED_PARAMETER_ is an earlier spelling, although the name | ||
49 | is a misnomer outside of parameter lists. */ | ||
50 | #define _UNUSED_PARAMETER_ _GL_UNUSED | ||
51 | 105 | ||
52 | /* The __pure__ attribute was added in gcc 2.96. */ | 106 | #ifdef __has_c_attribute |
53 | #if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 96) | 107 | # define _GL_HAS_C_ATTRIBUTE(attr) __has_c_attribute (__##attr##__) |
54 | # define _GL_ATTRIBUTE_PURE __attribute__ ((__pure__)) | 108 | #else |
109 | # define _GL_HAS_C_ATTRIBUTE(attr) 0 | ||
110 | #endif | ||
111 | |||
112 | ]dnl There is no _GL_ATTRIBUTE_ALIGNED; use stdalign's _Alignas instead. | ||
113 | [ | ||
114 | /* _GL_ATTRIBUTE_ALLOC_SIZE ((N)) declares that the Nth argument of the function | ||
115 | is the size of the returned memory block. | ||
116 | _GL_ATTRIBUTE_ALLOC_SIZE ((M, N)) declares that the Mth argument multiplied | ||
117 | by the Nth argument of the function is the size of the returned memory block. | ||
118 | */ | ||
119 | /* Applies to: function, pointer to function, function types. */ | ||
120 | #if _GL_HAS_ATTRIBUTE (alloc_size) | ||
121 | # define _GL_ATTRIBUTE_ALLOC_SIZE(args) __attribute__ ((__alloc_size__ args)) | ||
122 | #else | ||
123 | # define _GL_ATTRIBUTE_ALLOC_SIZE(args) | ||
124 | #endif | ||
125 | |||
126 | /* _GL_ATTRIBUTE_ALWAYS_INLINE tells that the compiler should always inline the | ||
127 | function and report an error if it cannot do so. */ | ||
128 | /* Applies to: function. */ | ||
129 | #if _GL_HAS_ATTRIBUTE (always_inline) | ||
130 | # define _GL_ATTRIBUTE_ALWAYS_INLINE __attribute__ ((__always_inline__)) | ||
131 | #else | ||
132 | # define _GL_ATTRIBUTE_ALWAYS_INLINE | ||
133 | #endif | ||
134 | |||
135 | /* _GL_ATTRIBUTE_ARTIFICIAL declares that the function is not important to show | ||
136 | in stack traces when debugging. The compiler should omit the function from | ||
137 | stack traces. */ | ||
138 | /* Applies to: function. */ | ||
139 | #if _GL_HAS_ATTRIBUTE (artificial) | ||
140 | # define _GL_ATTRIBUTE_ARTIFICIAL __attribute__ ((__artificial__)) | ||
141 | #else | ||
142 | # define _GL_ATTRIBUTE_ARTIFICIAL | ||
143 | #endif | ||
144 | |||
145 | /* _GL_ATTRIBUTE_COLD declares that the function is rarely executed. */ | ||
146 | /* Applies to: functions. */ | ||
147 | /* Avoid __attribute__ ((cold)) on MinGW; see thread starting at | ||
148 | <https://lists.gnu.org/r/emacs-devel/2019-04/msg01152.html>. | ||
149 | Also, Oracle Studio 12.6 requires 'cold' not '__cold__'. */ | ||
150 | #if _GL_HAS_ATTRIBUTE (cold) && !defined __MINGW32__ | ||
151 | # ifndef __SUNPRO_C | ||
152 | # define _GL_ATTRIBUTE_COLD __attribute__ ((__cold__)) | ||
153 | # else | ||
154 | # define _GL_ATTRIBUTE_COLD __attribute__ ((cold)) | ||
155 | # endif | ||
55 | #else | 156 | #else |
56 | # define _GL_ATTRIBUTE_PURE /* empty */ | 157 | # define _GL_ATTRIBUTE_COLD |
57 | #endif | 158 | #endif |
58 | 159 | ||
59 | /* The __const__ attribute was added in gcc 2.95. */ | 160 | /* _GL_ATTRIBUTE_CONST declares that it is OK for a compiler to omit duplicate |
60 | #if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 95) | 161 | calls to the function with the same arguments. |
162 | This attribute is safe for a function that neither depends on nor affects | ||
163 | observable state, and always returns exactly once - e.g., does not loop | ||
164 | forever, and does not call longjmp. | ||
165 | (This attribute is stricter than _GL_ATTRIBUTE_PURE.) */ | ||
166 | /* Applies to: functions. */ | ||
167 | #if _GL_HAS_ATTRIBUTE (const) | ||
61 | # define _GL_ATTRIBUTE_CONST __attribute__ ((__const__)) | 168 | # define _GL_ATTRIBUTE_CONST __attribute__ ((__const__)) |
62 | #else | 169 | #else |
63 | # define _GL_ATTRIBUTE_CONST /* empty */ | 170 | # define _GL_ATTRIBUTE_CONST |
171 | #endif | ||
172 | |||
173 | /* _GL_ATTRIBUTE_DEALLOC (F, I) declares that the function returns pointers | ||
174 | that can be freed by passing them as the Ith argument to the | ||
175 | function F. | ||
176 | _GL_ATTRIBUTE_DEALLOC_FREE declares that the function returns pointers that | ||
177 | can be freed via 'free'; it can be used only after declaring 'free'. */ | ||
178 | /* Applies to: functions. Cannot be used on inline functions. */ | ||
179 | #if _GL_GNUC_PREREQ (11, 0) | ||
180 | # define _GL_ATTRIBUTE_DEALLOC(f, i) __attribute__ ((__malloc__ (f, i))) | ||
181 | #else | ||
182 | # define _GL_ATTRIBUTE_DEALLOC(f, i) | ||
183 | #endif | ||
184 | #define _GL_ATTRIBUTE_DEALLOC_FREE _GL_ATTRIBUTE_DEALLOC (free, 1) | ||
185 | |||
186 | /* _GL_ATTRIBUTE_DEPRECATED: Declares that an entity is deprecated. | ||
187 | The compiler may warn if the entity is used. */ | ||
188 | /* Applies to: | ||
189 | - function, variable, | ||
190 | - struct, union, struct/union member, | ||
191 | - enumeration, enumeration item, | ||
192 | - typedef, | ||
193 | in C++ also: namespace, class, template specialization. */ | ||
194 | #if _GL_HAS_C_ATTRIBUTE (deprecated) | ||
195 | # define _GL_ATTRIBUTE_DEPRECATED [[__deprecated__]] | ||
196 | #elif _GL_HAS_ATTRIBUTE (deprecated) | ||
197 | # define _GL_ATTRIBUTE_DEPRECATED __attribute__ ((__deprecated__)) | ||
198 | #else | ||
199 | # define _GL_ATTRIBUTE_DEPRECATED | ||
200 | #endif | ||
201 | |||
202 | /* _GL_ATTRIBUTE_ERROR(msg) requests an error if a function is called and | ||
203 | the function call is not optimized away. | ||
204 | _GL_ATTRIBUTE_WARNING(msg) requests a warning if a function is called and | ||
205 | the function call is not optimized away. */ | ||
206 | /* Applies to: functions. */ | ||
207 | #if _GL_HAS_ATTRIBUTE (error) | ||
208 | # define _GL_ATTRIBUTE_ERROR(msg) __attribute__ ((__error__ (msg))) | ||
209 | # define _GL_ATTRIBUTE_WARNING(msg) __attribute__ ((__warning__ (msg))) | ||
210 | #elif _GL_HAS_ATTRIBUTE (diagnose_if) | ||
211 | # define _GL_ATTRIBUTE_ERROR(msg) __attribute__ ((__diagnose_if__ (1, msg, "error"))) | ||
212 | # define _GL_ATTRIBUTE_WARNING(msg) __attribute__ ((__diagnose_if__ (1, msg, "warning"))) | ||
213 | #else | ||
214 | # define _GL_ATTRIBUTE_ERROR(msg) | ||
215 | # define _GL_ATTRIBUTE_WARNING(msg) | ||
216 | #endif | ||
217 | |||
218 | /* _GL_ATTRIBUTE_EXTERNALLY_VISIBLE declares that the entity should remain | ||
219 | visible to debuggers etc., even with '-fwhole-program'. */ | ||
220 | /* Applies to: functions, variables. */ | ||
221 | #if _GL_HAS_ATTRIBUTE (externally_visible) | ||
222 | # define _GL_ATTRIBUTE_EXTERNALLY_VISIBLE __attribute__ ((externally_visible)) | ||
223 | #else | ||
224 | # define _GL_ATTRIBUTE_EXTERNALLY_VISIBLE | ||
225 | #endif | ||
226 | |||
227 | /* _GL_ATTRIBUTE_FALLTHROUGH declares that it is not a programming mistake if | ||
228 | the control flow falls through to the immediately following 'case' or | ||
229 | 'default' label. The compiler should not warn in this case. */ | ||
230 | /* Applies to: Empty statement (;), inside a 'switch' statement. */ | ||
231 | /* Always expands to something. */ | ||
232 | #if _GL_HAS_C_ATTRIBUTE (fallthrough) | ||
233 | # define _GL_ATTRIBUTE_FALLTHROUGH [[__fallthrough__]] | ||
234 | #elif _GL_HAS_ATTRIBUTE (fallthrough) | ||
235 | # define _GL_ATTRIBUTE_FALLTHROUGH __attribute__ ((__fallthrough__)) | ||
236 | #else | ||
237 | # define _GL_ATTRIBUTE_FALLTHROUGH ((void) 0) | ||
238 | #endif | ||
239 | |||
240 | /* _GL_ATTRIBUTE_FORMAT ((ARCHETYPE, STRING-INDEX, FIRST-TO-CHECK)) | ||
241 | declares that the STRING-INDEXth function argument is a format string of | ||
242 | style ARCHETYPE, which is one of: | ||
243 | printf, gnu_printf | ||
244 | scanf, gnu_scanf, | ||
245 | strftime, gnu_strftime, | ||
246 | strfmon, | ||
247 | or the same thing prefixed and suffixed with '__'. | ||
248 | If FIRST-TO-CHECK is not 0, arguments starting at FIRST-TO_CHECK | ||
249 | are suitable for the format string. */ | ||
250 | /* Applies to: functions. */ | ||
251 | #if _GL_HAS_ATTRIBUTE (format) | ||
252 | # define _GL_ATTRIBUTE_FORMAT(spec) __attribute__ ((__format__ spec)) | ||
253 | #else | ||
254 | # define _GL_ATTRIBUTE_FORMAT(spec) | ||
255 | #endif | ||
256 | |||
257 | /* _GL_ATTRIBUTE_LEAF declares that if the function is called from some other | ||
258 | compilation unit, it executes code from that unit only by return or by | ||
259 | exception handling. This declaration lets the compiler optimize that unit | ||
260 | more aggressively. */ | ||
261 | /* Applies to: functions. */ | ||
262 | #if _GL_HAS_ATTRIBUTE (leaf) | ||
263 | # define _GL_ATTRIBUTE_LEAF __attribute__ ((__leaf__)) | ||
264 | #else | ||
265 | # define _GL_ATTRIBUTE_LEAF | ||
266 | #endif | ||
267 | |||
268 | /* _GL_ATTRIBUTE_MALLOC declares that the function returns a pointer to freshly | ||
269 | allocated memory. */ | ||
270 | /* Applies to: functions. */ | ||
271 | #if _GL_HAS_ATTRIBUTE (malloc) | ||
272 | # define _GL_ATTRIBUTE_MALLOC __attribute__ ((__malloc__)) | ||
273 | #else | ||
274 | # define _GL_ATTRIBUTE_MALLOC | ||
275 | #endif | ||
276 | |||
277 | /* _GL_ATTRIBUTE_MAY_ALIAS declares that pointers to the type may point to the | ||
278 | same storage as pointers to other types. Thus this declaration disables | ||
279 | strict aliasing optimization. */ | ||
280 | /* Applies to: types. */ | ||
281 | /* Oracle Studio 12.6 mishandles may_alias despite __has_attribute OK. */ | ||
282 | #if _GL_HAS_ATTRIBUTE (may_alias) && !defined __SUNPRO_C | ||
283 | # define _GL_ATTRIBUTE_MAY_ALIAS __attribute__ ((__may_alias__)) | ||
284 | #else | ||
285 | # define _GL_ATTRIBUTE_MAY_ALIAS | ||
286 | #endif | ||
287 | |||
288 | /* _GL_ATTRIBUTE_MAYBE_UNUSED declares that it is not a programming mistake if | ||
289 | the entity is not used. The compiler should not warn if the entity is not | ||
290 | used. */ | ||
291 | /* Applies to: | ||
292 | - function, variable, | ||
293 | - struct, union, struct/union member, | ||
294 | - enumeration, enumeration item, | ||
295 | - typedef, | ||
296 | in C++ also: class. */ | ||
297 | /* In C++ and C2x, this is spelled [[__maybe_unused__]]. | ||
298 | GCC's syntax is __attribute__ ((__unused__)). | ||
299 | clang supports both syntaxes. */ | ||
300 | #if _GL_HAS_C_ATTRIBUTE (maybe_unused) | ||
301 | # define _GL_ATTRIBUTE_MAYBE_UNUSED [[__maybe_unused__]] | ||
302 | #else | ||
303 | # define _GL_ATTRIBUTE_MAYBE_UNUSED _GL_ATTRIBUTE_UNUSED | ||
304 | #endif | ||
305 | /* Alternative spelling of this macro, for convenience. */ | ||
306 | #define _GL_UNUSED _GL_ATTRIBUTE_MAYBE_UNUSED | ||
307 | /* Earlier spellings of this macro. */ | ||
308 | #define _UNUSED_PARAMETER_ _GL_ATTRIBUTE_MAYBE_UNUSED | ||
309 | |||
310 | /* _GL_ATTRIBUTE_NODISCARD declares that the caller of the function should not | ||
311 | discard the return value. The compiler may warn if the caller does not use | ||
312 | the return value, unless the caller uses something like ignore_value. */ | ||
313 | /* Applies to: function, enumeration, class. */ | ||
314 | #if _GL_HAS_C_ATTRIBUTE (nodiscard) | ||
315 | # define _GL_ATTRIBUTE_NODISCARD [[__nodiscard__]] | ||
316 | #elif _GL_HAS_ATTRIBUTE (warn_unused_result) | ||
317 | # define _GL_ATTRIBUTE_NODISCARD __attribute__ ((__warn_unused_result__)) | ||
318 | #else | ||
319 | # define _GL_ATTRIBUTE_NODISCARD | ||
320 | #endif | ||
321 | |||
322 | /* _GL_ATTRIBUTE_NOINLINE tells that the compiler should not inline the | ||
323 | function. */ | ||
324 | /* Applies to: functions. */ | ||
325 | #if _GL_HAS_ATTRIBUTE (noinline) | ||
326 | # define _GL_ATTRIBUTE_NOINLINE __attribute__ ((__noinline__)) | ||
327 | #else | ||
328 | # define _GL_ATTRIBUTE_NOINLINE | ||
329 | #endif | ||
330 | |||
331 | /* _GL_ATTRIBUTE_NONNULL ((N1, N2,...)) declares that the arguments N1, N2,... | ||
332 | must not be NULL. | ||
333 | _GL_ATTRIBUTE_NONNULL () declares that all pointer arguments must not be | ||
334 | null. */ | ||
335 | /* Applies to: functions. */ | ||
336 | #if _GL_HAS_ATTRIBUTE (nonnull) | ||
337 | # define _GL_ATTRIBUTE_NONNULL(args) __attribute__ ((__nonnull__ args)) | ||
338 | #else | ||
339 | # define _GL_ATTRIBUTE_NONNULL(args) | ||
340 | #endif | ||
341 | |||
342 | /* _GL_ATTRIBUTE_NONSTRING declares that the contents of a character array is | ||
343 | not meant to be NUL-terminated. */ | ||
344 | /* Applies to: struct/union members and variables that are arrays of element | ||
345 | type '[[un]signed] char'. */ | ||
346 | #if _GL_HAS_ATTRIBUTE (nonstring) | ||
347 | # define _GL_ATTRIBUTE_NONSTRING __attribute__ ((__nonstring__)) | ||
348 | #else | ||
349 | # define _GL_ATTRIBUTE_NONSTRING | ||
350 | #endif | ||
351 | |||
352 | /* There is no _GL_ATTRIBUTE_NORETURN; use _Noreturn instead. */ | ||
353 | |||
354 | /* _GL_ATTRIBUTE_NOTHROW declares that the function does not throw exceptions. | ||
355 | */ | ||
356 | /* Applies to: functions. */ | ||
357 | #if _GL_HAS_ATTRIBUTE (nothrow) && !defined __cplusplus | ||
358 | # define _GL_ATTRIBUTE_NOTHROW __attribute__ ((__nothrow__)) | ||
359 | #else | ||
360 | # define _GL_ATTRIBUTE_NOTHROW | ||
361 | #endif | ||
362 | |||
363 | /* _GL_ATTRIBUTE_PACKED declares: | ||
364 | For struct members: The member has the smallest possible alignment. | ||
365 | For struct, union, class: All members have the smallest possible alignment, | ||
366 | minimizing the memory required. */ | ||
367 | /* Applies to: struct members, struct, union, | ||
368 | in C++ also: class. */ | ||
369 | #if _GL_HAS_ATTRIBUTE (packed) | ||
370 | # define _GL_ATTRIBUTE_PACKED __attribute__ ((__packed__)) | ||
371 | #else | ||
372 | # define _GL_ATTRIBUTE_PACKED | ||
373 | #endif | ||
374 | |||
375 | /* _GL_ATTRIBUTE_PURE declares that It is OK for a compiler to omit duplicate | ||
376 | calls to the function with the same arguments if observable state is not | ||
377 | changed between calls. | ||
378 | This attribute is safe for a function that does not affect | ||
379 | observable state, and always returns exactly once. | ||
380 | (This attribute is looser than _GL_ATTRIBUTE_CONST.) */ | ||
381 | /* Applies to: functions. */ | ||
382 | #if _GL_HAS_ATTRIBUTE (pure) | ||
383 | # define _GL_ATTRIBUTE_PURE __attribute__ ((__pure__)) | ||
384 | #else | ||
385 | # define _GL_ATTRIBUTE_PURE | ||
386 | #endif | ||
387 | |||
388 | /* _GL_ATTRIBUTE_RETURNS_NONNULL declares that the function's return value is | ||
389 | a non-NULL pointer. */ | ||
390 | /* Applies to: functions. */ | ||
391 | #if _GL_HAS_ATTRIBUTE (returns_nonnull) | ||
392 | # define _GL_ATTRIBUTE_RETURNS_NONNULL __attribute__ ((__returns_nonnull__)) | ||
393 | #else | ||
394 | # define _GL_ATTRIBUTE_RETURNS_NONNULL | ||
395 | #endif | ||
396 | |||
397 | /* _GL_ATTRIBUTE_SENTINEL(pos) declares that the variadic function expects a | ||
398 | trailing NULL argument. | ||
399 | _GL_ATTRIBUTE_SENTINEL () - The last argument is NULL (requires C99). | ||
400 | _GL_ATTRIBUTE_SENTINEL ((N)) - The (N+1)st argument from the end is NULL. */ | ||
401 | /* Applies to: functions. */ | ||
402 | #if _GL_HAS_ATTRIBUTE (sentinel) | ||
403 | # define _GL_ATTRIBUTE_SENTINEL(pos) __attribute__ ((__sentinel__ pos)) | ||
404 | #else | ||
405 | # define _GL_ATTRIBUTE_SENTINEL(pos) | ||
406 | #endif | ||
407 | |||
408 | /* A helper macro. Don't use it directly. */ | ||
409 | #if _GL_HAS_ATTRIBUTE (unused) | ||
410 | # define _GL_ATTRIBUTE_UNUSED __attribute__ ((__unused__)) | ||
411 | #else | ||
412 | # define _GL_ATTRIBUTE_UNUSED | ||
413 | #endif | ||
414 | |||
415 | ]dnl There is no _GL_ATTRIBUTE_VISIBILITY; see m4/visibility.m4 instead. | ||
416 | [ | ||
417 | /* _GL_UNUSED_LABEL; declares that it is not a programming mistake if the | ||
418 | immediately preceding label is not used. The compiler should not warn | ||
419 | if the label is not used. */ | ||
420 | /* Applies to: label (both in C and C++). */ | ||
421 | /* Note that g++ < 4.5 does not support the '__attribute__ ((__unused__)) ;' | ||
422 | syntax. But clang does. */ | ||
423 | #if !(defined __cplusplus && !_GL_GNUC_PREREQ (4, 5)) || defined __clang__ | ||
424 | # define _GL_UNUSED_LABEL _GL_ATTRIBUTE_UNUSED | ||
425 | #else | ||
426 | # define _GL_UNUSED_LABEL | ||
64 | #endif | 427 | #endif |
65 | ]) | 428 | ]) |
429 | AH_VERBATIM([async_safe], | ||
430 | [/* The _GL_ASYNC_SAFE marker should be attached to functions that are | ||
431 | signal handlers (for signals other than SIGABRT, SIGPIPE) or can be | ||
432 | invoked from such signal handlers. Such functions have some restrictions: | ||
433 | * All functions that it calls should be marked _GL_ASYNC_SAFE as well, | ||
434 | or should be listed as async-signal-safe in POSIX | ||
435 | <https://pubs.opengroup.org/onlinepubs/9699919799/functions/V2_chap02.html#tag_15_04> | ||
436 | section 2.4.3. Note that malloc(), sprintf(), and fwrite(), in | ||
437 | particular, are NOT async-signal-safe. | ||
438 | * All memory locations (variables and struct fields) that these functions | ||
439 | access must be marked 'volatile'. This holds for both read and write | ||
440 | accesses. Otherwise the compiler might optimize away stores to and | ||
441 | reads from such locations that occur in the program, depending on its | ||
442 | data flow analysis. For example, when the program contains a loop | ||
443 | that is intended to inspect a variable set from within a signal handler | ||
444 | while (!signal_occurred) | ||
445 | ; | ||
446 | the compiler is allowed to transform this into an endless loop if the | ||
447 | variable 'signal_occurred' is not declared 'volatile'. | ||
448 | Additionally, recall that: | ||
449 | * A signal handler should not modify errno (except if it is a handler | ||
450 | for a fatal signal and ends by raising the same signal again, thus | ||
451 | provoking the termination of the process). If it invokes a function | ||
452 | that may clobber errno, it needs to save and restore the value of | ||
453 | errno. */ | ||
454 | #define _GL_ASYNC_SAFE | ||
455 | ]) | ||
456 | AH_VERBATIM([micro_optimizations], | ||
457 | [/* _GL_CMP (n1, n2) performs a three-valued comparison on n1 vs. n2, where | ||
458 | n1 and n2 are expressions without side effects, that evaluate to real | ||
459 | numbers (excluding NaN). | ||
460 | It returns | ||
461 | 1 if n1 > n2 | ||
462 | 0 if n1 == n2 | ||
463 | -1 if n1 < n2 | ||
464 | The naïve code (n1 > n2 ? 1 : n1 < n2 ? -1 : 0) produces a conditional | ||
465 | jump with nearly all GCC versions up to GCC 10. | ||
466 | This variant (n1 < n2 ? -1 : n1 > n2) produces a conditional with many | ||
467 | GCC versions up to GCC 9. | ||
468 | The better code (n1 > n2) - (n1 < n2) from Hacker's Delight § 2-9 | ||
469 | avoids conditional jumps in all GCC versions >= 3.4. */ | ||
470 | #define _GL_CMP(n1, n2) (((n1) > (n2)) - ((n1) < (n2))) | ||
471 | ]) | ||
472 | dnl Hint which direction to take regarding cross-compilation guesses: | ||
473 | dnl When a user installs a program on a platform they are not intimately | ||
474 | dnl familiar with, --enable-cross-guesses=conservative is the appropriate | ||
475 | dnl choice. It implements the "If we don't know, assume the worst" principle. | ||
476 | dnl However, when an operating system developer (on a platform which is not | ||
477 | dnl yet known to gnulib) builds packages for their platform, they want to | ||
478 | dnl expose, not hide, possible platform bugs; in this case, | ||
479 | dnl --enable-cross-guesses=risky is the appropriate choice. | ||
480 | dnl Sets the variables | ||
481 | dnl gl_cross_guess_normal (to be used when 'yes' is good and 'no' is bad), | ||
482 | dnl gl_cross_guess_inverted (to be used when 'no' is good and 'yes' is bad). | ||
483 | AC_ARG_ENABLE([cross-guesses], | ||
484 | [AS_HELP_STRING([--enable-cross-guesses={conservative|risky}], | ||
485 | [specify policy for cross-compilation guesses])], | ||
486 | [if test "x$enableval" != xconservative && test "x$enableval" != xrisky; then | ||
487 | AC_MSG_WARN([invalid argument supplied to --enable-cross-guesses]) | ||
488 | enableval=conservative | ||
489 | fi | ||
490 | gl_cross_guesses="$enableval"], | ||
491 | [gl_cross_guesses=conservative]) | ||
492 | if test $gl_cross_guesses = risky; then | ||
493 | gl_cross_guess_normal="guessing yes" | ||
494 | gl_cross_guess_inverted="guessing no" | ||
495 | else | ||
496 | gl_cross_guess_normal="guessing no" | ||
497 | gl_cross_guess_inverted="guessing yes" | ||
498 | fi | ||
66 | dnl Preparation for running test programs: | 499 | dnl Preparation for running test programs: |
67 | dnl Tell glibc to write diagnostics from -D_FORTIFY_SOURCE=2 to stderr, not | 500 | dnl Tell glibc to write diagnostics from -D_FORTIFY_SOURCE=2 to stderr, not |
68 | dnl to /dev/tty, so they can be redirected to log files. Such diagnostics | 501 | dnl to /dev/tty, so they can be redirected to log files. Such diagnostics |
@@ -71,6 +504,16 @@ AC_DEFUN([gl_COMMON_BODY], [ | |||
71 | export LIBC_FATAL_STDERR_ | 504 | export LIBC_FATAL_STDERR_ |
72 | ]) | 505 | ]) |
73 | 506 | ||
507 | # gl_MODULE_INDICATOR_INIT_VARIABLE([variablename]) | ||
508 | # gl_MODULE_INDICATOR_INIT_VARIABLE([variablename], [initialvalue]) | ||
509 | # initializes the shell variable that indicates the presence of the given module | ||
510 | # as a C preprocessor expression. | ||
511 | AC_DEFUN([gl_MODULE_INDICATOR_INIT_VARIABLE], | ||
512 | [ | ||
513 | GL_MODULE_INDICATOR_PREFIX[]_[$1]=m4_if([$2], , [0], [$2]) | ||
514 | AC_SUBST(GL_MODULE_INDICATOR_PREFIX[]_[$1]) | ||
515 | ]) | ||
516 | |||
74 | # gl_MODULE_INDICATOR_CONDITION | 517 | # gl_MODULE_INDICATOR_CONDITION |
75 | # expands to a C preprocessor expression that evaluates to 1 or 0, depending | 518 | # expands to a C preprocessor expression that evaluates to 1 or 0, depending |
76 | # whether a gnulib module that has been requested shall be considered present | 519 | # whether a gnulib module that has been requested shall be considered present |
@@ -83,9 +526,9 @@ m4_define([gl_MODULE_INDICATOR_CONDITION], [1]) | |||
83 | AC_DEFUN([gl_MODULE_INDICATOR_SET_VARIABLE], | 526 | AC_DEFUN([gl_MODULE_INDICATOR_SET_VARIABLE], |
84 | [ | 527 | [ |
85 | gl_MODULE_INDICATOR_SET_VARIABLE_AUX( | 528 | gl_MODULE_INDICATOR_SET_VARIABLE_AUX( |
86 | [GNULIB_[]m4_translit([[$1]], | 529 | [GL_MODULE_INDICATOR_PREFIX[]_GNULIB_[]m4_translit([[$1]], |
87 | [abcdefghijklmnopqrstuvwxyz./-], | 530 | [abcdefghijklmnopqrstuvwxyz./-], |
88 | [ABCDEFGHIJKLMNOPQRSTUVWXYZ___])], | 531 | [ABCDEFGHIJKLMNOPQRSTUVWXYZ___])], |
89 | [gl_MODULE_INDICATOR_CONDITION]) | 532 | [gl_MODULE_INDICATOR_CONDITION]) |
90 | ]) | 533 | ]) |
91 | 534 | ||
@@ -197,42 +640,20 @@ AC_DEFUN([gl_FEATURES_H], | |||
197 | AC_SUBST([HAVE_FEATURES_H]) | 640 | AC_SUBST([HAVE_FEATURES_H]) |
198 | ]) | 641 | ]) |
199 | 642 | ||
200 | # m4_foreach_w | ||
201 | # is a backport of autoconf-2.59c's m4_foreach_w. | ||
202 | # Remove this macro when we can assume autoconf >= 2.60. | ||
203 | m4_ifndef([m4_foreach_w], | ||
204 | [m4_define([m4_foreach_w], | ||
205 | [m4_foreach([$1], m4_split(m4_normalize([$2]), [ ]), [$3])])]) | ||
206 | |||
207 | # AS_VAR_IF(VAR, VALUE, [IF-MATCH], [IF-NOT-MATCH]) | ||
208 | # ---------------------------------------------------- | ||
209 | # Backport of autoconf-2.63b's macro. | ||
210 | # Remove this macro when we can assume autoconf >= 2.64. | ||
211 | m4_ifndef([AS_VAR_IF], | ||
212 | [m4_define([AS_VAR_IF], | ||
213 | [AS_IF([test x"AS_VAR_GET([$1])" = x""$2], [$3], [$4])])]) | ||
214 | |||
215 | # gl_PROG_CC_C99 | 643 | # gl_PROG_CC_C99 |
216 | # Modifies the value of the shell variable CC in an attempt to make $CC | 644 | # Modifies the value of the shell variable CC in an attempt to make $CC |
217 | # understand ISO C99 source code. | 645 | # understand ISO C99 source code. |
218 | # This is like AC_PROG_CC_C99, except that | ||
219 | # - AC_PROG_CC_C99 did not exist in Autoconf versions < 2.60, | ||
220 | # - AC_PROG_CC_C99 does not mix well with AC_PROG_CC_STDC | ||
221 | # <http://lists.gnu.org/archive/html/bug-gnulib/2011-09/msg00367.html>, | ||
222 | # but many more packages use AC_PROG_CC_STDC than AC_PROG_CC_C99 | ||
223 | # <http://lists.gnu.org/archive/html/bug-gnulib/2011-09/msg00441.html>. | ||
224 | # Remaining problems: | ||
225 | # - When AC_PROG_CC_STDC is invoked twice, it adds the C99 enabling options | ||
226 | # to CC twice | ||
227 | # <http://lists.gnu.org/archive/html/bug-gnulib/2011-09/msg00431.html>. | ||
228 | # - AC_PROG_CC_STDC is likely to change now that C11 is an ISO standard. | ||
229 | AC_DEFUN([gl_PROG_CC_C99], | 646 | AC_DEFUN([gl_PROG_CC_C99], |
230 | [ | 647 | [ |
231 | dnl Change that version number to the minimum Autoconf version that supports | 648 | dnl Just use AC_PROG_CC_C99. |
232 | dnl mixing AC_PROG_CC_C99 calls with AC_PROG_CC_STDC calls. | 649 | dnl When AC_PROG_CC_C99 and AC_PROG_CC_STDC are used together, the substituted |
233 | m4_version_prereq([9.0], | 650 | dnl value of CC will contain the C99 enabling options twice. But this is only |
234 | [AC_REQUIRE([AC_PROG_CC_C99])], | 651 | dnl a cosmetic problem. |
235 | [AC_REQUIRE([AC_PROG_CC_STDC])]) | 652 | dnl With Autoconf >= 2.70, use AC_PROG_CC since it implies AC_PROG_CC_C99; |
653 | dnl this avoids a "warning: The macro `AC_PROG_CC_C99' is obsolete." | ||
654 | m4_version_prereq([2.70], | ||
655 | [AC_REQUIRE([AC_PROG_CC])], | ||
656 | [AC_REQUIRE([AC_PROG_CC_C99])]) | ||
236 | ]) | 657 | ]) |
237 | 658 | ||
238 | # gl_PROG_AR_RANLIB | 659 | # gl_PROG_AR_RANLIB |
@@ -243,9 +664,11 @@ AC_DEFUN([gl_PROG_AR_RANLIB], | |||
243 | [ | 664 | [ |
244 | dnl Minix 3 comes with two toolchains: The Amsterdam Compiler Kit compiler | 665 | dnl Minix 3 comes with two toolchains: The Amsterdam Compiler Kit compiler |
245 | dnl as "cc", and GCC as "gcc". They have different object file formats and | 666 | dnl as "cc", and GCC as "gcc". They have different object file formats and |
246 | dnl library formats. In particular, the GNU binutils programs ar, ranlib | 667 | dnl library formats. In particular, the GNU binutils programs ar and ranlib |
247 | dnl produce libraries that work only with gcc, not with cc. | 668 | dnl produce libraries that work only with gcc, not with cc. |
248 | AC_REQUIRE([AC_PROG_CC]) | 669 | AC_REQUIRE([AC_PROG_CC]) |
670 | dnl The '][' hides this use from 'aclocal'. | ||
671 | AC_BEFORE([$0], [A][M_PROG_AR]) | ||
249 | AC_CACHE_CHECK([for Minix Amsterdam compiler], [gl_cv_c_amsterdam_compiler], | 672 | AC_CACHE_CHECK([for Minix Amsterdam compiler], [gl_cv_c_amsterdam_compiler], |
250 | [ | 673 | [ |
251 | AC_EGREP_CPP([Amsterdam], | 674 | AC_EGREP_CPP([Amsterdam], |
@@ -257,25 +680,39 @@ Amsterdam | |||
257 | [gl_cv_c_amsterdam_compiler=yes], | 680 | [gl_cv_c_amsterdam_compiler=yes], |
258 | [gl_cv_c_amsterdam_compiler=no]) | 681 | [gl_cv_c_amsterdam_compiler=no]) |
259 | ]) | 682 | ]) |
260 | if test -z "$AR"; then | 683 | |
261 | if test $gl_cv_c_amsterdam_compiler = yes; then | 684 | dnl Don't compete with AM_PROG_AR's decision about AR/ARFLAGS if we are not |
685 | dnl building with __ACK__. | ||
686 | if test $gl_cv_c_amsterdam_compiler = yes; then | ||
687 | if test -z "$AR"; then | ||
262 | AR='cc -c.a' | 688 | AR='cc -c.a' |
263 | if test -z "$ARFLAGS"; then | ||
264 | ARFLAGS='-o' | ||
265 | fi | ||
266 | else | ||
267 | dnl Use the Automake-documented default values for AR and ARFLAGS, | ||
268 | dnl but prefer ${host}-ar over ar (useful for cross-compiling). | ||
269 | AC_CHECK_TOOL([AR], [ar], [ar]) | ||
270 | if test -z "$ARFLAGS"; then | ||
271 | ARFLAGS='cru' | ||
272 | fi | ||
273 | fi | 689 | fi |
274 | else | ||
275 | if test -z "$ARFLAGS"; then | 690 | if test -z "$ARFLAGS"; then |
276 | ARFLAGS='cru' | 691 | ARFLAGS='-o' |
277 | fi | 692 | fi |
693 | else | ||
694 | dnl AM_PROG_AR was added in automake v1.11.2. AM_PROG_AR does not AC_SUBST | ||
695 | dnl ARFLAGS variable (it is filed into Makefile.in directly by automake | ||
696 | dnl script on-demand, if not specified by ./configure of course). | ||
697 | dnl Don't AC_REQUIRE the AM_PROG_AR otherwise the code for __ACK__ above | ||
698 | dnl will be ignored. Also, pay attention to call AM_PROG_AR in else block | ||
699 | dnl because AM_PROG_AR is written so it could re-set AR variable even for | ||
700 | dnl __ACK__. It may seem like its easier to avoid calling the macro here, | ||
701 | dnl but we need to AC_SUBST both AR/ARFLAGS (thus those must have some good | ||
702 | dnl default value and automake should usually know them). | ||
703 | dnl | ||
704 | dnl The '][' hides this use from 'aclocal'. | ||
705 | m4_ifdef([A][M_PROG_AR], [A][M_PROG_AR], [:]) | ||
706 | fi | ||
707 | |||
708 | dnl In case the code above has not helped with setting AR/ARFLAGS, use | ||
709 | dnl Automake-documented default values for AR and ARFLAGS, but prefer | ||
710 | dnl ${host}-ar over ar (useful for cross-compiling). | ||
711 | AC_CHECK_TOOL([AR], [ar], [ar]) | ||
712 | if test -z "$ARFLAGS"; then | ||
713 | ARFLAGS='cr' | ||
278 | fi | 714 | fi |
715 | |||
279 | AC_SUBST([AR]) | 716 | AC_SUBST([AR]) |
280 | AC_SUBST([ARFLAGS]) | 717 | AC_SUBST([ARFLAGS]) |
281 | if test -z "$RANLIB"; then | 718 | if test -z "$RANLIB"; then |
@@ -289,46 +726,29 @@ Amsterdam | |||
289 | AC_SUBST([RANLIB]) | 726 | AC_SUBST([RANLIB]) |
290 | ]) | 727 | ]) |
291 | 728 | ||
292 | # AC_PROG_MKDIR_P | ||
293 | # is a backport of autoconf-2.60's AC_PROG_MKDIR_P, with a fix | ||
294 | # for interoperability with automake-1.9.6 from autoconf-2.62. | ||
295 | # Remove this macro when we can assume autoconf >= 2.62 or | ||
296 | # autoconf >= 2.60 && automake >= 1.10. | ||
297 | # AC_AUTOCONF_VERSION was introduced in 2.62, so use that as the witness. | ||
298 | m4_ifndef([AC_AUTOCONF_VERSION],[ | ||
299 | m4_ifdef([AC_PROG_MKDIR_P], [ | ||
300 | dnl For automake-1.9.6 && autoconf < 2.62: Ensure MKDIR_P is AC_SUBSTed. | ||
301 | m4_define([AC_PROG_MKDIR_P], | ||
302 | m4_defn([AC_PROG_MKDIR_P])[ | ||
303 | AC_SUBST([MKDIR_P])])], [ | ||
304 | dnl For autoconf < 2.60: Backport of AC_PROG_MKDIR_P. | ||
305 | AC_DEFUN_ONCE([AC_PROG_MKDIR_P], | ||
306 | [AC_REQUIRE([AM_PROG_MKDIR_P])dnl defined by automake | ||
307 | MKDIR_P='$(mkdir_p)' | ||
308 | AC_SUBST([MKDIR_P])])]) | ||
309 | ]) | ||
310 | |||
311 | # AC_C_RESTRICT | 729 | # AC_C_RESTRICT |
312 | # This definition overrides the AC_C_RESTRICT macro from autoconf 2.60..2.61, | 730 | # This definition is copied from post-2.70 Autoconf and overrides the |
313 | # so that mixed use of GNU C and GNU C++ and mixed use of Sun C and Sun C++ | 731 | # AC_C_RESTRICT macro from autoconf 2.60..2.70. |
314 | # works. | 732 | m4_version_prereq([2.70.1], [], [ |
315 | # This definition can be removed once autoconf >= 2.62 can be assumed. | ||
316 | # AC_AUTOCONF_VERSION was introduced in 2.62, so use that as the witness. | ||
317 | m4_ifndef([AC_AUTOCONF_VERSION],[ | ||
318 | AC_DEFUN([AC_C_RESTRICT], | 733 | AC_DEFUN([AC_C_RESTRICT], |
319 | [AC_CACHE_CHECK([for C/C++ restrict keyword], [ac_cv_c_restrict], | 734 | [AC_CACHE_CHECK([for C/C++ restrict keyword], [ac_cv_c_restrict], |
320 | [ac_cv_c_restrict=no | 735 | [ac_cv_c_restrict=no |
321 | # The order here caters to the fact that C++ does not require restrict. | 736 | # Put '__restrict__' first, to avoid problems with glibc and non-GCC; see: |
322 | for ac_kw in __restrict __restrict__ _Restrict restrict; do | 737 | # https://lists.gnu.org/archive/html/bug-autoconf/2016-02/msg00006.html |
323 | AC_COMPILE_IFELSE([AC_LANG_PROGRAM( | 738 | # Put 'restrict' last, because C++ lacks it. |
324 | [[typedef int * int_ptr; | 739 | for ac_kw in __restrict__ __restrict _Restrict restrict; do |
325 | int foo (int_ptr $ac_kw ip) { | 740 | AC_COMPILE_IFELSE( |
326 | return ip[0]; | 741 | [AC_LANG_PROGRAM( |
327 | }]], | 742 | [[typedef int *int_ptr; |
328 | [[int s[1]; | 743 | int foo (int_ptr $ac_kw ip) { return ip[0]; } |
329 | int * $ac_kw t = s; | 744 | int bar (int [$ac_kw]); /* Catch GCC bug 14050. */ |
330 | t[0] = 0; | 745 | int bar (int ip[$ac_kw]) { return ip[0]; } |
331 | return foo(t)]])], | 746 | ]], |
747 | [[int s[1]; | ||
748 | int *$ac_kw t = s; | ||
749 | t[0] = 0; | ||
750 | return foo (t) + bar (t); | ||
751 | ]])], | ||
332 | [ac_cv_c_restrict=$ac_kw]) | 752 | [ac_cv_c_restrict=$ac_kw]) |
333 | test "$ac_cv_c_restrict" != no && break | 753 | test "$ac_cv_c_restrict" != no && break |
334 | done | 754 | done |
@@ -336,22 +756,24 @@ AC_DEFUN([AC_C_RESTRICT], | |||
336 | AH_VERBATIM([restrict], | 756 | AH_VERBATIM([restrict], |
337 | [/* Define to the equivalent of the C99 'restrict' keyword, or to | 757 | [/* Define to the equivalent of the C99 'restrict' keyword, or to |
338 | nothing if this is not supported. Do not define if restrict is | 758 | nothing if this is not supported. Do not define if restrict is |
339 | supported directly. */ | 759 | supported only directly. */ |
340 | #undef restrict | 760 | #undef restrict |
341 | /* Work around a bug in Sun C++: it does not support _Restrict, even | 761 | /* Work around a bug in older versions of Sun C++, which did not |
342 | though the corresponding Sun C compiler does, which causes | 762 | #define __restrict__ or support _Restrict or __restrict__ |
343 | "#define restrict _Restrict" in the previous line. Perhaps some future | 763 | even though the corresponding Sun C compiler ended up with |
344 | version of Sun C++ will work with _Restrict; if so, it'll probably | 764 | "#define restrict _Restrict" or "#define restrict __restrict__" |
345 | define __RESTRICT, just as Sun C does. */ | 765 | in the previous line. This workaround can be removed once |
346 | #if defined __SUNPRO_CC && !defined __RESTRICT | 766 | we assume Oracle Developer Studio 12.5 (2016) or later. */ |
767 | #if defined __SUNPRO_CC && !defined __RESTRICT && !defined __restrict__ | ||
347 | # define _Restrict | 768 | # define _Restrict |
769 | # define __restrict__ | ||
348 | #endif]) | 770 | #endif]) |
349 | case $ac_cv_c_restrict in | 771 | case $ac_cv_c_restrict in |
350 | restrict) ;; | 772 | restrict) ;; |
351 | no) AC_DEFINE([restrict], []) ;; | 773 | no) AC_DEFINE([restrict], []) ;; |
352 | *) AC_DEFINE_UNQUOTED([restrict], [$ac_cv_c_restrict]) ;; | 774 | *) AC_DEFINE_UNQUOTED([restrict], [$ac_cv_c_restrict]) ;; |
353 | esac | 775 | esac |
354 | ]) | 776 | ])# AC_C_RESTRICT |
355 | ]) | 777 | ]) |
356 | 778 | ||
357 | # gl_BIGENDIAN | 779 | # gl_BIGENDIAN |
@@ -363,6 +785,22 @@ AC_DEFUN([gl_BIGENDIAN], | |||
363 | AC_C_BIGENDIAN | 785 | AC_C_BIGENDIAN |
364 | ]) | 786 | ]) |
365 | 787 | ||
788 | # A temporary file descriptor. | ||
789 | # Must be less than 10, because dash 0.5.8 does not support redirections | ||
790 | # with multi-digit file descriptors. | ||
791 | m4_define([GL_TMP_FD], 9) | ||
792 | |||
793 | # gl_SILENT(command) | ||
794 | # executes command, but without the normal configure output. | ||
795 | # This is useful when you want to invoke AC_CACHE_CHECK (or AC_CHECK_FUNC etc.) | ||
796 | # inside another AC_CACHE_CHECK. | ||
797 | AC_DEFUN([gl_SILENT], | ||
798 | [ | ||
799 | exec GL_TMP_FD>&AS_MESSAGE_FD AS_MESSAGE_FD>/dev/null | ||
800 | $1 | ||
801 | exec AS_MESSAGE_FD>&GL_TMP_FD GL_TMP_FD>&- | ||
802 | ]) | ||
803 | |||
366 | # gl_CACHE_VAL_SILENT(cache-id, command-to-set-it) | 804 | # gl_CACHE_VAL_SILENT(cache-id, command-to-set-it) |
367 | # is like AC_CACHE_VAL(cache-id, command-to-set-it), except that it does not | 805 | # is like AC_CACHE_VAL(cache-id, command-to-set-it), except that it does not |
368 | # output a spurious "(cached)" mark in the midst of other configure output. | 806 | # output a spurious "(cached)" mark in the midst of other configure output. |
@@ -370,8 +808,143 @@ AC_DEFUN([gl_BIGENDIAN], | |||
370 | # by an AC_MSG_CHECKING/AC_MSG_RESULT pair. | 808 | # by an AC_MSG_CHECKING/AC_MSG_RESULT pair. |
371 | AC_DEFUN([gl_CACHE_VAL_SILENT], | 809 | AC_DEFUN([gl_CACHE_VAL_SILENT], |
372 | [ | 810 | [ |
373 | saved_as_echo_n="$as_echo_n" | 811 | gl_SILENT([ |
374 | as_echo_n=':' | 812 | AC_CACHE_VAL([$1], [$2]) |
375 | AC_CACHE_VAL([$1], [$2]) | 813 | ]) |
376 | as_echo_n="$saved_as_echo_n" | 814 | ]) |
815 | |||
816 | # gl_CC_ALLOW_WARNINGS | ||
817 | # sets and substitutes a variable GL_CFLAG_ALLOW_WARNINGS, to a $(CC) option | ||
818 | # that reverts a preceding '-Werror' option, if available. | ||
819 | # This is expected to be '-Wno-error' on gcc, clang (except clang/MSVC), xlclang | ||
820 | # and empty otherwise. | ||
821 | AC_DEFUN([gl_CC_ALLOW_WARNINGS], | ||
822 | [ | ||
823 | AC_REQUIRE([AC_PROG_CC]) | ||
824 | AC_CACHE_CHECK([for C compiler option to allow warnings], | ||
825 | [gl_cv_cc_wallow], | ||
826 | [rm -f conftest* | ||
827 | echo 'int dummy;' > conftest.c | ||
828 | AC_TRY_COMMAND([${CC-cc} $CFLAGS $CPPFLAGS -c conftest.c 2>conftest1.err]) >/dev/null | ||
829 | AC_TRY_COMMAND([${CC-cc} $CFLAGS $CPPFLAGS -Wno-error -c conftest.c 2>conftest2.err]) >/dev/null | ||
830 | dnl Test the number of error output lines, because AIX xlc accepts the | ||
831 | dnl option '-Wno-error', just to produce a warning | ||
832 | dnl "Option -Wno-error was incorrectly specified. The option will be ignored." | ||
833 | dnl afterwards. | ||
834 | if test $? = 0 && test `wc -l < conftest1.err` = `wc -l < conftest2.err`; then | ||
835 | gl_cv_cc_wallow='-Wno-error' | ||
836 | else | ||
837 | gl_cv_cc_wallow=none | ||
838 | fi | ||
839 | rm -f conftest* | ||
840 | ]) | ||
841 | case "$gl_cv_cc_wallow" in | ||
842 | none) GL_CFLAG_ALLOW_WARNINGS='' ;; | ||
843 | *) GL_CFLAG_ALLOW_WARNINGS="$gl_cv_cc_wallow" ;; | ||
844 | esac | ||
845 | AC_SUBST([GL_CFLAG_ALLOW_WARNINGS]) | ||
846 | ]) | ||
847 | |||
848 | # gl_CXX_ALLOW_WARNINGS | ||
849 | # sets and substitutes a variable GL_CXXFLAG_ALLOW_WARNINGS, to a $(CC) option | ||
850 | # that reverts a preceding '-Werror' option, if available. | ||
851 | AC_DEFUN([gl_CXX_ALLOW_WARNINGS], | ||
852 | [ | ||
853 | dnl Requires AC_PROG_CXX or gl_PROG_ANSI_CXX. | ||
854 | if test -n "$CXX" && test "$CXX" != no; then | ||
855 | AC_CACHE_CHECK([for C++ compiler option to allow warnings], | ||
856 | [gl_cv_cxx_wallow], | ||
857 | [rm -f conftest* | ||
858 | echo 'int dummy;' > conftest.cc | ||
859 | AC_TRY_COMMAND([${CXX-c++} $CXXFLAGS $CPPFLAGS -c conftest.cc 2>conftest1.err]) >/dev/null | ||
860 | AC_TRY_COMMAND([${CXX-c++} $CXXFLAGS $CPPFLAGS -Wno-error -c conftest.cc 2>conftest2.err]) >/dev/null | ||
861 | dnl Test the number of error output lines, because AIX xlC accepts the | ||
862 | dnl option '-Wno-error', just to produce a warning | ||
863 | dnl "Option -Wno-error was incorrectly specified. The option will be ignored." | ||
864 | dnl afterwards. | ||
865 | if test $? = 0 && test `wc -l < conftest1.err` = `wc -l < conftest2.err`; then | ||
866 | gl_cv_cxx_wallow='-Wno-error' | ||
867 | else | ||
868 | gl_cv_cxx_wallow=none | ||
869 | fi | ||
870 | rm -f conftest* | ||
871 | ]) | ||
872 | case "$gl_cv_cxx_wallow" in | ||
873 | none) GL_CXXFLAG_ALLOW_WARNINGS='' ;; | ||
874 | *) GL_CXXFLAG_ALLOW_WARNINGS="$gl_cv_cxx_wallow" ;; | ||
875 | esac | ||
876 | else | ||
877 | GL_CXXFLAG_ALLOW_WARNINGS='' | ||
878 | fi | ||
879 | AC_SUBST([GL_CXXFLAG_ALLOW_WARNINGS]) | ||
880 | ]) | ||
881 | |||
882 | dnl Expands to some code for use in .c programs that, on native Windows, defines | ||
883 | dnl the Microsoft deprecated alias function names to the underscore-prefixed | ||
884 | dnl actual function names. With this macro, these function names are available | ||
885 | dnl without linking with '-loldnames' and without generating warnings. | ||
886 | dnl Usage: Use it after all system header files are included. | ||
887 | dnl #include <...> | ||
888 | dnl #include <...> | ||
889 | dnl ]GL_MDA_DEFINES[ | ||
890 | dnl ... | ||
891 | AC_DEFUN([GL_MDA_DEFINES],[ | ||
892 | AC_REQUIRE([_GL_MDA_DEFINES]) | ||
893 | [$gl_mda_defines] | ||
894 | ]) | ||
895 | AC_DEFUN([_GL_MDA_DEFINES], | ||
896 | [gl_mda_defines=' | ||
897 | #if defined _WIN32 && !defined __CYGWIN__ | ||
898 | #define access _access | ||
899 | #define chdir _chdir | ||
900 | #define chmod _chmod | ||
901 | #define close _close | ||
902 | #define creat _creat | ||
903 | #define dup _dup | ||
904 | #define dup2 _dup2 | ||
905 | #define ecvt _ecvt | ||
906 | #define execl _execl | ||
907 | #define execle _execle | ||
908 | #define execlp _execlp | ||
909 | #define execv _execv | ||
910 | #define execve _execve | ||
911 | #define execvp _execvp | ||
912 | #define execvpe _execvpe | ||
913 | #define fcloseall _fcloseall | ||
914 | #define fcvt _fcvt | ||
915 | #define fdopen _fdopen | ||
916 | #define fileno _fileno | ||
917 | #define gcvt _gcvt | ||
918 | #define getcwd _getcwd | ||
919 | #define getpid _getpid | ||
920 | #define getw _getw | ||
921 | #define isatty _isatty | ||
922 | #define j0 _j0 | ||
923 | #define j1 _j1 | ||
924 | #define jn _jn | ||
925 | #define lfind _lfind | ||
926 | #define lsearch _lsearch | ||
927 | #define lseek _lseek | ||
928 | #define memccpy _memccpy | ||
929 | #define mkdir _mkdir | ||
930 | #define mktemp _mktemp | ||
931 | #define open _open | ||
932 | #define putenv _putenv | ||
933 | #define putw _putw | ||
934 | #define read _read | ||
935 | #define rmdir _rmdir | ||
936 | #define strdup _strdup | ||
937 | #define swab _swab | ||
938 | #define tempnam _tempnam | ||
939 | #define tzset _tzset | ||
940 | #define umask _umask | ||
941 | #define unlink _unlink | ||
942 | #define utime _utime | ||
943 | #define wcsdup _wcsdup | ||
944 | #define write _write | ||
945 | #define y0 _y0 | ||
946 | #define y1 _y1 | ||
947 | #define yn _yn | ||
948 | #endif | ||
949 | ' | ||
377 | ]) | 950 | ]) |