Skip to content

Commit 14042a8

Browse files
Refactor: Replace deprecated Zend types with standard C99 types (#353)
1 parent f80f4db commit 14042a8

File tree

21 files changed

+111
-111
lines changed

21 files changed

+111
-111
lines changed

src/cache.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ static zend_always_inline void php_parallel_cache_type(zend_type *type) { /* {{{
123123

124124

125125
/* {{{ */
126-
static zend_op_array* php_parallel_cache_create(const zend_function *source, zend_bool statics) {
126+
static zend_op_array* php_parallel_cache_create(const zend_function *source, bool statics) {
127127
zend_op_array *cached = php_parallel_cache_copy_mem((void*) source, sizeof(zend_op_array));
128128

129129
cached->fn_flags |= ZEND_ACC_IMMUTABLE;
@@ -333,7 +333,7 @@ static zend_op_array* php_parallel_cache_create(const zend_function *source, zen
333333
} /* }}} */
334334

335335
/* {{{ */
336-
static zend_always_inline zend_function* php_parallel_cache_function_ex(const zend_function *source, zend_bool statics) {
336+
static zend_always_inline zend_function* php_parallel_cache_function_ex(const zend_function *source, bool statics) {
337337
zend_op_array *cached;
338338

339339
pthread_mutex_lock(&PCG(mutex));

src/channel.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ php_parallel_channels_t php_parallel_channels = {NULL, 0};
3131
zend_class_entry *php_parallel_channel_ce;
3232
zend_object_handlers php_parallel_channel_handlers;
3333

34-
static zend_always_inline void php_parallel_channels_make_ex(php_parallel_channel_t *channel, zend_string *name, zend_bool buffered, zend_long capacity) {
34+
static zend_always_inline void php_parallel_channels_make_ex(php_parallel_channel_t *channel, zend_string *name, bool buffered, zend_long capacity) {
3535
channel->link = php_parallel_link_init(name, buffered, capacity);
3636

3737
zend_hash_add_ptr(
@@ -40,7 +40,7 @@ static zend_always_inline void php_parallel_channels_make_ex(php_parallel_channe
4040
php_parallel_link_copy(channel->link));
4141
}
4242

43-
static zend_always_inline void php_parallel_channels_make(zval *return_value, zend_string *name, zend_bool buffered, zend_long capacity) {
43+
static zend_always_inline void php_parallel_channels_make(zval *return_value, zend_string *name, bool buffered, zend_long capacity) {
4444
object_init_ex(return_value, php_parallel_channel_ce);
4545

4646
php_parallel_channels_make_ex(
@@ -96,7 +96,7 @@ PHP_METHOD(Parallel_Channel, __construct)
9696
{
9797
php_parallel_channel_t *channel = php_parallel_channel_from(getThis());
9898
zend_long capacity = -1;
99-
zend_bool buffered = 0;
99+
bool buffered = 0;
100100
zend_string *name = NULL;
101101

102102
if (ZEND_NUM_ARGS()) {
@@ -134,7 +134,7 @@ ZEND_END_ARG_INFO()
134134
PHP_METHOD(Parallel_Channel, make)
135135
{
136136
zend_string *name = NULL;
137-
zend_bool buffered = 0;
137+
bool buffered = 0;
138138
zend_long capacity = -1;
139139

140140
if (ZEND_NUM_ARGS() == 1) {

src/check.c

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -35,17 +35,17 @@ TSRM_TLS struct {
3535

3636
typedef struct _php_parallel_check_task_t {
3737
zend_function *function;
38-
zend_bool returns;
38+
bool returns;
3939
} php_parallel_check_task_t;
4040

4141
typedef struct _php_parallel_check_function_t {
4242
zend_function *function;
4343
zend_uchar instruction;
44-
zend_bool valid;
44+
bool valid;
4545
} php_parallel_check_function_t;
4646

4747
typedef struct _php_parallel_check_type_t {
48-
zend_bool valid;
48+
bool valid;
4949
} php_parallel_check_type_t;
5050

5151
typedef enum {
@@ -80,7 +80,7 @@ static zend_always_inline const char* php_parallel_check_opcode_name(zend_uchar
8080
}
8181
} /* }}} */
8282

83-
static zend_always_inline zend_bool php_parallel_check_type(zend_type type) { /* {{{ */
83+
static zend_always_inline bool php_parallel_check_type(zend_type type) { /* {{{ */
8484
zend_string *name;
8585
zend_type *single;
8686
zend_class_entry *class;
@@ -153,7 +153,7 @@ static zend_always_inline zend_bool php_parallel_check_type(zend_type type) { /*
153153
return check.valid;
154154
} /* }}} */
155155

156-
static zend_always_inline zend_bool php_parallel_check_arginfo(const zend_function *function) { /* {{{ */
156+
static zend_always_inline bool php_parallel_check_arginfo(const zend_function *function) { /* {{{ */
157157
zend_arg_info *it, *end;
158158
int argc = 1;
159159

@@ -212,7 +212,7 @@ static zend_always_inline zend_bool php_parallel_check_arginfo(const zend_functi
212212
return 1;
213213
} /* }}} */
214214

215-
static zend_always_inline zend_bool php_parallel_check_statics(const zend_function *function, zend_string **errn, zval **errz) { /* {{{ */
215+
static zend_always_inline bool php_parallel_check_statics(const zend_function *function, zend_string **errn, zval **errz) { /* {{{ */
216216
HashTable *statics;
217217
zval *value, *error;
218218
zend_string *name;
@@ -241,7 +241,7 @@ static zend_always_inline zend_bool php_parallel_check_statics(const zend_functi
241241
return 1;
242242
} /* }}} */
243243

244-
static zend_always_inline zend_bool php_parallel_check_argv(zval *args, uint32_t *argc, zval **error) { /* {{{ */
244+
static zend_always_inline bool php_parallel_check_argv(zval *args, uint32_t *argc, zval **error) { /* {{{ */
245245
zval *arg;
246246

247247
if (*argc == 0) {
@@ -259,7 +259,7 @@ static zend_always_inline zend_bool php_parallel_check_argv(zval *args, uint32_t
259259
return 1;
260260
} /* }}} */
261261

262-
static zend_always_inline zend_bool php_parallel_check_use(zend_execute_data *execute_data, const zend_function *function, zend_op *bind) { /* {{{ */
262+
static zend_always_inline bool php_parallel_check_use(zend_execute_data *execute_data, const zend_function *function, zend_op *bind) { /* {{{ */
263263
zend_op *opline, *end;
264264

265265
if (EX(func)->type != ZEND_USER_FUNCTION) {
@@ -283,7 +283,7 @@ static zend_always_inline zend_bool php_parallel_check_use(zend_execute_data *ex
283283
return 0;
284284
} /* }}} */
285285

286-
zend_bool php_parallel_check_task(php_parallel_runtime_t *runtime, zend_execute_data *execute_data, const zend_function * function, zval *argv, zend_bool *returns) { /* {{{ */
286+
bool php_parallel_check_task(php_parallel_runtime_t *runtime, zend_execute_data *execute_data, const zend_function * function, zval *argv, bool *returns) { /* {{{ */
287287
php_parallel_check_task_t check, *checked;
288288
zend_op *it, *end;
289289

@@ -436,7 +436,7 @@ zend_bool php_parallel_check_task(php_parallel_runtime_t *runtime, zend_execute_
436436
return 1;
437437
} /* }}} */
438438

439-
zend_bool php_parallel_check_function(const zend_function *function, zend_function **errf, zend_uchar *erro) { /* {{{ */
439+
bool php_parallel_check_function(const zend_function *function, zend_function **errf, zend_uchar *erro) { /* {{{ */
440440
php_parallel_check_function_t check, *checked;
441441
zend_op *it, *end;
442442

@@ -499,7 +499,7 @@ zend_bool php_parallel_check_function(const zend_function *function, zend_functi
499499
return check.valid;
500500
} /* }}} */
501501

502-
static zend_always_inline zend_bool php_parallel_check_closure(zend_closure_t *closure) { /* {{{ */
502+
static zend_always_inline bool php_parallel_check_closure(zend_closure_t *closure) { /* {{{ */
503503
return php_parallel_check_statics(&closure->func, NULL, NULL) &&
504504
php_parallel_check_function(&closure->func, NULL, NULL);
505505
} /* }}} */
@@ -660,7 +660,7 @@ static php_parallel_check_class_result_t php_parallel_check_class(zend_class_ent
660660
return php_parallel_check_class_inline(ce);
661661
}
662662

663-
static zend_always_inline zend_bool php_parallel_check_object(zend_object *object, zval **error) { /* {{{ */
663+
static zend_always_inline bool php_parallel_check_object(zend_object *object, zval **error) { /* {{{ */
664664
if (instanceof_function(object->ce, php_parallel_channel_ce) ||
665665
instanceof_function(object->ce, php_parallel_sync_ce)) {
666666
return 1;
@@ -724,7 +724,7 @@ static zend_always_inline zend_bool php_parallel_check_object(zend_object *objec
724724
return 1;
725725
} /* }}} */
726726

727-
static zend_always_inline zend_bool php_parallel_check_resource(zval *zv) { /* {{{ */
727+
static zend_always_inline bool php_parallel_check_resource(zval *zv) { /* {{{ */
728728
zend_resource *resource = Z_RES_P(zv);
729729

730730
if (resource->type == php_file_le_stream() ||
@@ -735,7 +735,7 @@ static zend_always_inline zend_bool php_parallel_check_resource(zval *zv) { /* {
735735
return 0;
736736
} /* }}} */
737737

738-
zend_bool php_parallel_check_zval(zval *zv, zval **error) { /* {{{ */
738+
bool php_parallel_check_zval(zval *zv, zval **error) { /* {{{ */
739739
switch (Z_TYPE_P(zv)) {
740740
case IS_OBJECT:
741741
if (PARALLEL_ZVAL_CHECK_CLOSURE(zv)) {

src/check.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,17 +18,17 @@
1818
#ifndef HAVE_PARALLEL_CHECK_H
1919
#define HAVE_PARALLEL_CHECK_H
2020

21-
zend_bool php_parallel_check_task(php_parallel_runtime_t *runtime, zend_execute_data *execute_data, const zend_function * function, zval *argv, zend_bool *returns);
22-
zend_bool php_parallel_check_zval(zval *zv, zval **error);
23-
zend_bool php_parallel_check_function(const zend_function *function, zend_function **errf, zend_uchar *erro);
21+
bool php_parallel_check_task(php_parallel_runtime_t *runtime, zend_execute_data *execute_data, const zend_function * function, zval *argv, bool *returns);
22+
bool php_parallel_check_zval(zval *zv, zval **error);
23+
bool php_parallel_check_function(const zend_function *function, zend_function **errf, zend_uchar *erro);
2424

2525
#define PARALLEL_ZVAL_CHECK php_parallel_check_zval
2626
#define PARALLEL_ZVAL_CHECK_CLOSURES php_parallel_check_zval_closures
2727

2828
#define PARALLEL_ZVAL_CHECK_CLOSURE(zv) \
2929
(Z_TYPE_P(zv) == IS_OBJECT && Z_OBJCE_P(zv) == zend_ce_closure)
3030

31-
static zend_always_inline zend_bool php_parallel_check_zval_closures(zval *zv) { /* {{{ */
31+
static zend_always_inline bool php_parallel_check_zval_closures(zval *zv) { /* {{{ */
3232
if (PARALLEL_ZVAL_CHECK_CLOSURE(zv)) {
3333
return 1;
3434
}

src/copy.c

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ static void php_parallel_copy_string_free(zval *zv) {
5151
free(Z_PTR_P(zv));
5252
}
5353

54-
static zend_always_inline zend_string* php_parallel_copy_string_ex(zend_string *source, zend_bool persistent) {
54+
static zend_always_inline zend_string* php_parallel_copy_string_ex(zend_string *source, bool persistent) {
5555
zend_string *dest = zend_string_alloc(ZSTR_LEN(source), persistent);
5656

5757
memcpy(ZSTR_VAL(dest),
@@ -89,7 +89,7 @@ zend_string* php_parallel_copy_string_interned(zend_string *source) {
8989
return dest;
9090
}
9191

92-
static zend_always_inline void php_parallel_copy_string_dtor(zend_string *source, zend_bool persistent) {
92+
static zend_always_inline void php_parallel_copy_string_dtor(zend_string *source, bool persistent) {
9393
if (ZSTR_IS_INTERNED(source)) {
9494
return;
9595
}
@@ -99,15 +99,15 @@ static zend_always_inline void php_parallel_copy_string_dtor(zend_string *source
9999
}
100100
}
101101

102-
static zend_always_inline zend_string* php_parallel_copy_string_ctor(zend_string *source, zend_bool persistent) {
102+
static zend_always_inline zend_string* php_parallel_copy_string_ctor(zend_string *source, bool persistent) {
103103
if (ZSTR_IS_INTERNED(source)) {
104104
return php_parallel_copy_string_interned(source);
105105
}
106106

107107
return php_parallel_copy_string_ex(source, persistent);
108108
}
109109

110-
zend_string* php_parallel_copy_string(zend_string *source, zend_bool persistent) {
110+
zend_string* php_parallel_copy_string(zend_string *source, bool persistent) {
111111
return php_parallel_copy_string_ctor(source, persistent);
112112
}
113113

@@ -151,7 +151,7 @@ zend_class_entry* php_parallel_copy_scope(zend_class_entry *class) {
151151
return zend_hash_index_update_ptr(&PCG(scope), (zend_ulong) class, scope);
152152
}
153153

154-
static zend_always_inline zend_long php_parallel_copy_resource_ctor(zend_resource *source, zend_bool persistent) {
154+
static zend_always_inline zend_long php_parallel_copy_resource_ctor(zend_resource *source, bool persistent) {
155155
#ifndef _WIN32
156156
if (source->type == php_file_le_stream() ||
157157
source->type == php_file_le_pstream()) {
@@ -357,7 +357,7 @@ static zend_string* php_parallel_copy_string_persistent(zend_string *string) {
357357
return php_parallel_copy_string_ctor(string, 1);
358358
}
359359

360-
HashTable *php_parallel_copy_hash_ctor(HashTable *source, zend_bool persistent) {
360+
HashTable *php_parallel_copy_hash_ctor(HashTable *source, bool persistent) {
361361
if (persistent) {
362362
return php_parallel_copy_hash_persistent_inline(
363363
source,
@@ -375,7 +375,7 @@ HashTable *php_parallel_copy_hash_persistent(HashTable *source,
375375
php_parallel_copy_memory_func);
376376
}
377377

378-
void php_parallel_copy_hash_dtor(HashTable *table, zend_bool persistent) {
378+
void php_parallel_copy_hash_dtor(HashTable *table, bool persistent) {
379379
// see https://github.com/krakjoe/parallel/issues/306#issuecomment-2414687880
380380
// TODO: needs fixing
381381
if (GC_DELREF(table) == (persistent ? 1 : 0)) {
@@ -531,15 +531,15 @@ static zend_always_inline zend_object* php_parallel_copy_closure_thread(zend_obj
531531
return &copy->std;
532532
}
533533

534-
static zend_always_inline zend_object* php_parallel_copy_closure_ctor(zend_object *source, zend_bool persistent) {
534+
static zend_always_inline zend_object* php_parallel_copy_closure_ctor(zend_object *source, bool persistent) {
535535
if (persistent) {
536536
return php_parallel_copy_closure_persistent(source);
537537
}
538538

539539
return php_parallel_copy_closure_thread(source);
540540
}
541541

542-
static zend_always_inline void php_parallel_copy_closure_dtor(zend_object *source, zend_bool persistent) {
542+
static zend_always_inline void php_parallel_copy_closure_dtor(zend_object *source, bool persistent) {
543543
zend_closure_t *closure;
544544

545545
if (!persistent) {
@@ -584,14 +584,14 @@ static zend_always_inline zend_reference* php_parallel_copy_reference_thread(zen
584584
return reference;
585585
}
586586

587-
static zend_always_inline zend_reference* php_parallel_copy_reference_ctor(zend_reference *source, zend_bool persistent) {
587+
static zend_always_inline zend_reference* php_parallel_copy_reference_ctor(zend_reference *source, bool persistent) {
588588
if (persistent) {
589589
return php_parallel_copy_reference_persistent(source);
590590
}
591591
return php_parallel_copy_reference_thread(source);
592592
}
593593

594-
static zend_always_inline void php_parallel_copy_reference_dtor(zend_reference *source, zend_bool persistent) {
594+
static zend_always_inline void php_parallel_copy_reference_dtor(zend_reference *source, bool persistent) {
595595
if (GC_DELREF(source) == 0) {
596596
PARALLEL_ZVAL_DTOR(
597597
&source->val);
@@ -637,14 +637,14 @@ static zend_always_inline zend_object* php_parallel_copy_channel_thread(zend_obj
637637
return &dest->std;
638638
}
639639

640-
static zend_always_inline zend_object* php_parallel_copy_channel_ctor(zend_object *source, zend_bool persistent) {
640+
static zend_always_inline zend_object* php_parallel_copy_channel_ctor(zend_object *source, bool persistent) {
641641
if (persistent) {
642642
return php_parallel_copy_channel_persistent(source);
643643
}
644644
return php_parallel_copy_channel_thread(source);
645645
}
646646

647-
static zend_always_inline void php_parallel_copy_channel_dtor(zend_object *source, zend_bool persistent) {
647+
static zend_always_inline void php_parallel_copy_channel_dtor(zend_object *source, bool persistent) {
648648
php_parallel_channel_t *channel = php_parallel_channel_fetch(source);
649649

650650
if (!persistent) {
@@ -696,14 +696,14 @@ static zend_always_inline zend_object* php_parallel_copy_sync_thread(zend_object
696696
return &dest->std;
697697
}
698698

699-
static zend_always_inline zend_object* php_parallel_copy_sync_ctor(zend_object *source, zend_bool persistent) {
699+
static zend_always_inline zend_object* php_parallel_copy_sync_ctor(zend_object *source, bool persistent) {
700700
if (persistent) {
701701
return php_parallel_copy_sync_persistent(source);
702702
}
703703
return php_parallel_copy_sync_thread(source);
704704
}
705705

706-
static zend_always_inline void php_parallel_copy_sync_dtor(zend_object *source, zend_bool persistent) {
706+
static zend_always_inline void php_parallel_copy_sync_dtor(zend_object *source, bool persistent) {
707707
php_parallel_sync_object_t *object = php_parallel_sync_object_fetch(source);
708708

709709
if (!persistent) {
@@ -831,7 +831,7 @@ static zend_always_inline zend_object* php_parallel_copy_object_thread(zend_obje
831831
return dest;
832832
}
833833

834-
static zend_always_inline zend_object* php_parallel_copy_object_ctor(zend_object *source, zend_bool persistent) {
834+
static zend_always_inline zend_object* php_parallel_copy_object_ctor(zend_object *source, bool persistent) {
835835
if (source->ce == zend_ce_closure) {
836836
return php_parallel_copy_closure_ctor(source, persistent);
837837
}
@@ -851,7 +851,7 @@ static zend_always_inline zend_object* php_parallel_copy_object_ctor(zend_object
851851
return php_parallel_copy_object_thread(source);
852852
}
853853

854-
static zend_always_inline void php_parallel_copy_object_dtor(zend_object *source, zend_bool persistent) {
854+
static zend_always_inline void php_parallel_copy_object_dtor(zend_object *source, bool persistent) {
855855
if (source->ce == zend_ce_closure) {
856856
php_parallel_copy_closure_dtor(source, persistent);
857857
return;
@@ -891,7 +891,7 @@ static zend_always_inline void php_parallel_copy_object_dtor(zend_object *source
891891
}
892892
}
893893

894-
void php_parallel_copy_zval_ctor(zval *dest, zval *source, zend_bool persistent) {
894+
void php_parallel_copy_zval_ctor(zval *dest, zval *source, bool persistent) {
895895
switch (Z_TYPE_P(source)) {
896896
case IS_NULL:
897897
case IS_TRUE:
@@ -985,7 +985,7 @@ static void php_parallel_copy_zval_persistent(
985985
}
986986
}
987987

988-
zend_function* php_parallel_copy_function(const zend_function *function, zend_bool persistent) {
988+
zend_function* php_parallel_copy_function(const zend_function *function, bool persistent) {
989989
if (persistent) {
990990
function =
991991
php_parallel_cache_function(function);

src/copy.h

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -46,25 +46,25 @@ typedef struct _zend_closure_t {
4646
zif_handler orig_internal_handler;
4747
} zend_closure_t;
4848

49-
static zend_always_inline void* php_parallel_copy_mem(void *source, size_t size, zend_bool persistent) {
49+
static zend_always_inline void* php_parallel_copy_mem(void *source, size_t size, bool persistent) {
5050
void *destination = (void*) pemalloc(PARALLEL_PLATFORM_ALIGNED(size), persistent);
5151

5252
memcpy(destination, source, size);
5353

5454
return destination;
5555
}
5656

57-
zend_function* php_parallel_copy_function(const zend_function *function, zend_bool persistent);
57+
zend_function* php_parallel_copy_function(const zend_function *function, bool persistent);
5858

5959
zend_string* php_parallel_copy_string_interned(zend_string *source);
60-
zend_string* php_parallel_copy_string(zend_string *source, zend_bool persistent);
60+
zend_string* php_parallel_copy_string(zend_string *source, bool persistent);
6161

62-
HashTable *php_parallel_copy_hash_ctor(HashTable *source, zend_bool persistent);
63-
void php_parallel_copy_hash_dtor(HashTable *table, zend_bool persistent);
62+
HashTable *php_parallel_copy_hash_ctor(HashTable *source, bool persistent);
63+
void php_parallel_copy_hash_dtor(HashTable *table, bool persistent);
6464

6565
HashTable *php_parallel_copy_hash_persistent(HashTable *source, zend_string* (*)(zend_string*), void* (*)(void *, zend_long));
6666

67-
void php_parallel_copy_zval_ctor(zval *dest, zval *source, zend_bool persistent);
67+
void php_parallel_copy_zval_ctor(zval *dest, zval *source, bool persistent);
6868
void php_parallel_copy_zval_dtor(zval *zv);
6969

7070
zend_class_entry* php_parallel_copy_scope(zend_class_entry *);

0 commit comments

Comments
 (0)