closes bpo-35025: Properly guard the `CLOCK_GETTIME` et al macros in timemodule.c. (GH-9961)
Guard the `CLOCK_GETTIME` et al macros in `timemodule` based on the availability of the parent functions
(cherry picked from commit 94451182ccd6729c11338926d8a3d11645e86626)
Co-authored-by: Max Bélanger <aeromax@gmail.com>
diff --git a/Modules/timemodule.c b/Modules/timemodule.c
index 7264ad6..cd287f5 100644
--- a/Modules/timemodule.c
+++ b/Modules/timemodule.c
@@ -1700,6 +1700,8 @@
/* Set, or reset, module variables like time.timezone */
PyInit_timezone(m);
+#if defined(HAVE_CLOCK_GETTIME) || defined(HAVE_CLOCK_SETTIME) || defined(HAVE_CLOCK_GETRES)
+
#ifdef CLOCK_REALTIME
PyModule_AddIntMacro(m, CLOCK_REALTIME);
#endif
@@ -1728,6 +1730,8 @@
PyModule_AddIntMacro(m, CLOCK_UPTIME);
#endif
+#endif /* defined(HAVE_CLOCK_GETTIME) || defined(HAVE_CLOCK_SETTIME) || defined(HAVE_CLOCK_GETRES) */
+
if (!initialized) {
if (PyStructSequence_InitType2(&StructTimeType,
&struct_time_type_desc) < 0)