]> Savannah Git Hosting - gnulib.git/commitdiff
Don't use CHERI facilities with CC="clang -march=morello".
authorBruno Haible <bruno@clisp.org>
Mon, 13 Nov 2023 13:55:01 +0000 (14:55 +0100)
committerBruno Haible <bruno@clisp.org>
Mon, 13 Nov 2023 13:59:36 +0000 (14:59 +0100)
Suggested by Jessica Clarke <jrtc27@jrtc27.com> in
<https://lists.gnu.org/archive/html/bug-gnulib/2023-11/msg00116.html>.

* lib/alignalloc.h (alignalloc): Test __CHERI_PURE_CAPABILITY__, not
__CHERI__.
* lib/eealloc.h (eemalloc, eerealloc): Likewise.
* lib/ialloc.h (irealloc, ireallocarray): Likewise.
* lib/malloca.h (malloca): Likewise.
* lib/malloca.c (small_t, mmalloca, freea): Likewise.
* lib/rawmemchr.c (rawmemchr): Likewise.
* lib/safe-alloc.h (safe_alloc_realloc_n): Likewise.
* lib/sigsegv.c (SIGSEGV_FAULT_STACKPOINTER): Likewise.
* lib/ssfmalloc.h (struct dissected_page_header, init_small_block_page,
init_medium_block_page, free_block_from_pool, allocate_block): Likewise.
* tests/test-stdint.c: Likewise.

ChangeLog
lib/alignalloc.h
lib/eealloc.h
lib/ialloc.h
lib/malloca.c
lib/malloca.h
lib/rawmemchr.c
lib/safe-alloc.h
lib/sigsegv.c
lib/ssfmalloc.h
tests/test-stdint.c

index f9b39d517ec1db966e7d89acf37732ee8f040ffc..ab55ea915c1d69fd43e8758ad43201d8601c7550 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,21 @@
+2023-11-13  Bruno Haible  <bruno@clisp.org>
+
+       Don't use CHERI facilities with CC="clang -march=morello".
+       Suggested by Jessica Clarke <jrtc27@jrtc27.com> in
+       <https://lists.gnu.org/archive/html/bug-gnulib/2023-11/msg00116.html>.
+       * lib/alignalloc.h (alignalloc): Test __CHERI_PURE_CAPABILITY__, not
+       __CHERI__.
+       * lib/eealloc.h (eemalloc, eerealloc): Likewise.
+       * lib/ialloc.h (irealloc, ireallocarray): Likewise.
+       * lib/malloca.h (malloca): Likewise.
+       * lib/malloca.c (small_t, mmalloca, freea): Likewise.
+       * lib/rawmemchr.c (rawmemchr): Likewise.
+       * lib/safe-alloc.h (safe_alloc_realloc_n): Likewise.
+       * lib/sigsegv.c (SIGSEGV_FAULT_STACKPOINTER): Likewise.
+       * lib/ssfmalloc.h (struct dissected_page_header, init_small_block_page,
+       init_medium_block_page, free_block_from_pool, allocate_block): Likewise.
+       * tests/test-stdint.c: Likewise.
+
 2023-11-13  Bruno Haible  <bruno@clisp.org>
 
        jit/cache: Fix configure test.
@@ -10,7 +28,7 @@
        rawmemchr: speed up, particularly on CHERI
        * lib/rawmemchr.c (rawmemchr) [__CHERI__]: Use memchr instead of
        one-byte reads.  This sped up a simple benchmark (rawmemchr on
-       100,000 bytes) by 6x on a Research Morello SoC r0p0 on CheriBSD 14.
+       100,000 bytes) by 6x on a Research Morello SoC r0p0 on CheriBSD 14.
        [!__CHERI__]: Use sizeof, not alignof, as better alignment
        should help performance a bit on some platforms.
        * modules/rawmemchr (Depends-on): Remove alignasof.
