[PATCH v2][malloc] Use relaxed atomics for malloc have_fastchunks

Wilco Dijkstra Wilco.Dijkstra@arm.com
Wed Oct 18 11:38:00 GMT 2017


Joseph Myers wrote:
>
> I think this breaks the build for tilepro.  You're using atomic operations
> on a bool field, and tilepro only supports atomic operations on 4-byte 
> objects and gives errors for other sizes.  Generic code should only use 
> atomics on int-size / pointer-size objects unless it knows the particular 
> architecture supports atomics of other sizes (e.g. through 
> __HAVE_64B_ATOMICS).

I thought there were only issues with types >= 64 bits...
Anyway I've updated the type to int - we can always decide not to use
atomics for this particular variable. I've committed this which fixes
tilepro:

2017-10-18  Wilco Dijkstra  <wdijkstr@arm.com>

        * malloc/malloc.c (malloc_state): Use int for have_fastchunks since
        not all targets support atomics on bool.

diff --git a/malloc/malloc.c b/malloc/malloc.c
index 51db44f..6b78968 100644
--- a/malloc/malloc.c
+++ b/malloc/malloc.c
@@ -1673,7 +1673,8 @@ struct malloc_state
   int flags;
 
   /* Set if the fastbin chunks contain recently inserted free blocks.  */
-  bool have_fastchunks;
+  /* Note this is a bool but not all targets support atomics on booleans.  */
+  int have_fastchunks;
 
   /* Fastbins */
   mfastbinptr fastbinsY[NFASTBINS];


More information about the Libc-alpha mailing list