diff options
Diffstat (limited to 'base')
-rw-r--r-- | base/rand_util_c.h | 20 | ||||
-rw-r--r-- | base/rand_util_posix.cc | 5 |
2 files changed, 25 insertions, 0 deletions
diff --git a/base/rand_util_c.h b/base/rand_util_c.h new file mode 100644 index 0000000..5a0bf73 --- /dev/null +++ b/base/rand_util_c.h @@ -0,0 +1,20 @@ +// Copyright (c) 2010 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef BASE_RAND_UTIL_C_H_ +#define BASE_RAND_UTIL_C_H_ + +#ifdef __cplusplus +extern "C" { +#endif + +// Returns an FD for /dev/urandom, possibly pre-opened before sandboxing +// was switched on. This is a C function so that Native Client can use it. +int GetUrandomFD(void); + +#ifdef __cplusplus +} +#endif + +#endif /* BASE_RAND_UTIL_C_H_ */ diff --git a/base/rand_util_posix.cc b/base/rand_util_posix.cc index c65551d..43dfd1e 100644 --- a/base/rand_util_posix.cc +++ b/base/rand_util_posix.cc @@ -3,6 +3,7 @@ // found in the LICENSE file. #include "base/rand_util.h" +#include "base/rand_util_c.h" #include <errno.h> #include <fcntl.h> @@ -54,3 +55,7 @@ uint64 RandUint64() { } } // namespace base + +int GetUrandomFD(void) { + return g_urandom_fd.Pointer()->fd(); +} |