From 36050eee10fb34c03bf100dc337a551b859a3bb6 Mon Sep 17 00:00:00 2001 From: Kumar Aditya <59607654+kumaraditya303@users.noreply.github.com> Date: Sat, 23 Jul 2022 10:46:00 +0000 Subject: [PATCH 1/7] fix checks for eventfd --- Modules/posixmodule.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/Modules/posixmodule.c b/Modules/posixmodule.c index 40229bce0f4033..6a05b9f1665c7e 100644 --- a/Modules/posixmodule.c +++ b/Modules/posixmodule.c @@ -15463,10 +15463,16 @@ all_ins(PyObject *m) #endif /* HAVE_MEMFD_CREATE */ #ifdef HAVE_EVENTFD +#ifdef EFD_CLOEXEC if (PyModule_AddIntMacro(m, EFD_CLOEXEC)) return -1; +#endif +#ifdef EFD_NONBLOCK if (PyModule_AddIntMacro(m, EFD_NONBLOCK)) return -1; +#endif +#ifdef EFD_SEMAPHORE if (PyModule_AddIntMacro(m, EFD_SEMAPHORE)) return -1; #endif +#endif #if defined(__APPLE__) if (PyModule_AddIntConstant(m, "_COPYFILE_DATA", COPYFILE_DATA)) return -1; From 9d2c9725198b4ceadb81c31abfc5af85e332f3ae Mon Sep 17 00:00:00 2001 From: "blurb-it[bot]" <43283697+blurb-it[bot]@users.noreply.github.com> Date: Sat, 23 Jul 2022 10:50:06 +0000 Subject: [PATCH 2/7] =?UTF-8?q?=F0=9F=93=9C=F0=9F=A4=96=20Added=20by=20blu?= =?UTF-8?q?rb=5Fit.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../next/Library/2022-07-23-10-50-05.gh-issue-93899.VT34A5.rst | 1 + 1 file changed, 1 insertion(+) create mode 100644 Misc/NEWS.d/next/Library/2022-07-23-10-50-05.gh-issue-93899.VT34A5.rst diff --git a/Misc/NEWS.d/next/Library/2022-07-23-10-50-05.gh-issue-93899.VT34A5.rst b/Misc/NEWS.d/next/Library/2022-07-23-10-50-05.gh-issue-93899.VT34A5.rst new file mode 100644 index 00000000000000..43683c285b9d3a --- /dev/null +++ b/Misc/NEWS.d/next/Library/2022-07-23-10-50-05.gh-issue-93899.VT34A5.rst @@ -0,0 +1 @@ +Fix check for existence of :data:`os.EFD_CLOEXEC`, :data:`os.EFD_NONBLOCK` and :data:`os.EFD_SEMAPHORE` flags on older kernel versions. Patch by Kumar Aditya. From 45a587daf48a3580c92de52075b30c6259541254 Mon Sep 17 00:00:00 2001 From: Kumar Aditya <59607654+kumaraditya303@users.noreply.github.com> Date: Sun, 24 Jul 2022 13:52:32 +0000 Subject: [PATCH 3/7] guard os.eventfd --- Modules/posixmodule.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Modules/posixmodule.c b/Modules/posixmodule.c index 6a05b9f1665c7e..6e358c3ba594e0 100644 --- a/Modules/posixmodule.c +++ b/Modules/posixmodule.c @@ -13104,7 +13104,7 @@ os_memfd_create_impl(PyObject *module, PyObject *name, unsigned int flags) } #endif -#ifdef HAVE_EVENTFD +#if defined(HAVE_EVENTFD) && defined(EFD_CLOEXEC) /*[clinic input] os.eventfd @@ -13175,7 +13175,7 @@ os_eventfd_write_impl(PyObject *module, int fd, unsigned long long value) } Py_RETURN_NONE; } -#endif /* HAVE_EVENTFD */ +#endif /* HAVE_EVENTFD && EFD_CLOEXEC*/ /* Terminal size querying */ From f35c3b846e832d28f01864f2123c3bd20166f2df Mon Sep 17 00:00:00 2001 From: Kumar Aditya <59607654+kumaraditya303@users.noreply.github.com> Date: Sun, 24 Jul 2022 13:53:57 +0000 Subject: [PATCH 4/7] whitespace --- Modules/posixmodule.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Modules/posixmodule.c b/Modules/posixmodule.c index 6e358c3ba594e0..d67b004a5b3599 100644 --- a/Modules/posixmodule.c +++ b/Modules/posixmodule.c @@ -13175,7 +13175,7 @@ os_eventfd_write_impl(PyObject *module, int fd, unsigned long long value) } Py_RETURN_NONE; } -#endif /* HAVE_EVENTFD && EFD_CLOEXEC*/ +#endif /* HAVE_EVENTFD && EFD_CLOEXEC */ /* Terminal size querying */ From 049c1cd33ec65572df7d31251f567a863fc5408d Mon Sep 17 00:00:00 2001 From: Kumar Aditya <59607654+kumaraditya303@users.noreply.github.com> Date: Sun, 24 Jul 2022 13:57:42 +0000 Subject: [PATCH 5/7] clinic regen --- Modules/clinic/posixmodule.c.h | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/Modules/clinic/posixmodule.c.h b/Modules/clinic/posixmodule.c.h index 1ce7d86204e6f3..174de9904984bf 100644 --- a/Modules/clinic/posixmodule.c.h +++ b/Modules/clinic/posixmodule.c.h @@ -7869,7 +7869,7 @@ os_memfd_create(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObj #endif /* defined(HAVE_MEMFD_CREATE) */ -#if defined(HAVE_EVENTFD) +#if (defined(HAVE_EVENTFD) && defined(EFD_CLOEXEC)) PyDoc_STRVAR(os_eventfd__doc__, "eventfd($module, /, initval, flags=EFD_CLOEXEC)\n" @@ -7915,9 +7915,9 @@ os_eventfd(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject * return return_value; } -#endif /* defined(HAVE_EVENTFD) */ +#endif /* (defined(HAVE_EVENTFD) && defined(EFD_CLOEXEC)) */ -#if defined(HAVE_EVENTFD) +#if (defined(HAVE_EVENTFD) && defined(EFD_CLOEXEC)) PyDoc_STRVAR(os_eventfd_read__doc__, "eventfd_read($module, /, fd)\n" @@ -7953,9 +7953,9 @@ os_eventfd_read(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObj return return_value; } -#endif /* defined(HAVE_EVENTFD) */ +#endif /* (defined(HAVE_EVENTFD) && defined(EFD_CLOEXEC)) */ -#if defined(HAVE_EVENTFD) +#if (defined(HAVE_EVENTFD) && defined(EFD_CLOEXEC)) PyDoc_STRVAR(os_eventfd_write__doc__, "eventfd_write($module, /, fd, value)\n" @@ -7995,7 +7995,7 @@ os_eventfd_write(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyOb return return_value; } -#endif /* defined(HAVE_EVENTFD) */ +#endif /* (defined(HAVE_EVENTFD) && defined(EFD_CLOEXEC)) */ #if (defined(TERMSIZE_USE_CONIO) || defined(TERMSIZE_USE_IOCTL)) @@ -9352,4 +9352,4 @@ os_waitstatus_to_exitcode(PyObject *module, PyObject *const *args, Py_ssize_t na #ifndef OS_WAITSTATUS_TO_EXITCODE_METHODDEF #define OS_WAITSTATUS_TO_EXITCODE_METHODDEF #endif /* !defined(OS_WAITSTATUS_TO_EXITCODE_METHODDEF) */ -/*[clinic end generated code: output=bae15f09a1b3d2e7 input=a9049054013a1b77]*/ +/*[clinic end generated code: output=b809926851691dbd input=a9049054013a1b77]*/ From 47a4d40f67515af4b90347b0227b9c77151c0829 Mon Sep 17 00:00:00 2001 From: Kumar Aditya <59607654+kumaraditya303@users.noreply.github.com> Date: Mon, 25 Jul 2022 06:57:11 +0000 Subject: [PATCH 6/7] style --- Modules/posixmodule.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/Modules/posixmodule.c b/Modules/posixmodule.c index d67b004a5b3599..1947564a655d3f 100644 --- a/Modules/posixmodule.c +++ b/Modules/posixmodule.c @@ -15462,17 +15462,15 @@ all_ins(PyObject *m) #endif #endif /* HAVE_MEMFD_CREATE */ -#ifdef HAVE_EVENTFD -#ifdef EFD_CLOEXEC +#if defined(HAVE_EVENTFD) && defined(EFD_CLOEXEC) if (PyModule_AddIntMacro(m, EFD_CLOEXEC)) return -1; -#endif #ifdef EFD_NONBLOCK if (PyModule_AddIntMacro(m, EFD_NONBLOCK)) return -1; #endif #ifdef EFD_SEMAPHORE if (PyModule_AddIntMacro(m, EFD_SEMAPHORE)) return -1; #endif -#endif +#endif /* HAVE_EVENTFD && EFD_CLOEXEC */ #if defined(__APPLE__) if (PyModule_AddIntConstant(m, "_COPYFILE_DATA", COPYFILE_DATA)) return -1; From 06dfe3f279249e2c319c92cd316e104318d23ba4 Mon Sep 17 00:00:00 2001 From: Kumar Aditya <59607654+kumaraditya303@users.noreply.github.com> Date: Wed, 27 Jul 2022 12:26:25 +0000 Subject: [PATCH 7/7] reword news --- .../next/Library/2022-07-23-10-50-05.gh-issue-93899.VT34A5.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Misc/NEWS.d/next/Library/2022-07-23-10-50-05.gh-issue-93899.VT34A5.rst b/Misc/NEWS.d/next/Library/2022-07-23-10-50-05.gh-issue-93899.VT34A5.rst index 43683c285b9d3a..e63475f8ba96f6 100644 --- a/Misc/NEWS.d/next/Library/2022-07-23-10-50-05.gh-issue-93899.VT34A5.rst +++ b/Misc/NEWS.d/next/Library/2022-07-23-10-50-05.gh-issue-93899.VT34A5.rst @@ -1 +1 @@ -Fix check for existence of :data:`os.EFD_CLOEXEC`, :data:`os.EFD_NONBLOCK` and :data:`os.EFD_SEMAPHORE` flags on older kernel versions. Patch by Kumar Aditya. +Fix check for existence of :data:`os.EFD_CLOEXEC`, :data:`os.EFD_NONBLOCK` and :data:`os.EFD_SEMAPHORE` flags on older kernel versions where these flags are not present. Patch by Kumar Aditya.