From: panne Date: Mon, 18 Aug 2003 16:29:36 +0000 (+0000) Subject: [project @ 2003-08-18 16:29:36 by panne] X-Git-Tag: Approx_11550_changesets_converted~557 X-Git-Url: http://git.megacz.com/?p=ghc-hetmet.git;a=commitdiff_plain;h=ac30425066d03716b2cb3159452e197ab40c22ab [project @ 2003-08-18 16:29:36 by panne] * Revamped macro for alignment test * Fixed a few tests for "long long"s --- diff --git a/aclocal.m4 b/aclocal.m4 index 19370ff..69a606b 100644 --- a/aclocal.m4 +++ b/aclocal.m4 @@ -24,6 +24,40 @@ AC_CHECK_DECLS([altzone], [], [],[#if TIME_WITH_SYS_TIME ])# FP_ALTZONE +# FP_COMPUTE_INT(EXPRESSION, VARIABLE, INCLUDES, IF-FAILS) +# --------------------------------------------------------- +# Assign VARIABLE the value of the compile-time EXPRESSION using INCLUDES for +# compilation. Execute IF-FAILS when unable to determine the value. Works for +# cross-compilation, too. +# Note: We are lazy and use an internal autoconf macro, but it is supported in +# autoconf versions 2.50 up to the actual 2.57, so there is little risk. +AC_DEFUN([FP_COMPUTE_INT], +[_AC_COMPUTE_INT([$1], [$2], [$3], [$4])[]dnl +])# FP_COMPUTE_INT + + +# FP_CHECK_ALIGNMENT(TYPE, [IGNORED], [INCLUDES = DEFAULT-INCLUDES]) +# ------------------------------------------------------------------ +# A variation of AC_CHECK_SIZEOF for computing the alignment restrictions of a +# given type. Defines ALIGNMENT_TYPE. +AC_DEFUN([FP_CHECK_ALIGNMENT], +[AS_LITERAL_IF([$1], [], + [AC_FATAL([$0: requires literal arguments])])dnl +AC_CHECK_TYPE([$1], [], [], [$3]) +AC_CACHE_CHECK([alignment of $1], AS_TR_SH([fp_cv_alignment_$1]), +[if test "$AS_TR_SH([ac_cv_type_$1])" = yes; then + FP_COMPUTE_INT([(long) (&((struct { char c; $1 ty; } *)0)->ty)], + [AS_TR_SH([fp_cv_alignment_$1])], + [AC_INCLUDES_DEFAULT([$3])], + [AC_MSG_FAILURE([cannot compute alignment ($1), 77])]) +else + AS_TR_SH([fp_cv_alignment_$1])=0 +fi])dnl +AC_DEFINE_UNQUOTED(AS_TR_CPP(alignment_$1), $AS_TR_SH([fp_cv_alignment_$1]), + [The alignment of a `$1'.]) +])# FP_CHECK_ALIGNMENT + + dnl ** check for leading underscores in symbol names dnl dnl Test for determining whether symbol names have a leading @@ -531,49 +565,6 @@ ifelse($#, [1], [dnl ])dnl -dnl ** figure out the alignment restriction of a type -dnl (required SIZEOF test but AC_CHECK_SIZEOF doesn't call PROVIDE -dnl so we can't call REQUIRE) - -dnl FPTOOLS_CHECK_ALIGNMENT(TYPE) -AC_DEFUN(FPTOOLS_CHECK_ALIGNMENT, -[changequote(<<, >>)dnl -dnl The name to #define. -define(<>, translit(alignment_$1, [a-z *], [A-Z_P]))dnl -dnl The cache variable name. -define(<>, translit(ac_cv_alignment_$1, [ *], [_p]))dnl -dnl The name of the corresponding size. -define(<>, translit(ac_cv_sizeof_$1, [ *], [_p]))dnl -changequote([, ])dnl -AC_MSG_CHECKING(alignment of $1) -AC_CACHE_VAL(AC_CV_NAME, -[AC_TRY_RUN([ -#include -#if HAVE_STDDEF_H -#include -#endif -#ifndef offsetof -#define offsetof(ty,field) ((size_t)((char *)&((ty *)0)->field - (char *)(ty *)0)) -#endif -int -main() -{ - FILE *f=fopen("conftestval", "w"); - if (!f) exit(1); - fprintf(f, "%d", offsetof(struct { char c; $1 ty;},ty)); - exit(0); -}], -AC_CV_NAME=`cat conftestval`, -AC_CV_NAME=$AC_CV_SIZEOF_NAME, -AC_CV_NAME=$AC_CV_SIZEOF_NAME)]) -AC_MSG_RESULT($AC_CV_NAME) -AC_DEFINE_UNQUOTED(AC_TYPE_NAME, $AC_CV_NAME) -AC_PROVIDE($AC_TYPE_NAME) -undefine([AC_TYPE_NAME])dnl -undefine([AC_CV_NAME])dnl -undefine([AC_CV_SIZEOF_NAME])dnl -]) - dnl ** Map an arithmetic C type to a Haskell type. dnl Based on autconf's AC_CHECK_SIZEOF. diff --git a/configure.ac b/configure.ac index 509f8e2..52de912 100644 --- a/configure.ac +++ b/configure.ac @@ -851,43 +851,42 @@ FPTOOLS_MSGHDR_MSG_ACCRIGHTS FPTOOLS_MSGHDR_MSG_CONTROL dnl ** what are the sizes of various types -dnl (these must come before GHC_CHECK_ALIGNMENT) AC_CHECK_SIZEOF(char, 1) AC_CHECK_SIZEOF(double, 8) AC_CHECK_SIZEOF(float, 4) AC_CHECK_SIZEOF(int, 4) AC_CHECK_SIZEOF(long, 4) -if test "$fptools_cv_have_long_long" = yes; then +if test "$ac_cv_type_long_long" = yes; then AC_CHECK_SIZEOF(long long, 8) fi AC_CHECK_SIZEOF(short, 2) AC_CHECK_SIZEOF(unsigned char, 1) AC_CHECK_SIZEOF(unsigned int, 4) AC_CHECK_SIZEOF(unsigned long, 4) -if test "$fptools_cv_have_long_long" = yes; then +if test "$ac_cv_type_long_long" = yes; then AC_CHECK_SIZEOF(unsigned long long, 8) fi AC_CHECK_SIZEOF(unsigned short, 2) AC_CHECK_SIZEOF(void *, 4) dnl ** what are alignment constraints on various types -FPTOOLS_CHECK_ALIGNMENT(char) -FPTOOLS_CHECK_ALIGNMENT(double) -FPTOOLS_CHECK_ALIGNMENT(float) -FPTOOLS_CHECK_ALIGNMENT(int) -FPTOOLS_CHECK_ALIGNMENT(long) -if test "$fptools_cv_have_long_long" = yes; then -FPTOOLS_CHECK_ALIGNMENT(long long) +FP_CHECK_ALIGNMENT(char) +FP_CHECK_ALIGNMENT(double) +FP_CHECK_ALIGNMENT(float) +FP_CHECK_ALIGNMENT(int) +FP_CHECK_ALIGNMENT(long) +if test "$ac_cv_type_long_long" = yes; then +FP_CHECK_ALIGNMENT(long long) fi -FPTOOLS_CHECK_ALIGNMENT(short) -FPTOOLS_CHECK_ALIGNMENT(unsigned char) -FPTOOLS_CHECK_ALIGNMENT(unsigned int) -FPTOOLS_CHECK_ALIGNMENT(unsigned long) -if test "$fptools_cv_have_long_long" = yes; then -FPTOOLS_CHECK_ALIGNMENT(unsigned long long) +FP_CHECK_ALIGNMENT(short) +FP_CHECK_ALIGNMENT(unsigned char) +FP_CHECK_ALIGNMENT(unsigned int) +FP_CHECK_ALIGNMENT(unsigned long) +if test "$ac_cv_type_long_long" = yes; then +FP_CHECK_ALIGNMENT(unsigned long long) fi -FPTOOLS_CHECK_ALIGNMENT(unsigned short) -FPTOOLS_CHECK_ALIGNMENT(void *) +FP_CHECK_ALIGNMENT(unsigned short) +FP_CHECK_ALIGNMENT(void *) dnl ** map standard C types and ISO types to Haskell types FPTOOLS_CHECK_HTYPE(char) @@ -899,7 +898,7 @@ FPTOOLS_CHECK_HTYPE(int) FPTOOLS_CHECK_HTYPE(unsigned int) FPTOOLS_CHECK_HTYPE(long) FPTOOLS_CHECK_HTYPE(unsigned long) -if test "$fptools_cv_have_long_long" = yes; then +if test "$ac_cv_type_long_long" = yes; then FPTOOLS_CHECK_HTYPE(long long) FPTOOLS_CHECK_HTYPE(unsigned long long) fi