unofficial mirror of guile-devel@gnu.org 
 help / color / mirror / Atom feed
* Portability bug with UINTPTR_MAX in Solaris/Forte
@ 2003-06-18  6:25 Matthias Koeppe
  2003-06-21  1:20 ` Kevin Ryde
  0 siblings, 1 reply; 6+ messages in thread
From: Matthias Koeppe @ 2003-06-18  6:25 UTC (permalink / raw)


I have trouble compiling Guile from CVS HEAD on Solaris 7 and 8 using
the Forte (Sun Workshop) C compiler.  The reason is the new code
using `uintptr_t' (declarations in tags.h).

On Solaris, there is a uintptr_t, and UINTPTR_MAX is also a defined
macro, but it expands to nothing.  (/usr/include/sys/int_limits.h,
line 124.)  This causes the compilation of libguile/print.c (for
instance) to fail.

I would suggest that the presence of both uintptr_t and a useful value
UINTPTR_MAX should be checked at configuration time.

I am not sending a patch, but I am willing to test patches that fix
this problem, in case you don't have access to Solaris (or a non-gcc
compiler). 

-- 
Matthias Köppe -- http://www.math.uni-magdeburg.de/~mkoeppe


_______________________________________________
Guile-devel mailing list
Guile-devel@gnu.org
http://mail.gnu.org/mailman/listinfo/guile-devel


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Portability bug with UINTPTR_MAX in Solaris/Forte
  2003-06-18  6:25 Portability bug with UINTPTR_MAX in Solaris/Forte Matthias Koeppe
@ 2003-06-21  1:20 ` Kevin Ryde
  2003-06-23  9:15   ` Matthias Koeppe
  0 siblings, 1 reply; 6+ messages in thread
From: Kevin Ryde @ 2003-06-21  1:20 UTC (permalink / raw)
  Cc: guile-devel

