1
Fork 0
mirror of https://git.savannah.gnu.org/git/guile.git synced 2025-05-18 01:42:24 +02:00

Don't rely on `HAVE_' macros in public header "tags.h".

* configure.ac: Check for `intptr_t' and `uintptr_t'.  Substitute
  `SCM_I_GSC_T_INTPTR' and `SCM_I_GSC_T_UINPTR'.

* libguile/__scm.h (SCM_T_UINTPTR_MAX, SCM_T_INTPTR_MIN,
  SCM_T_INTPTR_MAX): New macros.

* libguile/_scm.h (SIZEOF_SCM_T_BITS): New macro.

* libguile/gen-scmconfig.c (main): Produce typedefs for `scm_t_intptr'
  and `scm_t_uintptr'.

* libguile/gen-scmconfig.h.in (SCM_I_GSC_T_INTPTR, SCM_I_GSC_T_UINPTR):
  New macros.

* libguile/tags.h: Don't check for `HAVE_INTTYPES_H' and
  `HAVE_STDINT_H'; don't include <inttypes.h> nor <stdint.h>.
  (scm_t_signed_bits, scm_t_bits): Define unconditionally as aliases for
  `scm_t_intptr' and `scm_t_uintptr', respectively.
  (SCM_T_SIGNED_BITS_MAX, SCM_T_SIGNED_BITS_MIN, SCM_T_BITS_MAX):
  Likewise.
  (SIZEOF_SCM_T_BITS): Remove.
This commit is contained in:
Ludovic Courtès 2009-11-24 23:12:03 +01:00
parent c27411f180
commit 9718acde77
6 changed files with 62 additions and 32 deletions

View file

