From e628c66f9d4173e585081ddef358505433f9a288 Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Wed, 4 Jan 2023 14:24:28 +0100 Subject: [PATCH] #include cleanup (#10216) Shift header include In the C file, include the header first so missing #includes are detected by the compiler, and use lighter header dependencies in the header, to speed up compile times. --- Zend/zend_alloc.c | 2 +- Zend/zend_alloc.h | 6 ++---- Zend/zend_hash.c | 1 + Zend/zend_hash.h | 7 +++++-- Zend/zend_portability.h | 6 ++++++ Zend/zend_sort.c | 2 -- Zend/zend_sort.h | 3 +++ Zend/zend_string.c | 1 + Zend/zend_string.h | 4 +++- 9 files changed, 22 insertions(+), 10 deletions(-) diff --git a/Zend/zend_alloc.c b/Zend/zend_alloc.c index 5f11f49b071..5f2f25c0c48 100644 --- a/Zend/zend_alloc.c +++ b/Zend/zend_alloc.c @@ -51,8 +51,8 @@ * with more specialized routines when the requested size is known. */ -#include "zend.h" #include "zend_alloc.h" +#include "zend.h" #include "zend_globals.h" #include "zend_operators.h" #include "zend_multiply.h" diff --git a/Zend/zend_alloc.h b/Zend/zend_alloc.h index 578d4c78cc5..0fe1ff98c6f 100644 --- a/Zend/zend_alloc.h +++ b/Zend/zend_alloc.h @@ -21,10 +21,8 @@ #ifndef ZEND_ALLOC_H #define ZEND_ALLOC_H -#include - -#include "../TSRM/TSRM.h" -#include "zend.h" +#include "zend_portability.h" // for BEGIN_EXTERN_C +#include "zend_types.h" // for zend_result #ifndef ZEND_MM_ALIGNMENT # error "ZEND_MM_ALIGNMENT was not defined during configure" diff --git a/Zend/zend_hash.c b/Zend/zend_hash.c index ef7111fafb5..29cd57076e7 100644 --- a/Zend/zend_hash.c +++ b/Zend/zend_hash.c @@ -18,6 +18,7 @@ +----------------------------------------------------------------------+ */ +#include "zend_hash.h" #include "zend.h" #include "zend_globals.h" #include "zend_variables.h" diff --git a/Zend/zend_hash.h b/Zend/zend_hash.h index 93b9f0d4530..09495f5fb2f 100644 --- a/Zend/zend_hash.h +++ b/Zend/zend_hash.h @@ -21,8 +21,11 @@ #ifndef ZEND_HASH_H #define ZEND_HASH_H -#include "zend.h" -#include "zend_sort.h" +#include "zend_alloc.h" // for pefree() +#include "zend_long.h" +#include "zend_portability.h" // for BEGIN_EXTERN_C +#include "zend_sort.h" // for zend_sort() +#include "zend_string.h" // for ZSTR_VAL() #define HASH_KEY_IS_STRING 1 #define HASH_KEY_IS_LONG 2 diff --git a/Zend/zend_portability.h b/Zend/zend_portability.h index 7fdeedee19b..6ddef3cd831 100644 --- a/Zend/zend_portability.h +++ b/Zend/zend_portability.h @@ -21,6 +21,12 @@ #ifndef ZEND_PORTABILITY_H #define ZEND_PORTABILITY_H +#ifdef PHP_WIN32 +#include "config.w32.h" +#else +#include "php_config.h" // for HAVE_* +#endif + #ifdef __cplusplus #define BEGIN_EXTERN_C() extern "C" { #define END_EXTERN_C() } diff --git a/Zend/zend_sort.c b/Zend/zend_sort.c index 355d2d1bad5..f43d5cae63f 100644 --- a/Zend/zend_sort.c +++ b/Zend/zend_sort.c @@ -17,9 +17,7 @@ +----------------------------------------------------------------------+ */ -#include "zend.h" #include "zend_sort.h" -#include static inline void zend_sort_2(void *a, void *b, compare_func_t cmp, swap_func_t swp) /* {{{ */ { if (cmp(a, b) > 0) { diff --git a/Zend/zend_sort.h b/Zend/zend_sort.h index e606935f790..320b5e56066 100644 --- a/Zend/zend_sort.h +++ b/Zend/zend_sort.h @@ -20,6 +20,9 @@ #ifndef ZEND_SORT_H #define ZEND_SORT_H +#include "zend_portability.h" // for BEGIN_EXTERN_C +#include "zend_types.h" // for compare_func_t, swap_func_t + BEGIN_EXTERN_C() ZEND_API void zend_sort(void *base, size_t nmemb, size_t siz, compare_func_t cmp, swap_func_t swp); ZEND_API void zend_insert_sort(void *base, size_t nmemb, size_t siz, compare_func_t cmp, swap_func_t swp); diff --git a/Zend/zend_string.c b/Zend/zend_string.c index 68e6084fdf6..eef68c8e8ac 100644 --- a/Zend/zend_string.c +++ b/Zend/zend_string.c @@ -16,6 +16,7 @@ +----------------------------------------------------------------------+ */ +#include "zend_string.h" #include "zend.h" #include "zend_globals.h" diff --git a/Zend/zend_string.h b/Zend/zend_string.h index ed59ef82a14..8705b4c300c 100644 --- a/Zend/zend_string.h +++ b/Zend/zend_string.h @@ -19,7 +19,9 @@ #ifndef ZEND_STRING_H #define ZEND_STRING_H -#include "zend.h" +#include "zend_alloc.h" // for pemalloc() +#include "zend_portability.h" // for BEGIN_EXTERN_C +#include "zend_types.h" // for zend_string BEGIN_EXTERN_C()