Repository: geode-native
Updated Branches:
  refs/heads/develop d4fe45d86 -> 4999c7910


GEODE-2525: Removes MersenneTwister sources.


Project: http://git-wip-us.apache.org/repos/asf/geode-native/repo
Commit: http://git-wip-us.apache.org/repos/asf/geode-native/commit/4999c791
Tree: http://git-wip-us.apache.org/repos/asf/geode-native/tree/4999c791
Diff: http://git-wip-us.apache.org/repos/asf/geode-native/diff/4999c791

Branch: refs/heads/develop
Commit: 4999c79104ccc50d658add486834654e75823f8f
Parents: d4fe45d
Author: Jacob Barrett <[email protected]>
Authored: Tue Mar 7 08:35:33 2017 -0800
Committer: Jacob Barrett <[email protected]>
Committed: Sat Jun 24 05:24:20 2017 -0700

----------------------------------------------------------------------
 LICENSE                                  |  36 ---
 src/tests/cpp/fwklib/GsRandom.cpp        |  51 +---
 src/tests/cpp/fwklib/GsRandom.hpp        | 103 +++-----
 src/tests/cpp/fwklib/MersenneTwister.cpp | 344 --------------------------
 src/tests/cpp/fwklib/MersenneTwister.hpp | 203 ---------------
 src/tests/cpp/fwklib/UDPIpc.cpp          |   4 +-
 src/tests/cpp/testobject/FastAsset.cpp   |   2 +-
 7 files changed, 45 insertions(+), 698 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/geode-native/blob/4999c791/LICENSE
----------------------------------------------------------------------
diff --git a/LICENSE b/LICENSE
index 2d176dc..4d8ae26 100644
--- a/LICENSE
+++ b/LICENSE
@@ -209,39 +209,3 @@ with separate copyright notices and license terms. Your 
use of those
 components are subject to the terms and conditions of the following
 licenses.
 
