1 dnl See if stdbool.h properly defines bool and true/false.
2 AC_DEFUN(gcc_AC_HEADER_STDBOOL,
3 [AC_CACHE_CHECK([for working stdbool.h],
4 ac_cv_header_stdbool_h,
5 [AC_TRY_COMPILE([#include <stdbool.h>],
7 ac_cv_header_stdbool_h=yes, ac_cv_header_stdbool_h=no)])
8 if test $ac_cv_header_stdbool_h = yes; then
9 AC_DEFINE(HAVE_STDBOOL_H, 1,
10 [Define if you have a working <stdbool.h> header file.])
14 dnl See whether we can include both string.h and strings.h.
15 AC_DEFUN(gcc_AC_HEADER_STRING,
16 [AC_CACHE_CHECK([whether string.h and strings.h may both be included],
18 [AC_TRY_COMPILE([#include <string.h>
19 #include <strings.h>], , gcc_cv_header_string=yes, gcc_cv_header_string=no)])
20 if test $gcc_cv_header_string = yes; then
21 AC_DEFINE(STRING_WITH_STRINGS, 1, [Define if you can safely include both <string.h> and <strings.h>.])
25 dnl See whether we need a declaration for a function.
26 dnl The result is highly dependent on the INCLUDES passed in, so make sure
27 dnl to use a different cache variable name in this macro if it is invoked
28 dnl in a different context somewhere else.
29 dnl gcc_AC_CHECK_DECL(SYMBOL,
30 dnl [ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND [, INCLUDES]]])
31 AC_DEFUN(gcc_AC_CHECK_DECL,
32 [AC_MSG_CHECKING([whether $1 is declared])
33 AC_CACHE_VAL(gcc_cv_have_decl_$1,
36 char *(*pfn) = (char *(*)) $1 ;
37 #endif], eval "gcc_cv_have_decl_$1=yes", eval "gcc_cv_have_decl_$1=no")])
38 if eval "test \"`echo '$gcc_cv_have_decl_'$1`\" = yes"; then
39 AC_MSG_RESULT(yes) ; ifelse([$2], , :, [$2])
41 AC_MSG_RESULT(no) ; ifelse([$3], , :, [$3])
45 dnl Check multiple functions to see whether each needs a declaration.
46 dnl Arrange to define HAVE_DECL_<FUNCTION> to 0 or 1 as appropriate.
47 dnl gcc_AC_CHECK_DECLS(SYMBOLS,
48 dnl [ACTION-IF-NEEDED [, ACTION-IF-NOT-NEEDED [, INCLUDES]]])
49 AC_DEFUN(gcc_AC_CHECK_DECLS,
53 ac_tr_decl=HAVE_DECL_`echo $ac_func | tr 'abcdefghijklmnopqrstuvwxyz' 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'`
55 gcc_AC_CHECK_DECL($ac_func,
56 [AC_DEFINE_UNQUOTED($ac_tr_decl, 1) $2],
57 [AC_DEFINE_UNQUOTED($ac_tr_decl, 0) $3],
58 dnl It is possible that the include files passed in here are local headers
59 dnl which supply a backup declaration for the relevant prototype based on
60 dnl the definition of (or lack of) the HAVE_DECL_ macro. If so, this test
61 dnl will always return success. E.g. see libiberty.h's handling of
62 dnl `basename'. To avoid this, we define the relevant HAVE_DECL_ macro to
63 dnl 1 so that any local headers used do not provide their own prototype
70 dnl Automatically generate config.h entries via autoheader.
72 patsubst(translit([$1], [a-z], [A-Z]), [\w+],
73 [AC_DEFINE([HAVE_DECL_\&], 1,
74 [Define to 1 if we found this declaration otherwise define to 0.])])dnl
78 dnl See if symbolic links work and if not, try to substitute either hard links or simple copy.
79 AC_DEFUN(gcc_AC_PROG_LN_S,
80 [AC_MSG_CHECKING(whether ln -s works)
81 AC_CACHE_VAL(gcc_cv_prog_LN_S,
84 if ln -s conftestdata_f conftestdata_t 2>/dev/null
86 gcc_cv_prog_LN_S="ln -s"
88 if ln conftestdata_f conftestdata_t 2>/dev/null
95 rm -f conftestdata_f conftestdata_t
97 LN_S="$gcc_cv_prog_LN_S"
98 if test "$gcc_cv_prog_LN_S" = "ln -s"; then
101 if test "$gcc_cv_prog_LN_S" = "ln"; then
102 AC_MSG_RESULT([no, using ln])
104 AC_MSG_RESULT([no, and neither does ln, so using cp])
110 dnl See if hard links work and if not, try to substitute either symbolic links or simple copy.
111 AC_DEFUN(gcc_AC_PROG_LN,
112 [AC_MSG_CHECKING(whether ln works)
113 AC_CACHE_VAL(gcc_cv_prog_LN,
114 [rm -f conftestdata_t
116 if ln conftestdata_f conftestdata_t 2>/dev/null
120 if ln -s conftestdata_f conftestdata_t 2>/dev/null
122 gcc_cv_prog_LN="ln -s"
127 rm -f conftestdata_f conftestdata_t
130 if test "$gcc_cv_prog_LN" = "ln"; then
133 if test "$gcc_cv_prog_LN" = "ln -s"; then
134 AC_MSG_RESULT([no, using ln -s])
136 AC_MSG_RESULT([no, and neither does ln -s, so using cp])
142 dnl Check whether _Bool is built-in.
143 AC_DEFUN(gcc_AC_C__BOOL,
144 [AC_CACHE_CHECK(for built-in _Bool, gcc_cv_c__bool,
147 gcc_cv_c__bool=yes, gcc_cv_c__bool=no)
149 if test $gcc_cv_c__bool = yes; then
150 AC_DEFINE(HAVE__BOOL, 1, [Define if the \`_Bool' type is built-in.])
154 dnl Define MKDIR_TAKES_ONE_ARG if mkdir accepts only one argument instead
156 AC_DEFUN(gcc_AC_FUNC_MKDIR_TAKES_ONE_ARG,
157 [AC_CACHE_CHECK([if mkdir takes one argument], gcc_cv_mkdir_takes_one_arg,
159 #include <sys/types.h>
160 #ifdef HAVE_SYS_STAT_H
161 # include <sys/stat.h>
168 #endif], [mkdir ("foo", 0);],
169 gcc_cv_mkdir_takes_one_arg=no, gcc_cv_mkdir_takes_one_arg=yes)])
170 if test $gcc_cv_mkdir_takes_one_arg = yes ; then
171 AC_DEFINE(MKDIR_TAKES_ONE_ARG, 1, [Define if host mkdir takes a single argument.])
175 AC_DEFUN(gcc_AC_PROG_INSTALL,
176 [AC_REQUIRE([AC_CONFIG_AUX_DIR_DEFAULT])dnl
177 # Find a good install program. We prefer a C program (faster),
178 # so one script is as good as another. But avoid the broken or
179 # incompatible versions:
180 # SysV /etc/install, /usr/sbin/install
181 # SunOS /usr/etc/install
184 # AFS /usr/afsws/bin/install, which mishandles nonexistent args
185 # SVR4 /usr/ucb/install, which tries to use the nonexistent group "staff"
186 # ./install, which can be erroneously created by make from ./install.sh.
187 AC_MSG_CHECKING(for a BSD compatible install)
188 if test -z "$INSTALL"; then
189 AC_CACHE_VAL(ac_cv_path_install,
190 [ IFS="${IFS= }"; ac_save_IFS="$IFS"; IFS="${IFS}:"
191 for ac_dir in $PATH; do
192 # Account for people who put trailing slashes in PATH elements.
194 /|./|.//|/etc/*|/usr/sbin/*|/usr/etc/*|/sbin/*|/usr/afsws/bin/*|/usr/ucb/*) ;;
196 # OSF1 and SCO ODT 3.0 have their own names for install.
197 for ac_prog in ginstall scoinst install; do
198 if test -f $ac_dir/$ac_prog; then
199 if test $ac_prog = install &&
200 grep dspmsg $ac_dir/$ac_prog >/dev/null 2>&1; then
201 # AIX install. It has an incompatible calling convention.
202 # OSF/1 installbsd also uses dspmsg, but is usable.
205 ac_cv_path_install="$ac_dir/$ac_prog -c"
215 if test "${ac_cv_path_install+set}" = set; then
216 INSTALL="$ac_cv_path_install"
218 # As a last resort, use the slow shell script. We don't cache a
219 # path for INSTALL within a source directory, because that will
220 # break other packages using the cache if that directory is
221 # removed, or if the path is relative.
222 INSTALL="$ac_install_sh"
225 dnl We do special magic for INSTALL instead of AC_SUBST, to get
226 dnl relative paths right.
227 AC_MSG_RESULT($INSTALL)
230 # Use test -z because SunOS4 sh mishandles braces in ${var-val}.
231 # It thinks the first close brace ends the variable substitution.
232 test -z "$INSTALL_PROGRAM" && INSTALL_PROGRAM='${INSTALL}'
233 AC_SUBST(INSTALL_PROGRAM)dnl
235 test -z "$INSTALL_DATA" && INSTALL_DATA='${INSTALL} -m 644'
236 AC_SUBST(INSTALL_DATA)dnl
240 dnl This test replaces the one in autoconf.
241 dnl Currently this macro should have the same name as the autoconf macro
242 dnl because gettext's gettext.m4 (distributed in the automake package)
243 dnl still uses it. Otherwise, the use in gettext.m4 makes autoheader
244 dnl give these diagnostics:
245 dnl configure.in:556: AC_TRY_COMPILE was called before AC_ISC_POSIX
246 dnl configure.in:556: AC_TRY_RUN was called before AC_ISC_POSIX
248 undefine([AC_ISC_POSIX])
249 AC_DEFUN(AC_ISC_POSIX,
251 dnl This test replaces the obsolescent AC_ISC_POSIX kludge.
252 AC_CHECK_LIB(cposix, strerror, [LIBS="$LIBS -lcposix"])
257 dnl GCC_PATH_PROG(VARIABLE, PROG-TO-CHECK-FOR [, VALUE-IF-NOT-FOUND [, PATH]])
258 dnl like AC_PATH_PROG but use other cache variables
259 AC_DEFUN(GCC_PATH_PROG,
260 [# Extract the first word of "$2", so it can be a program name with args.
261 set dummy $2; ac_word=[$]2
262 AC_MSG_CHECKING([for $ac_word])
263 AC_CACHE_VAL(gcc_cv_path_$1,
266 gcc_cv_path_$1="[$]$1" # Let the user override the test with a path.
269 gcc_cv_path_$1="[$]$1" # Let the user override the test with a dos path.
272 IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS=":"
273 dnl $ac_dummy forces splitting on constant user-supplied paths.
274 dnl POSIX.2 word splitting is done only on the output of word expansions,
275 dnl not every word. This closes a longstanding sh security hole.
276 ac_dummy="ifelse([$4], , $PATH, [$4])"
277 for ac_dir in $ac_dummy; do
278 test -z "$ac_dir" && ac_dir=.
279 if test -f $ac_dir/$ac_word; then
280 gcc_cv_path_$1="$ac_dir/$ac_word"
285 dnl If no 3rd arg is given, leave the cache variable unset,
286 dnl so GCC_PATH_PROGS will keep looking.
287 ifelse([$3], , , [ test -z "[$]gcc_cv_path_$1" && gcc_cv_path_$1="$3"
292 if test -n "[$]$1"; then
302 dnl GCC_PATH_PROG_WITH_TEST(VARIABLE, PROG-TO-CHECK-FOR,
303 dnl TEST-PERFORMED-ON-FOUND_PROGRAM [, VALUE-IF-NOT-FOUND [, PATH]])
304 AC_DEFUN(GCC_PATH_PROG_WITH_TEST,
305 [# Extract the first word of "$2", so it can be a program name with args.
306 set dummy $2; ac_word=[$]2
307 AC_MSG_CHECKING([for $ac_word])
308 AC_CACHE_VAL(gcc_cv_path_$1,
311 gcc_cv_path_$1="[$]$1" # Let the user override the test with a path.
314 IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS="${IFS}:"
315 for ac_dir in ifelse([$5], , $PATH, [$5]); do
316 test -z "$ac_dir" && ac_dir=.
317 if test -f $ac_dir/$ac_word; then
319 gcc_cv_path_$1="$ac_dir/$ac_word"
325 dnl If no 4th arg is given, leave the cache variable unset,
326 dnl so GCC_PATH_PROGS will keep looking.
327 ifelse([$4], , , [ test -z "[$]gcc_cv_path_$1" && gcc_cv_path_$1="$4"
332 if test -n "[$]$1"; then
340 # Check whether mmap can map an arbitrary page from /dev/zero or with
341 # MAP_ANONYMOUS, without MAP_FIXED.
342 AC_DEFUN([AC_FUNC_MMAP_ANYWHERE],
343 [AC_CHECK_FUNCS(getpagesize)
344 # The test program for the next two tests is the same except for one
346 changequote({{{,}}})dnl
347 {{{cat >ct-mmap.inc <<'EOF'
348 #include <sys/types.h>
349 #include <sys/mman.h>
355 #if !defined (MAP_ANONYMOUS) && defined (MAP_ANON)
356 # define MAP_ANONYMOUS MAP_ANON
359 /* This mess was copied from the GNU getpagesize.h. */
360 #ifndef HAVE_GETPAGESIZE
361 # ifdef HAVE_UNISTD_H
365 /* Assume that all systems that can run configure have sys/param.h. */
366 # ifndef HAVE_SYS_PARAM_H
367 # define HAVE_SYS_PARAM_H 1
371 # define getpagesize() sysconf(_SC_PAGESIZE)
372 # else /* no _SC_PAGESIZE */
373 # ifdef HAVE_SYS_PARAM_H
374 # include <sys/param.h>
375 # ifdef EXEC_PAGESIZE
376 # define getpagesize() EXEC_PAGESIZE
377 # else /* no EXEC_PAGESIZE */
379 # define getpagesize() NBPG * CLSIZE
382 # endif /* no CLSIZE */
385 # define getpagesize() NBPC
388 # define getpagesize() PAGESIZE
389 # endif /* PAGESIZE */
390 # endif /* no NBPC */
391 # endif /* no NBPG */
392 # endif /* no EXEC_PAGESIZE */
393 # else /* no HAVE_SYS_PARAM_H */
394 # define getpagesize() 8192 /* punt totally */
395 # endif /* no HAVE_SYS_PARAM_H */
396 # endif /* no _SC_PAGESIZE */
398 #endif /* no HAVE_GETPAGESIZE */
401 # define MAP_FAILED -1
405 #define perror_exit(str, val) \
406 do { perror(str); exit(val); } while (0)
408 /* Some versions of cygwin mmap require that munmap is called with the
409 same parameters as mmap. GCC expects that this is not the case.
410 Test for various forms of this problem. Warning - icky signal games. */
412 static sigset_t unblock_sigsegv;
422 return (char *) mmap (0, size, PROT_READ|PROT_WRITE,
423 MAP_PRIVATE|MAP_ANONYMOUS, -1, 0);
425 return (char *) mmap (0, size, PROT_READ|PROT_WRITE,
426 MAP_PRIVATE, devzero, 0);
434 sigprocmask (SIG_UNBLOCK, &unblock_sigsegv, 0);
438 /* Basic functionality test. */
442 char *x = anonmap (pg);
443 if (x == (char *) MAP_FAILED)
444 perror_exit("test 0 mmap", 2);
448 if (munmap(x, pg) < 0)
449 perror_exit("test 0 munmap", 3);
452 /* 1. If we map a 2-page region and unmap its second page, the first page
457 char *x = anonmap (pg * 2);
458 if (x == (char *)MAP_FAILED)
459 perror_exit ("test 1 mmap", 4);
461 signal (SIGSEGV, sigsegv);
463 perror_exit ("test 1 fault", 5);
468 if (munmap (x + pg, pg) < 0)
469 perror_exit ("test 1 munmap 1", 6);
475 perror_exit ("test 1 no fault", 7);
477 if (munmap (x, pg) < 0)
478 perror_exit ("test 1 munmap 2", 8);
481 /* 2. If we map a 2-page region and unmap its first page, the second
486 char *x = anonmap (pg * 2);
487 if (x == (char *)MAP_FAILED)
488 perror_exit ("test 2 mmap", 9);
490 signal (SIGSEGV, sigsegv);
492 perror_exit ("test 2 fault", 10);
497 if (munmap (x, pg) < 0)
498 perror_exit ("test 2 munmap 1", 11);
505 perror_exit ("test 2 no fault", 12);
508 if (munmap (x+pg, pg) < 0)
509 perror_exit ("test 2 munmap 2", 13);
512 /* 3. If we map two adjacent 1-page regions and unmap them both with
513 one munmap, both must go away.
515 Getting two adjacent 1-page regions with two mmap calls is slightly
516 tricky. All OS's tested skip over already-allocated blocks; therefore
517 we have been careful to unmap all allocated regions in previous tests.
518 HP/UX allocates pages backward in memory. No OS has yet been observed
519 to be so perverse as to leave unmapped space between consecutive calls
528 if (x == (char *)MAP_FAILED)
529 perror_exit ("test 3 mmap 1", 14);
531 if (y == (char *)MAP_FAILED)
532 perror_exit ("test 3 mmap 2", 15);
540 fprintf (stderr, "test 3 nonconsecutive pages - %lx, %lx\n",
541 (unsigned long)x, (unsigned long)y);
546 signal (SIGSEGV, sigsegv);
548 perror_exit ("test 3 fault", 17);
553 if (munmap (x, pg*2) < 0)
554 perror_exit ("test 3 munmap", 18);
559 perror_exit ("test 3 no fault 1", 19);
562 signal (SIGSEGV, sigsegv);
566 perror_exit ("test 3 no fault 2", 20);
573 sigemptyset (&unblock_sigsegv);
574 sigaddset (&unblock_sigsegv, SIGSEGV);
577 devzero = open ("/dev/zero", O_RDWR);
579 perror_exit ("open /dev/zero", 1);
592 AC_CACHE_CHECK(for working mmap from /dev/zero,
593 ac_cv_func_mmap_dev_zero,
595 [#include "ct-mmap.inc"],
596 ac_cv_func_mmap_dev_zero=yes,
598 then ac_cv_func_mmap_dev_zero=no
599 else ac_cv_func_mmap_dev_zero=buggy
601 # If this is not cygwin, and /dev/zero is a character device, it's probably
602 # safe to assume it works.
604 cygwin* | win32 | pe | mingw* ) ac_cv_func_mmap_dev_zero=buggy ;;
605 * ) if test -c /dev/zero
606 then ac_cv_func_mmap_dev_zero=yes
607 else ac_cv_func_mmap_dev_zero=no
611 if test $ac_cv_func_mmap_dev_zero = yes; then
612 AC_DEFINE(HAVE_MMAP_DEV_ZERO, 1,
613 [Define if mmap can get us zeroed pages from /dev/zero.])
616 AC_CACHE_CHECK([for working mmap with MAP_ANON(YMOUS)],
617 ac_cv_func_mmap_anon,
619 [#define USE_MAP_ANON
620 #include "ct-mmap.inc"],
621 ac_cv_func_mmap_anon=yes,
623 then ac_cv_func_mmap_anon=no
624 else ac_cv_func_mmap_anon=buggy
626 # Unlike /dev/zero, it is not safe to assume MAP_ANON(YMOUS) works
627 # just because it's there. Some SCO Un*xen define it but don't implement it.
628 ac_cv_func_mmap_anon=no)
630 if test $ac_cv_func_mmap_anon = yes; then
631 AC_DEFINE(HAVE_MMAP_ANON, 1,
632 [Define if mmap can get us zeroed pages using MAP_ANON(YMOUS).])
637 # Check whether mmap can map a plain file, without MAP_FIXED.
638 AC_DEFUN([AC_FUNC_MMAP_FILE],
639 [AC_CACHE_CHECK(for working mmap of a file, ac_cv_func_mmap_file,
640 [# Create a file one thousand bytes long.
641 for i in 1 2 3 4 5 6 7 8 9 0
642 do for j in 1 2 3 4 5 6 7 8 9 0
645 done > conftestdata$$
648 /* Test by Zack Weinberg. Modified from MMAP_ANYWHERE test by
649 Richard Henderson and Alexandre Oliva.
650 Check whether read-only mmap of a plain file works. */
651 #include <sys/types.h>
652 #include <sys/stat.h>
654 #include <sys/mman.h>
662 fd = open("conftestdata$$", O_RDONLY);
669 x = (char*)mmap(0, st.st_size, PROT_READ, MAP_PRIVATE, fd, 0);
670 if (x == (char *) -1)
673 if (x[0] != '1' || x[1] != ' ' || x[2] != '1' || x[3] != ' ')
676 if (munmap(x, st.st_size) < 0)
680 }], ac_cv_func_mmap_file=yes, ac_cv_func_mmap_file=no,
681 ac_cv_func_mmap_file=no)])
682 if test $ac_cv_func_mmap_file = yes; then
683 AC_DEFINE(HAVE_MMAP_FILE, 1,
684 [Define if read-only mmap of a plain file works.])
688 dnl Locate a program and check that its version is acceptable.
689 dnl AC_PROG_CHECK_VER(var, name, version-switch,
690 dnl version-extract-regexp, version-glob)
691 AC_DEFUN(gcc_AC_CHECK_PROG_VER,
692 [AC_CHECK_PROG([$1], [$2], [$2])
693 if test -n "[$]$1"; then
694 # Found it, now check the version.
695 AC_CACHE_CHECK(for modern $2, gcc_cv_prog_$2_modern,
696 [changequote(<<,>>)dnl
697 ac_prog_version=`<<$>>$1 $3 2>&1 |
698 sed -n 's/^.*patsubst(<<$4>>,/,\/).*$/\1/p'`
700 echo "configure:__oline__: version of $2 is $ac_prog_version" >&AC_FD_CC
701 changequote(<<,>>)dnl
702 case $ac_prog_version in
703 '') gcc_cv_prog_$2_modern=no;;
705 gcc_cv_prog_$2_modern=yes;;
706 *) gcc_cv_prog_$2_modern=no;;
711 gcc_cv_prog_$2_modern=no
715 dnl Determine if enumerated bitfields are unsigned. ISO C says they can
716 dnl be either signed or unsigned.
718 AC_DEFUN(gcc_AC_C_ENUM_BF_UNSIGNED,
719 [AC_CACHE_CHECK(for unsigned enumerated bitfields, gcc_cv_enum_bf_unsigned,
720 [AC_TRY_RUN(#include <stdlib.h>
721 enum t { BLAH = 128 } ;
722 struct s_t { enum t member : 8; } s ;
726 if (s.member < 0) exit(1);
729 }, gcc_cv_enum_bf_unsigned=yes, gcc_cv_enum_bf_unsigned=no, gcc_cv_enum_bf_unsigned=yes)])
730 if test $gcc_cv_enum_bf_unsigned = yes; then
731 AC_DEFINE(ENUM_BITFIELDS_ARE_UNSIGNED, 1,
732 [Define if enumerated bitfields are treated as unsigned values.])
735 dnl Host type sizes probe.
736 dnl By Kaveh R. Ghazi. One typo fixed since.
738 AC_DEFUN([gcc_AC_COMPILE_CHECK_SIZEOF],
739 [changequote(<<, >>)dnl
740 dnl The name to #define.
741 define(<<AC_TYPE_NAME>>, translit(sizeof_$1, [a-z *], [A-Z_P]))dnl
742 dnl The cache variable name.
743 define(<<AC_CV_NAME>>, translit(ac_cv_sizeof_$1, [ *], [_p]))dnl
745 AC_MSG_CHECKING(size of $1)
746 AC_CACHE_VAL(AC_CV_NAME,
747 [for ac_size in 4 8 1 2 16 $3 ; do # List sizes in rough order of prevalence.
748 AC_TRY_COMPILE([#include "confdefs.h"
749 #include <sys/types.h>
751 ], [switch (0) case 0: case (sizeof ($1) == $ac_size):;], AC_CV_NAME=$ac_size)
752 if test x$AC_CV_NAME != x ; then break; fi
755 if test x$AC_CV_NAME = x ; then
756 AC_MSG_ERROR([cannot determine a size for $1])
758 AC_MSG_RESULT($AC_CV_NAME)
759 AC_DEFINE_UNQUOTED(AC_TYPE_NAME, $AC_CV_NAME, [The number of bytes in type $1])
760 undefine([AC_TYPE_NAME])dnl
761 undefine([AC_CV_NAME])dnl
764 dnl Probe number of bits in a byte.
765 dnl Note C89 requires CHAR_BIT >= 8.
767 AC_DEFUN(gcc_AC_C_CHAR_BIT,
768 [AC_CACHE_CHECK(for CHAR_BIT, gcc_cv_decl_char_bit,
770 [#ifdef HAVE_LIMITS_H
775 #endif], gcc_cv_decl_char_bit=yes, gcc_cv_decl_char_bit=no)
777 if test $gcc_cv_decl_char_bit = no; then
778 AC_CACHE_CHECK(number of bits in a byte, gcc_cv_c_nbby,
781 while test $i -lt 65; do
784 case (unsigned char)((unsigned long)1 << $i) == ((unsigned long)1 << $i):
785 case (unsigned char)((unsigned long)1<<($i-1)) == ((unsigned long)1<<($i-1)):
787 [gcc_cv_c_nbby=$i; break])
790 test -z "$gcc_cv_c_nbby" && gcc_cv_c_nbby=failed
792 if test $gcc_cv_c_nbby = failed; then
793 AC_MSG_ERROR(cannot determine number of bits in a byte)
795 AC_DEFINE_UNQUOTED(CHAR_BIT, $gcc_cv_c_nbby,
796 [Define as the number of bits in a byte, if \`limits.h' doesn't.])
800 dnl Host character set probe.
801 dnl The EBCDIC values match the table in config/i370/i370.c;
802 dnl there are other versions of EBCDIC but GCC won't work with them.
804 AC_DEFUN([gcc_AC_C_CHARSET],
805 [AC_CACHE_CHECK(execution character set, ac_cv_c_charset,
807 [#if '\n' == 0x0A && ' ' == 0x20 && '0' == 0x30 \
808 && 'A' == 0x41 && 'a' == 0x61 && '!' == 0x21
810 #endif], ac_cv_c_charset=ASCII)
811 if test x${ac_cv_c_charset+set} != xset; then
813 [#if '\n' == 0x15 && ' ' == 0x40 && '0' == 0xF0 \
814 && 'A' == 0xC1 && 'a' == 0x81 && '!' == 0x5A
816 #endif], ac_cv_c_charset=EBCDIC)
818 if test x${ac_cv_c_charset+set} != xset; then
819 ac_cv_c_charset=unknown
821 if test $ac_cv_c_charset = unknown; then
822 AC_MSG_ERROR([*** Cannot determine host character set.])
823 elif test $ac_cv_c_charset = EBCDIC; then
824 AC_DEFINE(HOST_EBCDIC, 1,
825 [Define if the host execution character set is EBCDIC.])
828 dnl Utility macro used by next two tests.
829 dnl AC_EXAMINE_OBJECT(C source code,
830 dnl commands examining object file,
831 dnl [commands to run if compile failed]):
833 dnl Compile the source code to an object file; then convert it into a
834 dnl printable representation. All unprintable characters and
835 dnl asterisks (*) are replaced by dots (.). All white space is
836 dnl deleted. Newlines (ASCII 0x10) in the input are preserved in the
837 dnl output, but runs of newlines are compressed to a single newline.
838 dnl Finally, line breaks are forcibly inserted so that no line is
839 dnl longer than 80 columns and the file ends with a newline. The
840 dnl result of all this processing is in the file conftest.dmp, which
841 dnl may be examined by the commands in the second argument.
843 AC_DEFUN([gcc_AC_EXAMINE_OBJECT],
846 dnl Next bit cribbed from AC_TRY_COMPILE.
847 cat > conftest.$ac_ext <<EOF
848 [#line __oline__ "configure"
849 #include "confdefs.h"
852 if AC_TRY_EVAL(ac_compile); then
854 sed ['s/^[0-7]*[ ]*/ /
857 s/ [0-9][0-9][0-9]/./g
871 dnl Host endianness probe.
872 dnl This tests byte-within-word endianness. GCC actually needs
873 dnl to know word-within-larger-object endianness. They are the
874 dnl same on all presently supported hosts.
875 dnl Differs from AC_C_BIGENDIAN in that it does not require
876 dnl running a program on the host, and it defines the macro we
879 AC_DEFUN([gcc_AC_C_COMPILE_ENDIAN],
880 [AC_CACHE_CHECK(byte ordering, ac_cv_c_compile_endian,
881 [ac_cv_c_compile_endian=unknown
882 gcc_AC_EXAMINE_OBJECT([
886 /* This structure must have no internal padding. */
888 char prefix[sizeof "\nendian:" - 1];
893 #if SIZEOF_SHORT == 4
894 ('A' << (CHAR_BIT * 3)) | ('B' << (CHAR_BIT * 2)) |
896 ('A' << CHAR_BIT) | 'B',
899 [if grep 'endian:AB' conftest.dmp >/dev/null 2>&1; then
900 ac_cv_c_compile_endian=big-endian
901 elif grep 'endian:BA' conftest.dmp >/dev/null 2>&1; then
902 ac_cv_c_compile_endian=little-endian
905 if test $ac_cv_c_compile_endian = unknown; then
906 AC_MSG_ERROR([*** unable to determine endianness])
907 elif test $ac_cv_c_compile_endian = big-endian; then
908 AC_DEFINE(HOST_WORDS_BIG_ENDIAN, 1,
909 [Define if the host machine stores words of multi-word integers in