This is the mail archive of the
newlib@sourceware.org
mailing list for the newlib project.
[patch,applied] RTEMS limits.h SSIZE_MAX
- From: Ralf Corsepius <ralf dot corsepius at rtems dot org>
- To: "newlib at sourceware dot org" <newlib at sourceware dot org>
- Date: Tue, 23 Aug 2011 07:56:04 +0200
- Subject: [patch,applied] RTEMS limits.h SSIZE_MAX
Hi,
I have applied the patch below.
It assures symmetry between SSIZE_MAX and SIZE_MAX for RTEMS targets.
I went ahead and applied it, because this patch is RTEMS-only, should
not affect any other target, and has been in use with RTEMS for quite a
while.
Ralf
2011-08-23 Ralf Corsépius <ralf.corsepius@rtems.org>
* libc/sys/rtems/include/limits.h: Compute SSIZE_MAX based on
__SIZE_MAX__, __SIZEOF_SIZE_T__ and __CHAR_BIT__.
--- libc/sys/rtems/include/limits.h 17 Nov 2008 22:05:12 -0000 1.3
+++ libc/sys/rtems/include/limits.h 23 Aug 2011 05:39:33 -0000
@@ -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