Skip to content

Commit

Permalink
Enforce TLS_MODEL attribute.
Browse files Browse the repository at this point in the history
Caught by @zoulasc in jemalloc#1460.  The attribute needs to be added in the headers as
well.
  • Loading branch information
interwq committed Apr 16, 2019
1 parent 21cfe59 commit 1aabab5
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 6 deletions.
6 changes: 4 additions & 2 deletions include/jemalloc/internal/tsd_malloc_thread_cleanup.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,10 @@
#endif
#define JEMALLOC_INTERNAL_TSD_MALLOC_THREAD_CLEANUP_H

extern __thread tsd_t tsd_tls;
extern __thread bool tsd_initialized;
#define JEMALLOC_TSD_TYPE_ATTR(type) __thread type JEMALLOC_TLS_MODEL

extern JEMALLOC_TSD_TYPE_ATTR(tsd_t) tsd_tls;
extern JEMALLOC_TSD_TYPE_ATTR(bool) tsd_initialized;
extern bool tsd_booted;

/* Initialization/cleanup. */
Expand Down
4 changes: 3 additions & 1 deletion include/jemalloc/internal/tsd_tls.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@
#endif
#define JEMALLOC_INTERNAL_TSD_TLS_H

extern __thread tsd_t tsd_tls;
#define JEMALLOC_TSD_TYPE_ATTR(type) __thread type JEMALLOC_TLS_MODEL

extern JEMALLOC_TSD_TYPE_ATTR(tsd_t) tsd_tls;
extern pthread_key_t tsd_tsd;
extern bool tsd_booted;

Expand Down
6 changes: 3 additions & 3 deletions src/tsd.c
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,11 @@ JEMALLOC_DIAGNOSTIC_PUSH
JEMALLOC_DIAGNOSTIC_IGNORE_MISSING_STRUCT_FIELD_INITIALIZERS

#ifdef JEMALLOC_MALLOC_THREAD_CLEANUP
__thread tsd_t JEMALLOC_TLS_MODEL tsd_tls = TSD_INITIALIZER;
__thread bool JEMALLOC_TLS_MODEL tsd_initialized = false;
JEMALLOC_TSD_TYPE_ATTR(tsd_t) tsd_tls = TSD_INITIALIZER;
JEMALLOC_TSD_TYPE_ATTR(bool) JEMALLOC_TLS_MODEL tsd_initialized = false;
bool tsd_booted = false;
#elif (defined(JEMALLOC_TLS))
__thread tsd_t JEMALLOC_TLS_MODEL tsd_tls = TSD_INITIALIZER;
JEMALLOC_TSD_TYPE_ATTR(tsd_t) tsd_tls = TSD_INITIALIZER;
pthread_key_t tsd_tsd;
bool tsd_booted = false;
#elif (defined(_WIN32))
Expand Down

0 comments on commit 1aabab5

Please sign in to comment.