Skip to content

Commit 413844d

Browse files
Zend/zend_types.h: deprecate zend_bool, zend_intptr_t, zend_uintptr_t (#10597)
These types are standard C99. For compatibility with out-of-tree extensions, keep the typedefs in main/php.h.
1 parent 5e617d0 commit 413844d

36 files changed

+77
-81
lines changed

.gdbinit

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -482,7 +482,7 @@ end
482482

483483
define print_pi
484484
set $pi = (zend_property_info *)$arg0
485-
set $initial_offset = ((uint32_t)(zend_uintptr_t)(&((zend_object*)0)->properties_table[(0)]))
485+
set $initial_offset = ((uint32_t)(uintptr_t)(&((zend_object*)0)->properties_table[(0)]))
486486
set $ptr_to_val = (zval*)((char*)$pi->ce->default_properties_table + $pi->offset - $initial_offset)
487487
printf "[%p] {\n", $pi
488488
printf " offset = %p\n", $pi->offset

Zend/zend_API.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2764,7 +2764,7 @@ ZEND_API zend_result zend_register_functions(zend_class_entry *scope, const zend
27642764
internal_function->arg_info = (zend_internal_arg_info*)ptr->arg_info+1;
27652765
internal_function->num_args = ptr->num_args;
27662766
/* Currently you cannot denote that the function can accept less arguments than num_args */
2767-
if (info->required_num_args == (zend_uintptr_t)-1) {
2767+
if (info->required_num_args == (uintptr_t)-1) {
27682768
internal_function->required_num_args = ptr->num_args;
27692769
} else {
27702770
internal_function->required_num_args = info->required_num_args;

Zend/zend_API.h

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,7 @@ typedef struct _zend_fcall_info_cache {
156156

157157
#define ZEND_BEGIN_ARG_WITH_RETURN_OBJ_INFO_EX2(name, return_reference, required_num_args, class_name, allow_null, is_tentative_return_type) \
158158
static const zend_internal_arg_info name[] = { \
159-
{ (const char*)(zend_uintptr_t)(required_num_args), \
159+
{ (const char*)(uintptr_t)(required_num_args), \
160160
ZEND_TYPE_INIT_CLASS_CONST(#class_name, allow_null, _ZEND_ARG_INFO_FLAGS(return_reference, 0, is_tentative_return_type)), NULL },
161161

162162
#define ZEND_BEGIN_ARG_WITH_RETURN_OBJ_INFO_EX(name, return_reference, required_num_args, class_name, allow_null) \
@@ -170,7 +170,7 @@ typedef struct _zend_fcall_info_cache {
170170

171171
#define ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX2(name, return_reference, required_num_args, type, is_tentative_return_type) \
172172
static const zend_internal_arg_info name[] = { \
173-
{ (const char*)(zend_uintptr_t)(required_num_args), ZEND_TYPE_INIT_MASK(type | _ZEND_ARG_INFO_FLAGS(return_reference, 0, is_tentative_return_type)), NULL },
173+
{ (const char*)(uintptr_t)(required_num_args), ZEND_TYPE_INIT_MASK(type | _ZEND_ARG_INFO_FLAGS(return_reference, 0, is_tentative_return_type)), NULL },
174174

175175
#define ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(name, return_reference, required_num_args, type) \
176176
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX2(name, return_reference, required_num_args, type, 0)
@@ -180,7 +180,7 @@ typedef struct _zend_fcall_info_cache {
180180

181181
#define ZEND_BEGIN_ARG_WITH_RETURN_OBJ_TYPE_MASK_EX2(name, return_reference, required_num_args, class_name, type, is_tentative_return_type) \
182182
static const zend_internal_arg_info name[] = { \
183-
{ (const char*)(zend_uintptr_t)(required_num_args), ZEND_TYPE_INIT_CLASS_CONST_MASK(#class_name, type | _ZEND_ARG_INFO_FLAGS(return_reference, 0, is_tentative_return_type)), NULL },
183+
{ (const char*)(uintptr_t)(required_num_args), ZEND_TYPE_INIT_CLASS_CONST_MASK(#class_name, type | _ZEND_ARG_INFO_FLAGS(return_reference, 0, is_tentative_return_type)), NULL },
184184

185185
#define ZEND_BEGIN_ARG_WITH_RETURN_OBJ_TYPE_MASK_EX(name, return_reference, required_num_args, class_name, type) \
186186
ZEND_BEGIN_ARG_WITH_RETURN_OBJ_TYPE_MASK_EX2(name, return_reference, required_num_args, class_name, type, 0)
@@ -190,7 +190,7 @@ typedef struct _zend_fcall_info_cache {
190190

191191
#define ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX2(name, return_reference, required_num_args, type, allow_null, is_tentative_return_type) \
192192
static const zend_internal_arg_info name[] = { \
193-
{ (const char*)(zend_uintptr_t)(required_num_args), ZEND_TYPE_INIT_CODE(type, allow_null, _ZEND_ARG_INFO_FLAGS(return_reference, 0, is_tentative_return_type)), NULL },
193+
{ (const char*)(uintptr_t)(required_num_args), ZEND_TYPE_INIT_CODE(type, allow_null, _ZEND_ARG_INFO_FLAGS(return_reference, 0, is_tentative_return_type)), NULL },
194194

195195
#define ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(name, return_reference, required_num_args, type, allow_null) \
196196
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX2(name, return_reference, required_num_args, type, allow_null, 0)
@@ -203,7 +203,7 @@ typedef struct _zend_fcall_info_cache {
203203

204204
#define ZEND_BEGIN_ARG_INFO_EX(name, _unused, return_reference, required_num_args) \
205205
static const zend_internal_arg_info name[] = { \
206-
{ (const char*)(zend_uintptr_t)(required_num_args), ZEND_TYPE_INIT_NONE(_ZEND_ARG_INFO_FLAGS(return_reference, 0, 0)), NULL },
206+
{ (const char*)(uintptr_t)(required_num_args), ZEND_TYPE_INIT_NONE(_ZEND_ARG_INFO_FLAGS(return_reference, 0, 0)), NULL },
207207
#define ZEND_BEGIN_ARG_INFO(name, _unused) \
208208
ZEND_BEGIN_ARG_INFO_EX(name, {}, ZEND_RETURN_VALUE, -1)
209209
#define ZEND_END_ARG_INFO() };

Zend/zend_alloc.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -774,7 +774,7 @@ static void *zend_mm_chunk_alloc(zend_mm_heap *heap, size_t size, size_t alignme
774774
#if ZEND_MM_STORAGE
775775
if (UNEXPECTED(heap->storage)) {
776776
void *ptr = heap->storage->handlers.chunk_alloc(heap->storage, size, alignment);
777-
ZEND_ASSERT(((zend_uintptr_t)((char*)ptr + (alignment-1)) & (alignment-1)) == (zend_uintptr_t)ptr);
777+
ZEND_ASSERT(((uintptr_t)((char*)ptr + (alignment-1)) & (alignment-1)) == (uintptr_t)ptr);
778778
return ptr;
779779
}
780780
#endif
@@ -2171,7 +2171,7 @@ static void zend_mm_check_leaks(zend_mm_heap *heap)
21712171
repeated = zend_mm_find_leaks_huge(heap, list);
21722172
total += 1 + repeated;
21732173
if (repeated) {
2174-
zend_message_dispatcher(ZMSG_MEMORY_LEAK_REPEATED, (void *)(zend_uintptr_t)repeated);
2174+
zend_message_dispatcher(ZMSG_MEMORY_LEAK_REPEATED, (void *)(uintptr_t)repeated);
21752175
}
21762176

21772177
heap->huge_list = list = list->next;
@@ -2210,7 +2210,7 @@ static void zend_mm_check_leaks(zend_mm_heap *heap)
22102210
zend_mm_find_leaks(heap, p, i + bin_pages[bin_num], &leak);
22112211
total += 1 + repeated;
22122212
if (repeated) {
2213-
zend_message_dispatcher(ZMSG_MEMORY_LEAK_REPEATED, (void *)(zend_uintptr_t)repeated);
2213+
zend_message_dispatcher(ZMSG_MEMORY_LEAK_REPEATED, (void *)(uintptr_t)repeated);
22142214
}
22152215
}
22162216
dbg = (zend_mm_debug_info*)((char*)dbg + bin_data_size[bin_num]);
@@ -2236,7 +2236,7 @@ static void zend_mm_check_leaks(zend_mm_heap *heap)
22362236
repeated = zend_mm_find_leaks(heap, p, i + pages_count, &leak);
22372237
total += 1 + repeated;
22382238
if (repeated) {
2239-
zend_message_dispatcher(ZMSG_MEMORY_LEAK_REPEATED, (void *)(zend_uintptr_t)repeated);
2239+
zend_message_dispatcher(ZMSG_MEMORY_LEAK_REPEATED, (void *)(uintptr_t)repeated);
22402240
}
22412241
i += pages_count;
22422242
}

Zend/zend_compile.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -431,7 +431,7 @@ typedef struct _zend_arg_info {
431431
* It's also used for the return type.
432432
*/
433433
typedef struct _zend_internal_function_info {
434-
zend_uintptr_t required_num_args;
434+
uintptr_t required_num_args;
435435
zend_type type;
436436
const char *default_value;
437437
} zend_internal_function_info;

Zend/zend_execute.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4804,7 +4804,7 @@ static zend_never_inline zend_execute_data *zend_init_dynamic_call_array(zend_ar
48044804
}
48054805
/* }}} */
48064806

4807-
#define ZEND_FAKE_OP_ARRAY ((zend_op_array*)(zend_intptr_t)-1)
4807+
#define ZEND_FAKE_OP_ARRAY ((zend_op_array*)(intptr_t)-1)
48084808

48094809
static zend_never_inline zend_op_array* ZEND_FASTCALL zend_include_or_eval(zval *inc_filename_zv, int type) /* {{{ */
48104810
{

Zend/zend_execute_API.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1141,7 +1141,7 @@ ZEND_API zend_class_entry *zend_lookup_class_ex(zend_string *name, zend_string *
11411141
ALLOC_HASHTABLE(CG(unlinked_uses));
11421142
zend_hash_init(CG(unlinked_uses), 0, NULL, NULL, 0);
11431143
}
1144-
zend_hash_index_add_empty_element(CG(unlinked_uses), (zend_long)(zend_uintptr_t)ce);
1144+
zend_hash_index_add_empty_element(CG(unlinked_uses), (zend_long)(uintptr_t)ce);
11451145
return ce;
11461146
}
11471147
return NULL;

Zend/zend_hash.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -298,7 +298,7 @@ ZEND_API int zend_hash_compare(HashTable *ht1, HashTable *ht2, compare_func_t
298298
ZEND_API void ZEND_FASTCALL zend_hash_sort_ex(HashTable *ht, sort_func_t sort_func, bucket_compare_func_t compare_func, bool renumber);
299299
ZEND_API zval* ZEND_FASTCALL zend_hash_minmax(const HashTable *ht, compare_func_t compar, uint32_t flag);
300300

301-
static zend_always_inline void ZEND_FASTCALL zend_hash_sort(HashTable *ht, bucket_compare_func_t compare_func, zend_bool renumber) {
301+
static zend_always_inline void ZEND_FASTCALL zend_hash_sort(HashTable *ht, bucket_compare_func_t compare_func, bool renumber) {
302302
zend_hash_sort_ex(ht, zend_sort, compare_func, renumber);
303303
}
304304

Zend/zend_inheritance.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2682,7 +2682,7 @@ static void check_unrecoverable_load_failure(zend_class_entry *ce) {
26822682
* a dependence on the inheritance hierarchy of this specific class. Instead we fall back to
26832683
* a fatal error, as would happen if we did not allow exceptions in the first place. */
26842684
if (CG(unlinked_uses)
2685-
&& zend_hash_index_del(CG(unlinked_uses), (zend_long)(zend_uintptr_t)ce) == SUCCESS) {
2685+
&& zend_hash_index_del(CG(unlinked_uses), (zend_long)(uintptr_t)ce) == SUCCESS) {
26862686
zend_exception_uncaught_error(
26872687
"During inheritance of %s with variance dependencies", ZSTR_VAL(ce->name));
26882688
}
@@ -2957,7 +2957,7 @@ ZEND_API zend_class_entry *zend_do_link_class(zend_class_entry *ce, zend_string
29572957
}
29582958

29592959
if (CG(unlinked_uses)) {
2960-
zend_hash_index_del(CG(unlinked_uses), (zend_long)(zend_uintptr_t) ce);
2960+
zend_hash_index_del(CG(unlinked_uses), (zend_long)(uintptr_t) ce);
29612961
}
29622962

29632963
orig_linking_class = CG(current_linking_class);

Zend/zend_object_handlers.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -536,7 +536,7 @@ ZEND_API zend_result zend_check_property_access(const zend_object *zobj, zend_st
536536

537537
static void zend_property_guard_dtor(zval *el) /* {{{ */ {
538538
uint32_t *ptr = (uint32_t*)Z_PTR_P(el);
539-
if (EXPECTED(!(((zend_uintptr_t)ptr) & 1))) {
539+
if (EXPECTED(!(((uintptr_t)ptr) & 1))) {
540540
efree_size(ptr, sizeof(uint32_t));
541541
}
542542
}
@@ -565,7 +565,7 @@ ZEND_API uint32_t *zend_get_property_guard(zend_object *zobj, zend_string *membe
565565
zend_hash_init(guards, 8, NULL, zend_property_guard_dtor, 0);
566566
/* mark pointer as "special" using low bit */
567567
zend_hash_add_new_ptr(guards, str,
568-
(void*)(((zend_uintptr_t)&Z_PROPERTY_GUARD_P(zv)) | 1));
568+
(void*)(((uintptr_t)&Z_PROPERTY_GUARD_P(zv)) | 1));
569569
zval_ptr_dtor_str(zv);
570570
ZVAL_ARR(zv, guards);
571571
}
@@ -574,7 +574,7 @@ ZEND_API uint32_t *zend_get_property_guard(zend_object *zobj, zend_string *membe
574574
ZEND_ASSERT(guards != NULL);
575575
zv = zend_hash_find(guards, member);
576576
if (zv != NULL) {
577-
return (uint32_t*)(((zend_uintptr_t)Z_PTR_P(zv)) & ~1);
577+
return (uint32_t*)(((uintptr_t)Z_PTR_P(zv)) & ~1);
578578
}
579579
} else {
580580
ZEND_ASSERT(Z_TYPE_P(zv) == IS_UNDEF);

0 commit comments

Comments
 (0)