1 # Macros to detect C compiler features
2 # $Header: /cvsroot/pgsql/config/c-compiler.m4,v 1.3 2000/08/29 09:36:37 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])
22 # Check if the C compiler understands `volatile'. Note that if it doesn't
23 # then this will potentially break the program semantics.
24 AC_DEFUN([PGAC_C_VOLATILE],
25 [AC_CACHE_CHECK(for volatile, pgac_cv_c_volatile,
27 [extern volatile int i;],
28 [pgac_cv_c_volatile=yes],
29 [pgac_cv_c_volatile=no])])
30 if test x"$pgac_cv_c_volatile" = xno ; then
31 AC_DEFINE(volatile,, [Define empty if the C compiler does not understand `volatile'])
36 # PGAC_TYPE_64BIT_INT(TYPE)
37 # -------------------------
38 # Check if TYPE is a working 64 bit integer type. Set HAVE_TYPE_64 to
39 # yes or no respectively, and define HAVE_TYPE_64 if yes.
40 AC_DEFUN([PGAC_TYPE_64BIT_INT],
41 [define([Ac_define], [translit([have_$1_64], [a-z *], [A-Z_P])])dnl
42 define([Ac_cachevar], [translit([pgac_cv_type_$1_64], [ *], [_p])])dnl
43 AC_CACHE_CHECK([whether $1 is 64 bits], [Ac_cachevar],
48 * These are globals to discourage the compiler from folding all the
49 * arithmetic tests down to compile-time constants.
58 if (sizeof(int64) != 8)
59 return 0; /* definitely not the right size */
61 /* Do perfunctory checks to see if 64-bit arithmetic seems to work */
69 exit(! does_int64_work());
74 dnl We will do better here with Autoconf 2.50
75 AC_MSG_WARN([64 bit arithmetic disabled when cross-compiling])])])
77 Ac_define=$Ac_cachevar
78 if test x"$Ac_cachevar" = xyes ; then
79 AC_DEFINE(Ac_define,, [Set to 1 if `]$1[' is 64 bits])
81 undefine([Ac_define])dnl
82 undefine([Ac_cachevar])dnl
83 ])# PGAC_TYPE_64BIT_INT
87 # PGAC_CHECK_ALIGNOF(TYPE)
88 # ------------------------
89 # Find the alignment requirement of the given type. Define the result
90 # as ALIGNOF_TYPE. If cross-compiling, sizeof(type) is used as a
93 # This is modeled on the standard autoconf macro AC_CHECK_SIZEOF.
94 # That macro never got any points for style.
95 AC_DEFUN([PGAC_CHECK_ALIGNOF],
96 [changequote(<<, >>)dnl
97 dnl The name to #define.
98 define(<<AC_TYPE_NAME>>, translit(alignof_$1, [a-z *], [A-Z_P]))dnl
99 dnl The cache variable name.
100 define(<<AC_CV_NAME>>, translit(pgac_cv_alignof_$1, [ *], [_p]))dnl
102 AC_MSG_CHECKING(alignment of $1)
103 AC_CACHE_VAL(AC_CV_NAME,
104 [AC_TRY_RUN([#include <stdio.h>
105 struct { char filler; $1 field; } mystruct;
108 FILE *f=fopen("conftestval", "w");
110 fprintf(f, "%d\n", ((char*) & mystruct.field) - ((char*) & mystruct));
112 }], AC_CV_NAME=`cat conftestval`,
113 AC_CV_NAME='sizeof($1)',
114 AC_CV_NAME='sizeof($1)')])dnl
115 AC_MSG_RESULT($AC_CV_NAME)
116 AC_DEFINE_UNQUOTED(AC_TYPE_NAME, $AC_CV_NAME, [The alignment requirement of a `]$1['])
117 undefine([AC_TYPE_NAME])dnl
118 undefine([AC_CV_NAME])dnl
119 ])# PGAC_CHECK_ALIGNOF