From 539064d4f73269a887ea032cac431f84fea594e7 Mon Sep 17 00:00:00 2001 From: Brad King Date: Wed, 20 Jun 2012 08:17:05 -0400 Subject: [PATCH 1/4] KWIML: Generalize interface to report broken integer literal macros The header on some platforms define the integer literal macros incorrectly for some of the integer types. Generalize the documented interface reporting broken U/INT64_C to all integer sizes. --- INT.h.in | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/INT.h.in b/INT.h.in index d40edcde4..c760b9e5c 100644 --- a/INT.h.in +++ b/INT.h.in @@ -91,10 +91,11 @@ An includer may test the following macros after inclusion: Some compilers define integer format macros incorrectly for their own formatted print/scan implementations. - @KWIML@_INT_BROKEN_INT64_C = macro INT64_C is incorrect if defined - @KWIML@_INT_BROKEN_UINT64_C = macro UINT64_C is incorrect if defined + @KWIML@_INT_BROKEN_INT#_C = macro INT#_C is incorrect if defined + @KWIML@_INT_BROKEN_UINT#_C = macro UINT#_C is incorrect if defined Some compilers define integer constant macros incorrectly and - cannot handle literals as large as the integer type. + cannot handle literals as large as the integer type or even + produce bad preprocessor syntax. @KWIML@_INT_BROKEN_INT8_T = type 'int8_t' is available but incorrect Some compilers have a flag to make 'char' (un)signed but do not account @@ -341,12 +342,12 @@ An includer may test the following macros after inclusion: #endif /* 8-bit constants */ -#if defined(INT8_C) +#if defined(INT8_C) && !defined(@KWIML@_INT_BROKEN_INT8_C) # define @KWIML@_INT_INT8_C(c) INT8_C(c) #else # define @KWIML@_INT_INT8_C(c) c #endif -#if defined(UINT8_C) +#if defined(UINT8_C) && !defined(@KWIML@_INT_BROKEN_UINT8_C) # define @KWIML@_INT_UINT8_C(c) UINT8_C(c) #else # define @KWIML@_INT_UINT8_C(c) c ## u @@ -435,12 +436,12 @@ An includer may test the following macros after inclusion: #endif /* 16-bit constants */ -#if defined(INT16_C) +#if defined(INT16_C) && !defined(@KWIML@_INT_BROKEN_INT16_C) # define @KWIML@_INT_INT16_C(c) INT16_C(c) #else # define @KWIML@_INT_INT16_C(c) c #endif -#if defined(UINT16_C) +#if defined(UINT16_C) && !defined(@KWIML@_INT_BROKEN_UINT16_C) # define @KWIML@_INT_UINT16_C(c) UINT16_C(c) #else # define @KWIML@_INT_UINT16_C(c) c ## u @@ -529,12 +530,12 @@ An includer may test the following macros after inclusion: #endif /* 32-bit constants */ -#if defined(INT32_C) +#if defined(INT32_C) && !defined(@KWIML@_INT_BROKEN_INT32_C) # define @KWIML@_INT_INT32_C(c) INT32_C(c) #else # define @KWIML@_INT_INT32_C(c) c #endif -#if defined(UINT32_C) +#if defined(UINT32_C) && !defined(@KWIML@_INT_BROKEN_UINT32_C) # define @KWIML@_INT_UINT32_C(c) UINT32_C(c) #else # define @KWIML@_INT_UINT32_C(c) c ## u From 6dc053114b8fe213e7d1b41f99d1ec4ab436d29a Mon Sep 17 00:00:00 2001 From: Brad King Date: Wed, 20 Jun 2012 13:16:48 -0400 Subject: [PATCH 2/4] KWIML: Teach ABI.h about 'long long' and 'char' on old HP The "HP92453-01 A.11.01.20 HP C Compiler" does not define any identifying macros except for platform __hpux. If we see that platform with no other compiler identification then assume this compiler. It has 'long long' and its 'char' is signed unless the +uc option is added. --- ABI.h.in | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/ABI.h.in b/ABI.h.in index e85a1c588..060a520db 100644 --- a/ABI.h.in +++ b/ABI.h.in @@ -156,6 +156,8 @@ suppression macro @KWIML@_ABI_NO_VERIFY was defined. # define @KWIML@_ABI_CHAR_IS_UNSIGNED 1 # elif defined(__BORLANDC__) /* Borland default */ # define @KWIML@_ABI_CHAR_IS_SIGNED 1 +# elif defined(__hpux) /* Old HP: no __HP_cc/__HP_aCC/__GNUC__ above */ +# define @KWIML@_ABI_CHAR_IS_SIGNED 1 /* (unless +uc) */ # endif #endif #if !defined(@KWIML@_ABI_CHAR_IS_UNSIGNED) && !defined(@KWIML@_ABI_CHAR_IS_SIGNED) \ @@ -251,6 +253,8 @@ suppression macro @KWIML@_ABI_NO_VERIFY was defined. # else # define @KWIML@_ABI_SIZEOF_LONG_LONG 0 # endif +# elif defined(__hpux) && !defined(__GNUC__) /* Old HP: no __HP_cc/__HP_aCC above */ +# define @KWIML@_ABI_SIZEOF_LONG_LONG 8 # endif #endif #if !defined(@KWIML@_ABI_SIZEOF_LONG_LONG) && !defined(@KWIML@_ABI_NO_ERROR_LONG_LONG) From 64d0e15627e72e4d96297096dd5c63598827ed10 Mon Sep 17 00:00:00 2001 From: Brad King Date: Wed, 20 Jun 2012 13:28:24 -0400 Subject: [PATCH 3/4] KWIML: Teach INT.h that no HP platform implements SCN*8 formats The "hh" class of scan formats is not implemented by the HP runtime. --- INT.h.in | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/INT.h.in b/INT.h.in index c760b9e5c..ee4c4bb82 100644 --- a/INT.h.in +++ b/INT.h.in @@ -260,8 +260,6 @@ An includer may test the following macros after inclusion: # endif #elif defined(__SUNPRO_C) || defined(__SUNPRO_CC) # define @KWIML@_INT__NO_SCN8 -#elif defined(__HP_cc) || defined(__HP_aCC) -# define @KWIML@_INT__NO_SCN8 #elif defined(__BORLANDC__) # define @KWIML@_INT__NO_SCN8 # define @KWIML@_INT__NO_SCN64 @@ -269,6 +267,8 @@ An includer may test the following macros after inclusion: # define @KWIML@_INT__NO_SCN8 #elif defined(__WATCOMC__) # define @KWIML@_INT__NO_SCN8 +# elif defined(__hpux) /* HP runtime lacks support (any compiler) */ +# define @KWIML@_INT__NO_SCN8 #endif /* 8-bit d, i */ From ec1d35248510235483abdf1294afb96500ae910f Mon Sep 17 00:00:00 2001 From: Brad King Date: Wed, 20 Jun 2012 13:48:11 -0400 Subject: [PATCH 4/4] KWIML: Teach INT about broken UINT32_C on old HP Old HP inttypes.h defines UINT32_C as: #define __CONCAT__(_A,_B) _A ## _B #define __CONCAT_U__(_A) _A ## u #define UINT32_C(__c) __CONCAT__(__CONCAT_U__(__c),l) The __CONCAT__ macro does not delay concatenation for an extra level so standard preprocessor implementations like GNU complain that they cannot concatenate the ")" and "l". --- INT.h.in | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/INT.h.in b/INT.h.in index ee4c4bb82..d2eda6387 100644 --- a/INT.h.in +++ b/INT.h.in @@ -529,6 +529,12 @@ An includer may test the following macros after inclusion: # define @KWIML@_INT_PRIX32 "X" #endif +#if defined(__hpux) && defined(__GNUC__) && !defined(__LP64__) \ + && defined(__CONCAT__) && defined(__CONCAT_U__) + /* Some HPs define UINT32_C incorrectly and break GNU. */ +# define @KWIML@_INT_BROKEN_UINT32_C +#endif + /* 32-bit constants */ #if defined(INT32_C) && !defined(@KWIML@_INT_BROKEN_INT32_C) # define @KWIML@_INT_INT32_C(c) INT32_C(c)