diff options
| author | Jason Evans <je@fb.com> | 2011-03-02 20:19:58 (GMT) |
|---|---|---|
| committer | Jason Evans <je@fb.com> | 2011-03-02 20:19:58 (GMT) |
| commit | e27d134efc8609e3f95e4ec13f605ddcb5eb6ca6 (patch) | |
| tree | 42c7835f25258ae9bf251bb1f5b9c29d46ca6a63 /jemalloc/include | |
| parent | a73ebd946ab00cacf9bbad6a5edf6aea50c18c0f (diff) | |
| parent | 6e56e5ec6a246c313e44cee0df9fd60483436cfd (diff) | |
| download | jemalloc-2.1.2.zip jemalloc-2.1.2.tar.gz jemalloc-2.1.2.tar.bz2 | |
Merge branch 'dev'2.1.2
Diffstat (limited to 'jemalloc/include')
| -rw-r--r-- | jemalloc/include/jemalloc/internal/hash.h | 2 | ||||
| -rw-r--r-- | jemalloc/include/jemalloc/internal/jemalloc_internal.h.in | 77 |
2 files changed, 40 insertions, 39 deletions
diff --git a/jemalloc/include/jemalloc/internal/hash.h b/jemalloc/include/jemalloc/internal/hash.h index d12cdb8..9073d83 100644 --- a/jemalloc/include/jemalloc/internal/hash.h +++ b/jemalloc/include/jemalloc/internal/hash.h @@ -62,7 +62,7 @@ hash(const void *key, size_t len, uint64_t seed) h *= m; h ^= h >> r; - return h; + return (h); } #endif diff --git a/jemalloc/include/jemalloc/internal/jemalloc_internal.h.in b/jemalloc/include/jemalloc/internal/jemalloc_internal.h.in index 0680b43..a27416c 100644 --- a/jemalloc/include/jemalloc/internal/jemalloc_internal.h.in +++ b/jemalloc/include/jemalloc/internal/jemalloc_internal.h.in @@ -148,11 +148,6 @@ extern void (*JEMALLOC_P(malloc_message))(void *wcbopaque, const char *s); #define SIZEOF_PTR (1U << LG_SIZEOF_PTR) -/* We can't use TLS in non-PIC programs, since TLS relies on loader magic. */ -#if (!defined(PIC) && !defined(NO_TLS)) -# define NO_TLS -#endif - /* * Maximum size of L1 cache line. This is used to avoid cache line aliasing. * In addition, this controls the spacing of cacheline-spaced size classes. @@ -240,6 +235,13 @@ extern void (*JEMALLOC_P(malloc_message))(void *wcbopaque, const char *s); #endif #include "jemalloc/internal/prof.h" +#ifdef JEMALLOC_STATS +typedef struct { + uint64_t allocated; + uint64_t deallocated; +} thread_allocated_t; +#endif + #undef JEMALLOC_H_STRUCTS /******************************************************************************/ #define JEMALLOC_H_EXTERNS @@ -295,45 +297,28 @@ extern arena_t **arenas; extern unsigned narenas; #ifdef JEMALLOC_STATS -typedef struct { - uint64_t allocated; - uint64_t deallocated; -} thread_allocated_t; # ifndef NO_TLS extern __thread thread_allocated_t thread_allocated_tls; -# define ALLOCATED_GET() thread_allocated_tls.allocated -# define DEALLOCATED_GET() thread_allocated_tls.deallocated +# define ALLOCATED_GET() (thread_allocated_tls.allocated) +# define ALLOCATEDP_GET() (&thread_allocated_tls.allocated) +# define DEALLOCATED_GET() (thread_allocated_tls.deallocated) +# define DEALLOCATEDP_GET() (&thread_allocated_tls.deallocated) # define ALLOCATED_ADD(a, d) do { \ thread_allocated_tls.allocated += a; \ thread_allocated_tls.deallocated += d; \ } while (0) # else extern pthread_key_t thread_allocated_tsd; -# define ALLOCATED_GET() \ - (uint64_t)((pthread_getspecific(thread_allocated_tsd) != NULL) \ - ? ((thread_allocated_t *) \ - pthread_getspecific(thread_allocated_tsd))->allocated : 0) -# define DEALLOCATED_GET() \ - (uint64_t)((pthread_getspecific(thread_allocated_tsd) != NULL) \ - ? ((thread_allocated_t \ - *)pthread_getspecific(thread_allocated_tsd))->deallocated : \ - 0) +thread_allocated_t *thread_allocated_get_hard(void); + +# define ALLOCATED_GET() (thread_allocated_get()->allocated) +# define ALLOCATEDP_GET() (&thread_allocated_get()->allocated) +# define DEALLOCATED_GET() (thread_allocated_get()->deallocated) +# define DEALLOCATEDP_GET() (&thread_allocated_get()->deallocated) # define ALLOCATED_ADD(a, d) do { \ - thread_allocated_t *thread_allocated = (thread_allocated_t *) \ - pthread_getspecific(thread_allocated_tsd); \ - if (thread_allocated != NULL) { \ - thread_allocated->allocated += (a); \ - thread_allocated->deallocated += (d); \ - } else { \ - thread_allocated = (thread_allocated_t *) \ - imalloc(sizeof(thread_allocated_t)); \ - if (thread_allocated != NULL) { \ - pthread_setspecific(thread_allocated_tsd, \ - thread_allocated); \ - thread_allocated->allocated = (a); \ - thread_allocated->deallocated = (d); \ - } \ - } \ + thread_allocated_t *thread_allocated = thread_allocated_get(); \ + thread_allocated->allocated += (a); \ + thread_allocated->deallocated += (d); \ } while (0) # endif #endif @@ -384,6 +369,9 @@ size_t s2u(size_t size); size_t sa2u(size_t size, size_t alignment, size_t *run_size_p); void malloc_write(const char *s); arena_t *choose_arena(void); +# ifdef NO_TLS +thread_allocated_t *thread_allocated_get(void); +# endif #endif #if (defined(JEMALLOC_ENABLE_INLINE) || defined(JEMALLOC_C_)) @@ -414,10 +402,10 @@ s2u(size_t size) { if (size <= small_maxclass) - return arenas[0]->bins[small_size2bin[size]].reg_size; + return (arenas[0]->bins[small_size2bin[size]].reg_size); if (size <= arena_maxclass) - return PAGE_CEILING(size); - return CHUNK_CEILING(size); + return (PAGE_CEILING(size)); + return (CHUNK_CEILING(size)); } /* @@ -544,6 +532,19 @@ choose_arena(void) return (ret); } + +#ifdef NO_TLS +JEMALLOC_INLINE thread_allocated_t * +thread_allocated_get(void) +{ + thread_allocated_t *thread_allocated = (thread_allocated_t *) + pthread_getspecific(thread_allocated_tsd); + + if (thread_allocated == NULL) + return (thread_allocated_get_hard()); + return (thread_allocated); +} +#endif #endif #include "jemalloc/internal/rtree.h" |
