* [Bug 3672] fix biased selection in median cut <perlinger@ntp.org>
* [Bug 3666] avoid unlimited receive buffer allocation <perlinger@ntp.org>
- follow-up: fix inverted sense in check, reset shortfall counter
+* [Bug 3640] ntp.conf: missing documentation for "discard monitor" default value
+ - sidekick: fixed a bug in discard monitor implementation <perlingeræntp.org>
* [Bug 3626] (SNTP) UTC offset calculation needs dst flag <perlinger@ntp.org>
- applied patch by Gerry Garvey
* [Bug 3432] refclocks that 'write()' should check the result <perlinger@ntp.org>
int ntp_crypto_random_buf(void *buf, size_t nbytes);
long ntp_random (void);
+double ntp_uurandom(void);
void ntp_srandom (unsigned long);
void ntp_srandomdev (void);
char * ntp_initstate (unsigned long, /* seed for R.N.G. */
}
return(i);
}
+
+/*
+ * ntp_uurandom()
+ *
+ * Generate a Uniform-distributed Unity based random number. Replaces a
+ * few locations where the transformation was made in an ad-hoc style
+ * (and in one instance, wrong...)
+ *
+ * returns a number in [0.0 .. 1.0], both ends inclusive
+ */
+double
+ntp_uurandom( void )
+{
+ return (double)ntp_random() / 0x7FFFFFFFu;
+}
* must scale up the result by 2.0 to cover the full fractional
* range.
*/
- dfuzz = ntp_random() * 2. / FRAC * sys_fuzz;
+ dfuzz = ntp_uurandom() * sys_fuzz;
DTOLFP(dfuzz, &lfpfuzz);
L_ADD(&result, &lfpfuzz);
break;
#endif /* HAVE_TIMESTAMP */
}
- fuzz = ntp_random() * 2. / FRAC * sys_fuzz;
+ fuzz = ntp_uurandom() * sys_fuzz;
DTOLFP(fuzz, &lfpfuzz);
L_ADD(&nts, &lfpfuzz);
#ifdef DEBUG_TIMING
mon_getmoremem();
UNLINK_HEAD_SLIST(mon, mon_free, hash_next);
/* Preempt from the MRU list if old enough. */
- } else if (ntp_random() / (2. * FRAC) >
+ } else if (ntp_uurandom() >
(double)oldest_age / mon_age) {
return ~(RES_LIMITED | RES_KOD) & flags;
} else {
* surviving packets.
*/
if (restrict_mask & RES_FLAKE) {
- if ((double)ntp_random() / 0x7fffffff < .1) {
+ if (ntp_uurandom() < .1) {
DPRINTF(2, ("receive: drop: RES_FLAKE\n"));
sys_restricted++;
return; /* no flakeway */