1
0
mirror of https://github.com/Zygo/bees.git synced 2025-06-16 01:26:18 +02:00

build: OK, maybe 32-bit machines could work

I accidentally did a pre-push verification on a 32-bit build host.
There were a surprisingly small number of problems, so fix them.

Bees now builds on a 32-bit host.  Let's not update README just yet,
though:  the 32-bit ioctl support fails immediately after startup on a
64-bit kernel.
This commit is contained in:
Zygo Blaxell
2016-11-26 02:02:10 -05:00
parent a57404442c
commit 38bb70f5d0
6 changed files with 44 additions and 14 deletions

View File

@ -171,7 +171,7 @@ namespace crucible {
ostream & operator<<(ostream &os, const BtrfsIoctlSearchKey &key); ostream & operator<<(ostream &os, const BtrfsIoctlSearchKey &key);
string btrfs_search_type_ntoa(unsigned type); string btrfs_search_type_ntoa(unsigned type);
string btrfs_search_objectid_ntoa(unsigned objectid); string btrfs_search_objectid_ntoa(uint64_t objectid);
uint64_t btrfs_get_root_id(int fd); uint64_t btrfs_get_root_id(int fd);
uint64_t btrfs_get_root_transid(int fd); uint64_t btrfs_get_root_transid(int fd);

View File

@ -7,12 +7,12 @@ namespace crucible {
using namespace std; using namespace std;
struct bits_ntoa_table { struct bits_ntoa_table {
unsigned long n; unsigned long long n;
unsigned long mask; unsigned long long mask;
const char *a; const char *a;
}; };
string bits_ntoa(unsigned long n, const bits_ntoa_table *a); string bits_ntoa(unsigned long long n, const bits_ntoa_table *a);
}; };

View File

