diff --git a/src/configure b/src/configure index 74bc763351..da5bc1399b 100755 --- a/src/configure +++ b/src/configure @@ -5496,10 +5496,237 @@ EOF + + + +echo $ac_n "checking alignment of short""... $ac_c" 1>&6 +echo "configure:5504: checking alignment of short" >&5 +if eval "test \"`echo '$''{'ac_cv_alignof_short'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + if test "$cross_compiling" = yes; then + ac_cv_alignof_short='sizeof(short)' +else + cat > conftest.$ac_ext < +struct { char filler; short field; } mystruct; +main() +{ + FILE *f=fopen("conftestval", "w"); + if (!f) exit(1); + fprintf(f, "%d\n", ((char*) & mystruct.field) - ((char*) & mystruct)); + exit(0); +} +EOF +if { (eval echo configure:5524: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit) 2>/dev/null +then + ac_cv_alignof_short=`cat conftestval` +else + echo "configure: failed program was:" >&5 + cat conftest.$ac_ext >&5 + rm -fr conftest* + ac_cv_alignof_short='sizeof(short)' +fi +rm -fr conftest* +fi + +fi +echo "$ac_t""$ac_cv_alignof_short" 1>&6 +cat >> confdefs.h <&6 +echo "configure:5544: checking alignment of int" >&5 +if eval "test \"`echo '$''{'ac_cv_alignof_int'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + if test "$cross_compiling" = yes; then + ac_cv_alignof_int='sizeof(int)' +else + cat > conftest.$ac_ext < +struct { char filler; int field; } mystruct; +main() +{ + FILE *f=fopen("conftestval", "w"); + if (!f) exit(1); + fprintf(f, "%d\n", ((char*) & mystruct.field) - ((char*) & mystruct)); + exit(0); +} +EOF +if { (eval echo configure:5564: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit) 2>/dev/null +then + ac_cv_alignof_int=`cat conftestval` +else + echo "configure: failed program was:" >&5 + cat conftest.$ac_ext >&5 + rm -fr conftest* + ac_cv_alignof_int='sizeof(int)' +fi +rm -fr conftest* +fi + +fi +echo "$ac_t""$ac_cv_alignof_int" 1>&6 +cat >> confdefs.h <&6 +echo "configure:5584: checking alignment of long" >&5 +if eval "test \"`echo '$''{'ac_cv_alignof_long'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + if test "$cross_compiling" = yes; then + ac_cv_alignof_long='sizeof(long)' +else + cat > conftest.$ac_ext < +struct { char filler; long field; } mystruct; +main() +{ + FILE *f=fopen("conftestval", "w"); + if (!f) exit(1); + fprintf(f, "%d\n", ((char*) & mystruct.field) - ((char*) & mystruct)); + exit(0); +} +EOF +if { (eval echo configure:5604: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit) 2>/dev/null +then + ac_cv_alignof_long=`cat conftestval` +else + echo "configure: failed program was:" >&5 + cat conftest.$ac_ext >&5 + rm -fr conftest* + ac_cv_alignof_long='sizeof(long)' +fi +rm -fr conftest* +fi + +fi +echo "$ac_t""$ac_cv_alignof_long" 1>&6 +cat >> confdefs.h <&6 +echo "configure:5625: checking alignment of long long int" >&5 +if eval "test \"`echo '$''{'ac_cv_alignof_long_long_int'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + if test "$cross_compiling" = yes; then + ac_cv_alignof_long_long_int='sizeof(long long int)' +else + cat > conftest.$ac_ext < +struct { char filler; long long int field; } mystruct; +main() +{ + FILE *f=fopen("conftestval", "w"); + if (!f) exit(1); + fprintf(f, "%d\n", ((char*) & mystruct.field) - ((char*) & mystruct)); + exit(0); +} +EOF +if { (eval echo configure:5645: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit) 2>/dev/null +then + ac_cv_alignof_long_long_int=`cat conftestval` +else + echo "configure: failed program was:" >&5 + cat conftest.$ac_ext >&5 + rm -fr conftest* + ac_cv_alignof_long_long_int='sizeof(long long int)' +fi +rm -fr conftest* +fi + +fi +echo "$ac_t""$ac_cv_alignof_long_long_int" 1>&6 +cat >> confdefs.h <&6 +echo "configure:5666: checking alignment of double" >&5 +if eval "test \"`echo '$''{'ac_cv_alignof_double'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + if test "$cross_compiling" = yes; then + ac_cv_alignof_double='sizeof(double)' +else + cat > conftest.$ac_ext < +struct { char filler; double field; } mystruct; +main() +{ + FILE *f=fopen("conftestval", "w"); + if (!f) exit(1); + fprintf(f, "%d\n", ((char*) & mystruct.field) - ((char*) & mystruct)); + exit(0); +} +EOF +if { (eval echo configure:5686: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit) 2>/dev/null +then + ac_cv_alignof_double=`cat conftestval` +else + echo "configure: failed program was:" >&5 + cat conftest.$ac_ext >&5 + rm -fr conftest* + ac_cv_alignof_double='sizeof(double)' +fi +rm -fr conftest* +fi + +fi +echo "$ac_t""$ac_cv_alignof_double" 1>&6 +cat >> confdefs.h <> confdefs.h <&6 -echo "configure:5501: checking for POSIX signal interface" >&5 +echo "configure:5728: checking for POSIX signal interface" >&5 cat > conftest.$ac_ext < int main() { @@ -5509,7 +5736,7 @@ act.sa_flags = SA_RESTART; sigaction(0, &act, &oact); ; return 0; } EOF -if { (eval echo configure:5513: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then +if { (eval echo configure:5740: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then rm -rf conftest* cat >> confdefs.h <<\EOF #define USE_POSIX_SIGNALS 1 @@ -5533,7 +5760,7 @@ then # Extract the first word of "tclsh", so it can be a program name with args. set dummy tclsh; ac_word=$2 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 -echo "configure:5537: checking for $ac_word" >&5 +echo "configure:5764: checking for $ac_word" >&5 if eval "test \"`echo '$''{'ac_cv_path_TCLSH'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -5566,7 +5793,7 @@ fi # Extract the first word of "tcl", so it can be a program name with args. set dummy tcl; ac_word=$2 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 -echo "configure:5570: checking for $ac_word" >&5 +echo "configure:5797: checking for $ac_word" >&5 if eval "test \"`echo '$''{'ac_cv_path_TCLSH'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -5605,7 +5832,7 @@ fi if test "$USE_TCL" = true then echo $ac_n "checking for tclConfig.sh""... $ac_c" 1>&6 -echo "configure:5609: checking for tclConfig.sh" >&5 +echo "configure:5836: checking for tclConfig.sh" >&5 TCL_CONFIG_SH= library_dirs= if test -z "$TCL_DIRS" @@ -5634,7 +5861,7 @@ USE_TK=$USE_TCL # If TCL is disabled, disable TK if test "$USE_TK" = true then echo $ac_n "checking for tkConfig.sh""... $ac_c" 1>&6 -echo "configure:5638: checking for tkConfig.sh" >&5 +echo "configure:5865: checking for tkConfig.sh" >&5 TK_CONFIG_SH= # library_dirs are set in the check for TCL for dir in $library_dirs @@ -5671,7 +5898,7 @@ if test "$USE_X" = true; then # Uses ac_ vars as temps to allow command line to override cache and checks. # --without-x overrides everything else, but does not touch the cache. echo $ac_n "checking for X""... $ac_c" 1>&6 -echo "configure:5675: checking for X" >&5 +echo "configure:5902: checking for X" >&5 # Check whether --with-x or --without-x was given. if test "${with_x+set}" = set; then @@ -5733,12 +5960,12 @@ if test "$ac_x_includes" = NO; then # First, try using that file with no special directory specified. cat > conftest.$ac_ext < EOF ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" -{ (eval echo configure:5742: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } +{ (eval echo configure:5969: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } ac_err=`grep -v '^ *+' conftest.out` if test -z "$ac_err"; then rm -rf conftest* @@ -5807,14 +6034,14 @@ if test "$ac_x_libraries" = NO; then ac_save_LIBS="$LIBS" LIBS="-l$x_direct_test_library $LIBS" cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest; then +if { (eval echo configure:6045: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then rm -rf conftest* LIBS="$ac_save_LIBS" # We can link X programs with no special library path. @@ -5920,17 +6147,17 @@ else case "`(uname -sr) 2>/dev/null`" in "SunOS 5"*) echo $ac_n "checking whether -R must be followed by a space""... $ac_c" 1>&6 -echo "configure:5924: checking whether -R must be followed by a space" >&5 +echo "configure:6151: checking whether -R must be followed by a space" >&5 ac_xsave_LIBS="$LIBS"; LIBS="$LIBS -R$x_libraries" cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest; then +if { (eval echo configure:6161: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then rm -rf conftest* ac_R_nospace=yes else @@ -5946,14 +6173,14 @@ rm -f conftest* else LIBS="$ac_xsave_LIBS -R $x_libraries" cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest; then +if { (eval echo configure:6184: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then rm -rf conftest* ac_R_space=yes else @@ -5985,7 +6212,7 @@ rm -f conftest* # libraries were built with DECnet support. And karl@cs.umb.edu says # the Alpha needs dnet_stub (dnet does not exist). echo $ac_n "checking for dnet_ntoa in -ldnet""... $ac_c" 1>&6 -echo "configure:5989: checking for dnet_ntoa in -ldnet" >&5 +echo "configure:6216: checking for dnet_ntoa in -ldnet" >&5 ac_lib_var=`echo dnet'_'dnet_ntoa | sed 'y%./+-%__p_%'` if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 @@ -5993,7 +6220,7 @@ else ac_save_LIBS="$LIBS" LIBS="-ldnet $LIBS" cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest; then +if { (eval echo configure:6235: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then rm -rf conftest* eval "ac_cv_lib_$ac_lib_var=yes" else @@ -6026,7 +6253,7 @@ fi if test $ac_cv_lib_dnet_dnet_ntoa = no; then echo $ac_n "checking for dnet_ntoa in -ldnet_stub""... $ac_c" 1>&6 -echo "configure:6030: checking for dnet_ntoa in -ldnet_stub" >&5 +echo "configure:6257: checking for dnet_ntoa in -ldnet_stub" >&5 ac_lib_var=`echo dnet_stub'_'dnet_ntoa | sed 'y%./+-%__p_%'` if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 @@ -6034,7 +6261,7 @@ else ac_save_LIBS="$LIBS" LIBS="-ldnet_stub $LIBS" cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest; then +if { (eval echo configure:6276: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then rm -rf conftest* eval "ac_cv_lib_$ac_lib_var=yes" else @@ -6074,12 +6301,12 @@ fi # The nsl library prevents programs from opening the X display # on Irix 5.2, according to dickey@clark.net. echo $ac_n "checking for gethostbyname""... $ac_c" 1>&6 -echo "configure:6078: checking for gethostbyname" >&5 +echo "configure:6305: checking for gethostbyname" >&5 if eval "test \"`echo '$''{'ac_cv_func_gethostbyname'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest; then +if { (eval echo configure:6333: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then rm -rf conftest* eval "ac_cv_func_gethostbyname=yes" else @@ -6123,7 +6350,7 @@ fi if test $ac_cv_func_gethostbyname = no; then echo $ac_n "checking for gethostbyname in -lnsl""... $ac_c" 1>&6 -echo "configure:6127: checking for gethostbyname in -lnsl" >&5 +echo "configure:6354: checking for gethostbyname in -lnsl" >&5 ac_lib_var=`echo nsl'_'gethostbyname | sed 'y%./+-%__p_%'` if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 @@ -6131,7 +6358,7 @@ else ac_save_LIBS="$LIBS" LIBS="-lnsl $LIBS" cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest; then +if { (eval echo configure:6373: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then rm -rf conftest* eval "ac_cv_lib_$ac_lib_var=yes" else @@ -6172,12 +6399,12 @@ fi # -lsocket must be given before -lnsl if both are needed. # We assume that if connect needs -lnsl, so does gethostbyname. echo $ac_n "checking for connect""... $ac_c" 1>&6 -echo "configure:6176: checking for connect" >&5 +echo "configure:6403: checking for connect" >&5 if eval "test \"`echo '$''{'ac_cv_func_connect'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest; then +if { (eval echo configure:6431: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then rm -rf conftest* eval "ac_cv_func_connect=yes" else @@ -6221,7 +6448,7 @@ fi if test $ac_cv_func_connect = no; then echo $ac_n "checking for connect in -lsocket""... $ac_c" 1>&6 -echo "configure:6225: checking for connect in -lsocket" >&5 +echo "configure:6452: checking for connect in -lsocket" >&5 ac_lib_var=`echo socket'_'connect | sed 'y%./+-%__p_%'` if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 @@ -6229,7 +6456,7 @@ else ac_save_LIBS="$LIBS" LIBS="-lsocket $X_EXTRA_LIBS $LIBS" cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest; then +if { (eval echo configure:6471: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then rm -rf conftest* eval "ac_cv_lib_$ac_lib_var=yes" else @@ -6264,12 +6491,12 @@ fi # gomez@mi.uni-erlangen.de says -lposix is necessary on A/UX. echo $ac_n "checking for remove""... $ac_c" 1>&6 -echo "configure:6268: checking for remove" >&5 +echo "configure:6495: checking for remove" >&5 if eval "test \"`echo '$''{'ac_cv_func_remove'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest; then +if { (eval echo configure:6523: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then rm -rf conftest* eval "ac_cv_func_remove=yes" else @@ -6313,7 +6540,7 @@ fi if test $ac_cv_func_remove = no; then echo $ac_n "checking for remove in -lposix""... $ac_c" 1>&6 -echo "configure:6317: checking for remove in -lposix" >&5 +echo "configure:6544: checking for remove in -lposix" >&5 ac_lib_var=`echo posix'_'remove | sed 'y%./+-%__p_%'` if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 @@ -6321,7 +6548,7 @@ else ac_save_LIBS="$LIBS" LIBS="-lposix $LIBS" cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest; then +if { (eval echo configure:6563: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then rm -rf conftest* eval "ac_cv_lib_$ac_lib_var=yes" else @@ -6356,12 +6583,12 @@ fi # BSDI BSD/OS 2.1 needs -lipc for XOpenDisplay. echo $ac_n "checking for shmat""... $ac_c" 1>&6 -echo "configure:6360: checking for shmat" >&5 +echo "configure:6587: checking for shmat" >&5 if eval "test \"`echo '$''{'ac_cv_func_shmat'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest; then +if { (eval echo configure:6615: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then rm -rf conftest* eval "ac_cv_func_shmat=yes" else @@ -6405,7 +6632,7 @@ fi if test $ac_cv_func_shmat = no; then echo $ac_n "checking for shmat in -lipc""... $ac_c" 1>&6 -echo "configure:6409: checking for shmat in -lipc" >&5 +echo "configure:6636: checking for shmat in -lipc" >&5 ac_lib_var=`echo ipc'_'shmat | sed 'y%./+-%__p_%'` if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 @@ -6413,7 +6640,7 @@ else ac_save_LIBS="$LIBS" LIBS="-lipc $LIBS" cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest; then +if { (eval echo configure:6655: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then rm -rf conftest* eval "ac_cv_lib_$ac_lib_var=yes" else @@ -6457,7 +6684,7 @@ fi # libraries we check for below, so use a different variable. # --interran@uluru.Stanford.EDU, kb@cs.umb.edu. echo $ac_n "checking for IceConnectionNumber in -lICE""... $ac_c" 1>&6 -echo "configure:6461: checking for IceConnectionNumber in -lICE" >&5 +echo "configure:6688: checking for IceConnectionNumber in -lICE" >&5 ac_lib_var=`echo ICE'_'IceConnectionNumber | sed 'y%./+-%__p_%'` if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 @@ -6465,7 +6692,7 @@ else ac_save_LIBS="$LIBS" LIBS="-lICE $LIBS" cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest; then +if { (eval echo configure:6707: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then rm -rf conftest* eval "ac_cv_lib_$ac_lib_var=yes" else @@ -6509,7 +6736,7 @@ fi X11_LIBS="" echo $ac_n "checking for XOpenDisplay in -lX11""... $ac_c" 1>&6 -echo "configure:6513: checking for XOpenDisplay in -lX11" >&5 +echo "configure:6740: checking for XOpenDisplay in -lX11" >&5 ac_lib_var=`echo X11'_'XOpenDisplay | sed 'y%./+-%__p_%'` if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 @@ -6517,7 +6744,7 @@ else ac_save_LIBS="$LIBS" LIBS="-lX11 ${X_PRE_LIBS} $LIBS" cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest; then +if { (eval echo configure:6759: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then rm -rf conftest* eval "ac_cv_lib_$ac_lib_var=yes" else @@ -6575,17 +6802,17 @@ then PWD_INCDIR=no ac_safe=`echo "pwd.h" | sed 'y%./+-%__p_%'` echo $ac_n "checking for pwd.h""... $ac_c" 1>&6 -echo "configure:6579: checking for pwd.h" >&5 +echo "configure:6806: checking for pwd.h" >&5 if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < EOF ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" -{ (eval echo configure:6589: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } +{ (eval echo configure:6816: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } ac_err=`grep -v '^ *+' conftest.out` if test -z "$ac_err"; then rm -rf conftest* diff --git a/src/configure.in b/src/configure.in index 091346153e..92ff013538 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(<>, translit(alignof_$1, [a-z *], [A-Z_P]))dnl +dnl The cache variable name. +define(<>, 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 +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 diff --git a/src/include/config.h.in b/src/include/config.h.in index 5d2070c6b7..d33bcb5f68 100644 --- a/src/include/config.h.in +++ b/src/include/config.h.in @@ -290,6 +290,18 @@ extern void srandom(unsigned int seed); /* Define this as the appropriate snprintf format for 64-bit ints, if any */ #undef INT64_FORMAT +/* These must be defined as the alignment requirement (NOT the size) of + * each of the basic C data types (except char, which we assume has align 1). + * MAXIMUM_ALIGNOF is the largest alignment requirement for any C data type. + * ALIGNOF_LONG_LONG_INT need only be defined if HAVE_LONG_LONG_INT_64 is. + */ +#undef ALIGNOF_SHORT +#undef ALIGNOF_INT +#undef ALIGNOF_LONG +#undef ALIGNOF_LONG_LONG_INT +#undef ALIGNOF_DOUBLE +#undef MAXIMUM_ALIGNOF + /* Define as the base type of the last arg to accept */ #undef SOCKET_SIZE_TYPE diff --git a/src/include/utils/memutils.h b/src/include/utils/memutils.h index 58db49693e..009d086311 100644 --- a/src/include/utils/memutils.h +++ b/src/include/utils/memutils.h @@ -15,7 +15,7 @@ * * Copyright (c) 1994, Regents of the University of California * - * $Id: memutils.h,v 1.22 1999/03/25 03:49:34 tgl Exp $ + * $Id: memutils.h,v 1.23 1999/03/25 19:05:19 tgl Exp $ * * NOTES * some of the information in this file will be moved to @@ -30,50 +30,21 @@ /* ---------------- * Alignment macros: align a length or address appropriately for a given type. * - * It'd be best to use offsetof to check how the compiler aligns stuff, - * but not all compilers support that (still true)? So we make the - * conservative assumption that a type must be aligned on a boundary equal - * to its own size, except on a few architectures where we know better. + * There used to be some incredibly crufty platform-dependent hackery here, + * but now we rely on the configure script to get the info for us. Much nicer. * - * CAUTION: for the system tables, the struct declarations found in - * src/include/pg_*.h had better be interpreted by the compiler in a way - * that agrees with the workings of these macros. In practice that means - * being careful to lay out the columns of a system table in a way that avoids - * wasted pad space. - * - * CAUTION: _ALIGN will not work if sizeof(TYPE) is not a power of 2. - * There are machines where sizeof(double) is not, for example. - * But such a size is almost certainly not an alignment boundary anyway. + * NOTE: _ALIGN will not work if ALIGNVAL is not a power of 2. + * That case seems extremely unlikely to occur in practice, however. * ---------------- */ -#define _ALIGN(TYPE,LEN) \ - (((long)(LEN) + (sizeof(TYPE) - 1)) & ~(sizeof(TYPE) - 1)) +#define _ALIGN(ALIGNVAL,LEN) (((long)(LEN) + (ALIGNVAL-1)) & ~(ALIGNVAL-1)) -#define SHORTALIGN(LEN) _ALIGN(short, (LEN)) - -#if defined(m68k) -#define INTALIGN(LEN) _ALIGN(short, (LEN)) -#else -#define INTALIGN(LEN) _ALIGN(int, (LEN)) -#endif - -#if (defined(sun) && ! defined(sparc)) || defined(m68k) -#define LONGALIGN(LEN) _ALIGN(short, (LEN)) -#else -#define LONGALIGN(LEN) _ALIGN(long, (LEN)) -#endif - -#if defined(m68k) -#define DOUBLEALIGN(LEN) _ALIGN(short, (LEN)) -#define MAXALIGN(LEN) _ALIGN(short, (LEN)) -#elif defined(sco) -#define DOUBLEALIGN(LEN) _ALIGN(int, (LEN)) -#define MAXALIGN(LEN) _ALIGN(int, (LEN)) -#else -#define DOUBLEALIGN(LEN) _ALIGN(double, (LEN)) -#define MAXALIGN(LEN) _ALIGN(double, (LEN)) -#endif +#define SHORTALIGN(LEN) _ALIGN(ALIGNOF_SHORT, (LEN)) +#define INTALIGN(LEN) _ALIGN(ALIGNOF_INT, (LEN)) +#define LONGALIGN(LEN) _ALIGN(ALIGNOF_LONG, (LEN)) +#define DOUBLEALIGN(LEN) _ALIGN(ALIGNOF_DOUBLE, (LEN)) +#define MAXALIGN(LEN) _ALIGN(MAXIMUM_ALIGNOF, (LEN)) /***************************************************************************** * oset.h -- Fixed format ordered set definitions. *