| OLD | NEW |
| 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 Loading... |
| 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 |
| OLD | NEW |