Skip to content

Commit 99ac181

Browse files
https://github.com/php/php-src/pull/10597
1 parent 035163f commit 99ac181

File tree

5 files changed

+30
-30
lines changed

5 files changed

+30
-30
lines changed

src/php7/hash_ptr.h

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
| Author: Oleg Grenrus <[email protected]> |
66
| See CREDITS for contributors |
77
| This defines hash_si_ptr. |
8-
| It is like hash_si, but the key is always a non-zero zend_uintptr_t |
8+
| It is like hash_si, but the key is always a non-zero uintptr_t |
99
+----------------------------------------------------------------------+
1010
*/
1111

@@ -31,12 +31,12 @@
3131
* @see hash_si_ptr
3232
*/
3333
struct hash_si_ptr_pair {
34-
zend_uintptr_t key; /**< The key: The address of a pointer, casted to an int (won't be dereferenced). */
34+
uintptr_t key; /**< The key: The address of a pointer, casted to an int (won't be dereferenced). */
3535
uint32_t value; /**< Value. */
3636
};
3737

3838
/** Hash-array.
39-
* Like c++ std::unordered_map<zend_uintptr_t, int32_t>, but does not allow HASH_PTR_KEY_INVALID as a key.
39+
* Like c++ std::unordered_map<uintptr_t, int32_t>, but does not allow HASH_PTR_KEY_INVALID as a key.
4040
* Current implementation uses linear probing.
4141
* @author Oleg Grenrus <[email protected]>
4242
*/
@@ -67,7 +67,7 @@ void hash_si_ptr_deinit(struct hash_si_ptr *h);
6767
* @return 0 on success, 1 or 2 else.
6868
*/
6969
/*
70-
int hash_si_ptr_insert (struct hash_si_ptr *h, const zend_uintptr_t key, uint32_t value);
70+
int hash_si_ptr_insert (struct hash_si_ptr *h, const uintptr_t key, uint32_t value);
7171
*/
7272

7373
/** Finds value from hash_si_ptr.
@@ -79,7 +79,7 @@ int hash_si_ptr_insert (struct hash_si_ptr *h, const zend_uintptr_t key, uint32_
7979
* @return 0 if found, 1 if not.
8080
*/
8181
/*
82-
int hash_si_ptr_find (struct hash_si_ptr *h, const zend_uintptr_t key, uint32_t * value);
82+
int hash_si_ptr_find (struct hash_si_ptr *h, const uintptr_t key, uint32_t * value);
8383
*/
8484

8585
/** Returns size of hash_si_ptr.
@@ -99,7 +99,7 @@ static zend_always_inline size_t hash_si_ptr_size(struct hash_si_ptr *h) {
9999
*
100100
* @return SIZE_MAX or old, unmodified key
101101
*/
102-
size_t hash_si_ptr_find_or_insert(struct hash_si_ptr *h, const zend_uintptr_t key, uint32_t value);
102+
size_t hash_si_ptr_find_or_insert(struct hash_si_ptr *h, const uintptr_t key, uint32_t value);
103103

