diff --git a/newlib/ChangeLog b/newlib/ChangeLog index bb8988804..c8dbd7f52 100644 --- a/newlib/ChangeLog +++ b/newlib/ChangeLog @@ -1,3 +1,8 @@ +2011-08-23 Ralf Corsépius + + * libc/sys/rtems/include/limits.h: Compute SSIZE_MAX based on + __SIZE_MAX__, __SIZEOF_SIZE_T__ and __CHAR_BIT__. + 2011-08-22 Ralf Corsépius * libc/string/index.c: Include for "index". diff --git a/newlib/libc/sys/rtems/include/limits.h b/newlib/libc/sys/rtems/include/limits.h index 13e168c0a..43ede04e6 100644 --- a/newlib/libc/sys/rtems/include/limits.h +++ b/newlib/libc/sys/rtems/include/limits.h @@ -78,7 +78,13 @@ * Invariant values */ +#ifdef __SIZE_MAX__ +#define SSIZE_MAX (__SIZE_MAX__ >> 1) +#elif defined(__SIZEOF_SIZE_T__) && defined(__CHAR_BIT__) +#define SSIZE_MAX ((1UL << (__SIZEOF_SIZE_T__ * __CHAR_BIT__ - 1)) - 1) +#else /* historic fallback, wrong in most cases */ #define SSIZE_MAX 32767 +#endif /* * Maximum Values