diff --git a/src/runtime/c/pgf/db.cxx b/src/runtime/c/pgf/db.cxx index 8f0bf4daa..068cccd4a 100644 --- a/src/runtime/c/pgf/db.cxx +++ b/src/runtime/c/pgf/db.cxx @@ -5,9 +5,9 @@ #include "data.h" -PGF_INTERNAL unsigned char* current_base = NULL; -PGF_INTERNAL PgfDB* current_db = NULL; -PGF_INTERNAL DB_scope *last_db_scope = NULL; +PGF_INTERNAL __thread unsigned char* current_base __attribute__((tls_model("initial-exec"))) = NULL; +PGF_INTERNAL __thread PgfDB* current_db __attribute__((tls_model("initial-exec"))) = NULL; +PGF_INTERNAL __thread DB_scope *last_db_scope __attribute__((tls_model("initial-exec"))) = NULL; #ifndef DEFAULT_TOP_PAD #define DEFAULT_TOP_PAD (0) diff --git a/src/runtime/c/pgf/db.h b/src/runtime/c/pgf/db.h index ddbe5a846..0331ad4b3 100644 --- a/src/runtime/c/pgf/db.h +++ b/src/runtime/c/pgf/db.h @@ -5,8 +5,8 @@ class PgfDB; -extern PGF_INTERNAL_DECL unsigned char* current_base; -extern PGF_INTERNAL_DECL PgfDB* current_db; +extern PGF_INTERNAL_DECL __thread unsigned char* current_base __attribute__((tls_model("initial-exec"))); +extern PGF_INTERNAL_DECL __thread PgfDB* current_db __attribute__((tls_model("initial-exec"))); struct malloc_state; @@ -108,6 +108,6 @@ private: DB_scope* next_scope; }; -extern PGF_INTERNAL_DECL DB_scope *last_db_scope; +extern PGF_INTERNAL_DECL thread_local DB_scope *last_db_scope __attribute__((tls_model("initial-exec"))); #endif