summaryrefslogtreecommitdiffstats
path: root/Modules/_testcapimodule.c
diff options
context:
space:
mode:
authorVictor Stinner <victor.stinner@gmail.com>2015-03-27 17:19:03 (GMT)
committerVictor Stinner <victor.stinner@gmail.com>2015-03-27 17:19:03 (GMT)
commit34dc0f46ae5c0c9ec91d9402fac61111b802855f (patch)
tree274e9bac8b7049fabac4f16161676edfd847c771 /Modules/_testcapimodule.c
parent7181dec3f12f11c9a5f4adc6336b1c7273452308 (diff)
downloadcpython-34dc0f46ae5c0c9ec91d9402fac61111b802855f.zip
cpython-34dc0f46ae5c0c9ec91d9402fac61111b802855f.tar.gz
cpython-34dc0f46ae5c0c9ec91d9402fac61111b802855f.tar.bz2
Issue #22117: The signal modules uses the new _PyTime_t API
* Add _PyTime_AsTimespec() * Add unit tests for _PyTime_AsTimespec()
Diffstat (limited to 'Modules/_testcapimodule.c')
-rw-r--r--Modules/_testcapimodule.c20
1 files changed, 20 insertions, 0 deletions
diff --git a/Modules/_testcapimodule.c b/Modules/_testcapimodule.c
index b382081..5029105 100644
--- a/Modules/_testcapimodule.c
+++ b/Modules/_testcapimodule.c
@@ -3408,6 +3408,23 @@ test_pytime_assecondsdouble(PyObject *self, PyObject *args)
return PyFloat_FromDouble(d);
}
+#ifdef HAVE_CLOCK_GETTIME
+static PyObject *
+test_PyTime_AsTimespec(PyObject *self, PyObject *args)
+{
+ PY_LONG_LONG ns;
+ _PyTime_t t;
+ struct timespec ts;
+
+ if (!PyArg_ParseTuple(args, "L", &ns))
+ return NULL;
+ t = _PyTime_FromNanoseconds(ns);
+ if (_PyTime_AsTimespec(t, &ts) == -1)
+ return NULL;
+ return Py_BuildValue("Nl", _PyLong_FromTime_t(ts.tv_sec), ts.tv_nsec);
+}
+#endif
+
static PyMethodDef TestMethods[] = {
{"raise_exception", raise_exception, METH_VARARGS},
@@ -3573,6 +3590,9 @@ static PyMethodDef TestMethods[] = {
return_result_with_error, METH_NOARGS},
{"PyTime_FromSecondsObject", test_pytime_fromsecondsobject, METH_VARARGS},
{"PyTime_AsSecondsDouble", test_pytime_assecondsdouble, METH_VARARGS},
+#ifdef HAVE_CLOCK_GETTIME
+ {"PyTime_AsTimespec", test_PyTime_AsTimespec, METH_VARARGS},
+#endif
{NULL, NULL} /* sentinel */
};