Skip to content

Commit cf0168f

Browse files
committed
Make more string API functions ZEND_API
1 parent 8c06a64 commit cf0168f

15 files changed

+87
-60
lines changed

Zend/zend.c

+5-4
Original file line numberDiff line numberDiff line change
@@ -2049,8 +2049,9 @@ ZEND_API void zend_alloc_ce_cache(zend_string *type_name)
20492049
}
20502050

20512051

2052-
ZEND_API extern inline uint32_t zend_gc_refcount(const zend_refcounted_h *p);
20532052
ZEND_API extern inline uint32_t zend_gc_delref(zend_refcounted_h *p);
2054-
ZEND_API extern zend_always_inline uint8_t zval_gc_type(uint32_t gc_type_info);
2055-
ZEND_API extern zend_always_inline uint32_t zval_gc_flags(uint32_t gc_type_info);
2056-
ZEND_API extern zend_always_inline uint32_t zval_gc_info(uint32_t gc_type_info);
2053+
ZEND_API extern inline uint32_t zval_gc_flags(uint32_t gc_type_info);
2054+
ZEND_API extern inline uint32_t zval_gc_info(uint32_t gc_type_info);
2055+
ZEND_API extern inline uint32_t zend_gc_refcount(const zend_refcounted_h *p);
2056+
ZEND_API extern inline uint32_t zend_gc_set_refcount(zend_refcounted_h *p, uint32_t rc);
2057+
ZEND_API extern inline uint8_t zval_gc_type(uint32_t gc_type_info);

Zend/zend_builtin_functions.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -1026,7 +1026,7 @@ flf_clean:;
10261026
Z_FLF_PARAM_FREE_STR(2, property_tmp)
10271027
}
10281028

1029-
static inline void _class_exists_impl(zval *return_value, zend_string *name, bool autoload, int flags, int skip_flags) /* {{{ */
1029+
static void _class_exists_impl(zval *return_value, zend_string *name, bool autoload, int flags, int skip_flags) /* {{{ */
10301030
{
10311031
zend_string *lcname;
10321032
zend_class_entry *ce;
@@ -1336,7 +1336,7 @@ ZEND_FUNCTION(restore_exception_handler)
13361336
}
13371337
/* }}} */
13381338

