aboutsummaryrefslogtreecommitdiffstats
path: root/libc
diff options
context:
space:
mode:
Diffstat (limited to 'libc')
-rw-r--r--libc/Android.mk16
-rw-r--r--libc/private/rand48.h10
-rw-r--r--libc/upstream-netbsd/libc/stdlib/_rand48.c (renamed from libc/stdlib/_rand48.c)12
-rw-r--r--libc/upstream-netbsd/libc/stdlib/drand48.c (renamed from libc/bionic/drand48.c)10
-rw-r--r--libc/upstream-netbsd/libc/stdlib/erand48.c (renamed from libc/bionic/erand48.c)17
-rw-r--r--libc/upstream-netbsd/libc/stdlib/jrand48.c (renamed from libc/stdlib/jrand48.c)19
-rw-r--r--libc/upstream-netbsd/libc/stdlib/lrand48.c (renamed from libc/stdlib/lrand48.c)16
-rw-r--r--libc/upstream-netbsd/libc/stdlib/mrand48.c (renamed from libc/stdlib/mrand48.c)13
-rw-r--r--libc/upstream-netbsd/libc/stdlib/nrand48.c (renamed from libc/stdlib/nrand48.c)21
-rw-r--r--libc/upstream-netbsd/libc/stdlib/srand48.c (renamed from libc/stdlib/srand48.c)17
10 files changed, 124 insertions, 27 deletions
diff --git a/libc/Android.mk b/libc/Android.mk
index 13d26477c..2fc430065 100644
--- a/libc/Android.mk
+++ b/libc/Android.mk
@@ -140,7 +140,6 @@ libc_common_src_files := \
stdio/__sprintf_chk.c \
stdio/__vsnprintf_chk.c \
stdio/__vsprintf_chk.c \
- stdlib/_rand48.c \
stdlib/assert.c \
stdlib/atexit.c \
stdlib/atoi.c \
@@ -151,19 +150,14 @@ libc_common_src_files := \
stdlib/div.c \
stdlib/exit.c \
stdlib/getenv.c \
- stdlib/jrand48.c \
stdlib/ldiv.c \
stdlib/lldiv.c \
stdlib/locale.c \
- stdlib/lrand48.c \
- stdlib/mrand48.c \
- stdlib/nrand48.c \
stdlib/putenv.c \
stdlib/qsort.c \
stdlib/seed48.c \
stdlib/setenv.c \
stdlib/setjmperr.c \
- stdlib/srand48.c \
stdlib/strntoimax.c \
stdlib/strntoumax.c \
stdlib/strtod.c \
@@ -265,8 +259,6 @@ libc_common_src_files := \
bionic/clearenv.c \
bionic/dirname.c \
bionic/dirname_r.c \
- bionic/drand48.c \
- bionic/erand48.c \
bionic/err.c \
bionic/fdprintf.c \
bionic/fork.c \
@@ -342,6 +334,14 @@ libc_upstream_netbsd_src_files := \
upstream-netbsd/libc/regex/regfree.c \
upstream-netbsd/libc/stdio/getdelim.c \
upstream-netbsd/libc/stdio/getline.c \
+ upstream-netbsd/libc/stdlib/drand48.c \
+ upstream-netbsd/libc/stdlib/erand48.c \
+ upstream-netbsd/libc/stdlib/jrand48.c \
+ upstream-netbsd/libc/stdlib/lrand48.c \
+ upstream-netbsd/libc/stdlib/mrand48.c \
+ upstream-netbsd/libc/stdlib/nrand48.c \
+ upstream-netbsd/libc/stdlib/_rand48.c \
+ upstream-netbsd/libc/stdlib/srand48.c \
upstream-netbsd/libc/stdlib/tdelete.c \
upstream-netbsd/libc/stdlib/tfind.c \
upstream-netbsd/libc/stdlib/tsearch.c \
diff --git a/libc/private/rand48.h b/libc/private/rand48.h
index afa49f65f..1ad8b0d21 100644
--- a/libc/private/rand48.h
+++ b/libc/private/rand48.h
@@ -1,3 +1,5 @@
+/* $NetBSD: rand48.h,v 1.6 2011/05/18 19:36:36 dsl Exp $ */
+
/*
* Copyright (c) 1993 Martin Birgmeier
* All rights reserved.
@@ -9,17 +11,17 @@
* This software is provided ``as is'', and comes with no warranties
* of any kind. I shall in no event be liable for anything that happens
* to anyone/anything when using this software.
- *
- * $OpenBSD: rand48.h,v 1.3 2002/02/16 21:27:24 millert Exp $
*/
#ifndef _RAND48_H_
#define _RAND48_H_
-#include <math.h>
#include <stdlib.h>
-void __dorand48(unsigned short[3]);
+extern void __dorand48(unsigned short[3]);
+extern unsigned short __rand48_seed[3];
+extern unsigned short __rand48_mult[3];
+extern unsigned short __rand48_add;
#define RAND48_SEED_0 (0x330e)
#define RAND48_SEED_1 (0xabcd)
diff --git a/libc/stdlib/_rand48.c b/libc/upstream-netbsd/libc/stdlib/_rand48.c
index 7c950f7ce..0468026dc 100644
--- a/libc/stdlib/_rand48.c
+++ b/libc/upstream-netbsd/libc/stdlib/_rand48.c
@@ -1,4 +1,5 @@
-/* $OpenBSD: _rand48.c,v 1.3 2005/08/08 08:05:36 espie Exp $ */
+/* $NetBSD: _rand48.c,v 1.7 2005/06/12 05:21:27 lukem Exp $ */
+
/*
* Copyright (c) 1993 Martin Birgmeier
* All rights reserved.
@@ -12,6 +13,13 @@
* to anyone/anything when using this software.
*/
+#include <sys/cdefs.h>
+#if defined(LIBC_SCCS) && !defined(lint)
+__RCSID("$NetBSD: _rand48.c,v 1.7 2005/06/12 05:21:27 lukem Exp $");
+#endif /* LIBC_SCCS and not lint */
+
+#include <assert.h>
+
#include "rand48.h"
unsigned short __rand48_seed[3] = {
@@ -32,6 +40,8 @@ __dorand48(unsigned short xseed[3])
unsigned long accu;
unsigned short temp[2];
+ _DIAGASSERT(xseed != NULL);
+
accu = (unsigned long) __rand48_mult[0] * (unsigned long) xseed[0] +
(unsigned long) __rand48_add;
temp[0] = (unsigned short) accu; /* lower 16 bits */
diff --git a/libc/bionic/drand48.c b/libc/upstream-netbsd/libc/stdlib/drand48.c
index 93272cf64..6fba607a3 100644
--- a/libc/bionic/drand48.c
+++ b/libc/upstream-netbsd/libc/stdlib/drand48.c
@@ -1,3 +1,5 @@
+/* $NetBSD: drand48.c,v 1.6 2005/06/12 05:21:28 lukem Exp $ */
+
/*
* Copyright (c) 1993 Martin Birgmeier
* All rights reserved.
@@ -12,10 +14,16 @@
*/
#include <sys/cdefs.h>
+#if defined(LIBC_SCCS) && !defined(lint)
+__RCSID("$NetBSD: drand48.c,v 1.6 2005/06/12 05:21:28 lukem Exp $");
+#endif /* LIBC_SCCS and not lint */
+#include "namespace.h"
#include "rand48.h"
-extern unsigned short __rand48_seed[3];
+#ifdef __weak_alias
+__weak_alias(drand48,_drand48)
+#endif
double
drand48(void)
diff --git a/libc/bionic/erand48.c b/libc/upstream-netbsd/libc/stdlib/erand48.c
index 4ecbeadfc..f1d8b4de0 100644
--- a/libc/bionic/erand48.c
+++ b/libc/upstream-netbsd/libc/stdlib/erand48.c
@@ -1,3 +1,5 @@
+/* $NetBSD: erand48.c,v 1.9 2006/03/22 20:52:16 drochner Exp $ */
+
/*
* Copyright (c) 1993 Martin Birgmeier
* All rights reserved.
@@ -12,12 +14,27 @@
*/
#include <sys/cdefs.h>
+#if defined(LIBC_SCCS) && !defined(lint)
+__RCSID("$NetBSD: erand48.c,v 1.9 2006/03/22 20:52:16 drochner Exp $");
+#endif /* LIBC_SCCS and not lint */
+
+#include "namespace.h"
+
+#include <assert.h>
+#include <math.h>
#include "rand48.h"
+#ifdef __weak_alias
+__weak_alias(erand48,_erand48)
+#endif
+
double
erand48(unsigned short xseed[3])
{
+
+ _DIAGASSERT(xseed != NULL);
+
__dorand48(xseed);
return ldexp((double) xseed[0], -48) +
ldexp((double) xseed[1], -32) +
diff --git a/libc/stdlib/jrand48.c b/libc/upstream-netbsd/libc/stdlib/jrand48.c
index cb8c59275..0ab594e9c 100644
--- a/libc/stdlib/jrand48.c
+++ b/libc/upstream-netbsd/libc/stdlib/jrand48.c
@@ -1,4 +1,5 @@
-/* $OpenBSD: jrand48.c,v 1.3 2005/08/08 08:05:36 espie Exp $ */
+/* $NetBSD: jrand48.c,v 1.8 2005/06/12 05:21:28 lukem Exp $ */
+
/*
* Copyright (c) 1993 Martin Birgmeier
* All rights reserved.
@@ -12,11 +13,27 @@
* to anyone/anything when using this software.
*/
+#include <sys/cdefs.h>
+#if defined(LIBC_SCCS) && !defined(lint)
+__RCSID("$NetBSD: jrand48.c,v 1.8 2005/06/12 05:21:28 lukem Exp $");
+#endif /* LIBC_SCCS and not lint */
+
+#include "namespace.h"
+
+#include <assert.h>
+
#include "rand48.h"
+#ifdef __weak_alias
+__weak_alias(jrand48,_jrand48)
+#endif
+
long
jrand48(unsigned short xseed[3])
{
+
+ _DIAGASSERT(xseed != NULL);
+
__dorand48(xseed);
return ((long) xseed[2] << 16) + (long) xseed[1];
}
diff --git a/libc/stdlib/lrand48.c b/libc/upstream-netbsd/libc/stdlib/lrand48.c
index 21beb858c..78f869e90 100644
--- a/libc/stdlib/lrand48.c
+++ b/libc/upstream-netbsd/libc/stdlib/lrand48.c
@@ -1,4 +1,5 @@
-/* $OpenBSD: lrand48.c,v 1.3 2005/08/08 08:05:36 espie Exp $ */
+/* $NetBSD: lrand48.c,v 1.8 2005/06/12 05:21:28 lukem Exp $ */
+
/*
* Copyright (c) 1993 Martin Birgmeier
* All rights reserved.
@@ -12,13 +13,22 @@
* to anyone/anything when using this software.
*/
+#include <sys/cdefs.h>
+#if defined(LIBC_SCCS) && !defined(lint)
+__RCSID("$NetBSD: lrand48.c,v 1.8 2005/06/12 05:21:28 lukem Exp $");
+#endif /* LIBC_SCCS and not lint */
+
+#include "namespace.h"
#include "rand48.h"
-extern unsigned short __rand48_seed[3];
+#ifdef __weak_alias
+__weak_alias(lrand48,_lrand48)
+#endif
long
lrand48(void)
{
__dorand48(__rand48_seed);
- return ((long) __rand48_seed[2] << 15) + ((long) __rand48_seed[1] >> 1);
+ return (long)((unsigned long) __rand48_seed[2] << 15) +
+ ((unsigned long) __rand48_seed[1] >> 1);
}
diff --git a/libc/stdlib/mrand48.c b/libc/upstream-netbsd/libc/stdlib/mrand48.c
index 977264aba..c787ce681 100644
--- a/libc/stdlib/mrand48.c
+++ b/libc/upstream-netbsd/libc/stdlib/mrand48.c
@@ -1,4 +1,5 @@
-/* $OpenBSD: mrand48.c,v 1.3 2005/08/08 08:05:37 espie Exp $ */
+/* $NetBSD: mrand48.c,v 1.7 2005/06/12 05:21:28 lukem Exp $ */
+
/*
* Copyright (c) 1993 Martin Birgmeier
* All rights reserved.
@@ -12,9 +13,17 @@
* to anyone/anything when using this software.
*/
+#include <sys/cdefs.h>
+#if defined(LIBC_SCCS) && !defined(lint)
+__RCSID("$NetBSD: mrand48.c,v 1.7 2005/06/12 05:21:28 lukem Exp $");
+#endif /* LIBC_SCCS and not lint */
+
+#include "namespace.h"
#include "rand48.h"
-extern unsigned short __rand48_seed[3];
+#ifdef __weak_alias
+__weak_alias(mrand48,_mrand48)
+#endif
long
mrand48(void)
diff --git a/libc/stdlib/nrand48.c b/libc/upstream-netbsd/libc/stdlib/nrand48.c
index f1f548c3a..fc7318512 100644
--- a/libc/stdlib/nrand48.c
+++ b/libc/upstream-netbsd/libc/stdlib/nrand48.c
@@ -1,4 +1,5 @@
-/* $OpenBSD: nrand48.c,v 1.3 2005/08/08 08:05:37 espie Exp $ */
+/* $NetBSD: nrand48.c,v 1.9 2005/06/12 05:21:28 lukem Exp $ */
+
/*
* Copyright (c) 1993 Martin Birgmeier
* All rights reserved.
@@ -12,11 +13,27 @@
* to anyone/anything when using this software.
*/
+#include <sys/cdefs.h>
+#if defined(LIBC_SCCS) && !defined(lint)
+__RCSID("$NetBSD: nrand48.c,v 1.9 2005/06/12 05:21:28 lukem Exp $");
+#endif /* LIBC_SCCS and not lint */
+
+#include "namespace.h"
+
+#include <assert.h>
+
#include "rand48.h"
+#ifdef __weak_alias
+__weak_alias(nrand48,_nrand48)
+#endif
+
long
nrand48(unsigned short xseed[3])
{
+ _DIAGASSERT(xseed != NULL);
+
__dorand48(xseed);
- return ((long) xseed[2] << 15) + ((long) xseed[1] >> 1);
+ return (long)((unsigned long) xseed[2] << 15) +
+ ((unsigned long) xseed[1] >> 1);
}
diff --git a/libc/stdlib/srand48.c b/libc/upstream-netbsd/libc/stdlib/srand48.c
index f76b6cca8..a9673fe1b 100644
--- a/libc/stdlib/srand48.c
+++ b/libc/upstream-netbsd/libc/stdlib/srand48.c
@@ -1,4 +1,5 @@
-/* $OpenBSD: srand48.c,v 1.3 2005/08/08 08:05:37 espie Exp $ */
+/* $NetBSD: srand48.c,v 1.7 2005/06/12 05:21:28 lukem Exp $ */
+
/*
* Copyright (c) 1993 Martin Birgmeier
* All rights reserved.
@@ -12,18 +13,24 @@
* to anyone/anything when using this software.
*/
+#include <sys/cdefs.h>
+#if defined(LIBC_SCCS) && !defined(lint)
+__RCSID("$NetBSD: srand48.c,v 1.7 2005/06/12 05:21:28 lukem Exp $");
+#endif /* LIBC_SCCS and not lint */
+
+#include "namespace.h"
#include "rand48.h"
-extern unsigned short __rand48_seed[3];
-extern unsigned short __rand48_mult[3];
-extern unsigned short __rand48_add;
+#ifdef __weak_alias
+__weak_alias(srand48,_srand48)
+#endif
void
srand48(long seed)
{
__rand48_seed[0] = RAND48_SEED_0;
__rand48_seed[1] = (unsigned short) seed;
- __rand48_seed[2] = (unsigned short) (seed >> 16);
+ __rand48_seed[2] = (unsigned short) ((unsigned long)seed >> 16);
__rand48_mult[0] = RAND48_MULT_0;
__rand48_mult[1] = RAND48_MULT_1;
__rand48_mult[2] = RAND48_MULT_2;