Skip to content

Commit

Permalink
[glog] fix not work on c++03
Browse files Browse the repository at this point in the history
  • Loading branch information
jiayuehua committed Jun 9, 2022
1 parent 1323f4b commit c905ac6
Show file tree
Hide file tree
Showing 6 changed files with 68 additions and 20 deletions.
17 changes: 0 additions & 17 deletions ports/glog/fix-windows-CXX11_ATOMIC.patch

This file was deleted.

60 changes: 60 additions & 0 deletions ports/glog/noerror-nominmax.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
diff --git a/src/glog/logging.h.in b/src/glog/logging.h.in
index 3ecacfb..0bdbe6d 100644
--- a/src/glog/logging.h.in
+++ b/src/glog/logging.h.in
@@ -103,7 +103,19 @@
#ifdef HAVE_CXX11_ATOMIC
#include <atomic>
#elif defined(GLOG_OS_WINDOWS)
+# ifndef WIN32_LEAN_AND_MEAN
+# define WIN32_LEAN_AND_MEAN // We only need minimal includes
+# endif
+// To avoid macro definition of ERROR.
+// To avoid macro definition of min/max.
+# ifndef NOMINMAX
+# define NOMINMAX
+# endif
+
#include <Windows.h>
+#ifdef ERROR
+# undef ERROR
+#endif
#endif

@ac_google_start_namespace@
@@ -1061,7 +1073,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 +1083,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 +1094,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 +1104,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) \
2 changes: 1 addition & 1 deletion ports/glog/portfile.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ vcpkg_from_github(
glog_disable_debug_postfix.patch
fix_glog_CMAKE_MODULE_PATH.patch
fix_log_every_n.patch
fix-windows-CXX11_ATOMIC.patch
noerror-nominmax.patch
fix_crosscompile_symbolize.patch

)
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": "bb84d3c0e6057e00ef151afde936fa6b4fba33c9",
"version": "0.5.0",
"port-version": 5
},
{
"git-tree": "bb5f54eba990cc0f03c64e1d09f343dd6cd7b22b",
"version": "0.5.0",
Expand Down

0 comments on commit c905ac6

Please sign in to comment.