diff options
| author | Tom Lane | 1999-03-25 19:05:19 +0000 |
|---|---|---|
| committer | Tom Lane | 1999-03-25 19:05:19 +0000 |
| commit | 1e117923aa03a58d3c4b55b84b564aeaf681449d (patch) | |
| tree | 66760832e628038ceca85c49c0f2ad8935781782 /src/configure.in | |
| parent | 235a569aaa422711238bc060381f2c9977537126 (diff) | |
Revise memutils.h to use alignment information gathered by
configure, instead of having a bunch of crufty platform-specific guesses.
Diffstat (limited to 'src/configure.in')
| -rw-r--r-- | src/configure.in | 64 |
1 files changed, 64 insertions, 0 deletions
diff --git a/src/configure.in b/src/configure.in index 091346153e4..92ff0135385 100644 --- a/src/configure.in +++ b/src/configure.in @@ -896,6 +896,70 @@ fi AC_DEFINE_UNQUOTED(INT64_FORMAT, $INT64_FORMAT) +dnl Determine memory alignment requirements for the basic C datatypes. + +dnl CHECK_ALIGNOF(TYPE) +dnl This is modeled on the standard autoconf macro AC_CHECK_SIZEOF, +dnl except it finds the alignment requirement of the type instead of the size. +dnl The defined symbol is named ALIGNOF_TYPE, where the type name is +dnl converted in the same way as for AC_CHECK_SIZEOF. +dnl If cross-compiling, sizeof(type) is used as a default assumption. + +AC_DEFUN(CHECK_ALIGNOF, +[changequote(<<, >>)dnl +dnl The name to #define. +define(<<AC_TYPE_NAME>>, translit(alignof_$1, [a-z *], [A-Z_P]))dnl +dnl The cache variable name. +define(<<AC_CV_NAME>>, translit(ac_cv_alignof_$1, [ *], [_p]))dnl +changequote([, ])dnl +AC_MSG_CHECKING(alignment of $1) +AC_CACHE_VAL(AC_CV_NAME, +[AC_TRY_RUN([#include <stdio.h> +struct { char filler; $1 field; } mystruct; +main() +{ + FILE *f=fopen("conftestval", "w"); + if (!f) exit(1); + fprintf(f, "%d\n", ((char*) & mystruct.field) - ((char*) & mystruct)); + exit(0); +}], AC_CV_NAME=`cat conftestval`, +AC_CV_NAME='sizeof($1)', +AC_CV_NAME='sizeof($1)')])dnl +AC_MSG_RESULT($AC_CV_NAME) +AC_DEFINE_UNQUOTED(AC_TYPE_NAME, $AC_CV_NAME) +undefine([AC_TYPE_NAME])dnl +undefine([AC_CV_NAME])dnl +]) + +CHECK_ALIGNOF(short) +CHECK_ALIGNOF(int) +CHECK_ALIGNOF(long) +if [[ $HAVE_LONG_LONG_INT_64 -eq 1 ]] ; then + CHECK_ALIGNOF(long long int) +fi +CHECK_ALIGNOF(double) + +dnl Compute maximum alignment of any basic type. +dnl We assume long's alignment is at least as strong as char, short, or int; +dnl but we must check long long (if it exists) and double. + +if [[ $ac_cv_alignof_double != 'sizeof(double)' ]] ; then + MAX_ALIGNOF="$ac_cv_alignof_long" + if [[ $MAX_ALIGNOF -lt $ac_cv_alignof_double ]] ; then + MAX_ALIGNOF="$ac_cv_alignof_double" + fi + if [[ $HAVE_LONG_LONG_INT_64 -eq 1 ]] ; then + if [[ $MAX_ALIGNOF -lt $ac_cv_alignof_long_long_int ]] ; then + MAX_ALIGNOF="$ac_cv_alignof_long_long_int" + fi + fi +else + dnl cross-compiling: assume that double's alignment is worst case + MAX_ALIGNOF="$ac_cv_alignof_double" +fi +AC_DEFINE_UNQUOTED(MAXIMUM_ALIGNOF, $MAX_ALIGNOF) + + dnl Check to see if platform has POSIX signal interface. dnl NOTE: if this test fails then POSIX signals definitely don't work. dnl It could be that the test compiles but the POSIX routines don't |
