From: Oliver Kurth Date: Wed, 10 Apr 2019 21:14:56 +0000 (-0700) Subject: Add a 64 bit pseudo random number generator X-Git-Tag: stable-11.0.0~131 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=8b2bbbd8c2b647592a2f444a678fe93552fb0d22;p=thirdparty%2Fopen-vm-tools.git Add a 64 bit pseudo random number generator This change adds a 64 bit pseudo random number generator to the public library by calling the existing 32 bit Random_Fast function twice. Since the period of Random_Fast is 2^64, this should be sufficient. --- diff --git a/open-vm-tools/lib/include/random.h b/open-vm-tools/lib/include/random.h index 1d09dfdaa..80c5c5f1c 100644 --- a/open-vm-tools/lib/include/random.h +++ b/open-vm-tools/lib/include/random.h @@ -1,5 +1,5 @@ /********************************************************* - * Copyright (C) 1998-2017 VMware, Inc. All rights reserved. + * Copyright (C) 1998-2017,2019 VMware, Inc. All rights reserved. * * This program is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published @@ -77,6 +77,7 @@ uint32 Random_Quick(rqContext *context); */ uint32 Random_Fast(uint64 *state); +uint64 Random_Fast64(uint64 *state); static INLINE void Random_FastSeed(uint64 *state, // OUT: diff --git a/open-vm-tools/lib/misc/prng.c b/open-vm-tools/lib/misc/prng.c index 64b7bfdab..d72ba8cef 100644 --- a/open-vm-tools/lib/misc/prng.c +++ b/open-vm-tools/lib/misc/prng.c @@ -1,5 +1,5 @@ /********************************************************* - * Copyright (C) 1998-2016 VMware, Inc. All rights reserved. + * Copyright (C) 1998-2016,2019 VMware, Inc. All rights reserved. * * This program is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published @@ -114,6 +114,7 @@ RandomFastImpl(uint64 *rs, // IN/OUT: *----------------------------------------------------------------------------- * * Random_Fast -- + * Random_Fast64 -- * Random_FastStream -- * Random_FastStreamSeed -- * @@ -156,6 +157,12 @@ Random_Fast(uint64 *rs) // IN/OUT: return RandomFastImpl(rs, inc); } +uint64 +Random_Fast64(uint64 *rs) // IN/OUT: +{ + return QWORD(Random_Fast(rs), Random_Fast(rs)) ; +} + uint32 Random_FastStream(RandomFastContext *rfc) // IN/OUT: {