Commit 1968d977 authored by sergeyu@chromium.org's avatar sergeyu@chromium.org

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
parent a2441774
include_rules = [ include_rules = [
"+jni", "+jni",
"+native_client", "+native_client/src/untrusted/irt/irt.h",
"+third_party/ashmem", "+third_party/ashmem",
"+third_party/apple_apsl", "+third_party/apple_apsl",
"+third_party/libevent", "+third_party/libevent",
......
...@@ -209,8 +209,6 @@ ...@@ -209,8 +209,6 @@
'third_party/xdg_user_dirs/xdg_user_dir_lookup.cc', 'third_party/xdg_user_dirs/xdg_user_dir_lookup.cc',
'third_party/xdg_user_dirs/xdg_user_dir_lookup.h', 'third_party/xdg_user_dirs/xdg_user_dir_lookup.h',
'auto_reset.h', 'auto_reset.h',
'base64.cc',
'base64.h',
'event_recorder.h', 'event_recorder.h',
'event_recorder_stubs.cc', 'event_recorder_stubs.cc',
'event_recorder_win.cc', 'event_recorder_win.cc',
...@@ -235,13 +233,9 @@ ...@@ -235,13 +233,9 @@
'message_pump_mac.mm', 'message_pump_mac.mm',
'metrics/field_trial.cc', 'metrics/field_trial.cc',
'metrics/field_trial.h', 'metrics/field_trial.h',
'string16.cc',
'string16.h',
'sync_socket.h', 'sync_socket.h',
'sync_socket_win.cc', 'sync_socket_win.cc',
'sync_socket_posix.cc', 'sync_socket_posix.cc',
'time_mac.cc',
'time_posix.cc',
], ],
}, },
{ {
...@@ -331,6 +325,10 @@ ...@@ -331,6 +325,10 @@
'win/pe_image.cc', 'win/pe_image.cc',
'win/pe_image.h', 'win/pe_image.h',
], ],
'sources!': [
# base64.cc depends on modp_b64.
'base64.cc',
],
'include_dirs': [ 'include_dirs': [
'..', '..',
], ],
...@@ -832,6 +830,10 @@ ...@@ -832,6 +830,10 @@
'defines': [ 'defines': [
'<@(nacl_win64_defines)', '<@(nacl_win64_defines)',
], ],
'sources!': [
# base64.cc depends on modp_b64.
'base64.cc',
],
'configurations': { 'configurations': {
'Common_Base': { 'Common_Base': {
'msvs_target_platform': 'x64', 'msvs_target_platform': 'x64',
......
...@@ -63,6 +63,8 @@ ...@@ -63,6 +63,8 @@
'base_paths_win.cc', 'base_paths_win.cc',
'base_paths_win.h', 'base_paths_win.h',
'base_switches.h', 'base_switches.h',
'base64.cc',
'base64.h',
'basictypes.h', 'basictypes.h',
'bind.h', 'bind.h',
'bind_helpers.cc', 'bind_helpers.cc',
...@@ -303,6 +305,7 @@ ...@@ -303,6 +305,7 @@
'property_bag.h', 'property_bag.h',
'rand_util.cc', 'rand_util.cc',
'rand_util.h', 'rand_util.h',
'rand_util_nacl.cc',
'rand_util_posix.cc', 'rand_util_posix.cc',
'rand_util_win.cc', 'rand_util_win.cc',
'run_loop.cc', 'run_loop.cc',
...@@ -338,6 +341,8 @@ ...@@ -338,6 +341,8 @@
'string_util.h', 'string_util.h',
'string_util_posix.h', 'string_util_posix.h',
'string_util_win.h', 'string_util_win.h',
'string16.cc',
'string16.h',
'stringize_macros.h', 'stringize_macros.h',
'stringprintf.cc', 'stringprintf.cc',
'stringprintf.h', 'stringprintf.h',
...@@ -425,6 +430,8 @@ ...@@ -425,6 +430,8 @@
'threading/worker_pool_win.cc', 'threading/worker_pool_win.cc',
'time.cc', 'time.cc',
'time.h', 'time.h',
'time_mac.cc',
'time_posix.cc',
'time_win.cc', 'time_win.cc',
'timer.cc', 'timer.cc',
'timer.h', 'timer.h',
...@@ -535,7 +542,6 @@ ...@@ -535,7 +542,6 @@
'command_line.cc', 'command_line.cc',
'cpu.cc', 'cpu.cc',
'debug/stack_trace_posix.cc', 'debug/stack_trace_posix.cc',
'environment.cc',
'file_util.cc', 'file_util.cc',
'file_util_posix.cc', 'file_util_posix.cc',
'file_util_proxy.cc', 'file_util_proxy.cc',
...@@ -547,7 +553,6 @@ ...@@ -547,7 +553,6 @@
'process_posix.cc', 'process_posix.cc',
'process_util.cc', 'process_util.cc',
'process_util_posix.cc', 'process_util_posix.cc',
'rand_util.cc',
'rand_util_posix.cc', 'rand_util_posix.cc',
'scoped_native_library.cc', 'scoped_native_library.cc',
'scoped_temp_dir.cc', 'scoped_temp_dir.cc',
......
...@@ -20,7 +20,7 @@ ...@@ -20,7 +20,7 @@
'base_target': 1, 'base_target': 1,
'nacl_untrusted_build': 1, 'nacl_untrusted_build': 1,
'nlib_target': 'libbase_untrusted.a', 'nlib_target': 'libbase_untrusted.a',
'build_glibc': 0, 'build_glibc': 1,
'build_newlib': 1, 'build_newlib': 1,
'sources': [ 'sources': [
'atomicops_internals_x86_gcc.cc', 'atomicops_internals_x86_gcc.cc',
......
...@@ -7,6 +7,8 @@ ...@@ -7,6 +7,8 @@
#include <stdlib.h> #include <stdlib.h>
#include <time.h> #include <time.h>
#if !defined (__GLIBC__)
extern "C" { extern "C" {
// Native Client has no timegm(). // Native Client has no timegm().
time_t timegm(struct tm* tm) { time_t timegm(struct tm* tm) {
...@@ -25,3 +27,4 @@ time_t timegm(struct tm* tm) { ...@@ -25,3 +27,4 @@ time_t timegm(struct tm* tm) {
} }
} // extern "C" } // extern "C"
#endif // !defined (__GLIBC__)
...@@ -7,8 +7,10 @@ ...@@ -7,8 +7,10 @@
#include <sys/types.h> #include <sys/types.h>
#if !defined (__GLIBC__)
// NaCl has no timegm(). // NaCl has no timegm().
extern "C" time_t timegm(struct tm* const t); extern "C" time_t timegm(struct tm* const t);
#endif // !defined (__GLIBC__)
#endif // BASE_OS_COMPAT_NACL_H_ #endif // BASE_OS_COMPAT_NACL_H_
// 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
...@@ -162,7 +162,9 @@ PlatformThreadId PlatformThread::CurrentId() { ...@@ -162,7 +162,9 @@ PlatformThreadId PlatformThread::CurrentId() {
return gettid(); return gettid();
#elif defined(OS_SOLARIS) #elif defined(OS_SOLARIS)
return pthread_self(); 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. // Pointers are 32-bits in NaCl.
return reinterpret_cast<int32>(pthread_self()); return reinterpret_cast<int32>(pthread_self());
#elif defined(OS_POSIX) #elif defined(OS_POSIX)
......
...@@ -189,7 +189,7 @@ Time Time::FromExploded(bool is_local, const Exploded& exploded) { ...@@ -189,7 +189,7 @@ Time Time::FromExploded(bool is_local, const Exploded& exploded) {
// TimeTicks ------------------------------------------------------------------ // TimeTicks ------------------------------------------------------------------
// FreeBSD 6 has CLOCK_MONOLITHIC but defines _POSIX_MONOTONIC_CLOCK to -1. // 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(_POSIX_MONOTONIC_CLOCK) && _POSIX_MONOTONIC_CLOCK >= 0) || \
defined(OS_BSD) || defined(OS_ANDROID) defined(OS_BSD) || defined(OS_ANDROID)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment