Skip to content

Commit ea58b54

Browse files
committed
Re-do a lot of it using a conditional define, and legacy type information for APIs
1 parent 1db6694 commit ea58b54

27 files changed

+757
-707
lines changed

Zend/zend.c

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -49,22 +49,22 @@ BOOL WINAPI IsDebuggerPresent(VOID);
4949

5050
/* true multithread-shared globals */
5151
ZEND_API zend_class_entry *zend_standard_class_def = NULL;
52-
ZEND_API int (*zend_printf)(const char *format, ...);
52+
ZEND_API zend_str_size_int (*zend_printf)(const char *format, ...);
5353
ZEND_API zend_write_func_t zend_write;
5454
ZEND_API FILE *(*zend_fopen)(const char *filename, char **opened_path TSRMLS_DC);
5555
ZEND_API int (*zend_stream_open_function)(const char *filename, zend_file_handle *handle TSRMLS_DC);
5656
ZEND_API void (*zend_block_interruptions)(void);
5757
ZEND_API void (*zend_unblock_interruptions)(void);
5858
ZEND_API void (*zend_ticks_function)(int ticks);
59-
ZEND_API void (*zend_error_cb)(int type, const char *error_filename, const uint error_lineno, const char *format, va_list args);
60-
int (*zend_vspprintf)(char **pbuf, size_t max_len, const char *format, va_list ap);
59+
ZEND_API void (*zend_error_cb)(int type, const char *error_filename, const zend_str_size_uint error_lineno, const char *format, va_list args);
60+
zend_str_size_int (*zend_vspprintf)(char **pbuf, zend_str_size_size_t max_len, const char *format, va_list ap);
6161
ZEND_API char *(*zend_getenv)(char *name, size_t name_len TSRMLS_DC);
62-
ZEND_API char *(*zend_resolve_path)(const char *filename, int filename_len TSRMLS_DC);
62+
ZEND_API char *(*zend_resolve_path)(const char *filename, zend_str_size_int filename_len TSRMLS_DC);
6363

6464
void (*zend_on_timeout)(int seconds TSRMLS_DC);
6565

6666
static void (*zend_message_dispatcher_p)(long message, const void *data TSRMLS_DC);
67-
static int (*zend_get_configuration_directive_p)(const char *name, uint name_length, zval *contents);
67+
static int (*zend_get_configuration_directive_p)(const char *name, zend_str_size_uint name_length, zval *contents);
6868

6969
static ZEND_INI_MH(OnUpdateErrorReporting) /* {{{ */
7070
{
@@ -130,7 +130,7 @@ ZEND_API zval zval_used_for_init; /* True global variable */
130130

131131
/* version information */
132132
static char *zend_version_info;
133-
static uint zend_version_info_length;
133+
static zend_str_size_uint zend_version_info_length;
134134
#define ZEND_CORE_VERSION_INFO "Zend Engine v" ZEND_VERSION ", Copyright (c) 1998-2013 Zend Technologies\n"
135135
#define PRINT_ZVAL_INDENT 4
136136

@@ -140,7 +140,7 @@ static void print_hash(zend_write_func_t write_func, HashTable *ht, int indent,
140140
char *string_key;
141141
HashPosition iterator;
142142
ulong num_key;
143-
uint str_len;
143+
zend_str_size str_len;
144144
int i;
145145

146146
for (i = 0; i < indent; i++) {
@@ -158,8 +158,8 @@ static void print_hash(zend_write_func_t write_func, HashTable *ht, int indent,
158158
case HASH_KEY_IS_STRING:
159159
if (is_object) {
160160
const char *prop_name, *class_name;
161-
int prop_len;
162-
int mangled = zend_unmangle_property_name_ex(string_key, str_len - 1, &class_name, &prop_name, &prop_len);
161+
zend_str_size prop_len;
162+
zend_str_size mangled = zend_unmangle_property_name_ex(string_key, str_len - 1, &class_name, &prop_name, &prop_len);
163163

164164
ZEND_WRITE_EX(prop_name, prop_len);
165165
if (class_name && mangled == SUCCESS) {
@@ -202,7 +202,7 @@ static void print_flat_hash(HashTable *ht TSRMLS_DC) /* {{{ */
202202
char *string_key;
203203
HashPosition iterator;
204204
ulong num_key;
205-
uint str_len;
205+
zend_str_size str_len;
206206
int i = 0;
207207

208208
zend_hash_internal_pointer_reset_ex(ht, &iterator);
@@ -358,7 +358,7 @@ ZEND_API void zend_print_flat_zval_r(zval *expr TSRMLS_DC) /* {{{ */
358358
{
359359
HashTable *properties = NULL;
360360
const char *class_name = NULL;
361-
zend_uint clen;
361+
zend_str_size clen;
362362

363363
if (Z_OBJ_HANDLER_P(expr, get_class_name)) {
364364
Z_OBJ_HANDLER_P(expr, get_class_name)(expr, &class_name, &clen, 0 TSRMLS_CC);
@@ -416,7 +416,7 @@ ZEND_API void zend_print_zval_r_ex(zend_write_func_t write_func, zval *expr, int
416416
{
417417
HashTable *properties;
418418
const char *class_name = NULL;
419-
zend_uint clen;
419+
zend_str_size clen;
420420
int is_temp;
421421

422422
if (Z_OBJ_HANDLER_P(expr, get_class_name)) {
@@ -624,7 +624,7 @@ static void php_scanner_globals_ctor(zend_php_scanner_globals *scanner_globals_p
624624

625625
void zend_init_opcodes_handlers(void);
626626

627-
static zend_bool php_auto_globals_create_globals(const char *name, uint name_len TSRMLS_DC) /* {{{ */
627+
static zend_bool php_auto_globals_create_globals(const char *name, zend_str_size_uint name_len TSRMLS_DC) /* {{{ */
628628
{
629629
zval *globals;
630630

@@ -863,7 +863,7 @@ void zenderror(const char *error) /* {{{ */
863863
/* }}} */
864864

865865
BEGIN_EXTERN_C()
866-
ZEND_API void _zend_bailout(char *filename, uint lineno) /* {{{ */
866+
ZEND_API void _zend_bailout(char *filename, zend_str_size_uint lineno) /* {{{ */
867867
{
868868
TSRMLS_FETCH();
869869

@@ -883,7 +883,7 @@ END_EXTERN_C()
883883
void zend_append_version_info(const zend_extension *extension) /* {{{ */
884884
{
885885
char *new_info;
886-
uint new_info_length;
886+
zend_str_size new_info_length;
887887

888888
new_info_length = sizeof(" with v, , by \n")
889889
+ strlen(extension->name)
@@ -980,7 +980,7 @@ ZEND_API void zend_message_dispatcher(long message, const void *data TSRMLS_DC)
980980
/* }}} */
981981
END_EXTERN_C()
982982

983-
ZEND_API int zend_get_configuration_directive(const char *name, uint name_length, zval *contents) /* {{{ */
983+
ZEND_API int zend_get_configuration_directive(const char *name, zend_str_size_uint name_length, zval *contents) /* {{{ */
984984
{
985985
if (zend_get_configuration_directive_p) {
986986
return zend_get_configuration_directive_p(name, name_length, contents);
@@ -1015,7 +1015,7 @@ ZEND_API void zend_error(int type, const char *format, ...) /* {{{ */
10151015
zval *retval;
10161016
zval *z_error_type, *z_error_message, *z_error_filename, *z_error_lineno, *z_context;
10171017
const char *error_filename;
1018-
uint error_lineno;
1018+
zend_str_size error_lineno;
10191019
zval *orig_user_error_handler;
10201020
zend_bool in_compilation;
10211021
zend_class_entry *saved_class_entry;
@@ -1364,7 +1364,7 @@ ZEND_API int zend_execute_scripts(int type TSRMLS_DC, zval **retval, int file_co
13641364
ZEND_API char *zend_make_compiled_string_description(const char *name TSRMLS_DC) /* {{{ */
13651365
{
13661366
const char *cur_filename;
1367-
int cur_lineno;
1367+
zend_str_size cur_lineno;
13681368
char *compiled_string_description;
13691369

13701370
if (zend_is_compiling(TSRMLS_C)) {

Zend/zend.h

Lines changed: 25 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -323,7 +323,7 @@ typedef union _zvalue_value {
323323
double dval; /* double value */
324324
struct {
325325
char *val;
326-
int len;
326+
zend_str_size_int len;
327327
} str;
328328
HashTable *ht; /* hash table value */
329329
zend_object_value obj;
@@ -441,12 +441,12 @@ typedef struct _zend_unserialize_data zend_unserialize_data;
441441

442442
struct _zend_trait_method_reference {
443443
const char* method_name;
444-
unsigned int mname_len;
444+
zend_str_size_uint mname_len;
445445

446446
zend_class_entry *ce;
447447

448448
const char* class_name;
449-
unsigned int cname_len;
449+
zend_str_size_uint cname_len;
450450
};
451451
typedef struct _zend_trait_method_reference zend_trait_method_reference;
452452

@@ -464,7 +464,7 @@ struct _zend_trait_alias {
464464
* name for method to be added
465465
*/
466466
const char* alias;
467-
unsigned int alias_len;
467+
zend_str_size_uint alias_len;
468468

469469
/**
470470
* modifiers to be set on trait method
@@ -476,7 +476,7 @@ typedef struct _zend_trait_alias zend_trait_alias;
476476
struct _zend_class_entry {
477477
char type;
478478
const char *name;
479-
zend_uint name_length;
479+
zend_str_size_uint name_length;
480480
struct _zend_class_entry *parent;
481481
int refcount;
482482
zend_uint ce_flags;
@@ -509,11 +509,11 @@ struct _zend_class_entry {
509509
zend_object_value (*create_object)(zend_class_entry *class_type TSRMLS_DC);
510510
zend_object_iterator *(*get_iterator)(zend_class_entry *ce, zval *object, int by_ref TSRMLS_DC);
511511
int (*interface_gets_implemented)(zend_class_entry *iface, zend_class_entry *class_type TSRMLS_DC); /* a class implements this interface */
512-
union _zend_function *(*get_static_method)(zend_class_entry *ce, char* method, int method_len TSRMLS_DC);
512+
union _zend_function *(*get_static_method)(zend_class_entry *ce, char* method, zend_str_size_int method_len TSRMLS_DC);
513513

514514
/* serializer callbacks */
515-
int (*serialize)(zval *object, unsigned char **buffer, zend_uint *buf_len, zend_serialize_data *data TSRMLS_DC);
516-
int (*unserialize)(zval **object, zend_class_entry *ce, const unsigned char *buf, zend_uint buf_len, zend_unserialize_data *data TSRMLS_DC);
515+
zend_str_size_int (*serialize)(zval *object, unsigned char **buffer, zend_str_size_uint *buf_len, zend_serialize_data *data TSRMLS_DC);
516+
zend_str_size_int (*unserialize)(zval **object, zend_class_entry *ce, const unsigned char *buf, zend_str_size_uint buf_len, zend_unserialize_data *data TSRMLS_DC);
517517

518518
zend_class_entry **interfaces;
519519
zend_uint num_interfaces;
@@ -526,10 +526,10 @@ struct _zend_class_entry {
526526
union {
527527
struct {
528528
const char *filename;
529-
zend_uint line_start;
530-
zend_uint line_end;
529+
zend_str_size_uint line_start;
530+
zend_str_size_uint line_end;
531531
const char *doc_comment;
532-
zend_uint doc_comment_len;
532+
zend_str_size_uint doc_comment_len;
533533
} user;
534534
struct {
535535
const struct _zend_function_entry *builtin_functions;
@@ -540,20 +540,20 @@ struct _zend_class_entry {
540540

541541
#include "zend_stream.h"
542542
typedef struct _zend_utility_functions {
543-
void (*error_function)(int type, const char *error_filename, const uint error_lineno, const char *format, va_list args) ZEND_ATTRIBUTE_PTR_FORMAT(printf, 4, 0);
544-
int (*printf_function)(const char *format, ...) ZEND_ATTRIBUTE_PTR_FORMAT(printf, 1, 2);
545-
int (*write_function)(const char *str, uint str_length);
543+
void (*error_function)(int type, const char *error_filename, const zend_str_size_uint error_lineno, const char *format, va_list args) ZEND_ATTRIBUTE_PTR_FORMAT(printf, 4, 0);
544+
zend_str_size_int (*printf_function)(const char *format, ...) ZEND_ATTRIBUTE_PTR_FORMAT(printf, 1, 2);
545+
zend_str_size_int (*write_function)(const char *str, zend_str_size_uint str_length);
546546
FILE *(*fopen_function)(const char *filename, char **opened_path TSRMLS_DC);
547547
void (*message_handler)(long message, const void *data TSRMLS_DC);
548548
void (*block_interruptions)(void);
549549
void (*unblock_interruptions)(void);
550-
int (*get_configuration_directive)(const char *name, uint name_length, zval *contents);
550+
int (*get_configuration_directive)(const char *name, zend_str_size_uint name_length, zval *contents);
551551
void (*ticks_function)(int ticks);
552552
void (*on_timeout)(int seconds TSRMLS_DC);
553553
int (*stream_open_function)(const char *filename, zend_file_handle *handle TSRMLS_DC);
554-
int (*vspprintf_function)(char **pbuf, size_t max_len, const char *format, va_list ap);
555-
char *(*getenv_function)(char *name, size_t name_len TSRMLS_DC);
556-
char *(*resolve_path_function)(const char *filename, int filename_len TSRMLS_DC);
554+
zend_str_size_int (*vspprintf_function)(char **pbuf, zend_str_size_size_t max_len, const char *format, va_list ap);
555+
char *(*getenv_function)(char *name, zend_str_size_size_t name_len TSRMLS_DC);
556+
char *(*resolve_path_function)(const char *filename, zend_str_size_int filename_len TSRMLS_DC);
557557
} zend_utility_functions;
558558

559559
typedef struct _zend_utility_values {
@@ -609,7 +609,7 @@ void zend_post_startup(TSRMLS_D);
609609
void zend_set_utility_values(zend_utility_values *utility_values);
610610

611611
BEGIN_EXTERN_C()
612-
ZEND_API void _zend_bailout(char *filename, uint lineno);
612+
ZEND_API void _zend_bailout(char *filename, zend_str_size_uint lineno);
613613
END_EXTERN_C()
614614

615615
#define zend_bailout() _zend_bailout(__FILE__, __LINE__)
@@ -686,18 +686,18 @@ END_EXTERN_C()
686686
#define ZEND_PUTC(c) zend_write(&(c), 1), (c)
687687

688688
BEGIN_EXTERN_C()
689-
extern ZEND_API int (*zend_printf)(const char *format, ...) ZEND_ATTRIBUTE_PTR_FORMAT(printf, 1, 2);
689+
extern ZEND_API zend_str_size_int (*zend_printf)(const char *format, ...) ZEND_ATTRIBUTE_PTR_FORMAT(printf, 1, 2);
690690
extern ZEND_API zend_write_func_t zend_write;
691691
extern ZEND_API FILE *(*zend_fopen)(const char *filename, char **opened_path TSRMLS_DC);
692692
extern ZEND_API void (*zend_block_interruptions)(void);
693693
extern ZEND_API void (*zend_unblock_interruptions)(void);
694694
extern ZEND_API void (*zend_ticks_function)(int ticks);
695-
extern ZEND_API void (*zend_error_cb)(int type, const char *error_filename, const uint error_lineno, const char *format, va_list args) ZEND_ATTRIBUTE_PTR_FORMAT(printf, 4, 0);
695+
extern ZEND_API void (*zend_error_cb)(int type, const char *error_filename, const zend_str_size_uint error_lineno, const char *format, va_list args) ZEND_ATTRIBUTE_PTR_FORMAT(printf, 4, 0);
696696
extern ZEND_API void (*zend_on_timeout)(int seconds TSRMLS_DC);
697697
extern ZEND_API int (*zend_stream_open_function)(const char *filename, zend_file_handle *handle TSRMLS_DC);
698-
extern int (*zend_vspprintf)(char **pbuf, size_t max_len, const char *format, va_list ap);
699-
extern ZEND_API char *(*zend_getenv)(char *name, size_t name_len TSRMLS_DC);
700-
extern ZEND_API char *(*zend_resolve_path)(const char *filename, int filename_len TSRMLS_DC);
698+
extern zend_str_size_int (*zend_vspprintf)(char **pbuf, zend_str_size_size_t max_len, const char *format, va_list ap);
699+
extern ZEND_API char *(*zend_getenv)(char *name, zend_str_size_size_t name_len TSRMLS_DC);
700+
extern ZEND_API char *(*zend_resolve_path)(const char *filename, zend_str_size_int filename_len TSRMLS_DC);
701701

702702
ZEND_API void zend_error(int type, const char *format, ...) ZEND_ATTRIBUTE_FORMAT(printf, 2, 3);
703703

@@ -726,7 +726,7 @@ END_EXTERN_C()
726726
BEGIN_EXTERN_C()
727727
ZEND_API void zend_message_dispatcher(long message, const void *data TSRMLS_DC);
728728

729-
ZEND_API int zend_get_configuration_directive(const char *name, uint name_length, zval *contents);
729+
ZEND_API int zend_get_configuration_directive(const char *name, zend_str_size_uint name_length, zval *contents);
730730
END_EXTERN_C()
731731

732732
/* Messages for applications of Zend */

0 commit comments

Comments
 (0)