]> git.ipfire.org Git - thirdparty/open-vm-tools.git/commitdiff
Add a 64 bit pseudo random number generator
authorOliver Kurth <okurth@vmware.com>
Wed, 10 Apr 2019 21:14:56 +0000 (14:14 -0700)
committerOliver Kurth <okurth@vmware.com>
Wed, 10 Apr 2019 21:14:56 +0000 (14:14 -0700)
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.

open-vm-tools/lib/include/random.h
open-vm-tools/lib/misc/prng.c

index 1d09dfdaaa3150e9f94487bde8e29e9d08e7b33f..80c5c5f1c12cd6bef36687e1e61917207db0d69d 100644 (file)
@@ -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:
index 64b7bfdab88b78b319d10ac36a616b08db4afe43..d72ba8cefec181ccc1f333ffa30ba45773c6234f 100644 (file)
@@ -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:
 {