[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH 2/3] stdint-tests: port to CHERI etc
From: |
Paul Eggert |
Subject: |
[PATCH 2/3] stdint-tests: port to CHERI etc |
Date: |
Tue, 7 Nov 2023 00:00:00 -0800 |
* tests/test-stdint.c: Test intptr_t only if INTPTR_MAX is
defined, since the type is optional. Similarly for uintptr_t.
If CHERI, don’t assume TYPE_MINIMUM and TYPE_MAXIMUM works on
intptr_t, and similarly for TYPE_MAXIMUM and uintptr_t.
---
ChangeLog | 6 ++++++
tests/test-stdint.c | 18 +++++++++++++-----
2 files changed, 19 insertions(+), 5 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index 7f02c24f6c..84d40e8393 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,11 @@
2023-11-06 Paul Eggert <eggert@cs.ucla.edu>
+ stdint-tests: port to CHERI etc
+ * tests/test-stdint.c: Test intptr_t only if INTPTR_MAX is
+ defined, since the type is optional. Similarly for uintptr_t.
+ If CHERI, don’t assume TYPE_MINIMUM and TYPE_MAXIMUM works on
+ intptr_t, and similarly for TYPE_MAXIMUM and uintptr_t.
+
posix_memalign-tests: port to CHERI-64
* tests/test-posix_memalign.c (main):
Don’t assume sizeof (void *) <= 8.
diff --git a/tests/test-stdint.c b/tests/test-stdint.c
index a34c33f104..fd12207b34 100644
--- a/tests/test-stdint.c
+++ b/tests/test-stdint.c
@@ -216,22 +216,24 @@ err or;
/* 7.18.1.4. Integer types capable of holding object pointers */
/* 7.18.2.4. Limits of integer types capable of holding object pointers */
+#ifdef INTPTR_MAX
intptr_t g[3] = { 17, INTPTR_MIN, INTPTR_MAX };
verify (sizeof (void *) <= sizeof (intptr_t));
+# ifndef __CHERI__
verify (TYPE_MINIMUM (intptr_t) == INTPTR_MIN);
verify (TYPE_MAXIMUM (intptr_t) == INTPTR_MAX);
+# endif
verify_same_types (INTPTR_MIN, (intptr_t) 0 + 0);
verify_same_types (INTPTR_MAX, (intptr_t) 0 + 0);
+#endif
+#ifdef UINTPTR_MAX
uintptr_t h[2] = { 17, UINTPTR_MAX };
verify (sizeof (void *) <= sizeof (uintptr_t));
+# ifndef __CHERI__
verify (TYPE_MAXIMUM (uintptr_t) == UINTPTR_MAX);
+# endif
verify_same_types (UINTPTR_MAX, (uintptr_t) 0 + 0);
-
-#if INTPTR_MIN && INTPTR_MAX && UINTPTR_MAX
-/* ok */
-#else
-err or;
#endif
/* 7.18.1.5. Greatest-width integer types */
@@ -408,8 +410,14 @@ verify_width (INT_FAST32_WIDTH, INT_FAST32_MIN,
INT_FAST32_MAX);
verify_width (UINT_FAST32_WIDTH, 0, UINT_FAST32_MAX);
verify_width (INT_FAST64_WIDTH, INT_FAST64_MIN, INT_FAST64_MAX);
verify_width (UINT_FAST64_WIDTH, 0, UINT_FAST64_MAX);
+#ifndef __CHERI__
+# ifdef INTPTR_WIDTH
verify_width (INTPTR_WIDTH, INTPTR_MIN, INTPTR_MAX);
+# endif
+# ifdef UINTPTR_WIDTH
verify_width (UINTPTR_WIDTH, 0, UINTPTR_MAX);
+# endif
+#endif
verify_width (INTMAX_WIDTH, INTMAX_MIN, INTMAX_MAX);
verify_width (UINTMAX_WIDTH, 0, UINTMAX_MAX);
verify_width (PTRDIFF_WIDTH, PTRDIFF_MIN, PTRDIFF_MAX);
--
2.39.2