Skip to content

Commit d15d5f0

Browse files
committed
gh-157695: Rename HAVE_GETTID to _Py_HAVE_GETTID
Make Tools/build/check_capi_macros.py executable.
1 parent a321390 commit d15d5f0

14 files changed

Lines changed: 356 additions & 104 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
bytes = getdents64(fd_dir_fd, buffer, sizeof(buffer));
440440
#else
441441
bytes = syscall(SYS_getdents64, fd_dir_fd,

‎Modules/clinic/posixmodule.c.h‎

Lines changed: 4 additions & 4 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: 2 additions & 2 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: 4 additions & 4 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
@@ -10863,7 +10863,7 @@ os_wait_impl(PyObject *module)
1086310863

1086410864

1086510865
// This system call always crashes on older Android versions.
10866-
#if defined(HAVE_PIDFD_OPEN) \
10866+
#if defined(_Py_HAVE_PIDFD_OPEN) \
1086710867
|| (defined(__linux__) && defined(__NR_pidfd_open) \
1086810868
&& !(defined(__ANDROID__) && __ANDROID_API__ < 31))
1086910869
/*[clinic input]
@@ -10881,7 +10881,7 @@ static PyObject *
1088110881
os_pidfd_open_impl(PyObject *module, pid_t pid, unsigned int flags)
1088210882
/*[clinic end generated code: output=5c7252698947dc41 input=03058b32c389f874]*/
1088310883
{
10884-
#ifdef HAVE_PIDFD_OPEN
10884+
#ifdef _Py_HAVE_PIDFD_OPEN
1088510885
int fd = pidfd_open(pid, flags);
1088610886
#else
1088710887
int fd = syscall(__NR_pidfd_open, pid, flags);
@@ -10894,7 +10894,7 @@ os_pidfd_open_impl(PyObject *module, pid_t pid, unsigned int flags)
1089410894
#endif
1089510895

1089610896

10897-
#if defined(HAVE_PIDFD_GETFD) \
10897+
#if defined(_Py_HAVE_PIDFD_GETFD) \
1089810898
|| (defined(__linux__) && defined(__NR_pidfd_getfd) \
1089910899
&& !(defined(__ANDROID__) && __ANDROID_API__ < 31))
1090010900
/*[clinic input]
@@ -10915,7 +10915,7 @@ os_pidfd_getfd_impl(PyObject *module, int pidfd, int targetfd,
1091510915
unsigned int flags)
1091610916
/*[clinic end generated code: output=e1a1415a13c7137f input=ef6417fb10deb1cc]*/
1091710917
{
10918-
#ifdef HAVE_PIDFD_GETFD
10918+
#ifdef _Py_HAVE_PIDFD_GETFD
1091910919
int fd = pidfd_getfd(pidfd, targetfd, flags);
1092010920
#else
1092110921
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
@@ -635,14 +635,14 @@ _PyLong_##NAME##_Converter(PyObject *obj, void *ptr) \
635635
return 1; \
636636
}
637637

638-
#if defined(HAVE_IF_INDEXTONAME) || defined(MS_WINDOWS_DESKTOP)
638+
#if defined(_Py_HAVE_IF_INDEXTONAME) || defined(MS_WINDOWS_DESKTOP)
639639
# ifdef MS_WINDOWS
640640
UNSIGNED_INT_CONVERTER(NetIfindex, NET_IFINDEX)
641641
# else
642642
# define _PyLong_NetIfindex_Converter _PyLong_UnsignedInt_Converter
643643
# define NET_IFINDEX unsigned int
644644
# endif
645-
#endif // defined(HAVE_IF_INDEXTONAME) || defined(MS_WINDOWS_DESKTOP)
645+
#endif // defined(_Py_HAVE_IF_INDEXTONAME) || defined(MS_WINDOWS_DESKTOP)
646646

647647
/*[python input]
648648
class NET_IFINDEX_converter(CConverter):
@@ -7424,7 +7424,7 @@ _socket_if_nameindex_impl(PyObject *module)
74247424

74257425
#endif // defined(HAVE_IF_NAMEINDEX) || defined(MS_WINDOWS_DESKTOP)
74267426

7427-
#if defined(HAVE_IF_NAMETOINDEX) || defined(MS_WINDOWS_DESKTOP)
7427+
#if defined(_Py_HAVE_IF_NAMETOINDEX) || defined(MS_WINDOWS_DESKTOP)
74287428

74297429
/*[clinic input]
74307430
_socket.if_nametoindex
@@ -7454,9 +7454,9 @@ _socket_if_nametoindex_impl(PyObject *module, PyObject *oname)
74547454
return PyLong_FromUnsignedLong(index);
74557455
}
74567456

7457-
#endif // defined(HAVE_IF_NAMETOINDEX) || defined(MS_WINDOWS_DESKTOP)
7457+
#endif // defined(_Py_HAVE_IF_NAMETOINDEX) || defined(MS_WINDOWS_DESKTOP)
74587458

7459-
#if defined(HAVE_IF_INDEXTONAME) || defined(MS_WINDOWS_DESKTOP)
7459+
#if defined(_Py_HAVE_IF_INDEXTONAME) || defined(MS_WINDOWS_DESKTOP)
74607460

74617461
/*[clinic input]
74627462
@permit_long_summary
@@ -7481,7 +7481,7 @@ _socket_if_indextoname_impl(PyObject *module, NET_IFINDEX index)
74817481
return PyUnicode_DecodeFSDefault(name);
74827482
}
74837483

7484-
#endif // defined(HAVE_IF_INDEXTONAME) || defined(MS_WINDOWS_DESKTOP)
7484+
#endif // defined(_Py_HAVE_IF_INDEXTONAME) || defined(MS_WINDOWS_DESKTOP)
74857485

74867486

74877487
#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)