Skip to content

#include cleanup #10216

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Jan 4, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Zend/zend_alloc.c
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
6 changes: 2 additions & 4 deletions Zend/zend_alloc.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,8 @@
#ifndef ZEND_ALLOC_H
#define ZEND_ALLOC_H

#include <stdio.h>

#include "../TSRM/TSRM.h"
#include "zend.h"
#include "zend_portability.h" // for BEGIN_EXTERN_C
#include "zend_types.h" // for zend_result
Copy link
Contributor

@smalyshev smalyshev Feb 1, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The issue I have with such comments is that they are very fragile. As the code changes, it may use more of the things in this file. It may stop using zend_result. zend_result may be moved to another header file or cease to exist. But unless the file is going to go away completely, or similar major change happens, nobody would bother to update all comments of this nature. It is not realistic to expect from people who alter the code to evaluate each time whether their code was the last instance of using some particular construct introduced in some include, and whether now we need to change the comment to some other construct also introduced by that include - nobody ever is going to do that. So this may be technically true now - but in a year, we won't know if it's true, and in three years, it becomes just meaningless.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That would be RFC vote "Is it allowed to document an #include line with a code comment?" - https://wiki.php.net/rfc/include_cleanup - please vote!
See also #10472


#ifndef ZEND_MM_ALIGNMENT
# error "ZEND_MM_ALIGNMENT was not defined during configure"
Expand Down
1 change: 1 addition & 0 deletions Zend/zend_hash.c
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
+----------------------------------------------------------------------+
*/

#include "zend_hash.h"
#include "zend.h"
#include "zend_globals.h"
#include "zend_variables.h"
Expand Down
7 changes: 5 additions & 2 deletions Zend/zend_hash.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 6 additions & 0 deletions Zend/zend_portability.h
Original file line number Diff line number Diff line change
Expand Up @@ -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() }
Expand Down
2 changes: 0 additions & 2 deletions Zend/zend_sort.c
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,7 @@
+----------------------------------------------------------------------+
*/

#include "zend.h"
#include "zend_sort.h"
#include <limits.h>

static inline void zend_sort_2(void *a, void *b, compare_func_t cmp, swap_func_t swp) /* {{{ */ {
if (cmp(a, b) > 0) {
Expand Down
3 changes: 3 additions & 0 deletions Zend/zend_sort.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
1 change: 1 addition & 0 deletions Zend/zend_string.c
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
+----------------------------------------------------------------------+
*/

#include "zend_string.h"
#include "zend.h"
#include "zend_globals.h"

Expand Down
4 changes: 3 additions & 1 deletion Zend/zend_string.h
Original file line number Diff line number Diff line change
Expand Up @@ -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()

Expand Down