| Index: third_party/protobuf/src/google/protobuf/stubs/common.cc
|
| diff --git a/third_party/protobuf/src/google/protobuf/stubs/common.cc b/third_party/protobuf/src/google/protobuf/stubs/common.cc
|
| index bcd45ec4e21689100fd77f32bb323c19eed8b3ea..54dbafab5dcaca22cc2658a1682b5ef553dff595 100644
|
| --- a/third_party/protobuf/src/google/protobuf/stubs/common.cc
|
| +++ b/third_party/protobuf/src/google/protobuf/stubs/common.cc
|
| @@ -116,8 +116,7 @@ inline void DefaultLogHandler(LogLevel level, const char* filename, int line,
|
| if (level < GOOGLE_PROTOBUF_MIN_LOG_LEVEL) {
|
| return;
|
| }
|
| - static const char* const level_names[] = {"INFO", "WARNING", "ERROR",
|
| - "FATAL"};
|
| + static const char* level_names[] = {"INFO", "WARNING", "ERROR", "FATAL"};
|
|
|
| static const int android_log_levels[] = {
|
| ANDROID_LOG_INFO, // LOG(INFO),
|
| @@ -149,8 +148,7 @@ inline void DefaultLogHandler(LogLevel level, const char* filename, int line,
|
| #else
|
| void DefaultLogHandler(LogLevel level, const char* filename, int line,
|
| const string& message) {
|
| - static const char* const level_names[] = {"INFO", "WARNING", "ERROR",
|
| - "FATAL"};
|
| + static const char* level_names[] = { "INFO", "WARNING", "ERROR", "FATAL" };
|
|
|
| // We use fprintf() instead of cerr because we want this to work at static
|
| // initialization time.
|
| @@ -165,22 +163,22 @@ void NullLogHandler(LogLevel /* level */, const char* /* filename */,
|
| // Nothing.
|
| }
|
|
|
| -extern LogHandler* cr_log_handler_;
|
| -extern int cr_log_silencer_count_;
|
| +static LogHandler* log_handler_ = &DefaultLogHandler;
|
| +static int log_silencer_count_ = 0;
|
|
|
| -extern Mutex* cr_log_silencer_count_mutex_;
|
| -extern ProtobufOnceType cr_log_silencer_count_init_;
|
| +static Mutex* log_silencer_count_mutex_ = NULL;
|
| +GOOGLE_PROTOBUF_DECLARE_ONCE(log_silencer_count_init_);
|
|
|
| void DeleteLogSilencerCount() {
|
| - delete cr_log_silencer_count_mutex_;
|
| - cr_log_silencer_count_mutex_ = NULL;
|
| + delete log_silencer_count_mutex_;
|
| + log_silencer_count_mutex_ = NULL;
|
| }
|
| void InitLogSilencerCount() {
|
| - cr_log_silencer_count_mutex_ = new Mutex;
|
| + log_silencer_count_mutex_ = new Mutex;
|
| OnShutdown(&DeleteLogSilencerCount);
|
| }
|
| void InitLogSilencerCountOnce() {
|
| - GoogleOnceInit(&cr_log_silencer_count_init_, &InitLogSilencerCount);
|
| + GoogleOnceInit(&log_silencer_count_init_, &InitLogSilencerCount);
|
| }
|
|
|
| LogMessage& LogMessage::operator<<(const string& value) {
|
| @@ -248,13 +246,12 @@ void LogMessage::Finish() {
|
|
|
| if (level_ != LOGLEVEL_FATAL) {
|
| InitLogSilencerCountOnce();
|
| - MutexLock lock(cr_log_silencer_count_mutex_);
|
| - suppress = cr_log_silencer_count_ > 0;
|
| + MutexLock lock(log_silencer_count_mutex_);
|
| + suppress = log_silencer_count_ > 0;
|
| }
|
|
|
| if (!suppress) {
|
| - (cr_log_handler_ ? cr_log_handler_ : DefaultLogHandler)(level_, filename_,
|
| - line_, message_);
|
| + log_handler_(level_, filename_, line_, message_);
|
| }
|
|
|
| if (level_ == LOGLEVEL_FATAL) {
|
| @@ -273,29 +270,28 @@ void LogFinisher::operator=(LogMessage& other) {
|
| } // namespace internal
|
|
|
| LogHandler* SetLogHandler(LogHandler* new_func) {
|
| - LogHandler* old = internal::cr_log_handler_ ? internal::cr_log_handler_
|
| - : internal::DefaultLogHandler;
|
| + LogHandler* old = internal::log_handler_;
|
| if (old == &internal::NullLogHandler) {
|
| old = NULL;
|
| }
|
| if (new_func == NULL) {
|
| - internal::cr_log_handler_ = &internal::NullLogHandler;
|
| + internal::log_handler_ = &internal::NullLogHandler;
|
| } else {
|
| - internal::cr_log_handler_ = new_func;
|
| + internal::log_handler_ = new_func;
|
| }
|
| return old;
|
| }
|
|
|
| LogSilencer::LogSilencer() {
|
| internal::InitLogSilencerCountOnce();
|
| - MutexLock lock(internal::cr_log_silencer_count_mutex_);
|
| - ++internal::cr_log_silencer_count_;
|
| + MutexLock lock(internal::log_silencer_count_mutex_);
|
| + ++internal::log_silencer_count_;
|
| };
|
|
|
| LogSilencer::~LogSilencer() {
|
| internal::InitLogSilencerCountOnce();
|
| - MutexLock lock(internal::cr_log_silencer_count_mutex_);
|
| - --internal::cr_log_silencer_count_;
|
| + MutexLock lock(internal::log_silencer_count_mutex_);
|
| + --internal::log_silencer_count_;
|
| };
|
|
|
| // ===================================================================
|
| @@ -411,23 +407,23 @@ uint32 ghtonl(uint32 x) {
|
| namespace internal {
|
|
|
| typedef void OnShutdownFunc();
|
| -extern vector<void (*)()>* cr_shutdown_functions;
|
| -extern Mutex* cr_shutdown_functions_mutex;
|
| -extern ProtobufOnceType cr_shutdown_functions_init;
|
| +vector<void (*)()>* shutdown_functions = NULL;
|
| +Mutex* shutdown_functions_mutex = NULL;
|
| +GOOGLE_PROTOBUF_DECLARE_ONCE(shutdown_functions_init);
|
|
|
| void InitShutdownFunctions() {
|
| - cr_shutdown_functions = new vector<void (*)()>;
|
| - cr_shutdown_functions_mutex = new Mutex;
|
| + shutdown_functions = new vector<void (*)()>;
|
| + shutdown_functions_mutex = new Mutex;
|
| }
|
|
|
| inline void InitShutdownFunctionsOnce() {
|
| - GoogleOnceInit(&cr_shutdown_functions_init, &InitShutdownFunctions);
|
| + GoogleOnceInit(&shutdown_functions_init, &InitShutdownFunctions);
|
| }
|
|
|
| void OnShutdown(void (*func)()) {
|
| InitShutdownFunctionsOnce();
|
| - MutexLock lock(cr_shutdown_functions_mutex);
|
| - cr_shutdown_functions->push_back(func);
|
| + MutexLock lock(shutdown_functions_mutex);
|
| + shutdown_functions->push_back(func);
|
| }
|
|
|
| } // namespace internal
|
| @@ -435,20 +431,20 @@ void OnShutdown(void (*func)()) {
|
| void ShutdownProtobufLibrary() {
|
| internal::InitShutdownFunctionsOnce();
|
|
|
| - // We don't need to lock cr_shutdown_functions_mutex because it's up to the
|
| + // We don't need to lock shutdown_functions_mutex because it's up to the
|
| // caller to make sure that no one is using the library before this is
|
| // called.
|
|
|
| // Make it safe to call this multiple times.
|
| - if (internal::cr_shutdown_functions == NULL) return;
|
| + if (internal::shutdown_functions == NULL) return;
|
|
|
| - for (int i = 0; i < internal::cr_shutdown_functions->size(); i++) {
|
| - internal::cr_shutdown_functions->at(i)();
|
| + for (int i = 0; i < internal::shutdown_functions->size(); i++) {
|
| + internal::shutdown_functions->at(i)();
|
| }
|
| - delete internal::cr_shutdown_functions;
|
| - internal::cr_shutdown_functions = NULL;
|
| - delete internal::cr_shutdown_functions_mutex;
|
| - internal::cr_shutdown_functions_mutex = NULL;
|
| + delete internal::shutdown_functions;
|
| + internal::shutdown_functions = NULL;
|
| + delete internal::shutdown_functions_mutex;
|
| + internal::shutdown_functions_mutex = NULL;
|
| }
|
|
|
| #if PROTOBUF_USE_EXCEPTIONS
|
|
|