diff mbox series

[07/11] add predefined macros for [u]intptr & ptrdiff

Message ID 20181209234320.65274-8-luc.vanoostenryck@gmail.com (mailing list archive)
State Superseded, archived
Headers show
Series predefined macros for intmax_t/intptr_t/... | expand

Commit Message

Luc Van Oostenryck Dec. 9, 2018, 11:43 p.m. UTC
Luckily, it seems all archs use for them the same types as
size_t & ssize_t.
---
 lib.c                            | 4 +++-
 validation/preprocessor/predef.c | 5 +++++
 2 files changed, 8 insertions(+), 1 deletion(-)
diff mbox series

Patch

diff --git a/lib.c b/lib.c
index 6523cf419..6a6133499 100644
--- a/lib.c
+++ b/lib.c
@@ -1257,7 +1257,9 @@  static void predefined_macros(void)
 	predefined_sizeof("INT128", "", 128);
 
 	predefined_ctype("SIZE", size_t_ctype, PTYPE_ALL|PTYPE_T|PTYPE_TYPE);
-	predefined_ctype("PTRDIFF", &ptr_ctype, PTYPE_ALL|PTYPE_T);
+	predefined_ctype("UINTPTR",  size_t_ctype, PTYPE_TYPE|PTYPE_MAX);
+	predefined_ctype("INTPTR",  ssize_t_ctype, PTYPE_TYPE|PTYPE_MAX|PTYPE_WIDTH);
+	predefined_ctype("PTRDIFF", ssize_t_ctype, PTYPE_ALL|PTYPE_T);
 	predefined_sizeof("POINTER", "", bits_in_pointer);
 
 	predefined_sizeof("FLOAT", "", bits_in_float);
diff --git a/validation/preprocessor/predef.c b/validation/preprocessor/predef.c
index 0453ce43f..e14c04d7b 100644
--- a/validation/preprocessor/predef.c
+++ b/validation/preprocessor/predef.c
@@ -13,6 +13,10 @@  int test(void)
 	TEST_MAX(INT, int);
 	TEST_MAX(LONG, long);
 	TEST_MAX(LONG_LONG, long long);
+	TEST_MAX(SIZE, __SIZE_TYPE__);
+	TEST_MAX(PTRDIFF, __PTRDIFF_TYPE__);
+	TEST_MAX(INTPTR, __INTPTR_TYPE__);
+	TEST_MAX(UINTPTR, __UINTPTR_TYPE__);
 
 #define TEST_SIZEOF(X, T) if (__SIZEOF_ ## X ## __ != sizeof(T)) return 1
 	TEST_SIZEOF(SHORT, short);
@@ -21,6 +25,7 @@  int test(void)
 	TEST_SIZEOF(LONG_LONG, long long);
 	TEST_SIZEOF(INT128, __int128);
 	TEST_SIZEOF(SIZE_T, __SIZE_TYPE__);
+	TEST_SIZEOF(PTRDIFF_T, __PTRDIFF_TYPE__);
 	TEST_SIZEOF(POINTER, void*);
 	TEST_SIZEOF(FLOAT, float);
 	TEST_SIZEOF(DOUBLE, double);