Skip to content

Commit 67bb9d1

Browse files
author
Hartmut Holzgraefe
committed
fixed a compile problem with glibc<=2.1.1 (#7327, #7892)
# zlib.c still produces a warning, perhaps i should move # the fopen wrapper to a seperate file to get things right # but i think i will wait for the autoconf book to arrive
1 parent b2c957d commit 67bb9d1

File tree

2 files changed

+41
-2
lines changed

2 files changed

+41
-2
lines changed

ext/zlib/config.m4

Lines changed: 39 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,5 +42,43 @@ if test "$PHP_ZLIB" != "no"; then
4242

4343
AC_ADD_INCLUDE($ZLIB_INCDIR)
4444

45-
AC_CHECK_FUNC(fopencookie, [AC_DEFINE(HAVE_FOPENCOOKIE,1,[ ])])
45+
dnl check for fopencookie() from glibc
46+
AC_CHECK_FUNC(fopencookie, [ have_glibc_fopencookie=yes ])
47+
48+
if test "$have_glibc_fopencookie" = "yes" ; then
49+
dnl this comes in two flavors:
50+
dnl newer glibcs (since 2.1.2 ? )
51+
dnl have a type called cookie_io_functions_t
52+
AC_TRY_COMPILE([ #define _GNU_SOURCE
53+
#include <stdio.h>
54+
],
55+
[ cookie_io_functions_t cookie; ],
56+
[ have_cookie_io_functions_t=yes ],
57+
[ ] )
58+
59+
if test "$have_cookie_io_functions_t" = "yes" ; then
60+
cookie_io_functions_t=cookie_io_functions_t
61+
have_fopen_cookie=yes
62+
else
63+
dnl older glibc versions (up to 2.1.2 ?)
64+
dnl call it _IO_cookie_io_functions_t
65+
AC_TRY_COMPILE([ #define _GNU_SOURCE
66+
#include <stdio.h>
67+
],
68+
[ _IO_cookie_io_functions_t cookie; ],
69+
[ have_IO_cookie_io_functions_t=yes ],
70+
[] )
71+
if test "$have_cookie_io_functions_t" = "yes" ; then
72+
cookie_io_functions_t=_IO_cookie_io_functions_t
73+
have_fopen_cookie=yes
74+
fi
75+
fi
76+
77+
if test "$have_fopen_cookie" = "yes" ; then
78+
AC_DEFINE(HAVE_FOPENCOOKIE, 1, [ ])
79+
AC_DEFINE_UNQUOTED(COOKIE_IO_FUNCTIONS_T, $cookie_io_functions_t, [ ])
80+
fi
81+
82+
fi
83+
4684
fi

ext/zlib/zlib.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -967,7 +967,8 @@ static int gz_closer(void *cookie) {
967967
}
968968

969969

970-
static cookie_io_functions_t gz_cookie_functions =
970+
971+
static COOKIE_IO_FUNCTIONS_T gz_cookie_functions =
971972
{ gz_reader
972973
, gz_writer
973974
, gz_seeker

0 commit comments

Comments
 (0)