Skip to content

Commit 8032d6f

Browse files
authored
Autotools: Check struct stat.st_blocks with AC_CHECK_MEMBERS (#13562)
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 ba996f7 commit 8032d6f

File tree

6 files changed

+21
-9
lines changed

6 files changed

+21
-9
lines changed

UPGRADING.INTERNALS

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,10 @@ PHP 8.6 INTERNALS UPGRADE NOTES
8484
values can be compared to the result of
8585
zend_enum_fetch_case_id(zend_object*).
8686

87+
- Unix build system changes:
88+
. Symbol HAVE_ST_BLOCKS has been removed from php_config.h (use
89+
HAVE_STRUCT_STAT_ST_BLOCKS).
90+
8791
========================
8892
3. Module changes
8993
========================

configure.ac

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

505505
dnl Check for structure members.
506506
AC_CHECK_MEMBERS([struct tm.tm_gmtoff],,,[#include <time.h>])
507-
AC_CHECK_MEMBERS([struct stat.st_blksize, struct stat.st_rdev])
508-
dnl AC_STRUCT_ST_BLOCKS will screw QNX because fileblocks.o does not exist.
509-
if test "$(uname -s 2>/dev/null)" != "QNX"; then
510-
AC_STRUCT_ST_BLOCKS
511-
fi
507+
AC_CHECK_MEMBERS(m4_normalize([
508+
struct stat.st_blksize,
509+
struct stat.st_blocks,
510+
struct stat.st_rdev
511+
]))
512512

513513
dnl Checks for types.
514514
AC_TYPE_UID_T

ext/phar/func_interceptors.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -631,8 +631,10 @@ static void phar_file_stat(const char *filename, size_t filename_length, int typ
631631
if (data) {
632632
sb.st_ino = data->inode;
633633
}
634-
#ifndef PHP_WIN32
634+
#ifdef HAVE_STRUCT_STAT_ST_BLKSIZE
635635
sb.st_blksize = -1;
636+
#endif
637+
#ifdef HAVE_STRUCT_STAT_ST_BLOCKS
636638
sb.st_blocks = -1;
637639
#endif
638640
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
@@ -526,8 +526,10 @@ void phar_dostat(phar_archive_data *phar, phar_entry_info *data, php_stream_stat
526526
if (!is_temp_dir) {
527527
ssb->sb.st_ino = data->inode;
528528
}
529-
#ifndef PHP_WIN32
529+
#ifdef HAVE_STRUCT_STAT_ST_BLKSIZE
530530
ssb->sb.st_blksize = -1;
531+
#endif
532+
#ifdef HAVE_STRUCT_STAT_ST_BLOCKS
531533
ssb->sb.st_blocks = -1;
532534
#endif
533535
}

ext/zip/zip_stream.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -177,8 +177,10 @@ static int php_zip_ops_stat(php_stream *stream, php_stream_statbuf *ssb) /* {{{
177177
ssb->sb.st_ctime = sb.mtime;
178178
ssb->sb.st_nlink = 1;
179179
ssb->sb.st_rdev = -1;
180-
#ifndef PHP_WIN32
180+
#ifdef HAVE_STRUCT_STAT_ST_BLKSIZE
181181
ssb->sb.st_blksize = -1;
182+
#endif
183+
#ifdef HAVE_STRUCT_STAT_ST_BLOCKS
182184
ssb->sb.st_blocks = -1;
183185
#endif
184186
ssb->sb.st_ino = -1;

main/streams/memory.c

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

216-
#ifndef PHP_WIN32
216+
#ifdef HAVE_STRUCT_STAT_ST_BLKSIZE
217217
ssb->sb.st_blksize = -1;
218+
#endif
219+
#ifdef HAVE_STRUCT_STAT_ST_BLOCKS
218220
ssb->sb.st_blocks = -1;
219221
#endif
220222

0 commit comments

Comments
 (0)