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>
This commit is contained in:
Masaru Tsuchiyama 2023-10-08 02:33:22 +09:00 committed by GitHub
parent 64f158e7b0
commit de2a4036cb
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
17 changed files with 1527 additions and 5 deletions

View file

@ -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)