Skip to content

Commit 9a026de

Browse files
committed
Remove static to global.
1 parent ef3e17c commit 9a026de

File tree

2 files changed

+61
-65
lines changed

2 files changed

+61
-65
lines changed

examples/simple/src/lib.rs

Lines changed: 61 additions & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,3 @@
1-
#![feature(allocator_api)]
2-
#![feature(const_raw_ptr_deref)]
3-
41
use phper::{c_str_ptr, php_fn, ebox};
52
use phper::sys::{ZEND_RESULT_CODE_SUCCESS, zend_parse_parameters, zend_internal_arg_info, zend_function_entry, PHP_INI_SYSTEM};
63
use phper::sys::{zend_ini_entry_def, zend_module_entry, zend_register_ini_entries, zend_unregister_ini_entries, OnUpdateBool};
@@ -92,69 +89,69 @@ pub fn test_simple(execute_data: ExecuteData) -> impl SetVal {
9289
}
9390
}
9491

95-
#[zend_get_module]
96-
pub fn get_module() -> &'static ModuleEntry {
97-
static ARG_INFO_TEST_SIMPLE: InternalArgInfos<3> = InternalArgInfos::new([
98-
zend_internal_arg_info {
99-
name: 2 as *const _,
100-
type_: 0,
101-
pass_by_reference: 0,
102-
is_variadic: 0,
103-
},
104-
zend_internal_arg_info {
105-
name: c_str_ptr!("a"),
106-
type_: 0,
107-
pass_by_reference: 0,
108-
is_variadic: 0,
109-
},
110-
zend_internal_arg_info {
111-
name: c_str_ptr!("b"),
112-
type_: 0,
113-
pass_by_reference: 0,
114-
is_variadic: 0,
115-
},
116-
]);
92+
static ARG_INFO_TEST_SIMPLE: InternalArgInfos<3> = InternalArgInfos::new([
93+
zend_internal_arg_info {
94+
name: 2 as *const _,
95+
type_: 0,
96+
pass_by_reference: 0,
97+
is_variadic: 0,
98+
},
99+
zend_internal_arg_info {
100+
name: c_str_ptr!("a"),
101+
type_: 0,
102+
pass_by_reference: 0,
103+
is_variadic: 0,
104+
},
105+
zend_internal_arg_info {
106+
name: c_str_ptr!("b"),
107+
type_: 0,
108+
pass_by_reference: 0,
109+
is_variadic: 0,
110+
},
111+
]);
117112

118-
static FUNCTION_ENTRIES: FunctionEntries<2> = FunctionEntries::new([
119-
zend_function_entry {
120-
fname: c_str_ptr!("test_simple"),
121-
handler: Some(php_fn!(test_simple)),
122-
arg_info: ARG_INFO_TEST_SIMPLE.get(),
123-
num_args: 2,
124-
flags: 0,
125-
},
126-
unsafe { transmute([0u8; size_of::<zend_function_entry>()]) },
127-
]);
113+
static FUNCTION_ENTRIES: FunctionEntries<2> = FunctionEntries::new([
114+
zend_function_entry {
115+
fname: c_str_ptr!("test_simple"),
116+
handler: Some(php_fn!(test_simple)),
117+
arg_info: ARG_INFO_TEST_SIMPLE.get(),
118+
num_args: 2,
119+
flags: 0,
120+
},
121+
unsafe { transmute([0u8; size_of::<zend_function_entry>()]) },
122+
]);
128123

129-
static MODULE_ENTRY: ModuleEntry = ModuleEntry::new(zend_module_entry {
130-
size: size_of::<zend_module_entry>() as c_ushort,
131-
zend_api: phper::sys::ZEND_MODULE_API_NO as c_uint,
132-
zend_debug: phper::sys::ZEND_DEBUG as c_uchar,
133-
zts: phper::sys::USING_ZTS as c_uchar,
134-
ini_entry: std::ptr::null(),
135-
deps: std::ptr::null(),
136-
name: c_str_ptr!(env!("CARGO_PKG_NAME")),
137-
functions: FUNCTION_ENTRIES.get(),
138-
module_startup_func: Some(php_minit!(m_init_simple)),
139-
module_shutdown_func: Some(php_mshutdown!(m_shutdown_simple)),
140-
request_startup_func: Some(php_rinit!(r_init_simple)),
141-
request_shutdown_func: Some(php_rshutdown!(r_shutdown_simple)),
142-
info_func: Some(php_minfo!(m_info_simple)),
143-
version: c_str_ptr!(env!("CARGO_PKG_VERSION")),
144-
globals_size: 0usize,
145-
#[cfg(phper_zts)]
146-
globals_id_ptr: std::ptr::null_mut(),
147-
#[cfg(not(phper_zts))]
148-
globals_ptr: std::ptr::null_mut(),
149-
globals_ctor: None,
150-
globals_dtor: None,
151-
post_deactivate_func: None,
152-
module_started: 0,
153-
type_: 0,
154-
handle: null_mut(),
155-
module_number: 0,
156-
build_id: phper::sys::PHP_MODULE_BUILD_ID,
157-
});
124+
static MODULE_ENTRY: ModuleEntry = ModuleEntry::new(zend_module_entry {
125+
size: size_of::<zend_module_entry>() as c_ushort,
126+
zend_api: phper::sys::ZEND_MODULE_API_NO as c_uint,
127+
zend_debug: phper::sys::ZEND_DEBUG as c_uchar,
128+
zts: phper::sys::USING_ZTS as c_uchar,
129+
ini_entry: std::ptr::null(),
130+
deps: std::ptr::null(),
131+
name: c_str_ptr!(env!("CARGO_PKG_NAME")),
132+
functions: FUNCTION_ENTRIES.get(),
133+
module_startup_func: Some(php_minit!(m_init_simple)),
134+
module_shutdown_func: Some(php_mshutdown!(m_shutdown_simple)),
135+
request_startup_func: Some(php_rinit!(r_init_simple)),
136+
request_shutdown_func: Some(php_rshutdown!(r_shutdown_simple)),
137+
info_func: Some(php_minfo!(m_info_simple)),
138+
version: c_str_ptr!(env!("CARGO_PKG_VERSION")),
139+
globals_size: 0usize,
140+
#[cfg(phper_zts)]
141+
globals_id_ptr: std::ptr::null_mut(),
142+
#[cfg(not(phper_zts))]
143+
globals_ptr: std::ptr::null_mut(),
144+
globals_ctor: None,
145+
globals_dtor: None,
146+
post_deactivate_func: None,
147+
module_started: 0,
148+
type_: 0,
149+
handle: null_mut(),
150+
module_number: 0,
151+
build_id: phper::sys::PHP_MODULE_BUILD_ID,
152+
});
158153

154+
#[zend_get_module]
155+
pub fn get_module() -> &'static ModuleEntry {
159156
&MODULE_ENTRY
160157
}

phper/src/zend/api.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ use std::os::raw::{c_char, c_int, c_void};
44
use crate::zend::ini::Mh;
55
use std::ptr::null_mut;
66

7-
#[repr(C)]
87
pub struct ModuleGlobals<T: 'static> {
98
inner: UnsafeCell<T>,
109
}

0 commit comments

Comments
 (0)