2008-01-22 09:29:29 +00:00
|
|
|
/*
|
|
|
|
+----------------------------------------------------------------------+
|
|
|
|
| Zend Engine |
|
|
|
|
+----------------------------------------------------------------------+
|
2018-01-02 04:57:58 +00:00
|
|
|
| Copyright (c) 1998-2018 Zend Technologies Ltd. (http://www.zend.com) |
|
2008-01-22 09:29:29 +00:00
|
|
|
+----------------------------------------------------------------------+
|
|
|
|
| This source file is subject to version 2.00 of the Zend license, |
|
|
|
|
| that is bundled with this package in the file LICENSE, and is |
|
|
|
|
| available through the world-wide-web at the following url: |
|
|
|
|
| http://www.zend.com/license/2_00.txt. |
|
|
|
|
| If you did not receive a copy of the Zend license and are unable to |
|
|
|
|
| obtain it through the world-wide-web, please send a note to |
|
|
|
|
| license@zend.com so we can mail you a copy immediately. |
|
|
|
|
+----------------------------------------------------------------------+
|
|
|
|
| Authors: David Wang <planetbeing@gmail.com> |
|
|
|
|
| Dmitry Stogov <dmitry@zend.com> |
|
|
|
|
+----------------------------------------------------------------------+
|
|
|
|
*/
|
|
|
|
|
|
|
|
/* $Id$ */
|
|
|
|
|
|
|
|
#ifndef ZEND_GC_H
|
|
|
|
#define ZEND_GC_H
|
|
|
|
|
|
|
|
BEGIN_EXTERN_C()
|
2014-12-02 20:18:18 +00:00
|
|
|
ZEND_API extern int (*gc_collect_cycles)(void);
|
|
|
|
|
2015-03-13 18:10:09 +00:00
|
|
|
ZEND_API void ZEND_FASTCALL gc_possible_root(zend_refcounted *ref);
|
|
|
|
ZEND_API void ZEND_FASTCALL gc_remove_from_buffer(zend_refcounted *ref);
|
2014-12-13 22:06:14 +00:00
|
|
|
ZEND_API void gc_globals_ctor(void);
|
|
|
|
ZEND_API void gc_globals_dtor(void);
|
|
|
|
ZEND_API void gc_reset(void);
|
2018-02-26 09:49:58 +00:00
|
|
|
ZEND_API zend_bool gc_set_enabled(zend_bool enable);
|
|
|
|
ZEND_API zend_bool gc_enabled(void);
|
2014-12-02 20:18:18 +00:00
|
|
|
|
|
|
|
/* The default implementation of the gc_collect_cycles callback. */
|
|
|
|
ZEND_API int zend_gc_collect_cycles(void);
|
2008-01-22 09:29:29 +00:00
|
|
|
END_EXTERN_C()
|
|
|
|
|
2014-03-19 13:00:28 +00:00
|
|
|
#define GC_REMOVE_FROM_BUFFER(p) do { \
|
|
|
|
zend_refcounted *_p = (zend_refcounted*)(p); \
|
2018-02-26 09:49:58 +00:00
|
|
|
if (GC_INFO(_p)) { \
|
2014-12-13 22:06:14 +00:00
|
|
|
gc_remove_from_buffer(_p); \
|
2014-02-10 06:04:30 +00:00
|
|
|
} \
|
2008-01-22 09:29:29 +00:00
|
|
|
} while (0)
|
|
|
|
|
2016-10-21 14:47:30 +00:00
|
|
|
#define GC_MAY_LEAK(ref) \
|
|
|
|
((GC_TYPE_INFO(ref) & \
|
|
|
|
(GC_INFO_MASK | (GC_COLLECTABLE << GC_FLAGS_SHIFT))) == \
|
|
|
|
(GC_COLLECTABLE << GC_FLAGS_SHIFT))
|
|
|
|
|
|
|
|
static zend_always_inline void gc_check_possible_root(zend_refcounted *ref)
|
2008-01-22 09:29:29 +00:00
|
|
|
{
|
2018-02-27 21:52:12 +00:00
|
|
|
if (GC_TYPE_INFO(ref) == IS_REFERENCE) {
|
2016-10-21 14:47:30 +00:00
|
|
|
zval *zv = &((zend_reference*)ref)->val;
|
|
|
|
|
|
|
|
if (!Z_REFCOUNTED_P(zv)) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
ref = Z_COUNTED_P(zv);
|
|
|
|
}
|
|
|
|
if (UNEXPECTED(GC_MAY_LEAK(ref))) {
|
|
|
|
gc_possible_root(ref);
|
2008-01-22 09:29:29 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif /* ZEND_GC_H */
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Local variables:
|
|
|
|
* tab-width: 4
|
|
|
|
* c-basic-offset: 4
|
|
|
|
* indent-tabs-mode: t
|
|
|
|
* End:
|
2017-07-04 16:12:45 +00:00
|
|
|
* vim600: sw=4 ts=4 fdm=marker
|
|
|
|
* vim<600: sw=4 ts=4
|
2008-01-22 09:29:29 +00:00
|
|
|
*/
|