aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/Python/fileutils.c
diff options
context:
space:
mode:
Diffstat (limited to 'Python/fileutils.c')
-rw-r--r--Python/fileutils.c24
1 files changed, 24 insertions, 0 deletions
diff --git a/Python/fileutils.c b/Python/fileutils.c
index 649b188b516..9d12bc89c95 100644
--- a/Python/fileutils.c
+++ b/Python/fileutils.c
@@ -2943,3 +2943,27 @@ _Py_closerange(int first, int last)
#endif /* USE_FDWALK */
_Py_END_SUPPRESS_IPH
}
+
+
+#ifndef MS_WINDOWS
+// Ticks per second used by clock() and times() functions.
+// See os.times() and time.process_time() implementations.
+int
+_Py_GetTicksPerSecond(long *ticks_per_second)
+{
+#if defined(HAVE_SYSCONF) && defined(_SC_CLK_TCK)
+ long value = sysconf(_SC_CLK_TCK);
+ if (value < 1) {
+ return -1;
+ }
+ *ticks_per_second = value;
+#elif defined(HZ)
+ assert(HZ >= 1);
+ *ticks_per_second = HZ;
+#else
+ // Magic fallback value; may be bogus
+ *ticks_per_second = 60;
+#endif
+ return 0;
+}
+#endif