Skip to content

Commit 550ad86

Browse files
committed
gh-157695: Rename HAVE_GETDENTS64 to _Py_HAVE_GETDENTS64
In configure script, use PY_CHECK_FUNC_PRIVATE() to detect functions: * getdents64() of <dirent.h>: _Py_HAVE_GETDENTS64 * gettid() of <unistd.h>: _Py_HAVE_GETTID * if_indextoname() of <net/if.h>: _Py_HAVE_IF_INDEXTONAME * if_nametoindex() of <net/if.h>: _Py_HAVE_IF_NAMETOINDEX * pidfd_getfd() of <sys/pidfd.h>: _Py_HAVE_PIDFD_GETFD * pidfd_open() of <sys/pidfd.h>: _Py_HAVE_PIDFD_OPEN * pidfd_send_signal() of <sys/pidfd.h>: _Py_HAVE_PIDFD_SEND_SIGNAL Add shebang to Tools/build/check_capi_macros.py and make the script executable.
1 parent 3ad9316 commit 550ad86

14 files changed

Lines changed: 358 additions & 107 deletions

‎Modules/_posixsubprocess.c‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -373,10 +373,10 @@ _close_range_except(int start_fd,
373373
return 0;
374374
}
375375

376-
#if defined(HAVE_GETDENTS64) \
376+
#if defined(_Py_HAVE_GETDENTS64) \
377377
|| (defined(__linux__) && defined(HAVE_SYS_SYSCALL_H))
378378

379-
#ifdef HAVE_GETDENTS64
379+
#ifdef _Py_HAVE_GETDENTS64
380380
# define py_dirent64 dirent64
381381
#else
382382
/* It doesn't matter if d_name has room for NAME_MAX chars; we're using this
@@ -392,7 +392,7 @@ struct py_dirent64 {
392392
unsigned char d_type;
393393
char d_name[256]; /* Filename (null-terminated) */
394394
};
395-
#endif // !HAVE_GETDENTS64
395+
#endif // !_Py_HAVE_GETDENTS64
396396

