Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support ZSTR_PARENT known_string #3106

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
103 changes: 56 additions & 47 deletions ext/compatibility.h
Original file line number Diff line number Diff line change
Expand Up @@ -190,53 +190,6 @@ static inline zend_string *php_base64_encode_str(const zend_string *str) {
#endif

#if PHP_VERSION_ID < 70300
enum {
#if PHP_VERSION_ID < 70300
ZEND_STR_NAME,
#if PHP_VERSION_ID >= 70100
#define ZEND_STR_NAME (-1 - ZEND_STR_NAME)
#endif
#endif
#if PHP_VERSION_ID < 70200
ZEND_STR_RESOURCE,
#if PHP_VERSION_ID >= 70100
#define ZEND_STR_RESOURCE (-1 - ZEND_STR_RESOURCE)
#endif
#endif
#if PHP_VERSION_ID < 70100
ZEND_STR_TRACE,
ZEND_STR_LINE,
ZEND_STR_FILE,
ZEND_STR_MESSAGE,
ZEND_STR_CODE,
ZEND_STR_TYPE,
ZEND_STR_FUNCTION,
ZEND_STR_OBJECT,
ZEND_STR_CLASS,
ZEND_STR_OBJECT_OPERATOR,
ZEND_STR_PAAMAYIM_NEKUDOTAYIM,
ZEND_STR_ARGS,
ZEND_STR_UNKNOWN,
ZEND_STR_EVAL,
ZEND_STR_INCLUDE,
ZEND_STR_REQUIRE,
ZEND_STR_INCLUDE_ONCE,
ZEND_STR_REQUIRE_ONCE,
ZEND_STR_PREVIOUS,
#endif
ZEND_STR__LAST
};
extern zend_string *ddtrace_known_strings[ZEND_STR__LAST];

#undef ZSTR_KNOWN
#if PHP_VERSION_ID >= 70200
#define ZSTR_KNOWN(idx) (idx < 0 ? ddtrace_known_strings[-1 - idx] : zend_known_strings[idx])
#elif PHP_VERSION_ID >= 70100
#define ZSTR_KNOWN(idx) (idx < 0 ? ddtrace_known_strings[-1 - idx] : CG(known_strings)[idx])
#else
#define ZSTR_KNOWN(idx) ddtrace_known_strings[idx]
#endif

#define GC_ADDREF(x) (++GC_REFCOUNT(x))
#define GC_DELREF(x) (--GC_REFCOUNT(x))
#define GC_SET_REFCOUNT(x, rc) (GC_REFCOUNT(x) = rc)
Expand Down Expand Up @@ -662,4 +615,60 @@ static inline zend_class_entry *zend_register_internal_class_with_flags(zend_cla
}
#endif

#if PHP_VERSION_ID < 80500
enum {
#if PHP_VERSION_ID < 80500
ZEND_STR_PARENT,
#if PHP_VERSION_ID >= 70100
#define ZEND_STR_PARENT (-1 - ZEND_STR_PARENT)
#endif
#endif
#if PHP_VERSION_ID < 70300
ZEND_STR_NAME,
#if PHP_VERSION_ID >= 70100
#define ZEND_STR_NAME (-1 - ZEND_STR_NAME)
#endif
#endif
#if PHP_VERSION_ID < 70200
ZEND_STR_RESOURCE,
#if PHP_VERSION_ID >= 70100
#define ZEND_STR_RESOURCE (-1 - ZEND_STR_RESOURCE)
#endif
#endif
#if PHP_VERSION_ID < 70100
ZEND_STR_TRACE,
ZEND_STR_LINE,
ZEND_STR_FILE,
ZEND_STR_MESSAGE,
ZEND_STR_CODE,
ZEND_STR_TYPE,
ZEND_STR_FUNCTION,
ZEND_STR_OBJECT,
ZEND_STR_CLASS,
ZEND_STR_OBJECT_OPERATOR,
ZEND_STR_PAAMAYIM_NEKUDOTAYIM,
ZEND_STR_ARGS,
ZEND_STR_UNKNOWN,
ZEND_STR_EVAL,
ZEND_STR_INCLUDE,
ZEND_STR_REQUIRE,
ZEND_STR_INCLUDE_ONCE,
ZEND_STR_REQUIRE_ONCE,
ZEND_STR_PREVIOUS,
#endif
ZEND_STR__LAST
};
extern zend_string *ddtrace_known_strings[ZEND_STR__LAST];

#undef ZSTR_KNOWN
#if PHP_VERSION_ID >= 70200
#define ZSTR_KNOWN(idx) (idx < 0 ? ddtrace_known_strings[-1 - idx] : zend_known_strings[idx])
#elif PHP_VERSION_ID >= 70100
#define ZSTR_KNOWN(idx) (idx < 0 ? ddtrace_known_strings[-1 - idx] : CG(known_strings)[idx])
#else
#define ZSTR_KNOWN(idx) ddtrace_known_strings[idx]
#endif

#endif

#endif // DD_COMPATIBILITY_H
10 changes: 8 additions & 2 deletions ext/ddtrace.c
Original file line number Diff line number Diff line change
Expand Up @@ -1304,11 +1304,17 @@ static void dd_disable_if_incompatible_sapi_detected(void) {
}
}

