Skip to content

Commit 7dc75d0

Browse files
committed
Simplify statx configure check
1 parent 534e33f commit 7dc75d0

File tree

5 files changed

+31
-96
lines changed

5 files changed

+31
-96
lines changed

Modules/clinic/posixmodule.c.h

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Modules/posixmodule.c

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -409,7 +409,7 @@ extern char *ctermid_r(char *);
409409
# define STRUCT_STAT struct stat
410410
#endif
411411

412-
#ifdef HAVE_LINUX_STATX
412+
#ifdef HAVE_STATX
413413
# pragma weak statx
414414
/* provide constants introduced later than statx itself */
415415
# ifndef STATX_MNT_ID
@@ -431,7 +431,7 @@ extern char *ctermid_r(char *);
431431
# define STATX_DIO_READ_ALIGN 0x00020000U
432432
# endif
433433
# define _Py_STATX_KNOWN (STATX_BASIC_STATS | STATX_BTIME | STATX_MNT_ID | STATX_DIOALIGN | STATX_MNT_ID_UNIQUE | STATX_SUBVOL | STATX_WRITE_ATOMIC | STATX_DIO_READ_ALIGN)
434-
#endif /* HAVE_LINUX_STATX */
434+
#endif /* HAVE_STATX */
435435

436436

