summaryrefslogtreecommitdiffstats
path: root/Modules/posixmodule.c
diff options
context:
space:
mode:
authorEric Snow <ericsnowcurrently@gmail.com>2022-12-08 23:46:09 (GMT)
committerGitHub <noreply@github.com>2022-12-08 23:46:09 (GMT)
commit8a3f06c54b52e5e7490a131b261384baac9d6090 (patch)
treeffbb65d3491ecb020e72a84e4bcf35008a602ffa /Modules/posixmodule.c
parentcda9f0236fd7800c6db5eec207668c4bfec4a45d (diff)
downloadcpython-8a3f06c54b52e5e7490a131b261384baac9d6090.zip
cpython-8a3f06c54b52e5e7490a131b261384baac9d6090.tar.gz
cpython-8a3f06c54b52e5e7490a131b261384baac9d6090.tar.bz2
gh-81057: Move time Globals to _PyRuntimeState (gh-100122)
https://github.com/python/cpython/issues/81057
Diffstat (limited to 'Modules/posixmodule.c')
-rw-r--r--Modules/posixmodule.c30
1 files changed, 5 insertions, 25 deletions
diff --git a/Modules/posixmodule.c b/Modules/posixmodule.c
index cbf4d5b..f517535 100644
--- a/Modules/posixmodule.c
+++ b/Modules/posixmodule.c
@@ -9065,24 +9065,6 @@ build_times_result(PyObject *module, double user, double system,
}
-#ifdef _OS_NEED_TICKS_PER_SECOND
-#define ticks_per_second _PyRuntime.os.ticks_per_second
-static void
-ticks_per_second_init(void)
-{
- if (ticks_per_second != -1) {
- return;
- }
-# if defined(HAVE_SYSCONF) && defined(_SC_CLK_TCK)
- ticks_per_second = sysconf(_SC_CLK_TCK);
-# elif defined(HZ)
- ticks_per_second = HZ;
-# else
- ticks_per_second = 60; /* magic fallback value; may be bogus */
-# endif
-}
-#endif
-
/*[clinic input]
os.times
@@ -9116,22 +9098,24 @@ os_times_impl(PyObject *module)
(double)0,
(double)0);
}
-#elif !defined(_OS_NEED_TICKS_PER_SECOND)
-# error "missing ticks_per_second"
#else /* MS_WINDOWS */
{
struct tms t;
clock_t c;
errno = 0;
c = times(&t);
- if (c == (clock_t) -1)
+ if (c == (clock_t) -1) {
return posix_error();
+ }
+ assert(_PyRuntime.time.ticks_per_second_initialized);
+#define ticks_per_second _PyRuntime.time.ticks_per_second
return build_times_result(module,
(double)t.tms_utime / ticks_per_second,
(double)t.tms_stime / ticks_per_second,
(double)t.tms_cutime / ticks_per_second,
(double)t.tms_cstime / ticks_per_second,
(double)c / ticks_per_second);
+#undef ticks_per_second
}
#endif /* MS_WINDOWS */
#endif /* HAVE_TIMES */
@@ -15950,10 +15934,6 @@ posixmodule_exec(PyObject *m)
PyModule_AddObject(m, "statvfs_result", Py_NewRef(StatVFSResultType));
state->StatVFSResultType = StatVFSResultType;
-#ifdef _OS_NEED_TICKS_PER_SECOND
- ticks_per_second_init();
-#endif
-
#if defined(HAVE_SCHED_SETPARAM) || defined(HAVE_SCHED_SETSCHEDULER) || defined(POSIX_SPAWN_SETSCHEDULER) || defined(POSIX_SPAWN_SETSCHEDPARAM)
sched_param_desc.name = MODNAME ".sched_param";
PyObject *SchedParamType = (PyObject *)PyStructSequence_NewType(&sched_param_desc);