1
0
forked from GitHub/gf-core

thread local for MSVC

This commit is contained in:
Krasimir Angelov
2023-01-25 23:16:02 +01:00
parent e4cc9bc0a7
commit 696a9ffb16
2 changed files with 11 additions and 1 deletions

View File

@@ -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)))

View File

@@ -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;