diff --git a/src/runtime/c/pgf/db.cxx b/src/runtime/c/pgf/db.cxx index 92f48c001..ada843340 100644 --- a/src/runtime/c/pgf/db.cxx +++ b/src/runtime/c/pgf/db.cxx @@ -45,10 +45,15 @@ int last_error_to_errno() } #endif +#if defined(_MSC_VER) +PGF_INTERNAL __declspec( thread ) unsigned char* current_base = NULL; +PGF_INTERNAL __declspec( thread ) PgfDB* current_db = NULL; +PGF_INTERNAL __declspec( thread ) DB_scope *last_db_scope = NULL; +#else 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; - +#endif #define ptr(T,o) ((T*) (base + (o))) diff --git a/src/runtime/c/pgf/db.h b/src/runtime/c/pgf/db.h index c6b1162b0..c593ea9ba 100644 --- a/src/runtime/c/pgf/db.h +++ b/src/runtime/c/pgf/db.h @@ -5,8 +5,13 @@ class PgfDB; +#if defined(_MSC_VER) +extern PGF_INTERNAL_DECL __declspec( thread ) unsigned char* current_base; +extern PGF_INTERNAL_DECL __declspec( thread ) PgfDB* current_db; +#else 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"))); +#endif struct block_descr; struct malloc_state;