1
0
mirror of https://github.com/Zygo/bees.git synced 2025-06-15 17:26:15 +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);
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_transid(int fd);

View File

@ -7,12 +7,12 @@ namespace crucible {
using namespace std;
struct bits_ntoa_table {
unsigned long n;
unsigned long mask;
unsigned long long n;
unsigned long long mask;
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:
struct Item {
Timestamp m_time;
unsigned m_id;
unsigned long m_id;
Task m_task;
bool operator<(const Item &that) const {

View File

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

View File

@ -7,7 +7,7 @@
namespace crucible {
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;
while (n && table->a) {

View File

@ -126,7 +126,13 @@ test_cast_0x80000000_to_things()
{
auto sv = 0x80000000LL;
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<uint32_t>(uv), 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 char>(uv));
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 char>(sv));
if (sizeof(int) == 4) {
@ -149,7 +161,7 @@ test_cast_0x80000000_to_things()
} else if (sizeof(int) == 8) {
SHOULD_PASS(ranged_cast<signed int>(sv), sv);
} 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 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<uint32_t>(uv), 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 char>(uv));
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 char>(sv));
if (sizeof(int) == 4) {
@ -182,7 +206,7 @@ test_cast_0xffffffff_to_things()
} else if (sizeof(int) == 8) {
SHOULD_PASS(ranged_cast<signed int>(sv), sv);
} 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 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_FAIL(ranged_cast<uint32_t>(uv));
SHOULD_FAIL(ranged_cast<uint16_t>(uv));