----------------------------------------------------------------------------
-The BSD 3-Clause License (http://opensource.org/licenses/BSD-3-Clause)
----------------------------------------------------------------------------
-
-Apache Geode bundles the following files under the BSD 3-Clause License:
-
-  - MersenneTwister.*pp 
(ihttp://www.math.sci.hiroshima-u.ac.jp/~m-mat/MT/emt.html),
-    Copyright (c) 1997-2002, Makoto Matsumoto and Takuji Nishimura
-    Copyright (c) 2000-2003, Richard J. Wagner
-
-All rights reserved.
-
-Redistribution and use in source and binary forms, with or without 
modification,
-are permitted provided that the following conditions are met:
-
-1. Redistributions of source code must retain the above copyright notice, this
-list of conditions and the following disclaimer.
-
-2. Redistributions in binary form must reproduce the above copyright notice,
-this list of conditions and the following disclaimer in the documentation 
and/or
-other materials provided with the distribution.
-
-3. Neither the name of the copyright holder nor the names of its contributors
-may be used to endorse or promote products derived from this software without
-specific prior written permission.
-
-THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
-ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
-WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
-DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 
FOR
-ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
-(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
-LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
-ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
-SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

http://git-wip-us.apache.org/repos/asf/geode-native/blob/4999c791/src/tests/cpp/fwklib/GsRandom.cpp
----------------------------------------------------------------------
diff --git a/src/tests/cpp/fwklib/GsRandom.cpp 
b/src/tests/cpp/fwklib/GsRandom.cpp
index c90a602..9bf91a1 100644
--- a/src/tests/cpp/fwklib/GsRandom.cpp
+++ b/src/tests/cpp/fwklib/GsRandom.cpp
@@ -18,60 +18,15 @@
 #include "GsRandom.hpp"
 
 #include <cstring>
-#include <mutex>
-#include <util/concurrent/spinlock_mutex.hpp>
 
 namespace apache {
 namespace geode {
 namespace client {
 namespace testframework {
 
-using util::concurrent::spinlock_mutex;
-
-GsRandom *GsRandom::singleton = 0;
-MTRand GsRandom::gen;
-int32_t GsRandom::seedUsed = -101;
-spinlock_mutex GsRandom::lck;
-
-/**
-  * Creates a new random number generator using a single
-  * <code>int32_t</code> seed.
-  *
-  * @param   seed   the initial seed.
-  * @see     java.util.Random#Random(int32_t)
-  */
-GsRandom *GsRandom::getInstance(int32_t seed) {
-  if (singleton == 0) {
-    setInstance(seed);
-  } else {
-    std::lock_guard<spinlock_mutex> guard(lck);
-    setSeed(seed);
-  }
-  return singleton;
-}
-
-void GsRandom::setInstance(int32_t seed) {
-  std::lock_guard<spinlock_mutex> guard(lck);
-  if (singleton == 0) {
-    singleton = new GsRandom();
-    if (seed != -1) {
-      singleton->gen.seed(seed);
-    } else {
-      singleton->gen.seed();
-    }
-    seedUsed = seed;
-  }
-}
-
-void GsRandom::setSeed(int32_t seed) {
-  if (seed != seedUsed) {
-    if (seed != -1) {
-      singleton->gen.seed(seed);
-    } else {
-      singleton->gen.seed();
-    }
-    seedUsed = seed;
-  }
+GsRandom &GsRandom::getInstance() {
+  static GsRandom instance;
+  return instance;
 }
 
 /**

http://git-wip-us.apache.org/repos/asf/geode-native/blob/4999c791/src/tests/cpp/fwklib/GsRandom.hpp
----------------------------------------------------------------------
diff --git a/src/tests/cpp/fwklib/GsRandom.hpp 
b/src/tests/cpp/fwklib/GsRandom.hpp
index 701568d..48c87ae 100644
--- a/src/tests/cpp/fwklib/GsRandom.hpp
+++ b/src/tests/cpp/fwklib/GsRandom.hpp
@@ -23,78 +23,63 @@
 #include <geode/geode_base.hpp>
 
 #include <string>
-
-#include <util/concurrent/spinlock_mutex.hpp>
-#include "MersenneTwister.hpp"
+#include <random>
 
 namespace apache {
 namespace geode {
 namespace client {
 namespace testframework {
 
-using util::concurrent::spinlock_mutex;
-
 class GsRandom {
  private:
-  static MTRand gen;
-  static GsRandom* singleton;
-  static int32_t seedUsed;
-  static spinlock_mutex lck;
-  static void setInstance(int32_t seed);
-
-  GsRandom() {}
-  static void setSeed(int32_t seed);
-
- public:
-  ~GsRandom() {
-    if (singleton != NULL) {
-      delete singleton;
-      singleton = NULL;
-    }
+  std::default_random_engine engine;
+
+  std::uniform_int_distribution<> distBoolean;
+  std::uniform_int_distribution<uint8_t> distUint8;
+  std::uniform_int_distribution<uint16_t> distUint16;
+  std::uniform_int_distribution<int32_t> distInt32;
+  std::uniform_int_distribution<uint32_t> distUint32;
+  std::uniform_real_distribution<double> distDouble;
+
+  GsRandom()
+      : distBoolean(0, 1),
+        distUint8(),
+        distUint16(),
+        distInt32(),
+        distUint32(),
+        distDouble() {
+    std::random_device seed;
+    engine = std::default_random_engine(seed());
   }
+  ~GsRandom() = default;
+  GsRandom(const GsRandom&) = delete;
+  GsRandom& operator=(const GsRandom&) = delete;
 
+ public:
   /**
     * Creates a new random number generator. Its seed is initialized to
-    * a value based on the /dev/urandom or current time.
-    *
-    * @see     java.lang.System#currentTimeMillis()
-    * @see     java.util.Random#Random()
-    */
-  inline static GsRandom* getInstance() {
-    if (singleton == 0) setInstance(-1);
-    return singleton;
-  }
-
-  /**
-    * Creates a new random number generator using a single
-    * <code>int32_t</code> seed.
+    * a value based on the random device.
     *
-    * @param   seed   the initial seed.
-    * @see     java.util.Random#Random(int32_t)
     */
-  static GsRandom* getInstance(int32_t seed);
+  static GsRandom& getInstance();
 
   /**
     * @return the next pseudorandom, uniformly distributed <code>boolean</code>
     *         value from this random number generator's sequence.
     */
-  inline bool nextBoolean() { return (singleton->gen.randInt(1) == 0); }
+  inline bool nextBoolean() { return 1 == distBoolean(engine); }
 
   /**
     * @return the next pseudorandom, uniformly distributed 
<code>uint16_t</code>
     *         value from this random number generator's sequence.
     */
-  inline uint16_t nextInt16() {
-    return static_cast<uint16_t>(singleton->gen.randInt(0xffff));
-  }
+  inline uint16_t nextInt16() { return distUint16(engine); }
 
   /**
     * @return the next pseudorandom, uniformly distributed <code>byte</code>
     *         value from this random number generator's sequence.
     */
-  inline uint8_t nextByte() {
-    return static_cast<uint8_t>(singleton->gen.randInt(0xff));
-  }
+  inline uint8_t nextByte() { return distUint8(engine); }
 
   /**
     * @param   min the minimum range (inclusive) for the pseudorandom.
@@ -103,9 +88,9 @@ class GsRandom {
     *          value from this random number generator's sequence.
     *       If max < min, returns 0 .
     */
-  inline uint8_t nextByte(int32_t min, int32_t max) {
-    if (max < min) return 0;
-    return static_cast<uint8_t>(singleton->gen.randInt(max - min) + min);
+  inline uint8_t nextByte(uint8_t min, uint8_t max) {
+    return distUint8(
+        engine, std::uniform_int_distribution<uint8_t>::param_type(min, max));
   }
 
   /**
@@ -123,7 +108,8 @@ class GsRandom {
     *      from min to max.
     */
   inline double nextDouble(double min, double max) {
-    return (singleton->gen.rand(max - min) + min);
+    return distDouble(
+        engine, std::uniform_real_distribution<double>::param_type(min, max));
   }
 
   /**
@@ -141,24 +127,23 @@ class GsRandom {
     *       If max < min, returns 0 .
     */
   inline int32_t nextInt(int32_t min, int32_t max) {
-    if (max < min) return 0;
-    return singleton->gen.randInt(max - min) + min;
+    return distInt32(
+        engine, std::uniform_int_distribution<int32_t>::param_type(min, max));
   }
 
   /** @brief return random number where: min <= retValue < max */
   static uint32_t random(uint32_t min, uint32_t max) {
-    return static_cast<uint32_t>(
-        GsRandom::getInstance()->nextInt(min, max - 1));
+    return getInstance().distUint32(
+        getInstance().engine,
+        std::uniform_int_distribution<uint32_t>::param_type(min, max - 1));
   }
 
   /** @brief return random number where: 0 <= retValue < max */
-  static uint32_t random(uint32_t max) {
-    return static_cast<uint32_t>(GsRandom::getInstance()->nextInt(0, max - 1));
-  }
+  static uint32_t random(uint32_t max) { return random(0, max - 1); }
 
   /** @brief return random double where: min <= retValue <= max */
   static double random(double min, double max) {
-    return GsRandom::getInstance()->nextDouble(min, max);
+    return getInstance().nextDouble(min, max);
   }
 
   /** @brief return bounded random string,
@@ -198,14 +183,6 @@ class GsRandom {
     }
   }
 
-  //  /**
-  //  * Returns a randomly-selected element of Vector vec.
-  //  */
-  //  inline void * randomElement(Vector vec)
-  //  {
-  //    return (void *)(vec.at(nextInt(vec.size())));
-  //  }
-
   /**
     * @param max the maximum length of the random string to generate.
     * @return a bounded random string with a length between 0 and

http://git-wip-us.apache.org/repos/asf/geode-native/blob/4999c791/src/tests/cpp/fwklib/MersenneTwister.cpp
----------------------------------------------------------------------
diff --git a/src/tests/cpp/fwklib/MersenneTwister.cpp 
b/src/tests/cpp/fwklib/MersenneTwister.cpp
deleted file mode 100644
index 7aedd02..0000000
--- a/src/tests/cpp/fwklib/MersenneTwister.cpp
+++ /dev/null
@@ -1,344 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-// MersenneTwister.h
-// Mersenne Twister random number generator -- a C++ class MTRand
-// Based on code by Makoto Matsumoto, Takuji Nishimura, and Shawn Cokus
-// Richard J. Wagner  v1.0  15 May 2003  [email protected]
-
-// The Mersenne Twister is an algorithm for generating random numbers.  It
-// was designed with consideration of the flaws in various other generators.
-// The period, 2^19937-1, and the order of equidistribution, 623 dimensions,
-// are far greater.  The generator is also fast; it avoids multiplication and
-// division, and it benefits from caches and pipelines.  For more information
-// see the inventors' web page at http://www.math.keio.ac.jp/~matumoto/emt.html
-
-// Reference
-// M. Matsumoto and T. Nishimura, "Mersenne Twister: A 623-Dimensionally
-// Equidistributed Uniform Pseudo-Random Number Generator", ACM Transactions on
-// Modeling and Computer Simulation, Vol. 8, No. 1, January 1998, pp 3-30.
-
-// Copyright (C) 1997 - 2002, Makoto Matsumoto and Takuji Nishimura,
-// Copyright (C) 2000 - 2003, Richard J. Wagner
-// All rights reserved.
-//
-// Redistribution and use in source and binary forms, with or without
-// modification, are permitted provided that the following conditions
-// are met:
-//
-//   1. Redistributions of source code must retain the above copyright
-//      notice, this list of conditions and the following disclaimer.
-//
-//   2. Redistributions in binary form must reproduce the above copyright
-//      notice, this list of conditions and the following disclaimer in the
-//      documentation and/or other materials provided with the distribution.
-//
-//   3. The names of its contributors may not be used to endorse or promote
-//      products derived from this software without specific prior written
-//      permission.
-//
-// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-// A PARTICULAR PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER
-// OR
-// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
-// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
-// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
-// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
-// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
-// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
-// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-
-// The original code included the following notice:
-//
-//     When you use this, send an email to: [email protected]
-//     with an appropriate reference to your work.
-//
-// It would be nice to CC: [email protected] and [email protected]
-// when you write.
-
-// Not thread safe (unless auto-initialization is avoided and each thread has
-// its own MTRand object)
-
-#include <mutex>
-#include "MersenneTwister.hpp"
-
-apache::geode::util::concurrent::spinlock_mutex MTRand::lck;
-
-MTRand::MTRand(const uint32_t &oneSeed) { seed(oneSeed); }
-
-MTRand::MTRand(uint32_t *const bigSeed, const uint32_t seedLength) {
-  seed(bigSeed, seedLength);
-}
-
-MTRand::MTRand() { seed(); }
-
-double MTRand::rand() { return double(randInt()) * (1.0 / 4294967295.0); }
-
-double MTRand::rand(const double &n) { return rand() * n; }
-
-double MTRand::randExc() { return double(randInt()) * (1.0 / 4294967296.0); }
-
-double MTRand::randExc(const double &n) { return randExc() * n; }
-
-double MTRand::randDblExc() {
-  return (double(randInt()) + 0.5) * (1.0 / 4294967296.0);
-}
-
-double MTRand::randDblExc(const double &n) { return randDblExc() * n; }
-
-double MTRand::rand53() {
-  uint32_t a = randInt() >> 5, b = randInt() >> 6;
-  return (a * 67108864.0 + b) * (1.0 / 9007199254740992.0);  // by Isaku Wada
-}
-
-double MTRand::randNorm(const double &mean, const double &variance) {
-  // Return a real number from a normal (Gaussian) distribution with given
-  // mean and variance by Box-Muller method
-  double r = sqrt(-2.0 * log(1.0 - randDblExc())) * variance;
-  double phi = 2.0 * 3.14159265358979323846264338328 * randExc();
-  return mean + r * cos(phi);
-}
-
-uint32_t MTRand::randInt() {
-  // Pull a 32-bit integer from the generator state
-  // Every other access function simply transforms the numbers extracted here
-  std::lock_guard<apache::geode::util::concurrent::spinlock_mutex> guard(lck);
-
-  if (left <= 0) reload();
-  --left;
-  uint32_t s1;
-  s1 = *pNext++;
-  s1 ^= (s1 >> 11);
-  s1 ^= (s1 << 7) & 0x9d2c5680UL;
-  s1 ^= (s1 << 15) & 0xefc60000UL;
-  return (s1 ^ (s1 >> 18));
-}
-
-uint32_t MTRand::randInt(const uint32_t &n) {
-  // Find which bits are used in n
-  // Optimized by Magnus Jonsson ([email protected])
-  uint32_t used = n;
-  used |= used >> 1;
-  used |= used >> 2;
-  used |= used >> 4;
-  used |= used >> 8;
-  used |= used >> 16;
-
-  // Draw numbers until one is found in [0,n]
-  uint32_t i;
-  do {
-    i = randInt() & used;  // toss unused bits to shorten search
-  } while (i > n);
-  return i;
-}
-
-void MTRand::seed(const uint32_t oneSeed) {
-  // Seed the generator with a simple uint32_t
-  initialize(oneSeed);
-  reload();
-}
-
-void MTRand::seed(uint32_t *const bigSeed, const uint32_t seedLength) {
-  // Seed the generator with an array of uint32_t's
-  // There are 2^19937-1 possible initial states.  This function allows
-  // all of those to be accessed by providing at least 19937 bits (with a
-  // default seed length of N = 624 uint32_t's).  Any bits above the lower 32
-  // in each element are discarded.
-  // Just call seed() if you want to get array from /dev/urandom
-  initialize(19650218UL);
-  int32_t i = 1;
-  uint32_t j = 0;
-  int32_t k = (N > seedLength ? N : seedLength);
-  for (; k; --k) {
-    state[i] = state[i] ^ ((state[i - 1] ^ (state[i - 1] >> 30)) * 1664525UL);
-    state[i] += (bigSeed[j] & 0xffffffffUL) + j;
-    state[i] &= 0xffffffffUL;
-    ++i;
-    ++j;
-    if (i >= N) {
-      state[0] = state[N - 1];
-      i = 1;
-    }
-    if (j >= seedLength) j = 0;
-  }
-  for (k = N - 1; k; --k) {
-    state[i] =
-        state[i] ^ ((state[i - 1] ^ (state[i - 1] >> 30)) * 1566083941UL);
-    state[i] -= i;
-    state[i] &= 0xffffffffUL;
-    ++i;
-    if (i >= N) {
-      state[0] = state[N - 1];
-      i = 1;
-    }
-  }
-  state[0] = 0x80000000UL;  // MSB is 1, assuring non-zero initial array
-  reload();
-}
-
-void MTRand::seed() {
-  // Seed the generator with an array from /dev/urandom if available
-  // Otherwise use a hash of time() and clock() values
-
-  // First try getting an array from /dev/urandom
-  FILE *urandom = fopen("/dev/urandom", "rb");
-  if (urandom) {
-    uint32_t bigSeed[N];
-    uint32_t *s = bigSeed;
-    int32_t i = N;
-    int32_t success = 1;
-    while (success && i--) {
-      success = static_cast<int32_t>(fread(s++, sizeof(uint32_t), 1, urandom));
-    }
-    fclose(urandom);
-    if (success) {
-      seed(bigSeed, N);
-      return;
-    }
-  }
-
-  // Was not successful, so use time() and clock() instead
-  seed(hash(time(nullptr), clock()));
-}
-
-void MTRand::initialize(const uint32_t seed) {
-  // Initialize generator state with seed
-  // See Knuth TAOCP Vol 2, 3rd Ed, p.106 for multiplier.
-  // In previous versions, most significant bits (MSBs) of the seed affect
-  // only MSBs of the state array.  Modified 9 Jan 2002 by Makoto Matsumoto.
-  uint32_t *s = state;
-  uint32_t *r = state;
-  int32_t i = 1;
-  *s++ = seed & 0xffffffffUL;
-  for (; i < N; ++i) {
-    *s++ = (1812433253UL * (*r ^ (*r >> 30)) + i) & 0xffffffffUL;
-    r++;
-  }
-}
-
-void MTRand::reload() {
-  // Generate N new values in state
-  // Made clearer and faster by Matthew Bellew ([email protected])
-  uint32_t *p = state;
-  int32_t i;
-  for (i = N - M; i--; ++p) *p = twist(p[M], p[0], p[1]);
-  for (i = M; --i; ++p) *p = twist(p[M - N], p[0], p[1]);
-  *p = twist(p[M - N], p[0], state[0]);
-
-  left = N, pNext = state;
-}
-
-uint32_t MTRand::hash(time_t t, clock_t c) {
-  // Get a uint32_t from t and c
-  // Better than uint32_t(x) in case x is floating point in [0,1]
-  // Based on code by Lawrence Kirby ([email protected])
-
-  static uint32_t differ = 0;  // guarantee time-based seeds will change
-
-  uint32_t h1 = 0;
-  unsigned char *p = reinterpret_cast<unsigned char *>(&t);
-  for (size_t i = 0; i < sizeof(t); ++i) {
-    h1 *= UCHAR_MAX + 2U;
-    h1 += p[i];
-  }
-  uint32_t h2 = 0;
-  p = reinterpret_cast<unsigned char *>(&c);
-  for (size_t j = 0; j < sizeof(c); ++j) {
-    h2 *= UCHAR_MAX + 2U;
-    h2 += p[j];
-  }
-  return (h1 + differ++) ^ h2;
-}
-
-void MTRand::save(uint32_t *saveArray) const {
-  uint32_t *sa = saveArray;
-  const uint32_t *s = state;
-  int32_t i = N;
-  for (; i--; *sa++ = *s++) {
-  }
-  *sa = left;
-}
-
-void MTRand::load(uint32_t *const loadArray) {
-  uint32_t *s = state;
-  uint32_t *la = loadArray;
-  int32_t i = N;
-  for (; i--; *s++ = *la++) {
-  }
-  left = *la;
-  pNext = &state[N - left];
-}
-
-std::ostream &operator<<(std::ostream &os, const MTRand &mtrand) {
-  const uint32_t *s = mtrand.state;
-  int32_t i = mtrand.N;
-  for (; i--; os << *s++ << "\t") {
-  }
-  return os << mtrand.left;
-}
-
-std::istream &operator>>(std::istream &is, MTRand &mtrand) {
-  uint32_t *s = mtrand.state;
-  int32_t i = mtrand.N;
-  for (; i--; is >> *s++) {
-  }
-  is >> mtrand.left;
-  mtrand.pNext = &mtrand.state[mtrand.N - mtrand.left];
-  return is;
-}
-
-// Change log:
-//
-// v0.1 - First release on 15 May 2000
-//      - Based on code by Makoto Matsumoto, Takuji Nishimura, and Shawn Cokus
-//      - Translated from C to C++
-//      - Made completely ANSI compliant
-//      - Designed convenient interface for initialization, seeding, and
-//        obtaining numbers in default or user-defined ranges
-//      - Added automatic seeding from /dev/urandom or time() and clock()
-//      - Provided functions for saving and loading generator state
-//
-// v0.2 - Fixed bug which reloaded generator one step too late
-//
-// v0.3 - Switched to clearer, faster reload() code from Matthew Bellew
-//
-// v0.4 - Removed trailing newline in saved generator format to be consistent
-//        with output format of built-in types
-//
-// v0.5 - Improved portability by replacing static const int's with enum's and
-//        clarifying return values in seed(); suggested by Eric Heimburg
-//      - Removed MAXINT constant; use 0xffffffffUL instead
-//
-// v0.6 - Eliminated seed overflow when uint32_t is larger than 32 bits
-//      - Changed integer [0,n] generator to give better uniformity
-//
-// v0.7 - Fixed operator precedence ambiguity in reload()
-//      - Added access for real numbers in (0,1) and (0,n)
-//
-// v0.8 - Included ctime header to properly support time_t and clock_t
-//
-// v1.0 - Revised seeding to match 26 Jan 2002 update of Nishimura and 
Matsumoto
-//      - Allowed for seeding with arrays of any length
-//      - Added access for real numbers in [0,1) with 53-bit resolution
-//      - Added access for real numbers from normal (Gaussian) distributions
-//      - Increased overall speed by optimizing twist()
-//      - Doubled speed of integer [0,n] generation
-//      - Fixed out-of-range number generation on 64-bit machines
-//      - Improved portability by substituting literal constants for int32_t
-//      enum's
-//      - Changed license from GNU LGPL to BSD

http://git-wip-us.apache.org/repos/asf/geode-native/blob/4999c791/src/tests/cpp/fwklib/MersenneTwister.hpp
----------------------------------------------------------------------
diff --git a/src/tests/cpp/fwklib/MersenneTwister.hpp 
b/src/tests/cpp/fwklib/MersenneTwister.hpp
deleted file mode 100644
index b22683e..0000000
--- a/src/tests/cpp/fwklib/MersenneTwister.hpp
+++ /dev/null
@@ -1,203 +0,0 @@
-#pragma once
-
-#ifndef GEODE_FWKLIB_MERSENNETWISTER_H_
-#define GEODE_FWKLIB_MERSENNETWISTER_H_
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-// MersenneTwister.h
-// Mersenne Twister random number generator -- a C++ class MTRand
-// Based on code by Makoto Matsumoto, Takuji Nishimura, and Shawn Cokus
-// Richard J. Wagner  v1.0  15 May 2003  [email protected]
-
-// The Mersenne Twister is an algorithm for generating random numbers.  It
-// was designed with consideration of the flaws in various other generators.
-// The period, 2^19937-1, and the order of equidistribution, 623 dimensions,
-// are far greater.  The generator is also fast; it avoids multiplication and
-// division, and it benefits from caches and pipelines.  For more information
-// see the inventors' web page at http://www.math.keio.ac.jp/~matumoto/emt.html
-
-// Reference
-// M. Matsumoto and T. Nishimura, "Mersenne Twister: A 623-Dimensionally
-// Equidistributed Uniform Pseudo-Random Number Generator", ACM Transactions on
-// Modeling and Computer Simulation, Vol. 8, No. 1, January 1998, pp 3-30.
-
-// Copyright (C) 1997 - 2002, Makoto Matsumoto and Takuji Nishimura,
-// Copyright (C) 2000 - 2003, Richard J. Wagner
-// All rights reserved.
-//
-// Redistribution and use in source and binary forms, with or without
-// modification, are permitted provided that the following conditions
-// are met:
-//
-//   1. Redistributions of source code must retain the above copyright
-//      notice, this list of conditions and the following disclaimer.
-//
-//   2. Redistributions in binary form must reproduce the above copyright
-//      notice, this list of conditions and the following disclaimer in the
-//      documentation and/or other materials provided with the distribution.
-//
-//   3. The names of its contributors may not be used to endorse or promote
-//      products derived from this software without specific prior written
-//      permission.
-//
-// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-// A PARTICULAR PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER
-// OR
-// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
-// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
-// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
-// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
-// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
-// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
-// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-
-// The original code included the following notice:
-//
-//     When you use this, send an email to: [email protected]
-//     with an appropriate reference to your work.
-//
-// It would be nice to CC: [email protected] and [email protected]
-// when you write.
-
-// Not thread safe (unless auto-initialization is avoided and each thread has
-// its own MTRand object)
-
-#include <iostream>
-#include <limits.h>
-#include <cstdio>
-#include <ctime>
-#include <math.h>
-
-#include <util/concurrent/spinlock_mutex.hpp>
-#include <geode/geode_base.hpp>
-
-class MTRand {
-  // Data
- public:
-  enum { N = 624 };       // length of state vector
-  enum { SAVE = N + 1 };  // length of array for save()
-
- protected:
-  enum { M = 397 };  // period parameter
-
-  uint32_t state[N];  // internal state
-  uint32_t* pNext;    // next value to get from state
-  int32_t left;       // number of values left before reload needed
-
- private:
-  static apache::geode::util::concurrent::spinlock_mutex lck;
-
-  // Methods
- public:
-  MTRand(const uint32_t& oneSeed);  // initialize with a simple uint32_t
-  MTRand(uint32_t* const bigSeed,
-         uint32_t const seedLength = N);  // or an array
-  MTRand();  // auto-initialize with /dev/urandom or time() and clock()
-
-  // Do NOT use for CRYPTOGRAPHY without securely hashing several returned
-  // values together, otherwise the generator state can be learned after
-  // reading 624 consecutive values.
-
-  // Access to 32-bit random numbers
-  double rand();                          // real number in [0,1]
-  double rand(const double& n);           // real number in [0,n]
-  double randExc();                       // real number in [0,1)
-  double randExc(const double& n);        // real number in [0,n)
-  double randDblExc();                    // real number in (0,1)
-  double randDblExc(const double& n);     // real number in (0,n)
-  uint32_t randInt();                     // integer in [0,2^32-1]
-  uint32_t randInt(const uint32_t& n);    // integer in [0,n] for n < 2^32
-  double operator()() { return rand(); }  // same as rand()
-
-  // Access to 53-bit random numbers (capacity of IEEE double precision)
-  double rand53();  // real number in [0,1)
-
-  // Access to nonuniform random number distributions
-  double randNorm(const double& mean = 0.0, const double& variance = 0.0);
-
-  // Re-seeding functions with same behavior as initializers
-  void seed(const uint32_t oneSeed);
-  void seed(uint32_t* const bigSeed, const uint32_t seedLength = N);
-  void seed();
-
-  // Saving and loading generator state
-  void save(uint32_t* saveArray) const;  // to array of size SAVE
-  void load(uint32_t* const loadArray);  // from such array
-  friend std::ostream& operator<<(std::ostream& os, const MTRand& mtrand);
-  friend std::istream& operator>>(std::istream& is, MTRand& mtrand);
-
- protected:
-  void initialize(const uint32_t oneSeed);
-  void reload();
-  uint32_t hiBit(const uint32_t& u) const { return u & 0x80000000; }
-  uint32_t loBit(const uint32_t& u) const { return u & 0x00000001; }
-  uint32_t loBits(const uint32_t& u) const { return u & 0x7fffffff; }
-  uint32_t mixBits(const uint32_t& u, const uint32_t& v) const {
-    return hiBit(u) | loBits(v);
-  }
-  uint32_t twist(const uint32_t& m, const uint32_t& s0,
-                 const uint32_t& s1) const {
-    return m ^ (mixBits(s0, s1) >> 1) ^
-           (-static_cast<int32_t>(loBit(s1)) & 0x9908b0df);
-  }
-  static uint32_t hash(time_t t, clock_t c);
-};
-
-// Change log:
-//
-// v0.1 - First release on 15 May 2000
-//      - Based on code by Makoto Matsumoto, Takuji Nishimura, and Shawn Cokus
-//      - Translated from C to C++
-//      - Made completely ANSI compliant
-//      - Designed convenient interface for initialization, seeding, and
-//        obtaining numbers in default or user-defined ranges
-//      - Added automatic seeding from /dev/urandom or time() and clock()
-//      - Provided functions for saving and loading generator state
-//
-// v0.2 - Fixed bug which reloaded generator one step too late
-//
-// v0.3 - Switched to clearer, faster reload() code from Matthew Bellew
-//
-// v0.4 - Removed trailing newline in saved generator format to be consistent
-//        with output format of built-in types
-//
-// v0.5 - Improved portability by replacing static const int's with enum's and
-//        clarifying return values in seed(); suggested by Eric Heimburg
-//      - Removed MAXINT constant; use 0xffffffffUL instead
-//
-// v0.6 - Eliminated seed overflow when uint32_t is larger than 32 bits
-//      - Changed integer [0,n] generator to give better uniformity
-//
-// v0.7 - Fixed operator precedence ambiguity in reload()
-//      - Added access for real numbers in (0,1) and (0,n)
-//
-// v0.8 - Included ctime header to properly support time_t and clock_t
-//
-// v1.0 - Revised seeding to match 26 Jan 2002 update of Nishimura and 
Matsumoto
-//      - Allowed for seeding with arrays of any length
-//      - Added access for real numbers in [0,1) with 53-bit resolution
-//      - Added access for real numbers from normal (Gaussian) distributions
-//      - Increased overall speed by optimizing twist()
-//      - Doubled speed of integer [0,n] generation
-//      - Fixed out-of-range number generation on 64-bit machines
-//      - Improved portability by substituting literal constants for long 
enum's
-//      - Changed license from GNU LGPL to BSD
-
-#endif  // GEODE_FWKLIB_MERSENNETWISTER_H_

http://git-wip-us.apache.org/repos/asf/geode-native/blob/4999c791/src/tests/cpp/fwklib/UDPIpc.cpp
----------------------------------------------------------------------
diff --git a/src/tests/cpp/fwklib/UDPIpc.cpp b/src/tests/cpp/fwklib/UDPIpc.cpp
index d3f9fc5..7741c1b 100644
--- a/src/tests/cpp/fwklib/UDPIpc.cpp
+++ b/src/tests/cpp/fwklib/UDPIpc.cpp
@@ -150,9 +150,7 @@ UDPMessageClient::UDPMessageClient(std::string server)
   int32_t tries = 100;
   ACE_INET_Addr* client = new ACE_INET_Addr();
   while ((result < 0) && (tries > 0)) {
-    uint32_t port = GsRandom::random(static_cast<uint32_t>(1111),
-                                     static_cast<uint32_t>(31111)) +
-                    tries;
+    uint32_t port = GsRandom::random(1111u, 31111u) + tries;
     client->set(port, "localhost");
     result = m_io.open(*client);
   }

http://git-wip-us.apache.org/repos/asf/geode-native/blob/4999c791/src/tests/cpp/testobject/FastAsset.cpp
----------------------------------------------------------------------
diff --git a/src/tests/cpp/testobject/FastAsset.cpp 
b/src/tests/cpp/testobject/FastAsset.cpp
index dbe1b34..7595993 100644
--- a/src/tests/cpp/testobject/FastAsset.cpp
+++ b/src/tests/cpp/testobject/FastAsset.cpp
@@ -22,7 +22,7 @@ using namespace testframework;
 using namespace testobject;
 
 FastAsset::FastAsset(int idx, int maxVal) : assetId(idx) {
-  value = GsRandom::getInstance(12)->nextDouble(1, 
static_cast<double>(maxVal));
+  value = GsRandom::getInstance().nextDouble(1, maxVal);
 }
 
 FastAsset::~FastAsset() {}

Reply via email to