Discussion:
[linux-lvm] [PATCH 0/7] thin-provisioning-tools: support old compilers
Mikulas Patocka
2015-01-13 19:47:07 UTC
Permalink
Hi

Here I'm sending patches that make it possible to compile thin
provisioning tools with g++ 4.1, 4.2, 4.3 and 4.4. So that it can be used
on Debian 5 and Debian 6.

Mikulas
Mikulas Patocka
2015-01-13 19:47:52 UTC
Permalink
Old glibc doesn't provide these macros, so we have to define them.

Signed-off-by: Mikulas Patocka <***@redhat.com>

---
base/endian_utils.h | 20 ++++++++++++++++++++
1 file changed, 20 insertions(+)

Index: thin-provisioning-tools/base/endian_utils.h
===================================================================
--- thin-provisioning-tools.orig/base/endian_utils.h 2014-11-08 00:26:05.000000000 +0100
+++ thin-provisioning-tools/base/endian_utils.h 2014-11-08 00:26:20.000000000 +0100
@@ -25,6 +25,26 @@

//----------------------------------------------------------------

+/* An old glic doesn't provide these macros */
+#if !defined(htole16) || !defined(le16toh) || !defined(htole32) || !defined(le32toh) || !defined(htole64) || !defined(le64toh)
+#include <byteswap.h>
+#if __BYTE_ORDER == __LITTLE_ENDIAN
+#define htole16(x) (x)
+#define le16toh(x) (x)
+#define htole32(x) (x)
+#define le32toh(x) (x)
+#define htole64(x) (x)
+#define le64toh(x) (x)
+#else
+#define htole16(x) __bswap_16(x)
+#define le16toh(x) __bswap_16(x)
+#define htole32(x) __bswap_32(x)
+#define le32toh(x) __bswap_32(x)
+#define htole64(x) __bswap_64(x)
+#define le64toh(x) __bswap_64(x)
+#endif
+#endif
+
namespace base {

// These are just little wrapper types to make the compiler
Mikulas Patocka
2015-01-13 19:49:28 UTC
Permalink
Fix this error:
persistent-data/data-structures/bloom_filter.cc:10: error: integer constant is too large for 'unsigned long' type

Signed-off-by: Mikulas Patocka <***@redhat.com>

---
persistent-data/data-structures/bloom_filter.cc | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

Index: thin-provisioning-tools/persistent-data/data-structures/bloom_filter.cc
===================================================================
--- thin-provisioning-tools.orig/persistent-data/data-structures/bloom_filter.cc 2014-11-05 16:11:48.000000000 +0100
+++ thin-provisioning-tools/persistent-data/data-structures/bloom_filter.cc 2014-11-05 16:12:14.000000000 +0100
@@ -7,7 +7,7 @@ using namespace persistent_data;
//----------------------------------------------------------------

namespace {
- static const uint64_t m1 = 0x9e37fffffffc0001UL;
+ static const uint64_t m1 = 0x9e37fffffffc0001ULL;
static const unsigned bits = 18;

static uint32_t hash1(block_address const &b) {
Mikulas Patocka
2015-01-13 19:48:19 UTC
Permalink
Fix these errors:
caching/superblock.cc:306: error: reference to 'validator' is ambiguous
caching/superblock.cc:271: error: candidates are: namespace validator { }
./block-cache/block_cache.h:22: error: class bcache::validator

caching/superblock.cc:316: error: reference to 'validator' is ambiguous
caching/superblock.cc:271: error: candidates are: namespace validator { }
./block-cache/block_cache.h:22: error: class bcache::validator

Signed-off-by: Mikulas Patocka <***@redhat.com>

---
caching/superblock.cc | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)

Index: thin-provisioning-tools/caching/superblock.cc
===================================================================
--- thin-provisioning-tools.orig/caching/superblock.cc 2014-11-05 16:10:19.000000000 +0100
+++ thin-provisioning-tools/caching/superblock.cc 2014-11-05 16:10:23.000000000 +0100
@@ -302,8 +302,9 @@ namespace validator {
superblock
caching::read_superblock(block_manager<>::ptr bm, block_address location)
{
+ using namespace validator;
superblock sb;
- block_manager<>::read_ref r = bm->read_lock(location, validator::mk_v());
+ block_manager<>::read_ref r = bm->read_lock(location, mk_v());
superblock_disk const *sbd = reinterpret_cast<superblock_disk const *>(r.data());
superblock_traits::unpack(*sbd, sb);

@@ -313,7 +314,8 @@ caching::read_superblock(block_manager<>
void
caching::write_superblock(block_manager<>::ptr bm, superblock const &sb, block_address location)
{
- block_manager<>::write_ref w = bm->superblock_zero(location, validator::mk_v());
+ using namespace validator;
+ block_manager<>::write_ref w = bm->superblock_zero(location, mk_v());
superblock_traits::pack(sb, *reinterpret_cast<superblock_disk *>(w.data()));
}
Mikulas Patocka
2015-01-13 19:48:46 UTC
Permalink
Fix these errors:
thin-provisioning/thin_pool.cc:206: error: reference to 'sector_t' is ambiguous
./thin-provisioning/metadata.h:40: error: candidates are: typedef uint64_t thin_provisioning::sector_t
./block-cache/block_cache.h:20: error: typedef uint64_t bcache::sector_t
thin-provisioning/thin_pool.cc:206: error: reference to 'sector_t' is ambiguous
./thin-provisioning/metadata.h:40: error: candidates are: typedef uint64_t thin_provisioning::sector_t
./block-cache/block_cache.h:20: error: typedef uint64_t bcache::sector_t
thin-provisioning/thin_pool.cc:206: error: 'sector_t' does not name a type

Signed-off-by: Mikulas Patocka <***@redhat.com>

---
thin-provisioning/thin_pool.cc | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

Index: thin-provisioning-tools/thin-provisioning/thin_pool.cc
===================================================================
--- thin-provisioning-tools.orig/thin-provisioning/thin_pool.cc 2014-11-05 16:14:22.000000000 +0100
+++ thin-provisioning-tools/thin-provisioning/thin_pool.cc 2014-11-05 16:14:45.000000000 +0100
@@ -203,7 +203,7 @@ thin_pool::get_nr_free_data_blocks() con
return md_->data_sm_->get_nr_free();
}

-sector_t
+thin_provisioning::sector_t
thin_pool::get_data_block_size() const
{
return md_->sb_.data_block_size_;
Mikulas Patocka
2015-01-13 19:50:04 UTC
Permalink
g++-4.2 and older doesn't accept binary constants.

Signed-off-by: Mikulas Patocka <***@redhat.com>

---
persistent-data/space-maps/disk.cc | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)

Index: thin-provisioning-tools/persistent-data/space-maps/disk.cc
===================================================================
--- thin-provisioning-tools.orig/persistent-data/space-maps/disk.cc 2014-11-08 00:38:27.000000000 +0100
+++ thin-provisioning-tools/persistent-data/space-maps/disk.cc 2014-11-08 00:38:51.000000000 +0100
@@ -112,7 +112,7 @@ namespace {
ref_t b1 = test_bit_le(bits, b * 2);
ref_t b2 = test_bit_le(bits, b * 2 + 1);
ref_t result = b2 ? 1 : 0;
- result |= b1 ? 0b10 : 0;
+ result |= b1 ? 2 : 0;
return result;
}

@@ -165,7 +165,7 @@ namespace {
ref_t b1 = test_bit_le(bits, b * 2);
ref_t b2 = test_bit_le(bits, b * 2 + 1);
ref_t result = b2 ? 1 : 0;
- result |= b1 ? 0b10 : 0;
+ result |= b1 ? 2 : 0;
it(offset + b, result);
}
}
Mikulas Patocka
2015-01-13 19:50:45 UTC
Permalink
Fix these errors:
unit-tests/array_block_t.cc:38: error: using 'typename' outside of template
unit-tests/array_block_t.cc:39: error: using 'typename' outside of template
unit-tests/array_block_t.cc:40: error: using 'typename' outside of template

Signed-off-by: Mikulas Patocka <***@redhat.com>

---
unit-tests/array_block_t.cc | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)

Index: thin-provisioning-tools/unit-tests/array_block_t.cc
===================================================================
--- thin-provisioning-tools.orig/unit-tests/array_block_t.cc 2014-11-08 01:42:09.000000000 +0100
+++ thin-provisioning-tools/unit-tests/array_block_t.cc 2014-11-08 01:42:18.000000000 +0100
@@ -35,9 +35,9 @@ using namespace testing;
namespace {
uint64_t MAX_VALUE = 1000ull;
block_address const NR_BLOCKS = 1024;
- typedef typename bcache::noop_validator noop_validator;
- typedef typename block_manager<>::read_ref read_ref;
- typedef typename block_manager<>::write_ref write_ref;
+ typedef bcache::noop_validator noop_validator;
+ typedef block_manager<>::read_ref read_ref;
+ typedef block_manager<>::write_ref write_ref;

// FIXME: lift to utils?
class simple_ref_counter {
Mikulas Patocka
2015-01-13 19:51:13 UTC
Permalink
The file boost/random/uniform_int_distribution.hpp was introduced in boost
version 1.47. If we have older Boost, use random numbers from libc.

Signed-off-by: Mikulas Patocka <***@redhat.com>

---
unit-tests/bloom_filter_t.cc | 17 +++++++++++++++++
1 file changed, 17 insertions(+)

Index: thin-provisioning-tools/unit-tests/bloom_filter_t.cc
===================================================================
--- thin-provisioning-tools.orig/unit-tests/bloom_filter_t.cc 2015-01-13 03:22:38.000000000 +0100
+++ thin-provisioning-tools/unit-tests/bloom_filter_t.cc 2015-01-13 04:20:36.000000000 +0100
@@ -5,8 +5,16 @@
#include "persistent-data/data-structures/array_block.h"
#include "test_utils.h"

+#include <boost/version.hpp>
+
+#if BOOST_VERSION >= 104700
+#define HAVE_RANDOM_UNIFORM_INT_DISTRIBUTION
+#endif
+
#include <boost/random/mersenne_twister.hpp>
+#ifdef HAVE_RANDOM_UNIFORM_INT_DISTRIBUTION
#include <boost/random/uniform_int_distribution.hpp>
+#endif
#include <utility>
#include <deque>
#include <vector>
@@ -40,10 +48,16 @@ namespace {

using namespace boost::random;

+#ifdef HAVE_RANDOM_UNIFORM_INT_DISTRIBUTION
boost::random::uniform_int_distribution<uint64_t> uniform_dist(0, max);
+#endif

while (r.size() < count) {
+#ifdef HAVE_RANDOM_UNIFORM_INT_DISTRIBUTION
block_address b = uniform_dist(rng_);
+#else
+ block_address b = random() % max;
+#endif
r.insert(b);
}

@@ -75,7 +89,9 @@ namespace {
space_map::ptr sm_;
transaction_manager tm_;

+#ifdef HAVE_RANDOM_UNIFORM_INT_DISTRIBUTION
boost::random::mt19937 rng_;
+#endif
};
}

@@ -312,3 +328,4 @@ TEST_F(BloomFilterTests, false_positives
}

//----------------------------------------------------------------
+

Loading...