summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorsergeyu@chromium.org <sergeyu@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-07-26 22:53:13 +0000
committersergeyu@chromium.org <sergeyu@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-07-26 22:53:13 +0000
commit1968d9778f74daa4056ddc5a18aeac5061d0314b (patch)
tree617c16cdb81229734e92aa908bbbd7a4923088be
parenta24417742faf535b1a616984b03dcf8258b9f818 (diff)
downloadchromium_src-1968d9778f74daa4056ddc5a18aeac5061d0314b.zip
chromium_src-1968d9778f74daa4056ddc5a18aeac5061d0314b.tar.gz
chromium_src-1968d9778f74daa4056ddc5a18aeac5061d0314b.tar.bz2
Enable parts of base_untrusted that are used by remoting client
1. base64, rand_util, threading, time and threads were previosly disabled in base_untrusted. Remoting code depends on these parts of base, so they need to be enabled. 2. Implemented NaCl version of rand_util. 3. Enabled glibc version of base_untrusted BUG=134216 Review URL: https://chromiumcodereview.appspot.com/10795083 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@148641 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--base/DEPS2
-rw-r--r--base/base.gyp14
-rw-r--r--base/base.gypi9
-rw-r--r--base/base_untrusted.gyp2
-rw-r--r--base/os_compat_nacl.cc3
-rw-r--r--base/os_compat_nacl.h2
-rw-r--r--base/rand_util_nacl.cc53
-rw-r--r--base/threading/platform_thread_posix.cc4
-rw-r--r--base/time_posix.cc2
9 files changed, 79 insertions, 12 deletions
diff --git a/base/DEPS b/base/DEPS
index f0aa936..e1545ae 100644
--- a/base/DEPS
+++ b/base/DEPS
@@ -1,6 +1,6 @@
include_rules = [
"+jni",
- "+native_client",
+ "+native_client/src/untrusted/irt/irt.h",
"+third_party/ashmem",
"+third_party/apple_apsl",
"+third_party/libevent",
diff --git a/base/base.gyp b/base/base.gyp
index 907ec1c..bab45b8 100644
--- a/base/base.gyp
+++ b/base/base.gyp
@@ -209,8 +209,6 @@
'third_party/xdg_user_dirs/xdg_user_dir_lookup.cc',
'third_party/xdg_user_dirs/xdg_user_dir_lookup.h',
'auto_reset.h',
- 'base64.cc',
- 'base64.h',
'event_recorder.h',
'event_recorder_stubs.cc',
'event_recorder_win.cc',
@@ -235,13 +233,9 @@
'message_pump_mac.mm',
'metrics/field_trial.cc',
'metrics/field_trial.h',
- 'string16.cc',
- 'string16.h',
'sync_socket.h',
'sync_socket_win.cc',
'sync_socket_posix.cc',
- 'time_mac.cc',
- 'time_posix.cc',
],
},
{
@@ -331,6 +325,10 @@
'win/pe_image.cc',
'win/pe_image.h',
],
+ 'sources!': [
+ # base64.cc depends on modp_b64.
+ 'base64.cc',
+ ],
'include_dirs': [
'..',
],
@@ -832,6 +830,10 @@
'defines': [
'<@(nacl_win64_defines)',
],
+ 'sources!': [
+ # base64.cc depends on modp_b64.
+ 'base64.cc',
+ ],
'configurations': {
'Common_Base': {
'msvs_target_platform': 'x64',
diff --git a/base/base.gypi b/base/base.gypi
index ffc290b..63362f1 100644
--- a/base/base.gypi
+++ b/base/base.gypi
@@ -63,6 +63,8 @@
'base_paths_win.cc',
'base_paths_win.h',
'base_switches.h',
+ 'base64.cc',
+ 'base64.h',
'basictypes.h',
'bind.h',
'bind_helpers.cc',
@@ -303,6 +305,7 @@
'property_bag.h',
'rand_util.cc',
'rand_util.h',
+ 'rand_util_nacl.cc',
'rand_util_posix.cc',
'rand_util_win.cc',
'run_loop.cc',
@@ -338,6 +341,8 @@
'string_util.h',
'string_util_posix.h',
'string_util_win.h',
+ 'string16.cc',
+ 'string16.h',
'stringize_macros.h',
'stringprintf.cc',
'stringprintf.h',
@@ -425,6 +430,8 @@
'threading/worker_pool_win.cc',
'time.cc',
'time.h',
+ 'time_mac.cc',
+ 'time_posix.cc',
'time_win.cc',
'timer.cc',
'timer.h',
@@ -535,7 +542,6 @@
'command_line.cc',
'cpu.cc',
'debug/stack_trace_posix.cc',
- 'environment.cc',
'file_util.cc',
'file_util_posix.cc',
'file_util_proxy.cc',
@@ -547,7 +553,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',
diff --git a/base/base_untrusted.gyp b/base/base_untrusted.gyp
index 44baaa1..a740649 100644
--- a/base/base_untrusted.gyp
+++ b/base/base_untrusted.gyp
@@ -20,7 +20,7 @@
'base_target': 1,
'nacl_untrusted_build': 1,
'nlib_target': 'libbase_untrusted.a',
- 'build_glibc': 0,
+ 'build_glibc': 1,
'build_newlib': 1,
'sources': [
'atomicops_internals_x86_gcc.cc',
diff --git a/base/os_compat_nacl.cc b/base/os_compat_nacl.cc
index d38f9e0..58fe93e 100644
--- a/base/os_compat_nacl.cc
+++ b/base/os_compat_nacl.cc
@@ -7,6 +7,8 @@
#include <stdlib.h>
#include <time.h>
+#if !defined (__GLIBC__)
+
extern "C" {
// Native Client has no timegm().
time_t timegm(struct tm* tm) {
@@ -25,3 +27,4 @@ time_t timegm(struct tm* tm) {
}
} // extern "C"
+#endif // !defined (__GLIBC__)
diff --git a/base/os_compat_nacl.h b/base/os_compat_nacl.h
index 5c4b9a1..13e0e3f 100644
--- a/base/os_compat_nacl.h
+++ b/base/os_compat_nacl.h
@@ -7,8 +7,10 @@
#include <sys/types.h>
+#if !defined (__GLIBC__)
// NaCl has no timegm().
extern "C" time_t timegm(struct tm* const t);
+#endif // !defined (__GLIBC__)
#endif // BASE_OS_COMPAT_NACL_H_
diff --git a/base/rand_util_nacl.cc b/base/rand_util_nacl.cc
new file mode 100644
index 0000000..47450aa
--- /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/basictypes.h"
+#include "base/lazy_instance.h"
+#include "base/logging.h"
+#include "native_client/src/untrusted/irt/irt.h"
+
+namespace {
+
+class NaclRandom {
+ public:
+ NaclRandom() {
+ size_t result = nacl_interface_query(NACL_IRT_RANDOM_v0_1,
+ &random_, sizeof(random_));
+ CHECK_EQ(result, sizeof(random_));
+ }
+
+ ~NaclRandom() {
+ }
+
+ void GetRandomBytes(char* buffer, uint32_t num_bytes) {
+ while (num_bytes > 0) {
+ size_t nread;
+ int error = random_.get_random_bytes(buffer, num_bytes, &nread);
+ CHECK_EQ(error, 0);
+ CHECK_LE(nread, num_bytes);
+ buffer += nread;
+ num_bytes -= nread;
+ }
+ }
+
+ private:
+ nacl_irt_random random_;
+};
+
+base::LazyInstance<NaclRandom>::Leaky g_nacl_random = LAZY_INSTANCE_INITIALIZER;
+
+} // namespace
+
+namespace base {
+
+uint64 RandUint64() {
+ uint64 result;
+ g_nacl_random.Pointer()->GetRandomBytes(
+ reinterpret_cast<char*>(&result), sizeof(result));
+ return result;
+}
+
+} // namespace base
diff --git a/base/threading/platform_thread_posix.cc b/base/threading/platform_thread_posix.cc
index 94a687c..444edc58 100644
--- a/base/threading/platform_thread_posix.cc
+++ b/base/threading/platform_thread_posix.cc
@@ -162,7 +162,9 @@ PlatformThreadId PlatformThread::CurrentId() {
return gettid();
#elif defined(OS_SOLARIS)
return pthread_self();
-#elif defined(OS_NACL)
+#elif defined(OS_NACL) && defined(__GLIBC__)
+ return pthread_self();
+#elif defined(OS_NACL) && !defined(__GLIBC__)
// Pointers are 32-bits in NaCl.
return reinterpret_cast<int32>(pthread_self());
#elif defined(OS_POSIX)
diff --git a/base/time_posix.cc b/base/time_posix.cc
index 5fc2c5d..c74cae5 100644
--- a/base/time_posix.cc
+++ b/base/time_posix.cc
@@ -189,7 +189,7 @@ Time Time::FromExploded(bool is_local, const Exploded& exploded) {
// TimeTicks ------------------------------------------------------------------
// FreeBSD 6 has CLOCK_MONOLITHIC but defines _POSIX_MONOTONIC_CLOCK to -1.
-#if (defined(OS_POSIX) && \
+#if (defined(OS_POSIX) && !defined(OS_NACL) && \
defined(_POSIX_MONOTONIC_CLOCK) && _POSIX_MONOTONIC_CLOCK >= 0) || \
defined(OS_BSD) || defined(OS_ANDROID)