From abed8b8e417e69d43f1ccd9e2c473f95dbab2400 Mon Sep 17 00:00:00 2001 From: Peter Kokot Date: Fri, 22 Sep 2023 22:31:19 +0200 Subject: [PATCH] Remove _IO_cookie_io_functions_t in favor of cookie_io_functions_t As noted in glibc, the cookie_io_functions_t should be used instead of internal _IO_cookie_io_functions_t. The _IO_cookie_io_functions_t was once used as a convenience for not having the cookie_io_functions_t available (glibc <=2.1.1) as noted in 67bb9d1ae23fe4c7e4160dabfb4f07b51dccabf1. Check in the build system was also always setting the COOKIE_IO_FUNCTIONS_T to cookie_io_functions_t due to a typo. There is unused variable have_IO_cookie_io_functions_t vs. have_cookie_io_functions_t. - COOKIE_IO_FUNCTIONS_T removed Closes GH-12236 --- UPGRADING.INTERNALS | 1 + build/php.m4 | 24 +++--------------------- main/streams/cast.c | 6 +++--- 3 files changed, 7 insertions(+), 24 deletions(-) diff --git a/UPGRADING.INTERNALS b/UPGRADING.INTERNALS index 781d56cc1bc..0651402518a 100644 --- a/UPGRADING.INTERNALS +++ b/UPGRADING.INTERNALS @@ -25,6 +25,7 @@ PHP 8.4 INTERNALS UPGRADE NOTES a. Unix build system changes - The configure option --with-zlib-dir has been removed. + - Symbol COOKIE_IO_FUNCTIONS_T has been removed (use cookie_io_functions_t). ======================== 3. Module changes diff --git a/build/php.m4 b/build/php.m4 index e66451fccc8..43e06422d3f 100644 --- a/build/php.m4 +++ b/build/php.m4 @@ -1431,18 +1431,14 @@ AC_DEFUN([PHP_FOPENCOOKIE], [ AC_CHECK_FUNC(fopencookie, [have_glibc_fopencookie=yes]) if test "$have_glibc_fopencookie" = "yes"; then -dnl This comes in two flavors: newer glibcs (since 2.1.2?) have a type called -dnl cookie_io_functions_t. +dnl glibcs (since 2.1.2?) have a type called cookie_io_functions_t. AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ #define _GNU_SOURCE #include ]], [[cookie_io_functions_t cookie;]])],[have_cookie_io_functions_t=yes],[]) if test "$have_cookie_io_functions_t" = "yes"; then - cookie_io_functions_t=cookie_io_functions_t - have_fopen_cookie=yes - -dnl Even newer glibcs have a different seeker definition. +dnl Newer glibcs have a different seeker definition. AC_RUN_IFELSE([AC_LANG_SOURCE([[ #define _GNU_SOURCE #include @@ -1488,22 +1484,8 @@ int main(void) { esac ]) - else - -dnl Older glibc versions (up to 2.1.2?) call it _IO_cookie_io_functions_t. -AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ -#define _GNU_SOURCE -#include -]], [[_IO_cookie_io_functions_t cookie;]])], [have_IO_cookie_io_functions_t=yes], []) - if test "$have_cookie_io_functions_t" = "yes" ; then - cookie_io_functions_t=_IO_cookie_io_functions_t - have_fopen_cookie=yes - fi - fi - - if test "$have_fopen_cookie" = "yes" ; then AC_DEFINE(HAVE_FOPENCOOKIE, 1, [ ]) - AC_DEFINE_UNQUOTED(COOKIE_IO_FUNCTIONS_T, $cookie_io_functions_t, [ ]) + if test "$cookie_io_functions_use_off64_t" = "yes" ; then AC_DEFINE(COOKIE_SEEKER_USES_OFF64_T, 1, [ ]) fi diff --git a/main/streams/cast.c b/main/streams/cast.c index 3bad65fbac1..dbeeff7b09f 100644 --- a/main/streams/cast.c +++ b/main/streams/cast.c @@ -42,9 +42,9 @@ typedef struct { int (*writer)(void *, const char *, int); PHP_FPOS_T (*seeker)(void *, PHP_FPOS_T, int); int (*closer)(void *); -} COOKIE_IO_FUNCTIONS_T; +} cookie_io_functions_t; -FILE *fopencookie(void *cookie, const char *mode, COOKIE_IO_FUNCTIONS_T *funcs) +FILE *fopencookie(void *cookie, const char *mode, cookie_io_functions_t *funcs) { return funopen(cookie, funcs->reader, funcs->writer, funcs->seeker, funcs->closer); } @@ -133,7 +133,7 @@ static int stream_cookie_closer(void *cookie) #endif /* elif defined(HAVE_FOPENCOOKIE) */ #if HAVE_FOPENCOOKIE -static COOKIE_IO_FUNCTIONS_T stream_cookie_functions = +static cookie_io_functions_t stream_cookie_functions = { stream_cookie_reader, stream_cookie_writer, stream_cookie_seeker, stream_cookie_closer