Skip to content

Commit

Permalink
basic windows fix
Browse files Browse the repository at this point in the history
  • Loading branch information
weltling committed Sep 22, 2014
1 parent f2e636d commit 4db75dc
Show file tree
Hide file tree
Showing 13 changed files with 46 additions and 23 deletions.
14 changes: 10 additions & 4 deletions TSRM/TSRM.c
Original file line number Diff line number Diff line change
Expand Up @@ -63,11 +63,7 @@ static int tsrm_error_level;
static FILE *tsrm_error_file;

#ifdef USE___THREAD
#ifdef TSRM_WIN32
TSRM_TLS void *tsrm_ls_cache = 0;
#else
TSRM_API TSRM_TLS void *tsrm_ls_cache = 0;
#endif
#endif

#ifdef PASS_TSRMLS
Expand Down Expand Up @@ -833,4 +829,14 @@ void tsrm_error_set(int level, char *debug_filename)
#endif
}

TSRM_API void *get_tsrm_ls_cache(void)
{
return tsrm_ls_cache;
}

TSRM_API void set_tsrm_ls_cache(void **cache)
{
tsrm_ls_cache = *cache;
}

#endif /* ZTS */
32 changes: 22 additions & 10 deletions TSRM/TSRM.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,13 @@
# else
# define TSRM_API __declspec(dllimport)
# endif
# define TSRM_EXP_API __declspec(dllexport)
#elif defined(__GNUC__) && __GNUC__ >= 4
# define TSRM_API __attribute__ ((visibility("default")))
# define TSRM_EXP_API TSRM_API
#else
# define TSRM_API
# define TSRM_EXP_API
#endif

