summaryrefslogtreecommitdiffstats
path: root/Python/pytime.c
diff options
context:
space:
mode:
authorMasaru Tsuchiyama <m.tmatma@gmail.com>2023-10-07 17:33:22 (GMT)
committerGitHub <noreply@github.com>2023-10-07 17:33:22 (GMT)
commitde2a4036cbfd5e41a5bdd2b81122b7765729af83 (patch)
tree44b739676b2707fddf3404882ae4b0e870cf0ce0 /Python/pytime.c
parent64f158e7b09e67d0bf5c8603ff88c86ed4e8f8fd (diff)
downloadcpython-de2a4036cbfd5e41a5bdd2b81122b7765729af83.zip
cpython-de2a4036cbfd5e41a5bdd2b81122b7765729af83.tar.gz
cpython-de2a4036cbfd5e41a5bdd2b81122b7765729af83.tar.bz2
gh-108277: Add os.timerfd_create() function (#108382)
Add wrapper for timerfd_create, timerfd_settime, and timerfd_gettime to os module. Co-authored-by: Serhiy Storchaka <storchaka@gmail.com> Co-authored-by: Adam Turner <9087854+AA-Turner@users.noreply.github.com> Co-authored-by: Erlend E. Aasland <erlend.aasland@protonmail.com> Co-authored-by: Victor Stinner <vstinner@python.org>
Diffstat (limited to 'Python/pytime.c')
-rw-r--r--Python/pytime.c14
1 files changed, 12 insertions, 2 deletions
diff --git a/Python/pytime.c b/Python/pytime.c
index d1e29e5..e4813d4 100644
--- a/Python/pytime.c
+++ b/Python/pytime.c
@@ -470,7 +470,7 @@ _PyTime_FromNanosecondsObject(_PyTime_t *tp, PyObject *obj)
#ifdef HAVE_CLOCK_GETTIME
static int
-pytime_fromtimespec(_PyTime_t *tp, struct timespec *ts, int raise_exc)
+pytime_fromtimespec(_PyTime_t *tp, const struct timespec *ts, int raise_exc)
{
_PyTime_t t, tv_nsec;
@@ -493,7 +493,7 @@ pytime_fromtimespec(_PyTime_t *tp, struct timespec *ts, int raise_exc)
}
int
-_PyTime_FromTimespec(_PyTime_t *tp, struct timespec *ts)
+_PyTime_FromTimespec(_PyTime_t *tp, const struct timespec *ts)
{
return pytime_fromtimespec(tp, ts, 1);
}
@@ -635,6 +635,16 @@ _PyTime_AsNanosecondsObject(_PyTime_t t)
return PyLong_FromLongLong((long long)ns);
}
+_PyTime_t
+_PyTime_FromSecondsDouble(double seconds, _PyTime_round_t round)
+{
+ _PyTime_t tp;
+ if(pytime_from_double(&tp, seconds, round, SEC_TO_NS) < 0) {
+ return -1;
+ }
+ return tp;
+}
+
static _PyTime_t
pytime_divide_round_up(const _PyTime_t t, const _PyTime_t k)