vcpkg/ports/glog/fix-SOME_KIND_OF_LOG.patch
Jia Yue Hua 86ff75c6d8
[glog] fix not work on c++03 (#25155)
* [glog] fix not work on c++03

* remove NOMINMAX

* Revert "remove NOMINMAX"

This reverts commit 17a80f259dd2718a375d06c0686f69c647cf2d57.

* fix atomic

* remove nominmax

* CI [skip actions]
2022-06-15 11:34:55 -07:00

59 lines
2.3 KiB
Diff

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) \