adds reflection info for APIs
git-svn-id: svn://svn.lighttpd.net/xcache/trunk@1477 c26eb9a1-5813-0410-bd6c-c2e55f420ca7master
parent
8550abf7e8
commit
501bbf2e0f
|
@ -9,6 +9,8 @@ ChangeLog
|
|||
* cacher:
|
||||
* (WIP) defragment
|
||||
* (WIP) cache to disk
|
||||
* misc:
|
||||
* Reflection info added for APIs
|
||||
|
||||
3.1.1 2013-??-??
|
||||
ChangeLog
|
||||
|
|
|
@ -0,0 +1,8 @@
|
|||
<?php
|
||||
|
||||
$all_functions = get_defined_functions();
|
||||
$xcache_functions = preg_grep("/^xcache_/", $all_functions['internal']);
|
||||
foreach ($xcache_functions as $function) {
|
||||
ReflectionFunction::export($function);
|
||||
}
|
||||
|
|
@ -3132,6 +3132,14 @@ static void xcache_admin_operate(xcache_op_type optype, INTERNAL_FUNCTION_PARAME
|
|||
/* }}} */
|
||||
/* {{{ proto int xcache_count(int type)
|
||||
Return count of cache on specified cache type */
|
||||
#ifdef ZEND_BEGIN_ARG_INFO_EX
|
||||
ZEND_BEGIN_ARG_INFO_EX(arginfo_xcache_count, 0, 0, 1)
|
||||
ZEND_ARG_INFO(0, type)
|
||||
ZEND_END_ARG_INFO()
|
||||
#else
|
||||
static unsigned char arginfo_xcache_count[] = { 1, BYREF_NONE };
|
||||
#endif
|
||||
|
||||
PHP_FUNCTION(xcache_count)
|
||||
{
|
||||
xcache_admin_operate(XC_OP_COUNT, INTERNAL_FUNCTION_PARAM_PASSTHRU);
|
||||
|
@ -3139,6 +3147,15 @@ PHP_FUNCTION(xcache_count)
|
|||
/* }}} */
|
||||
/* {{{ proto array xcache_info(int type, int id)
|
||||
Get cache info by id on specified cache type */
|
||||
#ifdef ZEND_BEGIN_ARG_INFO_EX
|
||||
ZEND_BEGIN_ARG_INFO_EX(arginfo_xcache_info, 0, 0, 2)
|
||||
ZEND_ARG_INFO(0, type)
|
||||
ZEND_ARG_INFO(0, id)
|
||||
ZEND_END_ARG_INFO()
|
||||
#else
|
||||
static unsigned char arginfo_xcache_info[] = { 2, BYREF_NONE, BYREF_NONE };
|
||||
#endif
|
||||
|
||||
PHP_FUNCTION(xcache_info)
|
||||
{
|
||||
xcache_admin_operate(XC_OP_INFO, INTERNAL_FUNCTION_PARAM_PASSTHRU);
|
||||
|
@ -3146,6 +3163,15 @@ PHP_FUNCTION(xcache_info)
|
|||
/* }}} */
|
||||
/* {{{ proto array xcache_list(int type, int id)
|
||||
Get cache entries list by id on specified cache type */
|
||||
#ifdef ZEND_BEGIN_ARG_INFO_EX
|
||||
ZEND_BEGIN_ARG_INFO_EX(arginfo_xcache_list, 0, 0, 2)
|
||||
ZEND_ARG_INFO(0, type)
|
||||
ZEND_ARG_INFO(0, id)
|
||||
ZEND_END_ARG_INFO()
|
||||
#else
|
||||
static unsigned char arginfo_xcache_list[] = { 2, BYREF_NONE, BYREF_NONE };
|
||||
#endif
|
||||
|
||||
PHP_FUNCTION(xcache_list)
|
||||
{
|
||||
xcache_admin_operate(XC_OP_LIST, INTERNAL_FUNCTION_PARAM_PASSTHRU);
|
||||
|
@ -3153,6 +3179,15 @@ PHP_FUNCTION(xcache_list)
|
|||
/* }}} */
|
||||
/* {{{ proto array xcache_clear_cache(int type, [ int id = -1 ])
|
||||
Clear cache by id on specified cache type */
|
||||
#ifdef ZEND_BEGIN_ARG_INFO_EX
|
||||
ZEND_BEGIN_ARG_INFO_EX(arginfo_xcache_clear_cache, 0, 0, 1)
|
||||
ZEND_ARG_INFO(0, type)
|
||||
ZEND_ARG_INFO(0, id)
|
||||
ZEND_END_ARG_INFO()
|
||||
#else
|
||||
static unsigned char arginfo_xcache_clear_cache[] = { 2, BYREF_NONE, BYREF_NONE };
|
||||
#endif
|
||||
|
||||
PHP_FUNCTION(xcache_clear_cache)
|
||||
{
|
||||
xcache_admin_operate(XC_OP_CLEAR, INTERNAL_FUNCTION_PARAM_PASSTHRU);
|
||||
|
@ -3160,6 +3195,16 @@ PHP_FUNCTION(xcache_clear_cache)
|
|||
/* }}} */
|
||||
/* {{{ proto array xcache_enable_cache(int type, [ int id = -1, [ bool enable = true ] ])
|
||||
Enable or disable cache by id on specified cache type */
|
||||
#ifdef ZEND_BEGIN_ARG_INFO_EX
|
||||
ZEND_BEGIN_ARG_INFO_EX(arginfo_xcache_enable_cache, 0, 0, 1)
|
||||
ZEND_ARG_INFO(0, type)
|
||||
ZEND_ARG_INFO(0, id)
|
||||
ZEND_ARG_INFO(0, enable)
|
||||
ZEND_END_ARG_INFO()
|
||||
#else
|
||||
static unsigned char arginfo_xcache_enable_cache[] = { 1, BYREF_NONE };
|
||||
#endif
|
||||
|
||||
PHP_FUNCTION(xcache_enable_cache)
|
||||
{
|
||||
xcache_admin_operate(XC_OP_ENABLE, INTERNAL_FUNCTION_PARAM_PASSTHRU);
|
||||
|
@ -3167,6 +3212,13 @@ PHP_FUNCTION(xcache_enable_cache)
|
|||
/* }}} */
|
||||
/* {{{ proto mixed xcache_admin_namespace()
|
||||
Break out of namespace limitation */
|
||||
#ifdef ZEND_BEGIN_ARG_INFO_EX
|
||||
ZEND_BEGIN_ARG_INFO_EX(arginfo_xcache_admin_namespace, 0, 0, 0)
|
||||
ZEND_END_ARG_INFO()
|
||||
#else
|
||||
static unsigned char arginfo_xcache_admin_namespace[] = { 0 };
|
||||
#endif
|
||||
|
||||
PHP_FUNCTION(xcache_admin_namespace)
|
||||
{
|
||||
xcache_admin_auth_check(TSRMLS_C);
|
||||
|
@ -3198,6 +3250,14 @@ static int xc_entry_var_init_key(xc_entry_var_t *entry_var, xc_entry_hash_t *ent
|
|||
/* }}} */
|
||||
/* {{{ proto mixed xcache_set_namespace(string namespace)
|
||||
Switch to user defined namespace */
|
||||
#ifdef ZEND_BEGIN_ARG_INFO_EX
|
||||
ZEND_BEGIN_ARG_INFO_EX(arginfo_xcache_set_namespace, 0, 0, 1)
|
||||
ZEND_ARG_INFO(0, namespace)
|
||||
ZEND_END_ARG_INFO()
|
||||
#else
|
||||
static unsigned char arginfo_xcache_set_namespace[] = { 1, BYREF_NONE };
|
||||
#endif
|
||||
|
||||
PHP_FUNCTION(xcache_set_namespace)
|
||||
{
|
||||
zval *namespace;
|
||||
|
@ -3223,6 +3283,14 @@ PHP_FUNCTION(xcache_set_namespace)
|
|||
/* }}} */
|
||||
/* {{{ proto mixed xcache_get(string name)
|
||||
Get cached data by specified name */
|
||||
#ifdef ZEND_BEGIN_ARG_INFO_EX
|
||||
ZEND_BEGIN_ARG_INFO_EX(arginfo_xcache_get, 0, 0, 1)
|
||||
ZEND_ARG_INFO(0, name)
|
||||
ZEND_END_ARG_INFO()
|
||||
#else
|
||||
static unsigned char arginfo_xcache_get[] = { 1, BYREF_NONE };
|
||||
#endif
|
||||
|
||||
PHP_FUNCTION(xcache_get)
|
||||
{
|
||||
xc_entry_hash_t entry_hash;
|
||||
|
@ -3264,6 +3332,16 @@ PHP_FUNCTION(xcache_get)
|
|||
/* }}} */
|
||||
/* {{{ proto bool xcache_set(string name, mixed value [, int ttl])
|
||||
Store data to cache by specified name */
|
||||
#ifdef ZEND_BEGIN_ARG_INFO_EX
|
||||
ZEND_BEGIN_ARG_INFO_EX(arginfo_xcache_set, 0, 0, 2)
|
||||
ZEND_ARG_INFO(0, name)
|
||||
ZEND_ARG_INFO(0, value)
|
||||
ZEND_ARG_INFO(0, ttl)
|
||||
ZEND_END_ARG_INFO()
|
||||
#else
|
||||
static unsigned char arginfo_xcache_set[] = { 3, BYREF_NONE, BYREF_NONE, BYREF_NONE };
|
||||
#endif
|
||||
|
||||
PHP_FUNCTION(xcache_set)
|
||||
{
|
||||
xc_entry_hash_t entry_hash;
|
||||
|
@ -3315,6 +3393,14 @@ PHP_FUNCTION(xcache_set)
|
|||
/* }}} */
|
||||
/* {{{ proto bool xcache_isset(string name)
|
||||
Check if an entry exists in cache by specified name */
|
||||
#ifdef ZEND_BEGIN_ARG_INFO_EX
|
||||
ZEND_BEGIN_ARG_INFO_EX(arginfo_xcache_isset, 0, 0, 1)
|
||||
ZEND_ARG_INFO(0, name)
|
||||
ZEND_END_ARG_INFO()
|
||||
#else
|
||||
static unsigned char arginfo_xcache_isset[] = { 1, BYREF_NONE };
|
||||
#endif
|
||||
|
||||
PHP_FUNCTION(xcache_isset)
|
||||
{
|
||||
xc_entry_hash_t entry_hash;
|
||||
|
@ -3357,6 +3443,14 @@ PHP_FUNCTION(xcache_isset)
|
|||
/* }}} */
|
||||
/* {{{ proto bool xcache_unset(string name)
|
||||
Unset existing data in cache by specified name */
|
||||
#ifdef ZEND_BEGIN_ARG_INFO_EX
|
||||
ZEND_BEGIN_ARG_INFO_EX(arginfo_xcache_unset, 0, 0, 1)
|
||||
ZEND_ARG_INFO(0, name)
|
||||
ZEND_END_ARG_INFO()
|
||||
#else
|
||||
static unsigned char arginfo_xcache_unset[] = { 1, BYREF_NONE };
|
||||
#endif
|
||||
|
||||
PHP_FUNCTION(xcache_unset)
|
||||
{
|
||||
xc_entry_hash_t entry_hash;
|
||||
|
@ -3397,6 +3491,14 @@ PHP_FUNCTION(xcache_unset)
|
|||
/* }}} */
|
||||
/* {{{ proto bool xcache_unset_by_prefix(string prefix)
|
||||
Unset existing data in cache by specified prefix */
|
||||
#ifdef ZEND_BEGIN_ARG_INFO_EX
|
||||
ZEND_BEGIN_ARG_INFO_EX(arginfo_xcache_unset_by_prefix, 0, 0, 1)
|
||||
ZEND_ARG_INFO(0, prefix)
|
||||
ZEND_END_ARG_INFO()
|
||||
#else
|
||||
static unsigned char arginfo_xcache_unset_by_prefix[] = { 1, BYREF_NONE };
|
||||
#endif
|
||||
|
||||
PHP_FUNCTION(xcache_unset_by_prefix)
|
||||
{
|
||||
zval *prefix;
|
||||
|
@ -3517,6 +3619,16 @@ static inline void xc_var_inc_dec(int inc, INTERNAL_FUNCTION_PARAMETERS) /* {{{
|
|||
/* }}} */
|
||||
/* {{{ proto int xcache_inc(string name [, int value [, int ttl]])
|
||||
Increase an int counter in cache by specified name, create it if not exists */
|
||||
#ifdef ZEND_BEGIN_ARG_INFO_EX
|
||||
ZEND_BEGIN_ARG_INFO_EX(arginfo_xcache_inc, 0, 0, 1)
|
||||
ZEND_ARG_INFO(0, prefix)
|
||||
ZEND_ARG_INFO(0, value)
|
||||
ZEND_ARG_INFO(0, ttl)
|
||||
ZEND_END_ARG_INFO()
|
||||
#else
|
||||
static unsigned char arginfo_xcache_inc[] = { 3, BYREF_NONE, BYREF_NONE, BYREF_NONE };
|
||||
#endif
|
||||
|
||||
PHP_FUNCTION(xcache_inc)
|
||||
{
|
||||
xc_var_inc_dec(1, INTERNAL_FUNCTION_PARAM_PASSTHRU);
|
||||
|
@ -3524,6 +3636,16 @@ PHP_FUNCTION(xcache_inc)
|
|||
/* }}} */
|
||||
/* {{{ proto int xcache_dec(string name [, int value [, int ttl]])
|
||||
Decrease an int counter in cache by specified name, create it if not exists */
|
||||
#ifdef ZEND_BEGIN_ARG_INFO_EX
|
||||
ZEND_BEGIN_ARG_INFO_EX(arginfo_xcache_dec, 0, 0, 1)
|
||||
ZEND_ARG_INFO(0, prefix)
|
||||
ZEND_ARG_INFO(0, value)
|
||||
ZEND_ARG_INFO(0, ttl)
|
||||
ZEND_END_ARG_INFO()
|
||||
#else
|
||||
static unsigned char arginfo_xcache_dec[] = { 3, BYREF_NONE, BYREF_NONE, BYREF_NONE };
|
||||
#endif
|
||||
|
||||
PHP_FUNCTION(xcache_dec)
|
||||
{
|
||||
xc_var_inc_dec(-1, INTERNAL_FUNCTION_PARAM_PASSTHRU);
|
||||
|
@ -3531,20 +3653,20 @@ PHP_FUNCTION(xcache_dec)
|
|||
/* }}} */
|
||||
static zend_function_entry xcache_cacher_functions[] = /* {{{ */
|
||||
{
|
||||
PHP_FE(xcache_count, NULL)
|
||||
PHP_FE(xcache_info, NULL)
|
||||
PHP_FE(xcache_list, NULL)
|
||||
PHP_FE(xcache_clear_cache, NULL)
|
||||
PHP_FE(xcache_enable_cache, NULL)
|
||||
PHP_FE(xcache_admin_namespace, NULL)
|
||||
PHP_FE(xcache_set_namespace, NULL)
|
||||
PHP_FE(xcache_get, NULL)
|
||||
PHP_FE(xcache_set, NULL)
|
||||
PHP_FE(xcache_isset, NULL)
|
||||
PHP_FE(xcache_unset, NULL)
|
||||
PHP_FE(xcache_unset_by_prefix, NULL)
|
||||
PHP_FE(xcache_inc, NULL)
|
||||
PHP_FE(xcache_dec, NULL)
|
||||
PHP_FE(xcache_count, arginfo_xcache_count)
|
||||
PHP_FE(xcache_info, arginfo_xcache_info)
|
||||
PHP_FE(xcache_list, arginfo_xcache_list)
|
||||
PHP_FE(xcache_clear_cache, arginfo_xcache_clear_cache)
|
||||
PHP_FE(xcache_enable_cache, arginfo_xcache_enable_cache)
|
||||
PHP_FE(xcache_admin_namespace, arginfo_xcache_admin_namespace)
|
||||
PHP_FE(xcache_set_namespace, arginfo_xcache_set_namespace)
|
||||
PHP_FE(xcache_get, arginfo_xcache_get)
|
||||
PHP_FE(xcache_set, arginfo_xcache_set)
|
||||
PHP_FE(xcache_isset, arginfo_xcache_isset)
|
||||
PHP_FE(xcache_unset, arginfo_xcache_unset)
|
||||
PHP_FE(xcache_unset_by_prefix, arginfo_xcache_unset_by_prefix)
|
||||
PHP_FE(xcache_inc, arginfo_xcache_inc)
|
||||
PHP_FE(xcache_dec, arginfo_xcache_dec)
|
||||
PHP_FE_END
|
||||
};
|
||||
/* }}} */
|
||||
|
|
|
@ -484,6 +484,14 @@ static void xc_coverager_handle_ext_stmt(zend_op_array *op_array, zend_uchar op)
|
|||
/* {{{ proto array xcache_coverager_decode(string data)
|
||||
* decode specified data which is saved by auto dumper to array
|
||||
*/
|
||||
#ifdef ZEND_BEGIN_ARG_INFO_EX
|
||||
ZEND_BEGIN_ARG_INFO_EX(arginfo_xcache_coverager_decode, 0, 0, 1)
|
||||
ZEND_ARG_INFO(0, data)
|
||||
ZEND_END_ARG_INFO()
|
||||
#else
|
||||
static unsigned char arginfo_xcache_coverager_decode[] = { 1, BYREF_NONE };
|
||||
#endif
|
||||
|
||||
PHP_FUNCTION(xcache_coverager_decode)
|
||||
{
|
||||
char *str;
|
||||
|
@ -514,6 +522,14 @@ PHP_FUNCTION(xcache_coverager_decode)
|
|||
/* {{{ proto void xcache_coverager_start([bool clean = true])
|
||||
* starts coverager data collecting
|
||||
*/
|
||||
#ifdef ZEND_BEGIN_ARG_INFO_EX
|
||||
ZEND_BEGIN_ARG_INFO_EX(arginfo_xcache_coverager_start, 0, 0, 0)
|
||||
ZEND_ARG_INFO(0, clean)
|
||||
ZEND_END_ARG_INFO()
|
||||
#else
|
||||
static unsigned char arginfo_xcache_coverager_start[] = { 1, BYREF_NONE };
|
||||
#endif
|
||||
|
||||
PHP_FUNCTION(xcache_coverager_start)
|
||||
{
|
||||
zend_bool clean = 1;
|
||||
|
@ -537,6 +553,14 @@ PHP_FUNCTION(xcache_coverager_start)
|
|||
/* {{{ proto void xcache_coverager_stop([bool clean = false])
|
||||
* stop coverager data collecting
|
||||
*/
|
||||
#ifdef ZEND_BEGIN_ARG_INFO_EX
|
||||
ZEND_BEGIN_ARG_INFO_EX(arginfo_xcache_coverager_stop, 0, 0, 0)
|
||||
ZEND_ARG_INFO(0, clean)
|
||||
ZEND_END_ARG_INFO()
|
||||
#else
|
||||
static unsigned char arginfo_xcache_coverager_stop[] = { 1, BYREF_NONE };
|
||||
#endif
|
||||
|
||||
PHP_FUNCTION(xcache_coverager_stop)
|
||||
{
|
||||
zend_bool clean = 0;
|
||||
|
@ -554,6 +578,13 @@ PHP_FUNCTION(xcache_coverager_stop)
|
|||
/* {{{ proto array xcache_coverager_get([bool clean = false])
|
||||
* get coverager data collected
|
||||
*/
|
||||
#ifdef ZEND_BEGIN_ARG_INFO_EX
|
||||
ZEND_BEGIN_ARG_INFO_EX(arginfo_xcache_coverager_get, 0, 0, 0)
|
||||
ZEND_ARG_INFO(0, clean)
|
||||
ZEND_END_ARG_INFO()
|
||||
#else
|
||||
static unsigned char arginfo_xcache_coverager_get[] = { 1, BYREF_NONE };
|
||||
#endif
|
||||
PHP_FUNCTION(xcache_coverager_get)
|
||||
{
|
||||
zend_bool clean = 0;
|
||||
|
@ -569,10 +600,10 @@ PHP_FUNCTION(xcache_coverager_get)
|
|||
/* }}} */
|
||||
static zend_function_entry xcache_coverager_functions[] = /* {{{ */
|
||||
{
|
||||
PHP_FE(xcache_coverager_decode, NULL)
|
||||
PHP_FE(xcache_coverager_start, NULL)
|
||||
PHP_FE(xcache_coverager_stop, NULL)
|
||||
PHP_FE(xcache_coverager_get, NULL)
|
||||
PHP_FE(xcache_coverager_decode, arginfo_xcache_coverager_decode)
|
||||
PHP_FE(xcache_coverager_start, arginfo_xcache_coverager_start)
|
||||
PHP_FE(xcache_coverager_stop, arginfo_xcache_coverager_stop)
|
||||
PHP_FE(xcache_coverager_get, arginfo_xcache_coverager_get)
|
||||
PHP_FE_END
|
||||
};
|
||||
/* }}} */
|
||||
|
|
|
@ -194,6 +194,14 @@ void xc_dasm_file(zval *output, const char *filename TSRMLS_DC) /* {{{ */
|
|||
|
||||
/* {{{ proto array xcache_dasm_file(string filename)
|
||||
Disassemble file into opcode array by filename */
|
||||
#ifdef ZEND_BEGIN_ARG_INFO_EX
|
||||
ZEND_BEGIN_ARG_INFO_EX(arginfo_xcache_dasm_file, 0, 0, 1)
|
||||
ZEND_ARG_INFO(0, filename)
|
||||
ZEND_END_ARG_INFO()
|
||||
#else
|
||||
static unsigned char arginfo_xcache_dasm_file[] = { 1, BYREF_NONE };
|
||||
#endif
|
||||
|
||||
PHP_FUNCTION(xcache_dasm_file)
|
||||
{
|
||||
char *filename;
|
||||
|
@ -209,6 +217,14 @@ PHP_FUNCTION(xcache_dasm_file)
|
|||
/* }}} */
|
||||
/* {{{ proto array xcache_dasm_string(string code)
|
||||
Disassemble php code into opcode array */
|
||||
#ifdef ZEND_BEGIN_ARG_INFO_EX
|
||||
ZEND_BEGIN_ARG_INFO_EX(arginfo_xcache_dasm_string, 0, 0, 1)
|
||||
ZEND_ARG_INFO(0, code)
|
||||
ZEND_END_ARG_INFO()
|
||||
#else
|
||||
static unsigned char arginfo_xcache_dasm_string[] = { 1, BYREF_NONE };
|
||||
#endif
|
||||
|
||||
PHP_FUNCTION(xcache_dasm_string)
|
||||
{
|
||||
zval *code;
|
||||
|
@ -232,8 +248,8 @@ static PHP_MINFO_FUNCTION(xcache_disassembler)
|
|||
/* }}} */
|
||||
static zend_function_entry xcache_disassembler_functions[] = /* {{{ */
|
||||
{
|
||||
PHP_FE(xcache_dasm_file, NULL)
|
||||
PHP_FE(xcache_dasm_string, NULL)
|
||||
PHP_FE(xcache_dasm_file, arginfo_xcache_dasm_file)
|
||||
PHP_FE(xcache_dasm_string, arginfo_xcache_dasm_string)
|
||||
PHP_FE_END
|
||||
};
|
||||
/* }}} */
|
||||
|
|
494
xcache.c
494
xcache.c
|
@ -176,6 +176,281 @@ void xc_shutdown_globals(zend_xcache_globals* xcache_globals TSRMLS_DC)
|
|||
}
|
||||
/* }}} */
|
||||
|
||||
#ifdef HAVE_XCACHE_DPRINT
|
||||
/* {{{ proto bool xcache_dprint(mixed value)
|
||||
Prints internal struct of an zval (debug only) */
|
||||
#include "xc_processor.h"
|
||||
|
||||
#ifdef ZEND_BEGIN_ARG_INFO_EX
|
||||
ZEND_BEGIN_ARG_INFO_EX(arginfo_xcache_dprint, 0, 0, 1)
|
||||
ZEND_ARG_INFO(0, value)
|
||||
ZEND_END_ARG_INFO()
|
||||
#else
|
||||
static unsigned char arginfo_xcache_dprint[] = { 1, BYREF_NONE };
|
||||
#endif
|
||||
|
||||
PHP_FUNCTION(xcache_dprint)
|
||||
{
|
||||
zval *value;
|
||||
|
||||
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "z", &value) == FAILURE) {
|
||||
return;
|
||||
}
|
||||
xc_dprint_zval(value, 0 TSRMLS_CC);
|
||||
}
|
||||
/* }}} */
|
||||
#endif
|
||||
#ifdef HAVE_XCACHE_ASSEMBLER
|
||||
/* {{{ proto string xcache_asm(string filename)
|
||||
*/
|
||||
PHP_FUNCTION(xcache_asm)
|
||||
{
|
||||
}
|
||||
/* }}} */
|
||||
#endif
|
||||
#ifdef HAVE_XCACHE_ENCODER
|
||||
/* {{{ proto string xcache_encode(string filename)
|
||||
Encode php file into XCache opcode encoded format */
|
||||
PHP_FUNCTION(xcache_encode)
|
||||
{
|
||||
}
|
||||
/* }}} */
|
||||
#endif
|
||||
#ifdef HAVE_XCACHE_DECODER
|
||||
/* {{{ proto bool xcache_decode_file(string filename)
|
||||
Decode(load) opcode from XCache encoded format file */
|
||||
PHP_FUNCTION(xcache_decode_file)
|
||||
{
|
||||
}
|
||||
/* }}} */
|
||||
/* {{{ proto bool xcache_decode_string(string data)
|
||||
Decode(load) opcode from XCache encoded format data */
|
||||
PHP_FUNCTION(xcache_decode_string)
|
||||
{
|
||||
}
|
||||
/* }}} */
|
||||
#endif
|
||||
/* {{{ xc_call_getter */
|
||||
typedef const char *(xc_name_getter_t)(zend_uchar type);
|
||||
static void xc_call_getter(xc_name_getter_t getter, int count, INTERNAL_FUNCTION_PARAMETERS)
|
||||
{
|
||||
long spec;
|
||||
const char *name;
|
||||
|
||||
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l", &spec) == FAILURE) {
|
||||
return;
|
||||
}
|
||||
if (spec >= 0 && spec < count) {
|
||||
name = getter((zend_uchar) spec);
|
||||
if (name) {
|
||||
/* RETURN_STRING */
|
||||
int len = (int) strlen(name);
|
||||
return_value->value.str.len = len;
|
||||
return_value->value.str.val = estrndup(name, len);
|
||||
return_value->type = IS_STRING;
|
||||
return;
|
||||
}
|
||||
}
|
||||
RETURN_NULL();
|
||||
}
|
||||
/* }}} */
|
||||
/* {{{ proto string xcache_get_op_type(int op_type) */
|
||||
#ifdef ZEND_BEGIN_ARG_INFO_EX
|
||||
ZEND_BEGIN_ARG_INFO_EX(arginfo_xcache_get_op_type, 0, 0, 1)
|
||||
ZEND_ARG_INFO(0, op_type)
|
||||
ZEND_END_ARG_INFO()
|
||||
#else
|
||||
static unsigned char arginfo_xcache_get_op_type[] = { 1, BYREF_NONE };
|
||||
#endif
|
||||
|
||||
PHP_FUNCTION(xcache_get_op_type)
|
||||
{
|
||||
xc_call_getter(xc_get_op_type, xc_get_op_type_count(), INTERNAL_FUNCTION_PARAM_PASSTHRU);
|
||||
}
|
||||
/* }}} */
|
||||
/* {{{ proto string xcache_get_data_type(int type) */
|
||||
#ifdef ZEND_BEGIN_ARG_INFO_EX
|
||||
ZEND_BEGIN_ARG_INFO_EX(arginfo_xcache_get_data_type, 0, 0, 1)
|
||||
ZEND_ARG_INFO(0, type)
|
||||
ZEND_END_ARG_INFO()
|
||||
#else
|
||||
static unsigned char arginfo_xcache_get_data_type[] = { 1, BYREF_NONE };
|
||||
#endif
|
||||
|
||||
PHP_FUNCTION(xcache_get_data_type)
|
||||
{
|
||||
xc_call_getter(xc_get_data_type, xc_get_data_type_count(), INTERNAL_FUNCTION_PARAM_PASSTHRU);
|
||||
}
|
||||
/* }}} */
|
||||
/* {{{ proto string xcache_get_opcode(int opcode) */
|
||||
#ifdef ZEND_BEGIN_ARG_INFO_EX
|
||||
ZEND_BEGIN_ARG_INFO_EX(arginfo_xcache_get_opcode, 0, 0, 1)
|
||||
ZEND_ARG_INFO(0, opcode)
|
||||
ZEND_END_ARG_INFO()
|
||||
#else
|
||||
static unsigned char arginfo_xcache_get_opcode[] = { 1, BYREF_NONE };
|
||||
#endif
|
||||
|
||||
PHP_FUNCTION(xcache_get_opcode)
|
||||
{
|
||||
xc_call_getter(xc_get_opcode, xc_get_opcode_count(), INTERNAL_FUNCTION_PARAM_PASSTHRU);
|
||||
}
|
||||
/* }}} */
|
||||
/* {{{ proto string xcache_get_op_spec(int op_type) */
|
||||
#ifdef ZEND_BEGIN_ARG_INFO_EX
|
||||
ZEND_BEGIN_ARG_INFO_EX(arginfo_xcache_get_op_spec, 0, 0, 1)
|
||||
ZEND_ARG_INFO(0, op_type)
|
||||
ZEND_END_ARG_INFO()
|
||||
#else
|
||||
static unsigned char arginfo_xcache_get_op_spec[] = { 1, BYREF_NONE };
|
||||
#endif
|
||||
|
||||
PHP_FUNCTION(xcache_get_op_spec)
|
||||
{
|
||||
xc_call_getter(xc_get_op_spec, xc_get_op_spec_count(), INTERNAL_FUNCTION_PARAM_PASSTHRU);
|
||||
}
|
||||
/* }}} */
|
||||
/* {{{ proto string xcache_get_opcode_spec(int opcode) */
|
||||
#ifdef ZEND_BEGIN_ARG_INFO_EX
|
||||
ZEND_BEGIN_ARG_INFO_EX(arginfo_xcache_get_opcode_spec, 0, 0, 1)
|
||||
ZEND_ARG_INFO(0, opcode)
|
||||
ZEND_END_ARG_INFO()
|
||||
#else
|
||||
static unsigned char arginfo_xcache_get_opcode_spec[] = { 1, BYREF_NONE };
|
||||
#endif
|
||||
|
||||
PHP_FUNCTION(xcache_get_opcode_spec)
|
||||
{
|
||||
long spec;
|
||||
const xc_opcode_spec_t *opspec;
|
||||
|
||||
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l", &spec) == FAILURE) {
|
||||
return;
|
||||
}
|
||||
if ((zend_uchar) spec <= xc_get_opcode_spec_count()) {
|
||||
opspec = xc_get_opcode_spec((zend_uchar) spec);
|
||||
if (opspec) {
|
||||
array_init(return_value);
|
||||
add_assoc_long_ex(return_value, XCACHE_STRS("ext"), opspec->ext);
|
||||
add_assoc_long_ex(return_value, XCACHE_STRS("op1"), opspec->op1);
|
||||
add_assoc_long_ex(return_value, XCACHE_STRS("op2"), opspec->op2);
|
||||
add_assoc_long_ex(return_value, XCACHE_STRS("res"), opspec->res);
|
||||
return;
|
||||
}
|
||||
}
|
||||
RETURN_NULL();
|
||||
}
|
||||
/* }}} */
|
||||
/* {{{ proto mixed xcache_get_special_value(zval value)
|
||||
XCache internal use only: For decompiler to get static value with type fixed */
|
||||
#ifdef ZEND_BEGIN_ARG_INFO_EX
|
||||
ZEND_BEGIN_ARG_INFO_EX(arginfo_xcache_get_special_value, 0, 0, 1)
|
||||
ZEND_ARG_INFO(0, value)
|
||||
ZEND_END_ARG_INFO()
|
||||
#else
|
||||
static unsigned char arginfo_xcache_get_special_value[] = { 1, BYREF_NONE };
|
||||
#endif
|
||||
|
||||
PHP_FUNCTION(xcache_get_special_value)
|
||||
{
|
||||
zval *value;
|
||||
|
||||
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "z", &value) == FAILURE) {
|
||||
return;
|
||||
}
|
||||
|
||||
switch ((Z_TYPE_P(value) & IS_CONSTANT_TYPE_MASK)) {
|
||||
case IS_CONSTANT:
|
||||
*return_value = *value;
|
||||
zval_copy_ctor(return_value);
|
||||
return_value->type = UNISW(IS_STRING, UG(unicode) ? IS_UNICODE : IS_STRING);
|
||||
break;
|
||||
|
||||
case IS_CONSTANT_ARRAY:
|
||||
*return_value = *value;
|
||||
zval_copy_ctor(return_value);
|
||||
return_value->type = IS_ARRAY;
|
||||
break;
|
||||
|
||||
default:
|
||||
if ((Z_TYPE_P(value) & ~IS_CONSTANT_TYPE_MASK)) {
|
||||
*return_value = *value;
|
||||
zval_copy_ctor(return_value);
|
||||
return_value->type &= IS_CONSTANT_TYPE_MASK;
|
||||
}
|
||||
else {
|
||||
RETURN_NULL();
|
||||
}
|
||||
}
|
||||
}
|
||||
/* }}} */
|
||||
/* {{{ proto int xcache_get_type(zval value)
|
||||
XCache internal use only for disassembler to get variable type in engine level */
|
||||
#ifdef ZEND_BEGIN_ARG_INFO_EX
|
||||
ZEND_BEGIN_ARG_INFO_EX(arginfo_xcache_get_type, 0, 0, 1)
|
||||
ZEND_ARG_INFO(0, value)
|
||||
ZEND_END_ARG_INFO()
|
||||
#else
|
||||
static unsigned char arginfo_xcache_get_type[] = { 1, BYREF_NONE };
|
||||
#endif
|
||||
|
||||
PHP_FUNCTION(xcache_get_type)
|
||||
{
|
||||
zval *value;
|
||||
|
||||
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "z", &value) == FAILURE) {
|
||||
return;
|
||||
}
|
||||
|
||||
RETURN_LONG(Z_TYPE_P(value));
|
||||
}
|
||||
/* }}} */
|
||||
/* {{{ proto string xcache_coredump() */
|
||||
#ifdef ZEND_BEGIN_ARG_INFO_EX
|
||||
ZEND_BEGIN_ARG_INFO_EX(arginfo_xcache_coredump, 0, 0, 0)
|
||||
ZEND_END_ARG_INFO()
|
||||
#else
|
||||
static unsigned char arginfo_xcache_coredump[] = { 1, BYREF_NONE };
|
||||
#endif
|
||||
|
||||
PHP_FUNCTION(xcache_coredump)
|
||||
{
|
||||
if (xc_test) {
|
||||
char *null_ptr = NULL;
|
||||
*null_ptr = 0;
|
||||
raise(SIGSEGV);
|
||||
}
|
||||
else {
|
||||
php_error_docref(NULL TSRMLS_CC, E_WARNING, "xcache.test must be enabled to test xcache_coredump()");
|
||||
}
|
||||
}
|
||||
/* }}} */
|
||||
/* {{{ proto string xcache_is_autoglobal(string name) */
|
||||
#ifdef ZEND_BEGIN_ARG_INFO_EX
|
||||
ZEND_BEGIN_ARG_INFO_EX(arginfo_xcache_is_autoglobal, 0, 0, 1)
|
||||
ZEND_ARG_INFO(0, name)
|
||||
ZEND_END_ARG_INFO()
|
||||
#else
|
||||
static unsigned char arginfo_xcache_is_autoglobal[] = { 1, BYREF_NONE };
|
||||
#endif
|
||||
|
||||
PHP_FUNCTION(xcache_is_autoglobal)
|
||||
{
|
||||
zval *name;
|
||||
|
||||
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "z", &name) == FAILURE) {
|
||||
return;
|
||||
}
|
||||
|
||||
#ifdef IS_UNICODE
|
||||
convert_to_unicode(name);
|
||||
#else
|
||||
convert_to_string(name);
|
||||
#endif
|
||||
|
||||
RETURN_BOOL(zend_u_hash_exists(CG(auto_globals), UG(unicode), Z_STRVAL_P(name), Z_STRLEN_P(name) + 1));
|
||||
}
|
||||
/* }}} */
|
||||
/* {{{ proto int xcache_get_refcount(mixed &variable)
|
||||
XCache internal uses only: Get reference count of referenced variable */
|
||||
#ifdef ZEND_BEGIN_ARG_INFO_EX
|
||||
|
@ -236,206 +511,11 @@ PHP_FUNCTION(xcache_get_isref)
|
|||
RETURN_BOOL(Z_ISREF(*variable) && Z_REFCOUNT(*variable) >= 3);
|
||||
}
|
||||
/* }}} */
|
||||
#ifdef HAVE_XCACHE_DPRINT
|
||||
/* {{{ proto bool xcache_dprint(mixed value)
|
||||
Prints variable (or value) internal struct (debug only) */
|
||||
#include "xc_processor.h"
|
||||
PHP_FUNCTION(xcache_dprint)
|
||||
{
|
||||
zval *value;
|
||||
|
||||
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "z", &value) == FAILURE) {
|
||||
return;
|
||||
}
|
||||
xc_dprint_zval(value, 0 TSRMLS_CC);
|
||||
}
|
||||
/* }}} */
|
||||
#endif
|
||||
/* {{{ proto string xcache_asm(string filename)
|
||||
*/
|
||||
#ifdef HAVE_XCACHE_ASSEMBLER
|
||||
PHP_FUNCTION(xcache_asm)
|
||||
{
|
||||
}
|
||||
#endif
|
||||
/* }}} */
|
||||
/* {{{ proto string xcache_encode(string filename)
|
||||
Encode php file into XCache opcode encoded format */
|
||||
#ifdef HAVE_XCACHE_ENCODER
|
||||
PHP_FUNCTION(xcache_encode)
|
||||
{
|
||||
}
|
||||
#endif
|
||||
/* }}} */
|
||||
/* {{{ proto bool xcache_decode_file(string filename)
|
||||
Decode(load) opcode from XCache encoded format file */
|
||||
#ifdef HAVE_XCACHE_DECODER
|
||||
PHP_FUNCTION(xcache_decode_file)
|
||||
{
|
||||
}
|
||||
#endif
|
||||
/* }}} */
|
||||
/* {{{ proto bool xcache_decode_string(string data)
|
||||
Decode(load) opcode from XCache encoded format data */
|
||||
#ifdef HAVE_XCACHE_DECODER
|
||||
PHP_FUNCTION(xcache_decode_string)
|
||||
{
|
||||
}
|
||||
#endif
|
||||
/* }}} */
|
||||
/* {{{ xc_call_getter */
|
||||
typedef const char *(xc_name_getter_t)(zend_uchar type);
|
||||
static void xc_call_getter(xc_name_getter_t getter, int count, INTERNAL_FUNCTION_PARAMETERS)
|
||||
{
|
||||
long spec;
|
||||
const char *name;
|
||||
|
||||
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l", &spec) == FAILURE) {
|
||||
return;
|
||||
}
|
||||
if (spec >= 0 && spec < count) {
|
||||
name = getter((zend_uchar) spec);
|
||||
if (name) {
|
||||
/* RETURN_STRING */
|
||||
int len = (int) strlen(name);
|
||||
return_value->value.str.len = len;
|
||||
return_value->value.str.val = estrndup(name, len);
|
||||
return_value->type = IS_STRING;
|
||||
return;
|
||||
}
|
||||
}
|
||||
RETURN_NULL();
|
||||
}
|
||||
/* }}} */
|
||||
/* {{{ proto string xcache_get_op_type(int op_type) */
|
||||
PHP_FUNCTION(xcache_get_op_type)
|
||||
{
|
||||
xc_call_getter(xc_get_op_type, xc_get_op_type_count(), INTERNAL_FUNCTION_PARAM_PASSTHRU);
|
||||
}
|
||||
/* }}} */
|
||||
/* {{{ proto string xcache_get_data_type(int type) */
|
||||
PHP_FUNCTION(xcache_get_data_type)
|
||||
{
|
||||
xc_call_getter(xc_get_data_type, xc_get_data_type_count(), INTERNAL_FUNCTION_PARAM_PASSTHRU);
|
||||
}
|
||||
/* }}} */
|
||||
/* {{{ proto string xcache_get_opcode(int opcode) */
|
||||
PHP_FUNCTION(xcache_get_opcode)
|
||||
{
|
||||
xc_call_getter(xc_get_opcode, xc_get_opcode_count(), INTERNAL_FUNCTION_PARAM_PASSTHRU);
|
||||
}
|
||||
/* }}} */
|
||||
/* {{{ proto string xcache_get_op_spec(int op_type) */
|
||||
PHP_FUNCTION(xcache_get_op_spec)
|
||||
{
|
||||
xc_call_getter(xc_get_op_spec, xc_get_op_spec_count(), INTERNAL_FUNCTION_PARAM_PASSTHRU);
|
||||
}
|
||||
/* }}} */
|
||||
/* {{{ proto string xcache_get_opcode_spec(int opcode) */
|
||||
PHP_FUNCTION(xcache_get_opcode_spec)
|
||||
{
|
||||
long spec;
|
||||
const xc_opcode_spec_t *opspec;
|
||||
|
||||
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l", &spec) == FAILURE) {
|
||||
return;
|
||||
}
|
||||
if ((zend_uchar) spec <= xc_get_opcode_spec_count()) {
|
||||
opspec = xc_get_opcode_spec((zend_uchar) spec);
|
||||
if (opspec) {
|
||||
array_init(return_value);
|
||||
add_assoc_long_ex(return_value, XCACHE_STRS("ext"), opspec->ext);
|
||||
add_assoc_long_ex(return_value, XCACHE_STRS("op1"), opspec->op1);
|
||||
add_assoc_long_ex(return_value, XCACHE_STRS("op2"), opspec->op2);
|
||||
add_assoc_long_ex(return_value, XCACHE_STRS("res"), opspec->res);
|
||||
return;
|
||||
}
|
||||
}
|
||||
RETURN_NULL();
|
||||
}
|
||||
/* }}} */
|
||||
/* {{{ proto mixed xcache_get_special_value(zval value)
|
||||
XCache internal use only: For decompiler to get static value with type fixed */
|
||||
PHP_FUNCTION(xcache_get_special_value)
|
||||
{
|
||||
zval *value;
|
||||
|
||||
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "z", &value) == FAILURE) {
|
||||
return;
|
||||
}
|
||||
|
||||
switch ((Z_TYPE_P(value) & IS_CONSTANT_TYPE_MASK)) {
|
||||
case IS_CONSTANT:
|
||||
*return_value = *value;
|
||||
zval_copy_ctor(return_value);
|
||||
return_value->type = UNISW(IS_STRING, UG(unicode) ? IS_UNICODE : IS_STRING);
|
||||
break;
|
||||
|
||||
case IS_CONSTANT_ARRAY:
|
||||
*return_value = *value;
|
||||
zval_copy_ctor(return_value);
|
||||
return_value->type = IS_ARRAY;
|
||||
break;
|
||||
|
||||
default:
|
||||
if ((Z_TYPE_P(value) & ~IS_CONSTANT_TYPE_MASK)) {
|
||||
*return_value = *value;
|
||||
zval_copy_ctor(return_value);
|
||||
return_value->type &= IS_CONSTANT_TYPE_MASK;
|
||||
}
|
||||
else {
|
||||
RETURN_NULL();
|
||||
}
|
||||
}
|
||||
}
|
||||
/* }}} */
|
||||
/* {{{ proto int xcache_get_type(zval value)
|
||||
XCache internal use only for disassembler to get variable type in engine level */
|
||||
PHP_FUNCTION(xcache_get_type)
|
||||
{
|
||||
zval *value;
|
||||
|
||||
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "z", &value) == FAILURE) {
|
||||
return;
|
||||
}
|
||||
|
||||
RETURN_LONG(Z_TYPE_P(value));
|
||||
}
|
||||
/* }}} */
|
||||
/* {{{ proto string xcache_coredump(int op_type) */
|
||||
PHP_FUNCTION(xcache_coredump)
|
||||
{
|
||||
if (xc_test) {
|
||||
char *null_ptr = NULL;
|
||||
*null_ptr = 0;
|
||||
raise(SIGSEGV);
|
||||
}
|
||||
else {
|
||||
php_error_docref(NULL TSRMLS_CC, E_WARNING, "xcache.test must be enabled to test xcache_coredump()");
|
||||
}
|
||||
}
|
||||
/* }}} */
|
||||
/* {{{ proto string xcache_is_autoglobal(string name) */
|
||||
PHP_FUNCTION(xcache_is_autoglobal)
|
||||
{
|
||||
zval *name;
|
||||
|
||||
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "z", &name) == FAILURE) {
|
||||
return;
|
||||
}
|
||||
|
||||
#ifdef IS_UNICODE
|
||||
convert_to_unicode(name);
|
||||
#else
|
||||
convert_to_string(name);
|
||||
#endif
|
||||
|
||||
RETURN_BOOL(zend_u_hash_exists(CG(auto_globals), UG(unicode), Z_STRVAL_P(name), Z_STRLEN_P(name) + 1));
|
||||
}
|
||||
/* }}} */
|
||||
static zend_function_entry xcache_functions[] = /* {{{ */
|
||||
{
|
||||
PHP_FE(xcache_coredump, NULL)
|
||||
#ifdef HAVE_XCACHE_DPRINT
|
||||
PHP_FE(xcache_dprint, arginfo_xcache_dprint)
|
||||
#endif
|
||||
#ifdef HAVE_XCACHE_ASSEMBLER
|
||||
PHP_FE(xcache_asm, NULL)
|
||||
#endif
|
||||
|
@ -446,19 +526,17 @@ static zend_function_entry xcache_functions[] = /* {{{ */
|
|||
PHP_FE(xcache_decode_file, NULL)
|
||||
PHP_FE(xcache_decode_string, NULL)
|
||||
#endif
|
||||
PHP_FE(xcache_get_special_value, NULL)
|
||||
PHP_FE(xcache_get_type, NULL)
|
||||
PHP_FE(xcache_get_op_type, NULL)
|
||||
PHP_FE(xcache_get_data_type, NULL)
|
||||
PHP_FE(xcache_get_opcode, NULL)
|
||||
PHP_FE(xcache_get_opcode_spec, NULL)
|
||||
PHP_FE(xcache_is_autoglobal, NULL)
|
||||
PHP_FE(xcache_get_special_value, arginfo_xcache_get_special_value)
|
||||
PHP_FE(xcache_get_type, arginfo_xcache_get_type)
|
||||
PHP_FE(xcache_get_op_type, arginfo_xcache_get_op_type)
|
||||
PHP_FE(xcache_get_data_type, arginfo_xcache_get_data_type)
|
||||
PHP_FE(xcache_get_opcode, arginfo_xcache_get_opcode)
|
||||
PHP_FE(xcache_get_opcode_spec, arginfo_xcache_get_opcode_spec)
|
||||
PHP_FE(xcache_coredump, arginfo_xcache_coredump)
|
||||
PHP_FE(xcache_is_autoglobal, arginfo_xcache_is_autoglobal)
|
||||
PHP_FE(xcache_get_refcount, arginfo_xcache_get_refcount)
|
||||
PHP_FE(xcache_get_cowcount, arginfo_xcache_get_cowcount)
|
||||
PHP_FE(xcache_get_isref, arginfo_xcache_get_isref)
|
||||
#ifdef HAVE_XCACHE_DPRINT
|
||||
PHP_FE(xcache_dprint, NULL)
|
||||
#endif
|
||||
PHP_FE_END
|
||||
};
|
||||
/* }}} */
|
||||
|
|
Loading…
Reference in New Issue