]>
git.saurik.com Git - redis.git/blob - deps/jemalloc.orig/include/jemalloc/internal/mb.h
1 /******************************************************************************/
2 #ifdef JEMALLOC_H_TYPES
4 #endif /* JEMALLOC_H_TYPES */
5 /******************************************************************************/
6 #ifdef JEMALLOC_H_STRUCTS
8 #endif /* JEMALLOC_H_STRUCTS */
9 /******************************************************************************/
10 #ifdef JEMALLOC_H_EXTERNS
12 #endif /* JEMALLOC_H_EXTERNS */
13 /******************************************************************************/
14 #ifdef JEMALLOC_H_INLINES
16 #ifndef JEMALLOC_ENABLE_INLINE
20 #if (defined(JEMALLOC_ENABLE_INLINE) || defined(JEMALLOC_MB_C_))
23 * According to the Intel Architecture Software Developer's Manual, current
24 * processors execute instructions in order from the perspective of other
25 * processors in a multiprocessor system, but 1) Intel reserves the right to
26 * change that, and 2) the compiler's optimizer could re-order instructions if
27 * there weren't some form of barrier. Therefore, even if running on an
28 * architecture that does not need memory barriers (everything through at least
29 * i686), an "optimizer barrier" is necessary.
36 /* This is a true memory barrier. */
37 asm volatile ("pusha;"
43 : "memory" /* Clobbers. */
47 * This is hopefully enough to keep the compiler from reordering
48 * instructions around this one.
53 : "memory" /* Clobbers. */
57 #elif (defined(__amd64_) || defined(__x86_64__))
62 asm volatile ("sfence"
65 : "memory" /* Clobbers. */
68 #elif defined(__powerpc__)
76 : "memory" /* Clobbers. */
79 #elif defined(__sparc64__)
84 asm volatile ("membar #StoreStore"
87 : "memory" /* Clobbers. */
92 * This is much slower than a simple memory barrier, but the semantics of mutex
93 * unlock make this work.
100 malloc_mutex_init(&mtx
);
101 malloc_mutex_lock(&mtx
);
102 malloc_mutex_unlock(&mtx
);
107 #endif /* JEMALLOC_H_INLINES */
108 /******************************************************************************/