Skip to content

Commit

Permalink
fix(cfg): unified php version cfg
Browse files Browse the repository at this point in the history
Refs: #331
  • Loading branch information
Xenira committed Oct 22, 2024
1 parent fd385d8 commit 6261e04
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 17 deletions.
7 changes: 5 additions & 2 deletions build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -231,13 +231,16 @@ fn check_php_version(info: &PHPInfo) -> Result<()> {
const PHP_83_API_VER: u32 = 20230831;

println!("cargo::rustc-check-cfg=cfg(php80, php81, php82, php83, php_zts, php_debug, docs)");
println!("cargo:rustc-cfg=php80");

if version < PHP_81_API_VER {
println!("cargo:rustc-cfg=php80");
}

if (PHP_81_API_VER..PHP_82_API_VER).contains(&version) {
println!("cargo:rustc-cfg=php81");
}

if version >= PHP_82_API_VER {
if (PHP_82_API_VER..PHP_83_API_VER).contains(&version) {
println!("cargo:rustc-cfg=php82");
}

Expand Down
2 changes: 1 addition & 1 deletion src/builders/class.rs
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,7 @@ impl ClassBuilder {
// disable serialization if the class has an associated object
if self.object_override.is_some() {
cfg_if::cfg_if! {
if #[cfg(any(php81, php82))] {
if #[cfg(not(php80))] {
class.ce_flags |= ClassFlags::NotSerializable.bits();
} else {
class.serialize = Some(crate::ffi::zend_class_serialize_deny);
Expand Down
6 changes: 3 additions & 3 deletions src/flags.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

use bitflags::bitflags;

#[cfg(not(php82))]
#[cfg(any(php80, php81))]
use crate::ffi::ZEND_ACC_REUSE_GET_ITERATOR;
use crate::ffi::{
CONST_CS, CONST_DEPRECATED, CONST_NO_FILE_CACHE, CONST_PERSISTENT, E_COMPILE_ERROR,
Expand Down Expand Up @@ -84,14 +84,14 @@ bitflags! {
const ConstantsUpdated = ZEND_ACC_CONSTANTS_UPDATED;
const NoDynamicProperties = ZEND_ACC_NO_DYNAMIC_PROPERTIES;
const HasStaticInMethods = ZEND_HAS_STATIC_IN_METHODS;
#[cfg(not(php82))]
#[cfg(any(php80, php81))]
const ReuseGetIterator = ZEND_ACC_REUSE_GET_ITERATOR;
const ResolvedParent = ZEND_ACC_RESOLVED_PARENT;
const ResolvedInterfaces = ZEND_ACC_RESOLVED_INTERFACES;
const UnresolvedVariance = ZEND_ACC_UNRESOLVED_VARIANCE;
const NearlyLinked = ZEND_ACC_NEARLY_LINKED;

#[cfg(any(php81,php82))]
#[cfg(not(php80))]
const NotSerializable = crate::ffi::ZEND_ACC_NOT_SERIALIZABLE;
}
}
Expand Down
22 changes: 11 additions & 11 deletions src/zend/globals.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,18 +10,18 @@ use parking_lot::{const_rwlock, RwLock, RwLockReadGuard, RwLockWriteGuard};

use crate::boxed::ZBox;
use crate::exception::PhpResult;
#[cfg(php80)]
use crate::ffi::_zend_hash_find_known_hash;
#[cfg(php82)]
#[cfg(not(any(php80, php81)))]
use crate::ffi::zend_atomic_bool_store;
use crate::ffi::{
_sapi_module_struct, _zend_executor_globals, _zend_string, executor_globals,
ext_php_rs_executor_globals, ext_php_rs_file_globals, ext_php_rs_process_globals,
ext_php_rs_sapi_globals, ext_php_rs_sapi_module, php_core_globals, php_file_globals,
sapi_globals_struct, sapi_header_struct, sapi_headers_struct, sapi_request_info,
zend_ini_entry, zend_is_auto_global, TRACK_VARS_COOKIE, TRACK_VARS_ENV, TRACK_VARS_FILES,
TRACK_VARS_GET, TRACK_VARS_POST, TRACK_VARS_SERVER,
_sapi_module_struct, _zend_executor_globals, executor_globals, ext_php_rs_executor_globals,
ext_php_rs_file_globals, ext_php_rs_process_globals, ext_php_rs_sapi_globals,
ext_php_rs_sapi_module, php_core_globals, php_file_globals, sapi_globals_struct,
sapi_header_struct, sapi_headers_struct, sapi_request_info, zend_ini_entry,
zend_is_auto_global, TRACK_VARS_COOKIE, TRACK_VARS_ENV, TRACK_VARS_FILES, TRACK_VARS_GET,
TRACK_VARS_POST, TRACK_VARS_SERVER,
};
#[cfg(php80)]
use crate::ffi::{_zend_hash_find_known_hash, _zend_string};
#[cfg(not(php80))]
use crate::ffi::{
_zend_known_string_id_ZEND_STR_AUTOGLOBAL_REQUEST, zend_hash_find_known_hash,
Expand Down Expand Up @@ -161,7 +161,7 @@ impl ExecutorGlobals {
/// set with [`crate::ffi::zend_interrupt_function`].
pub fn request_interrupt(&mut self) {
cfg_if::cfg_if! {
if #[cfg(php82)] {
if #[cfg(not(any(php80, php81)))] {
unsafe {
zend_atomic_bool_store(&mut self.vm_interrupt, true);
}
Expand All @@ -174,7 +174,7 @@ impl ExecutorGlobals {
/// Cancel a requested an interrupt of the PHP VM.
pub fn cancel_interrupt(&mut self) {
cfg_if::cfg_if! {
if #[cfg(php82)] {
if #[cfg(not(any(php80, php81)))] {
unsafe {
zend_atomic_bool_store(&mut self.vm_interrupt, false);
}
Expand Down

0 comments on commit 6261e04

Please sign in to comment.