[php-src] master: Zend: use C23 enums for some zend_module fields
| From: | Gina Peter Banyard | Date: | Fri, 20 Nov 2026 16:07:54 +0000 |
| Subject: | [php-src] master: Zend: use C23 enums for some zend_module fields | ||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-143975@lists.php.net to get a copy of this message | ||
Author: Gina Peter Banyard (Girgias)
Date: 2026-11-20T16:07:51Z
Commit: https://github.com/php/php-src/commit/b5f94153aa59531d3439ecda5f1558ca03729f59
Raw diff: https://github.com/php/php-src/commit/b5f94153aa59531d3439ecda5f1558ca03729f59.diff
Zend: use C23 enums for some zend_module fields
Changed paths:
M Zend/zend_API.c
M Zend/zend_API.h
M Zend/zend_ini.c
M Zend/zend_ini.h
M Zend/zend_modules.h
M ext/standard/dl.c
M ext/standard/dl.h
Diff:
diff --git a/Zend/zend_API.c b/Zend/zend_API.c
index 8f1877f0be9e..fc236b1886e2 100644
--- a/Zend/zend_API.c
+++ b/Zend/zend_API.c
@@ -2598,7 +2598,7 @@ ZEND_API void zend_destroy_modules(void) /* {{{ */
}
/* }}} */
-ZEND_API zend_module_entry* zend_register_module_ex(zend_module_entry *module, int module_type) /*
{{{ */
+ZEND_API zend_module_entry* zend_register_module_ex(zend_module_entry *module, zend_module_type
module_type) /* {{{ */
{
size_t name_len;
zend_string *lcname;
@@ -3022,7 +3022,7 @@ ZEND_API void zend_convert_internal_arg_info(zend_arg_info *new_arg_info,
const
}
/* registers all functions in *library_functions in the function hash */
-ZEND_API zend_result zend_register_functions(zend_class_entry *scope, const zend_function_entry
*functions, HashTable *function_table, int type) /* {{{ */
+ZEND_API zend_result zend_register_functions(zend_class_entry *scope, const zend_function_entry
*functions, HashTable *function_table, zend_module_type type) /* {{{ */
{
const zend_function_entry *ptr = functions;
zend_function function;
diff --git a/Zend/zend_API.h b/Zend/zend_API.h
index 6fefb349eae3..5239a14530e7 100644
--- a/Zend/zend_API.h
+++ b/Zend/zend_API.h
@@ -340,11 +340,11 @@ ZEND_API zend_result zend_parse_method_parameters_ex(int flags, uint32_t
num_arg
/* End of parameter parsing API -- andrei */
-ZEND_API zend_result zend_register_functions(zend_class_entry *scope, const zend_function_entry
*functions, HashTable *function_table, int type);
+ZEND_API zend_result zend_register_functions(zend_class_entry *scope, const zend_function_entry
*functions, HashTable *function_table, zend_module_type type);
ZEND_API void zend_unregister_functions(const zend_function_entry *functions, int count, HashTable
*function_table);
ZEND_API zend_result zend_startup_module(zend_module_entry *module_entry);
ZEND_API zend_module_entry* zend_register_internal_module(zend_module_entry *module_entry);
-ZEND_API zend_module_entry* zend_register_module_ex(zend_module_entry *module, int module_type);
+ZEND_API zend_module_entry* zend_register_module_ex(zend_module_entry *module, zend_module_type
module_type);
ZEND_API zend_result zend_startup_module_ex(zend_module_entry *module);
ZEND_API void zend_startup_modules(void);
ZEND_API void zend_collect_module_handlers(void);
diff --git a/Zend/zend_ini.c b/Zend/zend_ini.c
index fb31f3cbe983..c72163d75a45 100644
--- a/Zend/zend_ini.c
+++ b/Zend/zend_ini.c
@@ -200,7 +200,7 @@ ZEND_API void zend_ini_sort_entries(void) /* {{{ */
/*
* Registration / unregistration
*/
-ZEND_API zend_result zend_register_ini_entries_ex(const zend_ini_entry_def *ini_entry, int
module_number, int module_type)
+ZEND_API zend_result zend_register_ini_entries_ex(const zend_ini_entry_def *ini_entry, int
module_number, zend_module_type module_type)
{
zend_ini_entry *p;
zval *default_value;
@@ -282,7 +282,7 @@ ZEND_API zend_result zend_register_ini_entries(const zend_ini_entry_def *ini_ent
}
/* }}} */
-ZEND_API void zend_unregister_ini_entries_ex(int module_number, int module_type)
+ZEND_API void zend_unregister_ini_entries_ex(int module_number, zend_module_type module_type)
{
HashTable *ini_directives;
diff --git a/Zend/zend_ini.h b/Zend/zend_ini.h
index c9db91237243..efd8eae976fd 100644
--- a/Zend/zend_ini.h
+++ b/Zend/zend_ini.h
@@ -74,9 +74,9 @@ ZEND_API void zend_copy_ini_directives(void);
ZEND_API void zend_ini_sort_entries(void);
ZEND_API zend_result zend_register_ini_entries(const zend_ini_entry_def *ini_entry, int
module_number);
-ZEND_API zend_result zend_register_ini_entries_ex(const zend_ini_entry_def *ini_entry, int
module_number, int module_type);
+ZEND_API zend_result zend_register_ini_entries_ex(const zend_ini_entry_def *ini_entry, int
module_number, zend_module_type module_type);
ZEND_API void zend_unregister_ini_entries(int module_number);
-ZEND_API void zend_unregister_ini_entries_ex(int module_number, int module_type);
+ZEND_API void zend_unregister_ini_entries_ex(int module_number, zend_module_type module_type);
ZEND_API void zend_ini_refresh_caches(int stage);
ZEND_API zend_result zend_alter_ini_entry(zend_string *name, zend_string *new_value, int
modify_type, int stage);
ZEND_API zend_result zend_alter_ini_entry_ex(zend_string *name, zend_string *new_value, int
modify_type, int stage, bool force_change);
diff --git a/Zend/zend_modules.h b/Zend/zend_modules.h
index a941fd063a5b..d8f1b80bacb0 100644
--- a/Zend/zend_modules.h
+++ b/Zend/zend_modules.h
@@ -23,9 +23,9 @@
#include "zend_compile.h"
#include "zend_build.h"
-#define INIT_FUNC_ARGS int type, int module_number
+#define INIT_FUNC_ARGS zend_module_type type, int module_number
#define INIT_FUNC_ARGS_PASSTHRU type, module_number
-#define SHUTDOWN_FUNC_ARGS int type, int module_number
+#define SHUTDOWN_FUNC_ARGS zend_module_type type, int module_number
#define SHUTDOWN_FUNC_ARGS_PASSTHRU type, module_number
#define ZEND_MODULE_INFO_FUNC_ARGS zend_module_entry *zend_module
#define ZEND_MODULE_INFO_FUNC_ARGS_PASSTHRU zend_module
@@ -65,8 +65,10 @@
#define NO_VERSION_YET NULL
-#define MODULE_PERSISTENT 1
-#define MODULE_TEMPORARY 2
+C23_ENUM(zend_module_type, uint8_t) {
+ MODULE_PERSISTENT = 1,
+ MODULE_TEMPORARY = 2,
+};
struct _zend_ini_entry;
typedef struct _zend_module_entry zend_module_entry;
@@ -98,15 +100,17 @@ struct _zend_module_entry {
zend_result (*post_deactivate_func)(void);
void (*child_init_func)(void);
int module_started;
- unsigned char type;
+ zend_module_type type;
void *handle;
int module_number;
const char *build_id;
};
-#define MODULE_DEP_REQUIRED 1
-#define MODULE_DEP_CONFLICTS 2
-#define MODULE_DEP_OPTIONAL 3
+C23_ENUM(zend_module_dependency_type, uint8_t) {
+ MODULE_DEP_REQUIRED = 1,
+ MODULE_DEP_CONFLICTS = 2,
+ MODULE_DEP_OPTIONAL = 3,
+};
#define ZEND_MOD_REQUIRED_EX(name, rel, ver) { name, rel, ver, MODULE_DEP_REQUIRED },
#define ZEND_MOD_CONFLICTS_EX(name, rel, ver) { name, rel, ver, MODULE_DEP_CONFLICTS },
@@ -122,7 +126,7 @@ struct _zend_module_dep {
const char *name; /* module name */
const char *rel; /* version relationship: NULL (exists), lt|le|eq|ge|gt (to given version) */
const char *version; /* version */
- unsigned char type; /* dependency type */
+ zend_module_dependency_type type; /* dependency type */
};
BEGIN_EXTERN_C()
diff --git a/ext/standard/dl.c b/ext/standard/dl.c
index ad2035fb5c74..2d7d023406dc 100644
--- a/ext/standard/dl.c
+++ b/ext/standard/dl.c
@@ -106,7 +106,7 @@ PHPAPI void *php_load_shlib(const char *path, char **errp)
/* }}} */
/* {{{ php_load_extension */
-PHPAPI zend_result php_load_extension(const char *filename, int type, bool start_now)
+PHPAPI zend_result php_load_extension(const char *filename, zend_module_type type, bool start_now)
{
void *handle;
char *libpath;
diff --git a/ext/standard/dl.h b/ext/standard/dl.h
index bd0118bd6ab2..9ce5de9e9274 100644
--- a/ext/standard/dl.h
+++ b/ext/standard/dl.h
@@ -17,7 +17,7 @@
#ifndef DL_H
#define DL_H
-PHPAPI zend_result php_load_extension(const char *filename, int type, bool start_now);
+PHPAPI zend_result php_load_extension(const char *filename, zend_module_type type, bool start_now);
PHPAPI void *php_load_shlib(const char *path, char **errp);
/* dynamic loading functions */