1
Fork 0
mirror of https://git.savannah.gnu.org/git/guile.git synced 2025-04-30 03:40:34 +02:00

build: When cross-compiling, get type sizes of the target system.

Fixes <https://issues.guix.gnu.org/54198>.

As noted in the comment at the top, 'SIZEOF_TYPE' must be used instead
of 'sizeof (TYPE)' to support cross-compilation.

The regression was introduced in
5e5afde06f but only became apparent with
717e787da6.

* libguile/gen-scmconfig.c (main): Replace uses of 'sizeof' by
references to the SIZEOF_* macros.
* configure.ac: Add 'AC_CHECK_SIZEOF' call for 'intmax_t'.
This commit is contained in:
Ludovic Courtès 2022-02-28 22:57:52 +01:00
parent 68aeffe8dd
commit 24b30130ca
2 changed files with 17 additions and 16 deletions

View file

@ -357,6 +357,7 @@ AC_CHECK_SIZEOF(uintptr_t)
AC_CHECK_SIZEOF(ptrdiff_t) AC_CHECK_SIZEOF(ptrdiff_t)
AC_CHECK_SIZEOF(size_t) AC_CHECK_SIZEOF(size_t)
AC_CHECK_SIZEOF(off_t) AC_CHECK_SIZEOF(off_t)
AC_CHECK_SIZEOF(intmax_t)
if test "$ac_cv_sizeof_long" -gt "$ac_cv_sizeof_void_p"; then if test "$ac_cv_sizeof_long" -gt "$ac_cv_sizeof_void_p"; then
AC_MSG_ERROR(long does not fit into a void*) AC_MSG_ERROR(long does not fit into a void*)

View file

@ -1,4 +1,4 @@
/* Copyright 2003-2013,2018,2020,2021 /* Copyright 2003-2013, 2018, 2020-2022
Free Software Foundation, Inc. Free Software Foundation, Inc.
This file is part of Guile. This file is part of Guile.
@ -238,21 +238,21 @@ main (int argc, char *argv[])
pf ("\n"); pf ("\n");
pf ("/* Standard types. */\n"); pf ("/* Standard types. */\n");
pf ("#define SCM_SIZEOF_CHAR %zu\n", sizeof (char)); pf ("#define SCM_SIZEOF_CHAR %d\n", SIZEOF_CHAR);
pf ("#define SCM_SIZEOF_UNSIGNED_CHAR %zu\n", sizeof (unsigned char)); pf ("#define SCM_SIZEOF_UNSIGNED_CHAR %d\n", SIZEOF_UNSIGNED_CHAR);
pf ("#define SCM_SIZEOF_SHORT %zu\n", sizeof (short)); pf ("#define SCM_SIZEOF_SHORT %d\n", SIZEOF_SHORT);
pf ("#define SCM_SIZEOF_UNSIGNED_SHORT %zu\n", sizeof (unsigned short)); pf ("#define SCM_SIZEOF_UNSIGNED_SHORT %d\n", SIZEOF_UNSIGNED_SHORT);
pf ("#define SCM_SIZEOF_LONG %zu\n", sizeof (long)); pf ("#define SCM_SIZEOF_LONG %d\n", SIZEOF_LONG);
pf ("#define SCM_SIZEOF_UNSIGNED_LONG %zu\n", sizeof (unsigned long)); pf ("#define SCM_SIZEOF_UNSIGNED_LONG %d\n", SIZEOF_UNSIGNED_LONG);
pf ("#define SCM_SIZEOF_INT %zu\n", sizeof (int)); pf ("#define SCM_SIZEOF_INT %d\n", SIZEOF_INT);
pf ("#define SCM_SIZEOF_UNSIGNED_INT %zu\n", sizeof (unsigned int)); pf ("#define SCM_SIZEOF_UNSIGNED_INT %d\n", SIZEOF_UNSIGNED_INT);
pf ("#define SCM_SIZEOF_SIZE_T %zu\n", sizeof (size_t)); pf ("#define SCM_SIZEOF_SIZE_T %d\n", SIZEOF_SIZE_T);
pf ("#define SCM_SIZEOF_LONG_LONG %zu\n", sizeof (long long)); pf ("#define SCM_SIZEOF_LONG_LONG %d\n", SIZEOF_LONG_LONG);
pf ("#define SCM_SIZEOF_UNSIGNED_LONG_LONG %zu\n", sizeof (unsigned long long)); pf ("#define SCM_SIZEOF_UNSIGNED_LONG_LONG %d\n", SIZEOF_UNSIGNED_LONG_LONG);
pf ("#define SCM_SIZEOF_INTMAX %zu\n", sizeof (intmax_t)); pf ("#define SCM_SIZEOF_INTMAX %d\n", SIZEOF_INTMAX_T);
pf ("#define SCM_SIZEOF_SCM_T_PTRDIFF %zu\n", sizeof (ptrdiff_t)); pf ("#define SCM_SIZEOF_SCM_T_PTRDIFF %d\n", SIZEOF_PTRDIFF_T);
pf ("#define SCM_SIZEOF_INTPTR_T %zu\n", sizeof (intptr_t)); pf ("#define SCM_SIZEOF_INTPTR_T %d\n", SIZEOF_INTPTR_T);
pf ("#define SCM_SIZEOF_UINTPTR_T %zu\n", sizeof (uintptr_t)); pf ("#define SCM_SIZEOF_UINTPTR_T %d\n", SIZEOF_UINTPTR_T);
pf ("\n"); pf ("\n");
pf ("/* same as POSIX \"struct timespec\" -- always defined */\n"); pf ("/* same as POSIX \"struct timespec\" -- always defined */\n");