[glog] upgrade to v0.6 (#25312)

* glog upgrade

* tmp

* is glog initialized

* fix glog dependency

* fix glog dependency

* fix folly abort call

* delete buildtrees

* fix folly abort call

* delete useless lines

* fix caffe2 isglog initialized

* make patches shorter

* glog fix typo

* glog fix tab

* Remove cpp patch since we don't need it

* Revert 6b8759a860

Co-authored-by: JackBoosY <yuzaiyang@beyondsoft.com>
This commit is contained in:
Jia Yue Hua 2022-06-24 06:29:07 +08:00 committed by GitHub
parent 53456892f3
commit 078f136afc
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
27 changed files with 213 additions and 1009 deletions

View File

@ -0,0 +1,31 @@
diff --git a/caffe2/core/logging.cc b/caffe2/core/logging.cc
index 1379f3a..d1289db 100644
--- a/caffe2/core/logging.cc
+++ b/caffe2/core/logging.cc
@@ -120,17 +120,6 @@ using fLB::FLAGS_logtostderr;
CAFFE2_DEFINE_int(caffe2_log_level, google::GLOG_ERROR,
"The minimum log level that caffe2 will output.");
-// Google glog's api does not have an external function that allows one to check
-// if glog is initialized or not. It does have an internal function - so we are
-// declaring it here. This is a hack but has been used by a bunch of others too
-// (e.g. Torch).
-namespace google {
-namespace glog_internal_namespace_ {
-bool IsGoogleLoggingInitialized();
-} // namespace glog_internal_namespace_
-} // namespace google
-
-
namespace caffe2 {
bool InitCaffeLogging(int* argc, char** argv) {
if (*argc == 0) return true;
@@ -138,7 +127,7 @@ bool InitCaffeLogging(int* argc, char** argv) {
// IsGoogleLoggingInitialized is not exported from the glog DLL
// so we can't call it. If our program calls InitGoogleLogging twice glog will
// abort it.
- if (!::google::glog_internal_namespace_::IsGoogleLoggingInitialized())
+ if (!::google::IsGoogleLoggingInitialized())
#endif
{
::google::InitGoogleLogging(argv[0]);

View File

@ -11,6 +11,7 @@ vcpkg_from_github(
fix-space.patch
fix-protobuf-deprecated.patch
no-inout-macros.patch
fix-isgloginitialized.patch
)
if(VCPKG_CRT_LINKAGE STREQUAL static)

View File

@ -1,7 +1,7 @@
{
"name": "caffe2",
"version": "0.8.1",
"port-version": 6,
"port-version": 7,
"description": "Caffe2 is a lightweight, modular, and scalable deep learning framework.",
"homepage": "https://github.com/caffe2/caffe2",
"license": "Apache-2.0",

View File

@ -0,0 +1,31 @@
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 47eb0a6..d325df7 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -53,7 +53,9 @@ if (UNIX)
list(APPEND DEPENDENT_INCLUDE_DIRS "${GLOG_INCLUDE_DIRS}/../")
SET(DEPENDENT_LIBRARIES libevent::core libevent::extra libevent::openssl glog::glog pthread)
else (UNIX)
- SET(DEPENDENT_LIBRARIES event glog)
+ find_package(glog CONFIG REQUIRED)
+ find_package(Libevent CONFIG REQUIRED)
+ SET(DEPENDENT_LIBRARIES libevent::core libevent::extra libevent::openssl glog::glog)
endif (UNIX)
if (CMAKE_BENCHMARK_TESTING)
diff --git a/evpp/CMakeLists.txt b/evpp/CMakeLists.txt
index b2e470d..031659f 100644
--- a/evpp/CMakeLists.txt
+++ b/evpp/CMakeLists.txt
@@ -15,9 +15,11 @@ include_directories(${PROJECT_SOURCE_DIR})
add_library(evpp_static STATIC ${evpp_SRCS})
target_link_libraries(evpp_static ${DEPENDENT_LIBRARIES})
+target_compile_features(evpp_static PRIVATE cxx_std_11)
add_library(evpp_lite_static STATIC ${evpp_lite_SRCS})
target_link_libraries(evpp_lite_static ${DEPENDENT_LIBRARIES})
+target_compile_features(evpp_lite_static PRIVATE cxx_std_11)
if (UNIX)
add_library(evpp SHARED ${evpp_SRCS})

View File

@ -10,6 +10,7 @@ vcpkg_from_github(
fix-rapidjson-1-1.patch
fix-linux-build.patch
fix-osx-build.patch
compile-features.patch
)
file(REMOVE_RECURSE ${SOURCE_PATH}/3rdparty/rapidjson ${SOURCE_PATH}/3rdparty/concurrentqueue)

View File

@ -1,7 +1,7 @@
{
"name": "evpp",
"version-string": "0.7.0",
"port-version": 5,
"version": "0.7.0",
"port-version": 6,
"description": "A modern C++ network library based on libevent for developing high performance network services in TCP/UDP/HTTP protocols.",
"homepage": "https://github.com/Qihoo360/evpp",
"dependencies": [

View File

@ -0,0 +1,14 @@
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 7b248a0..beae7d7 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -101,7 +101,8 @@ endif ()
# Find required dependencies for thrift/lib
if(lib_only OR build_all)
find_package(Gflags REQUIRED)
- find_package(Glog REQUIRED)
+ find_package(glog CONFIG REQUIRED)
+ set (GLOG_LIBRARIES glog::glog)
find_package(folly CONFIG REQUIRED)
find_package(fizz CONFIG REQUIRED)
find_package(fmt CONFIG REQUIRED)

View File

@ -7,7 +7,9 @@ vcpkg_from_github(
REF v2022.03.21.00
SHA512 8d2d9430dc3a4ecc23042cd9bcf4eee888824449d05d98baec408aef806b934d643e578d3876169f69966c846aeddbe0aa84416c4e020cba028a49d2fccfe7ab
HEAD_REF master
PATCHES 0001-fix-compatibility-with-boost-1.79.0.patch
PATCHES
0001-fix-compatibility-with-boost-1.79.0.patch
fix-glog.patch
)
vcpkg_cmake_configure(

View File

@ -1,7 +1,7 @@
{
"name": "fbthrift",
"version-string": "2022.03.21.00",
"port-version": 1,
"port-version": 2,
"description": "Facebook's branch of Apache Thrift, including a new C++ server.",
"homepage": "https://github.com/facebook/fbthrift",
"license": "Apache-2.0",

View File

@ -0,0 +1,38 @@
diff --git a/folly/init/Init.cpp b/folly/init/Init.cpp
index 66ca5cc..2302f10 100644
--- a/folly/init/Init.cpp
+++ b/folly/init/Init.cpp
@@ -47,6 +47,24 @@ void init(int* argc, char*** argv, bool removeFlags) {
init(argc, argv, options);
}
+#if FOLLY_USE_SYMBOLIZER
+// Newer versions of glog require the function passed to InstallFailureFunction
+// to be noreturn. But glog spells that in multiple possible ways, depending on
+// platform. But glog's choice of spelling does not match how the
+// noreturn-ability of std::abort is spelled. Some compilers consider this a
+// type mismatch on the function-ptr type. To fix the type mismatch, we wrap
+// std::abort and mimic the condition and the spellings from glog here.
+#if defined(__GNUC__)
+__attribute__((noreturn))
+#else
+[[noreturn]]
+#endif
+static void
+wrapped_abort() {
+ abort();
+}
+#endif
+
void init(int* argc, char*** argv, InitOptions options) {
#if !defined(_WIN32) && !defined(__XROS__)
// Install the handler now, to trap errors received during startup.
@@ -76,7 +94,7 @@ void init(int* argc, char*** argv, InitOptions options) {
#if FOLLY_USE_SYMBOLIZER
// Don't use glog's DumpStackTraceAndExit; rely on our signal handler.
- google::InstallFailureFunction(abort);
+ google::InstallFailureFunction(wrapped_abort);
// Actually install the callbacks into the handler.
folly::symbolizer::installFatalSignalCallbacks();

View File

@ -16,6 +16,7 @@ vcpkg_from_github(
disable-non-underscore-posix-names.patch
boost-1.70.patch
fix-windows-minmax.patch
fix-abort.patch
)
file(COPY

View File

@ -1,6 +1,7 @@
{
"name": "folly",
"version-string": "2022.03.21.00",
"port-version": 1,
"description": "An open-source C++ library developed and used at Facebook. The library is UNSTABLE on Windows",
"homepage": "https://github.com/facebook/folly",
"license": "Apache-2.0",

View File

@ -1,17 +0,0 @@
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 13c474b..7858c8f 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -398,6 +398,12 @@ if (HAVE_EXECINFO_H)
set (HAVE_STACKTRACE 1)
endif (HAVE_EXECINFO_H)
+if (HAVE_CXX11_ATOMIC)
+ set (ac_cv_cxx11_atomic 1)
+else ()
+ set (ac_cv_cxx11_atomic 0)
+endif ()
+
if (WITH_SYMBOLIZE)
if (WIN32 OR CYGWIN)
if(CMAKE_CROSSCOMPILING)

View File

@ -1,58 +0,0 @@
diff --git a/src/glog/logging.h.in b/src/glog/logging.h.in
index 3ecacfb..ef10284 100644
--- a/src/glog/logging.h.in
+++ b/src/glog/logging.h.in
@@ -100,7 +100,7 @@
#include <gflags/gflags.h>
#endif
-#ifdef HAVE_CXX11_ATOMIC
+#if @ac_cv_cxx11_atomic@
#include <atomic>
#elif defined(GLOG_OS_WINDOWS)
#include <Windows.h>
@@ -1014,7 +1014,7 @@ extern "C" void AnnotateBenignRaceSized(
namespace google {
#endif
-#ifdef HAVE_CXX11_ATOMIC
+#if @ac_cv_cxx11_atomic@
#define SOME_KIND_OF_LOG_EVERY_N(severity, n, what_to_do) \
static std::atomic<int> LOG_OCCURRENCES(0), LOG_OCCURRENCES_MOD_N(0); \
_GLOG_IFDEF_THREAD_SANITIZER(AnnotateBenignRaceSized(__FILE__, __LINE__, &LOG_OCCURRENCES, sizeof(int), "")); \
@@ -1061,7 +1061,7 @@ namespace google {
#elif defined(GLOG_OS_WINDOWS)
#define SOME_KIND_OF_LOG_EVERY_N(severity, n, what_to_do) \
- static int LOG_OCCURRENCES = 0, LOG_OCCURRENCES_MOD_N = 0; \
+ static volatile unsigned LOG_OCCURRENCES = 0, LOG_OCCURRENCES_MOD_N = 0; \
InterlockedIncrement(&LOG_OCCURRENCES); \
if (InterlockedIncrement(&LOG_OCCURRENCES_MOD_N) > n) \
InterlockedExchangeSubtract(&LOG_OCCURRENCES_MOD_N, n); \
@@ -1071,7 +1071,7 @@ namespace google {
&what_to_do).stream()
#define SOME_KIND_OF_LOG_IF_EVERY_N(severity, condition, n, what_to_do) \
- static int LOG_OCCURRENCES = 0, LOG_OCCURRENCES_MOD_N = 0; \
+ static volatile unsigned LOG_OCCURRENCES = 0, LOG_OCCURRENCES_MOD_N = 0; \
InterlockedIncrement(&LOG_OCCURRENCES); \
if (condition && \
(InterlockedIncrement(&LOG_OCCURRENCES_MOD_N) || true) && \
@@ -1082,7 +1082,7 @@ namespace google {
&what_to_do).stream()
#define SOME_KIND_OF_PLOG_EVERY_N(severity, n, what_to_do) \
- static int LOG_OCCURRENCES = 0, LOG_OCCURRENCES_MOD_N = 0; \
+ static volatile unsigned LOG_OCCURRENCES = 0, LOG_OCCURRENCES_MOD_N = 0; \
InterlockedIncrement(&LOG_OCCURRENCES); \
if (InterlockedIncrement(&LOG_OCCURRENCES_MOD_N) > n) \
InterlockedExchangeSubtract(&LOG_OCCURRENCES_MOD_N, n); \
@@ -1092,7 +1092,7 @@ namespace google {
&what_to_do).stream()
#define SOME_KIND_OF_LOG_FIRST_N(severity, n, what_to_do) \
- static int LOG_OCCURRENCES = 0; \
+ static volatile unsigned LOG_OCCURRENCES = 0; \
if (LOG_OCCURRENCES <= n) \
InterlockedIncrement(&LOG_OCCURRENCES); \
if (LOG_OCCURRENCES <= n) \

View File

@ -0,0 +1,15 @@
diff --git a/CMakeLists.txt b/CMakeLists.txt
index d145517..681b791 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -669,6 +669,10 @@ if (CYGWIN OR WIN32)
target_compile_definitions (glog PUBLIC GLOG_NO_ABBREVIATED_SEVERITIES)
endif (CYGWIN OR WIN32)
+if ((MSVC) AND (MSVC_VERSION GREATER_EQUAL 1914))
+ target_compile_options(glog INTERFACE "/Zc:__cplusplus")
+endif()
+
if (WITH_CUSTOM_PREFIX)
target_compile_definitions (glog PUBLIC GLOG_CUSTOM_PREFIX_SUPPORT)
endif (WITH_CUSTOM_PREFIX)

View File

@ -1,6 +1,9 @@
diff --git a/CMakeLists.txt b/CMakeLists.txt
index d314abe..d145517 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -401,4 +401,7 @@
@@ -450,6 +450,9 @@ endif (HAVE_CXX11_ATOMIC)
if (WITH_SYMBOLIZE)
if (WIN32 OR CYGWIN)
+ if(CMAKE_CROSSCOMPILING)
@ -8,11 +11,12 @@
+ else()
cmake_push_check_state (RESET)
set (CMAKE_REQUIRED_LIBRARIES DbgHelp)
@@ -430,6 +433,7 @@
@@ -480,6 +483,7 @@ if (WITH_SYMBOLIZE)
]=] HAVE_SYMBOLIZE)
cmake_pop_check_state ()
+ endif()
if (HAVE_SYMBOLIZE)
set (HAVE_STACKTRACE 1)

View File

@ -1,44 +1,24 @@
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 28e2688..cf87798 100644
index 846b444..20441d1 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -843,36 +843,6 @@ write_basic_package_version_file (
@@ -1027,7 +1027,7 @@ write_basic_package_version_file (
export (TARGETS glog NAMESPACE glog:: FILE glog-targets.cmake)
export (PACKAGE glog)
-
+if(0)
get_filename_component (_PREFIX "${CMAKE_INSTALL_PREFIX}" ABSOLUTE)
# Directory containing the find modules relative to the config install
@@ -1063,6 +1063,7 @@ file (INSTALL
"
COMPONENT Development
)
+endif()
-get_filename_component (_PREFIX "${CMAKE_INSTALL_PREFIX}" ABSOLUTE)
-
-# Directory containing the find modules relative to the config install
-# directory.
-file (RELATIVE_PATH glog_REL_CMake_MODULES
- ${_PREFIX}/${_glog_CMake_INSTALLDIR}
- ${_PREFIX}/${_glog_CMake_DATADIR}/glog-modules.cmake)
-
-get_filename_component (glog_REL_CMake_DATADIR ${glog_REL_CMake_MODULES}
- DIRECTORY)
-
-set (glog_FULL_CMake_DATADIR
- ${CMAKE_CURRENT_BINARY_DIR}/${_glog_CMake_DATADIR})
-
-configure_file (glog-modules.cmake.in
- ${CMAKE_CURRENT_BINARY_DIR}/glog-modules.cmake @ONLY)
-
-install (CODE
-"
-set (glog_FULL_CMake_DATADIR \"\\\${CMAKE_CURRENT_LIST_DIR}/${glog_REL_CMake_DATADIR}\")
-configure_file (\"${CMAKE_CURRENT_SOURCE_DIR}/glog-modules.cmake.in\"
- \"${CMAKE_CURRENT_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/glog-modules.cmake\" @ONLY)
-file (INSTALL
- \"${CMAKE_CURRENT_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/glog-modules.cmake\"
- DESTINATION
- \"\${CMAKE_INSTALL_PREFIX}/${_glog_CMake_INSTALLDIR}\")
-"
- COMPONENT Development
-)
-
install (FILES
${CMAKE_CURRENT_BINARY_DIR}/glog-config.cmake
${CMAKE_CURRENT_BINARY_DIR}/glog-config-version.cmake
diff --git a/glog-config.cmake.in b/glog-config.cmake.in
index 5c5c9c0..31fac52 100644
--- a/glog-config.cmake.in
@ -51,27 +31,3 @@ index 5c5c9c0..31fac52 100644
@gflags_DEPENDENCY@
@Unwind_DEPENDENCY@
diff --git a/glog-modules.cmake.in b/glog-modules.cmake.in
deleted file mode 100644
index 71c5160..0000000
--- a/glog-modules.cmake.in
+++ /dev/null
@@ -1,18 +0,0 @@
-cmake_policy (PUSH)
-cmake_policy (SET CMP0057 NEW)
-
-if (CMAKE_VERSION VERSION_LESS 3.3)
- message (FATAL_ERROR "glog-modules.cmake requires the consumer "
- "to use CMake 3.3 (or newer)")
-endif (CMAKE_VERSION VERSION_LESS 3.3)
-
-set (glog_MODULE_PATH "@glog_FULL_CMake_DATADIR@")
-list (APPEND CMAKE_MODULE_PATH ${glog_MODULE_PATH})
-
-if (NOT glog_MODULE_PATH IN_LIST CMAKE_MODULE_PATH)
- message (FATAL_ERROR "Cannot add '${glog_MODULE_PATH}' to "
- "CMAKE_MODULE_PATH. This will cause glog-config.cmake to fail at "
- "locating required find modules. Make sure CMAKE_MODULE_PATH is not a cache variable.")
-endif (NOT glog_MODULE_PATH IN_LIST CMAKE_MODULE_PATH)
-
-cmake_policy (POP)

View File

@ -1,839 +0,0 @@
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 61e5f6c..889df87 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -501,6 +501,7 @@ set (GLOG_PUBLIC_H
${CMAKE_CURRENT_BINARY_DIR}/glog/stl_logging.h
${CMAKE_CURRENT_BINARY_DIR}/glog/vlog_is_on.h
src/glog/log_severity.h
+ src/glog/platform.h
)
set (GLOG_SRCS
diff --git a/src/demangle.cc b/src/demangle.cc
index f3e6ad7..8c0bdc7 100644
--- a/src/demangle.cc
+++ b/src/demangle.cc
@@ -38,14 +38,14 @@
#include "utilities.h"
#include "demangle.h"
-#if defined(OS_WINDOWS)
+#if defined(GLOG_OS_WINDOWS)
#include <dbghelp.h>
#pragma comment(lib, "dbghelp")
#endif
_START_GOOGLE_NAMESPACE_
-#if !defined(OS_WINDOWS)
+#if !defined(GLOG_OS_WINDOWS)
typedef struct {
const char *abbrev;
const char *real_name;
@@ -1324,7 +1324,7 @@ static bool ParseTopLevelMangledName(State *state) {
// The demangler entry point.
bool Demangle(const char *mangled, char *out, int out_size) {
-#if defined(OS_WINDOWS)
+#if defined(GLOG_OS_WINDOWS)
// When built with incremental linking, the Windows debugger
// library provides a more complicated `Symbol->Name` with the
// Incremental Linking Table offset, which looks like
diff --git a/src/demangle_unittest.cc b/src/demangle_unittest.cc
index be48341..c65adc4 100644
--- a/src/demangle_unittest.cc
+++ b/src/demangle_unittest.cc
@@ -62,7 +62,7 @@ static const char *DemangleIt(const char * const mangled) {
}
}
-#if defined(OS_WINDOWS)
+#if defined(GLOG_OS_WINDOWS)
TEST(Demangle, Windows) {
EXPECT_STREQ(
diff --git a/src/glog/logging.h.in b/src/glog/logging.h.in
index 421f1e0..3ecacfb 100644
--- a/src/glog/logging.h.in
+++ b/src/glog/logging.h.in
@@ -35,7 +35,6 @@
//
#ifndef _LOGGING_H_
#define _LOGGING_H_
-
#include <cerrno>
#include <cstddef>
#include <cstring>
@@ -58,6 +57,8 @@
#define GLOG_MSVC_POP_WARNING()
#endif
+#include <glog/platform.h>
+
#if @ac_cv_have_glog_export@
#include "glog/export.h"
#endif
@@ -101,7 +102,7 @@
#ifdef HAVE_CXX11_ATOMIC
#include <atomic>
-#elif defined(OS_WINDOWS)
+#elif defined(GLOG_OS_WINDOWS)
#include <Windows.h>
#endif
@@ -1057,7 +1058,7 @@ namespace google {
__FILE__, __LINE__, @ac_google_namespace@::GLOG_ ## severity, LOG_OCCURRENCES, \
&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) \
static int LOG_OCCURRENCES = 0, LOG_OCCURRENCES_MOD_N = 0; \
diff --git a/src/glog/platform.h b/src/glog/platform.h
new file mode 100644
index 0000000..e614411
--- /dev/null
+++ b/src/glog/platform.h
@@ -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
diff --git a/src/googletest.h b/src/googletest.h
index 7230606..a7ce3c2 100644
--- a/src/googletest.h
+++ b/src/googletest.h
@@ -72,7 +72,7 @@ _END_GOOGLE_NAMESPACE_
#define GOOGLE_GLOG_DLL_DECL
static inline string GetTempDir() {
-#ifndef OS_WINDOWS
+#ifndef GLOG_OS_WINDOWS
return "/tmp";
#else
char tmp[MAX_PATH];
@@ -81,7 +81,7 @@ static inline string GetTempDir() {
#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>
// (e.g., glog/vsproject/logging_unittest).
static const char TEST_SRC_DIR[] = "../..";
@@ -207,7 +207,7 @@ static inline void CalledAbort() {
longjmp(g_jmp_buf, 1);
}
-#ifdef OS_WINDOWS
+#ifdef GLOG_OS_WINDOWS
// TODO(hamaji): Death test somehow doesn't work in Windows.
#define ASSERT_DEATH(fn, msg)
#else
@@ -490,7 +490,7 @@ static inline bool MungeAndDiffTestStderr(const string& golden_filename) {
WriteToFile(golden, munged_golden);
string munged_captured = cap->filename() + ".munged";
WriteToFile(captured, munged_captured);
-#ifdef OS_WINDOWS
+#ifdef GLOG_OS_WINDOWS
string diffcmd("fc " + munged_golden + " " + munged_captured);
#else
string diffcmd("diff -u " + munged_golden + " " + munged_captured);
@@ -532,7 +532,7 @@ class Thread {
virtual ~Thread() {}
void SetJoinable(bool) {}
-#if defined(OS_WINDOWS) && !defined(OS_CYGWIN)
+#if defined(GLOG_OS_WINDOWS) && !defined(GLOG_OS_CYGWIN)
void Start() {
handle_ = CreateThread(NULL,
0,
@@ -565,7 +565,7 @@ class Thread {
return NULL;
}
-#if defined(OS_WINDOWS) && !defined(OS_CYGWIN)
+#if defined(GLOG_OS_WINDOWS) && !defined(GLOG_OS_CYGWIN)
HANDLE handle_;
DWORD th_;
#else
@@ -574,7 +574,7 @@ class Thread {
};
static inline void SleepForMilliseconds(int t) {
-#ifndef OS_WINDOWS
+#ifndef GLOG_OS_WINDOWS
# if defined(_POSIX_C_SOURCE) && _POSIX_C_SOURCE >= 199309L
const struct timespec req = {0, t * 1000 * 1000};
nanosleep(&req, NULL);
diff --git a/src/logging.cc b/src/logging.cc
index 71de91d..f251d67 100644
--- a/src/logging.cc
+++ b/src/logging.cc
@@ -59,7 +59,7 @@
#include <vector>
#include <cerrno> // for errno
#include <sstream>
-#ifdef OS_WINDOWS
+#ifdef GLOG_OS_WINDOWS
#include "windows/dirent.h"
#else
#include <dirent.h> // for automatic removal of old logs
@@ -122,7 +122,7 @@ GLOG_DEFINE_bool(alsologtostderr, BoolFromEnv("GOOGLE_ALSOLOGTOSTDERR", false),
"log messages go to stderr in addition to logfiles");
GLOG_DEFINE_bool(colorlogtostderr, false,
"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. "
"Logs can grow very quickly and they are rarely read before they "
"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 '/'
#ifndef HAVE_PREAD
-#if defined(OS_WINDOWS)
+#if defined(GLOG_OS_WINDOWS)
#include <basetsd.h>
#define ssize_t SSIZE_T
#endif
@@ -241,7 +241,7 @@ static void GetHostName(string* hostname) {
*buf.nodename = '\0';
}
*hostname = buf.nodename;
-#elif defined(OS_WINDOWS)
+#elif defined(GLOG_OS_WINDOWS)
char buf[MAX_COMPUTERNAME_LENGTH + 1];
DWORD len = MAX_COMPUTERNAME_LENGTH + 1;
if (GetComputerNameA(buf, &len)) {
@@ -258,7 +258,7 @@ static void GetHostName(string* hostname) {
// Returns true iff terminal supports using colors in output.
static bool TerminalSupportsColor() {
bool term_supports_color = false;
-#ifdef OS_WINDOWS
+#ifdef GLOG_OS_WINDOWS
// on Windows TERM variable is usually not set, but the console does
// support colors.
term_supports_color = true;
@@ -312,7 +312,7 @@ static GLogColor SeverityToColor(LogSeverity severity) {
return color;
}
-#ifdef OS_WINDOWS
+#ifdef GLOG_OS_WINDOWS
// Returns the character attribute for the given color.
static WORD GetColorAttribute(GLogColor color) {
@@ -337,7 +337,7 @@ static const char* GetAnsiColorCode(GLogColor color) {
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
static int32 MaxLogSize() {
@@ -753,7 +753,7 @@ static void ColoredWriteToStderr(LogSeverity severity,
fwrite(message, len, 1, stderr);
return;
}
-#ifdef OS_WINDOWS
+#ifdef GLOG_OS_WINDOWS
const HANDLE stderr_handle = GetStdHandle(STD_ERROR_HANDLE);
// Gets the current text color.
@@ -775,7 +775,7 @@ static void ColoredWriteToStderr(LogSeverity severity,
fprintf(stderr, "\033[0;3%sm", GetAnsiColorCode(color));
fwrite(message, len, 1, stderr);
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) {
@@ -788,7 +788,7 @@ inline void LogDestination::MaybeLogToStderr(LogSeverity severity,
const char* message, size_t message_len, size_t prefix_len) {
if ((severity >= FLAGS_stderrthreshold) || FLAGS_alsologtostderr) {
ColoredWriteToStderr(severity, message, message_len);
-#ifdef OS_WINDOWS
+#ifdef GLOG_OS_WINDOWS
// On Windows, also output to the debugger
::OutputDebugStringA(message);
#elif defined(__ANDROID__)
@@ -1056,7 +1056,7 @@ bool LogFileObject::CreateLogfile(const string& time_pid_string) {
}
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
// empirically replicated with wine over mingw build
if (!FLAGS_timestamp_in_logfile_name) {
@@ -1080,7 +1080,7 @@ bool LogFileObject::CreateLogfile(const string& time_pid_string) {
linkpath += linkname;
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?
#elif defined(HAVE_UNISTD_H)
// We must have unistd.h.
@@ -1270,7 +1270,7 @@ void LogFileObject::Write(bool force_flush,
(bytes_since_flush_ >= 1000000) ||
(CycleClock_Now() >= next_flush_time_) ) {
FlushUnlocked();
-#ifdef OS_LINUX
+#ifdef GLOG_OS_LINUX
// Only consider files >= 3MiB
if (FLAGS_drop_log_memory && file_length_ >= (3 << 20)) {
// Don't evict the most recent 1-2MiB so as not to impact a tailer
@@ -1305,7 +1305,7 @@ void LogFileObject::Write(bool force_flush,
LogCleaner::LogCleaner() : enabled_(false), overdue_days_(7), dir_delim_('/') {
-#ifdef OS_WINDOWS
+#ifdef GLOG_OS_WINDOWS
dir_delim_ = '\\';
#endif
}
@@ -1898,7 +1898,7 @@ void LogMessage::RecordCrashReason(
# define ATTRIBUTE_NORETURN
#endif
-#if defined(OS_WINDOWS)
+#if defined(GLOG_OS_WINDOWS)
__declspec(noreturn)
#endif
static void logging_fail() ATTRIBUTE_NORETURN;
@@ -2223,7 +2223,7 @@ bool SendEmail(const char*dest, const char *subject, const char*body){
static void GetTempDirectories(vector<string>* list) {
list->clear();
-#ifdef OS_WINDOWS
+#ifdef GLOG_OS_WINDOWS
// On windows we'll try to find a directory in this order:
// C:/Documents & Settings/whomever/TEMP (or whatever GetTempPath() is)
// C:/TMP/
@@ -2282,7 +2282,7 @@ const vector<string>& GetLoggingDirectories() {
logging_directories_list->push_back(FLAGS_log_dir.c_str());
} else {
GetTempDirectories(logging_directories_list);
-#ifdef OS_WINDOWS
+#ifdef GLOG_OS_WINDOWS
char tmp[MAX_PATH];
if (GetWindowsDirectoryA(tmp, MAX_PATH))
logging_directories_list->push_back(tmp);
@@ -2325,7 +2325,7 @@ void TruncateLogFile(const char *path, int64 limit, int64 keep) {
// Don't follow symlinks unless they're our own fd symlinks in /proc
int flags = O_RDWR;
// TODO(hamaji): Support other environments.
-#ifdef OS_LINUX
+#ifdef GLOG_OS_LINUX
const char *procfd_prefix = "/proc/self/fd/";
if (strncmp(procfd_prefix, path, strlen(procfd_prefix))) flags |= O_NOFOLLOW;
#endif
@@ -2464,7 +2464,7 @@ int posix_strerror_r(int err, char *buf, size_t len) {
return 0;
} else {
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) {
// This means an error on MacOSX or FreeBSD.
return -1;
diff --git a/src/logging_custom_prefix_unittest.cc b/src/logging_custom_prefix_unittest.cc
index c9fb5b8..8740fad 100644
--- a/src/logging_custom_prefix_unittest.cc
+++ b/src/logging_custom_prefix_unittest.cc
@@ -588,7 +588,7 @@ void TestCHECK() {
// Tests using CHECK*() on anonymous enums.
// Apple's GCC doesn't like this.
-#if !defined(OS_MACOSX)
+#if !defined(GLOG_OS_MACOSX)
CHECK_EQ(CASE_A, CASE_A);
CHECK_NE(CASE_A, CASE_B);
CHECK_GE(CASE_A, CASE_A);
@@ -670,7 +670,7 @@ static void GetFiles(const string& pattern, vector<string>* files) {
files->push_back(string(g.gl_pathv[i]));
}
globfree(&g);
-#elif defined(OS_WINDOWS)
+#elif defined(GLOG_OS_WINDOWS)
WIN32_FIND_DATAA data;
HANDLE handle = FindFirstFileA(pattern.c_str(), &data);
size_t index = pattern.rfind('\\');
@@ -799,7 +799,7 @@ static void TestTwoProcessesWrite() {
}
static void TestSymlink() {
-#ifndef OS_WINDOWS
+#ifndef GLOG_OS_WINDOWS
fprintf(stderr, "==== Test setting log file symlink\n");
string dest = FLAGS_test_tmpdir + "/logging_test_symlink";
string sym = FLAGS_test_tmpdir + "/symlinkbase";
@@ -942,7 +942,7 @@ static void TestTruncate() {
// MacOSX 10.4 doesn't fail in this case.
// Windows doesn't have symlink.
// 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
string linkname = path + ".link";
unlink(linkname.c_str());
@@ -951,7 +951,7 @@ static void TestTruncate() {
#endif
// 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
int fd;
CHECK_ERR(fd = open(path.c_str(), O_APPEND | O_WRONLY));
@@ -1205,7 +1205,7 @@ TEST(Strerror, logging) {
CHECK_EQ(posix_strerror_r(errcode, buf, 0), -1);
CHECK_EQ(buf[0], 'A');
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
// no enough space.
CHECK_EQ(posix_strerror_r(errcode, buf, 1), -1);
diff --git a/src/logging_unittest.cc b/src/logging_unittest.cc
index edc7d35..ce3c483 100644
--- a/src/logging_unittest.cc
+++ b/src/logging_unittest.cc
@@ -561,7 +561,7 @@ void TestCHECK() {
// Tests using CHECK*() on anonymous enums.
// Apple's GCC doesn't like this.
-#if !defined(OS_MACOSX)
+#if !defined(GLOG_OS_MACOSX)
CHECK_EQ(CASE_A, CASE_A);
CHECK_NE(CASE_A, CASE_B);
CHECK_GE(CASE_A, CASE_A);
@@ -643,7 +643,7 @@ static void GetFiles(const string& pattern, vector<string>* files) {
files->push_back(string(g.gl_pathv[i]));
}
globfree(&g);
-#elif defined(OS_WINDOWS)
+#elif defined(GLOG_OS_WINDOWS)
WIN32_FIND_DATAA data;
HANDLE handle = FindFirstFileA(pattern.c_str(), &data);
size_t index = pattern.rfind('\\');
@@ -772,7 +772,7 @@ static void TestTwoProcessesWrite() {
}
static void TestSymlink() {
-#ifndef OS_WINDOWS
+#ifndef GLOG_OS_WINDOWS
fprintf(stderr, "==== Test setting log file symlink\n");
string dest = FLAGS_test_tmpdir + "/logging_test_symlink";
string sym = FLAGS_test_tmpdir + "/symlinkbase";
@@ -915,7 +915,7 @@ static void TestTruncate() {
// MacOSX 10.4 doesn't fail in this case.
// Windows doesn't have symlink.
// 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
string linkname = path + ".link";
unlink(linkname.c_str());
@@ -924,7 +924,7 @@ static void TestTruncate() {
#endif
// 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
int fd;
CHECK_ERR(fd = open(path.c_str(), O_APPEND | O_WRONLY));
@@ -1178,7 +1178,7 @@ TEST(Strerror, logging) {
CHECK_EQ(posix_strerror_r(errcode, buf, 0), -1);
CHECK_EQ(buf[0], 'A');
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
// no enough space.
CHECK_EQ(posix_strerror_r(errcode, buf, 1), -1);
diff --git a/src/signalhandler.cc b/src/signalhandler.cc
index b6d6e25..ababf86 100644
--- a/src/signalhandler.cc
+++ b/src/signalhandler.cc
@@ -63,7 +63,7 @@ const struct {
{ SIGILL, "SIGILL" },
{ SIGFPE, "SIGFPE" },
{ SIGABRT, "SIGABRT" },
-#if !defined(OS_WINDOWS)
+#if !defined(GLOG_OS_WINDOWS)
{ SIGBUS, "SIGBUS" },
#endif
{ SIGTERM, "SIGTERM" },
@@ -208,7 +208,7 @@ void DumpSignalInfo(int signal_number, siginfo_t *siginfo) {
formatter.AppendUint64((uintptr_t)pthread_self(), 16);
formatter.AppendString(") ");
// Only linux has the PID of the signal sender in si_pid.
-#ifdef OS_LINUX
+#ifdef GLOG_OS_LINUX
formatter.AppendString("from PID ");
formatter.AppendUint64(siginfo->si_pid, 10);
formatter.AppendString("; ");
@@ -253,7 +253,7 @@ void InvokeDefaultSignalHandler(int signal_number) {
sig_action.sa_handler = SIG_DFL;
sigaction(signal_number, &sig_action, NULL);
kill(getpid(), signal_number);
-#elif defined(OS_WINDOWS)
+#elif defined(GLOG_OS_WINDOWS)
signal(signal_number, SIG_DFL);
raise(signal_number);
#endif
@@ -267,7 +267,7 @@ static pthread_t* g_entered_thread_id_pointer = NULL;
// Dumps signal and stack frame information, and invokes the default
// signal handler once our job is done.
-#if defined(OS_WINDOWS)
+#if defined(GLOG_OS_WINDOWS)
void FailureSignalHandler(int signal_number)
#else
void FailureSignalHandler(int signal_number,
@@ -314,7 +314,7 @@ void FailureSignalHandler(int signal_number,
// First dump time info.
DumpTimeInfo();
-#if !defined(OS_WINDOWS)
+#if !defined(GLOG_OS_WINDOWS)
// Get the program counter from ucontext.
void *pc = GetPC(ucontext);
DumpStackFrameInfo("PC: ", pc);
@@ -364,7 +364,7 @@ bool IsFailureSignalHandlerInstalled() {
sigaction(SIGABRT, NULL, &sig_action);
if (sig_action.sa_sigaction == &FailureSignalHandler)
return true;
-#elif defined(OS_WINDOWS)
+#elif defined(GLOG_OS_WINDOWS)
return kFailureSignalHandlerInstalled;
#endif // HAVE_SIGACTION
return false;
@@ -385,7 +385,7 @@ void InstallFailureSignalHandler() {
CHECK_ERR(sigaction(kFailureSignals[i].number, &sig_action, NULL));
}
kFailureSignalHandlerInstalled = true;
-#elif defined(OS_WINDOWS)
+#elif defined(GLOG_OS_WINDOWS)
for (size_t i = 0; i < ARRAYSIZE(kFailureSignals); ++i) {
CHECK_NE(signal(kFailureSignals[i].number, &FailureSignalHandler),
SIG_ERR);
@@ -395,7 +395,7 @@ void InstallFailureSignalHandler() {
}
void InstallFailureWriter(void (*writer)(const char* data, int size)) {
-#if defined(HAVE_SIGACTION) || defined(OS_WINDOWS)
+#if defined(HAVE_SIGACTION) || defined(GLOG_OS_WINDOWS)
g_failure_writer = writer;
#endif // HAVE_SIGACTION
}
diff --git a/src/stacktrace_x86-inl.h b/src/stacktrace_x86-inl.h
index af2783d..99c5de7 100644
--- a/src/stacktrace_x86-inl.h
+++ b/src/stacktrace_x86-inl.h
@@ -31,9 +31,9 @@
#include <stdint.h> // for uintptr_t
-#include "utilities.h" // for OS_* macros
+#include "utilities.h" // for GLOG_OS_* macros
-#if !defined(OS_WINDOWS)
+#if !defined(GLOG_OS_WINDOWS)
#include <unistd.h>
#include <sys/mman.h>
#endif
@@ -74,7 +74,7 @@ static void **NextStackFrame(void **old_sp) {
// last two pages in the address space
if ((uintptr_t)new_sp >= 0xffffe000) return NULL;
#endif
-#if !defined(OS_WINDOWS)
+#if !defined(GLOG_OS_WINDOWS)
if (!STRICT_UNWINDING) {
// Lax sanity checks cause a crash in 32-bit tcmalloc/crash_reason_test
// on AMD-based machines with VDSO-enabled kernels.
diff --git a/src/symbolize.cc b/src/symbolize.cc
index f7fbc53..8688ca2 100644
--- a/src/symbolize.cc
+++ b/src/symbolize.cc
@@ -46,7 +46,7 @@
// and memmove(). We assume they are async-signal-safe.
//
// 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
#include GLOG_BUILD_CONFIG_INCLUDE
@@ -113,7 +113,7 @@ _END_GOOGLE_NAMESPACE_
#if defined(HAVE_DLFCN_H)
#include <dlfcn.h>
#endif
-#if defined(OS_OPENBSD)
+#if defined(GLOG_OS_OPENBSD)
#include <sys/exec_elf.h>
#else
#include <elf.h>
@@ -846,7 +846,7 @@ static ATTRIBUTE_NOINLINE bool SymbolizeAndDemangle(void *pc, char *out,
_END_GOOGLE_NAMESPACE_
-#elif defined(OS_MACOSX) && defined(HAVE_DLADDR)
+#elif defined(GLOG_OS_MACOSX) && defined(HAVE_DLADDR)
#include <dlfcn.h>
#include <cstring>
@@ -871,7 +871,7 @@ static ATTRIBUTE_NOINLINE bool SymbolizeAndDemangle(void *pc, char *out,
_END_GOOGLE_NAMESPACE_
-#elif defined(OS_WINDOWS) || defined(OS_CYGWIN)
+#elif defined(GLOG_OS_WINDOWS) || defined(GLOG_OS_CYGWIN)
#include <windows.h>
#include <dbghelp.h>
diff --git a/src/symbolize_unittest.cc b/src/symbolize_unittest.cc
index 0b53230..7e8f6d4 100644
--- a/src/symbolize_unittest.cc
+++ b/src/symbolize_unittest.cc
@@ -359,7 +359,7 @@ static void ATTRIBUTE_NOINLINE TestWithReturnAddress() {
#endif
}
-# elif defined(OS_WINDOWS) || defined(OS_CYGWIN)
+# elif defined(GLOG_OS_WINDOWS) || defined(GLOG_OS_CYGWIN)
#ifdef _MSC_VER
#include <intrin.h>
@@ -411,10 +411,10 @@ int main(int argc, char **argv) {
TestWithPCInsideNonInlineFunction();
TestWithReturnAddress();
return RUN_ALL_TESTS();
-# elif defined(OS_WINDOWS) || defined(OS_CYGWIN)
+# elif defined(GLOG_OS_WINDOWS) || defined(GLOG_OS_CYGWIN)
TestWithReturnAddress();
return RUN_ALL_TESTS();
-# else // OS_WINDOWS
+# else // GLOG_OS_WINDOWS
printf("PASS (no symbolize_unittest support)\n");
return 0;
# endif // __ELF__
diff --git a/src/utilities.cc b/src/utilities.cc
index 6b9a69e..ecda730 100644
--- a/src/utilities.cc
+++ b/src/utilities.cc
@@ -151,7 +151,7 @@ static void DumpStackTraceAndExit() {
sigemptyset(&sig_action.sa_mask);
sig_action.sa_handler = SIG_DFL;
sigaction(SIGABRT, &sig_action, NULL);
-#elif defined(OS_WINDOWS)
+#elif defined(GLOG_OS_WINDOWS)
signal(SIGABRT, SIG_DFL);
#endif // HAVE_SIGACTION
}
@@ -180,7 +180,7 @@ bool IsGoogleLoggingInitialized() {
return g_program_invocation_short_name != NULL;
}
-#ifdef OS_WINDOWS
+#ifdef GLOG_OS_WINDOWS
struct timeval {
long tv_sec, tv_usec;
};
@@ -236,9 +236,9 @@ bool PidHasChanged() {
pid_t 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
-#ifdef OS_MACOSX
+#ifdef GLOG_OS_MACOSX
#define __NR_gettid SYS_gettid
#elif ! defined __i386__
#error "Must define __NR_gettid for non-x86 platforms"
@@ -258,12 +258,12 @@ pid_t GetTID() {
// the value change to "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 defined OS_LINUX
+#if defined GLOG_OS_LINUX
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();
#elif defined(HAVE_PTHREAD)
// If none of the techniques above worked, we use pthread_self().
@@ -275,7 +275,7 @@ pid_t GetTID() {
const char* const_basename(const char* 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)
base = strrchr(filepath, '\\');
#endif
@@ -288,7 +288,7 @@ const string& MyUserName() {
}
static void MyUserNameInitializer() {
// TODO(hamaji): Probably this is not portable.
-#if defined(OS_WINDOWS)
+#if defined(GLOG_OS_WINDOWS)
const char* user = getenv("USERNAME");
#else
const char* user = getenv("USER");
@@ -337,7 +337,7 @@ void InitGoogleLoggingUtilities(const char* argv0) {
CHECK(!IsGoogleLoggingInitialized())
<< "You called InitGoogleLogging() twice!";
const char* slash = strrchr(argv0, '/');
-#ifdef OS_WINDOWS
+#ifdef GLOG_OS_WINDOWS
if (!slash) slash = strrchr(argv0, '\\');
#endif
g_program_invocation_short_name = slash ? slash + 1 : argv0;
diff --git a/src/utilities.h b/src/utilities.h
index e4115ad..86bc296 100644
--- a/src/utilities.h
+++ b/src/utilities.h
@@ -34,25 +34,6 @@
#ifndef 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
#ifdef _LP64
@@ -76,12 +57,12 @@
#include <string>
-#if defined(OS_WINDOWS)
+#include "glog/logging.h"
+#if defined(GLOG_OS_WINDOWS)
# include "port.h"
#endif
#include "config.h"
-#include "glog/logging.h"
// 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"
# elif (defined(__ppc__) || defined(__PPC__)) && __GNUC__ >= 2
# define STACKTRACE_H "stacktrace_powerpc-inl.h"
-# elif defined(OS_WINDOWS)
+# elif defined(GLOG_OS_WINDOWS)
# define STACKTRACE_H "stacktrace_windows-inl.h"
# endif
#endif
@@ -130,12 +111,12 @@
#ifndef GLOG_NO_SYMBOLIZE_DETECTION
#ifndef HAVE_SYMBOLIZE
// defined by gcc
-#if defined(__ELF__) && defined(OS_LINUX)
+#if defined(__ELF__) && defined(GLOG_OS_LINUX)
# define HAVE_SYMBOLIZE
-#elif defined(OS_MACOSX) && defined(HAVE_DLADDR)
+#elif defined(GLOG_OS_MACOSX) && defined(HAVE_DLADDR)
// Use dladdr to symbolize.
# define HAVE_SYMBOLIZE
-#elif defined(OS_WINDOWS)
+#elif defined(GLOG_OS_WINDOWS)
// Use DbgHelp to symbolize
# define HAVE_SYMBOLIZE
#endif
@@ -154,7 +135,7 @@ namespace glog_internal_namespace_ {
#ifdef HAVE___ATTRIBUTE__
# define ATTRIBUTE_NOINLINE __attribute__ ((noinline))
# define HAVE_ATTRIBUTE_NOINLINE
-#elif defined(OS_WINDOWS)
+#elif defined(GLOG_OS_WINDOWS)
# define ATTRIBUTE_NOINLINE __declspec(noinline)
# define HAVE_ATTRIBUTE_NOINLINE
#else

View File

@ -1,13 +1,13 @@
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 62ebbcc..28e2688 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -65,7 +65,7 @@ include (GenerateExportHeader)
include (GetCacheVariables)
include (GNUInstallDirs)
-set (CMAKE_DEBUG_POSTFIX d)
+#set (CMAKE_DEBUG_POSTFIX d)
set (CMAKE_THREAD_PREFER_PTHREAD 1)
find_package (GTest)
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 20441d1..d314abe 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -65,7 +65,7 @@ set (CMAKE_CXX_VISIBILITY_PRESET hidden)
set (CMAKE_POSITION_INDEPENDENT_CODE ON)
set (CMAKE_VISIBILITY_INLINES_HIDDEN ON)
-set (CMAKE_DEBUG_POSTFIX d)
+#set (CMAKE_DEBUG_POSTFIX d)
set (CMAKE_THREAD_PREFER_PTHREAD 1)
find_package (GTest NO_MODULE)

View File

@ -1,21 +1,20 @@
vcpkg_from_github(
OUT_SOURCE_PATH SOURCE_PATH
REPO google/glog
REF v0.5.0
SHA512 445e4338f3d81cd0b065f2da9c6ce343c243263ca144cea424ef97531a4e9e09c06ffd6942ac01c5213a8003c75cfbbede3c4028d12f0134f23ff29314769c1a
REF v0.6.0
SHA512 fd2c42583d0dd72c790a8cf888f328a64447c5fb9d99b2e2a3833d70c102cb0eb9ae874632c2732424cc86216c8a076a3e24b23a793eaddb5da8a1dc52ba9226
HEAD_REF master
PATCHES
glog_disable_debug_postfix.patch
fix_glog_CMAKE_MODULE_PATH.patch
fix_log_every_n.patch
fix-SOME_KIND_OF_LOG.patch
fix_crosscompile_symbolize.patch
cmakelists_atomicdetect.patch
fix_glog_CMAKE_MODULE_PATH.patch
glog_disable_debug_postfix.patch
fix_crosscompile_symbolize.patch
fix_cplusplus_macro.patch
)
vcpkg_check_features(OUT_FEATURE_OPTIONS FEATURE_OPTIONS
unwind WITH_UNWIND
)
file(REMOVE "${SOURCE_PATH}/glog-modules.cmake.in")
vcpkg_cmake_configure(
SOURCE_PATH "${SOURCE_PATH}"

View File

@ -1,7 +1,6 @@
{
"name": "glog",
"version": "0.5.0",
"port-version": 5,
"version": "0.6.0",
"description": "C++ implementation of the Google logging module",
"homepage": "https://github.com/google/glog",
"license": "BSD-3-Clause",

View File

@ -1234,7 +1234,7 @@
},
"caffe2": {
"baseline": "0.8.1",
"port-version": 6
"port-version": 7
},
"cairo": {
"baseline": "1.17.6",
@ -2122,7 +2122,7 @@
},
"evpp": {
"baseline": "0.7.0",
"port-version": 5
"port-version": 6
},
"exiv2": {
"baseline": "0.27.5",
@ -2210,7 +2210,7 @@
},
"fbthrift": {
"baseline": "2022.03.21.00",
"port-version": 1
"port-version": 2
},
"fcl": {
"baseline": "0.7.0",
@ -2306,7 +2306,7 @@
},
"folly": {
"baseline": "2022.03.21.00",
"port-version": 0
"port-version": 1
},
"font-chef": {
"baseline": "1.1.0",
@ -2581,8 +2581,8 @@
"port-version": 4
},
"glog": {
"baseline": "0.5.0",
"port-version": 5
"baseline": "0.6.0",
"port-version": 0
},
"gloo": {
"baseline": "20201203",

View File

@ -1,5 +1,10 @@
{
"versions": [
{
"git-tree": "83f1ccbf682aad8aacd3d74e8880becad6eb8d91",
"version": "0.8.1",
"port-version": 7
},
{
"git-tree": "ca32eb4601a1c35daa69e526f0af30efeb599c8c",
"version": "0.8.1",

View File

@ -1,5 +1,10 @@
{
"versions": [
{
"git-tree": "7bcbd80099c9f1551101e9abc91ba7ad4849dd05",
"version": "0.7.0",
"port-version": 6
},
{
"git-tree": "b312644fb2498483feb3114cef2c8afaa44f45ed",
"version-string": "0.7.0",

View File

@ -1,5 +1,10 @@
{
"versions": [
{
"git-tree": "60135cc9f7a4bf698b67d275e1ad66a542d9acb4",
"version-string": "2022.03.21.00",
"port-version": 2
},
{
"git-tree": "ed9295b0cad6c25b409e6e400148bb91017f3678",
"version-string": "2022.03.21.00",

View File

@ -1,5 +1,10 @@
{
"versions": [
{
"git-tree": "c1b11303819bf16b4cde18fdc8e6511b7bb34ed7",
"version-string": "2022.03.21.00",
"port-version": 1
},
{
"git-tree": "bb704ec83012c1ef40ba934b0d5f3ae45471e4bd",
"version-string": "2022.03.21.00",

View File

@ -1,5 +1,10 @@
{
"versions": [
{
"git-tree": "b1be508a55f3c9cbd8d78b40ac3739365ff301b7",
"version": "0.6.0",
"port-version": 0
},
{
"git-tree": "b1c79ab6934cb1a24d37e2e7c0a73f486f3400c4",
"version": "0.5.0",