summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authormarcel <marcel@FreeBSD.org>2010-02-16 06:47:00 +0000
committermarcel <marcel@FreeBSD.org>2010-02-16 06:47:00 +0000
commitb3a749c0d1ec76a6d6db15266cc3819ac868be53 (patch)
treed9d433535ebd0d8b52fca2dadf555dfab934f901
parentb72bfb8c312d5db35f2c91540a4c9f0cd7555c24 (diff)
downloadFreeBSD-src-b3a749c0d1ec76a6d6db15266cc3819ac868be53.zip
FreeBSD-src-b3a749c0d1ec76a6d6db15266cc3819ac868be53.tar.gz
Unbreak ia64: tls_model("initial-exec") is invalid, because it assumes
the static TLS model, which is fundamentally different from the dynamic TLS model. The consequence was data corruption. Limit the attribute to i386 and amd64.
-rw-r--r--lib/libc/stdlib/malloc.c20
1 files changed, 9 insertions, 11 deletions
diff --git a/lib/libc/stdlib/malloc.c b/lib/libc/stdlib/malloc.c
index f91220e..5abcca9 100644
--- a/lib/libc/stdlib/malloc.c
+++ b/lib/libc/stdlib/malloc.c
@@ -215,10 +215,12 @@ __FBSDID("$FreeBSD$");
# define LG_QUANTUM 4
# define LG_SIZEOF_PTR 2
# define CPU_SPINWAIT __asm__ volatile("pause")
+# define TLS_MODEL __attribute__((tls_model("initial-exec")))
#endif
#ifdef __ia64__
# define LG_QUANTUM 4
# define LG_SIZEOF_PTR 3
+# define TLS_MODEL /* default */
#endif
#ifdef __alpha__
# define LG_QUANTUM 4
@@ -234,6 +236,7 @@ __FBSDID("$FreeBSD$");
# define LG_QUANTUM 4
# define LG_SIZEOF_PTR 3
# define CPU_SPINWAIT __asm__ volatile("pause")
+# define TLS_MODEL __attribute__((tls_model("initial-exec")))
#endif
#ifdef __arm__
# define LG_QUANTUM 3
@@ -1090,14 +1093,12 @@ static pthread_mutex_t arenas_lock; /* Protects arenas initialization. */
* Map of _pthread_self() --> arenas[???], used for selecting an arena to use
* for allocations.
*/
-static __thread arena_t *arenas_map
- __attribute__((tls_model("initial-exec")));
+static __thread arena_t *arenas_map TLS_MODEL;
#endif
#ifdef MALLOC_TCACHE
/* Map of thread-specific caches. */
-static __thread tcache_t *tcache_tls
- __attribute__((tls_model("initial-exec")));
+static __thread tcache_t *tcache_tls TLS_MODEL;
/*
* Number of cache slots for each bin in the thread cache, or 0 if tcache is
@@ -1115,15 +1116,12 @@ unsigned tcache_gc_incr;
* since the state of mmap_unaligned only affects performance, rather than
* correct function.
*/
-static
#ifndef NO_TLS
- __thread
-#endif
- bool mmap_unaligned
-#ifndef NO_TLS
- __attribute__((tls_model("initial-exec")))
+static __thread bool mmap_unaligned TLS_MODEL;
+#else
+static bool mmap_unaligned;
#endif
- ;
+
#ifdef MALLOC_STATS
static malloc_mutex_t chunks_mtx;
/* Chunk statistics. */
OpenPOWER on IntegriCloud