index cb40b344e8f59c6583be0a6e31ed7a5e99ddd253..4f75084d137544b9907e869977fbc73e0fe5aaa2 100644 (file)
@@ -29,7 +29,7 @@
 #include <errno.h>
 #include <stdlib.h>
 #include "idx.h"
-#if defined __CHERI__
+#if defined __CHERI_PURE_CAPABILITY__
 # include <cheri.h>
 #endif
 
@@ -96,7 +96,7 @@ alignalloc (idx_t alignment, idx_t size)
   if (alignment < sizeof (void *))
     alignment = sizeof (void *);
   errno = posix_memalign (&ptr, alignment, size | !size);
-#  if defined __CHERI__
+#  if defined __CHERI_PURE_CAPABILITY__
   if (ptr != NULL)
     ptr = cheri_bounds_set (ptr, size);
 #  endif
index bae39151468006d204ca5360b56a7e2d37502883..1c54465680817e0fe25de093f8081945779e4fca 100644 (file)
@@ -36,7 +36,7 @@
 #endif
 
 #include <stdlib.h>
-#if defined __CHERI__
+#if defined __CHERI_PURE_CAPABILITY__
 # include <cheri.h>
 #endif
 
@@ -59,7 +59,7 @@ eemalloc (size_t n)
   if (n == 0)
     nx = 1;
   void *ptr = malloc (nx);
-# if defined __CHERI__
+# if defined __CHERI_PURE_CAPABILITY__
   if (ptr != NULL)
     ptr = cheri_bounds_set (ptr, n);
 # endif
@@ -80,7 +80,7 @@ eerealloc (void *p, size_t n)
   if (n == 0)
     nx = 1;
   void *ptr = realloc (p, nx);
-# if defined __CHERI__
+# if defined __CHERI_PURE_CAPABILITY__
   if (ptr != NULL)
     ptr = cheri_bounds_set (ptr, n);
 # endif
index 527b1f48beb15962a185e40d5332fb2cbf9d3252..5b336ab1c5d59228f27e9fabab437020a98a4733 100644 (file)
@@ -29,7 +29,7 @@
 #include <errno.h>
 #include <stdint.h>
 #include <stdlib.h>
-#if defined __CHERI__
+#if defined __CHERI_PURE_CAPABILITY__
 # include <cheri.h>
 #endif
 
@@ -73,7 +73,7 @@ irealloc (void *p, idx_t s)
       /* Work around GNU realloc glitch by treating a zero size as if it
          were 1, so that returning NULL is equivalent to failing.  */
       p = realloc (p, s | !s);
-#if defined __CHERI__
+#if defined __CHERI_PURE_CAPABILITY__
       if (p != NULL)
         p = cheri_bounds_set (p, s);
 #endif
@@ -121,7 +121,7 @@ ireallocarray (void *p, idx_t n, idx_t s)
       if (n == 0 || s == 0)
         nx = sx = 1;
       p = reallocarray (p, nx, sx);
-#if defined __CHERI__
+#if defined __CHERI_PURE_CAPABILITY__
       if (p != NULL && (n == 0 || s == 0))
         p = cheri_bounds_set (p, 0);
 #endif
index f98fdf152d56b7bc1985a4b7c202811a80b70b0c..5ddb867039c9cf564af0f23a9e036df06176678d 100644 (file)
@@ -22,7 +22,7 @@
 #include "malloca.h"
 
 #include <stdckdint.h>
-#if defined __CHERI__
+#if defined __CHERI_PURE_CAPABILITY__
 # include <cheri.h>
 #endif
 
@@ -39,7 +39,7 @@
        allocation.
      - NULL comes from a failed heap allocation.  */
 
-#if defined __CHERI__
+#if defined __CHERI_PURE_CAPABILITY__
 /* Type for holding the original malloc() result.  */
 typedef uintptr_t small_t;
 #else
