[Git][NTPsec/ntpsec][master] 3 commits: Add ntp_set_tod to the Python extension.

Eric S. Raymond gitlab at mg.gitlab.com
Thu Nov 10 12:14:49 UTC 2016


Eric S. Raymond pushed to branch master at NTPsec / ntpsec


Commits:
9a9d3ec9 by Eric S. Raymond at 2016-11-10T07:03:11-05:00
Add ntp_set_tod to the Python extension.

- - - - -
74967037 by Eric S. Raymond at 2016-11-10T07:08:01-05:00
Because clock_settime(2) is now called from the Python extension...

...we need to ensure that in will pick up the real-time library, which
some platforms require to resolve that function.

- - - - -
e7e0e116 by Eric S. Raymond at 2016-11-10T07:14:08-05:00
Er, *really* don't import curses.ascii.  This was supposed...

...to be in "Address Issue #148: ntpq fails to run on netbsd".

- - - - -


3 changed files:

- libntp/pymodule.c
- libntp/wscript
- pylib/packet.py


Changes:

=====================================
libntp/pymodule.c
=====================================
--- a/libntp/pymodule.c
+++ b/libntp/pymodule.c
@@ -90,6 +90,17 @@ ntpc_lfptofloat(PyObject *self, PyObject *args)
     return Py_BuildValue("d", tt.tv_sec + tt.tv_nsec * 1e-9);
 }
 
+static PyObject *
+ntpc_set_tod(PyObject *self, PyObject *args)
+{
+    struct timespec ts;
+
+    UNUSED_ARG(self);
+    if (!PyArg_ParseTuple(args, "ii", &ts.tv_sec, &ts.tv_nsec))
+	return NULL;
+    return Py_BuildValue("d", ntp_set_tod(&ts));
+}
+
 /* List of functions defined in the module */
 
 static PyMethodDef ntpc_methods[] = {
@@ -101,6 +112,8 @@ static PyMethodDef ntpc_methods[] = {
      PyDoc_STR("Convert a time stamp to something readable.")},
     {"lfptofloat",     	ntpc_lfptofloat,  	METH_VARARGS,
      PyDoc_STR("NTP l_fp to Python-style float time.")},
+    {"set_tod",     	ntpc_set_tod,   	METH_VARARGS,
+     PyDoc_STR("Set time to nanosecind precision.")},
     {NULL,		NULL, 0, NULL}		/* sentinel */
 };
 


=====================================
libntp/wscript
=====================================
--- a/libntp/wscript
+++ b/libntp/wscript
@@ -73,5 +73,6 @@ def build(ctx):
 		features	= "c cshlib bld_include src_include pyext",
 		source		= ["pymodule.c"] + libntp_source_sharable,
 		install_path	= '${PYTHONDIR}/ntp',
+		use		= "M RT",
 		includes	= includes,
 	)


=====================================
pylib/packet.py
=====================================
--- a/pylib/packet.py
+++ b/pylib/packet.py
@@ -97,7 +97,7 @@ A Mode 6 packet cannot have extension fields.
 """
 # SPDX-License-Identifier: BSD-2-clause
 from __future__ import print_function, division
-import sys, socket, select, struct, curses.ascii, collections
+import sys, socket, select, struct, qcollections
 import getpass, hashlib, time
 from ntpc import lfptofloat
 
@@ -365,6 +365,7 @@ def dump_hex_printable(xdata):
                 sys.stdout.write("   ")
         i = restart
         for idx in range(rowlen):
+            # Do not use curses.isprint(), netbsd base doesn't install curses
             if ord(xdata[i]) >= 32 and ord(xdata(i)) < 127:
                 sys.stdout.write(xdata[i])
             else:



View it on GitLab: https://gitlab.com/NTPsec/ntpsec/compare/b753fd753c7f9fbf6d114e404e7796fa76d4fd93...e7e0e116a5a735cd4b3770c03b57d30f179130cc
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.ntpsec.org/pipermail/vc/attachments/20161110/37afd974/attachment.html>


More information about the vc mailing list