Skip to content

Commit e165e93

Browse files
committed
Autotools: Check struct stat.st_blocks with AC_CHECK_MEMBERS
The AC_STRUCT_ST_BLOCKS expects fileblocks object to be compiled with AC_LIBOBJ if stat.st_blocks is missing on the system. This can be simplified with the usual AC_CHECK_MEMBERS since PHP is using the stat.st_blocks (and stat.st_blksize) conditionally. These members are mostly present on all POSIX-based systems except on Windows these days. This also removes the obsolete HAVE_ST_BLOCKS symbol: https://git.savannah.gnu.org/cgit/autoconf.git/tree/lib/autoconf/types.m4?h=v2.72#n1055 Additionally, the st_blksize and st_blocks members are checked conditionally with HAVE_ preprocessor macros. Instead of filtering Windows specifically here, the preprocessor macros HAVE_STRUCT_STAT_ST_BLKSIZE and HAVE_STRUCT_STAT_ST_BLOCKS can be used.
1 parent 8699da6 commit e165e93

File tree

6 files changed

+18
-9
lines changed

6 files changed

+18
-9
lines changed

UPGRADING.INTERNALS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,7 @@ PHP 8.4 INTERNALS UPGRADE NOTES
162162
- Symbols PHP_HAVE_AVX512_SUPPORTS and PHP_HAVE_AVX512_VBMI_SUPPORTS are now
163163
either defined to 1 or undefined.
164164
- Symbol HAVE_LIBCRYPT has been removed.
165+
- Symbol HAVE_ST_BLOCKS has been removed (use HAVE_STRUCT_STAT_ST_BLOCKS).
165166
- M4 macro PHP_DEFINE (atomic includes) removed (use AC_DEFINE and config.h).
166167
- M4 macro PHP_WITH_SHARED has been removed (use PHP_ARG_WITH).
167168
- M4 macro PHP_STRUCT_FLOCK has been removed (use AC_CHECK_TYPES).

configure.ac

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -497,11 +497,11 @@ AS_VAR_IF([php_cv_have_alignof], [yes],
497497

498498
dnl Check for structure members.
499499
AC_CHECK_MEMBERS([struct tm.tm_gmtoff],,,[#include <time.h>])
500-
AC_CHECK_MEMBERS([struct stat.st_blksize, struct stat.st_rdev])
501-
dnl AC_STRUCT_ST_BLOCKS will screw QNX because fileblocks.o does not exist.
502-
if test "$(uname -s 2>/dev/null)" != "QNX"; then
503-
AC_STRUCT_ST_BLOCKS
504-
fi
500+
AC_CHECK_MEMBERS(m4_normalize([
501+
struct stat.st_blksize,
502+
struct stat.st_blocks,
503+
struct stat.st_rdev
504+
]))
505505

506506
dnl Checks for types.
507507
AC_TYPE_UID_T

ext/phar/func_interceptors.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -637,8 +637,10 @@ static void phar_file_stat(const char *filename, size_t filename_length, int typ
637637
if (data) {
638638
sb.st_ino = data->inode;
639639
}
640-
#ifndef PHP_WIN32
640+
#ifdef HAVE_STRUCT_STAT_ST_BLKSIZE
641641
sb.st_blksize = -1;
642+
#endif
643+
#ifdef HAVE_STRUCT_STAT_ST_BLOCKS
642644
sb.st_blocks = -1;
643645
#endif
644646
phar_fancy_stat(&sb, type, return_value);

ext/phar/stream.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -530,8 +530,10 @@ void phar_dostat(phar_archive_data *phar, phar_entry_info *data, php_stream_stat
530530
if (!is_temp_dir) {
531531
ssb->sb.st_ino = data->inode;
532532
}
533-
#ifndef PHP_WIN32
533+
#ifdef HAVE_STRUCT_STAT_ST_BLKSIZE
534534
ssb->sb.st_blksize = -1;
535+
#endif
536+
#ifdef HAVE_STRUCT_STAT_ST_BLOCKS
535537
ssb->sb.st_blocks = -1;
536538
#endif
537539
}

ext/zip/zip_stream.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -184,8 +184,10 @@ static int php_zip_ops_stat(php_stream *stream, php_stream_statbuf *ssb) /* {{{
184184
ssb->sb.st_ctime = sb.mtime;
185185
ssb->sb.st_nlink = 1;
186186
ssb->sb.st_rdev = -1;
187-
#ifndef PHP_WIN32
187+
#ifdef HAVE_STRUCT_STAT_ST_BLKSIZE
188188
ssb->sb.st_blksize = -1;
189+
#endif
190+
#ifdef HAVE_STRUCT_STAT_ST_BLOCKS
189191
ssb->sb.st_blocks = -1;
190192
#endif
191193
ssb->sb.st_ino = -1;

main/streams/memory.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -208,8 +208,10 @@ static int php_stream_memory_stat(php_stream *stream, php_stream_statbuf *ssb) /
208208
/* generate unique inode number for alias/filename, so no phars will conflict */
209209
ssb->sb.st_ino = 0;
210210

211-
#ifndef PHP_WIN32
211+
#ifdef HAVE_STRUCT_STAT_ST_BLKSIZE
212212
ssb->sb.st_blksize = -1;
213+
#endif
214+
#ifdef HAVE_STRUCT_STAT_ST_BLOCKS
213215
ssb->sb.st_blocks = -1;
214216
#endif
215217

0 commit comments

Comments
 (0)