@ -23,7 +23,7 @@ namespace crucible {
private: private:
struct Item { struct Item {
Timestamp m_time; Timestamp m_time;
unsigned m_id; unsigned long m_id;
Task m_task; Task m_task;
bool operator<(const Item &that) const { bool operator<(const Item &that) const {

View File

@ -834,7 +834,7 @@ namespace crucible {
} }
string string
btrfs_search_objectid_ntoa(unsigned objectid) btrfs_search_objectid_ntoa(uint64_t objectid)
{ {
static const bits_ntoa_table table[] = { static const bits_ntoa_table table[] = {
NTOA_TABLE_ENTRY_ENUM(BTRFS_ROOT_TREE_OBJECTID), NTOA_TABLE_ENTRY_ENUM(BTRFS_ROOT_TREE_OBJECTID),

View File

@ -7,7 +7,7 @@
namespace crucible { namespace crucible {
using namespace std; using namespace std;
string bits_ntoa(unsigned long n, const bits_ntoa_table *table) string bits_ntoa(unsigned long long n, const bits_ntoa_table *table)
{ {
string out; string out;
while (n && table->a) { while (n && table->a) {

View File

@ -126,7 +126,13 @@ test_cast_0x80000000_to_things()
{ {
auto sv = 0x80000000LL; auto sv = 0x80000000LL;
auto uv = 0x80000000ULL; auto uv = 0x80000000ULL;
SHOULD_PASS(ranged_cast<off_t>(sv), sv); if (sizeof(off_t) == 4) {
SHOULD_FAIL(ranged_cast<off_t>(sv));
} else if (sizeof(off_t) == 8) {
SHOULD_PASS(ranged_cast<off_t>(sv), sv);
} else {
assert(!"unhandled case, please add code for off_t here");
}
SHOULD_PASS(ranged_cast<uint64_t>(uv), uv); SHOULD_PASS(ranged_cast<uint64_t>(uv), uv);
SHOULD_PASS(ranged_cast<uint32_t>(uv), uv); SHOULD_PASS(ranged_cast<uint32_t>(uv), uv);
SHOULD_FAIL(ranged_cast<uint16_t>(uv)); SHOULD_FAIL(ranged_cast<uint16_t>(uv));
@ -141,7 +147,13 @@ test_cast_0x80000000_to_things()
SHOULD_FAIL(ranged_cast<unsigned short>(uv)); SHOULD_FAIL(ranged_cast<unsigned short>(uv));
SHOULD_FAIL(ranged_cast<unsigned char>(uv)); SHOULD_FAIL(ranged_cast<unsigned char>(uv));
SHOULD_PASS(ranged_cast<signed long long>(sv), sv); SHOULD_PASS(ranged_cast<signed long long>(sv), sv);
SHOULD_PASS(ranged_cast<signed long>(sv), sv); if (sizeof(long) == 4) {
SHOULD_FAIL(ranged_cast<signed long>(sv));
} else if (sizeof(long) == 8) {
SHOULD_PASS(ranged_cast<signed long>(sv), sv);
} else {
assert(!"unhandled case, please add code for long here");
}
SHOULD_FAIL(ranged_cast<signed short>(sv)); SHOULD_FAIL(ranged_cast<signed short>(sv));
SHOULD_FAIL(ranged_cast<signed char>(sv)); SHOULD_FAIL(ranged_cast<signed char>(sv));
if (sizeof(int) == 4) { if (sizeof(int) == 4) {
@ -149,7 +161,7 @@ test_cast_0x80000000_to_things()
} else if (sizeof(int) == 8) { } else if (sizeof(int) == 8) {
SHOULD_PASS(ranged_cast<signed int>(sv), sv); SHOULD_PASS(ranged_cast<signed int>(sv), sv);
} else { } else {
assert(!"unhandled case, please add code here"); assert(!"unhandled case, please add code for int here");
} }
} }
@ -159,7 +171,13 @@ test_cast_0xffffffff_to_things()
{ {
auto sv = 0xffffffffLL; auto sv = 0xffffffffLL;
auto uv = 0xffffffffULL; auto uv = 0xffffffffULL;
SHOULD_PASS(ranged_cast<off_t>(sv), sv); if (sizeof(off_t) == 4) {
SHOULD_FAIL(ranged_cast<off_t>(sv));
} else if (sizeof(off_t) == 8) {
SHOULD_PASS(ranged_cast<off_t>(sv), sv);
} else {
assert(!"unhandled case, please add code for off_t here");
}
SHOULD_PASS(ranged_cast<uint64_t>(uv), uv); SHOULD_PASS(ranged_cast<uint64_t>(uv), uv);
SHOULD_PASS(ranged_cast<uint32_t>(uv), uv); SHOULD_PASS(ranged_cast<uint32_t>(uv), uv);
SHOULD_FAIL(ranged_cast<uint16_t>(uv)); SHOULD_FAIL(ranged_cast<uint16_t>(uv));
@ -174,7 +192,13 @@ test_cast_0xffffffff_to_things()
SHOULD_FAIL(ranged_cast<unsigned short>(uv)); SHOULD_FAIL(ranged_cast<unsigned short>(uv));
SHOULD_FAIL(ranged_cast<unsigned char>(uv)); SHOULD_FAIL(ranged_cast<unsigned char>(uv));
SHOULD_PASS(ranged_cast<signed long long>(sv), sv); SHOULD_PASS(ranged_cast<signed long long>(sv), sv);
SHOULD_PASS(ranged_cast<signed long>(sv), sv); if (sizeof(long) == 4) {
SHOULD_FAIL(ranged_cast<signed long>(sv));
} else if (sizeof(long) == 8) {
SHOULD_PASS(ranged_cast<signed long>(sv), sv);
} else {
assert(!"unhandled case, please add code for long here");
}
SHOULD_FAIL(ranged_cast<signed short>(sv)); SHOULD_FAIL(ranged_cast<signed short>(sv));
SHOULD_FAIL(ranged_cast<signed char>(sv)); SHOULD_FAIL(ranged_cast<signed char>(sv));
if (sizeof(int) == 4) { if (sizeof(int) == 4) {
@ -182,7 +206,7 @@ test_cast_0xffffffff_to_things()
} else if (sizeof(int) == 8) { } else if (sizeof(int) == 8) {
SHOULD_PASS(ranged_cast<signed int>(sv), sv); SHOULD_PASS(ranged_cast<signed int>(sv), sv);
} else { } else {
assert(!"unhandled case, please add code here"); assert(!"unhandled case, please add code for int here");
} }
} }
@ -192,7 +216,13 @@ test_cast_0xfffffffff_to_things()
{ {
auto sv = 0xfffffffffLL; auto sv = 0xfffffffffLL;
auto uv = 0xfffffffffULL; auto uv = 0xfffffffffULL;
SHOULD_PASS(ranged_cast<off_t>(sv), sv); if (sizeof(off_t) == 4) {
SHOULD_FAIL(ranged_cast<off_t>(sv));
} else if (sizeof(off_t) == 8) {
SHOULD_PASS(ranged_cast<off_t>(sv), sv);
} else {
assert(!"unhandled case, please add code for off_t here");
}
SHOULD_PASS(ranged_cast<uint64_t>(uv), uv); SHOULD_PASS(ranged_cast<uint64_t>(uv), uv);
SHOULD_FAIL(ranged_cast<uint32_t>(uv)); SHOULD_FAIL(ranged_cast<uint32_t>(uv));
SHOULD_FAIL(ranged_cast<uint16_t>(uv)); SHOULD_FAIL(ranged_cast<uint16_t>(uv));