437437
#if !defined(EX_OK) && defined(EXIT_SUCCESS)
@@ -1184,7 +1184,7 @@ typedef struct {
11841184
#endif
11851185
newfunc statresult_new_orig;
11861186
PyObject *StatResultType;
1187-
#ifdef HAVE_LINUX_STATX
1187+
#ifdef HAVE_STATX
11881188
PyObject *StatxResultType;
11891189
#endif
11901190
PyObject *StatVFSResultType;
@@ -2381,10 +2381,10 @@ static PyStructSequence_Field stat_result_fields[] = {
23812381
#ifdef HAVE_STRUCT_STAT_ST_GEN
23822382
{"st_gen", "generation number"},
23832383
#endif
2384-
#if defined(HAVE_STRUCT_STAT_ST_BIRTHTIME) || defined(HAVE_LINUX_STATX) || defined(MS_WINDOWS)
2384+
#if defined(HAVE_STRUCT_STAT_ST_BIRTHTIME) || defined(HAVE_STATX) || defined(MS_WINDOWS)
23852385
{"st_birthtime", "time of creation"},
23862386
#endif
2387-
#if defined(HAVE_LINUX_STATX) || defined(MS_WINDOWS)
2387+
#if defined(HAVE_STATX) || defined(MS_WINDOWS)
23882388
{"st_birthtime_ns", "time of creation in nanoseconds"},
23892389
#endif
23902390
#ifdef HAVE_STRUCT_STAT_ST_FILE_ATTRIBUTES
@@ -2429,13 +2429,13 @@ static PyStructSequence_Field stat_result_fields[] = {
24292429
#define ST_GEN_IDX ST_FLAGS_IDX
24302430
#endif
24312431

2432-
#if defined(HAVE_STRUCT_STAT_ST_BIRTHTIME) || defined(HAVE_LINUX_STATX) || defined(MS_WINDOWS)
2432+
#if defined(HAVE_STRUCT_STAT_ST_BIRTHTIME) || defined(HAVE_STATX) || defined(MS_WINDOWS)
24332433
#define ST_BIRTHTIME_IDX (ST_GEN_IDX+1)
24342434
#else
24352435
#define ST_BIRTHTIME_IDX ST_GEN_IDX
24362436
#endif
24372437

2438-
#if defined(HAVE_LINUX_STATX) || defined(MS_WINDOWS)
2438+
#if defined(HAVE_STATX) || defined(MS_WINDOWS)
24392439
#define ST_BIRTHTIME_NS_IDX (ST_BIRTHTIME_IDX+1)
24402440
#else
24412441
#define ST_BIRTHTIME_NS_IDX ST_BIRTHTIME_IDX
@@ -2567,7 +2567,7 @@ _posix_clear(PyObject *module)
25672567
Py_CLEAR(state->SchedParamType);
25682568
#endif
25692569
Py_CLEAR(state->StatResultType);
2570-
#ifdef HAVE_LINUX_STATX
2570+
#ifdef HAVE_STATX
25712571
Py_CLEAR(state->StatxResultType);
25722572
#endif
25732573
Py_CLEAR(state->StatVFSResultType);
@@ -2595,7 +2595,7 @@ _posix_traverse(PyObject *module, visitproc visit, void *arg)
25952595
Py_VISIT(state->SchedParamType);
25962596
#endif
25972597
Py_VISIT(state->StatResultType);
2598-
#ifdef HAVE_LINUX_STATX
2598+
#ifdef HAVE_STATX
25992599
Py_VISIT(state->StatxResultType);
26002600
#endif
26012601
Py_VISIT(state->StatVFSResultType);
@@ -2810,7 +2810,7 @@ _pystat_fromstructstat(PyObject *module, STRUCT_STAT *st)
28102810
#endif
28112811
SET_ITEM(ST_BIRTHTIME_IDX, PyFloat_FromDouble(bsec + bnsec * 1e-9));
28122812
}
2813-
#elif defined(HAVE_LINUX_STATX)
2813+
#elif defined(HAVE_STATX)
28142814
/* We were built with statx support, so stat_result.st_birthtime[_ns]
28152815
exists, but we fell back to stat because statx isn't available at
28162816
runtime. User programs assume st_birthtime is not None. */
@@ -2844,7 +2844,7 @@ _pystat_fromstructstat(PyObject *module, STRUCT_STAT *st)
28442844
return NULL;
28452845
}
28462846

2847-
#ifdef HAVE_LINUX_STATX
2847+
#ifdef HAVE_STATX
28482848
static PyObject*
28492849
_pystat_fromstructstatx(PyObject *module, struct statx *st)
28502850
{
@@ -2905,7 +2905,7 @@ _pystat_fromstructstatx(PyObject *module, struct statx *st)
29052905
Py_DECREF(v);
29062906
return NULL;
29072907
}
2908-
#endif /* HAVE_LINUX_STATX */
2908+
#endif /* HAVE_STATX */
29092909
#undef SET_ITEM
29102910

29112911
/* POSIX methods */
@@ -2932,7 +2932,7 @@ posix_do_stat(PyObject *module, const char *function_name, path_t *path,
29322932
fd_and_follow_symlinks_invalid("stat", path->fd, follow_symlinks))
29332933
return NULL;
29342934

2935-
#ifdef HAVE_LINUX_STATX
2935+
#ifdef HAVE_STATX
29362936
struct statx stx = {};
29372937
static int statx_works = -1;
29382938
if (statx != NULL && statx_works != 0) {
@@ -2962,7 +2962,7 @@ posix_do_stat(PyObject *module, const char *function_name, path_t *path,
29622962
return _pystat_fromstructstatx(module, &stx);
29632963
}
29642964
}
2965-
#endif /* HAVE_LINUX_STATX */
2965+
#endif /* HAVE_STATX */
29662966

29672967
Py_BEGIN_ALLOW_THREADS
29682968
if (path->fd != -1)
@@ -3412,7 +3412,7 @@ os_lstat_impl(PyObject *module, path_t *path, int dir_fd)
34123412
}
34133413

34143414

3415-
#ifdef HAVE_LINUX_STATX
3415+
#ifdef HAVE_STATX
34163416
#define STATX_RESULT_CACHE_SLOTS 17
34173417
typedef struct {
34183418
PyObject_HEAD
@@ -18294,7 +18294,7 @@ all_ins(PyObject *m)
1829418294
#endif
1829518295
#endif /* HAVE_EVENTFD && EFD_CLOEXEC */
1829618296

18297-
#ifdef HAVE_LINUX_STATX
18297+
#ifdef HAVE_STATX
1829818298
if (PyModule_AddIntMacro(m, STATX_TYPE)) return -1;
1829918299
if (PyModule_AddIntMacro(m, STATX_MODE)) return -1;
1830018300
if (PyModule_AddIntMacro(m, STATX_NLINK)) return -1;
@@ -18316,7 +18316,7 @@ all_ins(PyObject *m)
1831618316
if (PyModule_AddIntMacro(m, STATX_DIO_READ_ALIGN)) return -1;
1831718317
/* STATX_ALL intentionally omitted because it is deprecated */
1831818318
/* STATX_ATTR_* constants are in the stat module */
18319-
#endif /* HAVE_LINUX_STATX */
18319+
#endif /* HAVE_STATX */
1832018320

1832118321
#if defined(__APPLE__)
1832218322
if (PyModule_AddIntConstant(m, "_COPYFILE_DATA", COPYFILE_DATA)) return -1;
@@ -18589,7 +18589,7 @@ posixmodule_exec(PyObject *m)
1858918589
}
1859018590
#endif
1859118591

