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

Side by Side Diff: base/rand_util.cc

Issue 6410105: run iwyu on base! Base URL: svn://svn.chromium.org/chrome/trunk/src/base
Patch Set: Created 9 years, 10 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
« no previous file with comments | « base/process_util_posix.cc ('k') | base/rand_util_posix.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 The Chromium 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 "base/rand_util.h" 5 #include <architecture/i386/math.h>
6
7 #include <math.h>
8
9 #include <limits> 6 #include <limits>
10 7
11 #include "base/basictypes.h" 8 #include "base/basictypes.h"
12 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/port.h"
11 #include "base/rand_util.h"
13 12
14 namespace base { 13 namespace base {
15 14
16 int RandInt(int min, int max) { 15 int RandInt(int min, int max) {
17 DCHECK(min <= max); 16 DCHECK(min <= max);
18 17
19 uint64 range = static_cast<uint64>(max) - min + 1; 18 uint64 range = static_cast<uint64>(max) - min + 1;
20 int result = min + static_cast<int>(base::RandGenerator(range)); 19 int result = min + static_cast<int>(base::RandGenerator(range));
21 DCHECK(result >= min && result <= max); 20 DCHECK(result >= min && result <= max);
22 return result; 21 return result;
(...skipping 12 matching lines...) Expand all
35 DCHECK(result >= 0.0 && result < 1.0); 34 DCHECK(result >= 0.0 && result < 1.0);
36 return result; 35 return result;
37 } 36 }
38 37
39 uint64 RandGenerator(uint64 max) { 38 uint64 RandGenerator(uint64 max) {
40 DCHECK(max > 0); 39 DCHECK(max > 0);
41 return base::RandUint64() % max; 40 return base::RandUint64() % max;
42 } 41 }
43 42
44 } // namespace base 43 } // namespace base
OLDNEW
« no previous file with comments | « base/process_util_posix.cc ('k') | base/rand_util_posix.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698