-
Notifications
You must be signed in to change notification settings - Fork 6.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[glog] fix not work on c++03 (#25155)
* [glog] fix not work on c++03 * remove NOMINMAX * Revert "remove NOMINMAX" This reverts commit 17a80f2. * fix atomic * remove nominmax * CI [skip actions]
- Loading branch information
Showing
7 changed files
with
84 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) \ |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters