Comments (2)
Hello! I'm too lazy to create a pull request so I release my fix in open domain here:
diff --git a/protobuf.c b/protobuf.c
index 0bf18b5..21a8deb 100644
--- a/protobuf.c
+++ b/protobuf.c
@@ -58,7 +58,7 @@ enum
zend_class_entry *pb_entry;
-static int pb_assign_value(zval *this, zval *dst, zval *src, uint32_t field_number);
+static int pb_assign_value(zval *this, zval *dst, zval *src, uint32_t field_number TSRMLS_DC);
static int pb_print_field_value(zval **value, long level, zend_bool only_set);
static int pb_dump_field_value(zval **value, long level, zend_bool only_set);
static int pb_print_debug_field_value(zval **value, long level);
@@ -70,9 +70,9 @@ static int pb_get_wire_type(int field_type);
static const char *pb_get_wire_type_name(int wire_type);
static zval **pb_get_value(zval *this, zval **values, uint32_t field_number);
static zval **pb_get_values(zval *this);
-static int pb_parse_field_value(zval *this, reader_t *reader, long field_number, long field_type, zval *value);
+static int pb_parse_field_value(zval *this, reader_t *reader, long field_number, long field_type, zval *value TSRMLS_DC);
static int pb_serialize_field_value(zval *this, writer_t *writer, uint32_t field_number, zval **type, zval **value);
-static int pb_serialize_packed_field(zval *this, writer_t *writer, long field_number, long field_type, zval *values);
+static int pb_serialize_packed_field(zval *this, writer_t *writer, long field_number, long field_type, zval *values TSRMLS_DC);
static ulong PB_FIELD_TYPE_HASH;
static ulong PB_VALUES_PROPERTY_HASH;
@@ -106,7 +106,7 @@ PHP_METHOD(ProtobufMessage, append)
RETURN_THIS();
MAKE_STD_ZVAL(val);
- if (pb_assign_value(getThis(), val, value, field_number) != 0) {
+ if (pb_assign_value(getThis(), val, value, field_number TSRMLS_CC) != 0) {
zval_ptr_dtor(&val);
RETURN_THIS();
}
@@ -462,7 +462,7 @@ PHP_METHOD(ProtobufMessage, parseFromString)
ALLOC_INIT_ZVAL(value);
add_next_index_zval(*old_value, value);
}
- if (pb_parse_field_value(getThis(), &packed_reader, field_number, Z_LVAL_PP(field_type), value) != 0) {
+ if (pb_parse_field_value(getThis(), &packed_reader, field_number, Z_LVAL_PP(field_type), value TSRMLS_CC) != 0) {
return;
}
value = NULL;
@@ -473,7 +473,7 @@ PHP_METHOD(ProtobufMessage, parseFromString)
return;
}
- if (pb_parse_field_value(getThis(), &reader, field_number, Z_LVAL_PP(field_type), value) != 0) {
+ if (pb_parse_field_value(getThis(), &reader, field_number, Z_LVAL_PP(field_type), value TSRMLS_CC) != 0) {
return;
}
}
@@ -532,7 +532,7 @@ PHP_METHOD(ProtobufMessage, serializeToString)
array = value;
if (zend_hash_find(Z_ARRVAL_PP(field_descriptor), PB_FIELD_PACKED, sizeof(PB_FIELD_PACKED), (void **) &packed) != FAILURE && Z_BVAL_PP(packed)) {
- if (pb_serialize_packed_field(getThis(), &writer, field_number, Z_LVAL_PP(type), *array) != 0)
+ if (pb_serialize_packed_field(getThis(), &writer, field_number, Z_LVAL_PP(type), *array TSRMLS_CC) != 0)
goto fail;
} else {
PB_FOREACH(&j, Z_ARRVAL_PP(array)) {
@@ -577,7 +577,7 @@ PHP_METHOD(ProtobufMessage, set)
}
} else {
zval_dtor(*old_value);
- pb_assign_value(getThis(), *old_value, value, field_number);
+ pb_assign_value(getThis(), *old_value, value, field_number TSRMLS_CC);
}
RETURN_THIS();
@@ -685,10 +685,9 @@ zend_module_entry protobuf_module_entry = {
ZEND_GET_MODULE(protobuf)
#endif
-static int pb_assign_value(zval *this, zval *dst, zval *src, uint32_t field_number)
+static int pb_assign_value(zval *this, zval *dst, zval *src, uint32_t field_number TSRMLS_DC)
{
zval **field_descriptor, *field_descriptors, tmp, **type;
- TSRMLS_FETCH();
if ((field_descriptors = pb_get_field_descriptors(this)) == NULL)
goto fail0;
@@ -988,7 +987,7 @@ static zval **pb_get_values(zval *this)
return values;
}
-static int pb_parse_field_value(zval *this, reader_t *reader, long field_number, long field_type, zval *value)
+static int pb_parse_field_value(zval *this, reader_t *reader, long field_number, long field_type, zval *value TSRMLS_DC)
{
int ret, str_size;
char *str;
@@ -1115,7 +1114,7 @@ static int pb_serialize_field_value(zval *this, writer_t *writer, uint32_t field
return 0;
}
-static int pb_serialize_packed_field(zval *this, writer_t *writer, long field_number, long field_type, zval *values)
+static int pb_serialize_packed_field(zval *this, writer_t *writer, long field_number, long field_type, zval *values TSRMLS_DC)
{
int ret = 0;
@@ -1152,4 +1151,4 @@ static int pb_serialize_packed_field(zval *this, writer_t *writer, long field_nu
}
return ret;
-}
\ No newline at end of file
+}
Point is: to support ZTS you have to add to related functions:
- to function prototypes:
TSRMLS_DC
(orTSRMLS_D
if you don't want it to pretend a comma to the function's argument - to function calls:
TSRMLS_CC
(orTSRMLS_C
likewise)
There's also a #ifdef ZTS
thing that I didn't really try to fiddle with. The changes above were enough to build the package pragmatically and I'll see what happens when running the lib. :B
This blog post helped me understand an actual application of the ZTS rules to an extension: STILL TRYING TO GET IT ALL OUT - What the heck is TSRMLS_CC, anyway? from -- what? -- 2006. :)
I'd better leave this open until someone merges the changes to the code, right? :)
from php-protobuf.
This seems to be the best documentation (linked from libgeos/geos#9) on how to handle this issue. But as I am not really experienced in building and developing PHP extensions, and I also not familiar to the php-protobuf source code, it might take a lot to me to figure out & fix where it hurts, but may be just easy for someone acquainted with the project. :)
from php-protobuf.
Related Issues (20)
- How to generate the CodeGeneratorResponse.php file? HOT 2
- How to define namespace using protoc?
- Error while installation, step 3 Build and install the PHP extension. HOT 2
- ERROR: The protoc command in your system is too old. Minimum required version is 2.6.0 but found 2.5.0 HOT 1
- Does this extension have a Windows version HOT 1
- make: *** [protobuf.lo] Error 1 HOT 7
- 64-bit integers on x86 HOT 2
- Can it be encoded as a binary stream? HOT 1
- Why change null to another value? HOT 4
- read Protocol Buffers delimited HOT 2
- ERROR: Unable to find the protoc command. Please make sure it's installed and available in the path. HOT 1
- ERROR: protobuf module is not installed. --allegrophp_out: protoc-gen-allegrophp: Plugin failed with status code 1. HOT 5
- Does php-protobuf support extend HOT 1
- Add support for extensions
- --allegrophp_out: protoc-gen-allegrophp: Plugin failed with status code 127. HOT 10
- How do we send request and receive response with this? HOT 1
- Can't be compiled for > PHP 7 on Windows 7 x64 HOT 4
- one question --php_out: protoc-gen-php: Plugin output is unparseable: This is a stub file for IDEs, don't use it directly! HOT 1
- php8.0 编译不成功 HOT 1
- Macbook m1 chip php5.6.31 wrong HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from php-protobuf.