104104
/** Returns capacity of hash_si_ptr.
105105
* @param h Pointer to hash_si_ptr struct.

src/php7/hash_si_ptr.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
#include "igbinary_bswap.h"
2323

2424
/* This assumes that pointers differ in low addresses rather than high addresses */
25-
inline static uint32_t inline_hash_of_address(zend_uintptr_t ptr) {
25+
inline static uint32_t inline_hash_of_address(uintptr_t ptr) {
2626
#if UINTPTR_MAX > UINT32_MAX
2727
uint64_t hash = ptr;
2828
hash *= 0x5e2d58d8b3bce8d9;
@@ -130,7 +130,7 @@ inline static void hash_si_ptr_rehash(struct hash_si_ptr *h) {
130130
* @param value - If the key does not exist, this is the value to associate with key
131131
* @return the old value, or SIZE_MAX if the key is brand new.
132132
*/
133-
size_t hash_si_ptr_find_or_insert(struct hash_si_ptr *h, const zend_uintptr_t key, uint32_t value) {
133+
size_t hash_si_ptr_find_or_insert(struct hash_si_ptr *h, const uintptr_t key, uint32_t value) {
134134
size_t size;
135135
size_t mask;
136136
uint32_t hv;

src/php7/igbinary.c

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -246,7 +246,7 @@ struct deferred_call {
246246
#endif
247247
} data;
248248
#if PHP_VERSION_ID >= 70400
249-
zend_bool is_unserialize;
249+
bool is_unserialize;
250250
#endif
251251
};
252252
/** Unserializer data.
@@ -268,7 +268,7 @@ struct igbinary_unserialize_data {
268268
struct deferred_call *deferred; /**< objects&data for calls to __unserialize/__wakeup */
269269
size_t deferred_capacity; /**< capacity of objects in array for calls to __unserialize/__wakeup */
270270
uint32_t deferred_count; /**< count of objects in array for calls to __unserialize/__wakeup. NOTE: Current php releases including 8.1 limit the total number of objects to a 32-bit integer. */
271-
zend_bool deferred_finished; /**< whether the deferred calls were performed */
271+
bool deferred_finished; /**< whether the deferred calls were performed */
272272
struct deferred_dtor_tracker deferred_dtor_tracker; /**< refcounted objects and arrays to call dtor on after unserializing. See i_zval_ptr_dtor */
273273
#if PHP_VERSION_ID >= 70400
274274
HashTable *ref_props; /**< objects&data for calls to __unserialize/__wakeup */
@@ -324,9 +324,9 @@ zend_always_inline static uint64_t igbinary_unserialize64(struct igbinary_unseri
324324
zend_always_inline static int igbinary_unserialize_long(struct igbinary_unserialize_data *igsd, enum igbinary_type t, zend_long *ret);
325325
zend_always_inline static int igbinary_unserialize_double(struct igbinary_unserialize_data *igsd, double *ret);
326326
zend_always_inline static zend_string *igbinary_unserialize_string(struct igbinary_unserialize_data *igsd, enum igbinary_type t);
327-
zend_always_inline static zend_string *igbinary_unserialize_chararray(struct igbinary_unserialize_data *igsd, enum igbinary_type t, zend_bool check_interned);
327+
zend_always_inline static zend_string *igbinary_unserialize_chararray(struct igbinary_unserialize_data *igsd, enum igbinary_type t, bool check_interned);
328328

329-
zend_always_inline static int igbinary_unserialize_array(struct igbinary_unserialize_data *igsd, enum igbinary_type t, zval *const z, int flags, zend_bool create_ref);
329+
zend_always_inline static int igbinary_unserialize_array(struct igbinary_unserialize_data *igsd, enum igbinary_type t, zval *const z, int flags, bool create_ref);
330330
zend_always_inline static int igbinary_unserialize_object(struct igbinary_unserialize_data *igsd, enum igbinary_type t, zval *const z, int flags);
331331
static int igbinary_unserialize_object_ser(struct igbinary_unserialize_data *igsd, enum igbinary_type t, zval *const z, zend_class_entry *ce);
332332

@@ -548,7 +548,7 @@ static int igbinary_finish_deferred_calls(struct igbinary_unserialize_data *igsd
548548
uint32_t i;
549549
struct deferred_call *deferred_arr;
550550
uint32_t deferred_count = igsd->deferred_count;
551-
zend_bool delayed_call_failed = 0;
551+
bool delayed_call_failed = 0;
552552
igsd->deferred_finished = 1;
553553
if (deferred_count == 0) { /* nothing to do */
554554
return 0;
@@ -1494,28 +1494,28 @@ inline static int igbinary_serialize_array(struct igbinary_serialize_data *igsd,
14941494
/* TODO: Use different result codes for missing keys and errors */
14951495
zend_always_inline static int igbinary_serialize_array_ref(struct igbinary_serialize_data *igsd, zval * const z, bool object) {
14961496
size_t t;
1497-
zend_uintptr_t key; /* The address of the pointer to the zend_refcounted struct or other struct */
1497+
uintptr_t key; /* The address of the pointer to the zend_refcounted struct or other struct */
14981498
static int INVALID_KEY; /* Not used, but we take the pointer of this knowing other zvals won't share it*/
14991499

15001500
/* Similar to php_var_serialize_intern's first part, as well as php_add_var_hash, for printing R: (reference) or r:(object) */
15011501
/* However, it differs from the built in serialize() in that references to objects are preserved when serializing and unserializing? (TODO check, test for backwards compatibility) */
15021502

15031503
ZEND_ASSERT(Z_ISREF_P(z) || (object && Z_TYPE_P(z) == IS_OBJECT) || Z_TYPE_P(z) == IS_ARRAY);
1504-
// zend_bool is_ref = Z_ISREF_P(z);
1504+
// bool is_ref = Z_ISREF_P(z);
15051505
/* Do I have to dereference object references so that reference ids will be the same as in php5? */
15061506
/* If I do, then more tests fail. */
15071507
/* is_ref || IS_OBJECT implies it has a unique refcounted struct */
15081508
// NOTE: The original code would always use the same memory address - Z_COUNTED_P is the start of an object/array/reference
15091509
// if (object && Z_TYPE_P(z) == IS_OBJECT) {
1510-
// key = (zend_uintptr_t)Z_OBJ_P(z); /* expand object handle(uint32_t), cast to 32-bit/64-bit pointer */
1510+
// key = (uintptr_t)Z_OBJ_P(z); /* expand object handle(uint32_t), cast to 32-bit/64-bit pointer */
15111511
// } else if (is_ref) {
15121512
// /* NOTE: PHP switched from `zval*` to `zval` for the values stored in HashTables.
15131513
// * If an array has two references to the same ZVAL, then those references will have different zvals.
15141514
// * We use Z_COUNTED_P(ref), which will be the same if (and only if) the references are the same. */
15151515
// /* is_ref implies there is a unique reference counting pointer for the reference */
1516-
// key = (zend_uintptr_t)Z_COUNTED_P(z);
1516+
// key = (uintptr_t)Z_COUNTED_P(z);
15171517
// } else if (EXPECTED(Z_TYPE_P(z) == IS_ARRAY)) {
1518-
// key = (zend_uintptr_t)Z_ARR_P(z);
1518+
// key = (uintptr_t)Z_ARR_P(z);
15191519
// } else {
15201520
// /* Nothing else is going to reference this when this is serialized, this isn't ref counted or an object, shouldn't be reached. */
15211521
// /* Increment the reference id for the deserializer, give up. */
@@ -1528,9 +1528,9 @@ zend_always_inline static int igbinary_serialize_array_ref(struct igbinary_seria
15281528
/* because that's the way it was serialized in php5. */
15291529
/* Does this work with different forms of recursive arrays? */
15301530
if (igsd->references_id == 0 && !object) {
1531-
key = (zend_uintptr_t)&INVALID_KEY;
1531+
key = (uintptr_t)&INVALID_KEY;
15321532
} else {
1533-
key = (zend_uintptr_t)z->value.ptr;
1533+
key = (uintptr_t)z->value.ptr;
15341534
}
15351535

15361536
t = hash_si_ptr_find_or_insert(&igsd->references, key, igsd->references_id);
@@ -2407,7 +2407,7 @@ static ZEND_COLD zend_never_inline zend_string* igbinary_unserialize_extremely_l
24072407
/* }}} */
24082408
/* {{{ igbinary_unserialize_chararray */
24092409
/** Unserializes chararray of string. Returns NULL on error. */
2410-
inline static zend_string *igbinary_unserialize_chararray(struct igbinary_unserialize_data *igsd, enum igbinary_type t, zend_bool check_interned) {
2410+
inline static zend_string *igbinary_unserialize_chararray(struct igbinary_unserialize_data *igsd, enum igbinary_type t, bool check_interned) {
24112411
size_t l;
24122412
zend_string *zstr;
24132413

@@ -2490,7 +2490,7 @@ inline static zend_string *igbinary_unserialize_chararray(struct igbinary_unseri
24902490
/* }}} */
24912491
/* {{{ igbinary_unserialize_array */
24922492
/** Unserializes a PHP array. */
2493-
zend_always_inline static int igbinary_unserialize_array(struct igbinary_unserialize_data *igsd, enum igbinary_type t, zval *const z, int flags, zend_bool create_ref) {
2493+
zend_always_inline static int igbinary_unserialize_array(struct igbinary_unserialize_data *igsd, enum igbinary_type t, zval *const z, int flags, bool create_ref) {
24942494
/* WANT_REF means that z will be wrapped by an IS_REFERENCE */
24952495
uint32_t n;
24962496
uint32_t i;
@@ -2708,7 +2708,7 @@ inline static int igbinary_unserialize_object_properties(struct igbinary_unseria
27082708
zval *z_deref;
27092709

27102710
HashTable *h;
2711-
zend_bool did_extend;
2711+
bool did_extend;
27122712

27132713
if (t == igbinary_type_array8) {
27142714
if (IGB_NEEDS_MORE_DATA(igsd, 1)) {
@@ -2845,7 +2845,7 @@ inline static int igbinary_unserialize_object_properties(struct igbinary_unseria
28452845
if (igsd->ref_props) {
28462846
/* Remove old entry from ref_props table, if it exists. */
28472847
zend_hash_index_del(
2848-
igsd->ref_props, ((zend_uintptr_t) prototype_value) >> ZEND_MM_ALIGNMENT_LOG2);
2848+
igsd->ref_props, ((uintptr_t) prototype_value) >> ZEND_MM_ALIGNMENT_LOG2);
28492849
}
28502850
}
28512851
#endif
@@ -2927,7 +2927,7 @@ inline static int igbinary_unserialize_object_properties(struct igbinary_unseria
29272927
zend_hash_init(igsd->ref_props, 8, NULL, NULL, 0);
29282928
}
29292929
zend_hash_index_update_ptr(
2930-
igsd->ref_props, ((zend_uintptr_t) vp) >> ZEND_MM_ALIGNMENT_LOG2, info);
2930+
igsd->ref_props, ((uintptr_t) vp) >> ZEND_MM_ALIGNMENT_LOG2, info);
29312931
}
29322932
}
29332933
#endif
@@ -3459,7 +3459,7 @@ static int igbinary_unserialize_zval(struct igbinary_unserialize_data *igsd, zva
34593459
#if PHP_VERSION_ID >= 70400
34603460
zend_property_info *info = NULL;
34613461
if (igsd->ref_props) {
3462-
info = zend_hash_index_find_ptr(igsd->ref_props, ((zend_uintptr_t) z) >> ZEND_MM_ALIGNMENT_LOG2);
3462+
info = zend_hash_index_find_ptr(igsd->ref_props, ((uintptr_t) z) >> ZEND_MM_ALIGNMENT_LOG2);
34633463
}
34643464
#endif
34653465
ZVAL_NEW_REF(z, z);

src/php7/igbinary_zend_hash.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -63,14 +63,14 @@ static zend_always_inline zval *igbinary_zend_hash_index_add_or_find(HashTable *
6363
# define zend_hash_real_init_packed(ht) zend_hash_real_init((ht), 1)
6464
# define HT_SIZE_TO_MASK(size) (-(size))
6565
# define HT_FLAGS(ht) ((ht)->u.flags)
66-
static zend_always_inline zend_bool zend_string_equal_content(zend_string *s1, zend_string *s2)
66+
static zend_always_inline bool zend_string_equal_content(zend_string *s1, zend_string *s2)
6767
{
6868
return ZSTR_LEN(s1) == ZSTR_LEN(s2) && !memcmp(ZSTR_VAL(s1), ZSTR_VAL(s2), ZSTR_LEN(s1));
6969
}
7070
#endif /* PHP_VERSION_ID < 70300 */
7171

72-
/* {{{ igbinary_zend_hash_find_bucket(const HashTable *ht, zend_string *key, zend_bool known_hash) */
73-
static zend_always_inline Bucket *igbinary_zend_hash_find_bucket(const HashTable *ht, zend_string *key, zend_bool known_hash)
72+
/* {{{ igbinary_zend_hash_find_bucket(const HashTable *ht, zend_string *key, bool known_hash) */
73+
static zend_always_inline Bucket *igbinary_zend_hash_find_bucket(const HashTable *ht, zend_string *key, bool known_hash)
7474
{
7575
zend_ulong h;
7676
uint32_t nIndex;

src/php7/php_igbinary.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ extern zend_module_entry igbinary_module_entry;
2525
#endif
2626

2727
ZEND_BEGIN_MODULE_GLOBALS(igbinary)
28-
zend_bool compact_strings;
28+
bool compact_strings;
2929
ZEND_END_MODULE_GLOBALS(igbinary)
3030

3131
#ifdef ZTS

0 commit comments

Comments
 (0)