@ -393,6 +393,8 @@ if test "$ac_cv_header_stdint_h" = yes; then
AC_CHECK_TYPE([uint64_t],[scm_stdint_has_uint64=1],,[#include <stdint.h>])
AC_CHECK_TYPE([intmax_t],[scm_stdint_has_intmax=1],,[#include <stdint.h>])
AC_CHECK_TYPE([uintmax_t],[scm_stdint_has_uintmax=1],,[#include <stdint.h>])
AC_CHECK_TYPE([intptr_t],[scm_stdint_has_intptr=1],,[#include <stdint.h>])
AC_CHECK_TYPE([uintptr_t],[scm_stdint_has_uintptr=1],,[#include <stdint.h>])
fi
# so we don't get confused by the cache (wish there was a better way
@ -421,6 +423,8 @@ if test "$ac_cv_header_inttypes_h" = yes; then
AC_CHECK_TYPE([uint64_t],[scm_inttypes_has_uint64=1],,[#include <inttypes.h>])
AC_CHECK_TYPE([intmax_t],[scm_inttypes_has_intmax=1],,[#include <inttypes.h>])
AC_CHECK_TYPE([uintmax_t],[scm_inttypes_has_uintmax=1],,[#include <inttypes.h>])
AC_CHECK_TYPE([intptr_t],[scm_inttypes_has_intptr=1],,[#include <inttypes.h>])
AC_CHECK_TYPE([uintptr_t],[scm_inttypes_has_uintptr=1],,[#include <inttypes.h>])
fi
# Try hard to find definitions for some required scm_t_*int* types.
@ -613,6 +617,46 @@ else
fi
AC_SUBST([SCM_I_GSC_T_UINTMAX])
### Required type scm_t_intptr
###
SCM_I_GSC_T_INTPTR=0
if test "$scm_stdint_has_intptr"; then
SCM_I_GSC_T_INTPTR='"intptr_t"'
SCM_I_GSC_NEEDS_STDINT_H=1
elif test "$scm_inttypes_has_intptr"; then
SCM_I_GSC_T_INTPTR='"intptr_t"'
SCM_I_GSC_NEEDS_INTTYPES_H=1
elif test "$ac_cv_sizeof_int" = "$ac_cv_sizeof_void_p"; then
SCM_I_GSC_T_INTPTR='"int"'
elif test "$ac_cv_sizeof_long" = "$ac_cv_sizeof_void_p"; then
SCM_I_GSC_T_INTPTR='"long"'
elif test "$ac_cv_sizeof_long_long" = "$ac_cv_sizeof_void_p"; then
SCM_I_GSC_T_INTPTR='"long long"'
else
AC_MSG_ERROR([Can't find appropriate type for `scm_t_intptr'.])
fi
AC_SUBST([SCM_I_GSC_T_INTPTR])
### Required type scm_t_uintptr
###
SCM_I_GSC_T_UINTPTR=0
if test "$scm_stdint_has_uintptr"; then
SCM_I_GSC_T_UINTPTR='"uintptr_t"'
SCM_I_GSC_NEEDS_STDINT_H=1
elif test "$scm_inttypes_has_uintptr"; then
SCM_I_GSC_T_UINTPTR='"uintptr_t"'
SCM_I_GSC_NEEDS_INTTYPES_H=1
elif test "$ac_cv_sizeof_int" = "$ac_cv_sizeof_void_p"; then
SCM_I_GSC_T_UINTPTR='"unsigned int"'
elif test "$ac_cv_sizeof_long" = "$ac_cv_sizeof_void_p"; then
SCM_I_GSC_T_UINTPTR='"unsigned long"'
elif test "$ac_cv_sizeof_long_long" = "$ac_cv_sizeof_void_p"; then
SCM_I_GSC_T_UINTPTR='"unsigned long long"'
else
AC_MSG_ERROR([Can't find appropriate type for `scm_t_uintptr'.])
fi
AC_SUBST([SCM_I_GSC_T_UINTPTR])
AC_SUBST([SCM_I_GSC_NEEDS_STDINT_H])
AC_SUBST([SCM_I_GSC_NEEDS_INTTYPES_H])

View file

@ -373,6 +373,10 @@
#define SCM_T_INTMAX_MIN SCM_I_TYPE_MIN(scm_t_intmax,SCM_T_UINTMAX_MAX)
#define SCM_T_INTMAX_MAX SCM_I_TYPE_MAX(scm_t_intmax,SCM_T_UINTMAX_MAX)
#define SCM_T_UINTPTR_MAX SCM_I_UTYPE_MAX(scm_t_uintptr)
#define SCM_T_INTPTR_MIN SCM_I_TYPE_MIN(scm_t_intptr,SCM_T_UINTPTR_MAX)
#define SCM_T_INTPTR_MAX SCM_I_TYPE_MAX(scm_t_intptr,SCM_T_UINTPTR_MAX)
#define SCM_I_SIZE_MAX SCM_I_UTYPE_MAX(size_t)
#define SCM_I_SSIZE_MIN SCM_I_TYPE_MIN(ssize_t,SCM_I_SIZE_MAX)
#define SCM_I_SSIZE_MAX SCM_I_TYPE_MAX(ssize_t,SCM_I_SIZE_MAX)

View file

@ -38,6 +38,9 @@
# include <config.h>
#endif
/* The size of `scm_t_bits'. */
#define SIZEOF_SCM_T_BITS SIZEOF_VOID_P
/* Undefine HAVE_STRUCT_TIMESPEC, because the libguile C code doesn't
need it anymore, and because on MinGW:

View file

@ -304,6 +304,8 @@ main (int argc, char *argv[])
pf ("typedef %s scm_t_uint32;\n", SCM_I_GSC_T_UINT32);
pf ("typedef %s scm_t_intmax;\n", SCM_I_GSC_T_INTMAX);
pf ("typedef %s scm_t_uintmax;\n", SCM_I_GSC_T_UINTMAX);
pf ("typedef %s scm_t_intptr;\n", SCM_I_GSC_T_INTPTR);
pf ("typedef %s scm_t_uintptr;\n", SCM_I_GSC_T_UINTPTR);
if (0 == strcmp ("intmax_t", SCM_I_GSC_T_INTMAX))
pf ("#define SCM_SIZEOF_INTMAX %d\n", SIZEOF_INTMAX_T);

View file

@ -25,6 +25,8 @@
#define SCM_I_GSC_T_UINT64 @SCM_I_GSC_T_UINT64@
#define SCM_I_GSC_T_INTMAX @SCM_I_GSC_T_INTMAX@
#define SCM_I_GSC_T_UINTMAX @SCM_I_GSC_T_UINTMAX@
#define SCM_I_GSC_T_INTPTR @SCM_I_GSC_T_INTPTR@
#define SCM_I_GSC_T_UINTPTR @SCM_I_GSC_T_UINTPTR@
#define SCM_I_GSC_T_PTRDIFF @SCM_I_GSC_T_PTRDIFF@
#define SCM_I_GSC_USE_PTHREAD_THREADS @SCM_I_GSC_USE_PTHREAD_THREADS@
#define SCM_I_GSC_USE_NULL_THREADS @SCM_I_GSC_USE_NULL_THREADS@

View file

@ -3,8 +3,8 @@
#ifndef SCM_TAGS_H
#define SCM_TAGS_H
/* Copyright (C) 1995,1996,1997,1998,1999,2000,2001,2002,2003,2004,2008
* Free Software Foundation, Inc.
/* Copyright (C) 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
* 2003, 2004, 2008, 2011 Free Software Foundation, Inc.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
@ -30,14 +30,6 @@
/* picks up scmconfig.h too */
#include "libguile/__scm.h"
#if HAVE_INTTYPES_H
# include <inttypes.h> /* for INTPTR_MAX and friends */
#else
# if HAVE_STDINT_H
# include <stdint.h> /* for INTPTR_MAX and friends */
# endif
#endif
/* In the beginning was the Word:
@ -68,31 +60,14 @@
/* For dealing with the bit level representation of scheme objects we define
* scm_t_bits:
*/
/* On Solaris 7 and 8, /usr/include/sys/int_limits.h defines
INTPTR_MAX and UINTPTR_MAX to empty, INTPTR_MIN is not defined.
To avoid uintptr_t and intptr_t in this case we require
UINTPTR_MAX-0 != 0 etc. */
#if SCM_SIZEOF_INTPTR_T != 0 && defined(INTPTR_MAX) && defined(INTPTR_MIN) \
&& INTPTR_MAX-0 != 0 && INTPTR_MIN-0 != 0 \
&& SCM_SIZEOF_UINTPTR_T != 0 && defined(UINTPTR_MAX) && UINTPTR_MAX-0 != 0
typedef intptr_t scm_t_signed_bits;
#define SCM_T_SIGNED_BITS_MAX INTPTR_MAX
#define SCM_T_SIGNED_BITS_MIN INTPTR_MIN
typedef uintptr_t scm_t_bits;
#define SIZEOF_SCM_T_BITS SCM_SIZEOF_UINTPTR_T
#define SCM_T_BITS_MAX UINTPTR_MAX
typedef scm_t_intptr scm_t_signed_bits;
typedef scm_t_uintptr scm_t_bits;
#else
#define SCM_T_SIGNED_BITS_MAX SCM_T_INTPTR_MAX
#define SCM_T_SIGNED_BITS_MIN SCM_T_INTPTR_MIN
#define SCM_T_BITS_MAX SCM_T_UINTPTR_MAX
typedef signed long scm_t_signed_bits;
#define SCM_T_SIGNED_BITS_MAX LONG_MAX
#define SCM_T_SIGNED_BITS_MIN LONG_MIN
typedef unsigned long scm_t_bits;
#define SIZEOF_SCM_T_BITS SCM_SIZEOF_UNSIGNED_LONG
#define SCM_T_BITS_MAX ULONG_MAX
#endif
/* But as external interface, we define SCM, which may, according to the
* desired level of type checking, be defined in several ways: