aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Dunbar <daniel@zuster.org>2013-04-12 23:24:56 +0000
committerDaniel Dunbar <daniel@zuster.org>2013-04-12 23:24:56 +0000
commit2943d3dded877fbe0bb965756f047d379032d4ba (patch)
treee06b91255e0c019db32f97223b89993619083544
parente0c804b214cbca72e00ecefecb19b43c9b0cdda7 (diff)
Headers: Add support for ISO9899:2011 rsize_t.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@179427 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--lib/Headers/stddef.h11
-rw-r--r--lib/Headers/stdint.h6
-rw-r--r--test/Headers/c11.c5
3 files changed, 22 insertions, 0 deletions
diff --git a/lib/Headers/stddef.h b/lib/Headers/stddef.h
index 52962248f6..c4861551da 100644
--- a/lib/Headers/stddef.h
+++ b/lib/Headers/stddef.h
@@ -42,6 +42,17 @@ typedef __PTRDIFF_TYPE__ ptrdiff_t;
typedef __SIZE_TYPE__ size_t;
#endif
+/* ISO9899:2011 7.20 (C11 Annex K): Define risze_t if __STDC_WANT_LIB_EXT1__ is
+ * enabled. */
+#if (defined(__STDC_WANT_LIB_EXT1__) && __STDC_WANT_LIB_EXT1__ >= 1 && \
+ !defined(_RSIZE_T)) || __has_feature(modules)
+/* Always define rsize_t when modules are available. */
+#if !__has_feature(modules)
+#define _RSIZE_T
+#endif
+typedef __SIZE_TYPE__ rsize_t;
+#endif
+
#ifndef __cplusplus
/* Always define wchar_t when modules are available. */
#if !defined(_WCHAR_T) || __has_feature(modules)
diff --git a/lib/Headers/stdint.h b/lib/Headers/stdint.h
index 051047f7d2..11529c0c67 100644
--- a/lib/Headers/stdint.h
+++ b/lib/Headers/stdint.h
@@ -667,6 +667,12 @@ typedef __UINTMAX_TYPE__ uintmax_t;
#define PTRDIFF_MAX __INTN_MAX(__PTRDIFF_WIDTH__)
#define SIZE_MAX __UINTN_MAX(__SIZE_WIDTH__)
+/* ISO9899:2011 7.20 (C11 Annex K): Define RSIZE_MAX if __STDC_WANT_LIB_EXT1__
+ * is enabled. */
+#if defined(__STDC_WANT_LIB_EXT1__) && __STDC_WANT_LIB_EXT1__ >= 1
+#define RSIZE_MAX (SIZE_MAX >> 1)
+#endif
+
/* C99 7.18.2.5 Limits of greatest-width integer types. */
#define INTMAX_MIN __INTN_MIN(__INTMAX_WIDTH__)
#define INTMAX_MAX __INTN_MAX(__INTMAX_WIDTH__)
diff --git a/test/Headers/c11.c b/test/Headers/c11.c
index f65164d15c..7d859fc5f0 100644
--- a/test/Headers/c11.c
+++ b/test/Headers/c11.c
@@ -17,3 +17,8 @@ _Static_assert(__alignas_is_defined, "");
_Static_assert(__alignof_is_defined, "");
alignas(alignof(int)) char c[4];
_Static_assert(__alignof(c) == 4, "");
+
+#define __STDC_WANT_LIB_EXT1__ 1
+#include <stddef.h>
+#include <stdint.h>
+rsize_t x = RSIZE_MAX;