lfpinit() signed or unsigned?

Achim Gratz Stromeko at nexgo.de
Sat Mar 11 12:21:38 UTC 2017


And more:

--8<---------------cut here---------------start------------->8---
@@ -323,7 +323,7 @@ step_systime(
 	struct timespec ofs_ts; /* desired offset as teimspec */
 
 	/* get the complete jump distance as timespec */
-        ofs_ts = d_to_tspec((step + sys_residual + 0.5e-9) * 1e9);
+        ofs_ts = d_to_tspec(step + sys_residual + 0.5e-9);
 
 	/* ---> time-critical path starts ---> */
 
--8<---------------cut here---------------end--------------->8---

Given how you've defined d_to_tspec, adding half a nanosecond is another
error right there since it's done again in d_to_tspec.  You are no
longer rounding, but instead addding a whole nanosecond.  Please fix it
up in another commit.

Oh, and you really do not need to normalize in d_to_tspec if you take
care of the fact that the nanoseconds should always be positive.  That's
true by definition if you start with a positive number and should be
handled directly in the conversion otherwise.

The normalization function itself has a pretty big blooper as well that
has been commited by Eric (dropping a minus sign in the condition).  It
basically made the test fail every time (except when the value was
eaxactly NANOSECOND), so we've run through the normalization even when
the number was already normalized.  If micro optimizations aren't
interesting, we should at least implement it correctly.  Since C99 has a
function that should be highly optimized that provides the numbers we
need, use it.  So, how about this (the code for 32bit timespec might be
removed later and replaced with a variant using div instead of LDIV):

-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0001-Fix-normalize_tspec.patch
Type: text/x-patch
Size: 2167 bytes
Desc: not available
URL: <https://lists.ntpsec.org/pipermail/devel/attachments/20170311/416b76c7/attachment.bin>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0002-Use-floor-in-d_to_tspec.patch
Type: text/x-patch
Size: 1092 bytes
Desc: not available
URL: <https://lists.ntpsec.org/pipermail/devel/attachments/20170311/416b76c7/attachment-0001.bin>
-------------- next part --------------



Regards,
Achim.
-- 
+<[Q+ Matrix-12 WAVE#46+305 Neuron microQkb Andromeda XTk Blofeld]>+

SD adaptation for Waldorf rackAttack V1.04R1:
http://Synth.Stromeko.net/Downloads.html#WaldorfSDada


More information about the devel mailing list