@@ -1319,24 +1319,20 @@ int main(void)
1319
1319
dnl
1320
1320
dnl PHP_FOPENCOOKIE
1321
1321
dnl
1322
- AC_DEFUN ( [ PHP_FOPENCOOKIE] , [
1323
- AC_CHECK_FUNC ( fopencookie , [ have_glibc_fopencookie=yes] )
1324
-
1325
- if test "$have_glibc_fopencookie" = "yes"; then
1326
- dnl glibcs (since 2.1.2?) have a type called cookie_io_functions_t.
1327
- AC_COMPILE_IFELSE ( [ AC_LANG_PROGRAM ( [ [
1328
- #ifndef _GNU_SOURCE
1329
- #define _GNU_SOURCE
1330
- #endif
1331
- #include <stdio.h>
1332
- ] ] , [ [ cookie_io_functions_t cookie;] ] ) ] ,[ have_cookie_io_functions_t=yes] ,[ ] )
1333
-
1334
- if test "$have_cookie_io_functions_t" = "yes"; then
1335
- dnl Newer glibcs have a different seeker definition.
1336
- AC_RUN_IFELSE ( [ AC_LANG_SOURCE ( [ [
1337
- #ifndef _GNU_SOURCE
1338
- #define _GNU_SOURCE
1339
- #endif
1322
+ dnl Check for cookie_io_functions_t type and fopencookie(). When using glibc,
1323
+ dnl checks here require _GNU_SOURCE defined via AC_USE_SYSTEM_EXTENSIONS. Some
1324
+ dnl glibc versions started using the off64_t in fopencookie seeker definition,
1325
+ dnl which is in transition to use the POSIX standard off_t on 32-bit (with large
1326
+ dnl file support enabled) and 64-bit.
1327
+ dnl
1328
+ AC_DEFUN ( [ PHP_FOPENCOOKIE] ,
1329
+ [ AC_CHECK_TYPE ( [ cookie_io_functions_t] , [ AC_CHECK_FUNCS ( [ fopencookie] ) ] ,,
1330
+ [ #include <stdio.h>] )
1331
+ dnl Check if glibc might use off64_t seeker definition.
1332
+ AS_VAR_IF ( [ ac_cv_func_fopencookie] , [ yes] ,
1333
+ [ AC_CACHE_CHECK ( [ whether fopencookie seeker uses off64_t] ,
1334
+ [ php_cv_type_cookie_off64_t] ,
1335
+ [ AC_RUN_IFELSE ( [ AC_LANG_SOURCE ( [
1340
1336
#include <stdio.h>
1341
1337
#include <stdlib.h>
1342
1338
@@ -1345,48 +1341,35 @@ struct cookiedata {
1345
1341
};
1346
1342
1347
1343
ssize_t reader(void *cookie, char *buffer, size_t size)
1348
- { return size; }
1344
+ { (void)cookie; (void)buffer; return size; }
1349
1345
ssize_t writer(void *cookie, const char *buffer, size_t size)
1350
- { return size; }
1346
+ { (void)cookie; (void)buffer; return size; }
1351
1347
int closer(void *cookie)
1352
- { return 0; }
1348
+ { (void)cookie; return 0; }
1353
1349
int seeker(void *cookie, off64_t *position, int whence)
1354
- { ((struct cookiedata*)cookie)->pos = *position; return 0; }
1350
+ { ((struct cookiedata*)cookie)->pos = *position; (void)whence; return 0; }
1355
1351
1356
1352
cookie_io_functions_t funcs = {reader, writer, seeker, closer};
1357
1353
1358
1354
int main(void) {
1359
1355
struct cookiedata g = { 0 };
1360
1356
FILE *fp = fopencookie(&g, "r", funcs);
1361
-
1362
- if (fp && fseek(fp, 8192, SEEK_SET) == 0 && g.pos == 8192)
1357
+ if (fp && fseek(fp, 8192, SEEK_SET) == 0 && g.pos == 8192) {
1363
1358
return 0;
1359
+ }
1364
1360
return 1;
1365
1361
}
1366
-
1367
- ] ] ) ] , [
1368
- cookie_io_functions_use_off64_t=yes
1369
- ] , [
1370
- cookie_io_functions_use_off64_t=no
1371
- ] , [
1372
- dnl Cross compilation.
1373
- case $host_alias in
1374
- *linux*)
1375
- cookie_io_functions_use_off64_t=yes
1376
- ;;
1377
- *)
1378
- cookie_io_functions_use_off64_t=no
1379
- ;;
1380
- esac
1362
+ ] ) ] ,
1363
+ [ php_cv_type_cookie_off64_t=yes] ,
1364
+ [ php_cv_type_cookie_off64_t=no] ,
1365
+ [ AS_CASE ( [ $host_alias] ,
1366
+ [ *linux*] , [ php_cv_type_cookie_off64_t=yes] ,
1367
+ [ php_cv_type_cookie_off64_t=no] ) ]
1368
+ ) ] )
1369
+ AS_VAR_IF ( [ php_cv_type_cookie_off64_t] , [ yes] ,
1370
+ [ AC_DEFINE ( [ COOKIE_SEEKER_USES_OFF64_T] , [ 1] ,
1371
+ [ Whether fopencookie seeker uses off64_t.] ) ] )
1381
1372
] )
1382
-
1383
- AC_DEFINE ( HAVE_FOPENCOOKIE , 1 , [ ] )
1384
-
1385
- if test "$cookie_io_functions_use_off64_t" = "yes" ; then
1386
- AC_DEFINE ( COOKIE_SEEKER_USES_OFF64_T , 1 , [ ] )
1387
- fi
1388
- fi
1389
- fi
1390
1373
] )
1391
1374
1392
1375
dnl ----------------------------------------------------------------------------
0 commit comments