basic windows fix

This commit is contained in:
Anatol Belski 2014-09-22 20:58:45 +02:00
parent f2e636de05
commit 4db75dc853
13 changed files with 46 additions and 23 deletions

View File

@ -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
@ -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 */

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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