397397
static int
398398
_brute_force_closer(int first, int last)
@@ -435,7 +435,7 @@ _close_open_fds_safe(int start_fd, int *fds_to_keep, Py_ssize_t fds_to_keep_len)
435435
char buffer[sizeof(struct py_dirent64)];
436436
Py_ssize_t bytes;
437437
while (1) {
438-
#ifdef HAVE_GETDENTS64
438+
#ifdef _Py_HAVE_GETDENTS64
439439
/* musl <1.2.4 headers expose `getdents64` as an alias for `getdents`, whose buffer parameter
440440
* is `struct dirent *`. We use `void *` to support both that interface and the glibc declaration
441441
* without an incompatible-pointer diagnostic.

‎Modules/clinic/posixmodule.c.h‎

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

‎Modules/clinic/signalmodule.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/clinic/socketmodule.c.h‎

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

‎Modules/posixmodule.c‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10870,7 +10870,7 @@ os_wait_impl(PyObject *module)
1087010870

1087110871

1087210872
// This system call always crashes on older Android versions.
10873-
#if defined(HAVE_PIDFD_OPEN) \
10873+
#if defined(_Py_HAVE_PIDFD_OPEN) \
1087410874
|| (defined(__linux__) && defined(__NR_pidfd_open) \
1087510875
&& !(defined(__ANDROID__) && __ANDROID_API__ < 31))
1087610876
/*[clinic input]
@@ -10888,7 +10888,7 @@ static PyObject *
1088810888
os_pidfd_open_impl(PyObject *module, pid_t pid, unsigned int flags)
1088910889
/*[clinic end generated code: output=5c7252698947dc41 input=03058b32c389f874]*/
1089010890
{
10891-
#ifdef HAVE_PIDFD_OPEN
10891+
#ifdef _Py_HAVE_PIDFD_OPEN
1089210892
int fd = pidfd_open(pid, flags);
1089310893
#else
1089410894
int fd = syscall(__NR_pidfd_open, pid, flags);
@@ -10901,7 +10901,7 @@ os_pidfd_open_impl(PyObject *module, pid_t pid, unsigned int flags)
1090110901
#endif
1090210902

1090310903

10904-
#if defined(HAVE_PIDFD_GETFD) \
10904+
#if defined(_Py_HAVE_PIDFD_GETFD) \
1090510905
|| (defined(__linux__) && defined(__NR_pidfd_getfd) \
1090610906
&& !(defined(__ANDROID__) && __ANDROID_API__ < 31))
1090710907
/*[clinic input]
@@ -10922,7 +10922,7 @@ os_pidfd_getfd_impl(PyObject *module, int pidfd, int targetfd,
1092210922
unsigned int flags)
1092310923
/*[clinic end generated code: output=e1a1415a13c7137f input=ef6417fb10deb1cc]*/
1092410924
{
10925-
#ifdef HAVE_PIDFD_GETFD
10925+
#ifdef _Py_HAVE_PIDFD_GETFD
1092610926
int fd = pidfd_getfd(pidfd, targetfd, flags);
1092710927
#else
1092810928
int fd = syscall(__NR_pidfd_getfd, pidfd, targetfd, flags);

‎Modules/signalmodule.c‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1304,7 +1304,7 @@ signal_pthread_kill_impl(PyObject *module, unsigned long thread_id,
13041304

13051305

13061306
// This system call always crashes on older Android versions.
1307-
#if defined(HAVE_PIDFD_SEND_SIGNAL) \
1307+
#if defined(_Py_HAVE_PIDFD_SEND_SIGNAL) \
13081308
|| (defined(__linux__) && defined(__NR_pidfd_send_signal) \
13091309
&& !(defined(__ANDROID__) && __ANDROID_API__ < 31))
13101310
/*[clinic input]
@@ -1329,7 +1329,7 @@ signal_pidfd_send_signal_impl(PyObject *module, int pidfd, int signalnum,
13291329
PyErr_SetString(PyExc_TypeError, "siginfo must be None");
13301330
return NULL;
13311331
}
1332-
#ifdef HAVE_PIDFD_SEND_SIGNAL
1332+
#ifdef _Py_HAVE_PIDFD_SEND_SIGNAL
13331333
int res = pidfd_send_signal(pidfd, signalnum, NULL, flags);
13341334
#else
13351335
int res = syscall(__NR_pidfd_send_signal, pidfd, signalnum, NULL, flags);

‎Modules/socketmodule.c‎

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -606,14 +606,14 @@ _PyLong_##NAME##_Converter(PyObject *obj, void *ptr) \
606606
return 1; \
607607
}
608608

609-
#if defined(HAVE_IF_INDEXTONAME) || defined(MS_WINDOWS_DESKTOP)
609+
#if defined(_Py_HAVE_IF_INDEXTONAME) || defined(MS_WINDOWS_DESKTOP)
610610
# ifdef MS_WINDOWS
611611
UNSIGNED_INT_CONVERTER(NetIfindex, NET_IFINDEX)
612612
# else
613613
# define _PyLong_NetIfindex_Converter _PyLong_UnsignedInt_Converter
614614
# define NET_IFINDEX unsigned int
615615
# endif
616-
#endif // defined(HAVE_IF_INDEXTONAME) || defined(MS_WINDOWS_DESKTOP)
616+
#endif // defined(_Py_HAVE_IF_INDEXTONAME) || defined(MS_WINDOWS_DESKTOP)
617617

618618
/*[python input]
619619
class NET_IFINDEX_converter(CConverter):
@@ -7403,7 +7403,7 @@ _socket_if_nameindex_impl(PyObject *module)
74037403

74047404
#endif // defined(HAVE_IF_NAMEINDEX) || defined(MS_WINDOWS_DESKTOP)
74057405

7406-
#if defined(HAVE_IF_NAMETOINDEX) || defined(MS_WINDOWS_DESKTOP)
7406+
#if defined(_Py_HAVE_IF_NAMETOINDEX) || defined(MS_WINDOWS_DESKTOP)
74077407

74087408
/*[clinic input]
74097409
_socket.if_nametoindex
@@ -7433,9 +7433,9 @@ _socket_if_nametoindex_impl(PyObject *module, PyObject *oname)
74337433
return PyLong_FromUnsignedLong(index);
74347434
}
74357435

7436-
#endif // defined(HAVE_IF_NAMETOINDEX) || defined(MS_WINDOWS_DESKTOP)
7436+
#endif // defined(_Py_HAVE_IF_NAMETOINDEX) || defined(MS_WINDOWS_DESKTOP)
74377437

7438-
#if defined(HAVE_IF_INDEXTONAME) || defined(MS_WINDOWS_DESKTOP)
7438+
#if defined(_Py_HAVE_IF_INDEXTONAME) || defined(MS_WINDOWS_DESKTOP)
74397439

74407440
/*[clinic input]
74417441
@permit_long_summary
@@ -7460,7 +7460,7 @@ _socket_if_indextoname_impl(PyObject *module, NET_IFINDEX index)
74607460
return PyUnicode_DecodeFSDefault(name);
74617461
}
74627462

7463-
#endif // defined(HAVE_IF_INDEXTONAME) || defined(MS_WINDOWS_DESKTOP)
7463+
#endif // defined(_Py_HAVE_IF_INDEXTONAME) || defined(MS_WINDOWS_DESKTOP)
74647464

74657465

74667466
#ifdef CMSG_LEN

‎Python/perf_jit_trampoline.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -672,7 +672,7 @@ static void perf_map_jit_write_entry_with_name(
672672
uint64_t thread_id = 0;
673673
pthread_threadid_np(NULL, &thread_id);
674674
ev.thread_id = (uint32_t)thread_id;
675-
#elif defined(HAVE_GETTID)
675+
#elif defined(_Py_HAVE_GETTID)
676676
ev.thread_id = gettid();
677677
#else
678678
ev.thread_id = syscall(SYS_gettid); // Get thread ID via system call

‎Python/thread_pthread.h‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
#include <signal.h>
1919
#include <unistd.h> /* pause(), also getthrid() on OpenBSD */
2020

21-
#ifdef HAVE_GETTID
21+
#ifdef _Py_HAVE_GETTID
2222
# include <unistd.h> // gettid()
2323
#elif defined(__linux__)
2424
# include <sys/syscall.h> /* syscall(SYS_gettid) */
@@ -384,7 +384,7 @@ PyThread_get_thread_native_id(void)
384384
#ifdef __APPLE__
385385
uint64_t native_id;
386386
(void) pthread_threadid_np(NULL, &native_id);
387-
#elif defined(HAVE_GETTID)
387+
#elif defined(_Py_HAVE_GETTID)
388388
pid_t native_id;
389389
native_id = gettid();
390390
#elif defined(__linux__)

‎Tools/build/check_capi_macros.py‎

100644100755
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
#! /usr/bin/env python3
12
"""
23
Check that all macros defined by the Python C API have a name starting with
34
"Py". Ignore names listed by check_capi_macros_ignored.txt: macros with an

0 commit comments

Comments
 (0)