#if PHP_VERSION_ID < 70300
#if PHP_VERSION_ID < 80500
zend_string *ddtrace_known_strings[ZEND_STR__LAST];
void ddtrace_init_known_strings(void) {
#if PHP_VERSION_ID < 80500
#undef ZEND_STR_PARENT
ddtrace_known_strings[ZEND_STR_PARENT] = zend_string_init_interned(ZEND_STRL("parent"), 1);
#endif
#if PHP_VERSION_ID < 70300
#undef ZEND_STR_NAME
ddtrace_known_strings[ZEND_STR_NAME] = zend_string_init_interned(ZEND_STRL("name"), 1);
#endif
#if PHP_VERSION_ID < 70200
#undef ZEND_STR_RESOURCE
ddtrace_known_strings[ZEND_STR_RESOURCE] = zend_string_init_interned(ZEND_STRL("resource"), 1);
Expand Down Expand Up @@ -1354,7 +1360,7 @@ static PHP_MINIT_FUNCTION(ddtrace) {
// Reset on every minit for `apachectl graceful`.
dd_activate_once_control = (pthread_once_t)PTHREAD_ONCE_INIT;

#if PHP_VERSION_ID < 70300
#if PHP_VERSION_ID < 80500
ddtrace_init_known_strings();
#endif

Expand Down
10 changes: 3 additions & 7 deletions ext/ddtrace_arginfo.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/* This is a generated file, edit the .stub.php file instead.
* Stub hash: 5edec61a2b1ae22c8473ffbd3c509df6196abbae */
* Stub hash: 5053d17ed0824b80591563b6f27fbc6ba18d0a3f */

ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_DDTrace_trace_method, 0, 3, _IS_BOOL, 0)
ZEND_ARG_TYPE_INFO(0, className, IS_STRING, 0)
Expand Down Expand Up @@ -705,10 +705,8 @@ static zend_class_entry *register_class_DDTrace_SpanData(void)

zval property_parent_default_value;
ZVAL_UNDEF(&property_parent_default_value);
zend_string *property_parent_name = zend_string_init("parent", sizeof("parent") - 1, 1);
zend_string *property_parent_class_DDTrace_SpanData = zend_string_init("DDTrace\\SpanData", sizeof("DDTrace\\SpanData")-1, 1);
zend_declare_typed_property(class_entry, property_parent_name, &property_parent_default_value, ZEND_ACC_PUBLIC|ZEND_ACC_READONLY, NULL, (zend_type) ZEND_TYPE_INIT_CLASS(property_parent_class_DDTrace_SpanData, 0, MAY_BE_NULL));
zend_string_release(property_parent_name);
zend_declare_typed_property(class_entry, ZSTR_KNOWN(ZEND_STR_PARENT), &property_parent_default_value, ZEND_ACC_PUBLIC|ZEND_ACC_READONLY, NULL, (zend_type) ZEND_TYPE_INIT_CLASS(property_parent_class_DDTrace_SpanData, 0, MAY_BE_NULL));

zval property_stack_default_value;
ZVAL_UNDEF(&property_stack_default_value);
Expand Down Expand Up @@ -794,10 +792,8 @@ static zend_class_entry *register_class_DDTrace_SpanStack(void)

zval property_parent_default_value;
ZVAL_UNDEF(&property_parent_default_value);
zend_string *property_parent_name = zend_string_init("parent", sizeof("parent") - 1, 1);
zend_string *property_parent_class_DDTrace_SpanStack = zend_string_init("DDTrace\\SpanStack", sizeof("DDTrace\\SpanStack")-1, 1);
zend_declare_typed_property(class_entry, property_parent_name, &property_parent_default_value, ZEND_ACC_PUBLIC|ZEND_ACC_READONLY, NULL, (zend_type) ZEND_TYPE_INIT_CLASS(property_parent_class_DDTrace_SpanStack, 0, MAY_BE_NULL));
zend_string_release(property_parent_name);
zend_declare_typed_property(class_entry, ZSTR_KNOWN(ZEND_STR_PARENT), &property_parent_default_value, ZEND_ACC_PUBLIC|ZEND_ACC_READONLY, NULL, (zend_type) ZEND_TYPE_INIT_CLASS(property_parent_class_DDTrace_SpanStack, 0, MAY_BE_NULL));

zval property_active_default_value;
ZVAL_NULL(&property_active_default_value);
Expand Down
Loading