From: Paul Eggert Date: Tue, 7 Nov 2023 07:46:53 +0000 (-0800) Subject: stdint-tests: port to CHERI etc X-Git-Tag: v1.0~627 X-Git-Url: https://gitweb.git.savannah.gnu.org/gitweb/?a=commitdiff_plain;h=66fc257c46bdfcb3334f2e049cd4629e6e80aafc;p=gnulib.git 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. --- diff --git a/ChangeLog b/ChangeLog index 7f02c24f6c..84d40e8393 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,11 @@ 2023-11-06 Paul Eggert + 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);