michael@0: // Copyright (c) 2008 The Chromium Authors. All rights reserved. michael@0: // Use of this source code is governed by a BSD-style license that can be michael@0: // found in the LICENSE file. michael@0: michael@0: #include "base/rand_util.h" michael@0: michael@0: #include michael@0: michael@0: #include "base/basictypes.h" michael@0: #include "base/logging.h" michael@0: michael@0: namespace { michael@0: michael@0: uint32_t RandUint32() { michael@0: uint32_t number; michael@0: CHECK(rand_s(&number) == 0); michael@0: return number; michael@0: } michael@0: michael@0: } // namespace michael@0: michael@0: namespace base { michael@0: michael@0: uint64_t RandUint64() { michael@0: uint32_t first_half = RandUint32(); michael@0: uint32_t second_half = RandUint32(); michael@0: return (static_cast(first_half) << 32) + second_half; michael@0: } michael@0: michael@0: } // namespace base