This is the mail archive of the
libc-alpha@sourceware.org
mailing list for the glibc project.
Re: [PATCH v2][malloc] Use relaxed atomics for malloc have_fastchunks
- From: Wilco Dijkstra <Wilco dot Dijkstra at arm dot com>
- To: Joseph Myers <joseph at codesourcery dot com>
- Cc: "libc-alpha at sourceware dot org" <libc-alpha at sourceware dot org>, "dj at redhat dot com" <dj at redhat dot com>, nd <nd at arm dot com>, "cmetcalf at mellanox dot com" <cmetcalf at mellanox dot com>
- Date: Wed, 18 Oct 2017 11:37:55 +0000
- Subject: Re: [PATCH v2][malloc] Use relaxed atomics for malloc have_fastchunks
- Authentication-results: sourceware.org; auth=none
- Authentication-results: spf=none (sender IP is ) smtp.mailfrom=Wilco dot Dijkstra at arm dot com;
- Nodisclaimer: True
- References: <DB6PR0801MB2053F5C639E8EBEE0E90CDB483660@DB6PR0801MB2053.eurprd08.prod.outlook.com>,<alpine.DEB.2.20.1710172304020.16511@digraph.polyomino.org.uk>
- Spamdiagnosticmetadata: NSPM
- Spamdiagnosticoutput: 1:99
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];