#ifdef _WIN64
Expand Down Expand Up @@ -109,16 +112,14 @@ extern "C" {
# define TSRM_TLS __thread
# endif

#ifdef TSRM_WIN32
extern TSRM_TLS void *tsrm_ls_cache;
#else
TSRM_API extern TSRM_TLS void *tsrm_ls_cache;
#endif

#define TSRMG(id, type, element) \
((type)((tsrm_uintptr_t)tsrm_ls_cache + id##_offset))->element
((type)((tsrm_uintptr_t) get_tsrm_ls_cache() + id##_offset))->element

#define TSRMLS_INIT() do { \
void *cache = (void *) ts_resource_ex(0, NULL); \
set_tsrm_ls_cache(&cache); \
} while (0)

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

#endif /* USE___THREAD */

#define TSRMG_DHE(type, id) \
TSRM_EXP_API extern ts_rsrc_id id; \
TSRM_EXP_API extern ts_rsrc_offset id##_offset

#define TSRMG_DE(type, id) \
TSRM_EXP_API ts_rsrc_id id; \
TSRM_EXP_API ts_rsrc_offset id##_offset

#define TSRMG_DH(type, id) \
TSRM_API extern ts_rsrc_id id; \
TSRM_API extern ts_rsrc_offset id##_offset;
TSRM_API extern ts_rsrc_offset id##_offset

#define TSRMG_D(type, id) \
TSRM_API ts_rsrc_id id; \
TSRM_API ts_rsrc_offset id##_offset;
TSRM_API ts_rsrc_offset id##_offset

#define TSRMG_ALLOCATE(id, size, ctor, dtor) \
TSRMG_ALLOCATE_EX(id, id##_offset, size, ctor, dtor);
Expand Down Expand Up @@ -216,6 +225,9 @@ TSRM_API void *tsrm_new_interpreter_context(void);
TSRM_API void *tsrm_set_interpreter_context(void *new_ctx);
TSRM_API void tsrm_free_interpreter_context(void *context);

TSRM_API void *get_tsrm_ls_cache(void);
TSRM_API void set_tsrm_ls_cache(void **tsrm_ls_cache);

#ifdef __cplusplus
}
#endif
Expand Down
2 changes: 1 addition & 1 deletion TSRM/tsrm_win32.c
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
#include "zend_virtual_cwd.h"

#ifdef ZTS
static ts_rsrc_id win32_globals_id;
TSRMG_D(win32_globals, win32_globals_id);
#else
static tsrm_win32_globals win32_globals;
#endif
Expand Down
1 change: 1 addition & 0 deletions TSRM/tsrm_win32.h
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ typedef struct {

#ifdef ZTS
# define TWG(v) TSRMG(win32_globals_id, tsrm_win32_globals *, v)
TSRMG_DH(win32_globals, win32_globals_id);
#else
# define TWG(v) (win32_globals.v)
#endif
Expand Down
5 changes: 5 additions & 0 deletions Zend/zend.h
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,11 @@ void zend_error_noreturn(int type, const char *format, ...) ZEND_NORETURN;
# define zend_error_noreturn zend_error
#endif

#ifdef ZTS
TSRMG_DH(zend_compiler_globals, compiler_globals_id);
TSRMG_DH(zend_executor_globals, executor_globals_id);
#endif

/* overloaded elements data types */
#define OE_IS_ARRAY (1<<0)
#define OE_IS_OBJECT (1<<1)
Expand Down
2 changes: 1 addition & 1 deletion Zend/zend_API.h
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ typedef struct _zend_fcall_info_cache {
#ifdef ZTS

#define ZEND_DECLARE_MODULE_GLOBALS(module_name) \
TSRMG_D(zend_##module_name##_globals, module_name##_globals_id);
TSRMG_DE(zend_##module_name##_globals, module_name##_globals_id);
#define ZEND_EXTERN_MODULE_GLOBALS(module_name) \
TSRMG_DH(zend_##module_name##_globals, module_name##_globals_id);
#define ZEND_INIT_MODULE_GLOBALS(module_name, globals_ctor, globals_dtor) \
Expand Down
1 change: 1 addition & 0 deletions ext/date/php_date.h
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,7 @@ ZEND_BEGIN_MODULE_GLOBALS(date)
ZEND_END_MODULE_GLOBALS(date)

#ifdef ZTS
TSRMG_DH(zend_date_globals, date_globals_id);
#define DATEG(v) TSRMG(date_globals_id, zend_date_globals *, v)
#else
#define DATEG(v) (date_globals.v)
Expand Down
2 changes: 1 addition & 1 deletion sapi/apache2handler/php_apache.h
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ typedef struct {
extern zend_module_entry apache2_module_entry;

#ifdef ZTS
TSRMG_DH(php_apache2_info_struct, php_apache2_info_id);
TSRMG_DHE(php_apache2_info_struct, php_apache2_info_id);
#define AP2(v) TSRMG(php_apache2_info_id, php_apache2_info_struct *, v)
#else
extern php_apache2_info_struct php_apache2_info;
Expand Down
2 changes: 1 addition & 1 deletion sapi/apache2handler/php_functions.c
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@
#include "php_apache.h"

#ifdef ZTS
TSRMG_D(php_apache2_info_struct, php_apache2_info_id);
TSRMG_DE(php_apache2_info_struct, php_apache2_info_id);
#else
php_apache2_info_struct php_apache2_info;
#endif
Expand Down
2 changes: 0 additions & 2 deletions sapi/cli/php_cli_server.c
Original file line number Diff line number Diff line change
Expand Up @@ -112,8 +112,6 @@
#define OUTPUT_IS_TTY 1
#define OUTPUT_NOT_TTY 0

TSRMG_D(zend_cli_server_globals, cli_server_globals_id);

typedef struct php_cli_server_poller {
fd_set rfds, wfds;
struct {
Expand Down
2 changes: 1 addition & 1 deletion sapi/cli/php_cli_server.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ ZEND_END_MODULE_GLOBALS(cli_server)

#ifdef ZTS
#define CLI_SERVER_G(v) TSRMG(cli_server_globals_id, zend_cli_server_globals *, v)
TSRMG_DH(zend_cli_server_globals, cli_server_globals_id);
TSRMG_DHE(zend_cli_server_globals, cli_server_globals_id);
#else
#define CLI_SERVER_G(v) (cli_server_globals.v)
#endif
Expand Down
2 changes: 1 addition & 1 deletion win32/globals.c
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
#include "syslog.h"

#ifdef ZTS
PHPAPI int php_win32_core_globals_id;
TSRMG_D(php_win32_core_globals, php_win32_core_globals_id);
#else
php_win32_core_globals the_php_win32_core_globals;
#endif
Expand Down
2 changes: 1 addition & 1 deletion win32/php_win32_globals.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ typedef struct _php_win32_core_globals php_win32_core_globals;

#ifdef ZTS
# define PW32G(v) TSRMG(php_win32_core_globals_id, php_win32_core_globals*, v)
extern PHPAPI int php_win32_core_globals_id;
TSRMG_DH(php_win32_core_globals, php_win32_core_globals_id);
#else
# define PW32G(v) (the_php_win32_core_globals.v)
extern PHPAPI struct _php_win32_core_globals the_php_win32_core_globals;
Expand Down

0 comments on commit 4db75dc

Please sign in to comment.