projects
/
ppp.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (from parent 1:
8ed8058
)
use drand48 et al. instead of random
author
Paul Mackerras
<paulus@samba.org>
Mon, 24 Apr 1995 05:57:01 +0000
(
05:57
+0000)
committer
Paul Mackerras
<paulus@samba.org>
Mon, 24 Apr 1995 05:57:01 +0000
(
05:57
+0000)
pppd/magic.c
patch
|
blob
|
history
diff --git
a/pppd/magic.c
b/pppd/magic.c
index 71647633d024a586dae624b4bfc59633693e2804..7391b1405df8a52b7649bd3390f2f24bcd06afc1 100644
(file)
--- a/
pppd/magic.c
+++ b/
pppd/magic.c
@@
-18,7
+18,7
@@
*/
#ifndef lint
*/
#ifndef lint
-static char rcsid[] = "$Id: magic.c,v 1.
3 1994/09/21 06:47:37
paulus Exp $";
+static char rcsid[] = "$Id: magic.c,v 1.
4 1995/04/24 05:57:01
paulus Exp $";
#endif
#include <stdio.h>
#endif
#include <stdio.h>
@@
-30,41
+30,58
@@
static char rcsid[] = "$Id: magic.c,v 1.3 1994/09/21 06:47:37 paulus Exp $";
static u_int32_t next; /* Next value to return */
static u_int32_t next; /* Next value to return */
-extern
u_int32_
t gethostid __P((void));
-extern long
random
__P((void));
-extern void srand
om __P((int
));
+extern
in
t gethostid __P((void));
+extern long
mrand48
__P((void));
+extern void srand
48 __P((long
));
/*
* magic_init - Initialize the magic number generator.
*
/*
* magic_init - Initialize the magic number generator.
*
- * Computes first magic number and seed for random number generator.
* Attempts to compute a random number seed which will not repeat.
* Attempts to compute a random number seed which will not repeat.
- * The current method uses the current hostid and current time.
+ * The current method uses the current hostid and current time
, currently
.
*/
*/
-void magic_init()
+void
+magic_init()
{
{
-
struct timeval tv
;
+
long seed
;
- next = gethostid();
- if (gettimeofday(&tv, NULL)) {
- perror("gettimeofday");
- exit(1);
- }
- next ^= (u_int32_t) tv.tv_sec ^ (u_int32_t) tv.tv_usec;
-
- srandom((int) next);
+ seed = gethostid() ^ time(NULL);
+ srand48(seed);
}
}
-
/*
* magic - Returns the next magic number.
*/
/*
* magic - Returns the next magic number.
*/
-u_int32_t magic()
+u_int32_t
+magic()
{
{
- u_int32_t m;
+ return (u_int32_t) mrand48();
+}
+
+#ifdef NO_DRAND48
+/*
+ * Substitute procedures for those systems which don't have
+ * drand48 et al.
+ */
- m = next;
- next = (u_int32_t) random();
- return (m);
+double
+drand48()
+{
+ return (double)random() / (double)0x7fffffffL; /* 2**31-1 */
}
}
+
+long
+mrand48()
+{
+ return random();
+}
+
+void
+srand48(seedval)
+long seedval;
+{
+ srandom((int)seedval);
+}
+
+#endif