diff options
Diffstat (limited to 'malloc')
-rw-r--r-- | malloc/arena.c | 3 | ||||
-rw-r--r-- | malloc/thread-m.h | 13 |
2 files changed, 15 insertions, 1 deletions
diff --git a/malloc/arena.c b/malloc/arena.c index e47d3d0e1f..fb7b92f318 100644 --- a/malloc/arena.c +++ b/malloc/arena.c @@ -1,5 +1,5 @@ /* Malloc implementation for multiple threads without lock contention. - Copyright (C) 2001, 2002 Free Software Foundation, Inc. + Copyright (C) 2001, 2002, 2003 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Wolfram Gloger <wg@malloc.de>, 2001. @@ -758,6 +758,7 @@ arena_get2(a_tsd, size) mstate a_tsd; size_t size; /* Add the new arena to the global list. */ (void)mutex_lock(&list_lock); a->next = main_arena.next; + atomic_write_barrier (); main_arena.next = a; (void)mutex_unlock(&list_lock); diff --git a/malloc/thread-m.h b/malloc/thread-m.h index da8bbf36f8..1dcaed0514 100644 --- a/malloc/thread-m.h +++ b/malloc/thread-m.h @@ -31,6 +31,7 @@ #if defined(_LIBC) /* The GNU C library, a special case of Posix threads */ +#include <atomic.h> #include <bits/libc-lock.h> #ifdef PTHREAD_MUTEX_INITIALIZER @@ -306,4 +307,16 @@ typedef void *tsd_key_t; #endif /* defined(NO_THREADS) */ +#ifndef atomic_full_barrier +# define atomic_full_barrier() __asm ("" ::: "memory") +#endif + +#ifndef atomic_read_barrier +# define atomic_read_barrier() atomic_full_barrier () +#endif + +#ifndef atomic_write_barrier +# define atomic_write_barrier() atomic_full_barrier () +#endif + #endif /* !defined(_THREAD_M_H) */ |