pdns/fix-unit-tests-32bit.patch
2017-01-17 14:27:31 +01:00

47 lines
1.6 KiB
Diff

From 00c6f2b9f5173c98cc883332f5ecf8b941715abc Mon Sep 17 00:00:00 2001
From: Remi Gacogne <remi.gacogne@powerdns.com>
Date: Fri, 13 Jan 2017 14:02:19 +0100
Subject: [PATCH] Fix AtomicCounter unit tests on 32-bit
---
pdns/misc.hh | 3 ++-
pdns/test-statbag_cc.cc | 4 ++--
2 files changed, 4 insertions(+), 3 deletions(-)
diff --git a/pdns/misc.hh b/pdns/misc.hh
index 50e8dca..2e0e65a 100644
--- a/pdns/misc.hh
+++ b/pdns/misc.hh
@@ -373,7 +373,8 @@ inline bool pdns_iequals_ch(const char a, const char b)
}
-typedef std::atomic<unsigned long> AtomicCounter ;
+typedef unsigned long AtomicCounterInner;
+typedef std::atomic<AtomicCounterInner> AtomicCounter ;
// FIXME400 this should probably go?
struct CIStringCompare: public std::binary_function<string, string, bool>
diff --git a/pdns/test-statbag_cc.cc b/pdns/test-statbag_cc.cc
index 3330451..4abbcd0 100644
--- a/pdns/test-statbag_cc.cc
+++ b/pdns/test-statbag_cc.cc
@@ -83,7 +83,7 @@ BOOST_AUTO_TEST_CASE(test_StatBagBasic) {
#ifdef UINTPTR_MAX
#if UINTPTR_MAX > 0xffffffffULL
- BOOST_CHECK_EQUAL(sizeof(unsigned long), 8);
+ BOOST_CHECK_EQUAL(sizeof(AtomicCounterInner), 8);
s.set("c", 1ULL<<33);
BOOST_CHECK_EQUAL(s.read("c"), (1ULL<<33) );
s.inc("c");
@@ -94,7 +94,7 @@ BOOST_AUTO_TEST_CASE(test_StatBagBasic) {
s.inc("c");
BOOST_CHECK_EQUAL(s.read("c"), 0 );
#else
- BOOST_CHECK_EQUAL(sizeof(AtomicCounter::native_t), 4);
+ BOOST_CHECK_EQUAL(sizeof(AtomicCounterInner), 4);
BOOST_CHECK_EQUAL(~0UL, 0xffffffffUL);
s.set("c", ~0UL);
BOOST_CHECK_EQUAL(s.read("c"), 0xffffffffUL );