1339-
static inline void get_declared_class_impl(INTERNAL_FUNCTION_PARAMETERS, int flags) /* {{{ */
1339+
static void get_declared_class_impl(INTERNAL_FUNCTION_PARAMETERS, int flags) /* {{{ */
13401340
{
13411341
zend_string *key;
13421342
zval *zv;

Zend/zend_exceptions.c

+14-9
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ static inline zend_class_entry *i_get_exception_base(zend_object *object) /* {{{
8787
}
8888
/* }}} */
8989

90-
ZEND_API zend_class_entry *zend_get_exception_base(zend_object *object) /* {{{ */
90+
ZEND_API zend_never_inline zend_class_entry *zend_get_exception_base(zend_object *object) /* {{{ */
9191
{
9292
return i_get_exception_base(object);
9393
}
@@ -403,6 +403,11 @@ ZEND_METHOD(ErrorException, __construct)
403403
#define GET_PROPERTY_SILENT(object, id) \
404404
zend_read_property_ex(i_get_exception_base(Z_OBJ_P(object)), Z_OBJ_P(object), ZSTR_KNOWN(id), 1, &rv)
405405

406+
#define GET_PROPERTY_OUTLINE(object, id) \
407+
zend_read_property_ex(zend_get_exception_base(Z_OBJ_P(object)), Z_OBJ_P(object), ZSTR_KNOWN(id), 0, &rv)
408+
#define GET_PROPERTY_SILENT_OUTLINE(object, id) \
409+
zend_read_property_ex(zend_get_exception_base(Z_OBJ_P(object)), Z_OBJ_P(object), ZSTR_KNOWN(id), 1, &rv)
410+
406411
/* {{{ Get the file in which the exception occurred */
407412
ZEND_METHOD(Exception, getFile)
408413
{
@@ -900,9 +905,9 @@ ZEND_API ZEND_COLD zend_result zend_exception_error(zend_object *ex, int severit
900905
ce_exception = ex->ce;
901906
EG(exception) = NULL;
902907
if (ce_exception == zend_ce_parse_error || ce_exception == zend_ce_compile_error) {
903-
zend_string *message = zval_get_string(GET_PROPERTY(&exception, ZEND_STR_MESSAGE));
904-
zend_string *file = zval_get_string(GET_PROPERTY_SILENT(&exception, ZEND_STR_FILE));
905-
zend_long line = zval_get_long(GET_PROPERTY_SILENT(&exception, ZEND_STR_LINE));
908+
zend_string *message = zval_get_string(GET_PROPERTY_OUTLINE(&exception, ZEND_STR_MESSAGE));
909+
zend_string *file = zval_get_string(GET_PROPERTY_SILENT_OUTLINE(&exception, ZEND_STR_FILE));
910+
zend_long line = zval_get_long(GET_PROPERTY_SILENT_OUTLINE(&exception, ZEND_STR_LINE));
906911
int type = (ce_exception == zend_ce_parse_error ? E_PARSE : E_COMPILE_ERROR) | E_DONT_BAIL;
907912

908913
zend_observer_error_notify(type, file, line, message);
@@ -931,8 +936,8 @@ ZEND_API ZEND_COLD zend_result zend_exception_error(zend_object *ex, int severit
931936
ZVAL_OBJ(&zv, EG(exception));
932937
/* do the best we can to inform about the inner exception */
933938
if (instanceof_function(ce_exception, zend_ce_exception) || instanceof_function(ce_exception, zend_ce_error)) {
934-
file = zval_get_string(GET_PROPERTY_SILENT(&zv, ZEND_STR_FILE));
935-
line = zval_get_long(GET_PROPERTY_SILENT(&zv, ZEND_STR_LINE));
939+
file = zval_get_string(GET_PROPERTY_SILENT_OUTLINE(&zv, ZEND_STR_FILE));
940+
line = zval_get_long(GET_PROPERTY_SILENT_OUTLINE(&zv, ZEND_STR_LINE));
936941
}
937942

938943
zend_error_va(E_WARNING, (file && ZSTR_LEN(file) > 0) ? file : NULL, line,
@@ -944,9 +949,9 @@ ZEND_API ZEND_COLD zend_result zend_exception_error(zend_object *ex, int severit
944949
}
945950
}
946951

947-
str = zval_get_string(GET_PROPERTY_SILENT(&exception, ZEND_STR_STRING));
948-
file = zval_get_string(GET_PROPERTY_SILENT(&exception, ZEND_STR_FILE));
949-
line = zval_get_long(GET_PROPERTY_SILENT(&exception, ZEND_STR_LINE));
952+
str = zval_get_string(GET_PROPERTY_SILENT_OUTLINE(&exception, ZEND_STR_STRING));
953+
file = zval_get_string(GET_PROPERTY_SILENT_OUTLINE(&exception, ZEND_STR_FILE));
954+
line = zval_get_long(GET_PROPERTY_SILENT_OUTLINE(&exception, ZEND_STR_LINE));
950955

951956
zend_error_va(severity | E_DONT_BAIL,
952957
(file && ZSTR_LEN(file) > 0) ? file : NULL, line,

Zend/zend_string.c

+17
Original file line numberDiff line numberDiff line change
@@ -396,6 +396,8 @@ ZEND_API bool ZEND_FASTCALL I_REPLACE_SONAME_FNNAME_ZU(NONE,zend_string_equal_va
396396
{
397397
return !memcmp(ZSTR_VAL(s1), ZSTR_VAL(s2), ZSTR_LEN(s1));
398398
}
399+
#else
400+
ZEND_API extern inline bool zend_string_equal_val(const zend_string *s1, const zend_string *s2);
399401
#endif
400402

401403
#if defined(__GNUC__) && defined(__i386__)
@@ -548,3 +550,18 @@ ZEND_API void zend_string_release_ex_outline(zend_string *s, bool persistent)
548550
{
549551
zend_string_release_ex(s, persistent);
550552
}
553+
554+
ZEND_API extern inline uint32_t zend_string_addref(zend_string *s);
555+
ZEND_API extern inline zend_string *zend_string_alloc(size_t len, bool persistent);
556+
ZEND_API extern inline zend_string *zend_string_copy(zend_string *s);
557+
ZEND_API extern inline uint32_t zend_string_delref(zend_string *s);
558+
ZEND_API extern inline zend_string *zend_string_dup(zend_string *s, bool persistent);
559+
ZEND_API extern inline bool zend_string_equals(const zend_string *s1, const zend_string *s2);
560+
ZEND_API extern inline bool zend_string_equal_content(const zend_string *s1, const zend_string *s2);
561+
ZEND_API extern inline bool zend_string_equals_cstr(const zend_string *s1, const char *s2, size_t s2_length);
562+
ZEND_API extern inline void zend_string_forget_hash_val(zend_string *s);
563+
ZEND_API extern inline zend_ulong zend_string_hash_val(zend_string *s);
564+
ZEND_API extern inline zend_string *zend_string_init(const char *str, size_t len, bool persistent);
565+
ZEND_API extern inline zend_string *zend_string_realloc(zend_string *s, size_t len, bool persistent);
566+
ZEND_API extern inline uint32_t zend_string_refcount(const zend_string *s);
567+
ZEND_API extern inline zend_string *zend_string_separate(zend_string *s, bool persistent);

Zend/zend_string.h

+29-25
Original file line numberDiff line numberDiff line change
@@ -141,42 +141,43 @@ END_EXTERN_C()
141141

142142
/*---*/
143143

144-
static zend_always_inline zend_ulong zend_string_hash_val(zend_string *s)
144+
BEGIN_EXTERN_C()
145+
ZEND_API zend_always_inline zend_ulong zend_string_hash_val(zend_string *s)
145146
{
146147
return ZSTR_H(s) ? ZSTR_H(s) : zend_string_hash_func(s);
147148
}
148149

149-
static zend_always_inline void zend_string_forget_hash_val(zend_string *s)
150+
ZEND_API zend_always_inline void zend_string_forget_hash_val(zend_string *s)
150151
{
151152
ZSTR_H(s) = 0;
152153
GC_DEL_FLAGS(s, IS_STR_VALID_UTF8);
153154
}
154155

155-
static zend_always_inline uint32_t zend_string_refcount(const zend_string *s)
156+
ZEND_API zend_always_inline uint32_t zend_string_refcount(const zend_string *s)
156157
{
157158
if (!ZSTR_IS_INTERNED(s)) {
158159
return GC_REFCOUNT(s);
159160
}
160161
return 1;
161162
}
162163

163-
static zend_always_inline uint32_t zend_string_addref(zend_string *s)
164+
ZEND_API zend_always_inline uint32_t zend_string_addref(zend_string *s)
164165
{
165166
if (!ZSTR_IS_INTERNED(s)) {
166167
return GC_ADDREF(s);
167168
}
168169
return 1;
169170
}
170171

171-
static zend_always_inline uint32_t zend_string_delref(zend_string *s)
172+
ZEND_API zend_always_inline uint32_t zend_string_delref(zend_string *s)
172173
{
173174
if (!ZSTR_IS_INTERNED(s)) {
174175
return GC_DELREF(s);
175176
}
176177
return 1;
177178
}
178179

179-
static zend_always_inline zend_string *zend_string_alloc(size_t len, bool persistent)
180+
ZEND_API zend_always_inline zend_string *zend_string_alloc(size_t len, bool persistent)
180181
{
181182
zend_string *ret = (zend_string *)pemalloc(ZEND_MM_ALIGNED_SIZE(_ZSTR_STRUCT_SIZE(len)), persistent);
182183

@@ -187,6 +188,16 @@ static zend_always_inline zend_string *zend_string_alloc(size_t len, bool persis
187188
return ret;
188189
}
189190

191+
ZEND_API zend_always_inline zend_string *zend_string_init(const char *str, size_t len, bool persistent)
192+
{
193+
zend_string *ret = zend_string_alloc(len, persistent);
194+
195+
memcpy(ZSTR_VAL(ret), str, len);
196+
ZSTR_VAL(ret)[len] = '\0';
197+
return ret;
198+
}
199+
END_EXTERN_C()
200+
190201
static zend_always_inline zend_string *zend_string_safe_alloc(size_t n, size_t m, size_t l, bool persistent)
191202
{
192203
zend_string *ret = (zend_string *)safe_pemalloc(n, m, ZEND_MM_ALIGNED_SIZE(_ZSTR_STRUCT_SIZE(l)), persistent);
@@ -198,15 +209,6 @@ static zend_always_inline zend_string *zend_string_safe_alloc(size_t n, size_t m
198209
return ret;
199210
}
200211

201-
static zend_always_inline zend_string *zend_string_init(const char *str, size_t len, bool persistent)
202-
{
203-
zend_string *ret = zend_string_alloc(len, persistent);
204-
205-
memcpy(ZSTR_VAL(ret), str, len);
206-
ZSTR_VAL(ret)[len] = '\0';
207-
return ret;
208-
}
209-
210212
static zend_always_inline zend_string *zend_string_init_fast(const char *str, size_t len)
211213
{
212214
if (len > 1) {
@@ -218,15 +220,16 @@ static zend_always_inline zend_string *zend_string_init_fast(const char *str, si
218220
}
219221
}
220222

221-
static zend_always_inline zend_string *zend_string_copy(zend_string *s)
223+
BEGIN_EXTERN_C()
224+
ZEND_API inline zend_string *zend_string_copy(zend_string *s)
222225
{
223226
if (!ZSTR_IS_INTERNED(s)) {
224227
GC_ADDREF(s);
225228
}
226229
return s;
227230
}
228231

229-
static zend_always_inline zend_string *zend_string_dup(zend_string *s, bool persistent)
232+
ZEND_API zend_always_inline zend_string *zend_string_dup(zend_string *s, bool persistent)
230233
{
231234
if (ZSTR_IS_INTERNED(s)) {
232235
return s;
@@ -235,7 +238,7 @@ static zend_always_inline zend_string *zend_string_dup(zend_string *s, bool pers
235238
}
236239
}
237240

238-
static zend_always_inline zend_string *zend_string_separate(zend_string *s, bool persistent)
241+
ZEND_API zend_always_inline zend_string *zend_string_separate(zend_string *s, bool persistent)
239242
{
240243
if (ZSTR_IS_INTERNED(s) || GC_REFCOUNT(s) > 1) {
241244
if (!ZSTR_IS_INTERNED(s)) {
@@ -248,7 +251,7 @@ static zend_always_inline zend_string *zend_string_separate(zend_string *s, bool
248251
return s;
249252
}
250253

251-
static zend_always_inline zend_string *zend_string_realloc(zend_string *s, size_t len, bool persistent)
254+
ZEND_API zend_always_inline zend_string *zend_string_realloc(zend_string *s, size_t len, bool persistent)
252255
{
253256
zend_string *ret;
254257

@@ -267,6 +270,7 @@ static zend_always_inline zend_string *zend_string_realloc(zend_string *s, size_
267270
}
268271
return ret;
269272
}
273+
END_EXTERN_C()
270274

271275
static zend_always_inline zend_string *zend_string_extend(zend_string *s, size_t len, bool persistent)
272276
{
@@ -370,31 +374,31 @@ static zend_always_inline void zend_string_release_ex(zend_string *s, bool persi
370374
}
371375
}
372376

373-
static zend_always_inline bool zend_string_equals_cstr(const zend_string *s1, const char *s2, size_t s2_length)
377+
BEGIN_EXTERN_C()
378+
ZEND_API zend_always_inline bool zend_string_equals_cstr(const zend_string *s1, const char *s2, size_t s2_length)
374379
{
375380
return ZSTR_LEN(s1) == s2_length && !memcmp(ZSTR_VAL(s1), s2, s2_length);
376381
}
377382

378383
#if defined(__GNUC__) && (defined(__i386__) || (defined(__x86_64__) && !defined(__ILP32__)))
379-
BEGIN_EXTERN_C()
380384
ZEND_API bool ZEND_FASTCALL zend_string_equal_val(const zend_string *s1, const zend_string *s2);
381-
END_EXTERN_C()
382385
#else
383-
static zend_always_inline bool zend_string_equal_val(const zend_string *s1, const zend_string *s2)
386+
ZEND_API zend_always_inline bool zend_string_equal_val(const zend_string *s1, const zend_string *s2)
384387
{
385388
return !memcmp(ZSTR_VAL(s1), ZSTR_VAL(s2), ZSTR_LEN(s1));
386389
}
387390
#endif
388391

389-
static zend_always_inline bool zend_string_equal_content(const zend_string *s1, const zend_string *s2)
392+
ZEND_API zend_always_inline bool zend_string_equal_content(const zend_string *s1, const zend_string *s2)
390393
{
391394
return ZSTR_LEN(s1) == ZSTR_LEN(s2) && zend_string_equal_val(s1, s2);
392395
}
393396

394-
static zend_always_inline bool zend_string_equals(const zend_string *s1, const zend_string *s2)
397+
ZEND_API zend_always_inline bool zend_string_equals(const zend_string *s1, const zend_string *s2)
395398
{
396399
return s1 == s2 || zend_string_equal_content(s1, s2);
397400
}
401+
END_EXTERN_C()
398402

399403
#define zend_string_equals_ci(s1, s2) \
400404
(ZSTR_LEN(s1) == ZSTR_LEN(s2) && !zend_binary_strcasecmp(ZSTR_VAL(s1), ZSTR_LEN(s1), ZSTR_VAL(s2), ZSTR_LEN(s2)))

Zend/zend_types.h

+3-3
Original file line numberDiff line numberDiff line change
@@ -1317,17 +1317,17 @@ BEGIN_EXTERN_C()
13171317
ZEND_API zend_always_inline uint32_t zend_gc_refcount(const zend_refcounted_h *p) {
13181318
return p->refcount;
13191319
}
1320-
END_EXTERN_C()
13211320

1322-
static zend_always_inline uint32_t zend_gc_set_refcount(zend_refcounted_h *p, uint32_t rc) {
1321+
ZEND_API zend_always_inline uint32_t zend_gc_set_refcount(zend_refcounted_h *p, uint32_t rc) {
13231322
p->refcount = rc;
13241323
return p->refcount;
13251324
}
13261325

1327-
static zend_always_inline uint32_t zend_gc_addref(zend_refcounted_h *p) {
1326+
ZEND_API zend_always_inline uint32_t zend_gc_addref(zend_refcounted_h *p) {
13281327
ZEND_RC_MOD_CHECK(p);
13291328
return ++(p->refcount);
13301329
}
1330+
END_EXTERN_C()
13311331

13321332
static zend_always_inline void zend_gc_try_addref(zend_refcounted_h *p) {
13331333
if (!(p->u.type_info & GC_IMMUTABLE)) {

ext/opcache/ZendAccelerator.c

+3-3
Original file line numberDiff line numberDiff line change
@@ -220,7 +220,7 @@ static ZEND_FUNCTION(accel_chdir)
220220
ZCG(cwd_check) = true;
221221
}
222222

223-
static inline zend_string* accel_getcwd(void)
223+
static zend_string* accel_getcwd(void)
224224
{
225225
if (ZCG(cwd)) {
226226
return ZCG(cwd);
@@ -598,7 +598,7 @@ static zend_always_inline zend_string *accel_find_interned_string_ex(zend_ulong
598598
static zend_string* ZEND_FASTCALL accel_init_interned_string_for_php(const char *str, size_t size, bool permanent)
599599
{
600600
if (ZCG(counted)) {
601-
zend_ulong h = zend_inline_hash_func(str, size);
601+
zend_ulong h = zend_inline_hash_func(str, size);
602602
zend_string *ret = accel_find_interned_string_ex(h, str, size);
603603

604604
if (!ret) {
@@ -1102,7 +1102,7 @@ accel_time_t zend_get_file_handle_timestamp(zend_file_handle *file_handle, size_
11021102
return statbuf.st_mtime;
11031103
}
11041104

1105-
static inline int do_validate_timestamps(zend_persistent_script *persistent_script, zend_file_handle *file_handle)
1105+
static int do_validate_timestamps(zend_persistent_script *persistent_script, zend_file_handle *file_handle)
11061106
{
11071107
zend_file_handle ps_handle;
11081108
zend_string *full_path_ptr = NULL;

ext/pdo/pdo_stmt.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -484,7 +484,7 @@ PHP_METHOD(PDOStatement, execute)
484484
}
485485
/* }}} */
486486

487-
static inline void fetch_value(pdo_stmt_t *stmt, zval *dest, int colno, enum pdo_param_type *type_override) /* {{{ */
487+
static void fetch_value(pdo_stmt_t *stmt, zval *dest, int colno, enum pdo_param_type *type_override) /* {{{ */
488488
{
489489
if (colno < 0) {
490490
zend_value_error("Column index must be greater than or equal to 0");

ext/simplexml/simplexml.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -894,7 +894,7 @@ static void sxe_dimension_delete(zend_object *object, zval *offset)
894894
}
895895
/* }}} */
896896

897-
static inline zend_string *sxe_xmlNodeListGetString(xmlDocPtr doc, xmlNodePtr list, int inLine) /* {{{ */
897+
static zend_string *sxe_xmlNodeListGetString(xmlDocPtr doc, xmlNodePtr list, int inLine) /* {{{ */
898898
{
899899
xmlChar *tmp = xmlNodeListGetString(doc, list, inLine);
900900
zend_string *res;
@@ -1389,7 +1389,7 @@ PHP_METHOD(SimpleXMLElement, asXML)
13891389

13901390
#define SXE_NS_PREFIX(ns) (ns->prefix ? (char*)ns->prefix : "")
13911391

1392-
static inline void sxe_add_namespace_name_raw(zval *return_value, const char *prefix, const char *href)
1392+
static void sxe_add_namespace_name_raw(zval *return_value, const char *prefix, const char *href)
13931393
{
13941394
zend_string *key = zend_string_init(prefix, strlen(prefix), 0);
13951395
zval zv;

ext/standard/url_scanner_ex.re

+4-4
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,7 @@ alphadash = ([a-zA-Z] | "-");
182182
#define YYLIMIT q
183183
#define YYMARKER r
184184

185-
static inline void append_modified_url(smart_str *url, smart_str *dest, smart_str *url_app, const char *separator, int type)
185+
static void append_modified_url(smart_str *url, smart_str *dest, smart_str *url_app, const char *separator, int type)
186186
{
187187
php_url *url_parts;
188188

@@ -485,7 +485,7 @@ static inline void handle_arg(STD_PARA)
485485
}
486486
}
487487

488-
static inline void handle_val(STD_PARA, char quotes, char type)
488+
static void handle_val(STD_PARA, char quotes, char type)
489489
{
490490
smart_str_setl(&ctx->val, start + quotes, YYCURSOR - start - quotes * 2);
491491
if (ctx->tag_type == TAG_FORM && ctx->attr_type == ATTR_ACTION) {
@@ -728,7 +728,7 @@ static void php_url_scanner_output_handler(char *output, size_t output_len, char
728728
php_url_scanner_session_handler_impl(output, output_len, handled_output, handled_output_len, mode, 0);
729729
}
730730

731-
static inline int php_url_scanner_add_var_impl(const char *name, size_t name_len, const char *value, size_t value_len, int encode, int type)
731+
static int php_url_scanner_add_var_impl(const char *name, size_t name_len, const char *value, size_t value_len, int encode, int type)
732732
{
733733
smart_str sname = {0};
734734
smart_str svalue = {0};
@@ -836,7 +836,7 @@ PHPAPI int php_url_scanner_reset_vars(void)
836836
}
837837

838838

839-
static inline int php_url_scanner_reset_var_impl(zend_string *name, int encode, int type)
839+
static int php_url_scanner_reset_var_impl(zend_string *name, int encode, int type)
840840
{
841841
char *start, *end, *limit;
842842
size_t separator_len;

0 commit comments

Comments
 (0)