*) AC_CHECK_FUNCS(mlockall)
;;
esac
-AC_CHECK_FUNCS(mrand48 srand48 nice nlist)
+AC_CHECK_FUNCS(nice nlist)
case "$host" in
*-*-solaris2.6)
# Broken...
;;
esac
AC_CHECK_FUNCS(plock pututline pututxline readlink recvmsg rtprio)
-case "$ac_cv_func_mrand48" in
- yes) ;;
- *) AC_REPLACE_FUNCS(random) ;;
-esac
case "$host" in
*-*-aix[[45]]*)
# Just a stub in AIX 4. Idiots.
AC_DEFINE(DECL_ADJTIME_0, 1, [Declaration style])
AC_DEFINE(DECL_INET_NTOA_0, 1, [Declaration style])
AC_DEFINE(DECL_MKTEMP_0, 1, [Declaration style])
- AC_DEFINE(DECL_MRAND48_0, 1, [Declaration style])
AC_DEFINE(DECL_SELECT_0, 1, [Declaration style])
AC_DEFINE(DECL_SETITIMER_0, 1, [Declaration style])
- AC_DEFINE(DECL_SRAND48_0, 1, [Declaration style])
AC_DEFINE(DECL_SYSLOG_0, 1, [Declaration style])
AC_DEFINE(DECL_TIMEOFDAY_0, 1, [Declaration style])
;;
AC_DEFINE(DECL_MEMMOVE_0, 1, [Declaration style])
AC_DEFINE(DECL_MKTEMP_0, 1, [Declaration style])
AC_DEFINE(DECL_MKSTEMP_0, 1, [Declaration style])
- AC_DEFINE(DECL_MRAND48_0, 1, [Declaration style])
AC_DEFINE(DECL_RENAME_0, 1, [Declaration style])
AC_DEFINE(DECL_SELECT_0, 1, [Declaration style])
AC_DEFINE(DECL_SETITIMER_0, 1, [Declaration style])
AC_DEFINE(DECL_SETPRIORITY_0, 1, [Declaration style])
AC_DEFINE(DECL_SIGVEC_0, 1, [Declaration style])
- AC_DEFINE(DECL_SRAND48_0, 1, [Declaration style])
case "`basename $ac_cv_prog_CC`" in
acc*) ;;
*) AC_DEFINE(DECL_STDIO_0, 1, [Declaration style])
AC_DEFINE(DECL_IOCTL_0, 1, [Declaration style])
AC_DEFINE(DECL_IPC_0, 1, [Declaration style])
AC_DEFINE(DECL_MKTEMP_0, 1, [Declaration style])
- AC_DEFINE(DECL_MRAND48_0, 1, [Declaration style])
AC_DEFINE(DECL_NLIST_0, 1, [Declaration style])
AC_DEFINE(DECL_PLOCK_0, 1, [Declaration style])
AC_DEFINE(DECL_SELECT_0, 1, [Declaration style])
AC_DEFINE(DECL_SETITIMER_0, 1, [Declaration style])
AC_DEFINE(DECL_SETPRIORITY_0, 1, [Declaration style])
- AC_DEFINE(DECL_SRAND48_0, 1, [Declaration style])
AC_DEFINE(DECL_STIME_0, 1, [Declaration style])
AC_DEFINE(DECL_SYSLOG_0, 1, [Declaration style])
AC_DEFINE(DECL_TIMEOFDAY_0, 1, [Declaration style])
extern char *mktemp P((char *));
#endif
-#ifdef DECL_MRAND48_0
-extern long mrand48 P((void));
-#endif
-
#ifdef DECL_NLIST_0
struct nlist;
extern int nlist P((const char *, struct nlist *));
extern int vsnprintf P((char *, size_t, const char *, va_list));
#endif
-#ifdef DECL_SRAND48_0
-extern void srand48 P((long));
-#endif
-
#ifdef DECL_STDIO_0
#if defined(FILE) || defined(BUFSIZ)
extern int _flsbuf P((int, FILE *));
extern int getdtablesize P((void));
extern int qsort (void *, int , int,
int P((*compar)(void *, void *)));
-extern long random P((void));
-extern long mrand48 P((void));
extern int setpgrp P((int, int));
-extern void srandom P((unsigned int));
extern void bcopy P((const char *, char *, int));
#endif
extern int fork P((void));
extern int getdtablesize P((void));
extern int ran P((void));
-extern int rand P((void));
-extern void srand P((unsigned int));
#ifdef _TIME_H_
extern int gettimeofday P((struct timeval *, struct timezone *));
extern int settimeofday P((struct timeval *, struct timezone *));
* How we randomize polls. The poll interval is a power of two. We chose
* a random interval which is this value plus-minus one second.
*/
-#if defined(HAVE_MRAND48)
-# define RANDOM (mrand48())
-# define SRANDOM(x) (srand48(x))
-#else
-# define RANDOM (random())
-# define SRANDOM(x) (srandom(x))
-#endif
-
-#define RANDPOLL(x) ((1 << (x)) - 1 + (RANDOM & 0x3))
+#define RANDPOLL(x) ((1 << (x)) - 1 + (ntp_random() & 0x3))
/*
* min, min3 and max. Makes it easier to transliterate the spec without
#define getclock clock_gettime
#define fcntl ioctl
#define _getch getchar
-#define random rand
-#define srandom srand
/* define this away for vxWorks */
#define openlog(x,y)
#define sleep(x) Sleep((DWORD) x * 1000 /* milliseconds */ );
#endif /* SYS_WINNT */
+extern void ntp_srandom P((unsigned long));
+extern int ntp_random P((void));
+
/* ntp_config.c */
extern void getconfig P((int, char **));
lib_strbuf.c machines.c md5c.c memmove.c mfptoa.c \
mfptoms.c mktime.c modetoa.c mstolfp.c msutotsf.c msyslog.c netof.c \
ntp_rfc2553.c numtoa.c numtohost.c octtoint.c prettydate.c \
- recvbuff.c refnumtoa.c snprintf.c socktoa.c socktohost.c \
+ random.c recvbuff.c refnumtoa.c snprintf.c socktoa.c socktohost.c \
statestr.c strdup.c strerror.c strstr.c \
syssignal.c tsftomsu.c tstotv.c tvtoa.c tvtots.c \
uglydate.c uinttoa.c utvtoa.c ymd2yd.c \
$(srcdir)/../libisc/netscope.c
libntp_a_SOURCES = systime.c $(libntp_a_SRCS)
libntpsim_a_SOURCES = systime_s.c $(libntp_a_SRCS)
-EXTRA_libntp_a_SOURCES = adjtimex.c random.c
+EXTRA_libntp_a_SOURCES = adjtimex.c
INCLUDES = -I$(top_srcdir)/include -I../include
ETAGS_ARGS = Makefile.am
static long *end_ptr = &randtbl[DEG_3 + 1];
static inline long good_rand P((long));
-long random P((void));
+long ntp_random P((void));
static inline long
good_rand (
* for default usage relies on values produced by this routine.
*/
void
-srandom(
+ntp_srandom(
unsigned long x
)
{
fptr = &state[rand_sep];
rptr = &state[0];
for (i = 0; i < 10 * rand_deg; i++)
- (void)random();
+ (void)ntp_random();
}
}
* a fixed seed.
*/
void
-srandomdev( void )
+ntp_srandomdev( void )
{
struct timeval tv;
unsigned long junk; /* Purposely used uninitialized */
gettimeofday(&tv, NULL);
- srandom(getpid() ^ tv.tv_sec ^ tv.tv_usec ^ junk);
+ ntp_srandom(getpid() ^ tv.tv_sec ^ tv.tv_usec ^ junk);
return;
}
* complain about mis-alignment, but you should disregard these messages.
*/
char *
-initstate(
+ntp_initstate(
unsigned long seed, /* seed for R.N.G. */
char *arg_state, /* pointer to state array */
long n /* # bytes of state info */
}
state = (long *) (long_arg_state + 1); /* first location */
end_ptr = &state[rand_deg]; /* must set end_ptr before srandom */
- srandom(seed);
+ ntp_srandom(seed);
if (rand_type == TYPE_0)
long_arg_state[0] = rand_type;
else
* complain about mis-alignment, but you should disregard these messages.
*/
char *
-setstate(
+ntp_setstate(
char *arg_state /* pointer to state array */
)
{
* Returns a 31-bit random number.
*/
long
-random( void )
+ntp_random( void )
{
register long i;
register long *f, *r;
+++ /dev/null
-/*
- * Random number generator is:
- *
- * Copyright 1988 by Rayan S. Zachariassen, all rights reserved.
- * This will be free software, but only when it is finished.
- *
- * Used in ntp by permission of the author. If copyright is
- * annoying to you, read no further. Instead, look up the reference,
- * write me an equivalent to this and send it back to me.
- */
-
-/*
- * Random number generator; see Knuth Vol 2. 2nd ed. p.27 (section 3.2.2)
- */
-#include "ntp_stdlib.h"
-
-/*
- * 55 random numbers, not all even. Note we don't initialize ran_y
- * directly since I have had thoughts of putting this in an EPROM
- */
-static time_t ran_y[55];
-
-static time_t init_ran_y[55] = {
- 1860909544, 231033423, 437666411, 1349655137, 2014584962,
- 504613712, 656256107, 1246027206, 573713775, 643466871,
- 540235388, 1630565153, 443649364, 729302839, 1933991552,
- 944681982, 949111118, 406212522, 1065063137, 1712954727,
- 73280612, 787623973, 1874130997, 801658492, 73395958,
- 739165367, 596047144, 490055249, 1131094323, 662727104,
- 483614097, 844520219, 893760527, 921280508, 46691708,
- 760861842, 1425894220, 702947816, 2006889048, 1999607995,
- 1346414687, 399640789, 1482689501, 1790064052, 1128943628,
- 1269197405, 587262386, 2078054746, 1675409928, 1652325524,
- 1643525825, 1748690540, 292465849, 1370173174, 402865384
-};
-
-static int ran_j;
-static int ran_k;
-
-
-/*
- * ranp2 - return a random integer in the range 0 .. (1 << m) - 1
- */
-u_long
-ranp2(
- int m
- )
-{
- time_t r;
-
- ran_y[ran_k] += ran_y[ran_j]; /* overflow does a mod */
- r = ran_y[ran_k];
- if (ran_k-- == 0)
- ran_k = 54;
- if (ran_j-- == 0)
- ran_j = 54;
- return (u_long)(r & ((1 << m ) - 1));
-}
-
-/*
- * init_random - do initialization of random number routine
- */
-void
-init_random(void)
-{
- register int i;
- register time_t now;
-
- ran_j = 23;
- ran_k = 54;
-
- /*
- * Randomize the seed array some more. The time of day
- * should be initialized by now.
- */
- now = time((time_t *)0) | 01;
-
- for (i = 0; i < 55; ++i)
- ran_y[i] = now * init_ran_y[i]; /* overflow does a mod */
-}
for (i = 0; i < 8; i++)
for (j = 1; j < 100; ++j) {
- rankey[i] = (char) (RANDOM & 0xff);
+ rankey[i] = (char) (ntp_random() & 0xff);
if (rankey[i] != 0) break;
}
rankey[8] = 0;
* NTP_MAXKEY.
*/
while (1) {
- keyid = (u_long)RANDOM & 0xffffffff;
+ keyid = (u_long)ntp_random(); /* 31 bits from ntp_random() */
if (keyid <= NTP_MAXKEY)
continue;
* Preempt from the MRU list if old enough.
*/
md = mon_mru_list.mru_prev;
- if (((u_long)RANDOM & 0xffffffff) / FRAC >
+ /* We get 31 bits from ntp_random() */
+ if (((u_long)ntp_random()) / FRAC >
(double)(current_time - md->lasttime) / mon_age)
return;
/*
* Initialize our first association ID
*/
- while ((current_association_ID = RANDOM & 0xffff) == 0);
+ while ((current_association_ID = ntp_random() & 0xffff) == 0);
}
if (initializing)
peer->nextdate = current_time + peer_associations;
else
- peer->nextdate = current_time + (RANDOM & ((1 <<
+ peer->nextdate = current_time + (ntp_random() & ((1 <<
NTP_MINPOLL) - 1));
#ifdef DEBUG
if (debug)
* Initialize random generator and public key pair
*/
get_systime(&now);
- SRANDOM((int)(now.l_i * now.l_uf));
+ ntp_srandom((int)(now.l_i * now.l_uf));
#ifdef HAVE_DNSREGISTRATION
msyslog(LOG_INFO, "Attemping to register mDNS\n");
* Watch out here, we want the real time, not the silly stuff.
*/
gettimeofday(&seed, NULL);
- srand48(seed.tv_usec);
+ ntp_srandom(seed.tv_usec);
/*
* Push a beep and timer interrupt on the queue
INCLUDES= -I$(top_srcdir)/include
# LDADD might need RESLIB and ADJLIB
LDADD= ../libntp/libntp.a
-ntp_keygen_LDADD= @LCRYPTO@
+ntp_keygen_LDADD= @LCRYPTO@ ../libntp/libntp.a
#EXTRA_DIST= README TAGS
EXTRA_DIST=
ETAGS_ARGS= Makefile.am
fprintf(stderr, "Generating MD5 keys...\n");
str = fheader("MD5key", hostname);
- srandom(epoch);
+ ntp_srandom(epoch);
for (i = 1; i <= MD5KEYS; i++) {
for (j = 0; j < 16; j++) {
while (1) {
- temp = random() & 0xff;
+ temp = ntp_random() & 0xff;
if (temp == '#')
continue;
if (temp > 0x20 && temp < 0x7f)