summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLudovic Courtès <ludo@gnu.org>2009-11-24 23:12:03 +0100
committerLudovic Courtès <ludo@gnu.org>2011-11-06 18:15:51 +0100
commit9718acde77935837ecb947d52d15e989ebbe4877 (patch)
tree4864010228f154e87b76a3da2bebfab598bb56de
parentc27411f180c42c89e1282edf0c992b6d11c8db7f (diff)
downloadguile-9718acde77935837ecb947d52d15e989ebbe4877.tar.gz
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.
-rw-r--r--configure.in44
-rw-r--r--libguile/__scm.h4
-rw-r--r--libguile/_scm.h3
-rw-r--r--libguile/gen-scmconfig.c2
-rw-r--r--libguile/gen-scmconfig.h.in2
-rw-r--r--libguile/tags.h39
6 files changed, 62 insertions, 32 deletions
diff --git a/configure.in b/configure.in
index 4ce2783a6..2b176ab97 100644
--- a/configure.in
+++ b/configure.in
@@ -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])
diff --git a/libguile/__scm.h b/libguile/__scm.h
index e75f1a940..f4dc80f17 100644
--- a/libguile/__scm.h
+++ b/libguile/__scm.h
@@ -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)
diff --git a/libguile/_scm.h b/libguile/_scm.h
index 84476e666..be923624f 100644
--- a/libguile/_scm.h
+++ b/libguile/_scm.h
@@ -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:
diff --git a/libguile/gen-scmconfig.c b/libguile/gen-scmconfig.c
index e5de31db8..6d6248cfe 100644
--- a/libguile/gen-scmconfig.c
+++ b/libguile/gen-scmconfig.c
@@ -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);
diff --git a/libguile/gen-scmconfig.h.in b/libguile/gen-scmconfig.h.in
index 1be95af94..4d0e850fa 100644
--- a/libguile/gen-scmconfig.h.in
+++ b/libguile/gen-scmconfig.h.in
@@ -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@
diff --git a/libguile/tags.h b/libguile/tags.h
index 4e0700b52..0fa68cda5 100644
--- a/libguile/tags.h
+++ b/libguile/tags.h
@@ -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
-#else
+typedef scm_t_intptr scm_t_signed_bits;
+typedef scm_t_uintptr scm_t_bits;
-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
+#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
-#endif
/* But as external interface, we define SCM, which may, according to the
* desired level of type checking, be defined in several ways: