Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Zend/Optimizer/zend_func_infos.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ static const func_info_t func_infos[] = {
F1("get_defined_constants", MAY_BE_ARRAY|MAY_BE_ARRAY_KEY_STRING|MAY_BE_ARRAY_OF_ANY),
F1("debug_backtrace", MAY_BE_ARRAY|MAY_BE_ARRAY_KEY_LONG|MAY_BE_ARRAY_OF_ARRAY),
F1("get_extension_funcs", MAY_BE_ARRAY|MAY_BE_ARRAY_KEY_LONG|MAY_BE_ARRAY_OF_STRING|MAY_BE_FALSE),
F1("gc_status", MAY_BE_ARRAY|MAY_BE_ARRAY_KEY_STRING|MAY_BE_ARRAY_OF_LONG),
F1("gc_status", MAY_BE_ARRAY|MAY_BE_ARRAY_KEY_STRING|MAY_BE_ARRAY_OF_LONG|MAY_BE_ARRAY_OF_FALSE|MAY_BE_ARRAY_OF_TRUE),
F1("bcadd", MAY_BE_STRING),
F1("bcsub", MAY_BE_STRING),
F1("bcmul", MAY_BE_STRING),
Expand Down
20 changes: 18 additions & 2 deletions Zend/tests/gc_037.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -13,23 +13,39 @@ gc_collect_cycles();
var_dump(gc_status());
?>
--EXPECT--
array(4) {
array(8) {
["running"]=>
bool(false)
["protected"]=>
bool(false)
["full"]=>
bool(false)
["runs"]=>
int(0)
["collected"]=>
int(0)
["threshold"]=>
int(10001)
["buffer_size"]=>
int(16384)
["roots"]=>
int(1)
}
array(4) {
array(8) {
["running"]=>
bool(false)
["protected"]=>
bool(false)
["full"]=>
bool(false)
["runs"]=>
int(1)
["collected"]=>
int(1)
["threshold"]=>
int(10001)
["buffer_size"]=>
int(16384)
["roots"]=>
int(0)
}
10 changes: 9 additions & 1 deletion Zend/tests/gc_045.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -46,13 +46,21 @@ for ($j = 0; $j < 10; $j++) {
var_dump(gc_status());
?>
--EXPECT--
array(4) {
array(8) {
["running"]=>
bool(false)
["protected"]=>
bool(false)
["full"]=>
bool(false)
["runs"]=>
int(10)
["collected"]=>
int(25000)
["threshold"]=>
int(10001)
["buffer_size"]=>
int(16384)
["roots"]=>
int(10000)
}
4 changes: 4 additions & 0 deletions Zend/zend_builtin_functions.c
Original file line number Diff line number Diff line change
Expand Up @@ -140,9 +140,13 @@ ZEND_FUNCTION(gc_status)

array_init_size(return_value, 3);

add_assoc_bool_ex(return_value, "running", sizeof("running")-1, status.active);
add_assoc_bool_ex(return_value, "protected", sizeof("protected")-1, status.gc_protected);
add_assoc_bool_ex(return_value, "full", sizeof("full")-1, status.full);
add_assoc_long_ex(return_value, "runs", sizeof("runs")-1, (long)status.runs);
add_assoc_long_ex(return_value, "collected", sizeof("collected")-1, (long)status.collected);
add_assoc_long_ex(return_value, "threshold", sizeof("threshold")-1, (long)status.threshold);
add_assoc_long_ex(return_value, "buffer_size", sizeof("buffer_size")-1, (long)status.buf_size);
add_assoc_long_ex(return_value, "roots", sizeof("roots")-1, (long)status.num_roots);
}
/* }}} */
Expand Down
2 changes: 1 addition & 1 deletion Zend/zend_builtin_functions.stub.php
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ function gc_enable(): void {}
function gc_disable(): void {}

/**
* @return array<string, int>
* @return array<string, int|bool>
* @refcount 1
*/
function gc_status(): array {}
2 changes: 1 addition & 1 deletion Zend/zend_builtin_functions_arginfo.h

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions Zend/zend_gc.c
Original file line number Diff line number Diff line change
Expand Up @@ -1675,9 +1675,13 @@ ZEND_API int zend_gc_collect_cycles(void)

ZEND_API void zend_gc_get_status(zend_gc_status *status)
{
status->active = GC_G(gc_active);
status->gc_protected = GC_G(gc_protected);
status->full = GC_G(gc_full);
status->runs = GC_G(gc_runs);
status->collected = GC_G(collected);
status->threshold = GC_G(gc_threshold);
status->buf_size = GC_G(buf_size);
status->num_roots = GC_G(num_roots);
}

Expand Down
4 changes: 4 additions & 0 deletions Zend/zend_gc.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,13 @@
BEGIN_EXTERN_C()

typedef struct _zend_gc_status {
bool active;
bool gc_protected;
bool full;
uint32_t runs;
uint32_t collected;
uint32_t threshold;
uint32_t buf_size;
uint32_t num_roots;
} zend_gc_status;

Expand Down