Mercurial > hg > octave-kai > gnulib-hg
changeset 14711:65d598825e03
intprops: Sun C 5.11 supports __typeof__
* lib/intprops.h (_GL_HAVE___TYPEOF__): New macro, which is set
for either GCC 2 or later, as before, or for Sun C 5.11 or later,
which is new.
(_GL_SIGNED_TYPE_OR_EXPR): Use it.
author | Paul Eggert <eggert@cs.ucla.edu> |
---|---|
date | Sun, 08 May 2011 12:28:01 -0700 |
parents | be8a8d04fbc8 |
children | 276333590a0c |
files | ChangeLog lib/intprops.h |
diffstat | 2 files changed, 24 insertions(+), 7 deletions(-) [+] |
line wrap: on
line diff
--- a/ChangeLog +++ b/ChangeLog @@ -1,8 +1,15 @@ 2011-05-08 Paul Eggert <eggert@cs.ucla.edu> + intprops: Sun C 5.11 supports __typeof__ + * lib/intprops.h (_GL_HAVE___TYPEOF__): New macro, which is set + for either GCC 2 or later, as before, or for Sun C 5.11 or later, + which is new. + (_GL_SIGNED_TYPE_OR_EXPR): Use it. + intprops: switch to usual gnulib indenting and naming * lib/intprops.h (_GL_INTPROPS_H): Rename from GL_INTPROPS_H. (_GL_SIGNED_TYPE_OR_EXPR): Rename from signed_type_or_expr__. + * tests/test-inttostr.c (IS_TIGHT): Adjust to above renaming. 2011-05-08 Jim Meyering <meyering@redhat.com>
--- a/lib/intprops.h +++ b/lib/intprops.h @@ -55,12 +55,18 @@ ? (t) -1 \ : ((((t) 1 << (sizeof (t) * CHAR_BIT - 2)) - 1) * 2 + 1))) -/* Return zero if T can be determined to be an unsigned type. - Otherwise, return 1. - When compiling with GCC, INT_STRLEN_BOUND uses this macro to obtain a - tighter bound. Otherwise, it overestimates the true bound by one byte - when applied to unsigned types of size 2, 4, 16, ... bytes. */ -#if __GNUC__ >= 2 +/* Return 1 if the __typeof__ keyword works. This could be done by + 'configure', but for now it's easier to do it by hand. */ +#if 2 <= __GNUC__ || 0x5110 <= __SUNPRO_C +# define _GL_HAVE___TYPEOF__ 1 +#else +# define _GL_HAVE___TYPEOF__ 0 +#endif + +/* Return 1 if the integer type or expression T might be signed. Return 0 + if it is definitely unsigned. This macro does not evaluate its argument, + and expands to an integer constant expression. */ +#if _GL_HAVE___TYPEOF__ # define _GL_SIGNED_TYPE_OR_EXPR(t) TYPE_SIGNED (__typeof__ (t)) #else # define _GL_SIGNED_TYPE_OR_EXPR(t) 1 @@ -73,7 +79,11 @@ /* Bound on length of the string representing an integer type or expression T. Subtract 1 for the sign bit if T is signed, and then add 1 more for - a minus sign if needed. */ + a minus sign if needed. + + Because _GL_SIGNED_TYPE_OR_EXPR sometimes returns 0 when its argument is + signed, this macro may overestimate the true bound by one byte when + applied to unsigned types of size 2, 4, 16, ... bytes. */ #define INT_STRLEN_BOUND(t) \ (INT_BITS_STRLEN_BOUND (sizeof (t) * CHAR_BIT \ - _GL_SIGNED_TYPE_OR_EXPR (t)) \