export OS_* defines (fixes #715)
This commit is contained in:
parent
2412db3158
commit
f7407d4d27
13
.gitignore
vendored
13
.gitignore
vendored
@ -1,12 +1,3 @@
|
|||||||
/*.cmake
|
*.orig
|
||||||
/*.filters
|
/build*/
|
||||||
/*.sln
|
|
||||||
/*.vcxproj
|
|
||||||
autom4te.cache
|
|
||||||
bazel-*
|
bazel-*
|
||||||
CMakeCache.txt
|
|
||||||
CMakeFiles/
|
|
||||||
config.h
|
|
||||||
glog-*.tar.gz
|
|
||||||
packages/debian-*
|
|
||||||
packages/rpm-unknown
|
|
||||||
|
|||||||
@ -545,6 +545,7 @@ set (GLOG_PUBLIC_H
|
|||||||
${CMAKE_CURRENT_BINARY_DIR}/glog/stl_logging.h
|
${CMAKE_CURRENT_BINARY_DIR}/glog/stl_logging.h
|
||||||
${CMAKE_CURRENT_BINARY_DIR}/glog/vlog_is_on.h
|
${CMAKE_CURRENT_BINARY_DIR}/glog/vlog_is_on.h
|
||||||
src/glog/log_severity.h
|
src/glog/log_severity.h
|
||||||
|
src/glog/platform.h
|
||||||
)
|
)
|
||||||
|
|
||||||
set (GLOG_SRCS
|
set (GLOG_SRCS
|
||||||
|
|||||||
@ -140,6 +140,7 @@ def glog_library(namespace = "google", with_gflags = 1, **kwargs):
|
|||||||
}),
|
}),
|
||||||
hdrs = [
|
hdrs = [
|
||||||
"src/glog/log_severity.h",
|
"src/glog/log_severity.h",
|
||||||
|
"src/glog/platform.h",
|
||||||
":logging_h",
|
":logging_h",
|
||||||
":raw_logging_h",
|
":raw_logging_h",
|
||||||
":stl_logging_h",
|
":stl_logging_h",
|
||||||
@ -149,7 +150,10 @@ def glog_library(namespace = "google", with_gflags = 1, **kwargs):
|
|||||||
defines = select({
|
defines = select({
|
||||||
# GOOGLE_GLOG_DLL_DECL is normally set by export.h, but that's not
|
# GOOGLE_GLOG_DLL_DECL is normally set by export.h, but that's not
|
||||||
# generated for Bazel.
|
# generated for Bazel.
|
||||||
"@bazel_tools//src/conditions:windows": ["GOOGLE_GLOG_DLL_DECL=__declspec(dllexport)"],
|
"@bazel_tools//src/conditions:windows": [
|
||||||
|
"GOOGLE_GLOG_DLL_DECL=__declspec(dllexport)",
|
||||||
|
"GLOG_NO_ABBREVIATED_SEVERITIES",
|
||||||
|
],
|
||||||
"//conditions:default": [],
|
"//conditions:default": [],
|
||||||
}),
|
}),
|
||||||
copts =
|
copts =
|
||||||
|
|||||||
@ -59,7 +59,7 @@
|
|||||||
|
|
||||||
#else
|
#else
|
||||||
|
|
||||||
#include "glog/logging.h"
|
#include <glog/logging.h>
|
||||||
|
|
||||||
#define DECLARE_VARIABLE(type, shorttype, name, tn) \
|
#define DECLARE_VARIABLE(type, shorttype, name, tn) \
|
||||||
namespace fL##shorttype { \
|
namespace fL##shorttype { \
|
||||||
|
|||||||
@ -39,13 +39,13 @@
|
|||||||
#include "demangle.h"
|
#include "demangle.h"
|
||||||
#include "utilities.h"
|
#include "utilities.h"
|
||||||
|
|
||||||
#if defined(OS_WINDOWS)
|
#if defined(GLOG_OS_WINDOWS)
|
||||||
#include <dbghelp.h>
|
#include <dbghelp.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
_START_GOOGLE_NAMESPACE_
|
_START_GOOGLE_NAMESPACE_
|
||||||
|
|
||||||
#if !defined(OS_WINDOWS)
|
#if !defined(GLOG_OS_WINDOWS)
|
||||||
typedef struct {
|
typedef struct {
|
||||||
const char *abbrev;
|
const char *abbrev;
|
||||||
const char *real_name;
|
const char *real_name;
|
||||||
@ -1324,7 +1324,7 @@ static bool ParseTopLevelMangledName(State *state) {
|
|||||||
|
|
||||||
// The demangler entry point.
|
// The demangler entry point.
|
||||||
bool Demangle(const char *mangled, char *out, size_t out_size) {
|
bool Demangle(const char *mangled, char *out, size_t out_size) {
|
||||||
#if defined(OS_WINDOWS)
|
#if defined(GLOG_OS_WINDOWS)
|
||||||
// When built with incremental linking, the Windows debugger
|
// When built with incremental linking, the Windows debugger
|
||||||
// library provides a more complicated `Symbol->Name` with the
|
// library provides a more complicated `Symbol->Name` with the
|
||||||
// Incremental Linking Table offset, which looks like
|
// Incremental Linking Table offset, which looks like
|
||||||
|
|||||||
@ -71,7 +71,7 @@
|
|||||||
#define BASE_DEMANGLE_H_
|
#define BASE_DEMANGLE_H_
|
||||||
|
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
#include "glog/logging.h"
|
#include <glog/logging.h>
|
||||||
|
|
||||||
_START_GOOGLE_NAMESPACE_
|
_START_GOOGLE_NAMESPACE_
|
||||||
|
|
||||||
|
|||||||
@ -36,7 +36,7 @@
|
|||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <fstream>
|
#include <fstream>
|
||||||
#include <string>
|
#include <string>
|
||||||
#include "glog/logging.h"
|
#include <glog/logging.h>
|
||||||
#include "demangle.h"
|
#include "demangle.h"
|
||||||
#include "googletest.h"
|
#include "googletest.h"
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
@ -62,7 +62,7 @@ static const char *DemangleIt(const char * const mangled) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#if defined(OS_WINDOWS)
|
#if defined(GLOG_OS_WINDOWS)
|
||||||
|
|
||||||
TEST(Demangle, Windows) {
|
TEST(Demangle, Windows) {
|
||||||
EXPECT_STREQ(
|
EXPECT_STREQ(
|
||||||
|
|||||||
@ -63,8 +63,10 @@
|
|||||||
#define GLOG_MSVC_POP_WARNING()
|
#define GLOG_MSVC_POP_WARNING()
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#include <glog/platform.h>
|
||||||
|
|
||||||
#if @ac_cv_have_glog_export@
|
#if @ac_cv_have_glog_export@
|
||||||
#include "glog/export.h"
|
#include <glog/export.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Annoying stuff for windows -- makes sure clients can import these functions
|
// Annoying stuff for windows -- makes sure clients can import these functions
|
||||||
@ -106,7 +108,7 @@
|
|||||||
|
|
||||||
#if @ac_cv_cxx11_atomic@ && __cplusplus >= 201103L
|
#if @ac_cv_cxx11_atomic@ && __cplusplus >= 201103L
|
||||||
#include <atomic>
|
#include <atomic>
|
||||||
#elif defined(OS_WINDOWS)
|
#elif defined(GLOG_OS_WINDOWS)
|
||||||
#include <Windows.h>
|
#include <Windows.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -586,8 +588,8 @@ DECLARE_bool(log_utc_time);
|
|||||||
@ac_google_start_namespace@
|
@ac_google_start_namespace@
|
||||||
|
|
||||||
// They need the definitions of integer types.
|
// They need the definitions of integer types.
|
||||||
#include "glog/log_severity.h"
|
#include <glog/log_severity.h>
|
||||||
#include "glog/vlog_is_on.h"
|
#include <glog/vlog_is_on.h>
|
||||||
|
|
||||||
// Initialize google's logging library. You will see the program name
|
// Initialize google's logging library. You will see the program name
|
||||||
// specified by argv0 in log outputs.
|
// specified by argv0 in log outputs.
|
||||||
@ -1055,7 +1057,7 @@ namespace google {
|
|||||||
LOG_PREVIOUS_TIME_RAW.store(std::chrono::duration_cast<std::chrono::nanoseconds>(LOG_CURRENT_TIME).count(), std::memory_order_relaxed); \
|
LOG_PREVIOUS_TIME_RAW.store(std::chrono::duration_cast<std::chrono::nanoseconds>(LOG_CURRENT_TIME).count(), std::memory_order_relaxed); \
|
||||||
if (LOG_TIME_DELTA > LOG_TIME_PERIOD) @ac_google_namespace@::LogMessage( \
|
if (LOG_TIME_DELTA > LOG_TIME_PERIOD) @ac_google_namespace@::LogMessage( \
|
||||||
__FILE__, __LINE__, @ac_google_namespace@::GLOG_ ## severity).stream()
|
__FILE__, __LINE__, @ac_google_namespace@::GLOG_ ## severity).stream()
|
||||||
#elif defined(OS_WINDOWS)
|
#elif defined(GLOG_OS_WINDOWS)
|
||||||
#define SOME_KIND_OF_LOG_EVERY_T(severity, seconds) \
|
#define SOME_KIND_OF_LOG_EVERY_T(severity, seconds) \
|
||||||
GLOG_CONSTEXPR LONGLONG LOG_TIME_PERIOD = (seconds) * LONGLONG(1000000000); \
|
GLOG_CONSTEXPR LONGLONG LOG_TIME_PERIOD = (seconds) * LONGLONG(1000000000); \
|
||||||
static LARGE_INTEGER LOG_PREVIOUS_TIME; \
|
static LARGE_INTEGER LOG_PREVIOUS_TIME; \
|
||||||
@ -1131,7 +1133,7 @@ namespace google {
|
|||||||
__FILE__, __LINE__, @ac_google_namespace@::GLOG_ ## severity, LOG_OCCURRENCES, \
|
__FILE__, __LINE__, @ac_google_namespace@::GLOG_ ## severity, LOG_OCCURRENCES, \
|
||||||
&what_to_do).stream()
|
&what_to_do).stream()
|
||||||
|
|
||||||
#elif defined(OS_WINDOWS)
|
#elif defined(GLOG_OS_WINDOWS)
|
||||||
|
|
||||||
#define SOME_KIND_OF_LOG_EVERY_N(severity, n, what_to_do) \
|
#define SOME_KIND_OF_LOG_EVERY_N(severity, n, what_to_do) \
|
||||||
static volatile unsigned LOG_OCCURRENCES = 0; \
|
static volatile unsigned LOG_OCCURRENCES = 0; \
|
||||||
|
|||||||
58
src/glog/platform.h
Normal file
58
src/glog/platform.h
Normal file
@ -0,0 +1,58 @@
|
|||||||
|
// Copyright (c) 2008, Google Inc.
|
||||||
|
// All rights reserved.
|
||||||
|
//
|
||||||
|
// Redistribution and use in source and binary forms, with or without
|
||||||
|
// modification, are permitted provided that the following conditions are
|
||||||
|
// met:
|
||||||
|
//
|
||||||
|
// * Redistributions of source code must retain the above copyright
|
||||||
|
// notice, this list of conditions and the following disclaimer.
|
||||||
|
// * Redistributions in binary form must reproduce the above
|
||||||
|
// copyright notice, this list of conditions and the following disclaimer
|
||||||
|
// in the documentation and/or other materials provided with the
|
||||||
|
// distribution.
|
||||||
|
// * Neither the name of Google Inc. nor the names of its
|
||||||
|
// contributors may be used to endorse or promote products derived from
|
||||||
|
// this software without specific prior written permission.
|
||||||
|
//
|
||||||
|
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||||
|
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||||
|
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||||
|
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||||
|
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||||
|
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||||
|
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||||
|
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||||
|
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||||
|
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||||
|
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
//
|
||||||
|
// Author: Shinichiro Hamaji
|
||||||
|
//
|
||||||
|
// Detect supported platforms.
|
||||||
|
|
||||||
|
#ifndef GLOG_PLATFORM_H
|
||||||
|
#define GLOG_PLATFORM_H
|
||||||
|
|
||||||
|
#if defined(WIN32) || defined(_WIN32) || defined(__WIN32__)
|
||||||
|
#define GLOG_OS_WINDOWS
|
||||||
|
#elif defined(__CYGWIN__) || defined(__CYGWIN32__)
|
||||||
|
#define GLOG_OS_CYGWIN
|
||||||
|
#elif defined(linux) || defined(__linux) || defined(__linux__)
|
||||||
|
#ifndef GLOG_OS_LINUX
|
||||||
|
#define GLOG_OS_LINUX
|
||||||
|
#endif
|
||||||
|
#elif defined(macintosh) || defined(__APPLE__) || defined(__APPLE_CC__)
|
||||||
|
#define GLOG_OS_MACOSX
|
||||||
|
#elif defined(__FreeBSD__)
|
||||||
|
#define GLOG_OS_FREEBSD
|
||||||
|
#elif defined(__NetBSD__)
|
||||||
|
#define GLOG_OS_NETBSD
|
||||||
|
#elif defined(__OpenBSD__)
|
||||||
|
#define GLOG_OS_OPENBSD
|
||||||
|
#else
|
||||||
|
// TODO(hamaji): Add other platforms.
|
||||||
|
#error Platform not supported by glog. Please consider to contribute platform information by submitting a pull request on Github.
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif // GLOG_PLATFORM_H
|
||||||
@ -40,9 +40,9 @@
|
|||||||
|
|
||||||
@ac_google_start_namespace@
|
@ac_google_start_namespace@
|
||||||
|
|
||||||
#include "glog/log_severity.h"
|
#include <glog/log_severity.h>
|
||||||
#include "glog/logging.h"
|
#include <glog/logging.h>
|
||||||
#include "glog/vlog_is_on.h"
|
#include <glog/vlog_is_on.h>
|
||||||
|
|
||||||
// Annoying stuff for windows -- makes sure clients can import these functions
|
// Annoying stuff for windows -- makes sure clients can import these functions
|
||||||
#ifndef GOOGLE_GLOG_DLL_DECL
|
#ifndef GOOGLE_GLOG_DLL_DECL
|
||||||
|
|||||||
@ -61,7 +61,7 @@
|
|||||||
#ifndef BASE_VLOG_IS_ON_H_
|
#ifndef BASE_VLOG_IS_ON_H_
|
||||||
#define BASE_VLOG_IS_ON_H_
|
#define BASE_VLOG_IS_ON_H_
|
||||||
|
|
||||||
#include "glog/log_severity.h"
|
#include <glog/log_severity.h>
|
||||||
|
|
||||||
// Annoying stuff for windows -- makes sure clients can import these functions
|
// Annoying stuff for windows -- makes sure clients can import these functions
|
||||||
#ifndef GOOGLE_GLOG_DLL_DECL
|
#ifndef GOOGLE_GLOG_DLL_DECL
|
||||||
|
|||||||
@ -76,7 +76,7 @@ _END_GOOGLE_NAMESPACE_
|
|||||||
#define GOOGLE_GLOG_DLL_DECL
|
#define GOOGLE_GLOG_DLL_DECL
|
||||||
|
|
||||||
static inline string GetTempDir() {
|
static inline string GetTempDir() {
|
||||||
#ifndef OS_WINDOWS
|
#ifndef GLOG_OS_WINDOWS
|
||||||
return "/tmp";
|
return "/tmp";
|
||||||
#else
|
#else
|
||||||
char tmp[MAX_PATH];
|
char tmp[MAX_PATH];
|
||||||
@ -85,7 +85,7 @@ static inline string GetTempDir() {
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
#if defined(OS_WINDOWS) && defined(_MSC_VER) && !defined(TEST_SRC_DIR)
|
#if defined(GLOG_OS_WINDOWS) && defined(_MSC_VER) && !defined(TEST_SRC_DIR)
|
||||||
// The test will run in glog/vsproject/<project name>
|
// The test will run in glog/vsproject/<project name>
|
||||||
// (e.g., glog/vsproject/logging_unittest).
|
// (e.g., glog/vsproject/logging_unittest).
|
||||||
static const char TEST_SRC_DIR[] = "../..";
|
static const char TEST_SRC_DIR[] = "../..";
|
||||||
@ -220,7 +220,7 @@ static inline void CalledAbort() {
|
|||||||
longjmp(g_jmp_buf, 1);
|
longjmp(g_jmp_buf, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef OS_WINDOWS
|
#ifdef GLOG_OS_WINDOWS
|
||||||
// TODO(hamaji): Death test somehow doesn't work in Windows.
|
// TODO(hamaji): Death test somehow doesn't work in Windows.
|
||||||
#define ASSERT_DEATH(fn, msg)
|
#define ASSERT_DEATH(fn, msg)
|
||||||
#else
|
#else
|
||||||
@ -510,7 +510,7 @@ static inline bool MungeAndDiffTestStderr(const string& golden_filename) {
|
|||||||
WriteToFile(golden, munged_golden);
|
WriteToFile(golden, munged_golden);
|
||||||
string munged_captured = cap->filename() + ".munged";
|
string munged_captured = cap->filename() + ".munged";
|
||||||
WriteToFile(captured, munged_captured);
|
WriteToFile(captured, munged_captured);
|
||||||
#ifdef OS_WINDOWS
|
#ifdef GLOG_OS_WINDOWS
|
||||||
string diffcmd("fc " + munged_golden + " " + munged_captured);
|
string diffcmd("fc " + munged_golden + " " + munged_captured);
|
||||||
#else
|
#else
|
||||||
string diffcmd("diff -u " + munged_golden + " " + munged_captured);
|
string diffcmd("diff -u " + munged_golden + " " + munged_captured);
|
||||||
@ -552,7 +552,7 @@ class Thread {
|
|||||||
virtual ~Thread() {}
|
virtual ~Thread() {}
|
||||||
|
|
||||||
void SetJoinable(bool) {}
|
void SetJoinable(bool) {}
|
||||||
#if defined(OS_WINDOWS) && !defined(OS_CYGWIN)
|
#if defined(GLOG_OS_WINDOWS) && !defined(GLOG_OS_CYGWIN)
|
||||||
void Start() {
|
void Start() {
|
||||||
handle_ = CreateThread(NULL,
|
handle_ = CreateThread(NULL,
|
||||||
0,
|
0,
|
||||||
@ -585,7 +585,7 @@ class Thread {
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if defined(OS_WINDOWS) && !defined(OS_CYGWIN)
|
#if defined(GLOG_OS_WINDOWS) && !defined(GLOG_OS_CYGWIN)
|
||||||
static DWORD InvokeThreadW(void* self) {
|
static DWORD InvokeThreadW(void* self) {
|
||||||
InvokeThread(self);
|
InvokeThread(self);
|
||||||
return 0;
|
return 0;
|
||||||
@ -598,7 +598,7 @@ class Thread {
|
|||||||
};
|
};
|
||||||
|
|
||||||
static inline void SleepForMilliseconds(unsigned t) {
|
static inline void SleepForMilliseconds(unsigned t) {
|
||||||
#ifndef OS_WINDOWS
|
#ifndef GLOG_OS_WINDOWS
|
||||||
# if defined(_POSIX_C_SOURCE) && _POSIX_C_SOURCE >= 199309L
|
# if defined(_POSIX_C_SOURCE) && _POSIX_C_SOURCE >= 199309L
|
||||||
const struct timespec req = {0, t * 1000 * 1000};
|
const struct timespec req = {0, t * 1000 * 1000};
|
||||||
nanosleep(&req, NULL);
|
nanosleep(&req, NULL);
|
||||||
|
|||||||
@ -59,14 +59,14 @@
|
|||||||
#include <vector>
|
#include <vector>
|
||||||
#include <cerrno> // for errno
|
#include <cerrno> // for errno
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
#ifdef OS_WINDOWS
|
#ifdef GLOG_OS_WINDOWS
|
||||||
#include "windows/dirent.h"
|
#include "windows/dirent.h"
|
||||||
#else
|
#else
|
||||||
#include <dirent.h> // for automatic removal of old logs
|
#include <dirent.h> // for automatic removal of old logs
|
||||||
#endif
|
#endif
|
||||||
#include "base/commandlineflags.h" // to get the program name
|
#include "base/commandlineflags.h" // to get the program name
|
||||||
#include "glog/logging.h"
|
#include <glog/logging.h>
|
||||||
#include "glog/raw_logging.h"
|
#include <glog/raw_logging.h>
|
||||||
#include "base/googleinit.h"
|
#include "base/googleinit.h"
|
||||||
|
|
||||||
#ifdef HAVE_STACKTRACE
|
#ifdef HAVE_STACKTRACE
|
||||||
@ -122,7 +122,7 @@ GLOG_DEFINE_bool(alsologtostderr, BoolFromEnv("GOOGLE_ALSOLOGTOSTDERR", false),
|
|||||||
"log messages go to stderr in addition to logfiles");
|
"log messages go to stderr in addition to logfiles");
|
||||||
GLOG_DEFINE_bool(colorlogtostderr, false,
|
GLOG_DEFINE_bool(colorlogtostderr, false,
|
||||||
"color messages logged to stderr (if supported by terminal)");
|
"color messages logged to stderr (if supported by terminal)");
|
||||||
#ifdef OS_LINUX
|
#ifdef GLOG_OS_LINUX
|
||||||
GLOG_DEFINE_bool(drop_log_memory, true, "Drop in-memory buffers of log contents. "
|
GLOG_DEFINE_bool(drop_log_memory, true, "Drop in-memory buffers of log contents. "
|
||||||
"Logs can grow very quickly and they are rarely read before they "
|
"Logs can grow very quickly and they are rarely read before they "
|
||||||
"need to be evicted from memory. Instead, drop them from memory "
|
"need to be evicted from memory. Instead, drop them from memory "
|
||||||
@ -198,7 +198,7 @@ GLOG_DEFINE_bool(log_utc_time, false,
|
|||||||
#define PATH_SEPARATOR '/'
|
#define PATH_SEPARATOR '/'
|
||||||
|
|
||||||
#ifndef HAVE_PREAD
|
#ifndef HAVE_PREAD
|
||||||
#if defined(OS_WINDOWS)
|
#if defined(GLOG_OS_WINDOWS)
|
||||||
#include <basetsd.h>
|
#include <basetsd.h>
|
||||||
#define ssize_t SSIZE_T
|
#define ssize_t SSIZE_T
|
||||||
#endif
|
#endif
|
||||||
@ -241,7 +241,7 @@ static void GetHostName(string* hostname) {
|
|||||||
*buf.nodename = '\0';
|
*buf.nodename = '\0';
|
||||||
}
|
}
|
||||||
*hostname = buf.nodename;
|
*hostname = buf.nodename;
|
||||||
#elif defined(OS_WINDOWS)
|
#elif defined(GLOG_OS_WINDOWS)
|
||||||
char buf[MAX_COMPUTERNAME_LENGTH + 1];
|
char buf[MAX_COMPUTERNAME_LENGTH + 1];
|
||||||
DWORD len = MAX_COMPUTERNAME_LENGTH + 1;
|
DWORD len = MAX_COMPUTERNAME_LENGTH + 1;
|
||||||
if (GetComputerNameA(buf, &len)) {
|
if (GetComputerNameA(buf, &len)) {
|
||||||
@ -258,7 +258,7 @@ static void GetHostName(string* hostname) {
|
|||||||
// Returns true iff terminal supports using colors in output.
|
// Returns true iff terminal supports using colors in output.
|
||||||
static bool TerminalSupportsColor() {
|
static bool TerminalSupportsColor() {
|
||||||
bool term_supports_color = false;
|
bool term_supports_color = false;
|
||||||
#ifdef OS_WINDOWS
|
#ifdef GLOG_OS_WINDOWS
|
||||||
// on Windows TERM variable is usually not set, but the console does
|
// on Windows TERM variable is usually not set, but the console does
|
||||||
// support colors.
|
// support colors.
|
||||||
term_supports_color = true;
|
term_supports_color = true;
|
||||||
@ -312,7 +312,7 @@ static GLogColor SeverityToColor(LogSeverity severity) {
|
|||||||
return color;
|
return color;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef OS_WINDOWS
|
#ifdef GLOG_OS_WINDOWS
|
||||||
|
|
||||||
// Returns the character attribute for the given color.
|
// Returns the character attribute for the given color.
|
||||||
static WORD GetColorAttribute(GLogColor color) {
|
static WORD GetColorAttribute(GLogColor color) {
|
||||||
@ -337,7 +337,7 @@ static const char* GetAnsiColorCode(GLogColor color) {
|
|||||||
return NULL; // stop warning about return type.
|
return NULL; // stop warning about return type.
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif // OS_WINDOWS
|
#endif // GLOG_OS_WINDOWS
|
||||||
|
|
||||||
// Safely get max_log_size, overriding to 1 if it somehow gets defined as 0
|
// Safely get max_log_size, overriding to 1 if it somehow gets defined as 0
|
||||||
static int32 MaxLogSize() {
|
static int32 MaxLogSize() {
|
||||||
@ -747,7 +747,7 @@ static void ColoredWriteToStderr(LogSeverity severity,
|
|||||||
fwrite(message, len, 1, stderr);
|
fwrite(message, len, 1, stderr);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
#ifdef OS_WINDOWS
|
#ifdef GLOG_OS_WINDOWS
|
||||||
const HANDLE stderr_handle = GetStdHandle(STD_ERROR_HANDLE);
|
const HANDLE stderr_handle = GetStdHandle(STD_ERROR_HANDLE);
|
||||||
|
|
||||||
// Gets the current text color.
|
// Gets the current text color.
|
||||||
@ -769,7 +769,7 @@ static void ColoredWriteToStderr(LogSeverity severity,
|
|||||||
fprintf(stderr, "\033[0;3%sm", GetAnsiColorCode(color));
|
fprintf(stderr, "\033[0;3%sm", GetAnsiColorCode(color));
|
||||||
fwrite(message, len, 1, stderr);
|
fwrite(message, len, 1, stderr);
|
||||||
fprintf(stderr, "\033[m"); // Resets the terminal to default.
|
fprintf(stderr, "\033[m"); // Resets the terminal to default.
|
||||||
#endif // OS_WINDOWS
|
#endif // GLOG_OS_WINDOWS
|
||||||
}
|
}
|
||||||
|
|
||||||
static void WriteToStderr(const char* message, size_t len) {
|
static void WriteToStderr(const char* message, size_t len) {
|
||||||
@ -782,7 +782,7 @@ inline void LogDestination::MaybeLogToStderr(LogSeverity severity,
|
|||||||
const char* message, size_t message_len, size_t /*prefix_len*/) {
|
const char* message, size_t message_len, size_t /*prefix_len*/) {
|
||||||
if ((severity >= FLAGS_stderrthreshold) || FLAGS_alsologtostderr) {
|
if ((severity >= FLAGS_stderrthreshold) || FLAGS_alsologtostderr) {
|
||||||
ColoredWriteToStderr(severity, message, message_len);
|
ColoredWriteToStderr(severity, message, message_len);
|
||||||
#ifdef OS_WINDOWS
|
#ifdef GLOG_OS_WINDOWS
|
||||||
// On Windows, also output to the debugger
|
// On Windows, also output to the debugger
|
||||||
::OutputDebugStringA(message);
|
::OutputDebugStringA(message);
|
||||||
#elif defined(__ANDROID__)
|
#elif defined(__ANDROID__)
|
||||||
@ -1050,7 +1050,7 @@ bool LogFileObject::CreateLogfile(const string& time_pid_string) {
|
|||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
#ifdef OS_WINDOWS
|
#ifdef GLOG_OS_WINDOWS
|
||||||
// https://github.com/golang/go/issues/27638 - make sure we seek to the end to append
|
// https://github.com/golang/go/issues/27638 - make sure we seek to the end to append
|
||||||
// empirically replicated with wine over mingw build
|
// empirically replicated with wine over mingw build
|
||||||
if (!FLAGS_timestamp_in_logfile_name) {
|
if (!FLAGS_timestamp_in_logfile_name) {
|
||||||
@ -1074,7 +1074,7 @@ bool LogFileObject::CreateLogfile(const string& time_pid_string) {
|
|||||||
linkpath += linkname;
|
linkpath += linkname;
|
||||||
unlink(linkpath.c_str()); // delete old one if it exists
|
unlink(linkpath.c_str()); // delete old one if it exists
|
||||||
|
|
||||||
#if defined(OS_WINDOWS)
|
#if defined(GLOG_OS_WINDOWS)
|
||||||
// TODO(hamaji): Create lnk file on Windows?
|
// TODO(hamaji): Create lnk file on Windows?
|
||||||
#elif defined(HAVE_UNISTD_H)
|
#elif defined(HAVE_UNISTD_H)
|
||||||
// We must have unistd.h.
|
// We must have unistd.h.
|
||||||
@ -1264,7 +1264,7 @@ void LogFileObject::Write(bool force_flush,
|
|||||||
(bytes_since_flush_ >= 1000000) ||
|
(bytes_since_flush_ >= 1000000) ||
|
||||||
(CycleClock_Now() >= next_flush_time_) ) {
|
(CycleClock_Now() >= next_flush_time_) ) {
|
||||||
FlushUnlocked();
|
FlushUnlocked();
|
||||||
#ifdef OS_LINUX
|
#ifdef GLOG_OS_LINUX
|
||||||
// Only consider files >= 3MiB
|
// Only consider files >= 3MiB
|
||||||
if (FLAGS_drop_log_memory && file_length_ >= (3 << 20)) {
|
if (FLAGS_drop_log_memory && file_length_ >= (3 << 20)) {
|
||||||
// Don't evict the most recent 1-2MiB so as not to impact a tailer
|
// Don't evict the most recent 1-2MiB so as not to impact a tailer
|
||||||
@ -1299,7 +1299,7 @@ void LogFileObject::Write(bool force_flush,
|
|||||||
|
|
||||||
|
|
||||||
LogCleaner::LogCleaner() : enabled_(false), overdue_days_(7), dir_delim_('/') {
|
LogCleaner::LogCleaner() : enabled_(false), overdue_days_(7), dir_delim_('/') {
|
||||||
#ifdef OS_WINDOWS
|
#ifdef GLOG_OS_WINDOWS
|
||||||
dir_delim_ = '\\';
|
dir_delim_ = '\\';
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
@ -2201,7 +2201,7 @@ bool SendEmail(const char*dest, const char *subject, const char*body){
|
|||||||
|
|
||||||
static void GetTempDirectories(vector<string>* list) {
|
static void GetTempDirectories(vector<string>* list) {
|
||||||
list->clear();
|
list->clear();
|
||||||
#ifdef OS_WINDOWS
|
#ifdef GLOG_OS_WINDOWS
|
||||||
// On windows we'll try to find a directory in this order:
|
// On windows we'll try to find a directory in this order:
|
||||||
// C:/Documents & Settings/whomever/TEMP (or whatever GetTempPath() is)
|
// C:/Documents & Settings/whomever/TEMP (or whatever GetTempPath() is)
|
||||||
// C:/TMP/
|
// C:/TMP/
|
||||||
@ -2260,7 +2260,7 @@ const vector<string>& GetLoggingDirectories() {
|
|||||||
logging_directories_list->push_back(FLAGS_log_dir.c_str());
|
logging_directories_list->push_back(FLAGS_log_dir.c_str());
|
||||||
} else {
|
} else {
|
||||||
GetTempDirectories(logging_directories_list);
|
GetTempDirectories(logging_directories_list);
|
||||||
#ifdef OS_WINDOWS
|
#ifdef GLOG_OS_WINDOWS
|
||||||
char tmp[MAX_PATH];
|
char tmp[MAX_PATH];
|
||||||
if (GetWindowsDirectoryA(tmp, MAX_PATH))
|
if (GetWindowsDirectoryA(tmp, MAX_PATH))
|
||||||
logging_directories_list->push_back(tmp);
|
logging_directories_list->push_back(tmp);
|
||||||
@ -2303,7 +2303,7 @@ void TruncateLogFile(const char *path, int64 limit, int64 keep) {
|
|||||||
// Don't follow symlinks unless they're our own fd symlinks in /proc
|
// Don't follow symlinks unless they're our own fd symlinks in /proc
|
||||||
int flags = O_RDWR;
|
int flags = O_RDWR;
|
||||||
// TODO(hamaji): Support other environments.
|
// TODO(hamaji): Support other environments.
|
||||||
#ifdef OS_LINUX
|
#ifdef GLOG_OS_LINUX
|
||||||
const char *procfd_prefix = "/proc/self/fd/";
|
const char *procfd_prefix = "/proc/self/fd/";
|
||||||
if (strncmp(procfd_prefix, path, strlen(procfd_prefix))) flags |= O_NOFOLLOW;
|
if (strncmp(procfd_prefix, path, strlen(procfd_prefix))) flags |= O_NOFOLLOW;
|
||||||
#endif
|
#endif
|
||||||
@ -2442,7 +2442,7 @@ int posix_strerror_r(int err, char *buf, size_t len) {
|
|||||||
return 0;
|
return 0;
|
||||||
} else {
|
} else {
|
||||||
buf[0] = '\000';
|
buf[0] = '\000';
|
||||||
#if defined(OS_MACOSX) || defined(OS_FREEBSD) || defined(OS_OPENBSD)
|
#if defined(GLOG_OS_MACOSX) || defined(GLOG_OS_FREEBSD) || defined(GLOG_OS_OPENBSD)
|
||||||
if (reinterpret_cast<intptr_t>(rc) < sys_nerr) {
|
if (reinterpret_cast<intptr_t>(rc) < sys_nerr) {
|
||||||
// This means an error on MacOSX or FreeBSD.
|
// This means an error on MacOSX or FreeBSD.
|
||||||
return -1;
|
return -1;
|
||||||
|
|||||||
@ -56,8 +56,8 @@
|
|||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
|
||||||
#include "base/commandlineflags.h"
|
#include "base/commandlineflags.h"
|
||||||
#include "glog/logging.h"
|
#include <glog/logging.h>
|
||||||
#include "glog/raw_logging.h"
|
#include <glog/raw_logging.h>
|
||||||
#include "googletest.h"
|
#include "googletest.h"
|
||||||
|
|
||||||
DECLARE_string(log_backtrace_at); // logging.cc
|
DECLARE_string(log_backtrace_at); // logging.cc
|
||||||
@ -592,7 +592,7 @@ void TestCHECK() {
|
|||||||
|
|
||||||
// Tests using CHECK*() on anonymous enums.
|
// Tests using CHECK*() on anonymous enums.
|
||||||
// Apple's GCC doesn't like this.
|
// Apple's GCC doesn't like this.
|
||||||
#if !defined(OS_MACOSX)
|
#if !defined(GLOG_OS_MACOSX)
|
||||||
CHECK_EQ(CASE_A, CASE_A);
|
CHECK_EQ(CASE_A, CASE_A);
|
||||||
CHECK_NE(CASE_A, CASE_B);
|
CHECK_NE(CASE_A, CASE_B);
|
||||||
CHECK_GE(CASE_A, CASE_A);
|
CHECK_GE(CASE_A, CASE_A);
|
||||||
@ -674,7 +674,7 @@ static void GetFiles(const string& pattern, vector<string>* files) {
|
|||||||
files->push_back(string(g.gl_pathv[i]));
|
files->push_back(string(g.gl_pathv[i]));
|
||||||
}
|
}
|
||||||
globfree(&g);
|
globfree(&g);
|
||||||
#elif defined(OS_WINDOWS)
|
#elif defined(GLOG_OS_WINDOWS)
|
||||||
WIN32_FIND_DATAA data;
|
WIN32_FIND_DATAA data;
|
||||||
HANDLE handle = FindFirstFileA(pattern.c_str(), &data);
|
HANDLE handle = FindFirstFileA(pattern.c_str(), &data);
|
||||||
size_t index = pattern.rfind('\\');
|
size_t index = pattern.rfind('\\');
|
||||||
@ -803,7 +803,7 @@ static void TestTwoProcessesWrite() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void TestSymlink() {
|
static void TestSymlink() {
|
||||||
#ifndef OS_WINDOWS
|
#ifndef GLOG_OS_WINDOWS
|
||||||
fprintf(stderr, "==== Test setting log file symlink\n");
|
fprintf(stderr, "==== Test setting log file symlink\n");
|
||||||
string dest = FLAGS_test_tmpdir + "/logging_test_symlink";
|
string dest = FLAGS_test_tmpdir + "/logging_test_symlink";
|
||||||
string sym = FLAGS_test_tmpdir + "/symlinkbase";
|
string sym = FLAGS_test_tmpdir + "/symlinkbase";
|
||||||
@ -946,7 +946,7 @@ static void TestTruncate() {
|
|||||||
// MacOSX 10.4 doesn't fail in this case.
|
// MacOSX 10.4 doesn't fail in this case.
|
||||||
// Windows doesn't have symlink.
|
// Windows doesn't have symlink.
|
||||||
// Let's just ignore this test for these cases.
|
// Let's just ignore this test for these cases.
|
||||||
#if !defined(OS_MACOSX) && !defined(OS_WINDOWS)
|
#if !defined(GLOG_OS_MACOSX) && !defined(GLOG_OS_WINDOWS)
|
||||||
// Through a symlink should fail to truncate
|
// Through a symlink should fail to truncate
|
||||||
string linkname = path + ".link";
|
string linkname = path + ".link";
|
||||||
unlink(linkname.c_str());
|
unlink(linkname.c_str());
|
||||||
@ -955,7 +955,7 @@ static void TestTruncate() {
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
// The /proc/self path makes sense only for linux.
|
// The /proc/self path makes sense only for linux.
|
||||||
#if defined(OS_LINUX)
|
#if defined(GLOG_OS_LINUX)
|
||||||
// Through an open fd symlink should work
|
// Through an open fd symlink should work
|
||||||
int fd;
|
int fd;
|
||||||
CHECK_ERR(fd = open(path.c_str(), O_APPEND | O_WRONLY));
|
CHECK_ERR(fd = open(path.c_str(), O_APPEND | O_WRONLY));
|
||||||
@ -1211,7 +1211,7 @@ TEST(Strerror, logging) {
|
|||||||
CHECK_EQ(posix_strerror_r(errcode, buf, 0), -1);
|
CHECK_EQ(posix_strerror_r(errcode, buf, 0), -1);
|
||||||
CHECK_EQ(buf[0], 'A');
|
CHECK_EQ(buf[0], 'A');
|
||||||
CHECK_EQ(posix_strerror_r(errcode, NULL, buf_size), -1);
|
CHECK_EQ(posix_strerror_r(errcode, NULL, buf_size), -1);
|
||||||
#if defined(OS_MACOSX) || defined(OS_FREEBSD) || defined(OS_OPENBSD)
|
#if defined(GLOG_OS_MACOSX) || defined(GLOG_OS_FREEBSD) || defined(GLOG_OS_OPENBSD)
|
||||||
// MacOSX or FreeBSD considers this case is an error since there is
|
// MacOSX or FreeBSD considers this case is an error since there is
|
||||||
// no enough space.
|
// no enough space.
|
||||||
CHECK_EQ(posix_strerror_r(errcode, buf, 1), -1);
|
CHECK_EQ(posix_strerror_r(errcode, buf, 1), -1);
|
||||||
|
|||||||
@ -34,7 +34,7 @@
|
|||||||
#include <cstdio>
|
#include <cstdio>
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <iosfwd>
|
#include <iosfwd>
|
||||||
#include "glog/logging.h"
|
#include <glog/logging.h>
|
||||||
#include "base/commandlineflags.h"
|
#include "base/commandlineflags.h"
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
|
|
||||||
|
|||||||
@ -56,8 +56,8 @@
|
|||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
#include "base/commandlineflags.h"
|
#include "base/commandlineflags.h"
|
||||||
#include "glog/logging.h"
|
#include <glog/logging.h>
|
||||||
#include "glog/raw_logging.h"
|
#include <glog/raw_logging.h>
|
||||||
#include "googletest.h"
|
#include "googletest.h"
|
||||||
|
|
||||||
DECLARE_string(log_backtrace_at); // logging.cc
|
DECLARE_string(log_backtrace_at); // logging.cc
|
||||||
@ -587,7 +587,7 @@ void TestCHECK() {
|
|||||||
|
|
||||||
// Tests using CHECK*() on anonymous enums.
|
// Tests using CHECK*() on anonymous enums.
|
||||||
// Apple's GCC doesn't like this.
|
// Apple's GCC doesn't like this.
|
||||||
#if !defined(OS_MACOSX)
|
#if !defined(GLOG_OS_MACOSX)
|
||||||
CHECK_EQ(CASE_A, CASE_A);
|
CHECK_EQ(CASE_A, CASE_A);
|
||||||
CHECK_NE(CASE_A, CASE_B);
|
CHECK_NE(CASE_A, CASE_B);
|
||||||
CHECK_GE(CASE_A, CASE_A);
|
CHECK_GE(CASE_A, CASE_A);
|
||||||
@ -669,7 +669,7 @@ static void GetFiles(const string& pattern, vector<string>* files) {
|
|||||||
files->push_back(string(g.gl_pathv[i]));
|
files->push_back(string(g.gl_pathv[i]));
|
||||||
}
|
}
|
||||||
globfree(&g);
|
globfree(&g);
|
||||||
#elif defined(OS_WINDOWS)
|
#elif defined(GLOG_OS_WINDOWS)
|
||||||
WIN32_FIND_DATAA data;
|
WIN32_FIND_DATAA data;
|
||||||
HANDLE handle = FindFirstFileA(pattern.c_str(), &data);
|
HANDLE handle = FindFirstFileA(pattern.c_str(), &data);
|
||||||
size_t index = pattern.rfind('\\');
|
size_t index = pattern.rfind('\\');
|
||||||
@ -798,7 +798,7 @@ static void TestTwoProcessesWrite() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void TestSymlink() {
|
static void TestSymlink() {
|
||||||
#ifndef OS_WINDOWS
|
#ifndef GLOG_OS_WINDOWS
|
||||||
fprintf(stderr, "==== Test setting log file symlink\n");
|
fprintf(stderr, "==== Test setting log file symlink\n");
|
||||||
string dest = FLAGS_test_tmpdir + "/logging_test_symlink";
|
string dest = FLAGS_test_tmpdir + "/logging_test_symlink";
|
||||||
string sym = FLAGS_test_tmpdir + "/symlinkbase";
|
string sym = FLAGS_test_tmpdir + "/symlinkbase";
|
||||||
@ -941,7 +941,7 @@ static void TestTruncate() {
|
|||||||
// MacOSX 10.4 doesn't fail in this case.
|
// MacOSX 10.4 doesn't fail in this case.
|
||||||
// Windows doesn't have symlink.
|
// Windows doesn't have symlink.
|
||||||
// Let's just ignore this test for these cases.
|
// Let's just ignore this test for these cases.
|
||||||
#if !defined(OS_MACOSX) && !defined(OS_WINDOWS)
|
#if !defined(GLOG_OS_MACOSX) && !defined(GLOG_OS_WINDOWS)
|
||||||
// Through a symlink should fail to truncate
|
// Through a symlink should fail to truncate
|
||||||
string linkname = path + ".link";
|
string linkname = path + ".link";
|
||||||
unlink(linkname.c_str());
|
unlink(linkname.c_str());
|
||||||
@ -950,7 +950,7 @@ static void TestTruncate() {
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
// The /proc/self path makes sense only for linux.
|
// The /proc/self path makes sense only for linux.
|
||||||
#if defined(OS_LINUX)
|
#if defined(GLOG_OS_LINUX)
|
||||||
// Through an open fd symlink should work
|
// Through an open fd symlink should work
|
||||||
int fd;
|
int fd;
|
||||||
CHECK_ERR(fd = open(path.c_str(), O_APPEND | O_WRONLY));
|
CHECK_ERR(fd = open(path.c_str(), O_APPEND | O_WRONLY));
|
||||||
@ -1031,7 +1031,7 @@ int64 elapsedTime_ns(const std::chrono::steady_clock::time_point& begin,
|
|||||||
return std::chrono::duration_cast<std::chrono::nanoseconds>((end - begin))
|
return std::chrono::duration_cast<std::chrono::nanoseconds>((end - begin))
|
||||||
.count();
|
.count();
|
||||||
}
|
}
|
||||||
#elif defined(OS_WINDOWS)
|
#elif defined(GLOG_OS_WINDOWS)
|
||||||
struct LogTimeRecorder {
|
struct LogTimeRecorder {
|
||||||
LogTimeRecorder() : m_streamTimes(0) {}
|
LogTimeRecorder() : m_streamTimes(0) {}
|
||||||
size_t m_streamTimes;
|
size_t m_streamTimes;
|
||||||
@ -1299,7 +1299,7 @@ TEST(Strerror, logging) {
|
|||||||
CHECK_EQ(posix_strerror_r(errcode, buf, 0), -1);
|
CHECK_EQ(posix_strerror_r(errcode, buf, 0), -1);
|
||||||
CHECK_EQ(buf[0], 'A');
|
CHECK_EQ(buf[0], 'A');
|
||||||
CHECK_EQ(posix_strerror_r(errcode, NULL, buf_size), -1);
|
CHECK_EQ(posix_strerror_r(errcode, NULL, buf_size), -1);
|
||||||
#if defined(OS_MACOSX) || defined(OS_FREEBSD) || defined(OS_OPENBSD)
|
#if defined(GLOG_OS_MACOSX) || defined(GLOG_OS_FREEBSD) || defined(GLOG_OS_OPENBSD)
|
||||||
// MacOSX or FreeBSD considers this case is an error since there is
|
// MacOSX or FreeBSD considers this case is an error since there is
|
||||||
// no enough space.
|
// no enough space.
|
||||||
CHECK_EQ(posix_strerror_r(errcode, buf, 1), -1);
|
CHECK_EQ(posix_strerror_r(errcode, buf, 1), -1);
|
||||||
|
|||||||
@ -42,7 +42,7 @@
|
|||||||
|
|
||||||
#include <gmock/gmock.h>
|
#include <gmock/gmock.h>
|
||||||
|
|
||||||
#include "glog/logging.h"
|
#include <glog/logging.h>
|
||||||
|
|
||||||
_START_GOOGLE_NAMESPACE_
|
_START_GOOGLE_NAMESPACE_
|
||||||
namespace glog_testing {
|
namespace glog_testing {
|
||||||
|
|||||||
@ -42,8 +42,8 @@
|
|||||||
#include <fcntl.h> // for open()
|
#include <fcntl.h> // for open()
|
||||||
#include <ctime>
|
#include <ctime>
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
#include "glog/logging.h" // To pick up flag settings etc.
|
#include <glog/logging.h> // To pick up flag settings etc.
|
||||||
#include "glog/raw_logging.h"
|
#include <glog/raw_logging.h>
|
||||||
#include "base/commandlineflags.h"
|
#include "base/commandlineflags.h"
|
||||||
|
|
||||||
#ifdef HAVE_STACKTRACE
|
#ifdef HAVE_STACKTRACE
|
||||||
@ -59,7 +59,7 @@
|
|||||||
# include <unistd.h>
|
# include <unistd.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if (defined(HAVE_SYSCALL_H) || defined(HAVE_SYS_SYSCALL_H)) && (!(defined(OS_MACOSX)))
|
#if (defined(HAVE_SYSCALL_H) || defined(HAVE_SYS_SYSCALL_H)) && (!(defined(GLOG_OS_MACOSX)))
|
||||||
# define safe_write(fd, s, len) syscall(SYS_write, fd, s, len)
|
# define safe_write(fd, s, len) syscall(SYS_write, fd, s, len)
|
||||||
#else
|
#else
|
||||||
// Not so safe, but what can you do?
|
// Not so safe, but what can you do?
|
||||||
|
|||||||
@ -34,7 +34,7 @@
|
|||||||
#include "utilities.h"
|
#include "utilities.h"
|
||||||
#include "stacktrace.h"
|
#include "stacktrace.h"
|
||||||
#include "symbolize.h"
|
#include "symbolize.h"
|
||||||
#include "glog/logging.h"
|
#include <glog/logging.h>
|
||||||
|
|
||||||
#include <csignal>
|
#include <csignal>
|
||||||
#include <ctime>
|
#include <ctime>
|
||||||
@ -63,7 +63,7 @@ const struct {
|
|||||||
{ SIGILL, "SIGILL" },
|
{ SIGILL, "SIGILL" },
|
||||||
{ SIGFPE, "SIGFPE" },
|
{ SIGFPE, "SIGFPE" },
|
||||||
{ SIGABRT, "SIGABRT" },
|
{ SIGABRT, "SIGABRT" },
|
||||||
#if !defined(OS_WINDOWS)
|
#if !defined(GLOG_OS_WINDOWS)
|
||||||
{ SIGBUS, "SIGBUS" },
|
{ SIGBUS, "SIGBUS" },
|
||||||
#endif
|
#endif
|
||||||
{ SIGTERM, "SIGTERM" },
|
{ SIGTERM, "SIGTERM" },
|
||||||
@ -71,7 +71,7 @@ const struct {
|
|||||||
|
|
||||||
static bool kFailureSignalHandlerInstalled = false;
|
static bool kFailureSignalHandlerInstalled = false;
|
||||||
|
|
||||||
#if !defined(OS_WINDOWS)
|
#if !defined(GLOG_OS_WINDOWS)
|
||||||
// Returns the program counter from signal context, NULL if unknown.
|
// Returns the program counter from signal context, NULL if unknown.
|
||||||
void* GetPC(void* ucontext_in_void) {
|
void* GetPC(void* ucontext_in_void) {
|
||||||
#if (defined(HAVE_UCONTEXT_H) || defined(HAVE_SYS_UCONTEXT_H)) && defined(PC_FROM_UCONTEXT)
|
#if (defined(HAVE_UCONTEXT_H) || defined(HAVE_SYS_UCONTEXT_H)) && defined(PC_FROM_UCONTEXT)
|
||||||
@ -212,7 +212,7 @@ void DumpSignalInfo(int signal_number, siginfo_t *siginfo) {
|
|||||||
formatter.AppendUint64((uintptr_t)pthread_self(), 16);
|
formatter.AppendUint64((uintptr_t)pthread_self(), 16);
|
||||||
formatter.AppendString(") ");
|
formatter.AppendString(") ");
|
||||||
// Only linux has the PID of the signal sender in si_pid.
|
// Only linux has the PID of the signal sender in si_pid.
|
||||||
#ifdef OS_LINUX
|
#ifdef GLOG_OS_LINUX
|
||||||
formatter.AppendString("from PID ");
|
formatter.AppendString("from PID ");
|
||||||
formatter.AppendUint64(static_cast<uint64>(siginfo->si_pid), 10);
|
formatter.AppendUint64(static_cast<uint64>(siginfo->si_pid), 10);
|
||||||
formatter.AppendString("; ");
|
formatter.AppendString("; ");
|
||||||
@ -257,7 +257,7 @@ void InvokeDefaultSignalHandler(int signal_number) {
|
|||||||
sig_action.sa_handler = SIG_DFL;
|
sig_action.sa_handler = SIG_DFL;
|
||||||
sigaction(signal_number, &sig_action, NULL);
|
sigaction(signal_number, &sig_action, NULL);
|
||||||
kill(getpid(), signal_number);
|
kill(getpid(), signal_number);
|
||||||
#elif defined(OS_WINDOWS)
|
#elif defined(GLOG_OS_WINDOWS)
|
||||||
signal(signal_number, SIG_DFL);
|
signal(signal_number, SIG_DFL);
|
||||||
raise(signal_number);
|
raise(signal_number);
|
||||||
#endif
|
#endif
|
||||||
@ -271,7 +271,7 @@ static pthread_t* g_entered_thread_id_pointer = NULL;
|
|||||||
|
|
||||||
// Dumps signal and stack frame information, and invokes the default
|
// Dumps signal and stack frame information, and invokes the default
|
||||||
// signal handler once our job is done.
|
// signal handler once our job is done.
|
||||||
#if defined(OS_WINDOWS)
|
#if defined(GLOG_OS_WINDOWS)
|
||||||
void FailureSignalHandler(int signal_number)
|
void FailureSignalHandler(int signal_number)
|
||||||
#else
|
#else
|
||||||
void FailureSignalHandler(int signal_number,
|
void FailureSignalHandler(int signal_number,
|
||||||
@ -318,7 +318,7 @@ void FailureSignalHandler(int signal_number,
|
|||||||
// First dump time info.
|
// First dump time info.
|
||||||
DumpTimeInfo();
|
DumpTimeInfo();
|
||||||
|
|
||||||
#if !defined(OS_WINDOWS)
|
#if !defined(GLOG_OS_WINDOWS)
|
||||||
// Get the program counter from ucontext.
|
// Get the program counter from ucontext.
|
||||||
void *pc = GetPC(ucontext);
|
void *pc = GetPC(ucontext);
|
||||||
DumpStackFrameInfo("PC: ", pc);
|
DumpStackFrameInfo("PC: ", pc);
|
||||||
@ -368,7 +368,7 @@ bool IsFailureSignalHandlerInstalled() {
|
|||||||
sigaction(SIGABRT, NULL, &sig_action);
|
sigaction(SIGABRT, NULL, &sig_action);
|
||||||
if (sig_action.sa_sigaction == &FailureSignalHandler)
|
if (sig_action.sa_sigaction == &FailureSignalHandler)
|
||||||
return true;
|
return true;
|
||||||
#elif defined(OS_WINDOWS)
|
#elif defined(GLOG_OS_WINDOWS)
|
||||||
return kFailureSignalHandlerInstalled;
|
return kFailureSignalHandlerInstalled;
|
||||||
#endif // HAVE_SIGACTION
|
#endif // HAVE_SIGACTION
|
||||||
return false;
|
return false;
|
||||||
@ -389,7 +389,7 @@ void InstallFailureSignalHandler() {
|
|||||||
CHECK_ERR(sigaction(kFailureSignals[i].number, &sig_action, NULL));
|
CHECK_ERR(sigaction(kFailureSignals[i].number, &sig_action, NULL));
|
||||||
}
|
}
|
||||||
kFailureSignalHandlerInstalled = true;
|
kFailureSignalHandlerInstalled = true;
|
||||||
#elif defined(OS_WINDOWS)
|
#elif defined(GLOG_OS_WINDOWS)
|
||||||
for (size_t i = 0; i < ARRAYSIZE(kFailureSignals); ++i) {
|
for (size_t i = 0; i < ARRAYSIZE(kFailureSignals); ++i) {
|
||||||
CHECK_NE(signal(kFailureSignals[i].number, &FailureSignalHandler),
|
CHECK_NE(signal(kFailureSignals[i].number, &FailureSignalHandler),
|
||||||
SIG_ERR);
|
SIG_ERR);
|
||||||
@ -399,7 +399,7 @@ void InstallFailureSignalHandler() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void InstallFailureWriter(void (*writer)(const char* data, size_t size)) {
|
void InstallFailureWriter(void (*writer)(const char* data, size_t size)) {
|
||||||
#if defined(HAVE_SIGACTION) || defined(OS_WINDOWS)
|
#if defined(HAVE_SIGACTION) || defined(GLOG_OS_WINDOWS)
|
||||||
g_failure_writer = writer;
|
g_failure_writer = writer;
|
||||||
#endif // HAVE_SIGACTION
|
#endif // HAVE_SIGACTION
|
||||||
}
|
}
|
||||||
|
|||||||
@ -41,7 +41,7 @@
|
|||||||
#include <cstdio>
|
#include <cstdio>
|
||||||
#include <cstdlib>
|
#include <cstdlib>
|
||||||
#include <string>
|
#include <string>
|
||||||
#include "glog/logging.h"
|
#include <glog/logging.h>
|
||||||
|
|
||||||
#ifdef HAVE_LIB_GFLAGS
|
#ifdef HAVE_LIB_GFLAGS
|
||||||
#include <gflags/gflags.h>
|
#include <gflags/gflags.h>
|
||||||
|
|||||||
@ -34,7 +34,7 @@
|
|||||||
#define BASE_STACKTRACE_H_
|
#define BASE_STACKTRACE_H_
|
||||||
|
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
#include "glog/logging.h"
|
#include <glog/logging.h>
|
||||||
|
|
||||||
_START_GOOGLE_NAMESPACE_
|
_START_GOOGLE_NAMESPACE_
|
||||||
|
|
||||||
|
|||||||
@ -37,7 +37,7 @@ extern "C" {
|
|||||||
#define UNW_LOCAL_ONLY
|
#define UNW_LOCAL_ONLY
|
||||||
#include <libunwind.h>
|
#include <libunwind.h>
|
||||||
}
|
}
|
||||||
#include "glog/raw_logging.h"
|
#include <glog/raw_logging.h>
|
||||||
#include "stacktrace.h"
|
#include "stacktrace.h"
|
||||||
|
|
||||||
_START_GOOGLE_NAMESPACE_
|
_START_GOOGLE_NAMESPACE_
|
||||||
|
|||||||
@ -33,7 +33,7 @@
|
|||||||
#include <cstdlib>
|
#include <cstdlib>
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
#include "base/commandlineflags.h"
|
#include "base/commandlineflags.h"
|
||||||
#include "glog/logging.h"
|
#include <glog/logging.h>
|
||||||
#include "stacktrace.h"
|
#include "stacktrace.h"
|
||||||
|
|
||||||
#ifdef HAVE_EXECINFO_H
|
#ifdef HAVE_EXECINFO_H
|
||||||
|
|||||||
@ -33,7 +33,7 @@
|
|||||||
|
|
||||||
#include "utilities.h" // for OS_* macros
|
#include "utilities.h" // for OS_* macros
|
||||||
|
|
||||||
#if !defined(OS_WINDOWS)
|
#if !defined(GLOG_OS_WINDOWS)
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <sys/mman.h>
|
#include <sys/mman.h>
|
||||||
#endif
|
#endif
|
||||||
@ -74,7 +74,7 @@ static void **NextStackFrame(void **old_sp) {
|
|||||||
// last two pages in the address space
|
// last two pages in the address space
|
||||||
if ((uintptr_t)new_sp >= 0xffffe000) return NULL;
|
if ((uintptr_t)new_sp >= 0xffffe000) return NULL;
|
||||||
#endif
|
#endif
|
||||||
#if !defined(OS_WINDOWS)
|
#if !defined(GLOG_OS_WINDOWS)
|
||||||
if (!STRICT_UNWINDING) {
|
if (!STRICT_UNWINDING) {
|
||||||
// Lax sanity checks cause a crash in 32-bit tcmalloc/crash_reason_test
|
// Lax sanity checks cause a crash in 32-bit tcmalloc/crash_reason_test
|
||||||
// on AMD-based machines with VDSO-enabled kernels.
|
// on AMD-based machines with VDSO-enabled kernels.
|
||||||
|
|||||||
@ -58,8 +58,8 @@
|
|||||||
# endif
|
# endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include "glog/logging.h"
|
#include <glog/logging.h>
|
||||||
#include "glog/stl_logging.h"
|
#include <glog/stl_logging.h>
|
||||||
#include "googletest.h"
|
#include "googletest.h"
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
|||||||
@ -46,7 +46,7 @@
|
|||||||
// and memmove(). We assume they are async-signal-safe.
|
// and memmove(). We assume they are async-signal-safe.
|
||||||
//
|
//
|
||||||
// Additional header can be specified by the GLOG_BUILD_CONFIG_INCLUDE
|
// Additional header can be specified by the GLOG_BUILD_CONFIG_INCLUDE
|
||||||
// macro to add platform specific defines (e.g. OS_OPENBSD).
|
// macro to add platform specific defines (e.g. GLOG_OS_OPENBSD).
|
||||||
|
|
||||||
#ifdef GLOG_BUILD_CONFIG_INCLUDE
|
#ifdef GLOG_BUILD_CONFIG_INCLUDE
|
||||||
#include GLOG_BUILD_CONFIG_INCLUDE
|
#include GLOG_BUILD_CONFIG_INCLUDE
|
||||||
@ -113,7 +113,7 @@ _END_GOOGLE_NAMESPACE_
|
|||||||
#if defined(HAVE_DLFCN_H)
|
#if defined(HAVE_DLFCN_H)
|
||||||
#include <dlfcn.h>
|
#include <dlfcn.h>
|
||||||
#endif
|
#endif
|
||||||
#if defined(OS_OPENBSD)
|
#if defined(GLOG_OS_OPENBSD)
|
||||||
#include <sys/exec_elf.h>
|
#include <sys/exec_elf.h>
|
||||||
#else
|
#else
|
||||||
#include <elf.h>
|
#include <elf.h>
|
||||||
@ -132,7 +132,7 @@ _END_GOOGLE_NAMESPACE_
|
|||||||
|
|
||||||
#include "symbolize.h"
|
#include "symbolize.h"
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
#include "glog/raw_logging.h"
|
#include <glog/raw_logging.h>
|
||||||
|
|
||||||
// Re-runs fn until it doesn't cause EINTR.
|
// Re-runs fn until it doesn't cause EINTR.
|
||||||
#define NO_INTR(fn) do {} while ((fn) < 0 && errno == EINTR)
|
#define NO_INTR(fn) do {} while ((fn) < 0 && errno == EINTR)
|
||||||
@ -847,7 +847,7 @@ static ATTRIBUTE_NOINLINE bool SymbolizeAndDemangle(void *pc, char *out,
|
|||||||
|
|
||||||
_END_GOOGLE_NAMESPACE_
|
_END_GOOGLE_NAMESPACE_
|
||||||
|
|
||||||
#elif defined(OS_MACOSX) && defined(HAVE_DLADDR)
|
#elif defined(GLOG_OS_MACOSX) && defined(HAVE_DLADDR)
|
||||||
|
|
||||||
#include <dlfcn.h>
|
#include <dlfcn.h>
|
||||||
#include <cstring>
|
#include <cstring>
|
||||||
@ -872,7 +872,7 @@ static ATTRIBUTE_NOINLINE bool SymbolizeAndDemangle(void *pc, char *out,
|
|||||||
|
|
||||||
_END_GOOGLE_NAMESPACE_
|
_END_GOOGLE_NAMESPACE_
|
||||||
|
|
||||||
#elif defined(OS_WINDOWS) || defined(OS_CYGWIN)
|
#elif defined(GLOG_OS_WINDOWS) || defined(GLOG_OS_CYGWIN)
|
||||||
|
|
||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
#include <dbghelp.h>
|
#include <dbghelp.h>
|
||||||
|
|||||||
@ -56,7 +56,7 @@
|
|||||||
|
|
||||||
#include "utilities.h"
|
#include "utilities.h"
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
#include "glog/logging.h"
|
#include <glog/logging.h>
|
||||||
|
|
||||||
#ifdef HAVE_SYMBOLIZE
|
#ifdef HAVE_SYMBOLIZE
|
||||||
|
|
||||||
|
|||||||
@ -35,7 +35,7 @@
|
|||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
#include "glog/logging.h"
|
#include <glog/logging.h>
|
||||||
#include "googletest.h"
|
#include "googletest.h"
|
||||||
#include "symbolize.h"
|
#include "symbolize.h"
|
||||||
#include "utilities.h"
|
#include "utilities.h"
|
||||||
@ -52,7 +52,7 @@ using namespace GOOGLE_NAMESPACE;
|
|||||||
|
|
||||||
#define always_inline
|
#define always_inline
|
||||||
|
|
||||||
#if defined(__ELF__) || defined(OS_WINDOWS) || defined(OS_CYGWIN)
|
#if defined(__ELF__) || defined(GLOG_OS_WINDOWS) || defined(GLOG_OS_CYGWIN)
|
||||||
// A wrapper function for Symbolize() to make the unit test simple.
|
// A wrapper function for Symbolize() to make the unit test simple.
|
||||||
static const char *TrySymbolize(void *pc) {
|
static const char *TrySymbolize(void *pc) {
|
||||||
static char symbol[4096];
|
static char symbol[4096];
|
||||||
@ -360,7 +360,7 @@ static void ATTRIBUTE_NOINLINE TestWithReturnAddress() {
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
# elif defined(OS_WINDOWS) || defined(OS_CYGWIN)
|
# elif defined(GLOG_OS_WINDOWS) || defined(GLOG_OS_CYGWIN)
|
||||||
|
|
||||||
#ifdef _MSC_VER
|
#ifdef _MSC_VER
|
||||||
#include <intrin.h>
|
#include <intrin.h>
|
||||||
@ -412,10 +412,10 @@ int main(int argc, char **argv) {
|
|||||||
TestWithPCInsideNonInlineFunction();
|
TestWithPCInsideNonInlineFunction();
|
||||||
TestWithReturnAddress();
|
TestWithReturnAddress();
|
||||||
return RUN_ALL_TESTS();
|
return RUN_ALL_TESTS();
|
||||||
# elif defined(OS_WINDOWS) || defined(OS_CYGWIN)
|
# elif defined(GLOG_OS_WINDOWS) || defined(GLOG_OS_CYGWIN)
|
||||||
TestWithReturnAddress();
|
TestWithReturnAddress();
|
||||||
return RUN_ALL_TESTS();
|
return RUN_ALL_TESTS();
|
||||||
# else // OS_WINDOWS
|
# else // GLOG_OS_WINDOWS
|
||||||
printf("PASS (no symbolize_unittest support)\n");
|
printf("PASS (no symbolize_unittest support)\n");
|
||||||
return 0;
|
return 0;
|
||||||
# endif // __ELF__
|
# endif // __ELF__
|
||||||
|
|||||||
@ -161,7 +161,7 @@ static void DumpStackTraceAndExit() {
|
|||||||
sigemptyset(&sig_action.sa_mask);
|
sigemptyset(&sig_action.sa_mask);
|
||||||
sig_action.sa_handler = SIG_DFL;
|
sig_action.sa_handler = SIG_DFL;
|
||||||
sigaction(SIGABRT, &sig_action, NULL);
|
sigaction(SIGABRT, &sig_action, NULL);
|
||||||
#elif defined(OS_WINDOWS)
|
#elif defined(GLOG_OS_WINDOWS)
|
||||||
signal(SIGABRT, SIG_DFL);
|
signal(SIGABRT, SIG_DFL);
|
||||||
#endif // HAVE_SIGACTION
|
#endif // HAVE_SIGACTION
|
||||||
}
|
}
|
||||||
@ -186,7 +186,7 @@ const char* ProgramInvocationShortName() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef OS_WINDOWS
|
#ifdef GLOG_OS_WINDOWS
|
||||||
struct timeval {
|
struct timeval {
|
||||||
long tv_sec, tv_usec;
|
long tv_sec, tv_usec;
|
||||||
};
|
};
|
||||||
@ -249,9 +249,9 @@ bool PidHasChanged() {
|
|||||||
|
|
||||||
pid_t GetTID() {
|
pid_t GetTID() {
|
||||||
// On Linux and MacOSX, we try to use gettid().
|
// On Linux and MacOSX, we try to use gettid().
|
||||||
#if defined OS_LINUX || defined OS_MACOSX
|
#if defined GLOG_OS_LINUX || defined GLOG_OS_MACOSX
|
||||||
#ifndef __NR_gettid
|
#ifndef __NR_gettid
|
||||||
#ifdef OS_MACOSX
|
#ifdef GLOG_OS_MACOSX
|
||||||
#define __NR_gettid SYS_gettid
|
#define __NR_gettid SYS_gettid
|
||||||
#elif ! defined __i386__
|
#elif ! defined __i386__
|
||||||
#error "Must define __NR_gettid for non-x86 platforms"
|
#error "Must define __NR_gettid for non-x86 platforms"
|
||||||
@ -261,7 +261,7 @@ pid_t GetTID() {
|
|||||||
#endif
|
#endif
|
||||||
static bool lacks_gettid = false;
|
static bool lacks_gettid = false;
|
||||||
if (!lacks_gettid) {
|
if (!lacks_gettid) {
|
||||||
#if (defined(OS_MACOSX) && defined(HAVE_PTHREAD_THREADID_NP))
|
#if (defined(GLOG_OS_MACOSX) && defined(HAVE_PTHREAD_THREADID_NP))
|
||||||
uint64_t tid64;
|
uint64_t tid64;
|
||||||
const int error = pthread_threadid_np(NULL, &tid64);
|
const int error = pthread_threadid_np(NULL, &tid64);
|
||||||
pid_t tid = error ? -1 : static_cast<pid_t>(tid64);
|
pid_t tid = error ? -1 : static_cast<pid_t>(tid64);
|
||||||
@ -277,12 +277,12 @@ pid_t GetTID() {
|
|||||||
// the value change to "true".
|
// the value change to "true".
|
||||||
lacks_gettid = true;
|
lacks_gettid = true;
|
||||||
}
|
}
|
||||||
#endif // OS_LINUX || OS_MACOSX
|
#endif // GLOG_OS_LINUX || GLOG_OS_MACOSX
|
||||||
|
|
||||||
// If gettid() could not be used, we use one of the following.
|
// If gettid() could not be used, we use one of the following.
|
||||||
#if defined OS_LINUX
|
#if defined GLOG_OS_LINUX
|
||||||
return getpid(); // Linux: getpid returns thread ID when gettid is absent
|
return getpid(); // Linux: getpid returns thread ID when gettid is absent
|
||||||
#elif defined OS_WINDOWS && !defined OS_CYGWIN
|
#elif defined GLOG_OS_WINDOWS && !defined GLOG_OS_CYGWIN
|
||||||
return GetCurrentThreadId();
|
return GetCurrentThreadId();
|
||||||
#elif defined(HAVE_PTHREAD)
|
#elif defined(HAVE_PTHREAD)
|
||||||
// If none of the techniques above worked, we use pthread_self().
|
// If none of the techniques above worked, we use pthread_self().
|
||||||
@ -294,7 +294,7 @@ pid_t GetTID() {
|
|||||||
|
|
||||||
const char* const_basename(const char* filepath) {
|
const char* const_basename(const char* filepath) {
|
||||||
const char* base = strrchr(filepath, '/');
|
const char* base = strrchr(filepath, '/');
|
||||||
#ifdef OS_WINDOWS // Look for either path separator in Windows
|
#ifdef GLOG_OS_WINDOWS // Look for either path separator in Windows
|
||||||
if (!base)
|
if (!base)
|
||||||
base = strrchr(filepath, '\\');
|
base = strrchr(filepath, '\\');
|
||||||
#endif
|
#endif
|
||||||
@ -307,7 +307,7 @@ const string& MyUserName() {
|
|||||||
}
|
}
|
||||||
static void MyUserNameInitializer() {
|
static void MyUserNameInitializer() {
|
||||||
// TODO(hamaji): Probably this is not portable.
|
// TODO(hamaji): Probably this is not portable.
|
||||||
#if defined(OS_WINDOWS)
|
#if defined(GLOG_OS_WINDOWS)
|
||||||
const char* user = getenv("USERNAME");
|
const char* user = getenv("USERNAME");
|
||||||
#else
|
#else
|
||||||
const char* user = getenv("USER");
|
const char* user = getenv("USER");
|
||||||
@ -356,7 +356,7 @@ void InitGoogleLoggingUtilities(const char* argv0) {
|
|||||||
CHECK(!IsGoogleLoggingInitialized())
|
CHECK(!IsGoogleLoggingInitialized())
|
||||||
<< "You called InitGoogleLogging() twice!";
|
<< "You called InitGoogleLogging() twice!";
|
||||||
const char* slash = strrchr(argv0, '/');
|
const char* slash = strrchr(argv0, '/');
|
||||||
#ifdef OS_WINDOWS
|
#ifdef GLOG_OS_WINDOWS
|
||||||
if (!slash) slash = strrchr(argv0, '\\');
|
if (!slash) slash = strrchr(argv0, '\\');
|
||||||
#endif
|
#endif
|
||||||
g_program_invocation_short_name = slash ? slash + 1 : argv0;
|
g_program_invocation_short_name = slash ? slash + 1 : argv0;
|
||||||
|
|||||||
@ -34,26 +34,6 @@
|
|||||||
#ifndef UTILITIES_H__
|
#ifndef UTILITIES_H__
|
||||||
#define UTILITIES_H__
|
#define UTILITIES_H__
|
||||||
|
|
||||||
#if defined(WIN32) || defined(_WIN32) || defined(__WIN32__)
|
|
||||||
# define OS_WINDOWS
|
|
||||||
#elif defined(__CYGWIN__) || defined(__CYGWIN32__)
|
|
||||||
# define OS_CYGWIN
|
|
||||||
#elif defined(linux) || defined(__linux) || defined(__linux__)
|
|
||||||
# ifndef OS_LINUX
|
|
||||||
# define OS_LINUX
|
|
||||||
# endif
|
|
||||||
#elif defined(macintosh) || defined(__APPLE__) || defined(__APPLE_CC__)
|
|
||||||
# define OS_MACOSX
|
|
||||||
#elif defined(__FreeBSD__)
|
|
||||||
# define OS_FREEBSD
|
|
||||||
#elif defined(__NetBSD__)
|
|
||||||
# define OS_NETBSD
|
|
||||||
#elif defined(__OpenBSD__)
|
|
||||||
# define OS_OPENBSD
|
|
||||||
#else
|
|
||||||
// TODO(hamaji): Add other platforms.
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// printf macros for size_t, in the style of inttypes.h
|
// printf macros for size_t, in the style of inttypes.h
|
||||||
#ifdef _LP64
|
#ifdef _LP64
|
||||||
#define __PRIS_PREFIX "z"
|
#define __PRIS_PREFIX "z"
|
||||||
@ -76,12 +56,13 @@
|
|||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
#if defined(OS_WINDOWS)
|
#include <glog/logging.h>
|
||||||
|
|
||||||
|
#if defined(GLOG_OS_WINDOWS)
|
||||||
# include "port.h"
|
# include "port.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
#include "glog/logging.h"
|
|
||||||
|
|
||||||
// There are three different ways we can try to get the stack trace:
|
// There are three different ways we can try to get the stack trace:
|
||||||
//
|
//
|
||||||
@ -114,7 +95,7 @@
|
|||||||
# define STACKTRACE_H "stacktrace_x86_64-inl.h"
|
# define STACKTRACE_H "stacktrace_x86_64-inl.h"
|
||||||
# elif (defined(__ppc__) || defined(__PPC__)) && __GNUC__ >= 2
|
# elif (defined(__ppc__) || defined(__PPC__)) && __GNUC__ >= 2
|
||||||
# define STACKTRACE_H "stacktrace_powerpc-inl.h"
|
# define STACKTRACE_H "stacktrace_powerpc-inl.h"
|
||||||
# elif defined(OS_WINDOWS)
|
# elif defined(GLOG_OS_WINDOWS)
|
||||||
# define STACKTRACE_H "stacktrace_windows-inl.h"
|
# define STACKTRACE_H "stacktrace_windows-inl.h"
|
||||||
# endif
|
# endif
|
||||||
#endif
|
#endif
|
||||||
@ -130,12 +111,12 @@
|
|||||||
#ifndef GLOG_NO_SYMBOLIZE_DETECTION
|
#ifndef GLOG_NO_SYMBOLIZE_DETECTION
|
||||||
#ifndef HAVE_SYMBOLIZE
|
#ifndef HAVE_SYMBOLIZE
|
||||||
// defined by gcc
|
// defined by gcc
|
||||||
#if defined(__ELF__) && defined(OS_LINUX)
|
#if defined(__ELF__) && defined(GLOG_OS_LINUX)
|
||||||
# define HAVE_SYMBOLIZE
|
# define HAVE_SYMBOLIZE
|
||||||
#elif defined(OS_MACOSX) && defined(HAVE_DLADDR)
|
#elif defined(GLOG_OS_MACOSX) && defined(HAVE_DLADDR)
|
||||||
// Use dladdr to symbolize.
|
// Use dladdr to symbolize.
|
||||||
# define HAVE_SYMBOLIZE
|
# define HAVE_SYMBOLIZE
|
||||||
#elif defined(OS_WINDOWS)
|
#elif defined(GLOG_OS_WINDOWS)
|
||||||
// Use DbgHelp to symbolize
|
// Use DbgHelp to symbolize
|
||||||
# define HAVE_SYMBOLIZE
|
# define HAVE_SYMBOLIZE
|
||||||
#endif
|
#endif
|
||||||
@ -154,7 +135,7 @@ namespace glog_internal_namespace_ {
|
|||||||
#ifdef HAVE___ATTRIBUTE__
|
#ifdef HAVE___ATTRIBUTE__
|
||||||
# define ATTRIBUTE_NOINLINE __attribute__ ((noinline))
|
# define ATTRIBUTE_NOINLINE __attribute__ ((noinline))
|
||||||
# define HAVE_ATTRIBUTE_NOINLINE
|
# define HAVE_ATTRIBUTE_NOINLINE
|
||||||
#elif defined(OS_WINDOWS)
|
#elif defined(GLOG_OS_WINDOWS)
|
||||||
# define ATTRIBUTE_NOINLINE __declspec(noinline)
|
# define ATTRIBUTE_NOINLINE __declspec(noinline)
|
||||||
# define HAVE_ATTRIBUTE_NOINLINE
|
# define HAVE_ATTRIBUTE_NOINLINE
|
||||||
#else
|
#else
|
||||||
|
|||||||
@ -30,7 +30,7 @@
|
|||||||
// Author: Shinichiro Hamaji
|
// Author: Shinichiro Hamaji
|
||||||
#include "utilities.h"
|
#include "utilities.h"
|
||||||
#include "googletest.h"
|
#include "googletest.h"
|
||||||
#include "glog/logging.h"
|
#include <glog/logging.h>
|
||||||
|
|
||||||
#ifdef HAVE_LIB_GFLAGS
|
#ifdef HAVE_LIB_GFLAGS
|
||||||
#include <gflags/gflags.h>
|
#include <gflags/gflags.h>
|
||||||
|
|||||||
@ -40,8 +40,8 @@
|
|||||||
#include <cstdio>
|
#include <cstdio>
|
||||||
#include <string>
|
#include <string>
|
||||||
#include "base/commandlineflags.h"
|
#include "base/commandlineflags.h"
|
||||||
#include "glog/logging.h"
|
#include <glog/logging.h>
|
||||||
#include "glog/raw_logging.h"
|
#include <glog/raw_logging.h>
|
||||||
#include "base/googleinit.h"
|
#include "base/googleinit.h"
|
||||||
|
|
||||||
// glog doesn't have annotation
|
// glog doesn't have annotation
|
||||||
|
|||||||
@ -62,7 +62,7 @@
|
|||||||
* used by both C and C++ code, so we put all the C++ together.
|
* used by both C and C++ code, so we put all the C++ together.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "glog/logging.h"
|
#include <glog/logging.h>
|
||||||
|
|
||||||
#ifdef _MSC_VER
|
#ifdef _MSC_VER
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user