diff options
author | Elliott Hughes <enh@google.com> | 2013-10-28 23:09:49 +0000 |
---|---|---|
committer | Gerrit Code Review <noreply-gerritcodereview@google.com> | 2013-10-28 23:09:49 +0000 |
commit | 07d3c6cecc8016577c9dbd827e85154c077604da (patch) | |
tree | 87579ea373e65026ad974c3f13fadfed26df194c | |
parent | 020bcdaef349b6bd82302a0656fdf9aaff30bdb3 (diff) | |
parent | 60fd3450bf5cd081e019ea50616032e1447aeeb3 (diff) | |
download | android_bionic-07d3c6cecc8016577c9dbd827e85154c077604da.tar.gz android_bionic-07d3c6cecc8016577c9dbd827e85154c077604da.tar.bz2 android_bionic-07d3c6cecc8016577c9dbd827e85154c077604da.zip |
Merge "Fix the *rand48 functions on LP64."
-rw-r--r-- | libc/upstream-netbsd/libc/stdlib/jrand48.c | 6 | ||||
-rw-r--r-- | libc/upstream-netbsd/libc/stdlib/lrand48.c | 7 | ||||
-rw-r--r-- | libc/upstream-netbsd/libc/stdlib/mrand48.c | 6 | ||||
-rw-r--r-- | libc/upstream-netbsd/libc/stdlib/nrand48.c | 7 |
4 files changed, 12 insertions, 14 deletions
diff --git a/libc/upstream-netbsd/libc/stdlib/jrand48.c b/libc/upstream-netbsd/libc/stdlib/jrand48.c index 0ab594e9c..079dbd30c 100644 --- a/libc/upstream-netbsd/libc/stdlib/jrand48.c +++ b/libc/upstream-netbsd/libc/stdlib/jrand48.c @@ -1,4 +1,4 @@ -/* $NetBSD: jrand48.c,v 1.8 2005/06/12 05:21:28 lukem Exp $ */ +/* $NetBSD: jrand48.c,v 1.9 2013/10/22 08:08:51 matt Exp $ */ /* * Copyright (c) 1993 Martin Birgmeier @@ -15,7 +15,7 @@ #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 $"); +__RCSID("$NetBSD: jrand48.c,v 1.9 2013/10/22 08:08:51 matt Exp $"); #endif /* LIBC_SCCS and not lint */ #include "namespace.h" @@ -35,5 +35,5 @@ jrand48(unsigned short xseed[3]) _DIAGASSERT(xseed != NULL); __dorand48(xseed); - return ((long) xseed[2] << 16) + (long) xseed[1]; + return (int16_t)xseed[2] * 65536 + xseed[1]; } diff --git a/libc/upstream-netbsd/libc/stdlib/lrand48.c b/libc/upstream-netbsd/libc/stdlib/lrand48.c index 78f869e90..11e64855b 100644 --- a/libc/upstream-netbsd/libc/stdlib/lrand48.c +++ b/libc/upstream-netbsd/libc/stdlib/lrand48.c @@ -1,4 +1,4 @@ -/* $NetBSD: lrand48.c,v 1.8 2005/06/12 05:21:28 lukem Exp $ */ +/* $NetBSD: lrand48.c,v 1.9 2013/10/22 08:08:51 matt Exp $ */ /* * Copyright (c) 1993 Martin Birgmeier @@ -15,7 +15,7 @@ #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 $"); +__RCSID("$NetBSD: lrand48.c,v 1.9 2013/10/22 08:08:51 matt Exp $"); #endif /* LIBC_SCCS and not lint */ #include "namespace.h" @@ -29,6 +29,5 @@ long lrand48(void) { __dorand48(__rand48_seed); - return (long)((unsigned long) __rand48_seed[2] << 15) + - ((unsigned long) __rand48_seed[1] >> 1); + return __rand48_seed[2] * 32768 + (__rand48_seed[1] >> 1); } diff --git a/libc/upstream-netbsd/libc/stdlib/mrand48.c b/libc/upstream-netbsd/libc/stdlib/mrand48.c index c787ce681..e51352acd 100644 --- a/libc/upstream-netbsd/libc/stdlib/mrand48.c +++ b/libc/upstream-netbsd/libc/stdlib/mrand48.c @@ -1,4 +1,4 @@ -/* $NetBSD: mrand48.c,v 1.7 2005/06/12 05:21:28 lukem Exp $ */ +/* $NetBSD: mrand48.c,v 1.8 2013/10/22 08:08:51 matt Exp $ */ /* * Copyright (c) 1993 Martin Birgmeier @@ -15,7 +15,7 @@ #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 $"); +__RCSID("$NetBSD: mrand48.c,v 1.8 2013/10/22 08:08:51 matt Exp $"); #endif /* LIBC_SCCS and not lint */ #include "namespace.h" @@ -29,5 +29,5 @@ long mrand48(void) { __dorand48(__rand48_seed); - return ((long) __rand48_seed[2] << 16) + (long) __rand48_seed[1]; + return (int16_t)__rand48_seed[2] * 65536 + __rand48_seed[1]; } diff --git a/libc/upstream-netbsd/libc/stdlib/nrand48.c b/libc/upstream-netbsd/libc/stdlib/nrand48.c index fc7318512..98beccac6 100644 --- a/libc/upstream-netbsd/libc/stdlib/nrand48.c +++ b/libc/upstream-netbsd/libc/stdlib/nrand48.c @@ -1,4 +1,4 @@ -/* $NetBSD: nrand48.c,v 1.9 2005/06/12 05:21:28 lukem Exp $ */ +/* $NetBSD: nrand48.c,v 1.10 2013/10/22 08:08:51 matt Exp $ */ /* * Copyright (c) 1993 Martin Birgmeier @@ -15,7 +15,7 @@ #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 $"); +__RCSID("$NetBSD: nrand48.c,v 1.10 2013/10/22 08:08:51 matt Exp $"); #endif /* LIBC_SCCS and not lint */ #include "namespace.h" @@ -34,6 +34,5 @@ nrand48(unsigned short xseed[3]) _DIAGASSERT(xseed != NULL); __dorand48(xseed); - return (long)((unsigned long) xseed[2] << 15) + - ((unsigned long) xseed[1] >> 1); + return xseed[2] * 32768 + (xseed[1] >> 1); } |