Use multiline attribute to check for IA2_STATE_MULTILINE.
[chromium-blink-merge.git] / components / nacl / loader / nonsfi / irt_random.cc
blob273bf08739c6f0ec6585f2317ae5aa30561a1de4
1 // Copyright 2014 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 <errno.h>
6 #include <unistd.h>
8 #include "base/logging.h"
9 #include "components/nacl/loader/nonsfi/irt_interfaces.h"
10 #include "components/nacl/loader/nonsfi/irt_util.h"
12 namespace nacl {
13 namespace nonsfi {
14 namespace {
16 // FD for urandom.
17 int secure_random_fd = -1;
19 int IrtGetRandomBytes(void* buf, size_t count, size_t* nread) {
20 DCHECK_NE(secure_random_fd, -1);
21 return CheckErrorWithResult(read(secure_random_fd, buf, count),
22 nread);
25 } // namespace
27 const nacl_irt_random kIrtRandom = {
28 IrtGetRandomBytes
31 void SetUrandomFd(int fd) {
32 DCHECK_EQ(secure_random_fd, -1);
33 secure_random_fd = fd;
36 } // namespace nonsfi
37 } // namespace nacl