Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(494)

Side by Side Diff: src/base/utils/random-number-generator.cc

Issue 358363002: Move platform abstraction to base library (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: updates Created 6 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright 2013 the V8 project authors. All rights reserved. 1 // Copyright 2013 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "src/utils/random-number-generator.h" 5 #include "src/base/utils/random-number-generator.h"
6 6
7 #include <stdio.h> 7 #include <stdio.h>
8 #include <stdlib.h> 8 #include <stdlib.h>
9 9
10 #include <new> 10 #include <new>
11 11
12 #include "src/base/macros.h" 12 #include "src/base/macros.h"
13 #include "src/platform/mutex.h" 13 #include "src/base/platform/mutex.h"
14 #include "src/platform/time.h" 14 #include "src/base/platform/time.h"
15 15
16 namespace v8 { 16 namespace v8 {
17 namespace internal { 17 namespace base {
18 18
19 static LazyMutex entropy_mutex = LAZY_MUTEX_INITIALIZER; 19 static LazyMutex entropy_mutex = LAZY_MUTEX_INITIALIZER;
20 static RandomNumberGenerator::EntropySource entropy_source = NULL; 20 static RandomNumberGenerator::EntropySource entropy_source = NULL;
21 21
22 22
23 // static 23 // static
24 void RandomNumberGenerator::SetEntropySource(EntropySource source) { 24 void RandomNumberGenerator::SetEntropySource(EntropySource source) {
25 LockGuard<Mutex> lock_guard(entropy_mutex.Pointer()); 25 LockGuard<Mutex> lock_guard(entropy_mutex.Pointer());
26 entropy_source = source; 26 entropy_source = source;
27 } 27 }
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
121 int64_t seed = static_cast<int64_t>((product + kAddend) & kMask); 121 int64_t seed = static_cast<int64_t>((product + kAddend) & kMask);
122 seed_ = seed; 122 seed_ = seed;
123 return static_cast<int>(seed >> (48 - bits)); 123 return static_cast<int>(seed >> (48 - bits));
124 } 124 }
125 125
126 126
127 void RandomNumberGenerator::SetSeed(int64_t seed) { 127 void RandomNumberGenerator::SetSeed(int64_t seed) {
128 seed_ = (seed ^ kMultiplier) & kMask; 128 seed_ = (seed ^ kMultiplier) & kMask;
129 } 129 }
130 130
131 } } // namespace v8::internal 131 } } // namespace v8::base
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698