aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--.travis.yml2
-rw-r--r--php/ext/google/protobuf/array.c8
-rw-r--r--php/ext/google/protobuf/def.c3
-rw-r--r--php/ext/google/protobuf/encode_decode.c6
-rw-r--r--php/ext/google/protobuf/map.c11
-rw-r--r--php/ext/google/protobuf/protobuf.c12
-rw-r--r--php/ext/google/protobuf/protobuf.h9
-rw-r--r--php/ext/google/protobuf/storage.c11
-rw-r--r--php/ext/google/protobuf/utf8.c2
-rwxr-xr-xphp/tests/test.sh5
-rwxr-xr-xtests.sh25
11 files changed, 55 insertions, 39 deletions
diff --git a/.travis.yml b/.travis.yml
index edbf642a..bd9a5dfb 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -31,7 +31,7 @@ env:
- CONFIG=ruby21
- CONFIG=ruby22
- CONFIG=jruby
- - CONFIG=php5.5_mac
+ - CONFIG=php5.6_mac
matrix:
exclude:
# It's nontrivial to programmatically install a new JDK from the command
diff --git a/php/ext/google/protobuf/array.c b/php/ext/google/protobuf/array.c
index c24ede81..215dcd46 100644
--- a/php/ext/google/protobuf/array.c
+++ b/php/ext/google/protobuf/array.c
@@ -169,7 +169,7 @@ static void repeated_field_write_dimension(zval *object, zval *offset,
} else {
if (protobuf_convert_to_uint64(offset, &index)) {
if (!zend_hash_index_exists(ht, index)) {
- zend_error(E_USER_ERROR, "Element at %d doesn't exist.\n", index);
+ zend_error(E_USER_ERROR, "Element at %llu doesn't exist.\n", index);
return;
}
} else {
@@ -222,7 +222,7 @@ void repeated_field_create_with_type(zend_class_entry *ce,
zend_object_store_get_object(*repeated_field TSRMLS_CC);
intern->type = upb_fielddef_type(field);
if (intern->type == UPB_TYPE_MESSAGE) {
- upb_msgdef *msg = upb_fielddef_msgsubdef(field);
+ const upb_msgdef *msg = upb_fielddef_msgsubdef(field);
zval *desc_php = get_def_obj(msg);
Descriptor *desc = zend_object_store_get_object(desc_php TSRMLS_CC);
intern->msg_ce = desc->klass;
@@ -321,7 +321,7 @@ PHP_METHOD(RepeatedField, offsetGet) {
HashTable *table = HASH_OF(intern->array);
if (zend_hash_index_find(table, index, (void **)&memory) == FAILURE) {
- zend_error(E_USER_ERROR, "Element at %d doesn't exist.\n", index);
+ zend_error(E_USER_ERROR, "Element at %ld doesn't exist.\n", index);
return;
}
@@ -365,7 +365,7 @@ PHP_METHOD(RepeatedField, offsetUnset) {
// Only the element at the end of the array can be removed.
if (index == -1 ||
index != (zend_hash_num_elements(HASH_OF(intern->array)) - 1)) {
- zend_error(E_USER_ERROR, "Cannot remove element at %d.\n", index);
+ zend_error(E_USER_ERROR, "Cannot remove element at %ld.\n", index);
return;
}
diff --git a/php/ext/google/protobuf/def.c b/php/ext/google/protobuf/def.c
index cbd0ec62..156eca07 100644
--- a/php/ext/google/protobuf/def.c
+++ b/php/ext/google/protobuf/def.c
@@ -318,7 +318,8 @@ PHP_METHOD(DescriptorPool, internalAddGeneratedFile) {
add_def_obj(desc->def_type_lower, desc_php); \
/* Unlike other messages, MapEntry is shared by all map fields and doesn't \
* have generated PHP class.*/ \
- if (upb_def_type(def) == UPB_DEF_MSG && upb_msgdef_mapentry(def)) { \
+ if (upb_def_type(def) == UPB_DEF_MSG && \
+ upb_msgdef_mapentry(upb_downcast_msgdef(def))) { \
break; \
} \
/* Prepend '.' to package name to make it absolute. */ \
diff --git a/php/ext/google/protobuf/encode_decode.c b/php/ext/google/protobuf/encode_decode.c
index b45d1b2a..eafe1ae8 100644
--- a/php/ext/google/protobuf/encode_decode.c
+++ b/php/ext/google/protobuf/encode_decode.c
@@ -29,6 +29,7 @@
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include "protobuf.h"
+#include "utf8.h"
/* stringsink *****************************************************************/
@@ -416,7 +417,8 @@ static void map_slot_uninit(void* memory, upb_fieldtype_t type) {
}
}
-static void map_slot_key(upb_fieldtype_t type, const void* from, char** keyval,
+static void map_slot_key(upb_fieldtype_t type, const void* from,
+ const char** keyval,
size_t* length) {
if (type == UPB_TYPE_STRING) {
zval* key_php = **(zval***)from;
@@ -891,7 +893,7 @@ static upb_selector_t getsel(const upb_fielddef* f, upb_handlertype_t type) {
return ret;
}
-static void put_optional_value(void* memory, int len, const upb_fielddef* f,
+static void put_optional_value(const void* memory, int len, const upb_fielddef* f,
int depth, upb_sink* sink TSRMLS_DC) {
assert(upb_fielddef_label(f) == UPB_LABEL_OPTIONAL);
diff --git a/php/ext/google/protobuf/map.c b/php/ext/google/protobuf/map.c
index 6a80d978..35747b05 100644
--- a/php/ext/google/protobuf/map.c
+++ b/php/ext/google/protobuf/map.c
@@ -33,6 +33,7 @@
#include <Zend/zend_interfaces.h>
#include "protobuf.h"
+#include "utf8.h"
ZEND_BEGIN_ARG_INFO_EX(arginfo_offsetGet, 0, 0, 1)
ZEND_ARG_INFO(0, index)
@@ -152,7 +153,7 @@ static zend_function_entry map_field_methods[] = {
zend_class_entry* map_field_type;
zend_object_handlers* map_field_handlers;
-static map_begin_internal(Map *map, MapIter *iter) {
+static void map_begin_internal(Map *map, MapIter *iter) {
iter->self = map;
upb_strtable_begin(&iter->it, &map->table);
}
@@ -258,8 +259,8 @@ static void map_field_free_element(void *object) {
// MapField Handlers
// -----------------------------------------------------------------------------
-static bool *map_field_read_dimension(zval *object, zval *key, int type,
- zval **retval TSRMLS_DC) {
+static bool map_field_read_dimension(zval *object, zval *key, int type,
+ zval **retval TSRMLS_DC) {
Map *intern =
(Map *)zend_object_store_get_object(object TSRMLS_CC);
@@ -398,7 +399,7 @@ PHP_METHOD(MapField, offsetExists) {
v.ctype = UPB_CTYPE_UINT64;
#endif
if (!table_key(intern, key, keybuf, &keyval, &length TSRMLS_CC)) {
- return false;
+ RETURN_BOOL(false);
}
RETURN_BOOL(upb_strtable_lookup2(&intern->table, keyval, length, &v));
@@ -434,7 +435,7 @@ PHP_METHOD(MapField, offsetUnset) {
PHP_METHOD(MapField, count) {
Map *intern =
- (MapField *)zend_object_store_get_object(getThis() TSRMLS_CC);
+ (Map *)zend_object_store_get_object(getThis() TSRMLS_CC);
if (zend_parse_parameters_none() == FAILURE) {
return;
diff --git a/php/ext/google/protobuf/protobuf.c b/php/ext/google/protobuf/protobuf.c
index d8ad3c88..019bca29 100644
--- a/php/ext/google/protobuf/protobuf.c
+++ b/php/ext/google/protobuf/protobuf.c
@@ -55,7 +55,7 @@ static void add_to_table(HashTable* t, const void* def, void* value) {
uint nIndex = (ulong)def & t->nTableMask;
zval* pDest = NULL;
- zend_hash_index_update(t, (zend_ulong)def, &value, sizeof(zval*), &pDest);
+ zend_hash_index_update(t, (zend_ulong)def, &value, sizeof(zval*), (void**)&pDest);
}
static void* get_from_table(const HashTable* t, const void* def) {
@@ -69,7 +69,7 @@ static void* get_from_table(const HashTable* t, const void* def) {
static void add_to_list(HashTable* t, void* value) {
zval* pDest = NULL;
- zend_hash_next_index_insert(t, &value, sizeof(void*), &pDest);
+ zend_hash_next_index_insert(t, &value, sizeof(void*), (void**)&pDest);
}
void add_def_obj(const void* def, zval* value) {
@@ -134,6 +134,8 @@ static PHP_RINIT_FUNCTION(protobuf) {
generated_pool = NULL;
generated_pool_php = NULL;
+
+ return 0;
}
static PHP_RSHUTDOWN_FUNCTION(protobuf) {
@@ -147,6 +149,8 @@ static PHP_RSHUTDOWN_FUNCTION(protobuf) {
zval_dtor(generated_pool_php);
FREE_ZVAL(generated_pool_php);
}
+
+ return 0;
}
static PHP_MINIT_FUNCTION(protobuf) {
@@ -158,10 +162,14 @@ static PHP_MINIT_FUNCTION(protobuf) {
descriptor_init(TSRMLS_C);
enum_descriptor_init(TSRMLS_C);
util_init(TSRMLS_C);
+
+ return 0;
}
static PHP_MSHUTDOWN_FUNCTION(protobuf) {
PEFREE(message_handlers);
PEFREE(repeated_field_handlers);
PEFREE(map_field_handlers);
+
+ return 0;
}
diff --git a/php/ext/google/protobuf/protobuf.h b/php/ext/google/protobuf/protobuf.h
index 5edb15db..8a1d9261 100644
--- a/php/ext/google/protobuf/protobuf.h
+++ b/php/ext/google/protobuf/protobuf.h
@@ -70,14 +70,6 @@ typedef struct MapField MapField;
ZEND_BEGIN_MODULE_GLOBALS(protobuf)
ZEND_END_MODULE_GLOBALS(protobuf)
-ZEND_DECLARE_MODULE_GLOBALS(protobuf)
-
-#ifdef ZTS
-#define PROTOBUF_G(v) TSRMG(protobuf_globals_id, zend_protobuf_globals*, v)
-#else
-#define PROTOBUF_G(v) (protobuf_globals.v)
-#endif
-
// Init module and PHP classes.
void descriptor_init(TSRMLS_D);
void enum_descriptor_init(TSRMLS_D);
@@ -347,6 +339,7 @@ void* upb_value_memory(upb_value* v);
// These operate on a map field (i.e., a repeated field of submessages whose
// submessage type is a map-entry msgdef).
+bool is_map_field(const upb_fielddef* field);
const upb_fielddef* map_field_key(const upb_fielddef* field);
const upb_fielddef* map_field_value(const upb_fielddef* field);
diff --git a/php/ext/google/protobuf/storage.c b/php/ext/google/protobuf/storage.c
index 56497f62..e94aa319 100644
--- a/php/ext/google/protobuf/storage.c
+++ b/php/ext/google/protobuf/storage.c
@@ -32,6 +32,8 @@
#include <protobuf.h>
#include <Zend/zend.h>
+#include "utf8.h"
+
// -----------------------------------------------------------------------------
// Native slot storage.
// -----------------------------------------------------------------------------
@@ -210,7 +212,7 @@ CASE(ENUM, LONG, uint32_t)
return;
}
default:
- return EG(uninitialized_zval_ptr);
+ return;
}
}
@@ -245,7 +247,7 @@ void native_slot_get_default(upb_fieldtype_t type, zval** cache TSRMLS_DC) {
return;
}
default:
- return EG(uninitialized_zval_ptr);
+ return;
}
}
@@ -305,6 +307,7 @@ const zend_class_entry* field_type_class(const upb_fielddef* field TSRMLS_DC) {
EnumDescriptor* desc = zend_object_store_get_object(desc_php TSRMLS_CC);
return desc->klass;
}
+ return NULL;
}
// -----------------------------------------------------------------------------
@@ -517,7 +520,7 @@ void layout_set(MessageLayout* layout, MessageHeader* header,
// zval in properties table first.
switch (type) {
case UPB_TYPE_MESSAGE: {
- upb_msgdef* msg = upb_fielddef_msgsubdef(field);
+ const upb_msgdef* msg = upb_fielddef_msgsubdef(field);
zval* desc_php = get_def_obj(msg);
Descriptor* desc = zend_object_store_get_object(desc_php TSRMLS_CC);
ce = desc->klass;
@@ -551,7 +554,7 @@ void layout_set(MessageLayout* layout, MessageHeader* header,
upb_fieldtype_t type = upb_fielddef_type(field);
zend_class_entry *ce = NULL;
if (type == UPB_TYPE_MESSAGE) {
- upb_msgdef* msg = upb_fielddef_msgsubdef(field);
+ const upb_msgdef* msg = upb_fielddef_msgsubdef(field);
zval* desc_php = get_def_obj(msg);
Descriptor* desc = zend_object_store_get_object(desc_php TSRMLS_CC);
ce = desc->klass;
diff --git a/php/ext/google/protobuf/utf8.c b/php/ext/google/protobuf/utf8.c
index a1541636..2752a08b 100644
--- a/php/ext/google/protobuf/utf8.c
+++ b/php/ext/google/protobuf/utf8.c
@@ -58,7 +58,7 @@ bool is_structurally_valid_utf8(const char* buf, int len) {
return false;
}
for (j = i + 1; j < i + offset; j++) {
- if (buf[j] & 0xc0 != 0x80) {
+ if ((buf[j] & 0xc0) != 0x80) {
return false;
}
}
diff --git a/php/tests/test.sh b/php/tests/test.sh
index 15df768c..888e93eb 100755
--- a/php/tests/test.sh
+++ b/php/tests/test.sh
@@ -24,9 +24,4 @@ done
# Make sure to run the memory test in debug mode.
php -dextension=../ext/google/protobuf/modules/protobuf.so memory_leak_test.php
-php --version
-which php
-pwd
-ls
-ls -l `which php`
USE_ZEND_ALLOC=0 valgrind --leak-check=yes php -dextension=../ext/google/protobuf/modules/protobuf.so memory_leak_test.php
diff --git a/tests.sh b/tests.sh
index 5823bff5..a497f1d2 100755
--- a/tests.sh
+++ b/tests.sh
@@ -369,12 +369,6 @@ build_php5.5_c() {
cd php/tests && /bin/bash ./test.sh && cd ../..
}
-build_php5.5_mac() {
- curl -s https://php-osx.liip.ch/install.sh | bash -s 5.5
- export PATH="/usr/local/php5-5.5.38-20160831-100002/bin:$PATH"
- cd php/tests && /bin/bash ./test.sh && cd ../..
-}
-
build_php5.5_zts_c() {
use_php_zts 5.5
wget https://phar.phpunit.de/phpunit-old.phar -O /usr/bin/phpunit
@@ -393,6 +387,25 @@ build_php5.6_c() {
cd php/tests && /bin/bash ./test.sh && cd ../..
}
+build_php5.6_mac() {
+ # Install PHP
+ curl -s https://php-osx.liip.ch/install.sh | bash -s 5.6
+ export PATH="/usr/local/php5-5.6.25-20160831-101628/bin:$PATH"
+
+ # Install phpunit
+ curl https://phar.phpunit.de/phpunit.phar -L -o phpunit.phar
+ chmod +x phpunit.phar
+ sudo mv phpunit.phar /usr/local/bin/phpunit
+
+ # Install valgrind
+ echo "#! /bin/bash" > valgrind
+ chmod ug+x valgrind
+ sudo mv valgrind /usr/local/bin/valgrind
+
+ # Test
+ cd php/tests && /bin/bash ./test.sh && cd ../..
+}
+
build_php7.0() {
use_php 7.0
rm -rf vendor