Commit 380d8329 authored by bbudge@chromium.org's avatar bbudge@chromium.org

Make base::Logging compile with the NaCl toolchain.

BUG=none
TEST=none

Review URL: http://codereview.chromium.org/9474034

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@124025 0039d316-1c4b-4281-b951-d872f2087c98
parent 3aa8b49d
// Copyright (c) 2011 The Chromium Authors. All rights reserved.
// 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.
......@@ -17,7 +17,7 @@
#include <string>
#include <vector>
#if !defined(OS_ANDROID)
#if !defined(OS_ANDROID) && !defined(OS_NACL)
#include <execinfo.h>
#endif
......
......@@ -335,7 +335,11 @@ TraceLog::TraceLog()
ANNOTATE_BENIGN_RACE(&g_category_enabled[i],
"trace_event category enabled");
}
#if defined(OS_NACL) // NaCl shouldn't expose the process id.
SetProcessID(0);
#else
SetProcessID(static_cast<int>(base::GetCurrentProcId()));
#endif
}
TraceLog::~TraceLog() {
......
......@@ -347,9 +347,10 @@ bool BaseInitLoggingImpl(const PathChar* new_log_file,
LogLockingState lock_log,
OldFileDeletionState delete_old,
DcheckState dcheck_state) {
CommandLine* command_line = CommandLine::ForCurrentProcess();
g_dcheck_state = dcheck_state;
// TODO(bbudge) Hook this up to NaCl logging.
#if !defined(OS_NACL)
CommandLine* command_line = CommandLine::ForCurrentProcess();
// Don't bother initializing g_vlog_info unless we use one of the
// vlog switches.
if (command_line->HasSwitch(switches::kV) ||
......@@ -391,6 +392,9 @@ bool BaseInitLoggingImpl(const PathChar* new_log_file,
DeleteFilePath(*log_file_name);
return InitializeLogFileHandle();
#else
return true;
#endif // !defined(OS_NACL)
}
void SetMinLogLevel(int level) {
......@@ -552,7 +556,7 @@ LogMessage::LogMessage(const char* file, int line, LogSeverity severity,
LogMessage::~LogMessage() {
// TODO(port): enable stacktrace generation on LOG_FATAL once backtrace are
// working in Android.
#if !defined(NDEBUG) && !defined(OS_ANDROID)
#if !defined(NDEBUG) && !defined(OS_ANDROID) && !defined(OS_NACL)
if (severity_ == LOG_FATAL) {
// Include a stack trace on a fatal.
base::debug::StackTrace trace;
......
// 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/rand_util_c.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<URandomInterface> g_urandom_interface =
LAZY_INSTANCE_INITIALIZER;
} // namespace
namespace base {
uint64 RandUint64() {
return g_urandom_interface.Pointer()->get_random_bytes();
}
} // namespace base
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