This is the mail archive of the
libc-alpha@sourceware.org
mailing list for the glibc project.
Re: Fix tst-obprintf - and mcheck in general
- From: Andreas Jaeger <aj at suse dot com>
- To: libc-alpha at sourceware dot org
- Date: Wed, 02 May 2012 22:27:04 +0200
- Subject: Re: Fix tst-obprintf - and mcheck in general
- References: <201204261453.08679.aj@suse.com> <m21una642x.fsf@igel.home> <Pine.LNX.4.64.1204261500570.23071@jbgna.fhfr.qr> <201204261515.48450.aj@suse.com>
On 04/26/2012 03:15 PM, Andreas Jaeger wrote:
On Thursday, April 26, 2012 15:01:16 Richard Guenther wrote:
On Thu, 26 Apr 2012, Andreas Schwab wrote:
Andreas Jaeger<aj@suse.com> writes:
One option is to compile with -fno-builtin-malloc, the alternative
would be to use some otherways to initialize the malloc
implementation.
Does it work to use the equivalent of math_opt_barrier from
<math_private.h>?
Yes, that it should work, too.
Yes, the following works as well.
What's the best place to put this barrier in? Put it into include/malloc.h?
Which is the better way? A barrier like below or setting
-fno-builtin-malloc?
Andreas
Andreas
diff --git a/malloc/mcheck.c b/malloc/mcheck.c
index 9213740..7491c49 100644
--- a/malloc/mcheck.c
+++ b/malloc/mcheck.c
@@ -370,6 +370,12 @@ mabort (enum mcheck_status status)
#endif
}
+#ifndef malloc_opt_barrier
+#define malloc_opt_barrier(x) \
+({ __typeof (x) __x = x; __asm ("" : "+m" (__x)); __x; })
+
+#endif
+
int
mcheck (func)
void (*func) (enum mcheck_status);
@@ -381,6 +387,7 @@ mcheck (func)
{
/* We call malloc() once here to ensure it is initialized. */
void *p = malloc (0);
+ p = malloc_opt_barrier (p);
free (p);
old_free_hook = __free_hook;
--
Andreas Jaeger aj@{suse.com,opensuse.org} Twitter/Identica: jaegerandi
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany
GF: Jeff Hawn,Jennifer Guild,Felix Imendörffer,HRB16746 (AG Nürnberg)
GPG fingerprint = 93A3 365E CE47 B889 DF7F FED1 389A 563C C272 A126