Merge branch 'dev'
authorkhizmax <libcds.dev@gmail.com>
Wed, 1 Jun 2016 05:21:57 +0000 (08:21 +0300)
committerkhizmax <libcds.dev@gmail.com>
Wed, 1 Jun 2016 05:21:57 +0000 (08:21 +0300)
cds/details/bitop_generic.h
cds/opt/options.h
cds/opt/permutation.h
test/stress/queue/random.cpp
test/unit/list/test_kv_list_nogc.h
test/unit/misc/split_bitstring.cpp

index 833732b1616616985dc2fae146cb68ef5889e2ba..38a1dd49e37a0909dca1f75e1c2dea80d1ab1933 100644 (file)
@@ -31,7 +31,8 @@
 #ifndef CDSLIB_DETAILS_BITOP_GENERIC_H
 #define CDSLIB_DETAILS_BITOP_GENERIC_H
 
-#include <stdlib.h>     // rand()
+#include <cstdlib>     // rand()
+
 namespace cds {
     namespace bitop { namespace platform {
         // Return true if x = 2 ** k, k >= 0
@@ -277,7 +278,7 @@ namespace cds {
             //static uint32_t xRandom = 2463534242UL    ;    //rand() | 0x0100    ;    // must be nonzero
             //uint32_t x = xRandom;
             if ( !x )
-                x = ((rand() + 1) << 16) + rand() + 1;
+                x = (( std::rand() + 1) << 16 ) + std::rand() + 1;
             x ^= x << 13;
             x ^= x >> 15;
             return x ^= x << 5;
index c2d39f3e294870a40c0993b576144cbfc1226e2a..82b0a1fcee1a4322a9eaad064af785a8741fd724 100644 (file)
@@ -38,7 +38,7 @@
         2011.01.23 khizmax  Created
 */
 
-#include <stdlib.h> // rand, srand
+#include <cstdlib> // rand, srand
 
 #include <cds/details/aligned_type.h>
 #include <cds/user_setup/allocator.h>
@@ -869,16 +869,16 @@ namespace cds { namespace opt {
         struct c_rand {
             typedef unsigned int result_type; ///< Result type
 
-            /// Constructor initializes object calling \p srand()
+            /// Constructor initializes object calling \p std::srand()
             c_rand()
             {
-                srand(1);
+                std::srand(1);
             }
 
-            /// Returns next random number calling \p rand()
+            /// Returns next random number calling \p std::rand()
             result_type operator()()
             {
-                return (result_type) rand();
+                return (result_type) std::rand();
             }
         };
 
index 58b2bf7743b6ad4772b1949545ec65d16e37a03b..46a2147277d18a13b1202dd62a9cd0dc1621af62 100644 (file)
@@ -31,7 +31,7 @@
 #ifndef CDSLIB_OPT_PERMUTATION_H
 #define CDSLIB_OPT_PERMUTATION_H
 
-#include <stdlib.h> // rand, srand
+#include <cstdlib> // rand, srand
 #include <random>
 #include <algorithm> // std::shuffle
 #include <numeric>   // std::iota
@@ -146,7 +146,7 @@ namespace cds { namespace opt {
             /// Resets the generator to produce new sequence
             void reset()
             {
-                m_nCur = m_nStart = integer_type( rand() ) % m_nMod;
+                m_nCur = m_nStart = integer_type( std::rand() ) % m_nMod;
             }
         };
 
@@ -204,7 +204,7 @@ namespace cds { namespace opt {
             /// Resets the generator to produce new sequence
             void reset()
             {
-                m_nCur = m_nStart = integer_type( rand() ) & m_nMask;
+                m_nCur = m_nStart = integer_type( std::rand() ) & m_nMask;
             }
         };
 
index 65b81a264498681c0bbdfb627f4181caae9bba62..f444f6369deae3d6abd5cc979dda4d14b864d44f 100644 (file)
@@ -89,7 +89,7 @@ namespace {
                 value_type node;
 
                 while ( m_nPushCount < nTotalPush ) {
-                    if ( (rand() & 3) != 3 ) {
+                    if ( ( std::rand() & 3) != 3 ) {
                         node.nThread = id();
                         node.nNo = ++m_nPushCount;
                         if ( !m_Queue.push( node )) {
index aff834afdcd507aca4cd1ca972332b46da1ccf7c..26352e05193f17d7af91a3bb47acd6cb9ddf448d 100644 (file)
@@ -167,7 +167,7 @@ namespace cds_test {
             ASSERT_CONTAINER_SIZE( l, 0 );
 
             // insert/find
-            for ( auto const& i : arr ) {
+            for ( key_val const& i : arr ) {
                 EXPECT_TRUE( l.contains( i.key ) == l.end());
                 EXPECT_TRUE( l.contains( key_type( i.key )) == l.end());
                 EXPECT_TRUE( l.contains( other_key( i.key ), other_less()) == l.end());
index a362a332dbfee543935dd065c63d8b89dc3ac9f8..d5d58f0c93e5ccf23ae7111cb9735a082655baeb 100644 (file)
@@ -108,7 +108,7 @@ namespace {
                     while ( splitter ) {
                         ASSERT_FALSE( splitter.eos() );
                         ASSERT_FALSE( !splitter );
-                        int bits = rand() % 16;
+                        int bits = std::rand() % 16;
                         res = res + ( splitter.safe_cut( bits ) << shift );
                         shift += bits;
                     }
@@ -180,7 +180,7 @@ namespace {
                     while ( splitter ) {
                         ASSERT_FALSE( splitter.eos() );
                         ASSERT_FALSE( !splitter );
-                        int bits = rand() % 16;
+                        int bits = std::rand() % 16;
                         res = (res << bits) + splitter.safe_cut( bits );
                     }
                     ASSERT_TRUE( splitter.eos() );
@@ -234,7 +234,7 @@ namespace {
                     while ( splitter ) {
                         ASSERT_FALSE( splitter.eos() );
                         ASSERT_FALSE( !splitter );
-                        int bits = rand() % 16;
+                        int bits = std::rand() % 16;
                         res = res + ( static_cast<uint64_t>(splitter.safe_cut( bits )) << shift );
                         shift += bits;
                     }
@@ -288,7 +288,7 @@ namespace {
                     while ( splitter ) {
                         ASSERT_FALSE( splitter.eos() );
                         ASSERT_FALSE( !splitter );
-                        int bits = rand() % 16;
+                        int bits = std::rand() % 16;
                         res = (res << bits) + splitter.safe_cut( bits );
                     }
                     ASSERT_TRUE( splitter.eos() );