18592-
#ifdef HAVE_LINUX_STATX
18592+
#ifdef HAVE_STATX
1859318593
/* We retract os.statx in three cases:
1859418594
- the weakly-linked statx wrapper function is not available (old libc)
1859518595
- the wrapper function fails with EINVAL on sync flags (glibc's

configure

Lines changed: 6 additions & 55 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

configure.ac

Lines changed: 1 addition & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -5252,7 +5252,7 @@ AC_CHECK_FUNCS([ \
52525252
setitimer setlocale setpgid setpgrp setpriority setregid setresgid \
52535253
setresuid setreuid setsid setuid setvbuf shutdown sigaction sigaltstack \
52545254
sigfillset siginterrupt sigpending sigrelse sigtimedwait sigwait \
5255-
sigwaitinfo snprintf splice strftime strlcpy strsignal symlinkat sync \
5255+
sigwaitinfo snprintf splice statx strftime strlcpy strsignal symlinkat sync \
52565256
sysconf tcgetpgrp tcsetpgrp tempnam timegm times tmpfile \
52575257
tmpnam tmpnam_r truncate ttyname_r umask uname unlinkat unlockpt utimensat utimes vfork \
52585258
wait wait3 wait4 waitid waitpid wcscoll wcsftime wcsxfrm wmemcmp writev \
@@ -7595,22 +7595,6 @@ AC_ARG_ENABLE([test-modules],
75957595
AC_MSG_RESULT([$TEST_MODULES])
75967596
AC_SUBST([TEST_MODULES])
75977597

7598-
AC_MSG_CHECKING([for --without-linux-statx])
7599-
AC_ARG_WITH([linux-statx],
7600-
[AS_HELP_STRING([--without-linux-statx], [don't provide os.statx nor os.stat_result.st_birthtime])],
7601-
[], [AS_CASE($ac_sys_system, [Linux*], [with_linux_statx=yes], [with_linux_statx=no])])
7602-
AC_MSG_RESULT([$with_linux_statx])
7603-
AS_IF([test "x$with_linux_statx" != xno],
7604-
[AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
7605-
#include <sys/stat.h>
7606-
]], [[void* p = statx]])],
7607-
[AC_DEFINE(HAVE_LINUX_STATX, 1, Define if you have the 'statx' function.)
7608-
AC_MSG_RESULT(yes)],
7609-
[AC_MSG_RESULT(no)
7610-
AC_MSG_ERROR([statx syscall wrapper function not available; upgrade to
7611-
glibc 2.28 or later or use --without-linux-statx])
7612-
])])
7613-
76147598
# gh-109054: Check if -latomic is needed to get <pyatomic.h> atomic functions.
76157599
# On Linux aarch64, GCC may require programs and libraries to be linked
76167600
# explicitly to libatomic. Call _Py_atomic_or_uint64() which may require

pyconfig.h.in

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -766,9 +766,6 @@
766766
/* Define to 1 if you have the <linux/soundcard.h> header file. */
767767
#undef HAVE_LINUX_SOUNDCARD_H
768768

769-
/* Define if you have the 'statx' function. */
770-
#undef HAVE_LINUX_STATX
771-
772769
/* Define to 1 if you have the <linux/tipc.h> header file. */
773770
#undef HAVE_LINUX_TIPC_H
774771

@@ -1282,6 +1279,9 @@
12821279
/* Define to 1 if you have the 'statvfs' function. */
12831280
#undef HAVE_STATVFS
12841281

1282+
/* Define to 1 if you have the 'statx' function. */
1283+
#undef HAVE_STATX
1284+
12851285
/* Define if you have struct stat.st_mtim.tv_nsec */
12861286
#undef HAVE_STAT_TV_NSEC
12871287

0 commit comments

Comments
 (0)