From: Jarkko Hietaniemi Date: Sat, 16 Jun 2001 22:47:40 +0000 (+0000) Subject: Add workaround for Darwin's (Mac OS X's) INT32_MIN X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=ccf874816b57b9b91848a81cf43371bf7b3f17c8;p=p5sagit%2Fp5-mst-13.2.git Add workaround for Darwin's (Mac OS X's) INT32_MIN (and INT64_MIN) brokenness. p4raw-id: //depot/perl@10649 --- diff --git a/hints/darwin.sh b/hints/darwin.sh index bf5e487..d99af92 100644 --- a/hints/darwin.sh +++ b/hints/darwin.sh @@ -41,6 +41,25 @@ optimize='-O3'; # We have a prototype for telldir. ccflags="${ccflags} -pipe -fno-common -DHAS_TELLDIR_PROTOTYPE"; +# At least OS X 10.0.3: +# +# # define INT32_MIN -2147483648 +# int main () { +# double a = INT32_MIN; +# printf ("INT32_MIN=%g\n", a); +# return 0; +# } +# will output: +# INT32_MIN=2.14748e+09 +# Note that the INT32_MIN has become positive. +# INT32_MIN is set in /usr/include/stdint.h by: +# #define INT32_MIN -2147483648 +# which seems to break the gcc. Defining INT32_MIN as (-2147483647-1) +# seems to work. INT64_MIN seems to be similarly broken. +# -- Nicholas Clark, Ken Williams, and Edward Moy +# +ccflags="${ccflags} -DINT32_MIN_BROKEN -DINT64_MIN_BROKEN" + # For Errno. cppflags='-traditional-cpp'; diff --git a/perl.h b/perl.h index 4c82ca7..a0405d1 100644 --- a/perl.h +++ b/perl.h @@ -1082,6 +1082,16 @@ int sockatmark(int); typedef IVTYPE IV; typedef UVTYPE UV; +#ifdef INT32_MIN_BROKEN +# undef INT32_MIN +# define INT32_MIN (-2147483647-1) +#endif + +#ifdef INT64_MIN_BROKEN +# undef INT64_MIN +# define INT64_MIN (-9223372036854775807LL-1) +#endif + #if defined(USE_64_BIT_INT) && defined(HAS_QUAD) # if QUADKIND == QUAD_IS_INT64_T && defined(INT64_MAX) # define IV_MAX INT64_MAX