From 3375e1a876e293d8acec655fb97273399ef46091 Mon Sep 17 00:00:00 2001 From: "bbudge@chromium.org" Date: Fri, 15 Jun 2012 22:15:53 +0000 Subject: Revert 142482 - Add untrusted NaCl build for PPAPI proxy. This patch refactors ppapi_shared.gypi and ppapi_proxy.gypi into proper includes, adds ppapi_shared_untrusted and ppapi_proxy_untrusted .gyp files, and integrates them into the nacl_irt build (ppapi/native_client/native_client.gyp). In order to build without link errors, it includes our plugin side initialization of PluginDispatcher, and a PpapiPluginMain definition. When the 'build_ppapi_ipc_proxy_untrusted' gyp flag is set to '1', this will build a working NaCl IRT using the Chrome IPC proxy. BUG=116317 TEST=compiles, runs HelloWorld and GetURL SDK examples. Review URL: https://chromiumcodereview.appspot.com/10546140 TBR=bbudge@chromium.org Review URL: https://chromiumcodereview.appspot.com/10565012 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@142494 0039d316-1c4b-4281-b951-d872f2087c98 --- base/base.gypi | 3 +-- base/base_untrusted.gyp | 4 +++- base/rand_util_nacl.cc | 53 +++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 57 insertions(+), 3 deletions(-) create mode 100644 base/rand_util_nacl.cc (limited to 'base') diff --git a/base/base.gypi b/base/base.gypi index 22aeda7..2f01f53 100644 --- a/base/base.gypi +++ b/base/base.gypi @@ -286,6 +286,7 @@ 'property_bag.h', 'rand_util.cc', 'rand_util.h', + 'rand_util_nacl.cc', 'rand_util_posix.cc', 'rand_util_win.cc', 'safe_strerror_posix.cc', @@ -524,8 +525,6 @@ 'process_posix.cc', 'process_util.cc', 'process_util_posix.cc', - 'rand_util.cc', - 'rand_util_posix.cc', 'scoped_native_library.cc', 'scoped_temp_dir.cc', 'shared_memory_posix.cc', diff --git a/base/base_untrusted.gyp b/base/base_untrusted.gyp index 44baaa1..16aef58 100644 --- a/base/base_untrusted.gyp +++ b/base/base_untrusted.gyp @@ -11,7 +11,7 @@ 'base.gypi', ], 'conditions': [ - ['disable_nacl==0 and disable_nacl_untrusted==0', { + ['disable_nacl_untrusted==0', { 'targets': [ { 'target_name': 'base_untrusted', @@ -32,6 +32,8 @@ }, 'dependencies': [ '<(DEPTH)/native_client/tools.gyp:prep_toolchain', + '<(DEPTH)/native_client/src/untrusted/pthread/pthread.gyp:pthread_lib', + '<(DEPTH)/native_client/src/untrusted/nacl/nacl.gyp:nacl_lib_newlib', ], }, ], diff --git a/base/rand_util_nacl.cc b/base/rand_util_nacl.cc new file mode 100644 index 0000000..718da05 --- /dev/null +++ b/base/rand_util_nacl.cc @@ -0,0 +1,53 @@ +// Copyright (c) 2012 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. + +#include "base/rand_util.h" + +#include "base/lazy_instance.h" +#include "base/logging.h" + +// TODO(bbudge) Replace this with a proper system header file when NaCl +// provides one. +#include "native_client/src/untrusted/irt/irt.h" + +namespace { + +// Create a wrapper class so we can cache the NaCl random number interface. +class URandomInterface { + public: + URandomInterface() { + size_t result = nacl_interface_query(NACL_IRT_RANDOM_v0_1, + &interface_, + sizeof(interface_)); + DCHECK_EQ(result, sizeof(interface_)) << "Can't get random interface."; + } + + uint64 get_random_bytes() const { + size_t nbytes; + uint64 result; + int error = interface_.get_random_bytes(&result, + sizeof(result), + &nbytes); + DCHECK_EQ(error, 0); + DCHECK_EQ(nbytes, sizeof(result)); + return result; + } + + private: + struct nacl_irt_random interface_; +}; + +base::LazyInstance g_urandom_interface = + LAZY_INSTANCE_INITIALIZER; + +} // namespace + +namespace base { + +uint64 RandUint64() { + return g_urandom_interface.Pointer()->get_random_bytes(); +} + +} // namespace base + -- cgit v1.1