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

Side by Side Diff: base/rand_util_posix.cc

Issue 4079: Porting refactoring changes:... (Closed) Base URL: http://src.chromium.org/svn/trunk/src/
Patch Set: '' Created 12 years, 2 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
OLDNEW
(Empty)
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.
4
5 #include "base/rand_util.h"
6
7 #include <fcntl.h>
8 #include <sys/stat.h>
9 #include <unistd.h>
10
11 #include "base/logging.h"
12
13 namespace base {
14
15 uint64 RandUInt64() {
16 uint64 number;
17
18 int urandom_fd = open("/dev/urandom", O_RDONLY);
19 CHECK(urandom_fd >= 0);
20 ssize_t bytes_read = read(urandom_fd, &number, sizeof(number));
21 CHECK(bytes_read == sizeof(number));
22 close(urandom_fd);
23
24 return number;
25 }
26
27 } // namespace base
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698