diff options
Diffstat (limited to 'Modules')
-rw-r--r-- | Modules/_decimal/_decimal.c | 10 | ||||
-rw-r--r-- | Modules/timemodule.c | 33 |
2 files changed, 38 insertions, 5 deletions
diff --git a/Modules/_decimal/_decimal.c b/Modules/_decimal/_decimal.c index d5d11341e39..32e336b4fff 100644 --- a/Modules/_decimal/_decimal.c +++ b/Modules/_decimal/_decimal.c @@ -1510,7 +1510,7 @@ current_context(void) #define CURRENT_CONTEXT_ADDR(ctx) \ ctx = CTX(current_context()) -/* Return current context, increment reference */ +/* Return a new reference to the current context */ static PyObject * PyDec_GetCurrentContext(void) { @@ -1614,7 +1614,7 @@ current_context(void) ctx = CTX(_c_t_x_o_b_j); \ } -/* Return current context, increment reference */ +/* Return a new reference to the current context */ static PyObject * PyDec_GetCurrentContext(void) { @@ -1759,7 +1759,7 @@ static PyTypeObject PyDecContextManager_Type = 0, /* tp_print */ (getattrfunc) 0, /* tp_getattr */ (setattrfunc) 0, /* tp_setattr */ - 0, /* tp_compare */ + 0, /* tp_reserved */ (reprfunc) 0, /* tp_repr */ 0, /* tp_as_number */ 0, /* tp_as_sequence */ @@ -2699,7 +2699,7 @@ ctx_create_decimal(PyObject *context, PyObject *args) /******************************************************************************/ -/* Implicit conversions to Decimal */ +/* Implicit conversions to Decimal */ /******************************************************************************/ /* Try to convert PyObject v to a new PyDecObject conv. If the conversion @@ -2796,7 +2796,7 @@ convert_op(int type_err, PyObject **conv, PyObject *v, PyObject *context) /******************************************************************************/ -/* Implicit conversions to Decimal for comparison */ +/* Implicit conversions to Decimal for comparison */ /******************************************************************************/ /* Convert rationals for comparison */ diff --git a/Modules/timemodule.c b/Modules/timemodule.c index f44e0c40c4e..23f3ddd765c 100644 --- a/Modules/timemodule.c +++ b/Modules/timemodule.c @@ -158,6 +158,33 @@ PyDoc_STRVAR(clock_gettime_doc, "clock_gettime(clk_id) -> floating point number\n\ \n\ Return the time of the specified clock clk_id."); + +static PyObject * +time_clock_settime(PyObject *self, PyObject *args) +{ + clockid_t clk_id; + PyObject *obj; + struct timespec tp; + int ret; + + if (!PyArg_ParseTuple(args, "iO:clock_settime", &clk_id, &obj)) + return NULL; + + if (_PyTime_ObjectToTimespec(obj, &tp.tv_sec, &tp.tv_nsec) == -1) + return NULL; + + ret = clock_settime((clockid_t)clk_id, &tp); + if (ret != 0) { + PyErr_SetFromErrno(PyExc_IOError); + return NULL; + } + Py_RETURN_NONE; +} + +PyDoc_STRVAR(clock_settime_doc, +"clock_settime(clk_id, time)\n\ +\n\ +Set the time of the specified clock clk_id."); #endif #ifdef HAVE_CLOCK_GETRES @@ -962,6 +989,9 @@ PyInit_timezone(PyObject *m) { #ifdef CLOCK_MONOTONIC_RAW PyModule_AddIntMacro(m, CLOCK_MONOTONIC_RAW); #endif +#ifdef CLOCK_HIGHRES + PyModule_AddIntMacro(m, CLOCK_HIGHRES); +#endif #ifdef CLOCK_PROCESS_CPUTIME_ID PyModule_AddIntMacro(m, CLOCK_PROCESS_CPUTIME_ID); #endif @@ -980,6 +1010,9 @@ static PyMethodDef time_methods[] = { #ifdef HAVE_CLOCK_GETTIME {"clock_gettime", time_clock_gettime, METH_VARARGS, clock_gettime_doc}, #endif +#ifdef HAVE_CLOCK_GETTIME + {"clock_settime", time_clock_settime, METH_VARARGS, clock_settime_doc}, +#endif #ifdef HAVE_CLOCK_GETRES {"clock_getres", time_clock_getres, METH_VARARGS, clock_getres_doc}, #endif |