ipc/chromium/src/base/rand_util_win.cc

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/ipc/chromium/src/base/rand_util_win.cc	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,30 @@
     1.4 +// Copyright (c) 2008 The Chromium Authors. All rights reserved.
     1.5 +// Use of this source code is governed by a BSD-style license that can be
     1.6 +// found in the LICENSE file.
     1.7 +
     1.8 +#include "base/rand_util.h"
     1.9 +
    1.10 +#include <stdlib.h>
    1.11 +
    1.12 +#include "base/basictypes.h"
    1.13 +#include "base/logging.h"
    1.14 +
    1.15 +namespace {
    1.16 +
    1.17 +uint32_t RandUint32() {
    1.18 +  uint32_t number;
    1.19 +  CHECK(rand_s(&number) == 0);
    1.20 +  return number;
    1.21 +}
    1.22 +
    1.23 +}  // namespace
    1.24 +
    1.25 +namespace base {
    1.26 +
    1.27 +uint64_t RandUint64() {
    1.28 +  uint32_t first_half = RandUint32();
    1.29 +  uint32_t second_half = RandUint32();
    1.30 +  return (static_cast<uint64_t>(first_half) << 32) + second_half;
    1.31 +}
    1.32 +
    1.33 +}  // namespace base

mercurial