bug-gnulib
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

stdint: fix for Sun C compiler


From: Bruno Haible
Subject: stdint: fix for Sun C compiler
Date: Mon, 12 Mar 2007 04:04:16 +0100
User-agent: KMail/1.5.4

The test in test-stdint.c that verifies that INTMAX_MIN is nonzero when
tested as a preprocessor expression fails with SunPRO C 5.0. This works
around it, by replacing the expression
    (~ 9223372036854775807LL)
with
    ((-1LL) << 63)


2007-03-11  Bruno Haible  <address@hidden>

        * lib/stdint_.h (INT64_MIN, INTMAX_MIN): Avoid using the ~INT..._MAX
        formula. Needed for SunPRO C 5.0.

*** lib/stdint_.h       10 Mar 2007 15:03:27 -0000      1.39
--- lib/stdint_.h       12 Mar 2007 02:58:48 -0000
***************
*** 277,283 ****
  #undef INT64_MIN
  #undef INT64_MAX
  #ifdef GL_INT64_T
! # define INT64_MIN  (~ INT64_MAX)
  # define INT64_MAX  INTMAX_C (9223372036854775807)
  #endif
  
--- 277,285 ----
  #undef INT64_MIN
  #undef INT64_MAX
  #ifdef GL_INT64_T
! /* Prefer (- INTMAX_C (1) << 63) over (~ INT64_MAX) because SunPRO C 5.0
!    evaluates the latter incorrectly in preprocessor expressions.  */
! # define INT64_MIN  (- INTMAX_C (1) << 63)
  # define INT64_MAX  INTMAX_C (9223372036854775807)
  #endif
  
***************
*** 377,386 ****
  
  #undef INTMAX_MIN
  #undef INTMAX_MAX
- #define INTMAX_MIN  (~ INTMAX_MAX)
  #ifdef INT64_MAX
  # define INTMAX_MAX  INT64_MAX
  #else
  # define INTMAX_MAX  INT32_MAX
  #endif
  
--- 379,389 ----
  
  #undef INTMAX_MIN
  #undef INTMAX_MAX
  #ifdef INT64_MAX
+ # define INTMAX_MIN  INT64_MIN
  # define INTMAX_MAX  INT64_MAX
  #else
+ # define INTMAX_MIN  INT32_MIN
  # define INTMAX_MAX  INT32_MAX
  #endif
  





reply via email to

[Prev in Thread] Current Thread [Next in Thread]