1 # Macros to detect C compiler features
7 # Check if the C compiler understands signed types.
8 AC_DEFUN([PGAC_C_SIGNED],
9 [AC_CACHE_CHECK(for signed types, pgac_cv_c_signed,
11 [signed char c; signed short s; signed int i;],
12 [pgac_cv_c_signed=yes],
13 [pgac_cv_c_signed=no])])
14 if test x"$pgac_cv_c_signed" = xno ; then
15 AC_DEFINE(signed,, [Define to empty if the C compiler does not understand signed types.])
22 # Check if the C compiler understands inline functions.
23 # Defines: inline, USE_INLINE
24 AC_DEFUN([PGAC_C_INLINE],
26 AC_CACHE_CHECK([for quiet inline (no complaint if unreferenced)], pgac_cv_c_inline_quietly,
27 [pgac_cv_c_inline_quietly=no
28 if test "$ac_cv_c_inline" != no; then
29 pgac_c_inline_save_werror=$ac_c_werror_flag
31 AC_LINK_IFELSE([AC_LANG_PROGRAM([static inline int fun () {return 0;}],[])],
32 [pgac_cv_c_inline_quietly=yes])
33 ac_c_werror_flag=$pgac_c_inline_save_werror
35 if test "$pgac_cv_c_inline_quietly" != no; then
36 AC_DEFINE_UNQUOTED([USE_INLINE], 1,
37 [Define to 1 if "static inline" works without unwanted warnings from ]
38 [compilations where static inline functions are defined but not called.])
44 # PGAC_TYPE_64BIT_INT(TYPE)
45 # -------------------------
46 # Check if TYPE is a working 64 bit integer type. Set HAVE_TYPE_64 to
47 # yes or no respectively, and define HAVE_TYPE_64 if yes.
48 AC_DEFUN([PGAC_TYPE_64BIT_INT],
49 [define([Ac_define], [translit([have_$1_64], [a-z *], [A-Z_P])])dnl
50 define([Ac_cachevar], [translit([pgac_cv_type_$1_64], [ *], [_p])])dnl
51 AC_CACHE_CHECK([whether $1 is 64 bits], [Ac_cachevar],
56 * These are globals to discourage the compiler from folding all the
57 * arithmetic tests down to compile-time constants.
59 ac_int64 a = 20000001;
60 ac_int64 b = 40000005;
66 if (sizeof(ac_int64) != 8)
67 return 0; /* definitely not the right size */
69 /* Do perfunctory checks to see if 64-bit arithmetic seems to work */
77 exit(! does_int64_work());
81 [# If cross-compiling, check the size reported by the compiler and
82 # trust that the arithmetic works.
83 AC_COMPILE_IFELSE([AC_LANG_BOOL_COMPILE_TRY([], [sizeof($1) == 8])],
87 Ac_define=$Ac_cachevar
88 if test x"$Ac_cachevar" = xyes ; then
89 AC_DEFINE(Ac_define, 1, [Define to 1 if `]$1[' works and is 64 bits.])
91 undefine([Ac_define])dnl
92 undefine([Ac_cachevar])dnl
93 ])# PGAC_TYPE_64BIT_INT
97 # PGAC_C_FUNCNAME_SUPPORT
98 # -----------------------
99 # Check if the C compiler understands __func__ (C99) or __FUNCTION__ (gcc).
100 # Define HAVE_FUNCNAME__FUNC or HAVE_FUNCNAME__FUNCTION accordingly.
101 AC_DEFUN([PGAC_C_FUNCNAME_SUPPORT],
102 [AC_CACHE_CHECK(for __func__, pgac_cv_funcname_func_support,
103 [AC_TRY_COMPILE([#include <stdio.h>],
104 [printf("%s\n", __func__);],
105 [pgac_cv_funcname_func_support=yes],
106 [pgac_cv_funcname_func_support=no])])
107 if test x"$pgac_cv_funcname_func_support" = xyes ; then
108 AC_DEFINE(HAVE_FUNCNAME__FUNC, 1,
109 [Define to 1 if your compiler understands __func__.])
111 AC_CACHE_CHECK(for __FUNCTION__, pgac_cv_funcname_function_support,
112 [AC_TRY_COMPILE([#include <stdio.h>],
113 [printf("%s\n", __FUNCTION__);],
114 [pgac_cv_funcname_function_support=yes],
115 [pgac_cv_funcname_function_support=no])])
116 if test x"$pgac_cv_funcname_function_support" = xyes ; then
117 AC_DEFINE(HAVE_FUNCNAME__FUNCTION, 1,
118 [Define to 1 if your compiler understands __FUNCTION__.])
120 fi])# PGAC_C_FUNCNAME_SUPPORT
124 # PGAC_PROG_CC_CFLAGS_OPT
125 # -----------------------
126 # Given a string, check if the compiler supports the string as a
127 # command-line option. If it does, add the string to CFLAGS.
128 AC_DEFUN([PGAC_PROG_CC_CFLAGS_OPT],
129 [define([Ac_cachevar], [AS_TR_SH([pgac_cv_prog_cc_cflags_$1])])dnl
130 AC_CACHE_CHECK([whether $CC supports $1], [Ac_cachevar],
131 [pgac_save_CFLAGS=$CFLAGS
132 CFLAGS="$pgac_save_CFLAGS $1"
133 ac_save_c_werror_flag=$ac_c_werror_flag
135 _AC_COMPILE_IFELSE([AC_LANG_PROGRAM()],
138 ac_c_werror_flag=$ac_save_c_werror_flag
139 CFLAGS="$pgac_save_CFLAGS"])
140 if test x"$Ac_cachevar" = x"yes"; then
143 undefine([Ac_cachevar])dnl
144 ])# PGAC_PROG_CC_CFLAGS_OPT
148 # PGAC_PROG_CC_LDFLAGS_OPT
149 # ------------------------
150 # Given a string, check if the compiler supports the string as a
151 # command-line option. If it does, add the string to LDFLAGS.
152 # For reasons you'd really rather not know about, this checks whether
153 # you can link to a particular function, not just whether you can link.
154 # In fact, we must actually check that the resulting program runs :-(
155 AC_DEFUN([PGAC_PROG_CC_LDFLAGS_OPT],
156 [define([Ac_cachevar], [AS_TR_SH([pgac_cv_prog_cc_ldflags_$1])])dnl
157 AC_CACHE_CHECK([whether $CC supports $1], [Ac_cachevar],
158 [pgac_save_LDFLAGS=$LDFLAGS
159 LDFLAGS="$pgac_save_LDFLAGS $1"
160 AC_RUN_IFELSE([AC_LANG_PROGRAM([extern void $2 (); void (*fptr) () = $2;],[])],
163 [Ac_cachevar="assuming no"])
164 LDFLAGS="$pgac_save_LDFLAGS"])
165 if test x"$Ac_cachevar" = x"yes"; then
166 LDFLAGS="$LDFLAGS $1"
168 undefine([Ac_cachevar])dnl
169 ])# PGAC_PROG_CC_LDFLAGS_OPT