[-- Attachment #1: Type: text/plain, Size: 273 bytes --]

Matthias Koeppe <mkoeppe@merkur.math.uni-magdeburg.de> writes:
>
> On Solaris, there is a uintptr_t, and UINTPTR_MAX is also a defined
> macro, but it expands to nothing.

Literally nothing?  Perhaps the change below would do the trick.
Does the same apply to INTPTR_MAX?


[-- Attachment #2: tags.h.solaris-uintptr.diff --]
[-- Type: text/plain, Size: 564 bytes --]

--- tags.h.~1.103.~	2003-06-12 10:58:55.000000000 +1000
+++ tags.h	2003-06-21 11:19:56.000000000 +1000
@@ -49,7 +49,9 @@
 #define SCM_T_SIGNED_BITS_MIN LONG_MIN
 #endif
 
-#if SCM_SIZEOF_UINTPTR_T != 0 && defined(UINTPTR_MAX)
+/* On solaris 7 and 8, Sun workshop cc has UINTPTR_MAX defined to empty.  To
+   avoid uintptr_t in this case we require UINTPTR_MAX-0 != 0.  */
+#if SCM_SIZEOF_UINTPTR_T != 0 && defined(UINTPTR_MAX) && UINTPTR_MAX-0 != 0
 typedef uintptr_t scm_t_bits;
 #define SIZEOF_SCM_T_BITS SCM_SIZEOF_UINTPTR_T
 #define SCM_T_BITS_MAX UINTPTR_MAX

[-- Attachment #3: Type: text/plain, Size: 142 bytes --]

_______________________________________________
Guile-devel mailing list
Guile-devel@gnu.org
http://mail.gnu.org/mailman/listinfo/guile-devel

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Portability bug with UINTPTR_MAX in Solaris/Forte
  2003-06-21  1:20 ` Kevin Ryde
@ 2003-06-23  9:15   ` Matthias Koeppe
  2003-06-23 23:05     ` Kevin Ryde
  0 siblings, 1 reply; 6+ messages in thread
From: Matthias Koeppe @ 2003-06-23  9:15 UTC (permalink / raw)


Kevin Ryde <user42@zip.com.au> writes:

> Matthias Koeppe <mkoeppe@merkur.math.uni-magdeburg.de> writes:
>>
>> On Solaris, there is a uintptr_t, and UINTPTR_MAX is also a defined
>> macro, but it expands to nothing.
>
> Literally nothing?  Perhaps the change below would do the trick.
> Does the same apply to INTPTR_MAX?

Thanks, your trick does the change.  (I still think that tricky
things like this should be checked at `configure' time, rather than
during compilation, though.)

The same does not apply to the signed version because INTPTR_MIN is
not defined at all.  I have updated your patch to check this anyway,
for "completeness".

--- tags.h.~1.103.~	Mon Jun 16 16:50:07 2003
+++ tags.h	Mon Jun 23 11:13:09 2003
@@ -39,7 +39,11 @@
 
 /* In the beginning was the Word:
  */
-#if SCM_SIZEOF_INTPTR_T != 0 && defined(INTPTR_MAX) && defined(INTPTR_MIN)
+/* 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
 typedef intptr_t scm_t_signed_bits;
 #define SCM_T_SIGNED_BITS_MAX INTPTR_MAX
 #define SCM_T_SIGNED_BITS_MIN INTPTR_MIN
@@ -49,7 +53,7 @@
 #define SCM_T_SIGNED_BITS_MIN LONG_MIN
 #endif
 
-#if SCM_SIZEOF_UINTPTR_T != 0 && defined(UINTPTR_MAX)
+#if SCM_SIZEOF_UINTPTR_T != 0 && defined(UINTPTR_MAX) && UINTPTR_MAX-0 != 0
 typedef uintptr_t scm_t_bits;
 #define SIZEOF_SCM_T_BITS SCM_SIZEOF_UINTPTR_T
 #define SCM_T_BITS_MAX UINTPTR_MAX

-- 
Matthias Koeppe -- http://www.math.uni-magdeburg.de/~mkoeppe


_______________________________________________
Guile-devel mailing list
Guile-devel@gnu.org
http://mail.gnu.org/mailman/listinfo/guile-devel


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Portability bug with UINTPTR_MAX in Solaris/Forte
  2003-06-23  9:15   ` Matthias Koeppe
@ 2003-06-23 23:05     ` Kevin Ryde
  2003-06-25 15:17       ` Matthias Koeppe
  0 siblings, 1 reply; 6+ messages in thread
From: Kevin Ryde @ 2003-06-23 23:05 UTC (permalink / raw)
  Cc: guile-devel

Matthias Koeppe <mkoeppe@merkur.math.uni-magdeburg.de> writes:
>
> (I still think that tricky
> things like this should be checked at `configure' time, rather than
> during compilation, though.)

Oh, well, no need to add to the configure script if a cpp conditional
can do it cleanly and portably.

> +/* On Solaris 7 and 8, /usr/include/sys/int_limits.h defines
> +   INTPTR_MAX and UINTPTR_MAX to empty, INTPTR_MIN is not defined.

That's a typo there is it?  Only UINTPTR_MAX defined to empty.

> +#if SCM_SIZEOF_INTPTR_T != 0 && defined(INTPTR_MAX) && defined(INTPTR_MIN) && INTPTR_MAX-0 != 0 && INTPTR_MIN-0 != 0

While you're at it you might like to merge the tests so scm_t_bits and
scm_t_signed_bits are both based on "intptr" stuff, or both on "long",
rather than having separate conditionals.  Wouldn't want them to come
out different.


_______________________________________________
Guile-devel mailing list
Guile-devel@gnu.org
http://mail.gnu.org/mailman/listinfo/guile-devel


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Portability bug with UINTPTR_MAX in Solaris/Forte
  2003-06-23 23:05     ` Kevin Ryde
@ 2003-06-25 15:17       ` Matthias Koeppe
  2003-07-05  0:03         ` Kevin Ryde
  0 siblings, 1 reply; 6+ messages in thread
From: Matthias Koeppe @ 2003-06-25 15:17 UTC (permalink / raw)


Kevin Ryde <user42@zip.com.au> writes:

> Matthias Koeppe <mkoeppe@merkur.math.uni-magdeburg.de> writes:
>> +/* On Solaris 7 and 8, /usr/include/sys/int_limits.h defines
>> +   INTPTR_MAX and UINTPTR_MAX to empty, INTPTR_MIN is not defined.
>
> That's a typo there is it?  Only UINTPTR_MAX defined to empty.

No, it's exactly as I wrote.  From int_limits.h:

| /*
|  * The following 2 macros are provided for testing whether the types
|  * intptr_t and uintptr_t (integers large enough to hold a void *) are
|  * defined in this header. They are needed in case the architecture can't
|  * represent a pointer in any standard integral type.
|  */
| #define INTPTR_MAX
| #define UINTPTR_MAX
 
>> +#if SCM_SIZEOF_INTPTR_T != 0 && defined(INTPTR_MAX) && defined(INTPTR_MIN) && INTPTR_MAX-0 != 0 && INTPTR_MIN-0 != 0
>
> While you're at it you might like to merge the tests so scm_t_bits and
> scm_t_signed_bits are both based on "intptr" stuff, or both on "long",
> rather than having separate conditionals.  Wouldn't want them to come
> out different.

OK, here is an updated patch.  Will you commit this change?  (I don't
have CVS write permissions.)

--- tags.h.~1.103.~	Mon Jun 16 16:50:07 2003
+++ tags.h	Wed Jun 25 16:51:10 2003
@@ -39,24 +39,30 @@
 
 /* In the beginning was the Word:
  */
-#if SCM_SIZEOF_INTPTR_T != 0 && defined(INTPTR_MAX) && defined(INTPTR_MIN)
+/* 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
-#else
-typedef signed long scm_t_signed_bits;
-#define SCM_T_SIGNED_BITS_MAX LONG_MAX
-#define SCM_T_SIGNED_BITS_MIN LONG_MIN
-#endif
-
-#if SCM_SIZEOF_UINTPTR_T != 0 && defined(UINTPTR_MAX)
 typedef uintptr_t scm_t_bits;
 #define SIZEOF_SCM_T_BITS SCM_SIZEOF_UINTPTR_T
 #define SCM_T_BITS_MAX UINTPTR_MAX
+
 #else
+
+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 use SCM, which may, according to the desired

-- 
Matthias Koeppe -- http://www.math.uni-magdeburg.de/~mkoeppe


_______________________________________________
Guile-devel mailing list
Guile-devel@gnu.org
http://mail.gnu.org/mailman/listinfo/guile-devel


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Portability bug with UINTPTR_MAX in Solaris/Forte
  2003-06-25 15:17       ` Matthias Koeppe
@ 2003-07-05  0:03         ` Kevin Ryde
  0 siblings, 0 replies; 6+ messages in thread
From: Kevin Ryde @ 2003-07-05  0:03 UTC (permalink / raw)
  Cc: guile-devel

Matthias Koeppe <mkoeppe@merkur.math.uni-magdeburg.de> writes:
>
> OK, here is an updated patch.  Will you commit this change?  (I don't
> have CVS write permissions.)

Me?  Ok.  Do you have copyright assignment paperwork on file?


_______________________________________________
Guile-devel mailing list
Guile-devel@gnu.org
http://mail.gnu.org/mailman/listinfo/guile-devel


^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2003-07-05  0:03 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2003-06-18  6:25 Portability bug with UINTPTR_MAX in Solaris/Forte Matthias Koeppe
2003-06-21  1:20 ` Kevin Ryde
2003-06-23  9:15   ` Matthias Koeppe
2003-06-23 23:05     ` Kevin Ryde
2003-06-25 15:17       ` Matthias Koeppe
2003-07-05  0:03         ` Kevin Ryde

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).