diff options
author | Evgeny Grin (Karlson2k) <k2k@narod.ru> | 2023-04-09 21:16:12 +0300 |
---|---|---|
committer | Evgeny Grin (Karlson2k) <k2k@narod.ru> | 2023-04-10 20:11:33 +0300 |
commit | d2919a6e7a8874fda287cfc4009f9915e4a26be9 (patch) | |
tree | 457e10f50a6e343e48138c49f0abf9ea9891f442 /contrib | |
parent | 420468d30a417dfee0119bec55f3397e57c62181 (diff) | |
download | libmicrohttpd-d2919a6e7a8874fda287cfc4009f9915e4a26be9.tar.gz libmicrohttpd-d2919a6e7a8874fda287cfc4009f9915e4a26be9.zip |
Added autoconf patches and fixes
Diffstat (limited to 'contrib')
-rwxr-xr-x | contrib/fixes-autoconf/apply-all.sh | 53 | ||||
-rw-r--r-- | contrib/fixes-autoconf/c_backported.m4 | 565 |
2 files changed, 618 insertions, 0 deletions
diff --git a/contrib/fixes-autoconf/apply-all.sh b/contrib/fixes-autoconf/apply-all.sh new file mode 100755 index 00000000..1a9d725b --- /dev/null +++ b/contrib/fixes-autoconf/apply-all.sh | |||
@@ -0,0 +1,53 @@ | |||
1 | #!/bin/bash | ||
2 | |||
3 | # | ||
4 | # This file applies optional Autoconf patches for better MSys2 and new | ||
5 | # compiler compatibility. | ||
6 | # | ||
7 | # Based on Debian SID baseline files as of April 2023. | ||
8 | # | ||
9 | |||
10 | patchesdir=$(dirname $BASH_SOURCE) || exit 2 | ||
11 | test -n "$patchesdir" || exit 2 | ||
12 | cd "$patchesdir" || exit 2 | ||
13 | patchesdir=$(pwd) || exit 2 | ||
14 | |||
15 | patches=( | ||
16 | # No patches currently | ||
17 | ) | ||
18 | |||
19 | failed=( ) | ||
20 | |||
21 | cd "${patchesdir}/../.." || exit 1 | ||
22 | |||
23 | patch_params="-Nf -p1 --no-backup-if-mismatch -r - --read-only=fail" | ||
24 | |||
25 | for patch in ${patches[@]}; do | ||
26 | patchfile="${patchesdir}/${patch}" | ||
27 | echo "*** Applying $patch..." | ||
28 | if echo "$patch_data" | patch $patch_params -i "$patchfile" | ||
29 | then | ||
30 | echo "** $patch successfully applied." | ||
31 | else | ||
32 | echo "** $patch failed." | ||
33 | failed+=("$patch") | ||
34 | fi | ||
35 | unset patch_data | ||
36 | done | ||
37 | |||
38 | |||
39 | addl_file="c_backported.m4" | ||
40 | echo "*** Copying $addl_file" | ||
41 | cp -fT "${patchesdir}/$addl_file" "m4/$addl_file" || exit 2 | ||
42 | echo "$addl_file copied." | ||
43 | |||
44 | echo '' | ||
45 | |||
46 | if [[ -n "${failed[@]}" ]]; then | ||
47 | printf '* Failed patch: %s\n' "${failed[@]}" >&2 | ||
48 | exit 2 | ||
49 | else | ||
50 | echo "* All patches have been successfully applied." | ||
51 | fi | ||
52 | |||
53 | exit 0 | ||
diff --git a/contrib/fixes-autoconf/c_backported.m4 b/contrib/fixes-autoconf/c_backported.m4 new file mode 100644 index 00000000..c0e7aabc --- /dev/null +++ b/contrib/fixes-autoconf/c_backported.m4 | |||
@@ -0,0 +1,565 @@ | |||
1 | # Backported macros from autoconf git master + a few custom patches | ||
2 | |||
3 | # This file is part of Autoconf. -*- Autoconf -*- | ||
4 | # Programming languages support. | ||
5 | # Copyright (C) 2001-2017, 2020-2023 Free Software Foundation, Inc. | ||
6 | |||
7 | # This file is part of Autoconf. This program is free | ||
8 | # software; you can redistribute it and/or modify it under the | ||
9 | # terms of the GNU General Public License as published by the | ||
10 | # Free Software Foundation, either version 3 of the License, or | ||
11 | # (at your option) any later version. | ||
12 | # | ||
13 | # This program is distributed in the hope that it will be useful, | ||
14 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
15 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
16 | # GNU General Public License for more details. | ||
17 | # | ||
18 | # Under Section 7 of GPL version 3, you are granted additional | ||
19 | # permissions described in the Autoconf Configure Script Exception, | ||
20 | # version 3.0, as published by the Free Software Foundation. | ||
21 | # | ||
22 | # You should have received a copy of the GNU General Public License | ||
23 | # and a copy of the Autoconf Configure Script Exception along with | ||
24 | # this program; see the files COPYINGv3 and COPYING.EXCEPTION | ||
25 | # respectively. If not, see <https://www.gnu.org/licenses/>. | ||
26 | |||
27 | # Written by David MacKenzie, with help from | ||
28 | # Akim Demaille, Paul Eggert, | ||
29 | # François Pinard, Karl Berry, Richard Pixley, Ian Lance Taylor, | ||
30 | # Roland McGrath, Noah Friedman, david d zuhn, and many others. | ||
31 | |||
32 | # ---- Backported macros only ---- | ||
33 | |||
34 | AC_DEFUN([_AC_C_C89_TEST_GLOBALS], | ||
35 | [m4_divert_text([INIT_PREPARE], | ||
36 | [[# Test code for whether the C compiler supports C89 (global declarations) | ||
37 | ac_c_conftest_c89_globals=' | ||
38 | /* Does the compiler advertise C89 conformance? | ||
39 | Do not test the value of __STDC__, because some compilers set it to 0 | ||
40 | while being otherwise adequately conformant. */ | ||
41 | #if !defined __STDC__ | ||
42 | # error "Compiler does not advertise C89 conformance" | ||
43 | #endif | ||
44 | |||
45 | #include <stddef.h> | ||
46 | #include <stdarg.h> | ||
47 | struct stat; | ||
48 | /* Most of the following tests are stolen from RCS 5.7 src/conf.sh. */ | ||
49 | struct buf { int x; }; | ||
50 | struct buf * (*rcsopen) (struct buf *, struct stat *, int); | ||
51 | static char *e (char **p, int i) | ||
52 | { | ||
53 | return p[i]; | ||
54 | } | ||
55 | static char *f (char * (*g) (char **, int), char **p, ...) | ||
56 | { | ||
57 | char *s; | ||
58 | va_list v; | ||
59 | va_start (v,p); | ||
60 | s = g (p, va_arg (v,int)); | ||
61 | va_end (v); | ||
62 | return s; | ||
63 | } | ||
64 | |||
65 | /* C89 style stringification. */ | ||
66 | #define noexpand_stringify(a) #a | ||
67 | const char *stringified = noexpand_stringify(arbitrary+token=sequence); | ||
68 | |||
69 | /* C89 style token pasting. Exercises some of the corner cases that | ||
70 | e.g. old MSVC gets wrong, but not very hard. */ | ||
71 | #define noexpand_concat(a,b) a##b | ||
72 | #define expand_concat(a,b) noexpand_concat(a,b) | ||
73 | extern int vA; | ||
74 | extern int vbee; | ||
75 | #define aye A | ||
76 | #define bee B | ||
77 | int *pvA = &expand_concat(v,aye); | ||
78 | int *pvbee = &noexpand_concat(v,bee); | ||
79 | |||
80 | /* OSF 4.0 Compaq cc is some sort of almost-ANSI by default. It has | ||
81 | function prototypes and stuff, but not \xHH hex character constants. | ||
82 | These do not provoke an error unfortunately, instead are silently treated | ||
83 | as an "x". The following induces an error, until -std is added to get | ||
84 | proper ANSI mode. Curiously \x00 != x always comes out true, for an | ||
85 | array size at least. It is necessary to write \x00 == 0 to get something | ||
86 | that is true only with -std. */ | ||
87 | int osf4_cc_array ['\''\x00'\'' == 0 ? 1 : -1]; | ||
88 | |||
89 | /* IBM C 6 for AIX is almost-ANSI by default, but it replaces macro parameters | ||
90 | inside strings and character constants. */ | ||
91 | #define FOO(x) '\''x'\'' | ||
92 | int xlc6_cc_array[FOO(a) == '\''x'\'' ? 1 : -1]; | ||
93 | |||
94 | int test (int i, double x); | ||
95 | struct s1 {int (*f) (int a);}; | ||
96 | struct s2 {int (*f) (double a);}; | ||
97 | int pairnames (int, char **, int *(*)(struct buf *, struct stat *, int), | ||
98 | int, int);' | ||
99 | ]])]) | ||
100 | |||
101 | |||
102 | AC_DEFUN([_AC_C_C99_TEST_GLOBALS], | ||
103 | [m4_divert_text([INIT_PREPARE], | ||
104 | [[# Test code for whether the C compiler supports C99 (global declarations) | ||
105 | ac_c_conftest_c99_globals=' | ||
106 | // Does the compiler advertise C99 conformance? | ||
107 | #if !defined __STDC_VERSION__ || __STDC_VERSION__ < 199901L | ||
108 | # error "Compiler does not advertise C99 conformance" | ||
109 | #endif | ||
110 | |||
111 | #include <stdbool.h> | ||
112 | extern int puts (const char *); | ||
113 | extern int printf (const char *, ...); | ||
114 | extern int dprintf (int, const char *, ...); | ||
115 | extern void *malloc (size_t); | ||
116 | extern void free (void *); | ||
117 | |||
118 | // Check varargs macros. These examples are taken from C99 6.10.3.5. | ||
119 | // dprintf is used instead of fprintf to avoid needing to declare | ||
120 | // FILE and stderr. | ||
121 | #define debug(...) dprintf (2, __VA_ARGS__) | ||
122 | #define showlist(...) puts (#__VA_ARGS__) | ||
123 | #define report(test,...) ((test) ? puts (#test) : printf (__VA_ARGS__)) | ||
124 | static void | ||
125 | test_varargs_macros (void) | ||
126 | { | ||
127 | int x = 1234; | ||
128 | int y = 5678; | ||
129 | debug ("Flag"); | ||
130 | debug ("X = %d\n", x); | ||
131 | showlist (The first, second, and third items.); | ||
132 | report (x>y, "x is %d but y is %d", x, y); | ||
133 | } | ||
134 | |||
135 | // Check long long types. | ||
136 | #define BIG64 18446744073709551615ull | ||
137 | #define BIG32 4294967295ul | ||
138 | #define BIG_OK (BIG64 / BIG32 == 4294967297ull && BIG64 % BIG32 == 0) | ||
139 | #if !BIG_OK | ||
140 | #error "your preprocessor is broken" | ||
141 | #endif | ||
142 | #if BIG_OK | ||
143 | #else | ||
144 | #error "your preprocessor is broken" | ||
145 | #endif | ||
146 | static long long int bignum = -9223372036854775807LL; | ||
147 | static unsigned long long int ubignum = BIG64; | ||
148 | |||
149 | struct incomplete_array | ||
150 | { | ||
151 | int datasize; | ||
152 | double data[]; | ||
153 | }; | ||
154 | |||
155 | struct named_init { | ||
156 | int number; | ||
157 | const wchar_t *name; | ||
158 | double average; | ||
159 | }; | ||
160 | |||
161 | typedef const char *ccp; | ||
162 | |||
163 | static inline int | ||
164 | test_restrict (ccp restrict text) | ||
165 | { | ||
166 | // See if C++-style comments work. | ||
167 | // Iterate through items via the restricted pointer. | ||
168 | // Also check for declarations in for loops. | ||
169 | for (unsigned int i = 0; *(text+i) != '\''\0'\''; ++i) | ||
170 | continue; | ||
171 | return 0; | ||
172 | } | ||
173 | |||
174 | // Check varargs and va_copy. | ||
175 | static bool | ||
176 | test_varargs (const char *format, ...) | ||
177 | { | ||
178 | va_list args; | ||
179 | va_start (args, format); | ||
180 | va_list args_copy; | ||
181 | va_copy (args_copy, args); | ||
182 | |||
183 | const char *str = ""; | ||
184 | int number = 0; | ||
185 | float fnumber = 0; | ||
186 | |||
187 | while (*format) | ||
188 | { | ||
189 | switch (*format++) | ||
190 | { | ||
191 | case '\''s'\'': // string | ||
192 | str = va_arg (args_copy, const char *); | ||
193 | break; | ||
194 | case '\''d'\'': // int | ||
195 | number = va_arg (args_copy, int); | ||
196 | break; | ||
197 | case '\''f'\'': // float | ||
198 | fnumber = va_arg (args_copy, double); | ||
199 | break; | ||
200 | default: | ||
201 | break; | ||
202 | } | ||
203 | } | ||
204 | va_end (args_copy); | ||
205 | va_end (args); | ||
206 | |||
207 | return *str && number && fnumber; | ||
208 | } | ||
209 | ' | ||
210 | ]])]) | ||
211 | |||
212 | |||
213 | AC_DEFUN([_AC_C_C11_TEST_GLOBALS], | ||
214 | [m4_divert_text([INIT_PREPARE], | ||
215 | [[# Test code for whether the C compiler supports C11 (global declarations) | ||
216 | ac_c_conftest_c11_globals=' | ||
217 | // Does the compiler advertise C11 conformance? | ||
218 | #if !defined __STDC_VERSION__ || __STDC_VERSION__ < 201112L | ||
219 | # error "Compiler does not advertise C11 conformance" | ||
220 | #endif | ||
221 | |||
222 | // Check _Alignas. | ||
223 | char _Alignas (double) aligned_as_double; | ||
224 | char _Alignas (0) no_special_alignment; | ||
225 | extern char aligned_as_int; | ||
226 | char _Alignas (0) _Alignas (int) aligned_as_int; | ||
227 | |||
228 | // Check _Alignof. | ||
229 | enum | ||
230 | { | ||
231 | int_alignment = _Alignof (int), | ||
232 | int_array_alignment = _Alignof (int[100]), | ||
233 | char_alignment = _Alignof (char) | ||
234 | }; | ||
235 | _Static_assert (0 < -_Alignof (int), "_Alignof is signed"); | ||
236 | |||
237 | // Check _Noreturn. | ||
238 | _Noreturn int does_not_return (void) { for (;;) continue; } | ||
239 | |||
240 | // Check _Static_assert. | ||
241 | struct test_static_assert | ||
242 | { | ||
243 | int x; | ||
244 | _Static_assert (sizeof (int) <= sizeof (long int), | ||
245 | "_Static_assert does not work in struct"); | ||
246 | long int y; | ||
247 | }; | ||
248 | |||
249 | // Check UTF-8 literals. | ||
250 | #define u8 syntax error! | ||
251 | char const utf8_literal[] = u8"happens to be ASCII" "another string"; | ||
252 | |||
253 | // Check duplicate typedefs. | ||
254 | typedef long *long_ptr; | ||
255 | typedef long int *long_ptr; | ||
256 | typedef long_ptr long_ptr; | ||
257 | |||
258 | // Anonymous structures and unions -- taken from C11 6.7.2.1 Example 1. | ||
259 | struct anonymous | ||
260 | { | ||
261 | union { | ||
262 | struct { int i; int j; }; | ||
263 | struct { int k; long int l; } w; | ||
264 | }; | ||
265 | int m; | ||
266 | } v1; | ||
267 | ' | ||
268 | ]])]) | ||
269 | |||
270 | |||
271 | # AC_LANG_CALL(C)(PROLOGUE, FUNCTION) | ||
272 | # ----------------------------------- | ||
273 | # Avoid conflicting decl of main. | ||
274 | m4_define([AC_LANG_CALL(C)], | ||
275 | [AC_LANG_PROGRAM([$1 | ||
276 | m4_if([$2], [main], , | ||
277 | [/* Override any GCC internal prototype to avoid an error. | ||
278 | Use char because int might match the return type of a GCC | ||
279 | builtin and then its argument prototype would still apply. | ||
280 | The 'extern "C"' is for builds by C++ compilers; | ||
281 | although this is not generally supported in C code supporting it here | ||
282 | has little cost and some practical benefit (sr 110532). */ | ||
283 | #ifdef __cplusplus | ||
284 | extern "C" | ||
285 | #endif | ||
286 | char $2 (void);])], [return $2 ();])]) | ||
287 | |||
288 | |||
289 | # AC_LANG_FUNC_LINK_TRY(C)(FUNCTION) | ||
290 | # ---------------------------------- | ||
291 | # Don't include <ctype.h> because on OSF/1 3.0 it includes | ||
292 | # <sys/types.h> which includes <sys/select.h> which contains a | ||
293 | # prototype for select. Similarly for bzero. | ||
294 | # | ||
295 | # This test used to merely assign f=$1 in main(), but that was | ||
296 | # optimized away by HP unbundled cc A.05.36 for ia64 under +O3, | ||
297 | # presumably on the basis that there's no need to do that store if the | ||
298 | # program is about to exit. Conversely, the AIX linker optimizes an | ||
299 | # unused external declaration that initializes f=$1. So this test | ||
300 | # program has both an external initialization of f, and a use of f in | ||
301 | # main that affects the exit status. | ||
302 | # | ||
303 | m4_define([AC_LANG_FUNC_LINK_TRY(C)], | ||
304 | [AC_LANG_PROGRAM( | ||
305 | [/* Define $1 to an innocuous variant, in case <limits.h> declares $1. | ||
306 | For example, HP-UX 11i <limits.h> declares gettimeofday. */ | ||
307 | #define $1 innocuous_$1 | ||
308 | |||
309 | /* System header to define __stub macros and hopefully few prototypes, | ||
310 | which can conflict with char $1 (void); below. */ | ||
311 | |||
312 | #include <limits.h> | ||
313 | #undef $1 | ||
314 | |||
315 | /* Override any GCC internal prototype to avoid an error. | ||
316 | Use char because int might match the return type of a GCC | ||
317 | builtin and then its argument prototype would still apply. */ | ||
318 | #ifdef __cplusplus | ||
319 | extern "C" | ||
320 | #endif | ||
321 | char $1 (void); | ||
322 | /* The GNU C library defines this for functions which it implements | ||
323 | to always fail with ENOSYS. Some functions are actually named | ||
324 | something starting with __ and the normal name is an alias. */ | ||
325 | #if defined __stub_$1 || defined __stub___$1 | ||
326 | choke me | ||
327 | #endif | ||
328 | ], [return $1 ();])]) | ||
329 | |||
330 | |||
331 | # AC_C_BIGENDIAN ([ACTION-IF-TRUE], [ACTION-IF-FALSE], [ACTION-IF-UNKNOWN], | ||
332 | # [ACTION-IF-UNIVERSAL]) | ||
333 | # ------------------------------------------------------------------------- | ||
334 | AC_DEFUN([AC_C_BIGENDIAN], | ||
335 | [AH_VERBATIM([WORDS_BIGENDIAN], | ||
336 | [/* Define WORDS_BIGENDIAN to 1 if your processor stores words with the most | ||
337 | significant byte first (like Motorola and SPARC, unlike Intel). */ | ||
338 | #if defined AC_APPLE_UNIVERSAL_BUILD | ||
339 | # if defined __BIG_ENDIAN__ | ||
340 | # define WORDS_BIGENDIAN 1 | ||
341 | # endif | ||
342 | #else | ||
343 | # ifndef WORDS_BIGENDIAN | ||
344 | # undef WORDS_BIGENDIAN | ||
345 | # endif | ||
346 | #endif])dnl | ||
347 | AC_CACHE_CHECK([whether byte ordering is bigendian], [ac_cv_c_bigendian], | ||
348 | [ac_cv_c_bigendian=unknown | ||
349 | # See if we're dealing with a universal compiler. | ||
350 | AC_COMPILE_IFELSE( | ||
351 | [AC_LANG_SOURCE( | ||
352 | [[#ifndef __APPLE_CC__ | ||
353 | not a universal capable compiler | ||
354 | #endif | ||
355 | typedef int dummy; | ||
356 | ]])], | ||
357 | [ | ||
358 | # Check for potential -arch flags. It is not universal unless | ||
359 | # there are at least two -arch flags with different values. | ||
360 | ac_arch= | ||
361 | ac_prev= | ||
362 | for ac_word in $CC $CFLAGS $CPPFLAGS $LDFLAGS; do | ||
363 | if test -n "$ac_prev"; then | ||
364 | case $ac_word in | ||
365 | i?86 | x86_64 | ppc | ppc64) | ||
366 | if test -z "$ac_arch" || test "$ac_arch" = "$ac_word"; then | ||
367 | ac_arch=$ac_word | ||
368 | else | ||
369 | ac_cv_c_bigendian=universal | ||
370 | break | ||
371 | fi | ||
372 | ;; | ||
373 | esac | ||
374 | ac_prev= | ||
375 | elif test "x$ac_word" = "x-arch"; then | ||
376 | ac_prev=arch | ||
377 | fi | ||
378 | done]) | ||
379 | if test $ac_cv_c_bigendian = unknown; then | ||
380 | # See if sys/param.h defines the BYTE_ORDER macro. | ||
381 | AC_COMPILE_IFELSE( | ||
382 | [AC_LANG_PROGRAM( | ||
383 | [[#include <sys/types.h> | ||
384 | #include <sys/param.h> | ||
385 | ]], | ||
386 | [[#if ! (defined BYTE_ORDER && defined BIG_ENDIAN \\ | ||
387 | && defined LITTLE_ENDIAN && BYTE_ORDER && BIG_ENDIAN \\ | ||
388 | && LITTLE_ENDIAN) | ||
389 | bogus endian macros | ||
390 | #endif | ||
391 | ]])], | ||
392 | [# It does; now see whether it defined to BIG_ENDIAN or not. | ||
393 | AC_COMPILE_IFELSE( | ||
394 | [AC_LANG_PROGRAM( | ||
395 | [[#include <sys/types.h> | ||
396 | #include <sys/param.h> | ||
397 | ]], | ||
398 | [[#if BYTE_ORDER != BIG_ENDIAN | ||
399 | not big endian | ||
400 | #endif | ||
401 | ]])], | ||
402 | [ac_cv_c_bigendian=yes], | ||
403 | [ac_cv_c_bigendian=no])]) | ||
404 | fi | ||
405 | if test $ac_cv_c_bigendian = unknown; then | ||
406 | # See if <limits.h> defines _LITTLE_ENDIAN or _BIG_ENDIAN (e.g., Solaris). | ||
407 | AC_COMPILE_IFELSE( | ||
408 | [AC_LANG_PROGRAM( | ||
409 | [[#include <limits.h> | ||
410 | ]], | ||
411 | [[#if ! (defined _LITTLE_ENDIAN || defined _BIG_ENDIAN) | ||
412 | bogus endian macros | ||
413 | #endif | ||
414 | ]])], | ||
415 | [# It does; now see whether it defined to _BIG_ENDIAN or not. | ||
416 | AC_COMPILE_IFELSE( | ||
417 | [AC_LANG_PROGRAM( | ||
418 | [[#include <limits.h> | ||
419 | ]], | ||
420 | [[#ifndef _BIG_ENDIAN | ||
421 | not big endian | ||
422 | #endif | ||
423 | ]])], | ||
424 | [ac_cv_c_bigendian=yes], | ||
425 | [ac_cv_c_bigendian=no])]) | ||
426 | fi | ||
427 | if test $ac_cv_c_bigendian = unknown; then | ||
428 | # Compile a test program. | ||
429 | AC_RUN_IFELSE( | ||
430 | [AC_LANG_PROGRAM([AC_INCLUDES_DEFAULT], | ||
431 | [[ | ||
432 | /* Are we little or big endian? From Harbison&Steele. */ | ||
433 | union | ||
434 | { | ||
435 | long int l; | ||
436 | char c[sizeof (long int)]; | ||
437 | } u; | ||
438 | u.l = 1; | ||
439 | return u.c[sizeof (long int) - 1] == 1; | ||
440 | ]])], | ||
441 | [ac_cv_c_bigendian=no], | ||
442 | [ac_cv_c_bigendian=yes], | ||
443 | [# Try to guess by grepping values from an object file. | ||
444 | AC_LINK_IFELSE( | ||
445 | [AC_LANG_SOURCE( | ||
446 | [[unsigned short int ascii_mm[] = | ||
447 | { 0x4249, 0x4765, 0x6E44, 0x6961, 0x6E53, 0x7953, 0 }; | ||
448 | unsigned short int ascii_ii[] = | ||
449 | { 0x694C, 0x5454, 0x656C, 0x6E45, 0x6944, 0x6E61, 0 }; | ||
450 | int use_ascii (int i) { | ||
451 | return ascii_mm[i] + ascii_ii[i]; | ||
452 | } | ||
453 | unsigned short int ebcdic_ii[] = | ||
454 | { 0x89D3, 0xE3E3, 0x8593, 0x95C5, 0x89C4, 0x9581, 0 }; | ||
455 | unsigned short int ebcdic_mm[] = | ||
456 | { 0xC2C9, 0xC785, 0x95C4, 0x8981, 0x95E2, 0xA8E2, 0 }; | ||
457 | int use_ebcdic (int i) { | ||
458 | return ebcdic_mm[i] + ebcdic_ii[i]; | ||
459 | } | ||
460 | int | ||
461 | main (int argc, char **argv) | ||
462 | { | ||
463 | /* Intimidate the compiler so that it does not | ||
464 | optimize the arrays away. */ | ||
465 | char *p = argv[0]; | ||
466 | ascii_mm[1] = *p++; ebcdic_mm[1] = *p++; | ||
467 | ascii_ii[1] = *p++; ebcdic_ii[1] = *p++; | ||
468 | return use_ascii (argc) == use_ebcdic (*p); | ||
469 | }]])], | ||
470 | [if grep BIGenDianSyS conftest$ac_exeext >/dev/null; then | ||
471 | ac_cv_c_bigendian=yes | ||
472 | fi | ||
473 | if grep LiTTleEnDian conftest$ac_exeext >/dev/null ; then | ||
474 | if test "$ac_cv_c_bigendian" = unknown; then | ||
475 | ac_cv_c_bigendian=no | ||
476 | else | ||
477 | # finding both strings is unlikely to happen, but who knows? | ||
478 | ac_cv_c_bigendian=unknown | ||
479 | fi | ||
480 | fi])]) | ||
481 | fi]) | ||
482 | case $ac_cv_c_bigendian in #( | ||
483 | yes) | ||
484 | m4_default([$1], | ||
485 | [AC_DEFINE([WORDS_BIGENDIAN], 1)]);; #( | ||
486 | no) | ||
487 | $2 ;; #( | ||
488 | universal) | ||
489 | dnl Note that AC_APPLE_UNIVERSAL_BUILD sorts less than WORDS_BIGENDIAN; | ||
490 | dnl this is a necessity for proper config header operation. Warn if | ||
491 | dnl the user did not specify a config header but is relying on the | ||
492 | dnl default behavior for universal builds. | ||
493 | m4_default([$4], | ||
494 | [AC_CONFIG_COMMANDS_PRE([m4_ifset([AH_HEADER], [], | ||
495 | [m4_warn([obsolete], | ||
496 | [AC_C_BIGENDIAN should be used with AC_CONFIG_HEADERS])])])dnl | ||
497 | AC_DEFINE([AC_APPLE_UNIVERSAL_BUILD],1, | ||
498 | [Define if building universal (internal helper macro)])]) | ||
499 | ;; #( | ||
500 | *) | ||
501 | m4_default([$3], | ||
502 | [AC_MSG_ERROR([unknown endianness | ||
503 | presetting ac_cv_c_bigendian=no (or yes) will help])]) ;; | ||
504 | esac | ||
505 | ])# AC_C_BIGENDIAN | ||
506 | |||
507 | |||
508 | # AC_C_VARARRAYS | ||
509 | # -------------- | ||
510 | # Check whether the C compiler supports variable-length arrays. | ||
511 | AC_DEFUN([AC_C_VARARRAYS], | ||
512 | [ | ||
513 | AC_CACHE_CHECK([for variable-length arrays], | ||
514 | ac_cv_c_vararrays, | ||
515 | [AC_COMPILE_IFELSE([AC_LANG_SOURCE( | ||
516 | [[ #ifndef __STDC_NO_VLA__ | ||
517 | #error __STDC_NO_VLA__ not defined | ||
518 | #endif | ||
519 | ]])], | ||
520 | [ac_cv_c_vararrays='no: __STDC_NO_VLA__ is defined'], | ||
521 | [AC_COMPILE_IFELSE( | ||
522 | [AC_LANG_PROGRAM( | ||
523 | [[/* Test for VLA support. This test is partly inspired | ||
524 | from examples in the C standard. Use at least two VLA | ||
525 | functions to detect the GCC 3.4.3 bug described in: | ||
526 | https://lists.gnu.org/archive/html/bug-gnulib/2014-08/msg00014.html | ||
527 | */ | ||
528 | #ifdef __STDC_NO_VLA__ | ||
529 | syntax error; | ||
530 | #else | ||
531 | extern int n; | ||
532 | static int B[100]; | ||
533 | int fvla (int m, int C[m][m]); | ||
534 | |||
535 | static int | ||
536 | simple (int count, int all[static count]) | ||
537 | { | ||
538 | return all[count - 1]; | ||
539 | } | ||
540 | |||
541 | int | ||
542 | fvla (int m, int C[m][m]) | ||
543 | { | ||
544 | typedef int VLA[m][m]; | ||
545 | VLA x; | ||
546 | int D[m]; | ||
547 | static int (*q)[m] = &B; | ||
548 | int (*s)[n] = q; | ||
549 | return C && &x[0][0] == &D[0] && &D[0] == s[0]; | ||
550 | } | ||
551 | #endif | ||
552 | ]])], | ||
553 | [ac_cv_c_vararrays=yes], | ||
554 | [ac_cv_c_vararrays=no])])]) | ||
555 | if test "$ac_cv_c_vararrays" = yes; then | ||
556 | dnl This is for compatibility with Autoconf 2.61-2.69. | ||
557 | AC_DEFINE([HAVE_C_VARARRAYS], 1, | ||
558 | [Define to 1 if C supports variable-length arrays.]) | ||
559 | elif test "$ac_cv_c_vararrays" = no; then | ||
560 | AC_DEFINE([__STDC_NO_VLA__], 1, | ||
561 | [Define to 1 if C does not support variable-length arrays, and | ||
562 | if the compiler does not already define this.]) | ||
563 | fi | ||
564 | ]) | ||
565 | |||