Skip to contentSkip to conversation

Comment for Solaris fix for the HPTC

Qemu-devel Ben Taylor 3 participants 3 messages Sep 16, 2007

lore
Share & tools
lore

Ben Taylor

author
#0 lore raw
Quoted 4 lines · ---- Johannes Schindelin

Hi Ben,

On Sat, 15 Sep 2007, Ben Taylor wrote:

Quoted 9 lines

Review

Quoted 6 lines
(quoted diff) +6 -0
+#ifdef __sun__
+/* Have to define this for Solaris as ULONG_LONG_MAX is not defined
+   anywhere.  ULONG_MAX is correct only on _LP64 systems */
+#define ULONG_LONG_MAX 18446744073709551615UL
+#endif
+

These constants are always defined, right? So why not "#ifndef ULONG_LONG_MAX"?

I fear I may not have explained this well.

On the Solaris systems I have access to, I find no system include file that defines "ULONG_LONG_MAX".

There are defines for ULONG_MAX which is equivilent to the value that ULONG_LONG_MAX is, but only when the system is being compiled on an "_LP64" (ie x86_64) system. When the system is 32-bit, ULONG_MAX defaults to a typical max value for a 32-bit unsigned int.

That help?

Ben

#1 lore raw
Quoted 17 lines · Ben Taylor
Quoted 4 lines · ---- Johannes Schindelin

Hi Ben,

On Sat, 15 Sep 2007, Ben Taylor wrote:

Quoted 9 lines

Review

Quoted 6 lines
(quoted diff) +6 -0
+#ifdef __sun__
+/* Have to define this for Solaris as ULONG_LONG_MAX is not defined
+   anywhere.  ULONG_MAX is correct only on _LP64 systems */
+#define ULONG_LONG_MAX 18446744073709551615UL
+#endif
+

These constants are always defined, right? So why not "#ifndef ULONG_LONG_MAX"?

I fear I may not have explained this well.

Quoted 7 lines

On the Solaris systems I have access to, I find no system include file that defines "ULONG_LONG_MAX".

There are defines for ULONG_MAX which is equivilent to the value that ULONG_LONG_MAX is, but only when the system is being compiled on an "_LP64" (ie x86_64) system. When the system is 32-bit, ULONG_MAX defaults to a typical max value for a 32-bit unsigned int.

Your reference to ULONG_MAX is a red herring. ULONG_MAX is the limit for unsigned long, and ULONG_LONG_MAX is the limit for unsigned long long. If your compiler does not support the long long type then ULONG_LONG_MAX should not be defined either. Instead, vl.c should use UINT64_MAX.

Andreas.

Signature · 4 lines
Andreas Schwab, SuSE Labs, [email protected]
SuSE Linux Products GmbH, Maxfeldstraße 5, 90409 Nürnberg, Germany
PGP key fingerprint = 58CA 54C7 6D53 942B 1756  01D3 44D5 214B 8276 4ED5
"And now for something completely different."
#2 lore raw
In reply to Ben Taylor

Hi,

Quoted 14 lines · Ben Taylor
Quoted 11 lines · ---- Johannes Schindelin

Review

Quoted 6 lines · Ben Taylor
(quoted diff) +6 -0
+#ifdef __sun__
+/* Have to define this for Solaris as ULONG_LONG_MAX is not defined
+   anywhere.  ULONG_MAX is correct only on _LP64 systems */
+#define ULONG_LONG_MAX 18446744073709551615UL
+#endif
+

These constants are always defined, right? So why not "#ifndef ULONG_LONG_MAX"?

Quoted 1 line

I fear I may not have explained this well.

I fear _I_ may not have made myself very clear. What I meant was: why not check if ULONG_LONG_MAX is undefined, instead of checking if __sun__ is defined? That way, more than one platform might benefit from this change.

Just an idea,
Dscho