Skip to content

Commit ce9a920

Browse files
make compatible with PHP7
1 parent e265aa1 commit ce9a920

File tree

3 files changed

+15
-5
lines changed

3 files changed

+15
-5
lines changed

profiling/build.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ fn main() {
3737
run_time_cache,
3838
fibers,
3939
trigger_time_sample,
40+
vernum,
4041
);
4142

4243
cfg_php_major_version(vernum);
@@ -86,12 +87,19 @@ fn build_zend_php_ffis(
8687
run_time_cache: bool,
8788
fibers: bool,
8889
trigger_time_sample: bool,
90+
vernum: u64,
8991
) {
9092
println!("cargo:rerun-if-changed=src/php_ffi.h");
9193
println!("cargo:rerun-if-changed=src/php_ffi.c");
9294
println!("cargo:rerun-if-changed=../ext/handlers_api.c");
9395
println!("cargo:rerun-if-changed=../ext/handlers_api.h");
9496

97+
let sandbox = if vernum < 80000 {
98+
"../zend_abstract_interface/sandbox/php7/sandbox.c"
99+
} else {
100+
"../zend_abstract_interface/sandbox/php8/sandbox.c"
101+
};
102+
95103
// Profiling only needs config and its dependencies.
96104
let zai_c_files = [
97105
"../zend_abstract_interface/config/config_decode.c",
@@ -101,6 +109,7 @@ fn build_zend_php_ffis(
101109
"../zend_abstract_interface/env/env.c",
102110
"../zend_abstract_interface/exceptions/exceptions.c",
103111
"../zend_abstract_interface/symbols/lookup.c",
112+
sandbox,
104113
"../zend_abstract_interface/json/json.c",
105114
"../zend_abstract_interface/zai_string/string.c",
106115
];

profiling/src/exception.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,12 @@ impl ExceptionProfilingStats {
6060
#[cfg(php8)]
6161
let exception_name = unsafe { (*exception).class_name() };
6262

63+
#[cfg(php7)]
64+
let message = unsafe {
65+
zend::zai_str_from_zstr(zend::zai_exception_message((*exception).value.obj).as_mut())
66+
.into_string()
67+
};
68+
#[cfg(php8)]
6369
let message = unsafe {
6470
zend::zai_str_from_zstr(zend::zai_exception_message(exception).as_mut()).into_string()
6571
};

profiling/src/php_ffi.c

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,6 @@
55
#include <stdint.h>
66
#include <string.h>
77

8-
/* needed by zend_abstract_interface/sandbox/sandbox.h which is included in
9-
* zend_abstract_interface/symbols/lookup.c which we need due to
10-
* zend_abstract_interface/exceptions/exeptions.c */
11-
long zai_sandbox_active = 0;
12-
138
#if CFG_STACK_WALKING_TESTS
149
#include <dlfcn.h> // for dlsym
1510
#endif

0 commit comments

Comments
 (0)