atomicity.h: Provide atomic __exchange_and_add and __atomic_add.
[official-gcc.git] / fastjar / acinclude.m4
blob0a45d735bd2f9c8f28945984aa50b753386017e7
2 dnl Host type sizes probe.
3 dnl By Kaveh R. Ghazi.  One typo fixed since.
4 dnl
5 AC_DEFUN([gcc_AC_COMPILE_CHECK_SIZEOF],
6 [changequote(<<, >>)dnl
7 dnl The name to #define.
8 define(<<AC_TYPE_NAME>>, translit(sizeof_$1, [a-z *], [A-Z_P]))dnl
9 dnl The cache variable name.
10 define(<<AC_CV_NAME>>, translit(ac_cv_sizeof_$1, [ *], [_p]))dnl
11 changequote([, ])dnl
12 AC_MSG_CHECKING(size of $1)
13 AC_CACHE_VAL(AC_CV_NAME,
14 [for ac_size in 4 8 1 2 16 $3 ; do # List sizes in rough order of prevalence.
15   AC_TRY_COMPILE([#include "confdefs.h"
16 #include <sys/types.h>
18 ], [switch (0) case 0: case (sizeof ($1) == $ac_size):;], AC_CV_NAME=$ac_size)
19   if test x$AC_CV_NAME != x ; then break; fi
20 done
22 if test x$AC_CV_NAME = x ; then
23   AC_MSG_ERROR([cannot determine a size for $1])
25 AC_MSG_RESULT($AC_CV_NAME)
26 AC_DEFINE_UNQUOTED(AC_TYPE_NAME, $AC_CV_NAME, [The number of bytes in type $1])
27 undefine([AC_TYPE_NAME])dnl
28 undefine([AC_CV_NAME])dnl
31 dnl Utility macro used by next two tests.
32 dnl AC_EXAMINE_OBJECT(C source code,
33 dnl     commands examining object file,
34 dnl     [commands to run if compile failed]):
35 dnl
36 dnl Compile the source code to an object file; then convert it into a
37 dnl printable representation.  All unprintable characters and
38 dnl asterisks (*) are replaced by dots (.).  All white space is
39 dnl deleted.  Newlines (ASCII 0x10) in the input are preserved in the
40 dnl output, but runs of newlines are compressed to a single newline.
41 dnl Finally, line breaks are forcibly inserted so that no line is
42 dnl longer than 80 columns and the file ends with a newline.  The
43 dnl result of all this processing is in the file conftest.dmp, which
44 dnl may be examined by the commands in the second argument.
45 dnl
46 AC_DEFUN([gcc_AC_EXAMINE_OBJECT],
47 [AC_LANG_SAVE
48 AC_LANG_C
49 dnl Next bit cribbed from AC_TRY_COMPILE.
50 cat > conftest.$ac_ext <<EOF
51 [#line __oline__ "configure"
52 #include "confdefs.h"
54 ]EOF
55 if AC_TRY_EVAL(ac_compile); then
56   od -c conftest.o |
57     sed ['s/^[0-7]*[    ]*/ /
58           s/\*/./g
59           s/ \\n/*/g
60           s/ [0-9][0-9][0-9]/./g
61           s/  \\[^ ]/./g'] |
62     tr -d '
63  ' | tr -s '*' '
64 ' | fold | sed '$a\
65 ' > conftest.dmp
66   $2
67 ifelse($3, , , else
68   $3
69 )dnl
71 rm -rf conftest*
72 AC_LANG_RESTORE])
74 dnl Host endianness probe.
75 dnl Differs from AC_C_BIGENDIAN in that it does not require
76 dnl running a program on the host.
77 dnl
78 AC_DEFUN([fastjar_AC_COMPILE_C_BIGENDIAN],
79 [AC_CACHE_CHECK(byte ordering, ac_cv_c_compile_endian,
80 [ac_cv_c_compile_endian=unknown
81 gcc_AC_EXAMINE_OBJECT([
82 #ifdef HAVE_LIMITS_H
83 # include <limits.h>
84 #endif
85 /* This structure must have no internal padding.  */
86   struct {
87     char prefix[sizeof "\nendian:" - 1];
88     short word;
89     char postfix[2];
90  } tester = {
91     "\nendian:",
92 #if SIZEOF_SHORT == 4
93     ('A' << (CHAR_BIT * 3)) | ('B' << (CHAR_BIT * 2)) |
94 #endif
95     ('A' << CHAR_BIT) | 'B',
96     'X', '\n'
97 };],
98  [if   grep 'endian:AB' conftest.dmp >/dev/null 2>&1; then
99     ac_cv_c_compile_endian=big-endian
100   elif grep 'endian:BA' conftest.dmp >/dev/null 2>&1; then
101     ac_cv_c_compile_endian=little-endian
102   fi])
104 if test $ac_cv_c_compile_endian = unknown; then
105   AC_MSG_ERROR([*** unable to determine endianness])
106 elif test $ac_cv_c_compile_endian = big-endian; then
107   AC_DEFINE(WORDS_BIG_ENDIAN, 1,
108   [Define if the host machine stores words of multi-word integers in
109    big-endian order.])
113 dnl Define MKDIR_TAKES_ONE_ARG if mkdir accepts only one argument instead
114 dnl of the usual 2.
115 AC_DEFUN(gcc_AC_FUNC_MKDIR_TAKES_ONE_ARG,
116 [AC_CACHE_CHECK([if mkdir takes one argument], gcc_cv_mkdir_takes_one_arg,
117 [AC_TRY_COMPILE([
118 #include <sys/types.h>
119 #ifdef HAVE_SYS_STAT_H
120 # include <sys/stat.h>
121 #endif
122 #ifdef HAVE_UNISTD_H
123 # include <unistd.h>
124 #endif
125 #ifdef HAVE_DIRECT_H
126 # include <direct.h>
127 #endif], [mkdir ("foo", 0);],
128          gcc_cv_mkdir_takes_one_arg=no, gcc_cv_mkdir_takes_one_arg=yes)])
129 if test $gcc_cv_mkdir_takes_one_arg = yes ; then
130    AC_DEFINE(MKDIR_TAKES_ONE_ARG, 1, [Define if host mkdir takes a
131 single argument.])