]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
gh-83714: Check for struct statx.stx_atomic_write_unit_max_opt in configure (#140185)
authorJeffrey Bosboom <jbosboom@jeffreybosboom.com>
Thu, 16 Oct 2025 11:40:47 +0000 (04:40 -0700)
committerGitHub <noreply@github.com>
Thu, 16 Oct 2025 11:40:47 +0000 (13:40 +0200)
stx_atomic_write_unit_max_opt was added in Linux 6.16, but is controlled
by the STATX_WRITE_ATOMIC mask bit added in Linux 6.11.  That's safe at
runtime because all kernels clear the reserved space in struct statx and
zero is a valid value for stx_atomic_write_unit_max_opt, and it avoids
allocating another mask bit, which are a limited resource.  But it also
means the kernel headers don't provide a way to check whether
stx_atomic_write_unit_max_opt exists, so add a configure check.

Doc/library/os.rst
Modules/posixmodule.c
configure
configure.ac
pyconfig.h.in

index 1ac87b32badd78a54c4f8422f478a16e94cd9bff..c3ed6a976926fdd8225b6af12fffd8187a02f552 100644 (file)
@@ -3496,7 +3496,7 @@ features:
       Maximum optimized size for direct I/O with torn-write protection.
 
       .. availability:: Linux >= 4.11 with glibc >= 2.28 and build-time kernel
-         userspace API headers >= 6.11.
+         userspace API headers >= 6.16.
 
    .. attribute:: stx_atomic_write_segments_max
 
index 5c1c508578a31e5301eaf703b445ee3bab40eaef..1338be22e1867885b57c4c8d5d72653ace4ec173 100644 (file)
@@ -3369,7 +3369,7 @@ static PyMemberDef pystatx_result_members[] = {
     MM(stx_atomic_write_segments_max, Py_T_UINT, atomic_write_segments_max,
         "maximum iovecs for direct I/O with torn-write protection"),
 #endif
-#if 0
+#ifdef HAVE_STRUCT_STATX_STX_ATOMIC_WRITE_UNIT_MAX_OPT
     MM(stx_atomic_write_unit_max_opt, Py_T_UINT, atomic_write_unit_max_opt,
         "maximum optimized size for direct I/O with torn-write protection"),
 #endif
index 28005cd1924be7a9278e1ff202bc96dbb4e24ef6..267981250cd7e2833de65c94ce55b0108c206592 100755 (executable)
--- a/configure
+++ b/configure
@@ -25133,6 +25133,21 @@ printf "%s\n" "#define HAVE_SIGINFO_T_SI_BAND 1" >>confdefs.h
 fi
 
 
+if test "$ac_cv_func_statx" = yes; then
+  # stx_atomic_write_unit_max_opt was added in Linux 6.16, but is controlled by
+  # the STATX_WRITE_ATOMIC mask bit added in Linux 6.11, so having the mask bit
+  # doesn't imply having the member.
+  ac_fn_c_check_member "$LINENO" "struct statx" "stx_atomic_write_unit_max_opt" "ac_cv_member_struct_statx_stx_atomic_write_unit_max_opt" "$ac_includes_default"
+if test "x$ac_cv_member_struct_statx_stx_atomic_write_unit_max_opt" = xyes
+then :
+
+printf "%s\n" "#define HAVE_STRUCT_STATX_STX_ATOMIC_WRITE_UNIT_MAX_OPT 1" >>confdefs.h
+
+
+fi
+
+fi
+
 { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for time.h that defines altzone" >&5
 printf %s "checking for time.h that defines altzone... " >&6; }
 if test ${ac_cv_header_time_altzone+y}
index d20f6f8c40abeb51150c8a05a6a759a992f7c940..382591952ef68fe357cde24bbe429f2ddad8fe1f 100644 (file)
@@ -5819,6 +5819,13 @@ AC_CHECK_MEMBERS([struct passwd.pw_gecos, struct passwd.pw_passwd], [], [], [[
 # Issue #21085: In Cygwin, siginfo_t does not have si_band field.
 AC_CHECK_MEMBERS([siginfo_t.si_band], [], [], [[@%:@include <signal.h>]])
 
+if test "$ac_cv_func_statx" = yes; then
+  # stx_atomic_write_unit_max_opt was added in Linux 6.16, but is controlled by
+  # the STATX_WRITE_ATOMIC mask bit added in Linux 6.11, so having the mask bit
+  # doesn't imply having the member.
+  AC_CHECK_MEMBERS([struct statx.stx_atomic_write_unit_max_opt])
+fi
+
 AC_CACHE_CHECK([for time.h that defines altzone], [ac_cv_header_time_altzone], [
   AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[@%:@include <time.h>]], [[return altzone;]])],
     [ac_cv_header_time_altzone=yes],
index 611408d88f05b5d9ed8d875211d5aa9e6fc7f2c5..092f96e7152e117e8302b8a11f4d51b8d97cb7d4 100644 (file)
 /* Define to 1 if 'pw_passwd' is a member of 'struct passwd'. */
 #undef HAVE_STRUCT_PASSWD_PW_PASSWD
 
+/* Define to 1 if 'stx_atomic_write_unit_max_opt' is a member of 'struct
+   statx'. */
+#undef HAVE_STRUCT_STATX_STX_ATOMIC_WRITE_UNIT_MAX_OPT
+
 /* Define to 1 if 'st_birthtime' is a member of 'struct stat'. */
 #undef HAVE_STRUCT_STAT_ST_BIRTHTIME