1 dnl See whether we can include both string.h and strings.h.
2 AC_DEFUN(gcc_AC_HEADER_STRING,
3 [AC_CACHE_CHECK([whether string.h and strings.h may both be included],
5 [AC_TRY_COMPILE([#include <string.h>
6 #include <strings.h>], , gcc_cv_header_string=yes, gcc_cv_header_string=no)])
7 if test $gcc_cv_header_string = yes; then
8 AC_DEFINE(STRING_WITH_STRINGS, 1, [Define if you can safely include both <string.h> and <strings.h>.])
12 dnl See whether we need a declaration for a function.
13 dnl The result is highly dependent on the INCLUDES passed in, so make sure
14 dnl to use a different cache variable name in this macro if it is invoked
15 dnl in a different context somewhere else.
16 dnl gcc_AC_CHECK_DECL(SYMBOL,
17 dnl [ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND [, INCLUDES]]])
18 AC_DEFUN(gcc_AC_CHECK_DECL,
19 [AC_MSG_CHECKING([whether $1 is declared])
20 AC_CACHE_VAL(gcc_cv_have_decl_$1,
23 char *(*pfn) = (char *(*)) $1 ;
24 #endif], eval "gcc_cv_have_decl_$1=yes", eval "gcc_cv_have_decl_$1=no")])
25 if eval "test \"`echo '$gcc_cv_have_decl_'$1`\" = yes"; then
26 AC_MSG_RESULT(yes) ; ifelse([$2], , :, [$2])
28 AC_MSG_RESULT(no) ; ifelse([$3], , :, [$3])
32 dnl Check multiple functions to see whether each needs a declaration.
33 dnl Arrange to define HAVE_DECL_<FUNCTION> to 0 or 1 as appropriate.
34 dnl gcc_AC_CHECK_DECLS(SYMBOLS,
35 dnl [ACTION-IF-NEEDED [, ACTION-IF-NOT-NEEDED [, INCLUDES]]])
36 AC_DEFUN(gcc_AC_CHECK_DECLS,
40 ac_tr_decl=HAVE_DECL_`echo $ac_func | tr 'abcdefghijklmnopqrstuvwxyz' 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'`
42 gcc_AC_CHECK_DECL($ac_func,
43 [AC_DEFINE_UNQUOTED($ac_tr_decl, 1) $2],
44 [AC_DEFINE_UNQUOTED($ac_tr_decl, 0) $3],
45 dnl It is possible that the include files passed in here are local headers
46 dnl which supply a backup declaration for the relevant prototype based on
47 dnl the definition of (or lack of) the HAVE_DECL_ macro. If so, this test
48 dnl will always return success. E.g. see libiberty.h's handling of
49 dnl `basename'. To avoid this, we define the relevant HAVE_DECL_ macro to
50 dnl 1 so that any local headers used do not provide their own prototype
57 dnl Automatically generate config.h entries via autoheader.
59 patsubst(translit([$1], [a-z], [A-Z]), [\w+],
60 [AC_DEFINE([HAVE_DECL_\&], 1,
61 [Define to 1 if we found this declaration otherwise define to 0.])])dnl
65 dnl See if symbolic links work and if not, try to substitute either hard links or simple copy.
66 AC_DEFUN(gcc_AC_PROG_LN_S,
67 [AC_MSG_CHECKING(whether ln -s works)
68 AC_CACHE_VAL(gcc_cv_prog_LN_S,
71 if ln -s conftestdata_f conftestdata_t 2>/dev/null
73 gcc_cv_prog_LN_S="ln -s"
75 if ln conftestdata_f conftestdata_t 2>/dev/null
82 rm -f conftestdata_f conftestdata_t
84 LN_S="$gcc_cv_prog_LN_S"
85 if test "$gcc_cv_prog_LN_S" = "ln -s"; then
88 if test "$gcc_cv_prog_LN_S" = "ln"; then
89 AC_MSG_RESULT([no, using ln])
91 AC_MSG_RESULT([no, and neither does ln, so using cp])
97 dnl See if hard links work and if not, try to substitute either symbolic links or simple copy.
98 AC_DEFUN(gcc_AC_PROG_LN,
99 [AC_MSG_CHECKING(whether ln works)
100 AC_CACHE_VAL(gcc_cv_prog_LN,
101 [rm -f conftestdata_t
103 if ln conftestdata_f conftestdata_t 2>/dev/null
107 if ln -s conftestdata_f conftestdata_t 2>/dev/null
109 gcc_cv_prog_LN="ln -s"
114 rm -f conftestdata_f conftestdata_t
117 if test "$gcc_cv_prog_LN" = "ln"; then
120 if test "$gcc_cv_prog_LN" = "ln -s"; then
121 AC_MSG_RESULT([no, using ln -s])
123 AC_MSG_RESULT([no, and neither does ln -s, so using cp])
129 dnl Define MKDIR_TAKES_ONE_ARG if mkdir accepts only one argument instead
131 AC_DEFUN(gcc_AC_FUNC_MKDIR_TAKES_ONE_ARG,
132 [AC_CACHE_CHECK([if mkdir takes one argument], gcc_cv_mkdir_takes_one_arg,
134 #include <sys/types.h>
135 #ifdef HAVE_SYS_STAT_H
136 # include <sys/stat.h>
143 #endif], [mkdir ("foo", 0);],
144 gcc_cv_mkdir_takes_one_arg=no, gcc_cv_mkdir_takes_one_arg=yes)])
145 if test $gcc_cv_mkdir_takes_one_arg = yes ; then
146 AC_DEFINE(MKDIR_TAKES_ONE_ARG, 1, [Define if host mkdir takes a single argument.])
150 AC_DEFUN(gcc_AC_PROG_INSTALL,
151 [AC_REQUIRE([AC_CONFIG_AUX_DIR_DEFAULT])dnl
152 # Find a good install program. We prefer a C program (faster),
153 # so one script is as good as another. But avoid the broken or
154 # incompatible versions:
155 # SysV /etc/install, /usr/sbin/install
156 # SunOS /usr/etc/install
159 # AFS /usr/afsws/bin/install, which mishandles nonexistent args
160 # SVR4 /usr/ucb/install, which tries to use the nonexistent group "staff"
161 # ./install, which can be erroneously created by make from ./install.sh.
162 AC_MSG_CHECKING(for a BSD compatible install)
163 if test -z "$INSTALL"; then
164 AC_CACHE_VAL(ac_cv_path_install,
165 [ IFS="${IFS= }"; ac_save_IFS="$IFS"; IFS="${IFS}:"
166 for ac_dir in $PATH; do
167 # Account for people who put trailing slashes in PATH elements.
169 /|./|.//|/etc/*|/usr/sbin/*|/usr/etc/*|/sbin/*|/usr/afsws/bin/*|/usr/ucb/*) ;;
171 # OSF1 and SCO ODT 3.0 have their own names for install.
172 for ac_prog in ginstall scoinst install; do
173 if test -f $ac_dir/$ac_prog; then
174 if test $ac_prog = install &&
175 grep dspmsg $ac_dir/$ac_prog >/dev/null 2>&1; then
176 # AIX install. It has an incompatible calling convention.
177 # OSF/1 installbsd also uses dspmsg, but is usable.
180 ac_cv_path_install="$ac_dir/$ac_prog -c"
190 if test "${ac_cv_path_install+set}" = set; then
191 INSTALL="$ac_cv_path_install"
193 # As a last resort, use the slow shell script. We don't cache a
194 # path for INSTALL within a source directory, because that will
195 # break other packages using the cache if that directory is
196 # removed, or if the path is relative.
197 INSTALL="$ac_install_sh"
200 dnl We do special magic for INSTALL instead of AC_SUBST, to get
201 dnl relative paths right.
202 AC_MSG_RESULT($INSTALL)
205 # Use test -z because SunOS4 sh mishandles braces in ${var-val}.
206 # It thinks the first close brace ends the variable substitution.
207 test -z "$INSTALL_PROGRAM" && INSTALL_PROGRAM='${INSTALL}'
208 AC_SUBST(INSTALL_PROGRAM)dnl
210 test -z "$INSTALL_DATA" && INSTALL_DATA='${INSTALL} -m 644'
211 AC_SUBST(INSTALL_DATA)dnl
215 dnl This test replaces the one in autoconf.
216 dnl Currently this macro should have the same name as the autoconf macro
217 dnl because gettext's gettext.m4 (distributed in the automake package)
218 dnl still uses it. Otherwise, the use in gettext.m4 makes autoheader
219 dnl give these diagnostics:
220 dnl configure.in:556: AC_TRY_COMPILE was called before AC_ISC_POSIX
221 dnl configure.in:556: AC_TRY_RUN was called before AC_ISC_POSIX
223 undefine([AC_ISC_POSIX])
224 AC_DEFUN(AC_ISC_POSIX,
226 dnl This test replaces the obsolescent AC_ISC_POSIX kludge.
227 AC_CHECK_LIB(cposix, strerror, [LIBS="$LIBS -lcposix"])
232 dnl GCC_PATH_PROG(VARIABLE, PROG-TO-CHECK-FOR [, VALUE-IF-NOT-FOUND [, PATH]])
233 dnl like AC_PATH_PROG but use other cache variables
234 AC_DEFUN(GCC_PATH_PROG,
235 [# Extract the first word of "$2", so it can be a program name with args.
236 set dummy $2; ac_word=[$]2
237 AC_MSG_CHECKING([for $ac_word])
238 AC_CACHE_VAL(gcc_cv_path_$1,
241 gcc_cv_path_$1="[$]$1" # Let the user override the test with a path.
244 gcc_cv_path_$1="[$]$1" # Let the user override the test with a dos path.
247 IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS=":"
248 dnl $ac_dummy forces splitting on constant user-supplied paths.
249 dnl POSIX.2 word splitting is done only on the output of word expansions,
250 dnl not every word. This closes a longstanding sh security hole.
251 ac_dummy="ifelse([$4], , $PATH, [$4])"
252 for ac_dir in $ac_dummy; do
253 test -z "$ac_dir" && ac_dir=.
254 if test -f $ac_dir/$ac_word; then
255 gcc_cv_path_$1="$ac_dir/$ac_word"
260 dnl If no 3rd arg is given, leave the cache variable unset,
261 dnl so GCC_PATH_PROGS will keep looking.
262 ifelse([$3], , , [ test -z "[$]gcc_cv_path_$1" && gcc_cv_path_$1="$3"
267 if test -n "[$]$1"; then
277 dnl GCC_PATH_PROG_WITH_TEST(VARIABLE, PROG-TO-CHECK-FOR,
278 dnl TEST-PERFORMED-ON-FOUND_PROGRAM [, VALUE-IF-NOT-FOUND [, PATH]])
279 AC_DEFUN(GCC_PATH_PROG_WITH_TEST,
280 [# Extract the first word of "$2", so it can be a program name with args.
281 set dummy $2; ac_word=[$]2
282 AC_MSG_CHECKING([for $ac_word])
283 AC_CACHE_VAL(gcc_cv_path_$1,
286 gcc_cv_path_$1="[$]$1" # Let the user override the test with a path.
289 IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS="${IFS}:"
290 for ac_dir in ifelse([$5], , $PATH, [$5]); do
291 test -z "$ac_dir" && ac_dir=.
292 if test -f $ac_dir/$ac_word; then
294 gcc_cv_path_$1="$ac_dir/$ac_word"
300 dnl If no 4th arg is given, leave the cache variable unset,
301 dnl so GCC_PATH_PROGS will keep looking.
302 ifelse([$4], , , [ test -z "[$]gcc_cv_path_$1" && gcc_cv_path_$1="$4"
307 if test -n "[$]$1"; then
315 # Check whether mmap can map an arbitrary page from /dev/zero or with
316 # MAP_ANONYMOUS, without MAP_FIXED.
317 AC_DEFUN([AC_FUNC_MMAP_ANYWHERE],
318 [AC_CHECK_FUNCS(getpagesize)
319 # The test program for the next two tests is the same except for one
321 changequote({{{,}}})dnl
322 {{{cat >ct-mmap.inc <<'EOF'
323 #include <sys/types.h>
324 #include <sys/mman.h>
330 #if !defined (MAP_ANONYMOUS) && defined (MAP_ANON)
331 # define MAP_ANONYMOUS MAP_ANON
334 /* This mess was copied from the GNU getpagesize.h. */
335 #ifndef HAVE_GETPAGESIZE
336 # ifdef HAVE_UNISTD_H
340 /* Assume that all systems that can run configure have sys/param.h. */
341 # ifndef HAVE_SYS_PARAM_H
342 # define HAVE_SYS_PARAM_H 1
346 # define getpagesize() sysconf(_SC_PAGESIZE)
347 # else /* no _SC_PAGESIZE */
348 # ifdef HAVE_SYS_PARAM_H
349 # include <sys/param.h>
350 # ifdef EXEC_PAGESIZE
351 # define getpagesize() EXEC_PAGESIZE
352 # else /* no EXEC_PAGESIZE */
354 # define getpagesize() NBPG * CLSIZE
357 # endif /* no CLSIZE */
360 # define getpagesize() NBPC
363 # define getpagesize() PAGESIZE
364 # endif /* PAGESIZE */
365 # endif /* no NBPC */
366 # endif /* no NBPG */
367 # endif /* no EXEC_PAGESIZE */
368 # else /* no HAVE_SYS_PARAM_H */
369 # define getpagesize() 8192 /* punt totally */
370 # endif /* no HAVE_SYS_PARAM_H */
371 # endif /* no _SC_PAGESIZE */
373 #endif /* no HAVE_GETPAGESIZE */
376 # define MAP_FAILED -1
380 #define perror_exit(str, val) \
381 do { perror(str); exit(val); } while (0)
383 /* Some versions of cygwin mmap require that munmap is called with the
384 same parameters as mmap. GCC expects that this is not the case.
385 Test for various forms of this problem. Warning - icky signal games. */
387 static sigset_t unblock_sigsegv;
397 return (char *) mmap (0, size, PROT_READ|PROT_WRITE,
398 MAP_PRIVATE|MAP_ANONYMOUS, -1, 0);
400 return (char *) mmap (0, size, PROT_READ|PROT_WRITE,
401 MAP_PRIVATE, devzero, 0);
409 sigprocmask (SIG_UNBLOCK, &unblock_sigsegv, 0);
413 /* Basic functionality test. */
417 char *x = anonmap (pg);
418 if (x == (char *) MAP_FAILED)
419 perror_exit("test 0 mmap", 2);
423 if (munmap(x, pg) < 0)
424 perror_exit("test 0 munmap", 3);
427 /* 1. If we map a 2-page region and unmap its second page, the first page
432 char *x = anonmap (pg * 2);
433 if (x == (char *)MAP_FAILED)
434 perror_exit ("test 1 mmap", 4);
436 signal (SIGSEGV, sigsegv);
438 perror_exit ("test 1 fault", 5);
443 if (munmap (x + pg, pg) < 0)
444 perror_exit ("test 1 munmap 1", 6);
450 perror_exit ("test 1 no fault", 7);
452 if (munmap (x, pg) < 0)
453 perror_exit ("test 1 munmap 2", 8);
456 /* 2. If we map a 2-page region and unmap its first page, the second
461 char *x = anonmap (pg * 2);
462 if (x == (char *)MAP_FAILED)
463 perror_exit ("test 2 mmap", 9);
465 signal (SIGSEGV, sigsegv);
467 perror_exit ("test 2 fault", 10);
472 if (munmap (x, pg) < 0)
473 perror_exit ("test 2 munmap 1", 11);
480 perror_exit ("test 2 no fault", 12);
483 if (munmap (x+pg, pg) < 0)
484 perror_exit ("test 2 munmap 2", 13);
487 /* 3. If we map two adjacent 1-page regions and unmap them both with
488 one munmap, both must go away.
490 Getting two adjacent 1-page regions with two mmap calls is slightly
491 tricky. All OS's tested skip over already-allocated blocks; therefore
492 we have been careful to unmap all allocated regions in previous tests.
493 HP/UX allocates pages backward in memory. No OS has yet been observed
494 to be so perverse as to leave unmapped space between consecutive calls
503 if (x == (char *)MAP_FAILED)
504 perror_exit ("test 3 mmap 1", 14);
506 if (y == (char *)MAP_FAILED)
507 perror_exit ("test 3 mmap 2", 15);
515 fprintf (stderr, "test 3 nonconsecutive pages - %lx, %lx\n",
516 (unsigned long)x, (unsigned long)y);
521 signal (SIGSEGV, sigsegv);
523 perror_exit ("test 3 fault", 17);
528 if (munmap (x, pg*2) < 0)
529 perror_exit ("test 3 munmap", 18);
534 perror_exit ("test 3 no fault 1", 19);
537 signal (SIGSEGV, sigsegv);
541 perror_exit ("test 3 no fault 2", 20);
548 sigemptyset (&unblock_sigsegv);
549 sigaddset (&unblock_sigsegv, SIGSEGV);
552 devzero = open ("/dev/zero", O_RDWR);
554 perror_exit ("open /dev/zero", 1);
567 AC_CACHE_CHECK(for working mmap from /dev/zero,
568 ac_cv_func_mmap_dev_zero,
570 [#include "ct-mmap.inc"],
571 ac_cv_func_mmap_dev_zero=yes,
573 then ac_cv_func_mmap_dev_zero=no
574 else ac_cv_func_mmap_dev_zero=buggy
576 # If this is not cygwin, and /dev/zero is a character device, it's probably
577 # safe to assume it works.
579 cygwin* | win32 | pe | mingw* ) ac_cv_func_mmap_dev_zero=buggy ;;
580 * ) if test -c /dev/zero
581 then ac_cv_func_mmap_dev_zero=yes
582 else ac_cv_func_mmap_dev_zero=no
586 if test $ac_cv_func_mmap_dev_zero = yes; then
587 AC_DEFINE(HAVE_MMAP_DEV_ZERO, 1,
588 [Define if mmap can get us zeroed pages from /dev/zero.])
591 AC_CACHE_CHECK([for working mmap with MAP_ANON(YMOUS)],
592 ac_cv_func_mmap_anon,
594 [#define USE_MAP_ANON
595 #include "ct-mmap.inc"],
596 ac_cv_func_mmap_anon=yes,
598 then ac_cv_func_mmap_anon=no
599 else ac_cv_func_mmap_anon=buggy
601 # Unlike /dev/zero, it is not safe to assume MAP_ANON(YMOUS) works
602 # just because it's there. Some SCO Un*xen define it but don't implement it.
603 ac_cv_func_mmap_anon=no)
605 if test $ac_cv_func_mmap_anon = yes; then
606 AC_DEFINE(HAVE_MMAP_ANON, 1,
607 [Define if mmap can get us zeroed pages using MAP_ANON(YMOUS).])
612 # Check whether mmap can map a plain file, without MAP_FIXED.
613 AC_DEFUN([AC_FUNC_MMAP_FILE],
614 [AC_CACHE_CHECK(for working mmap of a file, ac_cv_func_mmap_file,
615 [# Create a file one thousand bytes long.
616 for i in 1 2 3 4 5 6 7 8 9 0
617 do for j in 1 2 3 4 5 6 7 8 9 0
620 done > conftestdata$$
623 /* Test by Zack Weinberg. Modified from MMAP_ANYWHERE test by
624 Richard Henderson and Alexandre Oliva.
625 Check whether read-only mmap of a plain file works. */
626 #include <sys/types.h>
627 #include <sys/stat.h>
629 #include <sys/mman.h>
637 fd = open("conftestdata$$", O_RDONLY);
644 x = (char*)mmap(0, st.st_size, PROT_READ, MAP_PRIVATE, fd, 0);
645 if (x == (char *) -1)
648 if (x[0] != '1' || x[1] != ' ' || x[2] != '1' || x[3] != ' ')
651 if (munmap(x, st.st_size) < 0)
655 }], ac_cv_func_mmap_file=yes, ac_cv_func_mmap_file=no,
656 ac_cv_func_mmap_file=no)])
657 if test $ac_cv_func_mmap_file = yes; then
658 AC_DEFINE(HAVE_MMAP_FILE, 1,
659 [Define if read-only mmap of a plain file works.])
663 dnl Locate a program and check that its version is acceptable.
664 dnl AC_PROG_CHECK_VER(var, name, version-switch,
665 dnl version-extract-regexp, version-glob)
666 AC_DEFUN(gcc_AC_CHECK_PROG_VER,
667 [AC_CHECK_PROG([$1], [$2], [$2])
668 if test -n "[$]$1"; then
669 # Found it, now check the version.
670 AC_CACHE_CHECK(for modern $2, gcc_cv_prog_$2_modern,
671 [changequote(<<,>>)dnl
672 ac_prog_version=`<<$>>$1 $3 2>&1 |
673 sed -n 's/^.*patsubst(<<$4>>,/,\/).*$/\1/p'`
675 echo "configure:__oline__: version of $2 is $ac_prog_version" >&AC_FD_CC
676 changequote(<<,>>)dnl
677 case $ac_prog_version in
678 '') gcc_cv_prog_$2_modern=no;;
680 gcc_cv_prog_$2_modern=yes;;
681 *) gcc_cv_prog_$2_modern=no;;
686 gcc_cv_prog_$2_modern=no
690 dnl Determine if enumerated bitfields are unsigned. ISO C says they can
691 dnl be either signed or unsigned.
693 AC_DEFUN(gcc_AC_C_ENUM_BF_UNSIGNED,
694 [AC_CACHE_CHECK(for unsigned enumerated bitfields, gcc_cv_enum_bf_unsigned,
695 [AC_TRY_RUN(#include <stdlib.h>
696 enum t { BLAH = 128 } ;
697 struct s_t { enum t member : 8; } s ;
701 if (s.member < 0) exit(1);
704 }, gcc_cv_enum_bf_unsigned=yes, gcc_cv_enum_bf_unsigned=no, gcc_cv_enum_bf_unsigned=yes)])
705 if test $gcc_cv_enum_bf_unsigned = yes; then
706 AC_DEFINE(ENUM_BITFIELDS_ARE_UNSIGNED, 1,
707 [Define if enumerated bitfields are treated as unsigned values.])
710 dnl Host type sizes probe.
711 dnl By Kaveh R. Ghazi. One typo fixed since.
713 AC_DEFUN([gcc_AC_COMPILE_CHECK_SIZEOF],
714 [changequote(<<, >>)dnl
715 dnl The name to #define.
716 define(<<AC_TYPE_NAME>>, translit(sizeof_$1, [a-z *], [A-Z_P]))dnl
717 dnl The cache variable name.
718 define(<<AC_CV_NAME>>, translit(ac_cv_sizeof_$1, [ *], [_p]))dnl
720 AC_MSG_CHECKING(size of $1)
721 AC_CACHE_VAL(AC_CV_NAME,
722 [for ac_size in 4 8 1 2 16 $3 ; do # List sizes in rough order of prevalence.
723 AC_TRY_COMPILE([#include "confdefs.h"
724 #include <sys/types.h>
726 ], [switch (0) case 0: case (sizeof ($1) == $ac_size):;], AC_CV_NAME=$ac_size)
727 if test x$AC_CV_NAME != x ; then break; fi
730 if test x$AC_CV_NAME = x ; then
731 AC_MSG_ERROR([cannot determine a size for $1])
733 AC_MSG_RESULT($AC_CV_NAME)
734 AC_DEFINE_UNQUOTED(AC_TYPE_NAME, $AC_CV_NAME, [The number of bytes in type $1])
735 undefine([AC_TYPE_NAME])dnl
736 undefine([AC_CV_NAME])dnl
739 dnl Probe number of bits in a byte.
740 dnl Note C89 requires CHAR_BIT >= 8.
742 AC_DEFUN(gcc_AC_C_CHAR_BIT,
743 [AC_CACHE_CHECK(for CHAR_BIT, gcc_cv_decl_char_bit,
745 [#ifdef HAVE_LIMITS_H
750 #endif], gcc_cv_decl_char_bit=yes, gcc_cv_decl_char_bit=no)
752 if test $gcc_cv_decl_char_bit = no; then
753 AC_CACHE_CHECK(number of bits in a byte, gcc_cv_c_nbby,
756 while test $i -lt 65; do
759 case (unsigned char)((unsigned long)1 << $i) == ((unsigned long)1 << $i):
760 case (unsigned char)((unsigned long)1<<($i-1)) == ((unsigned long)1<<($i-1)):
762 [gcc_cv_c_nbby=$i; break])
765 test -z "$gcc_cv_c_nbby" && gcc_cv_c_nbby=failed
767 if test $gcc_cv_c_nbby = failed; then
768 AC_MSG_ERROR(cannot determine number of bits in a byte)
770 AC_DEFINE_UNQUOTED(CHAR_BIT, $gcc_cv_c_nbby,
771 [Define as the number of bits in a byte, if \`limits.h' doesn't.])
775 dnl Host character set probe.
776 dnl The EBCDIC values match the table in config/i370/i370.c;
777 dnl there are other versions of EBCDIC but GCC won't work with them.
779 AC_DEFUN([gcc_AC_C_CHARSET],
780 [AC_CACHE_CHECK(execution character set, ac_cv_c_charset,
782 [#if '\n' == 0x0A && ' ' == 0x20 && '0' == 0x30 \
783 && 'A' == 0x41 && 'a' == 0x61 && '!' == 0x21
785 #endif], ac_cv_c_charset=ASCII)
786 if test x${ac_cv_c_charset+set} != xset; then
788 [#if '\n' == 0x15 && ' ' == 0x40 && '0' == 0xF0 \
789 && 'A' == 0xC1 && 'a' == 0x81 && '!' == 0x5A
791 #endif], ac_cv_c_charset=EBCDIC)
793 if test x${ac_cv_c_charset+set} != xset; then
794 ac_cv_c_charset=unknown
796 if test $ac_cv_c_charset = unknown; then
797 AC_MSG_ERROR([*** Cannot determine host character set.])
798 elif test $ac_cv_c_charset = EBCDIC; then
799 AC_DEFINE(HOST_EBCDIC, 1,
800 [Define if the host execution character set is EBCDIC.])
803 dnl Utility macro used by next two tests.
804 dnl AC_EXAMINE_OBJECT(C source code,
805 dnl commands examining object file,
806 dnl [commands to run if compile failed]):
808 dnl Compile the source code to an object file; then convert it into a
809 dnl printable representation. All unprintable characters and
810 dnl asterisks (*) are replaced by dots (.). All white space is
811 dnl deleted. Newlines (ASCII 0x10) in the input are preserved in the
812 dnl output, but runs of newlines are compressed to a single newline.
813 dnl Finally, line breaks are forcibly inserted so that no line is
814 dnl longer than 80 columns and the file ends with a newline. The
815 dnl result of all this processing is in the file conftest.dmp, which
816 dnl may be examined by the commands in the second argument.
818 AC_DEFUN([gcc_AC_EXAMINE_OBJECT],
821 dnl Next bit cribbed from AC_TRY_COMPILE.
822 cat > conftest.$ac_ext <<EOF
823 [#line __oline__ "configure"
824 #include "confdefs.h"
827 if AC_TRY_EVAL(ac_compile); then
829 sed ['s/^[0-7]*[ ]*/ /
832 s/ [0-9][0-9][0-9]/./g
846 dnl Host endianness probe.
847 dnl This tests byte-within-word endianness. GCC actually needs
848 dnl to know word-within-larger-object endianness. They are the
849 dnl same on all presently supported hosts.
850 dnl Differs from AC_C_BIGENDIAN in that it does not require
851 dnl running a program on the host, and it defines the macro we
854 AC_DEFUN([gcc_AC_C_COMPILE_ENDIAN],
855 [AC_CACHE_CHECK(byte ordering, ac_cv_c_compile_endian,
856 [ac_cv_c_compile_endian=unknown
857 gcc_AC_EXAMINE_OBJECT([
861 /* This structure must have no internal padding. */
863 char prefix[sizeof "\nendian:" - 1];
868 #if SIZEOF_SHORT == 4
869 ('A' << (CHAR_BIT * 3)) | ('B' << (CHAR_BIT * 2)) |
871 ('A' << CHAR_BIT) | 'B',
874 [if grep 'endian:AB' conftest.dmp >/dev/null 2>&1; then
875 ac_cv_c_compile_endian=big-endian
876 elif grep 'endian:BA' conftest.dmp >/dev/null 2>&1; then
877 ac_cv_c_compile_endian=little-endian
880 if test $ac_cv_c_compile_endian = unknown; then
881 AC_MSG_ERROR([*** unable to determine endianness])
882 elif test $ac_cv_c_compile_endian = big-endian; then
883 AC_DEFINE(HOST_WORDS_BIG_ENDIAN, 1,
884 [Define if the host machine stores words of multi-word integers in