2006-05-09 10:58:38 +00:00
|
|
|
#include "php.h"
|
2006-12-08 16:11:19 +00:00
|
|
|
#include "xcache.h"
|
|
|
|
|
|
|
|
#ifdef DEBUG
|
|
|
|
# define IFDEBUG(x) (x)
|
2007-02-12 07:48:57 +00:00
|
|
|
int xc_vtrace(const char *fmt, va_list args);
|
2006-12-08 16:11:19 +00:00
|
|
|
int xc_trace(const char *fmt, ...) ZEND_ATTRIBUTE_PTR_FORMAT(printf, 1, 2);
|
2007-02-12 07:48:57 +00:00
|
|
|
|
|
|
|
# ifdef ZEND_WIN32
|
|
|
|
static inline int TRACE(const char *fmt, ...)
|
|
|
|
{
|
|
|
|
va_list args;
|
|
|
|
int ret;
|
|
|
|
|
|
|
|
va_start(args, fmt);
|
|
|
|
ret = xc_vtrace(fmt, args);
|
|
|
|
va_end(args);
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
# else
|
|
|
|
# define TRACE(fmt, ...) \
|
|
|
|
xc_trace("%s:%d: " fmt "\r\n", __FILE__, __LINE__, __VA_ARGS__)
|
|
|
|
# endif /* ZEND_WIN32 */
|
2006-12-08 16:11:19 +00:00
|
|
|
# undef NDEBUG
|
|
|
|
# undef inline
|
|
|
|
# define inline
|
2007-02-12 07:48:57 +00:00
|
|
|
#else /* DEBUG */
|
|
|
|
|
|
|
|
# ifdef ZEND_WIN32
|
2007-02-12 08:01:44 +00:00
|
|
|
static inline int TRACE_DUMMY(const char *fmt, ...)
|
2007-02-12 07:48:57 +00:00
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
2007-02-12 08:02:19 +00:00
|
|
|
# define TRACE 1 ? 0 : TRACE_DUMMY
|
2007-02-12 07:48:57 +00:00
|
|
|
# else
|
|
|
|
# define TRACE(fmt, ...) do { } while (0)
|
|
|
|
# endif /* ZEND_WIN32 */
|
|
|
|
|
2006-12-08 16:11:19 +00:00
|
|
|
# define IFDEBUG(x) do { } while (0)
|
|
|
|
# ifndef NDEBUG
|
|
|
|
# define NDEBUG
|
|
|
|
# endif
|
2007-02-12 07:48:57 +00:00
|
|
|
#endif /* DEBUG */
|
2006-12-08 16:11:19 +00:00
|
|
|
#include <assert.h>
|
2006-05-09 10:58:38 +00:00
|
|
|
|
|
|
|
typedef struct {
|
|
|
|
int alloc;
|
|
|
|
zend_op_array *op_array;
|
|
|
|
HashTable *function_table;
|
|
|
|
HashTable *class_table;
|
|
|
|
} xc_compile_result_t;
|
|
|
|
|
|
|
|
xc_compile_result_t *xc_compile_result_init(xc_compile_result_t *cr,
|
|
|
|
zend_op_array *op_array,
|
|
|
|
HashTable *function_table,
|
|
|
|
HashTable *class_table);
|
|
|
|
void xc_compile_result_free(xc_compile_result_t *cr);
|
|
|
|
xc_compile_result_t *xc_compile_result_init_cur(xc_compile_result_t *cr, zend_op_array *op_array TSRMLS_DC);
|
|
|
|
/* apply func */
|
|
|
|
int xc_apply_function(zend_function *zf, apply_func_t applyer TSRMLS_DC);
|
|
|
|
int xc_apply_class(zend_class_entry *ce, apply_func_t applyer TSRMLS_DC);
|
|
|
|
int xc_apply_op_array(xc_compile_result_t *cr, apply_func_t applyer TSRMLS_DC);
|
|
|
|
|
|
|
|
int xc_undo_pass_two(zend_op_array *op_array TSRMLS_DC);
|
|
|
|
int xc_redo_pass_two(zend_op_array *op_array TSRMLS_DC);
|
|
|
|
int xc_fix_opcode(zend_op_array *op_array TSRMLS_DC);
|
|
|
|
int xc_undo_fix_opcode(zend_op_array *op_array TSRMLS_DC);
|
|
|
|
zend_uchar xc_get_fixed_opcode(zend_uchar opcode, int line);
|
|
|
|
|
2006-10-04 00:38:45 +00:00
|
|
|
int xc_foreach_early_binding_class(zend_op_array *op_array, void (*callback)(zend_op *opline, int oplineno, void *data TSRMLS_DC), void *data TSRMLS_DC);
|
|
|
|
|
2006-05-09 10:58:38 +00:00
|
|
|
/* installer */
|
2006-07-16 11:07:57 +00:00
|
|
|
#ifdef HAVE_XCACHE_CONSTANT
|
2008-01-05 04:45:48 +00:00
|
|
|
void xc_install_constant(char *filename, zend_constant *constant, zend_uchar type, zstr key, uint len, ulong h TSRMLS_DC);
|
2006-07-16 11:07:57 +00:00
|
|
|
#endif
|
2008-01-05 04:45:48 +00:00
|
|
|
void xc_install_function(char *filename, zend_function *func, zend_uchar type, zstr key, uint len, ulong h TSRMLS_DC);
|
|
|
|
ZESW(xc_cest_t *, void) xc_install_class(char *filename, xc_cest_t *cest, int oplineno, zend_uchar type, zstr key, uint len, ulong h TSRMLS_DC);
|
2006-05-09 10:58:38 +00:00
|
|
|
|
|
|
|
/* sandbox */
|
|
|
|
typedef struct {
|
|
|
|
int alloc;
|
|
|
|
char *filename;
|
|
|
|
|
|
|
|
HashTable orig_included_files;
|
|
|
|
HashTable *tmp_included_files;
|
|
|
|
|
2006-07-16 11:07:57 +00:00
|
|
|
#ifdef HAVE_XCACHE_CONSTANT
|
|
|
|
HashTable *orig_zend_constants;
|
|
|
|
HashTable tmp_zend_constants;
|
|
|
|
#endif
|
2006-05-09 10:58:38 +00:00
|
|
|
HashTable *orig_function_table;
|
|
|
|
HashTable *orig_class_table;
|
2006-10-29 02:05:01 +00:00
|
|
|
HashTable *orig_auto_globals;
|
2006-05-09 10:58:38 +00:00
|
|
|
HashTable tmp_function_table;
|
|
|
|
HashTable tmp_class_table;
|
2006-10-29 02:05:01 +00:00
|
|
|
HashTable tmp_auto_globals;
|
2007-02-04 06:22:14 +00:00
|
|
|
Bucket *tmp_internal_function_tail;
|
|
|
|
Bucket *tmp_internal_class_tail;
|
2008-01-04 11:38:57 +00:00
|
|
|
|
|
|
|
#ifdef E_STRICT
|
|
|
|
int orig_user_error_handler_error_reporting;
|
2008-02-17 16:49:46 +00:00
|
|
|
void (*orig_zend_error_cb)(int type, const char *error_filename, const uint error_lineno, const char *format, va_list args);
|
2008-01-04 11:38:57 +00:00
|
|
|
zend_uint compilererror_cnt;
|
|
|
|
zend_uint compilererror_size;
|
|
|
|
xc_compilererror_t *compilererrors;
|
|
|
|
#endif
|
2006-05-09 10:58:38 +00:00
|
|
|
} xc_sandbox_t;
|
|
|
|
|
2007-05-31 03:48:08 +00:00
|
|
|
typedef enum _xc_install_action_t {
|
|
|
|
XC_NoInstall,
|
|
|
|
XC_Install,
|
|
|
|
XC_InstallNoBinding
|
|
|
|
} xc_install_action_t;
|
|
|
|
|
2007-02-04 08:15:00 +00:00
|
|
|
void xc_zend_class_add_ref(zend_class_entry ZESW(*ce, **ce));
|
2006-05-09 10:58:38 +00:00
|
|
|
xc_sandbox_t *xc_sandbox_init(xc_sandbox_t *sandbox, char *filename TSRMLS_DC);
|
2007-05-31 03:48:08 +00:00
|
|
|
void xc_sandbox_free(xc_sandbox_t *sandbox, xc_install_action_t install TSRMLS_DC);
|