From c1f295aa8666eb1c08a1edf944ac5617659a066c Mon Sep 17 00:00:00 2001 From: d <> Date: Fri, 20 Nov 1998 11:18:51 +0000 Subject: Add thread-safety to libc, so that libc_r will build (on i386 at least). All POSIX libc api now there (to P1003.1c/D10) (more md stuff is needed for other libc/arch/*) (setlogin is no longer a special syscall) Add -pthread option to gcc (that makes it use -lc_r and -D_POSIX_THREADS). Doc some re-entrant routines Add libc_r to intro(3) dig() uses some libc srcs and an extra -I was needed there. Add more md stuff to libc_r. Update includes for the pthreads api Update libc_r TODO --- src/lib/libc/stdlib/rand.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) (limited to 'src/lib/libc/stdlib/rand.c') diff --git a/src/lib/libc/stdlib/rand.c b/src/lib/libc/stdlib/rand.c index f270ffd986..61fb66e5ec 100644 --- a/src/lib/libc/stdlib/rand.c +++ b/src/lib/libc/stdlib/rand.c @@ -32,7 +32,7 @@ */ #if defined(LIBC_SCCS) && !defined(lint) -static char *rcsid = "$OpenBSD: rand.c,v 1.2 1996/08/19 08:33:44 tholo Exp $"; +static char *rcsid = "$OpenBSD: rand.c,v 1.3 1998/11/20 11:18:50 d Exp $"; #endif /* LIBC_SCCS and not lint */ #include @@ -40,10 +40,18 @@ static char *rcsid = "$OpenBSD: rand.c,v 1.2 1996/08/19 08:33:44 tholo Exp $"; static u_long next = 1; +int +rand_r(seed) +u_int *seed; +{ + *seed = *seed * 1103515245 + 12345; + return (u_int)(*seed / 65536) % ((u_int)RAND_MAX + 1); +} + int rand() { - return ((next = next * 1103515245 + 12345) % ((u_int)RAND_MAX + 1)); + return rand_r(&next); } void -- cgit v1.2.3-55-g6feb