Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

PHPEMBED: Thread Safety GO

Summary: The PHPEmbed core is now thread safe. New problem: our extensions
aren't. Putting big ass locks around each of them is next.

This also adds protection against reentrence for shared single instances

Reviewed By: shire

Test Plan: 
WITHOUT ZTS:
- test, example, and usage from the examples dir all pass
- worker passes
- separate thread and reentrant tests both fail
WITH ZTS:
- test, example, and usage from the examples dir all pass
- worker fails (extensions are not thread safe)
- separate thread and reentrant tests both pass




git-svn-id: svn+ssh://tubbs/svnroot/projects/phpembed/trunk@65268 2c7ba8d8-a2f7-0310-a573-de162e16dcc7
  • Loading branch information...
commit eb51c6cdc28945288471d114e6e0e20f28828973 1 parent 4eb2278
boz authored
View
8 examples/example.cpp
@@ -55,14 +55,16 @@ int main(int argc, char **argv){
printf("\n");
// get a nested array back from php
- php_array a = p.call_php_array("foo_complex_array");
+ php_array *a = p.call_php_array("foo_complex_array");
// use our function below with iterators and type checking to print it in C
- print_php_array(a);
+ print_php_array(*a);
printf("\n");
// now try printing it with PHP, should use our output function from above
- p.call_void("print_r", "a", &a);
+ p.call_void("print_r", "a", a);
+
+ delete a;
}
View
6 examples/test.cpp
@@ -503,8 +503,8 @@ int main(int argc, char **argv){
printf("testing call_php_array and php_iterator...");
bool pass = true;
- php_array e = p.call_php_array("foo_complex_array");
- php_iterator it(e);
+ php_array *e = p.call_php_array("foo_complex_array");
+ php_iterator it(*e);
if(!it.done() && it.get_data_type() == IS_ARRAY){
php_array f = it.get_data_array();
@@ -576,6 +576,8 @@ int main(int argc, char **argv){
pass = false;
}
+ delete e;
+
if(!pass){
printf("failed!\n");
failcount++;
View
325 src/php_cxx.cpp
@@ -5,33 +5,6 @@
#include "php_cxx.h"
#include <stdio.h>
-php::php(bool _type_warnings)
-{
- type_warnings = _type_warnings;
-
- char *argv[2] = {"", NULL};
-
- // set up the callbacks
- php_embed_module.sapi_error = error_wrap;
- php_embed_module.log_message = message_wrap;
- php_embed_module.ub_write = output_wrap;
-
- if (SUCCESS != php_embed_init(1, argv PTSRMLS_CC))
- {
- internal_error("PHP ERROR: failed initializing php_embed\n");
- status = FAIL;
- return;
- }
-
- // CLIENTS: you may want to modify these ini arguments in your code
-
- // as an embedded module, we don't want any PHP timeout!
- php_set_ini_entry("max_execution_time", "0", PHP_INI_STAGE_ACTIVATE);
-
- // we don't have get or post or cookie data in an embedded context
- php_set_ini_entry("variables_order", "S", PHP_INI_STAGE_ACTIVATE);
-}
-
void php::set_message_function(void (*_message_function)(const char *)){
p.message_function = _message_function;
}
@@ -61,24 +34,32 @@ void php::internal_error(const char *str){
void php::error_wrap(int error, const char * fmt, ...){
- char **buffer;
+ // NOTE: for reasons passing understanding, compiling with ZTS enabled
+ // causes vasprintf to seg fault on allocation, so we've implemented this
+ // vsnprintf workaround
va_list ap;
va_start(ap, fmt);
- int ret = vasprintf(buffer, fmt, ap);
- // give up if we failed to allocate a proper buffer
- if(ret < 0)
- return;
+ char *dummy;
+ int size = vsnprintf(dummy, 0, fmt, ap);
va_end(ap);
+ va_start(ap, fmt);
+
+ char buffer[size + 1];
+ int ret= vsnprintf(buffer, size + 1, fmt, ap);
- internal_error(*buffer);
+ va_end(ap);
- free(*buffer);
+ // give up if we failed to allocate a proper buffer
+ if(ret < size)
+ return;
+
+ internal_error(buffer);
}
-int php::output_wrap(const char *str, unsigned int strlen){
+int php::output_wrap(const char *str, unsigned int strlen TSRMLS_DC){
if(strlen <= 0)
return SUCCESS;
@@ -90,35 +71,34 @@ int php::output_wrap(const char *str, unsigned int strlen){
return SUCCESS;
}
-php::~php()
-{
- php_embed_shutdown(TSRMLS_C);
-}
-
// void is the easiest, we just call the function and free the return
void php::call_void(char *fn, char *argspec, ...)
{
+ PUSH_CTX();
zval *rv;
va_list ap;
va_start(ap, argspec);
- rv = call(fn, argspec, ap);
+ rv = call(fn, argspec, ap TSRMLS_CC);
va_end(ap);
if(rv)
zval_ptr_dtor(&rv);
+ POP_CTX();
return;
}
long php::call_long(char *fn, char *argspec, ...)
{
- zval *rv;
long rrv = 0;
+ PUSH_CTX();
+ zval *rv;
+
va_list ap;
va_start(ap, argspec);
- rv = call(fn, argspec, ap);
+ rv = call(fn, argspec, ap TSRMLS_CC);
va_end(ap);
if(rv)
@@ -149,17 +129,20 @@ long php::call_long(char *fn, char *argspec, ...)
zval_ptr_dtor(&rv);
}
+ POP_CTX();
return rrv;
}
bool php::call_bool(char *fn, char *argspec, ...)
{
- zval *rv;
bool rrv = false;
+ PUSH_CTX();
+ zval *rv;
+
va_list ap;
va_start(ap, argspec);
- rv = call(fn, argspec, ap);
+ rv = call(fn, argspec, ap TSRMLS_CC);
va_end(ap);
if(rv)
@@ -188,17 +171,20 @@ bool php::call_bool(char *fn, char *argspec, ...)
zval_ptr_dtor(&rv);
}
+ POP_CTX();
return rrv;
}
double php::call_double(char *fn, char *argspec, ...)
{
- zval *rv;
double rrv = 0;
+ PUSH_CTX();
+ zval *rv;
+
va_list ap;
va_start(ap, argspec);
- rv = call(fn, argspec, ap);
+ rv = call(fn, argspec, ap TSRMLS_CC);
va_end(ap);
if(rv)
@@ -227,17 +213,20 @@ double php::call_double(char *fn, char *argspec, ...)
zval_ptr_dtor(&rv);
}
+ POP_CTX();
return rrv;
}
char *php::call_c_string(char *fn, char *argspec, ...)
{
- zval *rv;
char *rrv = NULL;
+ PUSH_CTX();
+ zval *rv;
+
va_list ap;
va_start(ap, argspec);
- rv = call(fn, argspec, ap);
+ rv = call(fn, argspec, ap TSRMLS_CC);
va_end(ap);
if(rv)
@@ -266,16 +255,20 @@ char *php::call_c_string(char *fn, char *argspec, ...)
zval_ptr_dtor(&rv);
}
+ POP_CTX();
return rrv;
}
-php_array php::call_php_array(char *fn, char *argspec, ...)
+php_array *php::call_php_array(char *fn, char *argspec, ...)
{
+ php_array *rrv = NULL;
+
+ PUSH_CTX();
zval *rv;
va_list ap;
va_start(ap, argspec);
- rv = call(fn, argspec, ap);
+ rv = call(fn, argspec, ap TSRMLS_CC);
va_end(ap);
if(rv)
@@ -301,22 +294,24 @@ php_array php::call_php_array(char *fn, char *argspec, ...)
}
// create the new php array object
- php_array rrv(rv);
+ rrv = new php_array(rv);
zval_ptr_dtor(&rv);
- return rrv;
}
- return php_array();
+ POP_CTX();
+ return rrv;
}
long *php::call_long_arr(size_t *size, char *fn, char *argspec, ...)
{
- zval *rv;
long *rrv = NULL;
+ PUSH_CTX();
+ zval *rv;
+
va_list ap;
va_start(ap, argspec);
- rv = call(fn, argspec, ap);
+ rv = call(fn, argspec, ap TSRMLS_CC);
va_end(ap);
if(rv)
@@ -370,14 +365,17 @@ long *php::call_long_arr(size_t *size, char *fn, char *argspec, ...)
zval_ptr_dtor(&rv);
}
+ POP_CTX();
return rrv;
}
bool *php::call_bool_arr(size_t *size, char *fn, char *argspec, ...)
{
- zval *rv;
bool *rrv = NULL;
+ PUSH_CTX();
+ zval *rv;
+
if(NULL == size){
internal_error("size must point to a valid size_t object\n");
return NULL;
@@ -385,7 +383,7 @@ bool *php::call_bool_arr(size_t *size, char *fn, char *argspec, ...)
va_list ap;
va_start(ap, argspec);
- rv = call(fn, argspec, ap);
+ rv = call(fn, argspec, ap TSRMLS_CC);
va_end(ap);
if(rv)
@@ -439,14 +437,17 @@ bool *php::call_bool_arr(size_t *size, char *fn, char *argspec, ...)
zval_ptr_dtor(&rv);
}
+ POP_CTX();
return rrv;
}
double *php::call_double_arr(size_t *size, char *fn, char *argspec, ...)
{
- zval *rv;
double *rrv = NULL;
+ PUSH_CTX();
+ zval *rv;
+
if(NULL == size){
internal_error("size must point to a valid size_t object\n");
return NULL;
@@ -454,7 +455,7 @@ double *php::call_double_arr(size_t *size, char *fn, char *argspec, ...)
va_list ap;
va_start(ap, argspec);
- rv = call(fn, argspec, ap);
+ rv = call(fn, argspec, ap TSRMLS_CC);
va_end(ap);
if(rv)
@@ -508,14 +509,17 @@ double *php::call_double_arr(size_t *size, char *fn, char *argspec, ...)
zval_ptr_dtor(&rv);
}
+ POP_CTX();
return rrv;
}
char **php::call_c_string_arr(size_t *size, char *fn, char *argspec, ...)
{
- zval *rv;
char **rrv = NULL;
+ PUSH_CTX();
+ zval *rv;
+
if(NULL == size){
internal_error("size must point to a valid size_t object\n");
return NULL;
@@ -523,7 +527,7 @@ char **php::call_c_string_arr(size_t *size, char *fn, char *argspec, ...)
va_list ap;
va_start(ap, argspec);
- rv = call(fn, argspec, ap);
+ rv = call(fn, argspec, ap TSRMLS_CC);
va_end(ap);
if(rv)
@@ -577,15 +581,18 @@ char **php::call_c_string_arr(size_t *size, char *fn, char *argspec, ...)
zval_ptr_dtor(&rv);
}
+ POP_CTX();
return rrv;
}
// NOTE: this just truncates the php long to an int!
int *php::call_int_arr(size_t *size, char *fn, char *argspec, ...)
{
- zval *rv;
int *rrv = NULL;
+ PUSH_CTX();
+ zval *rv;
+
if(NULL == size){
internal_error("size must point to a valid size_t object\n");
return NULL;
@@ -593,7 +600,7 @@ int *php::call_int_arr(size_t *size, char *fn, char *argspec, ...)
va_list ap;
va_start(ap, argspec);
- rv = call(fn, argspec, ap);
+ rv = call(fn, argspec, ap TSRMLS_CC);
va_end(ap);
if(rv)
@@ -648,15 +655,18 @@ int *php::call_int_arr(size_t *size, char *fn, char *argspec, ...)
zval_ptr_dtor(&rv);
}
+ POP_CTX();
return rrv;
}
// NOTE: this just truncates the php long to an int!
unsigned int *php::call_uint_arr(size_t *size, char *fn, char *argspec, ...)
{
- zval *rv;
unsigned int *rrv = NULL;
+ PUSH_CTX();
+ zval *rv;
+
if(NULL == size){
internal_error("size must point to a valid size_t object\n");
return NULL;
@@ -664,7 +674,7 @@ unsigned int *php::call_uint_arr(size_t *size, char *fn, char *argspec, ...)
va_list ap;
va_start(ap, argspec);
- rv = call(fn, argspec, ap);
+ rv = call(fn, argspec, ap TSRMLS_CC);
va_end(ap);
if(rv)
@@ -720,6 +730,7 @@ unsigned int *php::call_uint_arr(size_t *size, char *fn, char *argspec, ...)
zval_ptr_dtor(&rv);
}
+ POP_CTX();
return rrv;
}
@@ -737,9 +748,11 @@ php_ret php::eval_string(const char *fmt, ...)
va_start(ap, fmt);
+ PUSH_CTX();
+
zend_first_try {
vspprintf(&data, 0, fmt, ap);
- status = zend_eval_string(data, NULL, "");
+ status = zend_eval_string(data, NULL, "" TSRMLS_CC);
} zend_catch {
status = FAIL;
} zend_end_try();
@@ -747,6 +760,7 @@ php_ret php::eval_string(const char *fmt, ...)
if (data)
efree(data);
+ POP_CTX();
va_end(ap);
return status;
}
@@ -755,17 +769,23 @@ php_ret php::eval_string(const char *fmt, ...)
zval *php::call(char *fn, char *argspec, ...){
zval *rv;
+ PUSH_CTX();
+
va_list ap;
va_start(ap, argspec);
- rv = call(fn, argspec, ap);
+ rv = call(fn, argspec, ap TSRMLS_CC);
va_end(ap);
+ POP_CTX();
+
return rv;
}
// call an arbitrary php function with the given arguments
-zval *php::call(char *fn, char *argspec, va_list ap)
+zval *php::call(char *fn, char *argspec, va_list ap TSRMLS_DC)
{
+ zval *rrv = NULL;
+
zend_try {
// convert the function name to a zval
zval *function_name;
@@ -782,34 +802,35 @@ zval *php::call(char *fn, char *argspec, va_list ap)
if(params[i]) zval_ptr_dtor(&params[i]);
efree(function_name);
status = FAIL;
- return NULL;
}
- zval *rv;
- MAKE_STD_ZVAL(rv);
- if(call_user_function(EG(function_table), NULL, function_name, rv,
- count, params TSRMLS_CC) != SUCCESS)
- {
- error_wrap(0, "calling function %s\n", fn);
- for(unsigned int i = 0; i < count; i++)
- if(params[i]) zval_ptr_dtor(&params[i]);
- efree(function_name);
- status = FAIL;
- return NULL;
- }
+ if(status != FAIL){
+ zval *rv;
+ MAKE_STD_ZVAL(rv);
+ if(call_user_function(EG(function_table), NULL, function_name, rv,
+ count, params TSRMLS_CC) != SUCCESS)
+ {
+ error_wrap(0, "calling function %s\n", fn);
+ for(unsigned int i = 0; i < count; i++)
+ if(params[i]) zval_ptr_dtor(&params[i]);
+ efree(function_name);
+ status = FAIL;
+ }
- for(unsigned int i = 0; i < count; i++)
- if(params[i]) zval_ptr_dtor(&params[i]);
- efree(function_name);
- return rv;
+ if(status != FAIL){
+ for(unsigned int i = 0; i < count; i++)
+ if(params[i]) zval_ptr_dtor(&params[i]);
+ efree(function_name);
+ rrv = rv;
+ }
+ }
} zend_catch {
error_wrap(0, "preparing function %s\n", fn);
status = FAIL;
- return NULL;
} zend_end_try() {
- return NULL;
}
- return NULL;
+
+ return rrv;
}
@@ -899,3 +920,129 @@ int php::php_set_ini_entry(char *entry, char *value, int stage)
return zend_alter_ini_entry(entry, strlen(entry)+1, value, strlen(value)+1,
PHP_INI_USER, stage);
}
+
+php::~php()
+{
+ PUSH_CTX();
+ php_request_shutdown((void *) 0);
+ php_module_shutdown(TSRMLS_C);
+ POP_CTX();
+#ifdef ZTS
+ tsrm_mutex_free(lock);
+#endif
+
+ p.clients--;
+ if(p.clients == 0 && p.initialized == true){
+ p.initialized = false;
+ sapi_shutdown();
+#ifdef ZTS
+ tsrm_shutdown();
+#endif
+ }
+}
+
+php::php(bool _type_warnings)
+{
+ type_warnings = _type_warnings;
+
+ // this will happen only once, but it keeps track of that
+ if(SUCCESS != init_global_php()){
+ internal_error("PHP ERROR: failed to initialize global PHP object\n");
+ status = FAIL;
+ }
+
+ // now we need to create a specific context for this particular object
+#ifdef ZTS
+ ctx = tsrm_new_interpreter_context();
+ lock = tsrm_mutex_alloc();
+# endif
+
+ PUSH_CTX();
+
+ // ADAPTED from php_embed_init
+ php_set_ini_entry("register_argc_argv", "1", PHP_INI_STAGE_ACTIVATE);
+ php_set_ini_entry("html_errors", "0", PHP_INI_STAGE_ACTIVATE);
+ php_set_ini_entry("implicit_flush", "1", PHP_INI_STAGE_ACTIVATE);
+ php_set_ini_entry("max_execution_time", "0", PHP_INI_STAGE_ACTIVATE);
+
+ // we don't have get or post or cookie data in an embedded context
+ php_set_ini_entry("variables_order", "S", PHP_INI_STAGE_ACTIVATE);
+
+ // CLIENTS: you may want to add your own ini modifications here
+
+ // ADAPTED from php_embed_init
+ SG(options) |= SAPI_OPTION_NO_CHDIR;
+ SG(headers_sent) = 1;
+ SG(request_info).no_headers = 1;
+
+ php_request_startup( TSRMLS_C );
+
+ PG( during_request_startup) = 0;
+
+ POP_CTX();
+}
+
+int php::init_global_php(){
+
+ // set up the callbacks
+ php_embed_module.sapi_error = error_wrap;
+ php_embed_module.log_message = message_wrap;
+ php_embed_module.ub_write = output_wrap;
+
+ // ADAPTED FROM php_embed_init, look for PHPE comments for our local edits
+
+ zend_llist global_vars;
+#ifdef ZTS
+ zend_compiler_globals *compiler_globals;
+ zend_executor_globals *executor_globals;
+ php_core_globals *core_globals;
+ sapi_globals_struct *sapi_globals;
+ void ***tsrm_ls;
+#endif
+
+ // PHPE: lots of objects will use this one initialized php instance
+ p.clients++;
+ if(p.initialized == true)
+ return SUCCESS;
+ p.initialized = true;
+
+#ifdef HAVE_SIGNAL_H
+#if defined(SIGPIPE) && defined(SIG_IGN)
+ signal(SIGPIPE, SIG_IGN); /* ignore SIGPIPE in standalone mode so
+ that sockets created via fsockopen()
+ don't kill PHP if the remote site
+ closes it. in apache|apxs mode apache
+ does that for us! thies@thieso.net
+ 20000419 */
+#endif
+#endif
+
+#ifdef PHP_WIN32
+ _fmode = _O_BINARY; /*sets default for file streams to binary */
+ setmode(_fileno(stdin), O_BINARY); /* make the stdio mode be binary */
+ setmode(_fileno(stdout), O_BINARY); /* make the stdio mode be binary */
+ setmode(_fileno(stderr), O_BINARY); /* make the stdio mode be binary */
+#endif
+
+#ifdef ZTS
+ // PHPE: if they want threads, let's give them more than 1!
+ tsrm_startup(128, 32, 0, NULL);
+ compiler_globals = (zend_compiler_globals *)ts_resource(compiler_globals_id);
+ executor_globals = (zend_executor_globals *)ts_resource(executor_globals_id);
+ core_globals = (php_core_globals *)ts_resource(core_globals_id);
+ sapi_globals = (sapi_globals_struct *)ts_resource(sapi_globals_id);
+ tsrm_ls = (void ***)ts_resource(0);
+#endif
+
+ sapi_startup(&php_embed_module);
+
+ if (php_embed_module.startup(&php_embed_module)==FAILURE) {
+ return FAILURE;
+ }
+
+ zend_llist_init(&global_vars, sizeof(char *), NULL, 0);
+
+ return SUCCESS;
+ // END ADAPTED php_embed_init
+}
+
View
38 src/php_cxx.h
@@ -11,6 +11,17 @@
#define SUCCESS 0
#define FAIL 1
+#ifdef ZTS
+#define PUSH_CTX() tsrm_mutex_lock(lock); \
+ void *prev_ctx = tsrm_set_interpreter_context(ctx); \
+ { TSRMLS_FETCH();
+#define POP_CTX() } tsrm_set_interpreter_context(prev_ctx); \
+ tsrm_mutex_unlock(lock);
+#else
+#define PUSH_CTX()
+#define POP_CTX()
+#endif
+
typedef unsigned int php_ret;
// these function pointers are in a separate class because
@@ -21,11 +32,17 @@ typedef unsigned int php_ret;
class php_const
{
public:
- php_const() { message_function = error_function = output_function = NULL; }
+ php_const() {
+ message_function = error_function = output_function = NULL;
+ initialized = false;
+ clients = 0;
+ }
void (*message_function)(const char *);
void (*error_function)(const char *);
void (*output_function)(const char *);
+ bool initialized;
+ int clients;
};
// This is the global constants variable we define for the reasons listed above
@@ -71,7 +88,9 @@ class php
// no int or uint versions since the user can just call_long and truncate
// gotta use this if you're going for nested arrays of any kind
- php_array call_php_array(char *fn, char *argspec = "", ...);
+ //
+ // NOTE: user is responsible for deleting the returned object
+ php_array *call_php_array(char *fn, char *argspec = "", ...);
// same as above except these return an array of the given type
// and set the size argument to the size of the array
@@ -103,7 +122,7 @@ class php
// we don't want the user to have to deal with zval returns
// caller needs to free the zval returned
- zval *call(char *fn, char *argspec, va_list ap);
+ zval *call(char *fn, char *argspec, va_list ap TSRMLS_DC);
zval *call(char *fn, char *argspec = "", ...);
// we'll use the same function as error_wrap for this
@@ -111,6 +130,14 @@ class php
bool type_warnings;
+#ifdef ZTS
+ // this is the context in which we evaluate this objects requests
+ void *ctx;
+
+ // a mutex to prevent re-entrance
+ MUTEX_T lock;
+#endif
+
private:
// these calls match the signatures required by php_embed_module but really
@@ -120,8 +147,11 @@ class php
// errors are sent to stderr
static void message_wrap(char *str);
static void error_wrap(int error, const char *fmt, ...);
- static int output_wrap(const char *str, unsigned int strlen);
+ static int output_wrap(const char *str, unsigned int strlen TSRMLS_DC);
+ // initialize the global PHP instance
+ int init_global_php();
+
// simulate an ini file on startup
int php_set_ini_entry(char *entry, char *value, int stage);
View
280 src/php_stl.cpp
@@ -6,12 +6,14 @@
string php_stl::call_string(char *fn, char *argspec, ...)
{
- zval *rv;
string rrv;
+ PUSH_CTX();
+ zval *rv;
+
va_list ap;
va_start(ap, argspec);
- rv = call(fn, argspec, ap);
+ rv = call(fn, argspec, ap TSRMLS_CC);
va_end(ap);
if(rv)
@@ -40,17 +42,20 @@ string php_stl::call_string(char *fn, char *argspec, ...)
zval_ptr_dtor(&rv);
}
+ POP_CTX();
return rrv;
}
vector<string> php_stl::call_string_vector(char *fn, char *argspec, ...)
{
- zval *rv;
vector<string> rrv;
+ PUSH_CTX();
+ zval *rv;
+
va_list ap;
va_start(ap, argspec);
- rv = call(fn, argspec, ap);
+ rv = call(fn, argspec, ap TSRMLS_CC);
va_end(ap);
if(rv)
@@ -99,17 +104,20 @@ vector<string> php_stl::call_string_vector(char *fn, char *argspec, ...)
zval_ptr_dtor(&rv);
}
+ POP_CTX();
return rrv;
}
vector<double> php_stl::call_double_vector(char *fn, char *argspec, ...)
{
- zval *rv;
vector<double> rrv;
+ PUSH_CTX();
+ zval *rv;
+
va_list ap;
va_start(ap, argspec);
- rv = call(fn, argspec, ap);
+ rv = call(fn, argspec, ap TSRMLS_CC);
va_end(ap);
if(rv)
@@ -158,17 +166,20 @@ vector<double> php_stl::call_double_vector(char *fn, char *argspec, ...)
zval_ptr_dtor(&rv);
}
+ POP_CTX();
return rrv;
}
vector<long> php_stl::call_long_vector(char *fn, char *argspec, ...)
{
- zval *rv;
vector<long> rrv;
+ PUSH_CTX();
+ zval *rv;
+
va_list ap;
va_start(ap, argspec);
- rv = call(fn, argspec, ap);
+ rv = call(fn, argspec, ap TSRMLS_CC);
va_end(ap);
if(rv)
@@ -217,17 +228,20 @@ vector<long> php_stl::call_long_vector(char *fn, char *argspec, ...)
zval_ptr_dtor(&rv);
}
+ POP_CTX();
return rrv;
}
vector<bool> php_stl::call_bool_vector(char *fn, char *argspec, ...)
{
- zval *rv;
vector<bool> rrv;
+ PUSH_CTX();
+ zval *rv;
+
va_list ap;
va_start(ap, argspec);
- rv = call(fn, argspec, ap);
+ rv = call(fn, argspec, ap TSRMLS_CC);
va_end(ap);
if(rv)
@@ -276,18 +290,21 @@ vector<bool> php_stl::call_bool_vector(char *fn, char *argspec, ...)
zval_ptr_dtor(&rv);
}
+ POP_CTX();
return rrv;
}
// NOTE: this just truncates the php long to an int!
vector<int> php_stl::call_int_vector(char *fn, char *argspec, ...)
{
- zval *rv;
vector<int> rrv;
+ PUSH_CTX();
+ zval *rv;
+
va_list ap;
va_start(ap, argspec);
- rv = call(fn, argspec, ap);
+ rv = call(fn, argspec, ap TSRMLS_CC);
va_end(ap);
if(rv)
@@ -336,18 +353,21 @@ vector<int> php_stl::call_int_vector(char *fn, char *argspec, ...)
zval_ptr_dtor(&rv);
}
+ POP_CTX();
return rrv;
}
// NOTE: this just truncates the php long to an unsigned int!
vector<unsigned int> php_stl::call_uint_vector(char *fn, char *argspec, ...)
{
- zval *rv;
vector<unsigned int> rrv;
+ PUSH_CTX();
+ zval *rv;
+
va_list ap;
va_start(ap, argspec);
- rv = call(fn, argspec, ap);
+ rv = call(fn, argspec, ap TSRMLS_CC);
va_end(ap);
if(rv)
@@ -396,17 +416,20 @@ vector<unsigned int> php_stl::call_uint_vector(char *fn, char *argspec, ...)
zval_ptr_dtor(&rv);
}
+ POP_CTX();
return rrv;
}
set<string> php_stl::call_string_set(char *fn, char *argspec, ...)
{
- zval *rv;
set<string> rrv;
+ PUSH_CTX();
+ zval *rv;
+
va_list ap;
va_start(ap, argspec);
- rv = call(fn, argspec, ap);
+ rv = call(fn, argspec, ap TSRMLS_CC);
va_end(ap);
if(rv)
@@ -455,17 +478,20 @@ set<string> php_stl::call_string_set(char *fn, char *argspec, ...)
zval_ptr_dtor(&rv);
}
+ POP_CTX();
return rrv;
}
set<double> php_stl::call_double_set(char *fn, char *argspec, ...)
{
- zval *rv;
set<double> rrv;
+ PUSH_CTX();
+ zval *rv;
+
va_list ap;
va_start(ap, argspec);
- rv = call(fn, argspec, ap);
+ rv = call(fn, argspec, ap TSRMLS_CC);
va_end(ap);
if(rv)
@@ -514,17 +540,20 @@ set<double> php_stl::call_double_set(char *fn, char *argspec, ...)
zval_ptr_dtor(&rv);
}
+ POP_CTX();
return rrv;
}
set<long> php_stl::call_long_set(char *fn, char *argspec, ...)
{
- zval *rv;
set<long> rrv;
+ PUSH_CTX();
+ zval *rv;
+
va_list ap;
va_start(ap, argspec);
- rv = call(fn, argspec, ap);
+ rv = call(fn, argspec, ap TSRMLS_CC);
va_end(ap);
if(rv)
@@ -573,18 +602,21 @@ set<long> php_stl::call_long_set(char *fn, char *argspec, ...)
zval_ptr_dtor(&rv);
}
+ POP_CTX();
return rrv;
}
// NOTE: this just truncates the php long to an int!
set<int> php_stl::call_int_set(char *fn, char *argspec, ...)
{
- zval *rv;
set<int> rrv;
+ PUSH_CTX();
+ zval *rv;
+
va_list ap;
va_start(ap, argspec);
- rv = call(fn, argspec, ap);
+ rv = call(fn, argspec, ap TSRMLS_CC);
va_end(ap);
if(rv)
@@ -633,18 +665,21 @@ set<int> php_stl::call_int_set(char *fn, char *argspec, ...)
zval_ptr_dtor(&rv);
}
+ POP_CTX();
return rrv;
}
// NOTE: this just truncates the php long to an unsigned int!
set<unsigned int> php_stl::call_uint_set(char *fn, char *argspec, ...)
{
- zval *rv;
set<unsigned int> rrv;
+ PUSH_CTX();
+ zval *rv;
+
va_list ap;
va_start(ap, argspec);
- rv = call(fn, argspec, ap);
+ rv = call(fn, argspec, ap TSRMLS_CC);
va_end(ap);
if(rv)
@@ -693,17 +728,20 @@ set<unsigned int> php_stl::call_uint_set(char *fn, char *argspec, ...)
zval_ptr_dtor(&rv);
}
+ POP_CTX();
return rrv;
}
hash_set<string> php_stl::call_string_hash_set(char *fn, char *argspec, ...)
{
- zval *rv;
hash_set<string> rrv;
+ PUSH_CTX();
+ zval *rv;
+
va_list ap;
va_start(ap, argspec);
- rv = call(fn, argspec, ap);
+ rv = call(fn, argspec, ap TSRMLS_CC);
va_end(ap);
if(rv)
@@ -752,17 +790,20 @@ hash_set<string> php_stl::call_string_hash_set(char *fn, char *argspec, ...)
zval_ptr_dtor(&rv);
}
+ POP_CTX();
return rrv;
}
hash_set<long> php_stl::call_long_hash_set(char *fn, char *argspec, ...)
{
- zval *rv;
hash_set<long> rrv;
+ PUSH_CTX();
+ zval *rv;
+
va_list ap;
va_start(ap, argspec);
- rv = call(fn, argspec, ap);
+ rv = call(fn, argspec, ap TSRMLS_CC);
va_end(ap);
if(rv)
@@ -811,17 +852,20 @@ hash_set<long> php_stl::call_long_hash_set(char *fn, char *argspec, ...)
zval_ptr_dtor(&rv);
}
+ POP_CTX();
return rrv;
}
hash_set<int> php_stl::call_int_hash_set(char *fn, char *argspec, ...)
{
- zval *rv;
hash_set<int> rrv;
+ PUSH_CTX();
+ zval *rv;
+
va_list ap;
va_start(ap, argspec);
- rv = call(fn, argspec, ap);
+ rv = call(fn, argspec, ap TSRMLS_CC);
va_end(ap);
if(rv)
@@ -870,17 +914,20 @@ hash_set<int> php_stl::call_int_hash_set(char *fn, char *argspec, ...)
zval_ptr_dtor(&rv);
}
+ POP_CTX();
return rrv;
}
hash_set<unsigned int> php_stl::call_uint_hash_set(char *fn, char *argspec, ...)
{
- zval *rv;
hash_set<unsigned int> rrv;
+ PUSH_CTX();
+ zval *rv;
+
va_list ap;
va_start(ap, argspec);
- rv = call(fn, argspec, ap);
+ rv = call(fn, argspec, ap TSRMLS_CC);
va_end(ap);
if(rv)
@@ -929,17 +976,20 @@ hash_set<unsigned int> php_stl::call_uint_hash_set(char *fn, char *argspec, ...)
zval_ptr_dtor(&rv);
}
+ POP_CTX();
return rrv;
}
map<string, string> php_stl::call_string_string_map(char *fn, char *argspec, ...)
{
- zval *rv;
map<string, string> rrv;
+ PUSH_CTX();
+ zval *rv;
+
va_list ap;
va_start(ap, argspec);
- rv = call(fn, argspec, ap);
+ rv = call(fn, argspec, ap TSRMLS_CC);
va_end(ap);
if(rv)
@@ -993,17 +1043,20 @@ map<string, string> php_stl::call_string_string_map(char *fn, char *argspec, ...
zval_ptr_dtor(&rv);
}
+ POP_CTX();
return rrv;
}
map<string, double> php_stl::call_string_double_map(char *fn, char *argspec, ...)
{
- zval *rv;
map<string, double> rrv;
+ PUSH_CTX();
+ zval *rv;
+
va_list ap;
va_start(ap, argspec);
- rv = call(fn, argspec, ap);
+ rv = call(fn, argspec, ap TSRMLS_CC);
va_end(ap);
if(rv)
@@ -1057,17 +1110,20 @@ map<string, double> php_stl::call_string_double_map(char *fn, char *argspec, ...
zval_ptr_dtor(&rv);
}
+ POP_CTX();
return rrv;
}
map<string, long> php_stl::call_string_long_map(char *fn, char *argspec, ...)
{
- zval *rv;
map<string, long> rrv;
+ PUSH_CTX();
+ zval *rv;
+
va_list ap;
va_start(ap, argspec);
- rv = call(fn, argspec, ap);
+ rv = call(fn, argspec, ap TSRMLS_CC);
va_end(ap);
if(rv)
@@ -1121,17 +1177,20 @@ map<string, long> php_stl::call_string_long_map(char *fn, char *argspec, ...)
zval_ptr_dtor(&rv);
}
+ POP_CTX();
return rrv;
}
map<string, bool> php_stl::call_string_bool_map(char *fn, char *argspec, ...)
{
- zval *rv;
map<string, bool> rrv;
+ PUSH_CTX();
+ zval *rv;
+
va_list ap;
va_start(ap, argspec);
- rv = call(fn, argspec, ap);
+ rv = call(fn, argspec, ap TSRMLS_CC);
va_end(ap);
if(rv)
@@ -1185,18 +1244,21 @@ map<string, bool> php_stl::call_string_bool_map(char *fn, char *argspec, ...)
zval_ptr_dtor(&rv);
}
+ POP_CTX();
return rrv;
}
// NOTE: this just truncates the php long to and int!
map<string, int> php_stl::call_string_int_map(char *fn, char *argspec, ...)
{
- zval *rv;
map<string, int> rrv;
+ PUSH_CTX();
+ zval *rv;
+
va_list ap;
va_start(ap, argspec);
- rv = call(fn, argspec, ap);
+ rv = call(fn, argspec, ap TSRMLS_CC);
va_end(ap);
if(rv)
@@ -1250,18 +1312,21 @@ map<string, int> php_stl::call_string_int_map(char *fn, char *argspec, ...)
zval_ptr_dtor(&rv);
}
+ POP_CTX();
return rrv;
}
// NOTE: this just truncates the php long to an unsigned int!
map<string, unsigned int> php_stl::call_string_uint_map(char *fn, char *argspec, ...)
{
- zval *rv;
map<string, unsigned int> rrv;
+ PUSH_CTX();
+ zval *rv;
+
va_list ap;
va_start(ap, argspec);
- rv = call(fn, argspec, ap);
+ rv = call(fn, argspec, ap TSRMLS_CC);
va_end(ap);
if(rv)
@@ -1315,17 +1380,20 @@ map<string, unsigned int> php_stl::call_string_uint_map(char *fn, char *argspec,
zval_ptr_dtor(&rv);
}
+ POP_CTX();
return rrv;
}
map<long, string> php_stl::call_long_string_map(char *fn, char *argspec, ...)
{
- zval *rv;
map<long, string> rrv;
+ PUSH_CTX();
+ zval *rv;
+
va_list ap;
va_start(ap, argspec);
- rv = call(fn, argspec, ap);
+ rv = call(fn, argspec, ap TSRMLS_CC);
va_end(ap);
if(rv)
@@ -1379,17 +1447,20 @@ map<long, string> php_stl::call_long_string_map(char *fn, char *argspec, ...)
zval_ptr_dtor(&rv);
}
+ POP_CTX();
return rrv;
}
map<long, double> php_stl::call_long_double_map(char *fn, char *argspec, ...)
{
- zval *rv;
map<long, double> rrv;
+ PUSH_CTX();
+ zval *rv;
+
va_list ap;
va_start(ap, argspec);
- rv = call(fn, argspec, ap);
+ rv = call(fn, argspec, ap TSRMLS_CC);
va_end(ap);
if(rv)
@@ -1443,17 +1514,20 @@ map<long, double> php_stl::call_long_double_map(char *fn, char *argspec, ...)
zval_ptr_dtor(&rv);
}
+ POP_CTX();
return rrv;
}
map<long, long> php_stl::call_long_long_map(char *fn, char *argspec, ...)
{
- zval *rv;
map<long, long> rrv;
+ PUSH_CTX();
+ zval *rv;
+
va_list ap;
va_start(ap, argspec);
- rv = call(fn, argspec, ap);
+ rv = call(fn, argspec, ap TSRMLS_CC);
va_end(ap);
if(rv)
@@ -1507,17 +1581,20 @@ map<long, long> php_stl::call_long_long_map(char *fn, char *argspec, ...)
zval_ptr_dtor(&rv);
}
+ POP_CTX();
return rrv;
}
map<long, bool> php_stl::call_long_bool_map(char *fn, char *argspec, ...)
{
- zval *rv;
map<long, bool> rrv;
+ PUSH_CTX();
+ zval *rv;
+
va_list ap;
va_start(ap, argspec);
- rv = call(fn, argspec, ap);
+ rv = call(fn, argspec, ap TSRMLS_CC);
va_end(ap);
if(rv)
@@ -1571,18 +1648,21 @@ map<long, bool> php_stl::call_long_bool_map(char *fn, char *argspec, ...)
zval_ptr_dtor(&rv);
}
+ POP_CTX();
return rrv;
}
// NOTE: this just truncates the php long to and int!
map<long, int> php_stl::call_long_int_map(char *fn, char *argspec, ...)
{
- zval *rv;
map<long, int> rrv;
+ PUSH_CTX();
+ zval *rv;
+
va_list ap;
va_start(ap, argspec);
- rv = call(fn, argspec, ap);
+ rv = call(fn, argspec, ap TSRMLS_CC);
va_end(ap);
if(rv)
@@ -1636,18 +1716,21 @@ map<long, int> php_stl::call_long_int_map(char *fn, char *argspec, ...)
zval_ptr_dtor(&rv);
}
+ POP_CTX();
return rrv;
}
// NOTE: this just truncates the php long to and unsigned int!
map<long, unsigned int> php_stl::call_long_uint_map(char *fn, char *argspec, ...)
{
- zval *rv;
map<long, unsigned int> rrv;
+ PUSH_CTX();
+ zval *rv;
+
va_list ap;
va_start(ap, argspec);
- rv = call(fn, argspec, ap);
+ rv = call(fn, argspec, ap TSRMLS_CC);
va_end(ap);
if(rv)
@@ -1701,17 +1784,20 @@ map<long, unsigned int> php_stl::call_long_uint_map(char *fn, char *argspec, ...
zval_ptr_dtor(&rv);
}
+ POP_CTX();
return rrv;
}
hash_map<string, string> php_stl::call_string_string_hash_map(char *fn, char *argspec, ...)
{
- zval *rv;
hash_map<string, string> rrv;
+ PUSH_CTX();
+ zval *rv;
+
va_list ap;
va_start(ap, argspec);
- rv = call(fn, argspec, ap);
+ rv = call(fn, argspec, ap TSRMLS_CC);
va_end(ap);
if(rv)
@@ -1765,17 +1851,20 @@ hash_map<string, string> php_stl::call_string_string_hash_map(char *fn, char *ar
zval_ptr_dtor(&rv);
}
+ POP_CTX();
return rrv;
}
hash_map<string, double> php_stl::call_string_double_hash_map(char *fn, char *argspec, ...)
{
- zval *rv;
hash_map<string, double> rrv;
+ PUSH_CTX();
+ zval *rv;
+
va_list ap;
va_start(ap, argspec);
- rv = call(fn, argspec, ap);
+ rv = call(fn, argspec, ap TSRMLS_CC);
va_end(ap);
if(rv)
@@ -1829,17 +1918,20 @@ hash_map<string, double> php_stl::call_string_double_hash_map(char *fn, char *ar
zval_ptr_dtor(&rv);
}
+ POP_CTX();
return rrv;
}
hash_map<string, long> php_stl::call_string_long_hash_map(char *fn, char *argspec, ...)
{
- zval *rv;
hash_map<string, long> rrv;
+ PUSH_CTX();
+ zval *rv;
+
va_list ap;
va_start(ap, argspec);
- rv = call(fn, argspec, ap);
+ rv = call(fn, argspec, ap TSRMLS_CC);
va_end(ap);
if(rv)
@@ -1893,17 +1985,20 @@ hash_map<string, long> php_stl::call_string_long_hash_map(char *fn, char *argspe
zval_ptr_dtor(&rv);
}
+ POP_CTX();
return rrv;
}
hash_map<string, bool> php_stl::call_string_bool_hash_map(char *fn, char *argspec, ...)
{
- zval *rv;
hash_map<string, bool> rrv;
+ PUSH_CTX();
+ zval *rv;
+
va_list ap;
va_start(ap, argspec);
- rv = call(fn, argspec, ap);
+ rv = call(fn, argspec, ap TSRMLS_CC);
va_end(ap);
if(rv)
@@ -1957,18 +2052,21 @@ hash_map<string, bool> php_stl::call_string_bool_hash_map(char *fn, char *argspe
zval_ptr_dtor(&rv);
}
+ POP_CTX();
return rrv;
}
// NOTE: this just truncates the php long to and int!
hash_map<string, int> php_stl::call_string_int_hash_map(char *fn, char *argspec, ...)
{
- zval *rv;
hash_map<string, int> rrv;
+ PUSH_CTX();
+ zval *rv;
+
va_list ap;
va_start(ap, argspec);
- rv = call(fn, argspec, ap);
+ rv = call(fn, argspec, ap TSRMLS_CC);
va_end(ap);
if(rv)
@@ -2022,18 +2120,21 @@ hash_map<string, int> php_stl::call_string_int_hash_map(char *fn, char *argspec,
zval_ptr_dtor(&rv);
}
+ POP_CTX();
return rrv;
}
// NOTE: this just truncates the php long to and unsigned int!
hash_map<string, unsigned int> php_stl::call_string_uint_hash_map(char *fn, char *argspec, ...)
{
- zval *rv;
hash_map<string, unsigned int> rrv;
+ PUSH_CTX();
+ zval *rv;
+
va_list ap;
va_start(ap, argspec);
- rv = call(fn, argspec, ap);
+ rv = call(fn, argspec, ap TSRMLS_CC);
va_end(ap);
if(rv)
@@ -2087,17 +2188,20 @@ hash_map<string, unsigned int> php_stl::call_string_uint_hash_map(char *fn, char
zval_ptr_dtor(&rv);
}
+ POP_CTX();
return rrv;
}
hash_map<long, string> php_stl::call_long_string_hash_map(char *fn, char *argspec, ...)
{
- zval *rv;
hash_map<long, string> rrv;
+ PUSH_CTX();
+ zval *rv;
+
va_list ap;
va_start(ap, argspec);
- rv = call(fn, argspec, ap);
+ rv = call(fn, argspec, ap TSRMLS_CC);
va_end(ap);
if(rv)
@@ -2151,17 +2255,20 @@ hash_map<long, string> php_stl::call_long_string_hash_map(char *fn, char *argspe
zval_ptr_dtor(&rv);
}
+ POP_CTX();
return rrv;
}
hash_map<long, double> php_stl::call_long_double_hash_map(char *fn, char *argspec, ...)
{
- zval *rv;
hash_map<long, double> rrv;
+ PUSH_CTX();
+ zval *rv;
+
va_list ap;
va_start(ap, argspec);
- rv = call(fn, argspec, ap);
+ rv = call(fn, argspec, ap TSRMLS_CC);
va_end(ap);
if(rv)
@@ -2215,17 +2322,20 @@ hash_map<long, double> php_stl::call_long_double_hash_map(char *fn, char *argspe
zval_ptr_dtor(&rv);
}
+ POP_CTX();
return rrv;
}
hash_map<long, long> php_stl::call_long_long_hash_map(char *fn, char *argspec, ...)
{
- zval *rv;
hash_map<long, long> rrv;
+ PUSH_CTX();
+ zval *rv;
+
va_list ap;
va_start(ap, argspec);
- rv = call(fn, argspec, ap);
+ rv = call(fn, argspec, ap TSRMLS_CC);
va_end(ap);
if(rv)
@@ -2279,17 +2389,20 @@ hash_map<long, long> php_stl::call_long_long_hash_map(char *fn, char *argspec, .
zval_ptr_dtor(&rv);
}
+ POP_CTX();
return rrv;
}
hash_map<long, bool> php_stl::call_long_bool_hash_map(char *fn, char *argspec, ...)
{
- zval *rv;
hash_map<long, bool> rrv;
+ PUSH_CTX();
+ zval *rv;
+
va_list ap;
va_start(ap, argspec);
- rv = call(fn, argspec, ap);
+ rv = call(fn, argspec, ap TSRMLS_CC);
va_end(ap);
if(rv)
@@ -2343,18 +2456,21 @@ hash_map<long, bool> php_stl::call_long_bool_hash_map(char *fn, char *argspec, .
zval_ptr_dtor(&rv);
}
+ POP_CTX();
return rrv;
}
// NOTE: this just truncates the php long to and int!
hash_map<long, int> php_stl::call_long_int_hash_map(char *fn, char *argspec, ...)
{
- zval *rv;
hash_map<long, int> rrv;
+ PUSH_CTX();
+ zval *rv;
+
va_list ap;
va_start(ap, argspec);
- rv = call(fn, argspec, ap);
+ rv = call(fn, argspec, ap TSRMLS_CC);
va_end(ap);
if(rv)
@@ -2408,18 +2524,21 @@ hash_map<long, int> php_stl::call_long_int_hash_map(char *fn, char *argspec, ...
zval_ptr_dtor(&rv);
}
+ POP_CTX();
return rrv;
}
// NOTE: this just truncates the php long to and unsigned int!
hash_map<long, unsigned int> php_stl::call_long_uint_hash_map(char *fn, char *argspec, ...)
{
- zval *rv;
hash_map<long, unsigned int> rrv;
+ PUSH_CTX();
+ zval *rv;
+
va_list ap;
va_start(ap, argspec);
- rv = call(fn, argspec, ap);
+ rv = call(fn, argspec, ap TSRMLS_CC);
va_end(ap);
if(rv)
@@ -2473,6 +2592,7 @@ hash_map<long, unsigned int> php_stl::call_long_uint_hash_map(char *fn, char *ar
zval_ptr_dtor(&rv);
}
+ POP_CTX();
return rrv;
}
Please sign in to comment.
Something went wrong with that request. Please try again.