diff options
author | Andy Wingo <wingo@pobox.com> | 2011-05-13 18:02:30 +0200 |
---|---|---|
committer | Andy Wingo <wingo@pobox.com> | 2011-05-13 19:30:00 +0200 |
commit | 20291e3db3ea9e3f00d7217686878bbcbe196d57 (patch) | |
tree | 8a58c1bbdd36bca18e406803a3678decfab66b1f | |
parent | c037832c65fd58902aa47b47bdd721e67e56b6c3 (diff) | |
download | guile-20291e3db3ea9e3f00d7217686878bbcbe196d57.tar.gz |
add check that pointers are represented the same way as integers
* acinclude.m4 (GUILE_POINTERS_AS_INTEGERS)
* configure.ac: Add a check that pointers are represented as integers.
Should catch weird cases like UNICOS at configure-time.
-rw-r--r-- | acinclude.m4 | 51 | ||||
-rw-r--r-- | configure.ac | 6 |
2 files changed, 57 insertions, 0 deletions
diff --git a/acinclude.m4 b/acinclude.m4 index ba8b09031..eea95a7c2 100644 --- a/acinclude.m4 +++ b/acinclude.m4 @@ -534,3 +534,54 @@ AC_DEFUN([gl_CLOCK_TIME], AC_CHECK_FUNCS([clock_gettime clock_settime]) LIBS=$gl_saved_libs ]) + +dnl GUILE_POINTERS_AS_INTEGERS +dnl +dnl Check whether the representation of pointers is the same as that of +dnl integers. This behavior is essentially compiler-dependent, and is +dnl not specified in the standard, but libguile/tags.h makes assumptions +dnl that we need to test here. +AC_DEFUN([GUILE_POINTERS_AS_INTEGERS], [ + GUILE_UINT64=`eval echo $SCM_I_GSC_T_UINT64` + GUILE_UINTPTR=`eval echo $SCM_I_GSC_T_UINTPTR` + AC_CACHE_CHECK([whether pointers have the same bit representation as integers], + [guile_cv_pointers_as_integers], [ + AC_RUN_IFELSE([AC_LANG_SOURCE([[ + #if HAVE_STDINT_H + #include <stdint.h> + #endif + #if HAVE_INTTYPES_H + #include <inttypes.h> + #endif + #include <malloc.h> + + union ptr_and_int + { + $GUILE_UINT64 integer; + void *pointer; + }; + + int + main (int argc, char *argv[]) + { + union ptr_and_int u; + + if (sizeof (union ptr_and_int) != sizeof ($GUILE_UINT64)) + return 1; + + if (sizeof ($GUILE_UINTPTR) > sizeof ($GUILE_UINT64)) + return 2; + + u.pointer = malloc (10); + + if (u.integer != ($GUILE_UINTPTR)u.pointer) + return 3; + + return 0; + } + ]])], + [guile_cv_pointers_as_integers=yes], + [guile_cv_pointers_as_integers=no], + [guile_cv_pointers_as_integers=yes]) + ]) +]) diff --git a/configure.ac b/configure.ac index 83e148733..03beca9ed 100644 --- a/configure.ac +++ b/configure.ac @@ -605,6 +605,12 @@ AC_SUBST([SCM_I_GSC_T_UINTPTR]) AC_SUBST([SCM_I_GSC_NEEDS_STDINT_H]) AC_SUBST([SCM_I_GSC_NEEDS_INTTYPES_H]) +GUILE_POINTERS_AS_INTEGERS +if test "$guile_cv_pointers_as_integers" != "yes"; then + AC_MSG_ERROR([This system's representation of pointers is incompatible with Guile. +Please contact guile-devel@gnu.org for more information.]) +fi + AC_HEADER_STDC AC_HEADER_TIME AC_HEADER_SYS_WAIT |