unofficial mirror of guile-devel@gnu.org 
 help / color / mirror / Atom feed
From: "Andreas Vögele" <voegelas@gmx.net>
Subject: Re: OpenBSD does not define INT8_MIN etc.
Date: Sat, 10 Jul 2004 14:32:44 +0200	[thread overview]
Message-ID: <3E3F013A-D26D-11D8-B8F3-000D93673682@gmx.net> (raw)
In-Reply-To: <CFC422FF-D24D-11D8-B8F3-000D93673682@gmx.net>

[-- 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

  reply	other threads:[~2004-07-10 12:32 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-07-10  8:47 OpenBSD does not define INT8_MIN etc Andreas Vögele
2004-07-10 12:32 ` Andreas Vögele [this message]
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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/guile/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=3E3F013A-D26D-11D8-B8F3-000D93673682@gmx.net \
    --to=voegelas@gmx.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).