1 # gnulib-common.m4 serial 75a
2 dnl Copyright (C) 2007-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.
10 # is expanded unconditionally through gnulib-tool magic.
11 AC_DEFUN([gl_COMMON], [
12 dnl Use AC_REQUIRE here, so that the code is expanded once only.
13 AC_REQUIRE([gl_00GNULIB])
14 AC_REQUIRE([gl_COMMON_BODY])
15 AC_REQUIRE([gl_ZZGNULIB])
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__))
24 # define _GL_GNUC_PREREQ(major, minor) 0
27 AH_VERBATIM([_Noreturn],
28 [/* The _Noreturn keyword of C11. */
30 # if (defined __cplusplus \
31 && ((201103 <= __cplusplus && !(__GNUC__ == 4 && __GNUC_MINOR__ == 7)) \
32 || (defined _MSC_VER && 1900 <= _MSC_VER)) \
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 __clang__ && __clang_major__ < 16 \
42 && defined _GL_WORK_AROUND_LLVM_BUG_59792)
43 /* Compile with -D_GL_WORK_AROUND_LLVM_BUG_59792 to work around
44 that rare LLVM bug, though you may get many false-alarm warnings. */
46 # elif ((!defined __cplusplus || defined __clang__) \
47 && (201112 <= (defined __STDC_VERSION__ ? __STDC_VERSION__ : 0) \
48 || (!defined __STRICT_ANSI__ \
49 && (_GL_GNUC_PREREQ (4, 7) \
50 || (defined __apple_build_version__ \
51 ? 6000000 <= __apple_build_version__ \
52 : 3 < __clang_major__ + (5 <= __clang_minor__))))))
53 /* _Noreturn works as-is. */
54 # elif _GL_GNUC_PREREQ (2, 8) || defined __clang__ || 0x5110 <= __SUNPRO_C
55 # define _Noreturn __attribute__ ((__noreturn__))
56 # elif 1200 <= (defined _MSC_VER ? _MSC_VER : 0)
57 # define _Noreturn __declspec (noreturn)
63 AH_VERBATIM([isoc99_inline],
64 [/* Work around a bug in Apple GCC 4.0.1 build 5465: In C99 mode, it supports
65 the ISO C 99 semantics of 'extern inline' (unlike the GNU C semantics of
66 earlier versions), but does not display it by setting __GNUC_STDC_INLINE__.
67 __APPLE__ && __MACH__ test for Mac OS X.
68 __APPLE_CC__ tests for the Apple compiler and its version.
69 __STDC_VERSION__ tests for the C99 mode. */
70 #if defined __APPLE__ && defined __MACH__ && __APPLE_CC__ >= 5465 && !defined __cplusplus && __STDC_VERSION__ >= 199901L && !defined __GNUC_STDC_INLINE__
71 # define __GNUC_STDC_INLINE__ 1
73 AH_VERBATIM([attribute],
75 #if (defined __has_attribute \
76 && (!defined __clang_minor__ \
77 || (defined __apple_build_version__ \
78 ? 6000000 <= __apple_build_version__ \
79 : 3 < __clang_major__ + (5 <= __clang_minor__))))
80 # define _GL_HAS_ATTRIBUTE(attr) __has_attribute (__##attr##__)
82 # define _GL_HAS_ATTRIBUTE(attr) _GL_ATTR_##attr
83 # define _GL_ATTR_alloc_size _GL_GNUC_PREREQ (4, 3)
84 # define _GL_ATTR_always_inline _GL_GNUC_PREREQ (3, 2)
85 # define _GL_ATTR_artificial _GL_GNUC_PREREQ (4, 3)
86 # define _GL_ATTR_cold _GL_GNUC_PREREQ (4, 3)
87 # define _GL_ATTR_const _GL_GNUC_PREREQ (2, 95)
88 # define _GL_ATTR_deprecated _GL_GNUC_PREREQ (3, 1)
89 # define _GL_ATTR_diagnose_if 0
90 # define _GL_ATTR_error _GL_GNUC_PREREQ (4, 3)
91 # define _GL_ATTR_externally_visible _GL_GNUC_PREREQ (4, 1)
92 # define _GL_ATTR_fallthrough _GL_GNUC_PREREQ (7, 0)
93 # define _GL_ATTR_format _GL_GNUC_PREREQ (2, 7)
94 # define _GL_ATTR_leaf _GL_GNUC_PREREQ (4, 6)
95 # define _GL_ATTR_malloc _GL_GNUC_PREREQ (3, 0)
97 # define _GL_ATTR_may_alias 0
99 # define _GL_ATTR_may_alias _GL_GNUC_PREREQ (3, 3)
101 # define _GL_ATTR_noinline _GL_GNUC_PREREQ (3, 1)
102 # define _GL_ATTR_nonnull _GL_GNUC_PREREQ (3, 3)
103 # define _GL_ATTR_nonstring _GL_GNUC_PREREQ (8, 0)
104 # define _GL_ATTR_nothrow _GL_GNUC_PREREQ (3, 3)
105 # define _GL_ATTR_packed _GL_GNUC_PREREQ (2, 7)
106 # define _GL_ATTR_pure _GL_GNUC_PREREQ (2, 96)
107 # define _GL_ATTR_returns_nonnull _GL_GNUC_PREREQ (4, 9)
108 # define _GL_ATTR_sentinel _GL_GNUC_PREREQ (4, 0)
109 # define _GL_ATTR_unused _GL_GNUC_PREREQ (2, 7)
110 # define _GL_ATTR_warn_unused_result _GL_GNUC_PREREQ (3, 4)
113 /* Disable GCC -Wpedantic if using __has_c_attribute and this is not C23+. */
114 #if (defined __has_c_attribute && _GL_GNUC_PREREQ (4, 6) \
115 && (defined __STDC_VERSION__ ? __STDC_VERSION__ : 0) <= 201710)
116 # pragma GCC diagnostic ignored "-Wpedantic"
119 ]dnl There is no _GL_ATTRIBUTE_ALIGNED; use stdalign's alignas instead.
121 /* _GL_ATTRIBUTE_ALLOC_SIZE ((N)) declares that the Nth argument of the function
122 is the size of the returned memory block.
123 _GL_ATTRIBUTE_ALLOC_SIZE ((M, N)) declares that the Mth argument multiplied
124 by the Nth argument of the function is the size of the returned memory block.
126 /* Applies to: function, pointer to function, function types. */
127 #ifndef _GL_ATTRIBUTE_ALLOC_SIZE
128 # if _GL_HAS_ATTRIBUTE (alloc_size)
129 # define _GL_ATTRIBUTE_ALLOC_SIZE(args) __attribute__ ((__alloc_size__ args))
131 # define _GL_ATTRIBUTE_ALLOC_SIZE(args)
135 /* _GL_ATTRIBUTE_ALWAYS_INLINE tells that the compiler should always inline the
136 function and report an error if it cannot do so. */
137 /* Applies to: function. */
138 #ifndef _GL_ATTRIBUTE_ALWAYS_INLINE
139 # if _GL_HAS_ATTRIBUTE (always_inline)
140 # define _GL_ATTRIBUTE_ALWAYS_INLINE __attribute__ ((__always_inline__))
142 # define _GL_ATTRIBUTE_ALWAYS_INLINE
146 /* _GL_ATTRIBUTE_ARTIFICIAL declares that the function is not important to show
147 in stack traces when debugging. The compiler should omit the function from
149 /* Applies to: function. */
150 #ifndef _GL_ATTRIBUTE_ARTIFICIAL
151 # if _GL_HAS_ATTRIBUTE (artificial)
152 # define _GL_ATTRIBUTE_ARTIFICIAL __attribute__ ((__artificial__))
154 # define _GL_ATTRIBUTE_ARTIFICIAL
158 /* _GL_ATTRIBUTE_COLD declares that the function is rarely executed. */
159 /* Applies to: functions. */
160 /* Avoid __attribute__ ((cold)) on MinGW; see thread starting at
161 <https://lists.gnu.org/r/emacs-devel/2019-04/msg01152.html>.
162 Also, Oracle Studio 12.6 requires 'cold' not '__cold__'. */
163 #ifndef _GL_ATTRIBUTE_COLD
164 # if _GL_HAS_ATTRIBUTE (cold) && !defined __MINGW32__
166 # define _GL_ATTRIBUTE_COLD __attribute__ ((__cold__))
168 # define _GL_ATTRIBUTE_COLD __attribute__ ((cold))
171 # define _GL_ATTRIBUTE_COLD
175 /* _GL_ATTRIBUTE_CONST declares that it is OK for a compiler to omit duplicate
176 calls to the function with the same arguments.
177 This attribute is safe for a function that neither depends on nor affects
178 observable state, and always returns exactly once - e.g., does not loop
179 forever, and does not call longjmp.
180 (This attribute is stricter than _GL_ATTRIBUTE_PURE.) */
181 /* Applies to: functions. */
182 #ifndef _GL_ATTRIBUTE_CONST
183 # if _GL_HAS_ATTRIBUTE (const)
184 # define _GL_ATTRIBUTE_CONST __attribute__ ((__const__))
186 # define _GL_ATTRIBUTE_CONST
190 /* _GL_ATTRIBUTE_DEALLOC (F, I) declares that the function returns pointers
191 that can be freed by passing them as the Ith argument to the
193 _GL_ATTRIBUTE_DEALLOC_FREE declares that the function returns pointers that
194 can be freed via 'free'; it can be used only after declaring 'free'. */
195 /* Applies to: functions. Cannot be used on inline functions. */
196 #ifndef _GL_ATTRIBUTE_DEALLOC
197 # if _GL_GNUC_PREREQ (11, 0)
198 # define _GL_ATTRIBUTE_DEALLOC(f, i) __attribute__ ((__malloc__ (f, i)))
200 # define _GL_ATTRIBUTE_DEALLOC(f, i)
203 /* If gnulib's <string.h> or <wchar.h> has already defined this macro, continue
204 to use this earlier definition, since <stdlib.h> may not have been included
206 #ifndef _GL_ATTRIBUTE_DEALLOC_FREE
207 # if defined __cplusplus && defined __GNUC__ && !defined __clang__
208 /* Work around GCC bug <https://gcc.gnu.org/bugzilla/show_bug.cgi?id=108231> */
209 # define _GL_ATTRIBUTE_DEALLOC_FREE \
210 _GL_ATTRIBUTE_DEALLOC ((void (*) (void *)) free, 1)
212 # define _GL_ATTRIBUTE_DEALLOC_FREE \
213 _GL_ATTRIBUTE_DEALLOC (free, 1)
217 /* _GL_ATTRIBUTE_DEPRECATED: Declares that an entity is deprecated.
218 The compiler may warn if the entity is used. */
220 - function, variable,
221 - struct, union, struct/union member,
222 - enumeration, enumeration item,
224 in C++ also: namespace, class, template specialization. */
225 #ifndef _GL_ATTRIBUTE_DEPRECATED
226 # ifdef __has_c_attribute
227 # if __has_c_attribute (__deprecated__)
228 # define _GL_ATTRIBUTE_DEPRECATED [[__deprecated__]]
231 # if !defined _GL_ATTRIBUTE_DEPRECATED && _GL_HAS_ATTRIBUTE (deprecated)
232 # define _GL_ATTRIBUTE_DEPRECATED __attribute__ ((__deprecated__))
234 # ifndef _GL_ATTRIBUTE_DEPRECATED
235 # define _GL_ATTRIBUTE_DEPRECATED
239 /* _GL_ATTRIBUTE_ERROR(msg) requests an error if a function is called and
240 the function call is not optimized away.
241 _GL_ATTRIBUTE_WARNING(msg) requests a warning if a function is called and
242 the function call is not optimized away. */
243 /* Applies to: functions. */
244 #if !(defined _GL_ATTRIBUTE_ERROR && defined _GL_ATTRIBUTE_WARNING)
245 # if _GL_HAS_ATTRIBUTE (error)
246 # define _GL_ATTRIBUTE_ERROR(msg) __attribute__ ((__error__ (msg)))
247 # define _GL_ATTRIBUTE_WARNING(msg) __attribute__ ((__warning__ (msg)))
248 # elif _GL_HAS_ATTRIBUTE (diagnose_if)
249 # define _GL_ATTRIBUTE_ERROR(msg) __attribute__ ((__diagnose_if__ (1, msg, "error")))
250 # define _GL_ATTRIBUTE_WARNING(msg) __attribute__ ((__diagnose_if__ (1, msg, "warning")))
252 # define _GL_ATTRIBUTE_ERROR(msg)
253 # define _GL_ATTRIBUTE_WARNING(msg)
257 /* _GL_ATTRIBUTE_EXTERNALLY_VISIBLE declares that the entity should remain
258 visible to debuggers etc., even with '-fwhole-program'. */
259 /* Applies to: functions, variables. */
260 #ifndef _GL_ATTRIBUTE_EXTERNALLY_VISIBLE
261 # if _GL_HAS_ATTRIBUTE (externally_visible)
262 # define _GL_ATTRIBUTE_EXTERNALLY_VISIBLE __attribute__ ((externally_visible))
264 # define _GL_ATTRIBUTE_EXTERNALLY_VISIBLE
268 /* _GL_ATTRIBUTE_FALLTHROUGH declares that it is not a programming mistake if
269 the control flow falls through to the immediately following 'case' or
270 'default' label. The compiler should not warn in this case. */
271 /* Applies to: Empty statement (;), inside a 'switch' statement. */
272 /* Always expands to something. */
273 #ifndef _GL_ATTRIBUTE_FALLTHROUGH
274 # ifdef __has_c_attribute
275 # if __has_c_attribute (__fallthrough__)
276 # define _GL_ATTRIBUTE_FALLTHROUGH [[__fallthrough__]]
279 # if !defined _GL_ATTRIBUTE_FALLTHROUGH && _GL_HAS_ATTRIBUTE (fallthrough)
280 # define _GL_ATTRIBUTE_FALLTHROUGH __attribute__ ((__fallthrough__))
282 # ifndef _GL_ATTRIBUTE_FALLTHROUGH
283 # define _GL_ATTRIBUTE_FALLTHROUGH ((void) 0)
287 /* _GL_ATTRIBUTE_FORMAT ((ARCHETYPE, STRING-INDEX, FIRST-TO-CHECK))
288 declares that the STRING-INDEXth function argument is a format string of
289 style ARCHETYPE, which is one of:
292 strftime, gnu_strftime,
294 or the same thing prefixed and suffixed with '__'.
295 If FIRST-TO-CHECK is not 0, arguments starting at FIRST-TO_CHECK
296 are suitable for the format string. */
297 /* Applies to: functions. */
298 #ifndef _GL_ATTRIBUTE_FORMAT
299 # if _GL_HAS_ATTRIBUTE (format)
300 # define _GL_ATTRIBUTE_FORMAT(spec) __attribute__ ((__format__ spec))
302 # define _GL_ATTRIBUTE_FORMAT(spec)
306 /* _GL_ATTRIBUTE_LEAF declares that if the function is called from some other
307 compilation unit, it executes code from that unit only by return or by
308 exception handling. This declaration lets the compiler optimize that unit
309 more aggressively. */
310 /* Applies to: functions. */
311 #ifndef _GL_ATTRIBUTE_LEAF
312 # if _GL_HAS_ATTRIBUTE (leaf)
313 # define _GL_ATTRIBUTE_LEAF __attribute__ ((__leaf__))
315 # define _GL_ATTRIBUTE_LEAF
319 /* _GL_ATTRIBUTE_MALLOC declares that the function returns a pointer to freshly
321 /* Applies to: functions. */
322 #ifndef _GL_ATTRIBUTE_MALLOC
323 # if _GL_HAS_ATTRIBUTE (malloc)
324 # define _GL_ATTRIBUTE_MALLOC __attribute__ ((__malloc__))
326 # define _GL_ATTRIBUTE_MALLOC
330 /* _GL_ATTRIBUTE_MAY_ALIAS declares that pointers to the type may point to the
331 same storage as pointers to other types. Thus this declaration disables
332 strict aliasing optimization. */
333 /* Applies to: types. */
334 /* Oracle Studio 12.6 mishandles may_alias despite __has_attribute OK. */
335 #ifndef _GL_ATTRIBUTE_MAY_ALIAS
336 # if _GL_HAS_ATTRIBUTE (may_alias) && !defined __SUNPRO_C
337 # define _GL_ATTRIBUTE_MAY_ALIAS __attribute__ ((__may_alias__))
339 # define _GL_ATTRIBUTE_MAY_ALIAS
343 /* _GL_ATTRIBUTE_MAYBE_UNUSED declares that it is not a programming mistake if
344 the entity is not used. The compiler should not warn if the entity is not
347 - function, variable,
348 - struct, union, struct/union member,
349 - enumeration, enumeration item,
351 in C++ also: class. */
352 /* In C++ and C23, this is spelled [[__maybe_unused__]].
353 GCC's syntax is __attribute__ ((__unused__)).
354 clang supports both syntaxes. */
355 #ifndef _GL_ATTRIBUTE_MAYBE_UNUSED
356 # ifdef __has_c_attribute
357 # if __has_c_attribute (__maybe_unused__)
358 # define _GL_ATTRIBUTE_MAYBE_UNUSED [[__maybe_unused__]]
361 # ifndef _GL_ATTRIBUTE_MAYBE_UNUSED
362 # define _GL_ATTRIBUTE_MAYBE_UNUSED _GL_ATTRIBUTE_UNUSED
365 /* Alternative spelling of this macro, for convenience and for
366 compatibility with glibc/include/libc-symbols.h. */
367 #define _GL_UNUSED _GL_ATTRIBUTE_MAYBE_UNUSED
368 /* Earlier spellings of this macro. */
369 #define _UNUSED_PARAMETER_ _GL_ATTRIBUTE_MAYBE_UNUSED
371 /* _GL_ATTRIBUTE_NODISCARD declares that the caller of the function should not
372 discard the return value. The compiler may warn if the caller does not use
373 the return value, unless the caller uses something like ignore_value. */
374 /* Applies to: function, enumeration, class. */
375 #ifndef _GL_ATTRIBUTE_NODISCARD
376 # ifdef __has_c_attribute
377 # if __has_c_attribute (__nodiscard__)
378 # define _GL_ATTRIBUTE_NODISCARD [[__nodiscard__]]
381 # if !defined _GL_ATTRIBUTE_NODISCARD && _GL_HAS_ATTRIBUTE (warn_unused_result)
382 # define _GL_ATTRIBUTE_NODISCARD __attribute__ ((__warn_unused_result__))
384 # ifndef _GL_ATTRIBUTE_NODISCARD
385 # define _GL_ATTRIBUTE_NODISCARD
389 /* _GL_ATTRIBUTE_NOINLINE tells that the compiler should not inline the
391 /* Applies to: functions. */
392 #ifndef _GL_ATTRIBUTE_NOINLINE
393 # if _GL_HAS_ATTRIBUTE (noinline)
394 # define _GL_ATTRIBUTE_NOINLINE __attribute__ ((__noinline__))
396 # define _GL_ATTRIBUTE_NOINLINE
400 /* _GL_ATTRIBUTE_NONNULL ((N1, N2,...)) declares that the arguments N1, N2,...
402 _GL_ATTRIBUTE_NONNULL () declares that all pointer arguments must not be
404 /* Applies to: functions. */
405 #ifndef _GL_ATTRIBUTE_NONNULL
406 # if _GL_HAS_ATTRIBUTE (nonnull)
407 # define _GL_ATTRIBUTE_NONNULL(args) __attribute__ ((__nonnull__ args))
409 # define _GL_ATTRIBUTE_NONNULL(args)
413 /* _GL_ATTRIBUTE_NONSTRING declares that the contents of a character array is
414 not meant to be NUL-terminated. */
415 /* Applies to: struct/union members and variables that are arrays of element
416 type '[[un]signed] char'. */
417 #ifndef _GL_ATTRIBUTE_NONSTRING
418 # if _GL_HAS_ATTRIBUTE (nonstring)
419 # define _GL_ATTRIBUTE_NONSTRING __attribute__ ((__nonstring__))
421 # define _GL_ATTRIBUTE_NONSTRING
425 /* There is no _GL_ATTRIBUTE_NORETURN; use _Noreturn instead. */
427 /* _GL_ATTRIBUTE_NOTHROW declares that the function does not throw exceptions.
429 /* Applies to: functions. */
430 #ifndef _GL_ATTRIBUTE_NOTHROW
431 # if _GL_HAS_ATTRIBUTE (nothrow) && !defined __cplusplus
432 # define _GL_ATTRIBUTE_NOTHROW __attribute__ ((__nothrow__))
434 # define _GL_ATTRIBUTE_NOTHROW
438 /* _GL_ATTRIBUTE_PACKED declares:
439 For struct members: The member has the smallest possible alignment.
440 For struct, union, class: All members have the smallest possible alignment,
441 minimizing the memory required. */
442 /* Applies to: struct members, struct, union,
443 in C++ also: class. */
444 #ifndef _GL_ATTRIBUTE_PACKED
445 # if _GL_HAS_ATTRIBUTE (packed)
446 # define _GL_ATTRIBUTE_PACKED __attribute__ ((__packed__))
448 # define _GL_ATTRIBUTE_PACKED
452 /* _GL_ATTRIBUTE_PURE declares that It is OK for a compiler to omit duplicate
453 calls to the function with the same arguments if observable state is not
454 changed between calls.
455 This attribute is safe for a function that does not affect
456 observable state, and always returns exactly once.
457 (This attribute is looser than _GL_ATTRIBUTE_CONST.) */
458 /* Applies to: functions. */
459 #ifndef _GL_ATTRIBUTE_PURE
460 # if _GL_HAS_ATTRIBUTE (pure)
461 # define _GL_ATTRIBUTE_PURE __attribute__ ((__pure__))
463 # define _GL_ATTRIBUTE_PURE
467 /* _GL_ATTRIBUTE_RETURNS_NONNULL declares that the function's return value is
468 a non-NULL pointer. */
469 /* Applies to: functions. */
470 #ifndef _GL_ATTRIBUTE_RETURNS_NONNULL
471 # if _GL_HAS_ATTRIBUTE (returns_nonnull)
472 # define _GL_ATTRIBUTE_RETURNS_NONNULL __attribute__ ((__returns_nonnull__))
474 # define _GL_ATTRIBUTE_RETURNS_NONNULL
478 /* _GL_ATTRIBUTE_SENTINEL(pos) declares that the variadic function expects a
479 trailing NULL argument.
480 _GL_ATTRIBUTE_SENTINEL () - The last argument is NULL (requires C99).
481 _GL_ATTRIBUTE_SENTINEL ((N)) - The (N+1)st argument from the end is NULL. */
482 /* Applies to: functions. */
483 #ifndef _GL_ATTRIBUTE_SENTINEL
484 # if _GL_HAS_ATTRIBUTE (sentinel)
485 # define _GL_ATTRIBUTE_SENTINEL(pos) __attribute__ ((__sentinel__ pos))
487 # define _GL_ATTRIBUTE_SENTINEL(pos)
491 /* A helper macro. Don't use it directly. */
492 #ifndef _GL_ATTRIBUTE_UNUSED
493 # if _GL_HAS_ATTRIBUTE (unused)
494 # define _GL_ATTRIBUTE_UNUSED __attribute__ ((__unused__))
496 # define _GL_ATTRIBUTE_UNUSED
500 ]dnl There is no _GL_ATTRIBUTE_VISIBILITY; see m4/visibility.m4 instead.
502 /* _GL_UNUSED_LABEL; declares that it is not a programming mistake if the
503 immediately preceding label is not used. The compiler should not warn
504 if the label is not used. */
505 /* Applies to: label (both in C and C++). */
506 /* Note that g++ < 4.5 does not support the '__attribute__ ((__unused__)) ;'
507 syntax. But clang does. */
508 #ifndef _GL_UNUSED_LABEL
509 # if !(defined __cplusplus && !_GL_GNUC_PREREQ (4, 5)) || defined __clang__
510 # define _GL_UNUSED_LABEL _GL_ATTRIBUTE_UNUSED
512 # define _GL_UNUSED_LABEL
516 AH_VERBATIM([async_safe],
517 [/* The _GL_ASYNC_SAFE marker should be attached to functions that are
518 signal handlers (for signals other than SIGABRT, SIGPIPE) or can be
519 invoked from such signal handlers. Such functions have some restrictions:
520 * All functions that it calls should be marked _GL_ASYNC_SAFE as well,
521 or should be listed as async-signal-safe in POSIX
522 <https://pubs.opengroup.org/onlinepubs/9699919799/functions/V2_chap02.html#tag_15_04>
523 section 2.4.3. Note that malloc(), sprintf(), and fwrite(), in
524 particular, are NOT async-signal-safe.
525 * All memory locations (variables and struct fields) that these functions
526 access must be marked 'volatile'. This holds for both read and write
527 accesses. Otherwise the compiler might optimize away stores to and
528 reads from such locations that occur in the program, depending on its
529 data flow analysis. For example, when the program contains a loop
530 that is intended to inspect a variable set from within a signal handler
531 while (!signal_occurred)
533 the compiler is allowed to transform this into an endless loop if the
534 variable 'signal_occurred' is not declared 'volatile'.
535 Additionally, recall that:
536 * A signal handler should not modify errno (except if it is a handler
537 for a fatal signal and ends by raising the same signal again, thus
538 provoking the termination of the process). If it invokes a function
539 that may clobber errno, it needs to save and restore the value of
541 #define _GL_ASYNC_SAFE
543 AH_VERBATIM([micro_optimizations],
544 [/* _GL_CMP (n1, n2) performs a three-valued comparison on n1 vs. n2, where
545 n1 and n2 are expressions without side effects, that evaluate to real
546 numbers (excluding NaN).
551 The naïve code (n1 > n2 ? 1 : n1 < n2 ? -1 : 0) produces a conditional
552 jump with nearly all GCC versions up to GCC 10.
553 This variant (n1 < n2 ? -1 : n1 > n2) produces a conditional with many
554 GCC versions up to GCC 9.
555 The better code (n1 > n2) - (n1 < n2) from Hacker's Delight § 2-9
556 avoids conditional jumps in all GCC versions >= 3.4. */
557 #define _GL_CMP(n1, n2) (((n1) > (n2)) - ((n1) < (n2)))
559 dnl Hint which direction to take regarding cross-compilation guesses:
560 dnl When a user installs a program on a platform they are not intimately
561 dnl familiar with, --enable-cross-guesses=conservative is the appropriate
562 dnl choice. It implements the "If we don't know, assume the worst" principle.
563 dnl However, when an operating system developer (on a platform which is not
564 dnl yet known to gnulib) builds packages for their platform, they want to
565 dnl expose, not hide, possible platform bugs; in this case,
566 dnl --enable-cross-guesses=risky is the appropriate choice.
567 dnl Sets the variables
568 dnl gl_cross_guess_normal (to be used when 'yes' is good and 'no' is bad),
569 dnl gl_cross_guess_inverted (to be used when 'no' is good and 'yes' is bad).
570 AC_ARG_ENABLE([cross-guesses],
571 [AS_HELP_STRING([--enable-cross-guesses={conservative|risky}],
572 [specify policy for cross-compilation guesses])],
573 [if test "x$enableval" != xconservative && test "x$enableval" != xrisky; then
574 AC_MSG_WARN([invalid argument supplied to --enable-cross-guesses])
575 enableval=conservative
577 gl_cross_guesses="$enableval"],
578 [gl_cross_guesses=conservative])
579 if test $gl_cross_guesses = risky; then
580 gl_cross_guess_normal="guessing yes"
581 gl_cross_guess_inverted="guessing no"
583 gl_cross_guess_normal="guessing no"
584 gl_cross_guess_inverted="guessing yes"
586 dnl Preparation for running test programs:
587 dnl Tell glibc to write diagnostics from -D_FORTIFY_SOURCE=2 to stderr, not
588 dnl to /dev/tty, so they can be redirected to log files. Such diagnostics
589 dnl arise e.g., in the macros gl_PRINTF_DIRECTIVE_N, gl_SNPRINTF_DIRECTIVE_N.
591 export LIBC_FATAL_STDERR_
594 # gl_MODULE_INDICATOR_INIT_VARIABLE([variablename])
595 # gl_MODULE_INDICATOR_INIT_VARIABLE([variablename], [initialvalue])
596 # initializes the shell variable that indicates the presence of the given module
597 # as a C preprocessor expression.
598 AC_DEFUN([gl_MODULE_INDICATOR_INIT_VARIABLE],
600 GL_MODULE_INDICATOR_PREFIX[]_[$1]=m4_if([$2], , [0], [$2])
601 AC_SUBST(GL_MODULE_INDICATOR_PREFIX[]_[$1])
604 # gl_MODULE_INDICATOR_CONDITION
605 # expands to a C preprocessor expression that evaluates to 1 or 0, depending
606 # whether a gnulib module that has been requested shall be considered present
608 m4_define([gl_MODULE_INDICATOR_CONDITION], [1])
610 # gl_MODULE_INDICATOR_SET_VARIABLE([modulename])
611 # sets the shell variable that indicates the presence of the given module to
612 # a C preprocessor expression that will evaluate to 1.
613 AC_DEFUN([gl_MODULE_INDICATOR_SET_VARIABLE],
615 gl_MODULE_INDICATOR_SET_VARIABLE_AUX(
616 [GL_MODULE_INDICATOR_PREFIX[]_GNULIB_[]m4_translit([[$1]],
617 [abcdefghijklmnopqrstuvwxyz./-],
618 [ABCDEFGHIJKLMNOPQRSTUVWXYZ___])],
619 [gl_MODULE_INDICATOR_CONDITION])
622 # gl_MODULE_INDICATOR_SET_VARIABLE_AUX([variable])
623 # modifies the shell variable to include the gl_MODULE_INDICATOR_CONDITION.
624 # The shell variable's value is a C preprocessor expression that evaluates
626 AC_DEFUN([gl_MODULE_INDICATOR_SET_VARIABLE_AUX],
628 m4_if(m4_defn([gl_MODULE_INDICATOR_CONDITION]), [1],
630 dnl Simplify the expression VALUE || 1 to 1.
633 [gl_MODULE_INDICATOR_SET_VARIABLE_AUX_OR([$1],
634 [gl_MODULE_INDICATOR_CONDITION])])
637 # gl_MODULE_INDICATOR_SET_VARIABLE_AUX_OR([variable], [condition])
638 # modifies the shell variable to include the given condition. The shell
639 # variable's value is a C preprocessor expression that evaluates to 0 or 1.
640 AC_DEFUN([gl_MODULE_INDICATOR_SET_VARIABLE_AUX_OR],
642 dnl Simplify the expression 1 || CONDITION to 1.
643 if test "$[]$1" != 1; then
644 dnl Simplify the expression 0 || CONDITION to CONDITION.
645 if test "$[]$1" = 0; then
653 # gl_MODULE_INDICATOR([modulename])
654 # defines a C macro indicating the presence of the given module
655 # in a location where it can be used.
657 # | in lib/ | in tests/ |
658 # --------------------------------------------+---------+-----------+
659 # Module present among main modules: | 1 | 1 |
660 # --------------------------------------------+---------+-----------+
661 # Module present among tests-related modules: | 0 | 1 |
662 # --------------------------------------------+---------+-----------+
663 # Module not present at all: | 0 | 0 |
664 # --------------------------------------------+---------+-----------+
665 AC_DEFUN([gl_MODULE_INDICATOR],
667 AC_DEFINE_UNQUOTED([GNULIB_]m4_translit([[$1]],
668 [abcdefghijklmnopqrstuvwxyz./-],
669 [ABCDEFGHIJKLMNOPQRSTUVWXYZ___]),
670 [gl_MODULE_INDICATOR_CONDITION],
671 [Define to a C preprocessor expression that evaluates to 1 or 0,
672 depending whether the gnulib module $1 shall be considered present.])
675 # gl_MODULE_INDICATOR_FOR_TESTS([modulename])
676 # defines a C macro indicating the presence of the given module
677 # in lib or tests. This is useful to determine whether the module
680 # | in lib/ | in tests/ |
681 # --------------------------------------------+---------+-----------+
682 # Module present among main modules: | 1 | 1 |
683 # --------------------------------------------+---------+-----------+
684 # Module present among tests-related modules: | 1 | 1 |
685 # --------------------------------------------+---------+-----------+
686 # Module not present at all: | 0 | 0 |
687 # --------------------------------------------+---------+-----------+
688 AC_DEFUN([gl_MODULE_INDICATOR_FOR_TESTS],
690 AC_DEFINE([GNULIB_TEST_]m4_translit([[$1]],
691 [abcdefghijklmnopqrstuvwxyz./-],
692 [ABCDEFGHIJKLMNOPQRSTUVWXYZ___]), [1],
693 [Define to 1 when the gnulib module $1 should be tested.])
696 # gl_ASSERT_NO_GNULIB_POSIXCHECK
697 # asserts that there will never be a need to #define GNULIB_POSIXCHECK.
698 # and thereby enables an optimization of configure and config.h.
700 AC_DEFUN([gl_ASSERT_NO_GNULIB_POSIXCHECK],
702 dnl Override gl_WARN_ON_USE_PREPARE.
703 dnl But hide this definition from 'aclocal'.
704 AC_DEFUN([gl_W][ARN_ON_USE_PREPARE], [])
707 # gl_ASSERT_NO_GNULIB_TESTS
708 # asserts that there will be no gnulib tests in the scope of the configure.ac
709 # and thereby enables an optimization of config.h.
711 AC_DEFUN([gl_ASSERT_NO_GNULIB_TESTS],
713 dnl Override gl_MODULE_INDICATOR_FOR_TESTS.
714 AC_DEFUN([gl_MODULE_INDICATOR_FOR_TESTS], [])
717 # Test whether <features.h> exists.
718 # Set HAVE_FEATURES_H.
719 AC_DEFUN([gl_FEATURES_H],
721 AC_CHECK_HEADERS_ONCE([features.h])
722 if test $ac_cv_header_features_h = yes; then
727 AC_SUBST([HAVE_FEATURES_H])
731 # Modifies the value of the shell variable CC in an attempt to make $CC
732 # understand ISO C99 source code.
733 AC_DEFUN([gl_PROG_CC_C99],
735 dnl Just use AC_PROG_CC_C99.
736 dnl When AC_PROG_CC_C99 and AC_PROG_CC_STDC are used together, the substituted
737 dnl value of CC will contain the C99 enabling options twice. But this is only
738 dnl a cosmetic problem.
739 dnl With Autoconf >= 2.70, use AC_PROG_CC since it implies AC_PROG_CC_C99;
740 dnl this avoids a "warning: The macro `AC_PROG_CC_C99' is obsolete."
741 m4_version_prereq([2.70],
742 [AC_REQUIRE([AC_PROG_CC])],
743 [AC_REQUIRE([AC_PROG_CC_C99])])
747 # Determines the values for AR, ARFLAGS, RANLIB that fit with the compiler.
748 # The user can set the variables AR, ARFLAGS, RANLIB if he wants to override
750 AC_DEFUN([gl_PROG_AR_RANLIB],
752 dnl Minix 3 comes with two toolchains: The Amsterdam Compiler Kit compiler
753 dnl as "cc", and GCC as "gcc". They have different object file formats and
754 dnl library formats. In particular, the GNU binutils programs ar and ranlib
755 dnl produce libraries that work only with gcc, not with cc.
756 AC_REQUIRE([AC_PROG_CC])
757 dnl The '][' hides this use from 'aclocal'.
758 AC_BEFORE([$0], [A][M_PROG_AR])
759 AC_CACHE_CHECK([for Minix Amsterdam compiler], [gl_cv_c_amsterdam_compiler],
761 AC_EGREP_CPP([Amsterdam],
767 [gl_cv_c_amsterdam_compiler=yes],
768 [gl_cv_c_amsterdam_compiler=no])
771 dnl Don't compete with AM_PROG_AR's decision about AR/ARFLAGS if we are not
772 dnl building with __ACK__.
773 if test $gl_cv_c_amsterdam_compiler = yes; then
774 if test -z "$AR"; then
777 if test -z "$ARFLAGS"; then
781 dnl AM_PROG_AR was added in automake v1.11.2. AM_PROG_AR does not AC_SUBST
782 dnl ARFLAGS variable (it is filed into Makefile.in directly by automake
783 dnl script on-demand, if not specified by ./configure of course).
784 dnl Don't AC_REQUIRE the AM_PROG_AR otherwise the code for __ACK__ above
785 dnl will be ignored. Also, pay attention to call AM_PROG_AR in else block
786 dnl because AM_PROG_AR is written so it could re-set AR variable even for
787 dnl __ACK__. It may seem like its easier to avoid calling the macro here,
788 dnl but we need to AC_SUBST both AR/ARFLAGS (thus those must have some good
789 dnl default value and automake should usually know them).
791 dnl The '][' hides this use from 'aclocal'.
792 m4_ifdef([A][M_PROG_AR], [A][M_PROG_AR], [:])
795 dnl In case the code above has not helped with setting AR/ARFLAGS, use
796 dnl Automake-documented default values for AR and ARFLAGS, but prefer
797 dnl ${host}-ar over ar (useful for cross-compiling).
798 AC_CHECK_TOOL([AR], [ar], [ar])
799 if test -z "$ARFLAGS"; then
805 if test -z "$RANLIB"; then
806 if test $gl_cv_c_amsterdam_compiler = yes; then
809 dnl Use the ranlib program if it is available.
817 # This definition is copied from post-2.70 Autoconf and overrides the
818 # AC_C_RESTRICT macro from autoconf 2.60..2.70.
819 m4_version_prereq([2.70.1], [], [
820 AC_DEFUN([AC_C_RESTRICT],
821 [AC_CACHE_CHECK([for C/C++ restrict keyword], [ac_cv_c_restrict],
823 # Put '__restrict__' first, to avoid problems with glibc and non-GCC; see:
824 # https://lists.gnu.org/archive/html/bug-autoconf/2016-02/msg00006.html
825 # Put 'restrict' last, because C++ lacks it.
826 for ac_kw in __restrict__ __restrict _Restrict restrict; do
829 [[typedef int *int_ptr;
830 int foo (int_ptr $ac_kw ip) { return ip[0]; }
831 int bar (int [$ac_kw]); /* Catch GCC bug 14050. */
832 int bar (int ip[$ac_kw]) { return ip[0]; }
837 return foo (t) + bar (t);
839 [ac_cv_c_restrict=$ac_kw])
840 test "$ac_cv_c_restrict" != no && break
843 AH_VERBATIM([restrict],
844 [/* Define to the equivalent of the C99 'restrict' keyword, or to
845 nothing if this is not supported. Do not define if restrict is
846 supported only directly. */
848 /* Work around a bug in older versions of Sun C++, which did not
849 #define __restrict__ or support _Restrict or __restrict__
850 even though the corresponding Sun C compiler ended up with
851 "#define restrict _Restrict" or "#define restrict __restrict__"
852 in the previous line. This workaround can be removed once
853 we assume Oracle Developer Studio 12.5 (2016) or later. */
854 #if defined __SUNPRO_CC && !defined __RESTRICT && !defined __restrict__
856 # define __restrict__
858 case $ac_cv_c_restrict in
860 no) AC_DEFINE([restrict], []) ;;
861 *) AC_DEFINE_UNQUOTED([restrict], [$ac_cv_c_restrict]) ;;
867 # is like AC_C_BIGENDIAN, except that it can be AC_REQUIREd.
868 # Note that AC_REQUIRE([AC_C_BIGENDIAN]) does not work reliably because some
869 # macros invoke AC_C_BIGENDIAN with arguments.
870 AC_DEFUN([gl_BIGENDIAN],
875 # A temporary file descriptor.
876 # Must be less than 10, because dash 0.5.8 does not support redirections
877 # with multi-digit file descriptors.
878 m4_define([GL_TMP_FD], 9)
881 # executes command, but without the normal configure output.
882 # This is useful when you want to invoke AC_CACHE_CHECK (or AC_CHECK_FUNC etc.)
883 # inside another AC_CACHE_CHECK.
884 AC_DEFUN([gl_SILENT],
886 exec GL_TMP_FD>&AS_MESSAGE_FD AS_MESSAGE_FD>/dev/null
888 exec AS_MESSAGE_FD>&GL_TMP_FD GL_TMP_FD>&-
891 # gl_CACHE_VAL_SILENT(cache-id, command-to-set-it)
892 # is like AC_CACHE_VAL(cache-id, command-to-set-it), except that it does not
893 # output a spurious "(cached)" mark in the midst of other configure output.
894 # This macro should be used instead of AC_CACHE_VAL when it is not surrounded
895 # by an AC_MSG_CHECKING/AC_MSG_RESULT pair.
896 AC_DEFUN([gl_CACHE_VAL_SILENT],
899 AC_CACHE_VAL([$1], [$2])
903 # gl_CONDITIONAL(conditional, condition)
904 # is like AM_CONDITIONAL(conditional, condition), except that it does not
906 # configure: error: conditional "..." was never defined.
907 # Usually this means the macro was only invoked conditionally.
908 # when only invoked conditionally. Instead, in that case, both the _TRUE
909 # and the _FALSE case are disabled.
910 AC_DEFUN([gl_CONDITIONAL],
912 pushdef([AC_CONFIG_COMMANDS_PRE], [:])dnl
913 AM_CONDITIONAL([$1], [$2])
914 popdef([AC_CONFIG_COMMANDS_PRE])dnl
915 if test -z "${[$1]_TRUE}" && test -z "${[$1]_FALSE}"; then
921 # gl_CC_ALLOW_WARNINGS
922 # sets and substitutes a variable GL_CFLAG_ALLOW_WARNINGS, to a $(CC) option
923 # that reverts a preceding '-Werror' option, if available.
924 # This is expected to be '-Wno-error' on gcc, clang (except clang/MSVC), xlclang
925 # and empty otherwise.
926 AC_DEFUN([gl_CC_ALLOW_WARNINGS],
928 AC_REQUIRE([AC_PROG_CC])
929 AC_CACHE_CHECK([for C compiler option to allow warnings],
932 echo 'int dummy;' > conftest.c
933 AC_TRY_COMMAND([${CC-cc} $CFLAGS $CPPFLAGS -c conftest.c 2>conftest1.err]) >/dev/null
934 AC_TRY_COMMAND([${CC-cc} $CFLAGS $CPPFLAGS -Wno-error -c conftest.c 2>conftest2.err]) >/dev/null
935 dnl Test the number of error output lines, because AIX xlc accepts the
936 dnl option '-Wno-error', just to produce a warning
937 dnl "Option -Wno-error was incorrectly specified. The option will be ignored."
939 if test $? = 0 && test `wc -l < conftest1.err` = `wc -l < conftest2.err`; then
940 gl_cv_cc_wallow='-Wno-error'
946 case "$gl_cv_cc_wallow" in
947 none) GL_CFLAG_ALLOW_WARNINGS='' ;;
948 *) GL_CFLAG_ALLOW_WARNINGS="$gl_cv_cc_wallow" ;;
950 AC_SUBST([GL_CFLAG_ALLOW_WARNINGS])
953 # gl_CXX_ALLOW_WARNINGS
954 # sets and substitutes a variable GL_CXXFLAG_ALLOW_WARNINGS, to a $(CC) option
955 # that reverts a preceding '-Werror' option, if available.
956 AC_DEFUN([gl_CXX_ALLOW_WARNINGS],
958 dnl Requires AC_PROG_CXX or gl_PROG_ANSI_CXX.
959 if test -n "$CXX" && test "$CXX" != no; then
960 AC_CACHE_CHECK([for C++ compiler option to allow warnings],
963 echo 'int dummy;' > conftest.cc
964 AC_TRY_COMMAND([${CXX-c++} $CXXFLAGS $CPPFLAGS -c conftest.cc 2>conftest1.err]) >/dev/null
965 AC_TRY_COMMAND([${CXX-c++} $CXXFLAGS $CPPFLAGS -Wno-error -c conftest.cc 2>conftest2.err]) >/dev/null
966 dnl Test the number of error output lines, because AIX xlC accepts the
967 dnl option '-Wno-error', just to produce a warning
968 dnl "Option -Wno-error was incorrectly specified. The option will be ignored."
970 if test $? = 0 && test `wc -l < conftest1.err` = `wc -l < conftest2.err`; then
971 gl_cv_cxx_wallow='-Wno-error'
973 gl_cv_cxx_wallow=none
977 case "$gl_cv_cxx_wallow" in
978 none) GL_CXXFLAG_ALLOW_WARNINGS='' ;;
979 *) GL_CXXFLAG_ALLOW_WARNINGS="$gl_cv_cxx_wallow" ;;
982 GL_CXXFLAG_ALLOW_WARNINGS=''
984 AC_SUBST([GL_CXXFLAG_ALLOW_WARNINGS])
987 # gl_CC_GNULIB_WARNINGS
988 # sets and substitutes a variable GL_CFLAG_GNULIB_WARNINGS, to a $(CC) option
989 # set that enables or disables warnings as suitable for the Gnulib coding style.
990 AC_DEFUN([gl_CC_GNULIB_WARNINGS],
992 AC_REQUIRE([gl_CC_ALLOW_WARNINGS])
993 dnl Assume that the compiler supports -Wno-* options only if it also supports
995 GL_CFLAG_GNULIB_WARNINGS=''
996 if test -n "$GL_CFLAG_ALLOW_WARNINGS"; then
997 dnl Enable these warning options:
1000 dnl -Wno-cast-qual >= 3 >= 3.9
1001 dnl -Wno-conversion >= 3 >= 3.9
1002 dnl -Wno-float-conversion >= 4.9 >= 3.9
1003 dnl -Wno-float-equal >= 3 >= 3.9
1004 dnl -Wimplicit-fallthrough >= 7 >= 3.9
1005 dnl -Wno-pedantic >= 4.8 >= 3.9
1006 dnl -Wno-sign-compare >= 3 >= 3.9
1007 dnl -Wno-sign-conversion >= 4.3 >= 3.9
1008 dnl -Wno-type-limits >= 4.3 >= 3.9
1009 dnl -Wno-undef >= 3 >= 3.9
1010 dnl -Wno-unsuffixed-float-constants >= 4.5
1011 dnl -Wno-unused-function >= 3 >= 3.9
1012 dnl -Wno-unused-parameter >= 3 >= 3.9
1014 cat > conftest.c <<\EOF
1015 #if __GNUC__ >= 3 || (__clang_major__ + (__clang_minor__ >= 9) > 3)
1021 -Wno-unused-function
1022 -Wno-unused-parameter
1024 #if __GNUC__ + (__GNUC_MINOR__ >= 9) > 4 || (__clang_major__ + (__clang_minor__ >= 9) > 3)
1025 -Wno-float-conversion
1027 #if __GNUC__ >= 7 || (__clang_major__ + (__clang_minor__ >= 9) > 3)
1028 -Wimplicit-fallthrough
1030 #if __GNUC__ + (__GNUC_MINOR__ >= 8) > 4 || (__clang_major__ + (__clang_minor__ >= 9) > 3)
1033 #if __GNUC__ + (__GNUC_MINOR__ >= 3) > 4 || (__clang_major__ + (__clang_minor__ >= 9) > 3)
1034 -Wno-sign-conversion
1037 #if __GNUC__ + (__GNUC_MINOR__ >= 5) > 4
1038 -Wno-unsuffixed-float-constants
1041 gl_command="$CC $CFLAGS $CPPFLAGS -E conftest.c > conftest.out"
1042 if AC_TRY_EVAL([gl_command]); then
1043 gl_options=`grep -v '#' conftest.out`
1044 for word in $gl_options; do
1045 GL_CFLAG_GNULIB_WARNINGS="$GL_CFLAG_GNULIB_WARNINGS $word"
1048 rm -f conftest.c conftest.out
1050 AC_SUBST([GL_CFLAG_GNULIB_WARNINGS])
1053 dnl gl_CONDITIONAL_HEADER([foo.h])
1054 dnl takes a shell variable GL_GENERATE_FOO_H (with value true or false) as input
1056 dnl - an AC_SUBSTed variable FOO_H that is either a file name or empty, based
1057 dnl on whether GL_GENERATE_FOO_H is true or false,
1058 dnl - an Automake conditional GL_GENERATE_FOO_H that evaluates to the value of
1059 dnl the shell variable GL_GENERATE_FOO_H.
1060 AC_DEFUN([gl_CONDITIONAL_HEADER],
1062 m4_pushdef([gl_header_name], AS_TR_SH(m4_toupper($1)))
1063 m4_pushdef([gl_generate_var], [GL_GENERATE_]AS_TR_SH(m4_toupper($1)))
1064 m4_pushdef([gl_generate_cond], [GL_GENERATE_]AS_TR_SH(m4_toupper($1)))
1065 case "$gl_generate_var" in
1066 false) gl_header_name='' ;;
1068 dnl It is OK to use a .h file in lib/ from within tests/, but not vice
1070 if test -z "$gl_header_name"; then
1071 gl_header_name="${gl_source_base_prefix}$1"
1074 *) echo "*** gl_generate_var is not set correctly" 1>&2; exit 1 ;;
1076 AC_SUBST(gl_header_name)
1077 gl_CONDITIONAL(gl_generate_cond, [$gl_generate_var])
1078 m4_popdef([gl_generate_cond])
1079 m4_popdef([gl_generate_var])
1080 m4_popdef([gl_header_name])
1083 dnl Expands to some code for use in .c programs that, on native Windows, defines
1084 dnl the Microsoft deprecated alias function names to the underscore-prefixed
1085 dnl actual function names. With this macro, these function names are available
1086 dnl without linking with '-loldnames' and without generating warnings.
1087 dnl Usage: Use it after all system header files are included.
1090 dnl ]GL_MDA_DEFINES[
1092 AC_DEFUN([GL_MDA_DEFINES],[
1093 AC_REQUIRE([_GL_MDA_DEFINES])
1096 AC_DEFUN([_GL_MDA_DEFINES],
1098 #if defined _WIN32 && !defined __CYGWIN__
1099 #define access _access
1100 #define chdir _chdir
1101 #define chmod _chmod
1102 #define close _close
1103 #define creat _creat
1107 #define execl _execl
1108 #define execle _execle
1109 #define execlp _execlp
1110 #define execv _execv
1111 #define execve _execve
1112 #define execvp _execvp
1113 #define execvpe _execvpe
1114 #define fcloseall _fcloseall
1116 #define fdopen _fdopen
1117 #define fileno _fileno
1119 #define getcwd _getcwd
1120 #define getpid _getpid
1122 #define isatty _isatty
1126 #define lfind _lfind
1127 #define lsearch _lsearch
1128 #define lseek _lseek
1129 #define memccpy _memccpy
1130 #define mkdir _mkdir
1131 #define mktemp _mktemp
1133 #define putenv _putenv
1136 #define rmdir _rmdir
1137 #define strdup _strdup
1139 #define tempnam _tempnam
1140 #define tzset _tzset
1141 #define umask _umask
1142 #define unlink _unlink
1143 #define utime _utime
1144 #define wcsdup _wcsdup
1145 #define write _write