Skip to content

Commit 9465ec4

Browse files
committed
Added num_roots to gc_status
1 parent e788e82 commit 9465ec4

File tree

4 files changed

+11
-3
lines changed

4 files changed

+11
-3
lines changed

Zend/tests/gc_037.phpt

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,27 +4,31 @@ GC 037: gc_status()
44
zend.enable_gc = 1
55
--FILE--
66
<?php
7-
var_dump(gc_status());
87
$a = array();
98
$a[] =& $a;
109
unset($a);
10+
var_dump(gc_status());
1111
gc_collect_cycles();
1212
gc_collect_cycles();
1313
var_dump(gc_status());
1414
--EXPECT--
15-
array(3) {
15+
array(4) {
1616
["runs"]=>
1717
int(0)
1818
["collected"]=>
1919
int(0)
2020
["threshold"]=>
2121
int(10001)
22+
["roots"]=>
23+
int(1)
2224
}
23-
array(3) {
25+
array(4) {
2426
["runs"]=>
2527
int(1)
2628
["collected"]=>
2729
int(1)
2830
["threshold"]=>
2931
int(10001)
32+
["roots"]=>
33+
int(0)
3034
}

Zend/zend_builtin_functions.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -401,7 +401,9 @@ ZEND_FUNCTION(gc_status)
401401
add_assoc_long_ex(return_value, "runs", sizeof("runs")-1, (long)status.runs);
402402
add_assoc_long_ex(return_value, "collected", sizeof("collected")-1, (long)status.collected);
403403
add_assoc_long_ex(return_value, "threshold", sizeof("threshold")-1, (long)status.threshold);
404+
add_assoc_long_ex(return_value, "roots", sizeof("roots")-1, (long)status.num_roots);
404405
}
406+
/* }}} */
405407

406408
/* {{{ proto int func_num_args(void)
407409
Get the number of arguments that were passed to the function */

Zend/zend_gc.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1447,6 +1447,7 @@ ZEND_API void zend_gc_get_status(zend_gc_status *status)
14471447
status->runs = GC_G(gc_runs);
14481448
status->collected = GC_G(collected);
14491449
status->threshold = GC_G(gc_threshold);
1450+
status->num_roots = GC_G(num_roots);
14501451
}
14511452

14521453
/*

Zend/zend_gc.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ typedef struct _zend_gc_status {
2828
uint32_t runs;
2929
uint32_t collected;
3030
uint32_t threshold;
31+
uint32_t num_roots;
3132
} zend_gc_status;
3233

3334
ZEND_API extern int (*gc_collect_cycles)(void);

0 commit comments

Comments
 (0)