[Python-checkins] cpython: Issue #22117: Use the _PyTime_t API for time.clock_settime()
victor.stinner
python-checkins at python.org
Sat Mar 28 05:20:04 CET 2015
https://hg.python.org/cpython/rev/5aa39b88bd55
changeset: 95238:5aa39b88bd55
user: Victor Stinner <victor.stinner at gmail.com>
date: Sat Mar 28 04:09:41 2015 +0100
summary:
Issue #22117: Use the _PyTime_t API for time.clock_settime()
Remove also the now unused _PyTime_AddDouble() function.
files:
Include/pytime.h | 5 -----
Modules/timemodule.c | 10 +++++-----
Python/pytime.c | 17 -----------------
3 files changed, 5 insertions(+), 27 deletions(-)
diff --git a/Include/pytime.h b/Include/pytime.h
--- a/Include/pytime.h
+++ b/Include/pytime.h
@@ -74,11 +74,6 @@
long *nsec,
_PyTime_round_t);
-/* Add interval seconds to tv */
-PyAPI_FUNC(void)
-_PyTime_AddDouble(_PyTime_timeval *tv, double interval,
- _PyTime_round_t round);
-
/* Initialize time.
Return 0 on success, raise an exception and return -1 on error. */
PyAPI_FUNC(int) _PyTime_Init(void);
diff --git a/Modules/timemodule.c b/Modules/timemodule.c
--- a/Modules/timemodule.c
+++ b/Modules/timemodule.c
@@ -166,18 +166,18 @@
{
int clk_id;
PyObject *obj;
- time_t tv_sec;
- long tv_nsec;
+ _PyTime_t t;
struct timespec tp;
int ret;
if (!PyArg_ParseTuple(args, "iO:clock_settime", &clk_id, &obj))
return NULL;
- if (_PyTime_ObjectToTimespec(obj, &tv_sec, &tv_nsec, _PyTime_ROUND_DOWN) == -1)
+ if (_PyTime_FromSecondsObject(&t, obj, _PyTime_ROUND_DOWN) < 0)
return NULL;
- tp.tv_sec = tv_sec;
- tp.tv_nsec = tv_nsec;
+
+ if (_PyTime_AsTimespec(t, &tp) == -1)
+ return NULL;
ret = clock_settime((clockid_t)clk_id, &tp);
if (ret != 0) {
diff --git a/Python/pytime.c b/Python/pytime.c
--- a/Python/pytime.c
+++ b/Python/pytime.c
@@ -251,23 +251,6 @@
return _PyTime_ObjectToDenominator(obj, sec, usec, 1e6, round);
}
-void
-_PyTime_AddDouble(_PyTime_timeval *tv, double interval, _PyTime_round_t round)
-{
- _PyTime_timeval tv2;
- double frac;
-
- frac = fmod(interval, 1.0);
- interval = floor(interval);
- tv2.tv_sec = (long)interval;
- tv2.tv_usec = (long)(frac*1e6);
-
- tv->tv_sec += tv2.tv_sec;
- tv->tv_usec += tv2.tv_usec;
- tv->tv_sec += (time_t)(tv->tv_usec / SEC_TO_US);
- tv->tv_usec %= SEC_TO_US;
-}
-
/****************** NEW _PyTime_t API **********************/
static void
--
Repository URL: https://hg.python.org/cpython
More information about the Python-checkins
mailing list