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.
/* 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 */
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);