Skip to content

Commit 4db75dc

Browse files
committed
basic windows fix
1 parent f2e636d commit 4db75dc

File tree

13 files changed

+46
-23
lines changed

13 files changed

+46
-23
lines changed

TSRM/TSRM.c

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -63,11 +63,7 @@ static int tsrm_error_level;
6363
static FILE *tsrm_error_file;
6464

6565
#ifdef USE___THREAD
66-
#ifdef TSRM_WIN32
6766
TSRM_TLS void *tsrm_ls_cache = 0;
68-
#else
69-
TSRM_API TSRM_TLS void *tsrm_ls_cache = 0;
70-
#endif
7167
#endif
7268

7369
#ifdef PASS_TSRMLS
@@ -833,4 +829,14 @@ void tsrm_error_set(int level, char *debug_filename)
833829
#endif
834830
}
835831

832+
TSRM_API void *get_tsrm_ls_cache(void)
833+
{
834+
return tsrm_ls_cache;
835+
}
836+
837+
TSRM_API void set_tsrm_ls_cache(void **cache)
838+
{
839+
tsrm_ls_cache = *cache;
840+
}
841+
836842
#endif /* ZTS */

TSRM/TSRM.h

Lines changed: 22 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,13 @@
2626
# else
2727
# define TSRM_API __declspec(dllimport)
2828
# endif
29+
# define TSRM_EXP_API __declspec(dllexport)
2930
#elif defined(__GNUC__) && __GNUC__ >= 4
3031
# define TSRM_API __attribute__ ((visibility("default")))
32+
# define TSRM_EXP_API TSRM_API
3133
#else
3234
# define TSRM_API
35+
# define TSRM_EXP_API
3336
#endif
3437

