1 # Macros to detect C compiler features
2 # $Header: /cvsroot/pgsql/config/c-compiler.m4,v 1.6 2003/01/28 21:57:12 petere Exp $
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 empty if the C compiler does not understand signed types])
20 # PGAC_TYPE_64BIT_INT(TYPE)
21 # -------------------------
22 # Check if TYPE is a working 64 bit integer type. Set HAVE_TYPE_64 to
23 # yes or no respectively, and define HAVE_TYPE_64 if yes.
24 AC_DEFUN([PGAC_TYPE_64BIT_INT],
25 [define([Ac_define], [translit([have_$1_64], [a-z *], [A-Z_P])])dnl
26 define([Ac_cachevar], [translit([pgac_cv_type_$1_64], [ *], [_p])])dnl
27 AC_CACHE_CHECK([whether $1 is 64 bits], [Ac_cachevar],
32 * These are globals to discourage the compiler from folding all the
33 * arithmetic tests down to compile-time constants.
42 if (sizeof(int64) != 8)
43 return 0; /* definitely not the right size */
45 /* Do perfunctory checks to see if 64-bit arithmetic seems to work */
53 exit(! does_int64_work());
57 [# If cross-compiling, check the size reported by the compiler and
58 # trust that the arithmetic works.
59 AC_COMPILE_IFELSE([AC_LANG_BOOL_COMPILE_TRY([], [sizeof($1) == 8])],
63 Ac_define=$Ac_cachevar
64 if test x"$Ac_cachevar" = xyes ; then
65 AC_DEFINE(Ac_define,, [Set to 1 if `]$1[' is 64 bits])
67 undefine([Ac_define])dnl
68 undefine([Ac_cachevar])dnl
69 ])# PGAC_TYPE_64BIT_INT
73 # PGAC_CHECK_ALIGNOF(TYPE, [INCLUDES = DEFAULT-INCLUDES])
74 # -----------------------------------------------------
75 # Find the alignment requirement of the given type. Define the result
76 # as ALIGNOF_TYPE. This macro works even when cross compiling.
77 # (Modelled after AC_CHECK_SIZEOF.)
79 AC_DEFUN([PGAC_CHECK_ALIGNOF],
80 [AS_LITERAL_IF([$1], [],
81 [AC_FATAL([$0: requires literal arguments])])dnl
82 AC_CHECK_TYPE([$1], [], [], [$2])
83 AC_CACHE_CHECK([alignment of $1], [AS_TR_SH([pgac_cv_alignof_$1])],
84 [if test "$AS_TR_SH([ac_cv_type_$1])" = yes; then
85 _AC_COMPUTE_INT([((char*) & pgac_struct.field) - ((char*) & pgac_struct)],
86 [AS_TR_SH([pgac_cv_alignof_$1])],
87 [AC_INCLUDES_DEFAULT([$2])
88 struct { char filler; $1 field; } pgac_struct;],
89 [AC_MSG_ERROR([cannot compute alignment of $1, 77])])
91 AS_TR_SH([pgac_cv_alignof_$1])=0
93 AC_DEFINE_UNQUOTED(AS_TR_CPP(alignof_$1),
94 [$AS_TR_SH([pgac_cv_alignof_$1])],
95 [The alignment requirement of a `$1'])
96 ])# PGAC_CHECK_ALIGNOF