Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[glog] fix not work on c++03 #25155

Merged
merged 6 commits into from
Jun 15, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions ports/glog/cmakelists_atomicdetect.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
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)
58 changes: 58 additions & 0 deletions ports/glog/fix-SOME_KIND_OF_LOG.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
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) \
17 changes: 0 additions & 17 deletions ports/glog/fix-windows-CXX11_ATOMIC.patch

This file was deleted.

4 changes: 2 additions & 2 deletions ports/glog/portfile.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ vcpkg_from_github(
glog_disable_debug_postfix.patch
fix_glog_CMAKE_MODULE_PATH.patch
fix_log_every_n.patch
fix-windows-CXX11_ATOMIC.patch
fix-SOME_KIND_OF_LOG.patch
fix_crosscompile_symbolize.patch

cmakelists_atomicdetect.patch
)

vcpkg_check_features(OUT_FEATURE_OPTIONS FEATURE_OPTIONS
Expand Down
2 changes: 1 addition & 1 deletion ports/glog/vcpkg.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "glog",
"version": "0.5.0",
"port-version": 4,
"port-version": 5,
"description": "C++ implementation of the Google logging module",
"homepage": "https://github.com/google/glog",
"license": "BSD-3-Clause",
Expand Down
2 changes: 1 addition & 1 deletion versions/baseline.json
Original file line number Diff line number Diff line change
Expand Up @@ -2574,7 +2574,7 @@
},
"glog": {
"baseline": "0.5.0",
"port-version": 4
"port-version": 5
},
"gloo": {
"baseline": "20201203",
Expand Down
5 changes: 5 additions & 0 deletions versions/g-/glog.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
{
"versions": [
{
"git-tree": "b1c79ab6934cb1a24d37e2e7c0a73f486f3400c4",
"version": "0.5.0",
"port-version": 5
},
{
"git-tree": "bb5f54eba990cc0f03c64e1d09f343dd6cd7b22b",
"version": "0.5.0",
Expand Down