ipc/chromium/src/base/rand_util_posix.cc

Wed, 31 Dec 2014 13:27:57 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 13:27:57 +0100
branch
TOR_BUG_3246
changeset 6
8bccb770b82d
permissions
-rw-r--r--

Ignore runtime configuration files generated during quality assurance.

     1 // Copyright (c) 2008 The Chromium Authors. All rights reserved.
     2 // Use of this source code is governed by a BSD-style license that can be
     3 // found in the LICENSE file.
     5 #include "base/rand_util.h"
     7 #include <fcntl.h>
     8 #include <unistd.h>
    10 #include "base/file_util.h"
    11 #include "base/logging.h"
    13 namespace base {
    15 uint64_t RandUint64() {
    16   uint64_t number;
    18   int urandom_fd = open("/dev/urandom", O_RDONLY);
    19   CHECK(urandom_fd >= 0);
    20   bool success = file_util::ReadFromFD(urandom_fd,
    21                                        reinterpret_cast<char*>(&number),
    22                                        sizeof(number));
    23   CHECK(success);
    24   close(urandom_fd);
    26   return number;
    27 }
    29 }  // namespace base

mercurial