From d08451b2ca816e3c8f7c07888355a926bef4a487 Mon Sep 17 00:00:00 2001 From: George Peter Banyard Date: Sun, 29 May 2022 11:20:56 +0100 Subject: [PATCH] Replace php_stdint.h header with standard headers (#8613) --- TSRM/TSRM.h | 2 +- UPGRADING.INTERNALS | 3 ++ Zend/zend_long.h | 3 +- ext/date/config.w32 | 3 +- ext/date/config0.m4 | 3 +- ext/fileinfo/libmagic.patch | 3 +- ext/fileinfo/libmagic/strcasestr.c | 4 +-- ext/mysqlnd/mysqlnd_portability.h | 2 +- ext/session/mod_mm.c | 2 +- main/php.h | 2 -- main/php_stdint.h | 51 ------------------------------ sapi/cli/php_http_parser.h | 2 +- sapi/phpdbg/phpdbg.h | 8 ++--- 13 files changed, 19 insertions(+), 69 deletions(-) delete mode 100644 main/php_stdint.h diff --git a/TSRM/TSRM.h b/TSRM/TSRM.h index e6feacf8bcc..60b65ca8ec7 100644 --- a/TSRM/TSRM.h +++ b/TSRM/TSRM.h @@ -20,7 +20,7 @@ # include "main/php_config.h" #endif -#include "main/php_stdint.h" +#include #include #ifdef TSRM_WIN32 diff --git a/UPGRADING.INTERNALS b/UPGRADING.INTERNALS index 8fb26f2a7e5..3bff661ebde 100644 --- a/UPGRADING.INTERNALS +++ b/UPGRADING.INTERNALS @@ -21,6 +21,9 @@ PHP 8.2 INTERNALS UPGRADE NOTES Call zend_str_tolower() yourself if necessary. You no longer need to copy the haystack and needle before passing them to php_stristr(). * zend_register_module_ex() no longer copies the module entry. +* The main/php_stdint.h header has been removed. + Include the standard and/or headers instead. + Replace usage of u_char by the standard C99 uint8_t type. ======================== 2. Build system changes diff --git a/Zend/zend_long.h b/Zend/zend_long.h index 453098c1eb0..3796f1c5aba 100644 --- a/Zend/zend_long.h +++ b/Zend/zend_long.h @@ -19,7 +19,8 @@ #ifndef ZEND_LONG_H #define ZEND_LONG_H -#include "main/php_stdint.h" +#include +#include /* This is the heart of the whole int64 enablement in zval. */ #if defined(__x86_64__) || defined(__LP64__) || defined(_LP64) || defined(_WIN64) diff --git a/ext/date/config.w32 b/ext/date/config.w32 index 4223cbcff29..cf9e220c558 100644 --- a/ext/date/config.w32 +++ b/ext/date/config.w32 @@ -8,7 +8,8 @@ ADD_FLAG('CFLAGS_DATE', "/wd4244"); var tl_config = FSO.CreateTextFile("ext/date/lib/timelib_config.h", true); tl_config.WriteLine("#include \"config.w32.h\""); -tl_config.WriteLine("#include "); +tl_config.WriteLine("#include "); +tl_config.WriteLine("#include "); tl_config.WriteLine("#include \"zend.h\""); tl_config.WriteLine("#define timelib_malloc emalloc"); tl_config.WriteLine("#define timelib_realloc erealloc"); diff --git a/ext/date/config0.m4 b/ext/date/config0.m4 index 18b8106bd2d..6b803bf33e5 100644 --- a/ext/date/config0.m4 +++ b/ext/date/config0.m4 @@ -23,7 +23,8 @@ cat > $ext_builddir/lib/timelib_config.h < #endif -#include +#include +#include #include "zend.h" diff --git a/ext/fileinfo/libmagic.patch b/ext/fileinfo/libmagic.patch index 72490d727f5..af0080ba5db 100644 --- a/ext/fileinfo/libmagic.patch +++ b/ext/fileinfo/libmagic.patch @@ -3503,7 +3503,8 @@ diff -u libmagic.orig/strcasestr.c libmagic/strcasestr.c #include "file.h" -+#include "php_stdint.h" ++#include ++#include + #include #include diff --git a/ext/fileinfo/libmagic/strcasestr.c b/ext/fileinfo/libmagic/strcasestr.c index 1d156883fba..4d62787c70d 100644 --- a/ext/fileinfo/libmagic/strcasestr.c +++ b/ext/fileinfo/libmagic/strcasestr.c @@ -39,8 +39,8 @@ __RCSID("$NetBSD: strncasecmp.c,v 1.2 2007/06/04 18:19:27 christos Exp $"); #include "file.h" -#include "php_stdint.h" - +#include +#include #include #include #include diff --git a/ext/mysqlnd/mysqlnd_portability.h b/ext/mysqlnd/mysqlnd_portability.h index 99406fa90cd..295ce393a11 100644 --- a/ext/mysqlnd/mysqlnd_portability.h +++ b/ext/mysqlnd/mysqlnd_portability.h @@ -38,7 +38,7 @@ This file is public domain and comes with NO WARRANTY of any kind */ #define atoll atol #endif -#include "php_stdint.h" +#include #if SIZEOF_LONG_LONG > 4 && !defined(_LONG_LONG) #define _LONG_LONG 1 /* For AIX string library */ diff --git a/ext/session/mod_mm.c b/ext/session/mod_mm.c index baec6f5a7fd..fe05a6451ae 100644 --- a/ext/session/mod_mm.c +++ b/ext/session/mod_mm.c @@ -24,8 +24,8 @@ #include #include #include +#include -#include "php_stdint.h" #include "php_session.h" #include "mod_mm.h" #include "SAPI.h" diff --git a/main/php.h b/main/php.h index 1fa7457f89d..c8ef2d05818 100644 --- a/main/php.h +++ b/main/php.h @@ -211,8 +211,6 @@ typedef unsigned int socklen_t; #include -#include "php_stdint.h" - #include "zend_hash.h" #include "zend_alloc.h" #include "zend_stack.h" diff --git a/main/php_stdint.h b/main/php_stdint.h deleted file mode 100644 index be4ca734407..00000000000 --- a/main/php_stdint.h +++ /dev/null @@ -1,51 +0,0 @@ -/* - +----------------------------------------------------------------------+ - | Copyright (c) The PHP Group | - +----------------------------------------------------------------------+ - | This source file is subject to version 3.01 of the PHP license, | - | that is bundled with this package in the file LICENSE, and is | - | available through the world-wide-web at the following url: | - | https://www.php.net/license/3_01.txt | - | If you did not receive a copy of the PHP license and are unable to | - | obtain it through the world-wide-web, please send a note to | - | license@php.net so we can mail you a copy immediately. | - +----------------------------------------------------------------------+ - | Author: Michael Wallner | - +----------------------------------------------------------------------+ -*/ - -#ifndef PHP_STDINT_H -#define PHP_STDINT_H - -/* C99 requires these for C++ to get the definitions - * of INT64_MAX and other macros used by Zend/zend_long.h - * C11 drops this requirement, so these effectively - * just backport that piece of behavior. - * - * These defines are placed here instead of - * with the include below, because sys/types - * and inttypes may include stdint themselves. - * And these definitions MUST come first. - */ -#ifdef __cplusplus -# ifndef __STDC_LIMIT_MACROS -# define __STDC_LIMIT_MACROS -# endif -# ifndef __STDC_CONSTANT_MACROS -# define __STDC_CONSTANT_MACROS -# endif -# ifndef __STDC_FORMAT_MACROS -# define __STDC_FORMAT_MACROS -# endif -#endif - -#include -#include - -#if defined(_MSC_VER) -# ifndef u_char -typedef unsigned __int8 u_char; -# endif -#endif /* !_MSC_VER */ - -#endif /* PHP_STDINT_H */ diff --git a/sapi/cli/php_http_parser.h b/sapi/cli/php_http_parser.h index 131a70ea0bd..37538cdeeea 100644 --- a/sapi/cli/php_http_parser.h +++ b/sapi/cli/php_http_parser.h @@ -34,7 +34,7 @@ extern "C" { # include "php_config.h" #endif -#include "php_stdint.h" +#include /* Compile with -DPHP_HTTP_PARSER_STRICT=0 to make less checks, but run * faster diff --git a/sapi/phpdbg/phpdbg.h b/sapi/phpdbg/phpdbg.h index 1da3b055dd9..76630dc53c7 100644 --- a/sapi/phpdbg/phpdbg.h +++ b/sapi/phpdbg/phpdbg.h @@ -27,12 +27,8 @@ # define PHPDBG_API #endif -#ifndef PHP_WIN32 -# include -# include -#else -# include "main/php_stdint.h" -#endif +#include +#include #include "php.h" #include "php_globals.h" #include "php_variables.h"