* OpenBSD does not define INT8_MIN etc.
@ 2004-07-10 8:47 Andreas Vögele
2004-07-10 12:32 ` Andreas Vögele
2004-07-10 13:26 ` Marius Vollmer
0 siblings, 2 replies; 6+ messages in thread
From: Andreas Vögele @ 2004-07-10 8:47 UTC (permalink / raw)
OpenBSD 3.5 doesn't define INT8_MIN, INT8_MAX, UINT8_MAX etc. OpenBSD
only defines INT_MAX, UINT_MAX, SIZE_MAX, SSIZE_MAX etc. I could write
a patch for gen-scmconfig.c and/or configure.in that handles this
problem but I'm wondering why INT8_MIN etc. are necessary at all. Are
there any architectures where INT8_MIN, INT16_MIN etc. aren't -128,
-32768 etc.?
_______________________________________________
Guile-devel mailing list
Guile-devel@gnu.org
http://lists.gnu.org/mailman/listinfo/guile-devel
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: OpenBSD does not define INT8_MIN etc.
2004-07-10 8:47 OpenBSD does not define INT8_MIN etc Andreas Vögele
@ 2004-07-10 12:32 ` Andreas Vögele
2004-07-10 13:26 ` Marius Vollmer
1 sibling, 0 replies; 6+ messages in thread
From: Andreas Vögele @ 2004-07-10 12:32 UTC (permalink / raw)
[-- Attachment #1: Type: text/plain, Size: 655 bytes --]
Am 10.07.2004 um 10:47 schrieb Andreas Vögele:
> OpenBSD 3.5 doesn't define INT8_MIN, INT8_MAX, UINT8_MAX etc.
Here's a patch for gen-scmconfig.c. The patch replaces code like
#define SCM_T_INT8_MIN INT8_MIN
with
#ifdef INT8_MIN
#define SCM_T_INT8_MIN INT8_MIN
#else
#define SCM_T_INT8_MIN ((scm_t_int8)(-128))
#endif
It's based on information I gathered from the POSIX standard (see
<http://www.opengroup.org/onlinepubs/009695399/basedefs/
stdint.h.html#tag_13_48_03_02>) and ICU's umachine.h (see
<http://oss.software.ibm.com/cvs/icu/icu/source/common/unicode/
umachine.h?rev=1.28&content-type=text/x-cvsweb-markup>).
[-- Attachment #2: gen-scmconfig.c.diff --]
[-- Type: application/octet-stream, Size: 4246 bytes --]
Index: gen-scmconfig.c
===================================================================
RCS file: /cvsroot/guile/guile/guile-core/libguile/gen-scmconfig.c,v
retrieving revision 1.7
diff -u -r1.7 gen-scmconfig.c
--- gen-scmconfig.c 8 Jul 2004 15:31:39 -0000 1.7
+++ gen-scmconfig.c 10 Jul 2004 12:20:31 -0000
@@ -316,15 +316,51 @@
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 ("#ifdef %s_MIN\n", SCM_I_GSC_T_INT8_LIMITS);
pf ("#define SCM_T_INT8_MIN %s_MIN\n", SCM_I_GSC_T_INT8_LIMITS);
+ pf ("#else\n");
+ pf ("#define SCM_T_INT8_MIN ((scm_t_int8)(-128))\n");
+ pf ("#endif\n");
+ pf ("#ifdef %s_MAX\n", SCM_I_GSC_T_INT8_LIMITS);
pf ("#define SCM_T_INT8_MAX %s_MAX\n", SCM_I_GSC_T_INT8_LIMITS);
+ pf ("#else\n");
+ pf ("#define SCM_T_INT8_MAX ((scm_t_int8)(127))\n");
+ pf ("#endif\n");
+ pf ("#ifdef %s_MAX\n", SCM_I_GSC_T_UINT8_LIMITS);
pf ("#define SCM_T_UINT8_MAX %s_MAX\n", SCM_I_GSC_T_UINT8_LIMITS);
+ pf ("#else\n");
+ pf ("#define SCM_T_UINT8_MAX ((scm_t_uint8)(255U))\n");
+ pf ("#endif\n");
+ pf ("#ifdef %s_MIN\n", SCM_I_GSC_T_INT16_LIMITS);
pf ("#define SCM_T_INT16_MIN %s_MIN\n", SCM_I_GSC_T_INT16_LIMITS);
+ pf ("#else\n");
+ pf ("#define SCM_T_INT16_MIN ((scm_t_int16)(-32767-1))\n");
+ pf ("#endif\n");
+ pf ("#ifdef %s_MAX\n", SCM_I_GSC_T_INT16_LIMITS);
pf ("#define SCM_T_INT16_MAX %s_MAX\n", SCM_I_GSC_T_INT16_LIMITS);
+ pf ("#else\n");
+ pf ("#define SCM_T_INT16_MAX ((scm_t_int16)(32767))\n");
+ pf ("#endif\n");
+ pf ("#ifdef %s_MAX\n", SCM_I_GSC_T_UINT16_LIMITS);
pf ("#define SCM_T_UINT16_MAX %s_MAX\n", SCM_I_GSC_T_UINT16_LIMITS);
+ pf ("#else\n");
+ pf ("#define SCM_T_UINT16_MAX ((scm_t_uint16)(65535U))\n");
+ pf ("#endif\n");
+ pf ("#ifdef %s_MIN\n", SCM_I_GSC_T_INT32_LIMITS);
pf ("#define SCM_T_INT32_MIN %s_MIN\n", SCM_I_GSC_T_INT32_LIMITS);
+ pf ("#else\n");
+ pf ("#define SCM_T_INT32_MIN ((scm_t_int32)(-2147483647-1))\n");
+ pf ("#endif\n");
+ pf ("#ifdef %s_MAX\n", SCM_I_GSC_T_INT32_LIMITS);
pf ("#define SCM_T_INT32_MAX %s_MAX\n", SCM_I_GSC_T_INT32_LIMITS);
+ pf ("#else\n");
+ pf ("#define SCM_T_INT32_MAX ((scm_t_int32)(2147483647))\n");
+ pf ("#endif\n");
+ pf ("#ifdef %s_MAX\n", SCM_I_GSC_T_UINT32_LIMITS);
pf ("#define SCM_T_UINT32_MAX %s_MAX\n", SCM_I_GSC_T_UINT32_LIMITS);
+ pf ("#else\n");
+ pf ("#define SCM_T_UINT32_MAX ((scm_t_uint32)(4294967295U))\n");
+ pf ("#endif\n");
pf ("\n");
pf ("/* 64-bit integer -- if available SCM_HAVE_T_INT64 will be 1 and\n"
@@ -334,8 +370,24 @@
{
pf ("#define SCM_HAVE_T_INT64 1 /* 0 or 1 */\n");
pf ("typedef %s scm_t_int64;\n", SCM_I_GSC_T_INT64);
+ pf ("#ifdef %s_MIN\n", SCM_I_GSC_T_INT64_LIMITS);
pf ("#define SCM_T_INT64_MIN %s_MIN\n", SCM_I_GSC_T_INT64_LIMITS);
+ pf ("#else\n");
+ pf ("#ifdef INT64_C\n");
+ pf ("#define SCM_T_INT64_MIN ((scm_t_int64)(INT64_C(-9223372036854775807)-1))\n");
+ pf ("#else\n");
+ pf ("#define SCM_T_INT64_MIN ((scm_t_int64)(-9223372036854775807LL-1))\n");
+ pf ("#endif\n");
+ pf ("#endif\n");
+ pf ("#ifdef %s_MAX\n", SCM_I_GSC_T_INT64_LIMITS);
pf ("#define SCM_T_INT64_MAX %s_MAX\n", SCM_I_GSC_T_INT64_LIMITS);
+ pf ("#else\n");
+ pf ("#ifdef INT64_C\n");
+ pf ("#define SCM_T_INT64_MAX ((scm_t_int64)(INT64_C(9223372036854775807)))\n");
+ pf ("#else\n");
+ pf ("#define SCM_T_INT64_MAX ((scm_t_int64)(9223372036854775807LL))\n");
+ pf ("#endif\n");
+ pf ("#endif\n");
}
else
pf ("#define SCM_HAVE_T_INT64 0 /* 0 or 1 */\n");
@@ -348,7 +400,15 @@
{
pf ("#define SCM_HAVE_T_UINT64 1 /* 0 or 1 */\n");
pf ("typedef %s scm_t_uint64;\n", SCM_I_GSC_T_UINT64);
+ pf ("#ifdef %s_MAX\n", SCM_I_GSC_T_UINT64_LIMITS);
pf ("#define SCM_T_UINT64_MAX %s_MAX\n", SCM_I_GSC_T_UINT64_LIMITS);
+ pf ("#else\n");
+ pf ("#ifdef UINT64_C\n");
+ pf ("#define SCM_T_UINT64_MAX ((scm_t_uint64)(UINT64_C(18446744073709551615)))\n");
+ pf ("#else\n");
+ pf ("#define SCM_T_UINT64_MAX ((scm_t_uint64)(18446744073709551615ULL))\n");
+ pf ("#endif\n");
+ pf ("#endif\n");
}
else
pf ("#define SCM_HAVE_T_UINT64 0 /* 0 or 1 */\n");
[-- Attachment #3: Type: text/plain, Size: 143 bytes --]
_______________________________________________
Guile-devel mailing list
Guile-devel@gnu.org
http://lists.gnu.org/mailman/listinfo/guile-devel
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: OpenBSD does not define INT8_MIN etc.
2004-07-10 8:47 OpenBSD does not define INT8_MIN etc Andreas Vögele
2004-07-10 12:32 ` Andreas Vögele
@ 2004-07-10 13:26 ` Marius Vollmer
2004-07-10 14:43 ` Andreas Vögele
2004-07-10 15:57 ` Paul Jarc
1 sibling, 2 replies; 6+ messages in thread
From: Marius Vollmer @ 2004-07-10 13:26 UTC (permalink / raw)
Cc: guile-devel
Andreas Vögele <voegelas@gmx.net> writes:
> OpenBSD 3.5 doesn't define INT8_MIN, INT8_MAX, UINT8_MAX etc.
Damn. I knew we couldn't rely on these being available...
> I could write a patch for gen-scmconfig.c and/or configure.in that
> handles this problem but I'm wondering why INT8_MIN etc. are
> necessary at all. Are there any architectures where INT8_MIN,
> INT16_MIN etc. aren't -128, -32768 etc.?
Yep, I had the same thoughts. There's no problem with INT8_MIN etc,
but I was afraid that for the larger sizes, there would be no portable
way to write the constants. For example, with GCC, UINT64_MAX is
"18446744073709551615ULL" where the "ULL" suffix is essential. That's
why I wanted to use the platform definition of UINT64_MAX, and for
symmetry, I used the platform definitions for the rest as well.
However, we already need to define LLONG_MIN, etc ourselves, and
currently, we rely on integers being in twos-complement. So, we could
just as well forego the platform definitons of INT8_MIN etc and define
them ourselves, maybe like so:
#define SCM_I_UTYPE_MAX(type) (~(type)0)
#define SCM_I_TYPE_MAX(type,utype) ((type)((~(utype)0)/2))
#define SCM_I_TYPE_MIN(type,utype) (-((type)((~(utype)0)/2))-1)
#define SCM_T_UINT8_MAX SCM_I_UTYPE_MAX(scm_t_uint8)
#define SCM_T_INT8_MIN SCM_I_TYPE_MIN(scm_t_int8,scm_t_uint8)
#define SCM_T_INT8_MAX SCM_I_TYPE_MAX(scm_t_int8,scm_t_uint8)
...
That should work for all kind of types.
I'll make this change.
--
GPG: D5D4E405 - 2F9B BCCC 8527 692A 04E3 331E FAF8 226A D5D4 E405
_______________________________________________
Guile-devel mailing list
Guile-devel@gnu.org
http://lists.gnu.org/mailman/listinfo/guile-devel
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: OpenBSD does not define INT8_MIN etc.
2004-07-10 13:26 ` Marius Vollmer
@ 2004-07-10 14:43 ` Andreas Vögele
2004-07-11 9:56 ` Andreas Vögele
2004-07-10 15:57 ` Paul Jarc
1 sibling, 1 reply; 6+ messages in thread
From: Andreas Vögele @ 2004-07-10 14:43 UTC (permalink / raw)
Cc: guile-devel
Marius Vollmer writes:
> Yep, I had the same thoughts. There's no problem with INT8_MIN etc,
> but I was afraid that for the larger sizes, there would be no portable
> way to write the constants. For example, with GCC, UINT64_MAX is
> "18446744073709551615ULL" where the "ULL" suffix is essential. That's
> why I wanted to use the platform definition of UINT64_MAX, and for
> symmetry, I used the platform definitions for the rest as well.
I'd definitely use the platform definitions if available. ICU's
umachine.h that I mentioned in my second message could be helpful. ICU
is highly portable. AFAIK ICU is used on all platforms that IBM
supports.
I thought about the patch that I attached to my previous message. It's
probably better to move the ifdefs from the printf statements into the
C code so that the ifdefs don't get into scmconfig.h. I'll post an
updated patch later.
_______________________________________________
Guile-devel mailing list
Guile-devel@gnu.org
http://lists.gnu.org/mailman/listinfo/guile-devel
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: OpenBSD does not define INT8_MIN etc.
2004-07-10 13:26 ` Marius Vollmer
2004-07-10 14:43 ` Andreas Vögele
@ 2004-07-10 15:57 ` Paul Jarc
1 sibling, 0 replies; 6+ messages in thread
From: Paul Jarc @ 2004-07-10 15:57 UTC (permalink / raw)
Cc: guile-devel
Marius Vollmer <mvo@zagadka.de> wrote:
> #define SCM_I_UTYPE_MAX(type) (~(type)0)
Maybe just personal preference, but I'd use ((type)-1). That's
guaranteed to work by the C standard.
> #define SCM_I_TYPE_MAX(type,utype) ((type)((~(utype)0)/2))
> #define SCM_I_TYPE_MIN(type,utype) (-((type)((~(utype)0)/2))-1)
Will integer promotions get in the way here for smaller types? I
think (utype)0 will be promoted to int before ~ is applied, etc.
paul
_______________________________________________
Guile-devel mailing list
Guile-devel@gnu.org
http://lists.gnu.org/mailman/listinfo/guile-devel
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: OpenBSD does not define INT8_MIN etc.
2004-07-10 14:43 ` Andreas Vögele
@ 2004-07-11 9:56 ` Andreas Vögele
0 siblings, 0 replies; 6+ messages in thread
From: Andreas Vögele @ 2004-07-11 9:56 UTC (permalink / raw)
[-- Attachment #1: Type: text/plain, Size: 934 bytes --]
Andreas Vögele writes:
> I thought about the patch that I attached to my previous message. It's
> probably better to move the ifdefs from the printf statements into the
> C code so that the ifdefs don't get into scmconfig.h. I'll post an
> updated patch later.
Here's the patch that I currently use. I moved the limits stuff from
configure.in to gen-scmconfig.c. The patch introduces a lot of ifdefs
that check if INT8_MAX etc. are defined. If the macros are not
available constants are used. I've tested this patch on Debian
Woody/i386, OpenBSD 3.5/i386, HP-UX 11.0 and Mac OS X 10.3.4.
I also tried to build Guile under Cygwin. I could build guile.exe but
the binary segfaults. I don't think that this problem is related to my
changes. At least, scmconfig.h looks good. I'll try to investigate this
problem but I'm not familiar with Windows and Cygwin.
BTW, HP-UX doesn't seem to define SIZE_MAX.
[-- Attachment #2: limits.diff --]
[-- Type: application/octet-stream, Size: 16478 bytes --]
Index: configure.in
===================================================================
RCS file: /cvsroot/guile/guile/guile-core/configure.in,v
retrieving revision 1.245
diff -u -r1.245 configure.in
--- configure.in 8 Jul 2004 22:50:45 -0000 1.245
+++ configure.in 11 Jul 2004 09:32:05 -0000
@@ -323,161 +323,123 @@
### Required type scm_t_int8
if test "$scm_stdint_has_int8"; then
SCM_I_GSC_T_INT8='"int8_t"'
- SCM_I_GSC_T_INT8_LIMITS='"INT8"'
SCM_I_GSC_NEEDS_STDINT_H=1
elif test "$scm_inttypes_has_int8"; then
SCM_I_GSC_T_INT8='"int8_t"'
- SCM_I_GSC_T_INT8_LIMITS='"INT8"'
SCM_I_GSC_NEEDS_INTTYPES_H=1
elif test "$ac_cv_sizeof_char" -eq 1; then
SCM_I_GSC_T_INT8='"signed char"'
- SCM_I_GSC_T_INT8_LIMITS='"SCHAR"'
else
AC_MSG_ERROR([Can't find appropriate type for scm_t_int8.])
fi
AC_SUBST([SCM_I_GSC_T_INT8])
-AC_SUBST([SCM_I_GSC_T_INT8_LIMITS])
### Required type scm_t_uint8
if test "$scm_stdint_has_uint8"; then
SCM_I_GSC_T_UINT8='"uint8_t"'
- SCM_I_GSC_T_UINT8_LIMITS='"UINT8"'
SCM_I_GSC_NEEDS_STDINT_H=1
elif test "$scm_inttypes_has_uint8"; then
SCM_I_GSC_T_UINT8='"uint8_t"'
- SCM_I_GSC_T_UINT8_LIMITS='"UINT8"'
SCM_I_GSC_NEEDS_INTTYPES_H=1
elif test "$ac_cv_sizeof_unsigned_char" -eq 1; then
SCM_I_GSC_T_UINT8='"unsigned char"'
- SCM_I_GSC_T_UINT8_LIMITS='"UCHAR"'
else
AC_MSG_ERROR([Can't find appropriate type for scm_t_uint8.])
fi
AC_SUBST([SCM_I_GSC_T_UINT8])
-AC_SUBST([SCM_I_GSC_T_UINT8_LIMITS])
### Required type scm_t_int16 (ANSI C says int or short might work)
if test "$scm_stdint_has_int16"; then
SCM_I_GSC_T_INT16='"int16_t"'
- SCM_I_GSC_T_INT16_LIMITS='"INT16"'
SCM_I_GSC_NEEDS_STDINT_H=1
elif test "$scm_inttypes_has_int16"; then
SCM_I_GSC_T_INT16='"int16_t"'
- SCM_I_GSC_T_INT16_LIMITS='"INT16"'
SCM_I_GSC_NEEDS_INTTYPES_H=1
elif test "$ac_cv_sizeof_int" -eq 2; then
SCM_I_GSC_T_INT16='"int"'
- SCM_I_GSC_T_INT16_LIMITS='"INT"'
elif test "$ac_cv_sizeof_short" -eq 2; then
SCM_I_GSC_T_INT16='"short"'
- SCM_I_GSC_T_INT16_LIMITS='"SHRT"'
else
AC_MSG_ERROR([Can't find appropriate type for scm_t_int16.])
fi
AC_SUBST([SCM_I_GSC_T_INT16])
-AC_SUBST([SCM_I_GSC_T_INT16_LIMITS])
### Required type scm_t_uint16 (ANSI C says int or short might work)
if test "$scm_stdint_has_uint16"; then
SCM_I_GSC_T_UINT16='"uint16_t"'
- SCM_I_GSC_T_UINT16_LIMITS='"UINT16"'
SCM_I_GSC_NEEDS_STDINT_H=1
elif test "$scm_inttypes_has_uint16"; then
SCM_I_GSC_T_UINT16='"uint16_t"'
- SCM_I_GSC_T_UINT16_LIMITS='"UINT16"'
SCM_I_GSC_NEEDS_INTTYPES_H=1
elif test "$ac_cv_sizeof_unsigned_int" -eq 2; then
SCM_I_GSC_T_UINT16='"unsigned int"'
- SCM_I_GSC_T_UINT16_LIMITS='"UINT"'
elif test "$ac_cv_sizeof_unsigned_short" -eq 2; then
SCM_I_GSC_T_UINT16='"unsigned short"'
- SCM_I_GSC_T_UINT16_LIMITS='"USHRT"'
else
AC_MSG_ERROR([Can't find appropriate type for scm_t_uint16.])
fi
AC_SUBST([SCM_I_GSC_T_UINT16])
-AC_SUBST([SCM_I_GSC_T_UINT16_LIMITS])
### Required type scm_t_int32 (ANSI C says int, short, or long might work)
if test "$scm_stdint_has_int32"; then
SCM_I_GSC_T_INT32='"int32_t"'
- SCM_I_GSC_T_INT32_LIMITS='"INT32"'
SCM_I_GSC_NEEDS_STDINT_H=1
elif test "$scm_inttypes_has_int32"; then
SCM_I_GSC_T_INT32='"int32_t"'
- SCM_I_GSC_T_INT32_LIMITS='"INT32"'
SCM_I_GSC_NEEDS_INTTYPES_H=1
elif test "$ac_cv_sizeof_int" -eq 4; then
SCM_I_GSC_T_INT32='"int"'
- SCM_I_GSC_T_INT32_LIMITS='"INT"'
elif test "$ac_cv_sizeof_long" -eq 4; then
SCM_I_GSC_T_INT32='"long"'
- SCM_I_GSC_T_INT32_LIMITS='"LONG"'
elif test "$ac_cv_sizeof_short" -eq 4; then
SCM_I_GSC_T_INT32='"short"'
- SCM_I_GSC_T_INT32_LIMITS='"SHRT"'
else
AC_MSG_ERROR([Can't find appropriate type for scm_t_int32.])
fi
AC_SUBST([SCM_I_GSC_T_INT32])
-AC_SUBST([SCM_I_GSC_T_INT32_LIMITS])
### Required type scm_t_uint32 (ANSI C says int, short, or long might work)
if test "$scm_stdint_has_uint32"; then
SCM_I_GSC_T_UINT32='"uint32_t"'
- SCM_I_GSC_T_UINT32_LIMITS='"UINT32"'
SCM_I_GSC_NEEDS_STDINT_H=1
elif test "$scm_inttypes_has_uint32"; then
SCM_I_GSC_T_UINT32='"uint32_t"'
- SCM_I_GSC_T_UINT32_LIMITS='"UINT32"'
SCM_I_GSC_NEEDS_INTTYPES_H=1
elif test "$ac_cv_sizeof_unsigned_int" -eq 4; then
SCM_I_GSC_T_UINT32='"unsigned int"'
- SCM_I_GSC_T_UINT32_LIMITS='"UINT"'
elif test "$ac_cv_sizeof_unsigned_long" -eq 4; then
SCM_I_GSC_T_UINT32='"unsigned long"'
- SCM_I_GSC_T_UINT32_LIMITS='"ULONG"'
elif test "$ac_cv_sizeof_unsigned_short" -eq 4; then
SCM_I_GSC_T_UINT32='"unsigned short"'
- SCM_I_GSC_T_UINT32_LIMITS='"USHRT"'
else
AC_MSG_ERROR([Can't find appropriate type for scm_t_uint32.])
fi
AC_SUBST([SCM_I_GSC_T_UINT32])
-AC_SUBST([SCM_I_GSC_T_UINT32_LIMITS])
### Optional type scm_t_int64 (ANSI C says int, short, or long might work)
### Also try 'long long' and '__int64' if we have it.
SCM_I_GSC_T_INT64=0
if test "$scm_stdint_has_int64"; then
SCM_I_GSC_T_INT64='"int64_t"'
- SCM_I_GSC_T_INT64_LIMITS='"INT64"'
SCM_I_GSC_NEEDS_STDINT_H=1
elif test "$scm_inttypes_has_int64"; then
SCM_I_GSC_T_INT64='"int64_t"'
- SCM_I_GSC_T_INT64_LIMITS='"INT64"'
SCM_I_GSC_NEEDS_INTTYPES_H=1
elif test "$ac_cv_sizeof_int" -eq 8; then
SCM_I_GSC_T_INT64='"int"'
- SCM_I_GSC_T_INT64_LIMITS='"INT"'
elif test "$ac_cv_sizeof_long" -eq 8; then
SCM_I_GSC_T_INT64='"long"'
- SCM_I_GSC_T_INT64_LIMITS='"LONG"'
elif test "$ac_cv_sizeof_short" -eq 8; then
SCM_I_GSC_T_INT64='"short"'
- SCM_I_GSC_T_INT64_LIMITS='"SHRT"'
elif test "$ac_cv_sizeof_long_long" -eq 8; then
SCM_I_GSC_T_INT64='"long long"'
- SCM_I_GSC_T_INT64_LIMITS='"SCM_I_LLONG"'
elif test "$ac_cv_sizeof___int64" -eq 8; then
SCM_I_GSC_T_INT64='"__int64"'
- SCM_I_GSC_T_INT64_LIMITS='"unknown"'
else
AC_MSG_ERROR([Can't find appropriate type for scm_t_int64.])
fi
AC_SUBST([SCM_I_GSC_T_INT64])
-AC_SUBST([SCM_I_GSC_T_INT64_LIMITS])
### Optional type scm_t_uint64 (ANSI C says int, short, or long might work)
@@ -485,32 +447,24 @@
SCM_I_GSC_T_UINT64=0
if test "$scm_stdint_has_uint64"; then
SCM_I_GSC_T_UINT64='"uint64_t"'
- SCM_I_GSC_T_UINT64_LIMITS='"UINT64"'
SCM_I_GSC_NEEDS_STDINT_H=1
elif test "$scm_inttypes_has_uint64"; then
SCM_I_GSC_T_UINT64='"uint64_t"'
- SCM_I_GSC_T_UINT64_LIMITS='"UINT64"'
SCM_I_GSC_NEEDS_INTTYPES_H=1
elif test "$ac_cv_sizeof_unsigned_int" -eq 8; then
SCM_I_GSC_T_UINT64='"unsigned int"'
- SCM_I_GSC_T_UINT64_LIMITS='"UINT"'
elif test "$ac_cv_sizeof_unsigned_long" -eq 8; then
SCM_I_GSC_T_UINT64='"unsigned long"'
- SCM_I_GSC_T_UINT64_LIMITS='"ULONG"'
elif test "$ac_cv_sizeof_unsigned_short" -eq 8; then
SCM_I_GSC_T_UINT64='"unsigned short"'
- SCM_I_GSC_T_UINT64_LIMITS='"USHRT"'
elif test "$ac_cv_sizeof_unsigned_long_long" -eq 8; then
SCM_I_GSC_T_UINT64='"unsigned long long"'
- SCM_I_GSC_T_UINT64_LIMITS='"SCM_I_ULLONG"'
elif test "$ac_cv_sizeof_unsigned___int64" -eq 8; then
SCM_I_GSC_T_UINT64='"unsigned __int64"'
- SCM_I_GSC_T_UINT64_LIMITS='"unknown"'
else
AC_MSG_ERROR([Can't find appropriate type for scm_t_uint64.])
fi
AC_SUBST([SCM_I_GSC_T_UINT64])
-AC_SUBST([SCM_I_GSC_T_UINT64_LIMITS])
### Required type scm_t_intmax
###
@@ -520,24 +474,18 @@
SCM_I_GSC_T_INTMAX=0
if test "$scm_stdint_has_intmax"; then
SCM_I_GSC_T_INTMAX='"intmax_t"'
- SCM_I_GSC_T_INTMAX_LIMITS='"INTMAX"'
SCM_I_GSC_NEEDS_STDINT_H=1
elif test "$scm_inttypes_has_intmax"; then
SCM_I_GSC_T_INTMAX='"intmax_t"'
- SCM_I_GSC_T_INTMAX_LIMITS='"INTMAX"'
SCM_I_GSC_NEEDS_INTTYPES_H=1
elif test "$ac_cv_sizeof___int64" -ne 0; then
SCM_I_GSC_T_INTMAX='"__int64"'
- SCM_I_GSC_T_INTMAX_LIMITS='"unknown"'
elif test "$ac_cv_sizeof_long_long" -ne 0; then
SCM_I_GSC_T_INTMAX='"long long"'
- SCM_I_GSC_T_INTMAX_LIMITS='"SCM_I_LLONG"'
else
SCM_I_GSC_T_INTMAX='"long"'
- SCM_I_GSC_T_INTMAX_LIMITS='"LONG"'
fi
AC_SUBST([SCM_I_GSC_T_INTMAX])
-AC_SUBST([SCM_I_GSC_T_INTMAX_LIMITS])
### Required type scm_t_uintmax
###
@@ -547,24 +495,18 @@
SCM_I_GSC_T_UINTMAX=0
if test "$scm_stdint_has_uintmax"; then
SCM_I_GSC_T_UINTMAX='"uintmax_t"'
- SCM_I_GSC_T_UINTMAX_LIMITS='"UINTMAX"'
SCM_I_GSC_NEEDS_STDINT_H=1
elif test "$scm_inttypes_has_uintmax"; then
SCM_I_GSC_T_UINTMAX='"uintmax_t"'
- SCM_I_GSC_T_UINTMAX_LIMITS='"UINTMAX"'
SCM_I_GSC_NEEDS_INTTYPES_H=1
elif test "$ac_cv_sizeof_unsigned___int64" -ne 0; then
SCM_I_GSC_T_UINTMAX='"unsigned __int64"'
- SCM_I_GSC_T_UINTMAX_LIMITS='"unknown"'
elif test "$ac_cv_sizeof_unsigned_long_long" -ne 0; then
SCM_I_GSC_T_UINTMAX='"unsigned long long"'
- SCM_I_GSC_T_UINTMAX_LIMITS='"SCM_I_ULLONG"'
else
SCM_I_GSC_T_UINTMAX='"unsigned long"'
- SCM_I_GSC_T_UINTMAX_LIMITS='"ULONG"'
fi
AC_SUBST([SCM_I_GSC_T_UINTMAX])
-AC_SUBST([SCM_I_GSC_T_UINTMAX_LIMITS])
AC_SUBST([SCM_I_GSC_NEEDS_STDINT_H])
Index: libguile/gen-scmconfig.h.in
===================================================================
RCS file: /cvsroot/guile/guile/guile-core/libguile/gen-scmconfig.h.in,v
retrieving revision 1.3
diff -u -r1.3 gen-scmconfig.h.in
--- libguile/gen-scmconfig.h.in 7 Jul 2004 15:16:20 -0000 1.3
+++ libguile/gen-scmconfig.h.in 11 Jul 2004 09:32:05 -0000
@@ -16,25 +16,15 @@
#define SCM_I_GSC_NEEDS_STDINT_H @SCM_I_GSC_NEEDS_STDINT_H@
#define SCM_I_GSC_NEEDS_INTTYPES_H @SCM_I_GSC_NEEDS_INTTYPES_H@
#define SCM_I_GSC_T_INT8 @SCM_I_GSC_T_INT8@
-#define SCM_I_GSC_T_INT8_LIMITS @SCM_I_GSC_T_INT8_LIMITS@
#define SCM_I_GSC_T_UINT8 @SCM_I_GSC_T_UINT8@
-#define SCM_I_GSC_T_UINT8_LIMITS @SCM_I_GSC_T_UINT8_LIMITS@
#define SCM_I_GSC_T_INT16 @SCM_I_GSC_T_INT16@
-#define SCM_I_GSC_T_INT16_LIMITS @SCM_I_GSC_T_INT16_LIMITS@
#define SCM_I_GSC_T_UINT16 @SCM_I_GSC_T_UINT16@
-#define SCM_I_GSC_T_UINT16_LIMITS @SCM_I_GSC_T_UINT16_LIMITS@
#define SCM_I_GSC_T_INT32 @SCM_I_GSC_T_INT32@
-#define SCM_I_GSC_T_INT32_LIMITS @SCM_I_GSC_T_INT32_LIMITS@
#define SCM_I_GSC_T_UINT32 @SCM_I_GSC_T_UINT32@
-#define SCM_I_GSC_T_UINT32_LIMITS @SCM_I_GSC_T_UINT32_LIMITS@
#define SCM_I_GSC_T_INT64 @SCM_I_GSC_T_INT64@
-#define SCM_I_GSC_T_INT64_LIMITS @SCM_I_GSC_T_INT64_LIMITS@
#define SCM_I_GSC_T_UINT64 @SCM_I_GSC_T_UINT64@
-#define SCM_I_GSC_T_UINT64_LIMITS @SCM_I_GSC_T_UINT64_LIMITS@
#define SCM_I_GSC_T_INTMAX @SCM_I_GSC_T_INTMAX@
-#define SCM_I_GSC_T_INTMAX_LIMITS @SCM_I_GSC_T_INTMAX_LIMITS@
#define SCM_I_GSC_T_UINTMAX @SCM_I_GSC_T_UINTMAX@
-#define SCM_I_GSC_T_UINTMAX_LIMITS @SCM_I_GSC_T_UINTMAX_LIMITS@
#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@
Index: libguile/gen-scmconfig.c
===================================================================
RCS file: /cvsroot/guile/guile/guile-core/libguile/gen-scmconfig.c,v
retrieving revision 1.7
diff -u -r1.7 gen-scmconfig.c
--- libguile/gen-scmconfig.c 8 Jul 2004 15:31:39 -0000 1.7
+++ libguile/gen-scmconfig.c 11 Jul 2004 09:32:05 -0000
@@ -126,6 +126,13 @@
#include <stdio.h>
#include <string.h>
+#if SCM_I_GSC_NEEDS_STDINT_H
+# include <stdint.h>
+#endif
+#if SCM_I_GSC_NEEDS_INTTYPES_H
+# include <inttypes.h>
+#endif
+
#define pf printf
int
@@ -285,9 +292,21 @@
pf (" being on a C99 system (which we can't rely on yet). Thus,\n");
pf (" we define the limits on our own, assuming twos-complement.\n");
pf ("*/\n");
+#ifdef LLONG_MAX
+ pf ("#define SCM_I_LLONG_MAX LLONG_MAX\n");
+#else
pf ("#define SCM_I_LLONG_MAX ((long long) (SCM_I_ULLONG_MAX >> 1))\n");
+#endif
+#ifdef LLONG_MIN
+ pf ("#define SCM_I_LLONG_MIN LLONG_MIN\n");
+#else
pf ("#define SCM_I_LLONG_MIN (~SCM_I_LLONG_MAX)\n");
+#endif
+#ifdef ULLONG_MAX
+ pf ("#define SCM_I_ULLONG_MAX ULLONG_MAX\n");
+#else
pf ("#define SCM_I_ULLONG_MAX ((unsigned long long) (-1))\n");
+#endif
}
pf("\n");
@@ -316,15 +335,51 @@
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 ("#define SCM_T_INT8_MIN %s_MIN\n", SCM_I_GSC_T_INT8_LIMITS);
- pf ("#define SCM_T_INT8_MAX %s_MAX\n", SCM_I_GSC_T_INT8_LIMITS);
- pf ("#define SCM_T_UINT8_MAX %s_MAX\n", SCM_I_GSC_T_UINT8_LIMITS);
- pf ("#define SCM_T_INT16_MIN %s_MIN\n", SCM_I_GSC_T_INT16_LIMITS);
- pf ("#define SCM_T_INT16_MAX %s_MAX\n", SCM_I_GSC_T_INT16_LIMITS);
- pf ("#define SCM_T_UINT16_MAX %s_MAX\n", SCM_I_GSC_T_UINT16_LIMITS);
- pf ("#define SCM_T_INT32_MIN %s_MIN\n", SCM_I_GSC_T_INT32_LIMITS);
- pf ("#define SCM_T_INT32_MAX %s_MAX\n", SCM_I_GSC_T_INT32_LIMITS);
- pf ("#define SCM_T_UINT32_MAX %s_MAX\n", SCM_I_GSC_T_UINT32_LIMITS);
+#ifdef INT8_MIN
+ pf ("#define SCM_T_INT8_MIN INT8_MIN\n");
+#else
+ pf ("#define SCM_T_INT8_MIN ((scm_t_int8)(-128))\n");
+#endif
+#ifdef INT8_MAX
+ pf ("#define SCM_T_INT8_MAX INT8_MAX\n");
+#else
+ pf ("#define SCM_T_INT8_MAX ((scm_t_int8)(127))\n");
+#endif
+#ifdef UINT8_MAX
+ pf ("#define SCM_T_UINT8_MAX UINT8_MAX\n");
+#else
+ pf ("#define SCM_T_UINT8_MAX ((scm_t_uint8)(255U))\n");
+#endif
+#ifdef INT16_MIN
+ pf ("#define SCM_T_INT16_MIN INT16_MIN\n");
+#else
+ pf ("#define SCM_T_INT16_MIN ((scm_t_int16)(-32767-1))\n");
+#endif
+#ifdef INT16_MAX
+ pf ("#define SCM_T_INT16_MAX INT16_MAX\n");
+#else
+ pf ("#define SCM_T_INT16_MAX ((scm_t_int16)(32767))\n");
+#endif
+#ifdef UINT16_MAX
+ pf ("#define SCM_T_UINT16_MAX UINT16_MAX\n");
+#else
+ pf ("#define SCM_T_UINT16_MAX ((scm_t_uint16)(65535U))\n");
+#endif
+#ifdef INT32_MIN
+ pf ("#define SCM_T_INT32_MIN INT32_MIN\n");
+#else
+ pf ("#define SCM_T_INT32_MIN ((scm_t_int32)(-2147483647-1))\n");
+#endif
+#ifdef INT32_MAX
+ pf ("#define SCM_T_INT32_MAX INT32_MAX\n");
+#else
+ pf ("#define SCM_T_INT32_MAX ((scm_t_int32)(2147483647))\n");
+#endif
+#ifdef UINT32_MAX
+ pf ("#define SCM_T_UINT32_MAX UINT32_MAX\n");
+#else
+ pf ("#define SCM_T_UINT32_MAX ((scm_t_uint32)(4294967295U))\n");
+#endif
pf ("\n");
pf ("/* 64-bit integer -- if available SCM_HAVE_T_INT64 will be 1 and\n"
@@ -334,8 +389,24 @@
{
pf ("#define SCM_HAVE_T_INT64 1 /* 0 or 1 */\n");
pf ("typedef %s scm_t_int64;\n", SCM_I_GSC_T_INT64);
- pf ("#define SCM_T_INT64_MIN %s_MIN\n", SCM_I_GSC_T_INT64_LIMITS);
- pf ("#define SCM_T_INT64_MAX %s_MAX\n", SCM_I_GSC_T_INT64_LIMITS);
+#ifdef INT64_MIN
+ pf ("#define SCM_T_INT64_MIN INT64_MIN\n");
+#else
+# ifdef INT64_C
+ pf ("#define SCM_T_INT64_MIN ((scm_t_int64)(INT64_C(-9223372036854775807)-1))\n");
+# else
+ pf ("#define SCM_T_INT64_MIN ((scm_t_int64)(-9223372036854775807LL-1))\n");
+# endif
+#endif
+#ifdef INT64_MAX
+ pf ("#define SCM_T_INT64_MAX INT64_MAX\n");
+#else
+# ifdef INT64_C
+ pf ("#define SCM_T_INT64_MAX ((scm_t_int64)(INT64_C(9223372036854775807)))\n");
+# else
+ pf ("#define SCM_T_INT64_MAX ((scm_t_int64)(9223372036854775807LL))\n");
+# endif
+#endif
}
else
pf ("#define SCM_HAVE_T_INT64 0 /* 0 or 1 */\n");
@@ -348,14 +419,40 @@
{
pf ("#define SCM_HAVE_T_UINT64 1 /* 0 or 1 */\n");
pf ("typedef %s scm_t_uint64;\n", SCM_I_GSC_T_UINT64);
- pf ("#define SCM_T_UINT64_MAX %s_MAX\n", SCM_I_GSC_T_UINT64_LIMITS);
+#ifdef UINT64_MAX
+ pf ("#define SCM_T_UINT64_MAX UINT64_MAX\n");
+#else
+# ifdef UINT64_C
+ pf ("#define SCM_T_UINT64_MAX ((scm_t_uint64)(UINT64_C(18446744073709551615)))\n");
+# else
+ pf ("#define SCM_T_UINT64_MAX ((scm_t_uint64)(18446744073709551615ULL))\n");
+# endif
+#endif
}
else
pf ("#define SCM_HAVE_T_UINT64 0 /* 0 or 1 */\n");
- pf ("#define SCM_T_INTMAX_MIN %s_MIN\n", SCM_I_GSC_T_INTMAX_LIMITS);
- pf ("#define SCM_T_INTMAX_MAX %s_MAX\n", SCM_I_GSC_T_INTMAX_LIMITS);
- pf ("#define SCM_T_UINTMAX_MAX %s_MAX\n", SCM_I_GSC_T_UINTMAX_LIMITS);
+#ifdef INTMAX_MIN
+ pf ("#define SCM_T_INTMAX_MIN INTMAX_MIN\n");
+#elif SIZEOF_LONG_LONG
+ pf ("#define SCM_T_INTMAX_MIN SCM_I_LLONG_MIN\n");
+#else
+ pf ("#define SCM_T_INTMAX_MIN LONG_MIN\n");
+#endif
+#ifdef INTMAX_MAX
+ pf ("#define SCM_T_INTMAX_MAX INTMAX_MAX\n");
+#elif SIZEOF_LONG_LONG
+ pf ("#define SCM_T_INTMAX_MAX SCM_I_LLONG_MAX\n");
+#else
+ pf ("#define SCM_T_INTMAX_MAX LONG_MAX\n");
+#endif
+#ifdef UINTMAX_MAX
+ pf ("#define SCM_T_UINTMAX_MAX UINTMAX_MAX\n");
+#elif SIZEOF_LONG_LONG
+ pf ("#define SCM_T_UINTMAX_MAX SCM_I_ULLONG_MAX\n");
+#else
+ pf ("#define SCM_T_UINTMAX_MAX ULONG_MAX\n");
+#endif
pf ("\n");
pf ("/* scm_t_ptrdiff_t and size, always defined -- defined to long if\n"
[-- Attachment #3: Type: text/plain, Size: 143 bytes --]
_______________________________________________
Guile-devel mailing list
Guile-devel@gnu.org
http://lists.gnu.org/mailman/listinfo/guile-devel
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2004-07-11 9:56 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2004-07-10 8:47 OpenBSD does not define INT8_MIN etc Andreas Vögele
2004-07-10 12:32 ` Andreas Vögele
2004-07-10 13:26 ` Marius Vollmer
2004-07-10 14:43 ` Andreas Vögele
2004-07-11 9:56 ` Andreas Vögele
2004-07-10 15:57 ` Paul Jarc
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).