@@ -78,7 +78,7 @@ mmalloca (size_t n)
              So, the memory range [p, p+n) lies in the allocated memory range
              [mem, mem + nplus).  */
           small_t *sp = p;
-# if defined __CHERI__
+# if defined __CHERI_PURE_CAPABILITY__
           sp[-1] = umem;
           p = (char *) cheri_bounds_set ((char *) p - sizeof (small_t),
                                          sizeof (small_t) + n)
@@ -117,7 +117,7 @@ freea (void *p)
     {
       char *cp = p;
       small_t *sp = p;
-# if defined __CHERI__
+# if defined __CHERI_PURE_CAPABILITY__
       void *mem = sp[-1];
 # else
       void *mem = cp - sp[-1];
index 120f406880e4f731daacca96b646d60d422b1113..2165e07096f1fe703945083b7de9bbaf21670405 100644 (file)
@@ -28,7 +28,7 @@
 #include <stddef.h>
 #include <stdlib.h>
 #include <stdint.h>
-#if defined __CHERI__
+#if defined __CHERI_PURE_CAPABILITY__
 # include <cheri.h>
 #endif
 
@@ -71,7 +71,7 @@ extern void freea (void *p);
    memory allocated on the stack, that must be freed using freea() before
    the function returns.  Upon failure, it returns NULL.  */
 #if HAVE_ALLOCA
-# if defined __CHERI__
+# if defined __CHERI_PURE_CAPABILITY__
 #  define malloca(N) \
     ((N) < 4032 - (2 * sa_alignment_max - 1)                                  \
      ? cheri_bounds_set ((void *) (((uintptr_t)                               \
index 9386ffc6289888d12127410f1f43ce7c456833c2..1c4a662ebff1509aefd8ddcf35a8a159c9ece5d7 100644 (file)
@@ -30,7 +30,7 @@
 void *
 rawmemchr (const void *s, int c_in)
 {
-# ifdef __CHERI__
+# ifdef __CHERI_PURE_CAPABILITY__
   /* Most architectures let you read an aligned word,
      even if the unsigned char array at S ends in the middle of the word.
      However CHERI does not, so call memchr
index 27049d3836d6aa22b04aff8621e4f2ec53b30f38..556735ab745a00ccce73ed93cf7314eb3843c986 100644 (file)
@@ -27,7 +27,7 @@
 #endif
 
 #include <stdlib.h>
-#if defined __CHERI__
+#if defined __CHERI_PURE_CAPABILITY__
 # include <cheri.h>
 #endif
 
@@ -45,7 +45,7 @@ safe_alloc_realloc_n (void *ptr, size_t count, size_t size)
   if (count == 0 || size == 0)
     countx = sizex = 1;
   ptr = reallocarray (ptr, countx, sizex);
-#if defined __CHERI__
+#if defined __CHERI_PURE_CAPABILITY__
   if (ptr != NULL && (count == 0 || size == 0))
     ptr = cheri_bounds_set (ptr, 0);
 #endif
index c683c03ac0a796548c09b4b1a08179483c58822d..9a1b8cc6c0c9dd18bb153d10f3e73fd8c584a0f0 100644 (file)
@@ -440,7 +440,7 @@ int libsigsegv_version = LIBSIGSEGV_VERSION;
 
 /* See sys/arm64/include/ucontext.h.  */
 
-#   if defined __CHERI__
+#   if defined __CHERI_PURE_CAPABILITY__
 #    define SIGSEGV_FAULT_STACKPOINTER  ((ucontext_t *) ucp)->uc_mcontext.mc_capregs.cap_sp
 #   else
 #    define SIGSEGV_FAULT_STACKPOINTER  ((ucontext_t *) ucp)->uc_mcontext.mc_gpregs.gp_sp
index 14644cb1d4c4e197e3b46db099bc751cbb6d9e28..645a2eda07728ea4e1b45b73b0af1c6609a0dfcc 100644 (file)
@@ -133,7 +133,7 @@ static void free_block (uintptr_t block);
 #include "thread-optim.h"
 #include "gl_oset.h"
 #include "gl_rbtree_oset.h"
-#ifdef __CHERI__
+#ifdef __CHERI_PURE_CAPABILITY__
 # include <cheri.h>
 #endif
 
@@ -181,7 +181,7 @@ struct page_tree_element
 struct dissected_page_header
 {
   struct any_page_header common;
-  #ifdef __CHERI__
+  #ifdef __CHERI_PURE_CAPABILITY__
   /* This page, with bounds [page, page + PAGESIZE).  */
   uintptr_t whole_page;
   #endif
@@ -393,7 +393,7 @@ init_small_block_page (uintptr_t page)
 {
   struct small_page_header *pageptr = (struct small_page_header *) page;
   pageptr->common.common.page_type = small_page_type;
-  #ifdef __CHERI__
+  #ifdef __CHERI_PURE_CAPABILITY__
   pageptr->common.whole_page = page;
   #endif
 
@@ -555,7 +555,7 @@ init_medium_block_page (uintptr_t page)
 {
   struct medium_page_header *pageptr = (struct medium_page_header *) page;
   pageptr->common.common.page_type = medium_page_type;
-  #ifdef __CHERI__
+  #ifdef __CHERI_PURE_CAPABILITY__
   pageptr->common.whole_page = page;
   #endif
   pageptr->num_gaps = 1;
@@ -857,7 +857,7 @@ free_block_from_pool (uintptr_t block, uintptr_t page, struct page_pool *pool)
         FREE_PAGES (pool->freeable_page, PAGESIZE);
 
       /* Don't free the page now, but later.  */
-      #ifdef __CHERI__
+      #ifdef __CHERI_PURE_CAPABILITY__
       pool->freeable_page = pageptr->whole_page;
       #else
       pool->freeable_page = page;
@@ -925,7 +925,7 @@ allocate_block (size_t size)
         (size <= SMALL_BLOCK_MAX_SIZE ? &small_block_pages : &medium_block_pages);
       block = allocate_block_from_pool (size, pool);
       if (mt) gl_lock_unlock (ssfmalloc_lock);
-#if defined __CHERI__
+#if defined __CHERI_PURE_CAPABILITY__
       if (block != 0)
         {
           size_t offset = block & (PAGESIZE - 1);
index fd12207b3488af451a0e91d3499097fb6acb0c80..988c452217e92325afbebd0747362ce3c2b21413 100644 (file)
@@ -219,7 +219,7 @@ err or;
 #ifdef INTPTR_MAX
 intptr_t g[3] = { 17, INTPTR_MIN, INTPTR_MAX };
 verify (sizeof (void *) <= sizeof (intptr_t));
-# ifndef __CHERI__
+# ifndef __CHERI_PURE_CAPABILITY__
 verify (TYPE_MINIMUM (intptr_t) == INTPTR_MIN);
 verify (TYPE_MAXIMUM (intptr_t) == INTPTR_MAX);
 # endif
@@ -230,7 +230,7 @@ verify_same_types (INTPTR_MAX, (intptr_t) 0 + 0);
 #ifdef UINTPTR_MAX
 uintptr_t h[2] = { 17, UINTPTR_MAX };
 verify (sizeof (void *) <= sizeof (uintptr_t));
-# ifndef __CHERI__
+# ifndef __CHERI_PURE_CAPABILITY__
 verify (TYPE_MAXIMUM (uintptr_t) == UINTPTR_MAX);
 # endif
 verify_same_types (UINTPTR_MAX, (uintptr_t) 0 + 0);
@@ -410,7 +410,7 @@ 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__
+#ifndef __CHERI_PURE_CAPABILITY__
 # ifdef INTPTR_WIDTH
 verify_width (INTPTR_WIDTH, INTPTR_MIN, INTPTR_MAX);
 # endif