3538
#ifdef _WIN64
@@ -109,16 +112,14 @@ extern "C" {
109112
# define TSRM_TLS __thread
110113
# endif
111114

112-
#ifdef TSRM_WIN32
113-
extern TSRM_TLS void *tsrm_ls_cache;
114-
#else
115-
TSRM_API extern TSRM_TLS void *tsrm_ls_cache;
116-
#endif
117-
118115
#define TSRMG(id, type, element) \
119-
((type)((tsrm_uintptr_t)tsrm_ls_cache + id##_offset))->element
116+
((type)((tsrm_uintptr_t) get_tsrm_ls_cache() + id##_offset))->element
117+
118+
#define TSRMLS_INIT() do { \
119+
void *cache = (void *) ts_resource_ex(0, NULL); \
120+
set_tsrm_ls_cache(&cache); \
121+
} while (0)
120122

121-
#define TSRMLS_INIT() tsrm_ls_cache = (void *) ts_resource_ex(0, NULL);
122123
#define TSRMLS_FETCH()
123124
#define TSRMLS_FETCH_FROM_CTX(ctx)
124125
#define TSRMLS_SET_CTX(ctx)
@@ -145,13 +146,21 @@ TSRM_API extern TSRM_TLS void *tsrm_ls_cache;
145146

146147
#endif /* USE___THREAD */
147148

149+
#define TSRMG_DHE(type, id) \
150+
TSRM_EXP_API extern ts_rsrc_id id; \
151+
TSRM_EXP_API extern ts_rsrc_offset id##_offset
152+
153+
#define TSRMG_DE(type, id) \
154+
TSRM_EXP_API ts_rsrc_id id; \
155+
TSRM_EXP_API ts_rsrc_offset id##_offset
156+
148157
#define TSRMG_DH(type, id) \
149158
TSRM_API extern ts_rsrc_id id; \
150-
TSRM_API extern ts_rsrc_offset id##_offset;
159+
TSRM_API extern ts_rsrc_offset id##_offset
151160

152161
#define TSRMG_D(type, id) \
153162
TSRM_API ts_rsrc_id id; \
154-
TSRM_API ts_rsrc_offset id##_offset;
163+
TSRM_API ts_rsrc_offset id##_offset
155164

156165
#define TSRMG_ALLOCATE(id, size, ctor, dtor) \
157166
TSRMG_ALLOCATE_EX(id, id##_offset, size, ctor, dtor);
@@ -216,6 +225,9 @@ TSRM_API void *tsrm_new_interpreter_context(void);
216225
TSRM_API void *tsrm_set_interpreter_context(void *new_ctx);
217226
TSRM_API void tsrm_free_interpreter_context(void *context);
218227

228+
TSRM_API void *get_tsrm_ls_cache(void);
229+
TSRM_API void set_tsrm_ls_cache(void **tsrm_ls_cache);
230+
219231
#ifdef __cplusplus
220232
}
221233
#endif

TSRM/tsrm_win32.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535
#include "zend_virtual_cwd.h"
3636

3737
#ifdef ZTS
38-
static ts_rsrc_id win32_globals_id;
38+
TSRMG_D(win32_globals, win32_globals_id);
3939
#else
4040
static tsrm_win32_globals win32_globals;
4141
#endif

TSRM/tsrm_win32.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@ typedef struct {
6969

7070
#ifdef ZTS
7171
# define TWG(v) TSRMG(win32_globals_id, tsrm_win32_globals *, v)
72+
TSRMG_DH(win32_globals, win32_globals_id);
7273
#else
7374
# define TWG(v) (win32_globals.v)
7475
#endif

Zend/zend.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,11 @@ void zend_error_noreturn(int type, const char *format, ...) ZEND_NORETURN;
7171
# define zend_error_noreturn zend_error
7272
#endif
7373

74+
#ifdef ZTS
75+
TSRMG_DH(zend_compiler_globals, compiler_globals_id);
76+
TSRMG_DH(zend_executor_globals, executor_globals_id);
77+
#endif
78+
7479
/* overloaded elements data types */
7580
#define OE_IS_ARRAY (1<<0)
7681
#define OE_IS_OBJECT (1<<1)

Zend/zend_API.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ typedef struct _zend_fcall_info_cache {
145145
#ifdef ZTS
146146

147147
#define ZEND_DECLARE_MODULE_GLOBALS(module_name) \
148-
TSRMG_D(zend_##module_name##_globals, module_name##_globals_id);
148+
TSRMG_DE(zend_##module_name##_globals, module_name##_globals_id);
149149
#define ZEND_EXTERN_MODULE_GLOBALS(module_name) \
150150
TSRMG_DH(zend_##module_name##_globals, module_name##_globals_id);
151151
#define ZEND_INIT_MODULE_GLOBALS(module_name, globals_ctor, globals_dtor) \

ext/date/php_date.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -197,6 +197,7 @@ ZEND_BEGIN_MODULE_GLOBALS(date)
197197
ZEND_END_MODULE_GLOBALS(date)
198198

199199
#ifdef ZTS
200+
TSRMG_DH(zend_date_globals, date_globals_id);
200201
#define DATEG(v) TSRMG(date_globals_id, zend_date_globals *, v)
201202
#else
202203
#define DATEG(v) (date_globals.v)

sapi/apache2handler/php_apache.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ typedef struct {
7878
extern zend_module_entry apache2_module_entry;
7979

8080
#ifdef ZTS
81-
TSRMG_DH(php_apache2_info_struct, php_apache2_info_id);
81+
TSRMG_DHE(php_apache2_info_struct, php_apache2_info_id);
8282
#define AP2(v) TSRMG(php_apache2_info_id, php_apache2_info_struct *, v)
8383
#else
8484
extern php_apache2_info_struct php_apache2_info;

sapi/apache2handler/php_functions.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@
4949
#include "php_apache.h"
5050

5151
#ifdef ZTS
52-
TSRMG_D(php_apache2_info_struct, php_apache2_info_id);
52+
TSRMG_DE(php_apache2_info_struct, php_apache2_info_id);
5353
#else
5454
php_apache2_info_struct php_apache2_info;
5555
#endif

sapi/cli/php_cli_server.c

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -112,8 +112,6 @@
112112
#define OUTPUT_IS_TTY 1
113113
#define OUTPUT_NOT_TTY 0
114114

115-
TSRMG_D(zend_cli_server_globals, cli_server_globals_id);
116-
117115
typedef struct php_cli_server_poller {
118116
fd_set rfds, wfds;
119117
struct {

sapi/cli/php_cli_server.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ ZEND_END_MODULE_GLOBALS(cli_server)
3333

3434
#ifdef ZTS
3535
#define CLI_SERVER_G(v) TSRMG(cli_server_globals_id, zend_cli_server_globals *, v)
36-
TSRMG_DH(zend_cli_server_globals, cli_server_globals_id);
36+
TSRMG_DHE(zend_cli_server_globals, cli_server_globals_id);
3737
#else
3838
#define CLI_SERVER_G(v) (cli_server_globals.v)
3939
#endif

win32/globals.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
#include "syslog.h"
2424

2525
#ifdef ZTS
26-
PHPAPI int php_win32_core_globals_id;
26+
TSRMG_D(php_win32_core_globals, php_win32_core_globals_id);
2727
#else
2828
php_win32_core_globals the_php_win32_core_globals;
2929
#endif

win32/php_win32_globals.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ typedef struct _php_win32_core_globals php_win32_core_globals;
2727

2828
#ifdef ZTS
2929
# define PW32G(v) TSRMG(php_win32_core_globals_id, php_win32_core_globals*, v)
30-
extern PHPAPI int php_win32_core_globals_id;
30+
TSRMG_DH(php_win32_core_globals, php_win32_core_globals_id);
3131
#else
3232
# define PW32G(v) (the_php_win32_core_globals.v)
3333
extern PHPAPI struct _php_win32_core_globals the_php_win32_core_globals;

0 commit comments

Comments
 (0)