--- Begin Message ---
Package: src:firebird3.0
Version: 3.0.0.32483.ds4-1
Severity: serious
Tags: upstream patch
Justification: Policy 4.2
Control: forwarded -1 https://github.com/FirebirdSQL/firebird/pull/21
As can be seen from
https://buildd.debian.org/status/package.php?p=firebird3.0&suite=experimental,
this package fails to build from source on any big-endian architecture. Please
apply the attached patch to fix this.
-- System Information:
Debian Release: stretch/sid
APT prefers unstable-debug
APT policy: (500, 'unstable-debug'), (500, 'unstable'), (1, 'experimental-
debug'), (1, 'experimental')
Architecture: amd64 (x86_64)
Kernel: Linux 4.5.0-2-amd64 (SMP w/4 CPU cores)
Locale: LANG=en_GB.UTF-8, LC_CTYPE=en_GB.UTF-8 (charmap=UTF-8)
--- a/src/jrd/Relation.cpp
+++ b/src/jrd/Relation.cpp
@@ -308,7 +308,7 @@
const USHORT relLockLen = relation->getRelLockKeyLength();
Lock* lock = FB_NEW_RPT(*pool, relLockLen) Lock(tdbb, relLockLen, lckType, relation);
- relation->getRelLockKey(tdbb, &lock->lck_key.lck_string[0]);
+ relation->getRelLockKey(tdbb, lock->getKeyString());
lock->lck_type = lckType;
switch (lckType)
--- a/src/jrd/btr.cpp
+++ b/src/jrd/btr.cpp
@@ -223,7 +223,7 @@
void BtrPageGCLock::disablePageGC(thread_db* tdbb, const PageNumber &page)
{
- page.getLockStr(lck_key.lck_string);
+ page.getLockStr(getKeyString());
LCK_lock(tdbb, this, LCK_read, LCK_WAIT);
}
@@ -235,7 +235,7 @@
bool BtrPageGCLock::isPageGCAllowed(thread_db* tdbb, const PageNumber& page)
{
BtrPageGCLock lock(tdbb);
- page.getLockStr(lock.lck_key.lck_string);
+ page.getLockStr(lock.getKeyString());
ThreadStatusGuard temp_status(tdbb);
--- a/src/jrd/cch.cpp
+++ b/src/jrd/cch.cpp
@@ -4055,7 +4055,7 @@
fb_assert(lock->lck_ast != NULL);
}
- bdb->bdb_page.getLockStr(lock->lck_key.lck_string);
+ bdb->bdb_page.getLockStr(lock->getKeyString());
if (LCK_lock_opt(tdbb, lock, lock_type, wait))
{
if (!lock->lck_ast)
--- a/src/jrd/lck.cpp
+++ b/src/jrd/lck.cpp
@@ -739,7 +739,7 @@
const SINT64 data =
dbb->dbb_lock_mgr->readData2(lock->lck_type,
- lock->lck_key.lck_string, lock->lck_length,
+ lock->getKeyString(), lock->lck_length,
lock->lck_owner_handle);
fb_assert(LCK_CHECK_LOCK(lock));
return data;
@@ -909,7 +909,7 @@
fb_assert(LCK_CHECK_LOCK(lock));
lock->lck_id = dbb->dbb_lock_mgr->enqueue(tdbb, statusVector, lock->lck_id,
- lock->lck_type, lock->lck_key.lck_string, lock->lck_length,
+ lock->lck_type, lock->getKeyString(), lock->lck_length,
level, lock->lck_ast, lock->lck_object, lock->lck_data, wait,
lock->lck_owner_handle);
@@ -1036,7 +1036,7 @@
if (!att->att_compatibility_table)
hash_allocate(lock);
- const USHORT hash_value = hash_func((UCHAR*) &lock->lck_key, lock->lck_length);
+ const USHORT hash_value = hash_func(lock->getKeyString(), lock->lck_length);
if (hash_slot)
*hash_slot = hash_value;
@@ -1061,7 +1061,7 @@
{
// check that the keys are the same
- if (!memcmp(lock->lck_key.lck_string, collision->lck_key.lck_string, lock->lck_length))
+ if (!memcmp(lock->getKeyString(), collision->getKeyString(), lock->lck_length))
return collision;
}
@@ -1426,7 +1426,7 @@
// with the local ast handler, passing it the lock block itself
lock->lck_id = dbb->dbb_lock_mgr->enqueue(tdbb, statusVector, lock->lck_id,
- lock->lck_type, (const UCHAR*) &lock->lck_key, lock->lck_length,
+ lock->lck_type, lock->getKeyString(), lock->lck_length,
level, external_ast, lock, lock->lck_data, wait, lock->lck_owner_handle);
// If the lock exchange failed, set the lock levels appropriately
--- a/src/jrd/lck.h
+++ b/src/jrd/lck.h
@@ -134,10 +134,19 @@
union
{
- UCHAR lck_string[1];
+ UCHAR lck_string[8];
SINT64 lck_long;
} lck_key; // Lock key string
+ UCHAR* getKeyString()
+ {
+#ifdef WORDS_BIGENDIAN
+ if (lck_length <= 8)
+ return &lck_key.lck_string[8-lck_length];
+#endif
+ return &lck_key.lck_string[0];
+ }
+
UCHAR lck_tail[1]; // Makes the allocator happy
};
--- a/src/jrd/met.epp
+++ b/src/jrd/met.epp
@@ -1390,7 +1390,7 @@
const USHORT key_length = item->lock->lck_length;
AutoPtr<Lock> temp_lock(FB_NEW_RPT(*tdbb->getDefaultPool(), key_length)
Lock(tdbb, key_length, LCK_dsql_cache));
- memcpy(temp_lock->lck_key.lck_string, item->lock->lck_key.lck_string, key_length);
+ memcpy(temp_lock->getKeyString(), item->lock->getKeyString(), key_length);
if (LCK_lock(tdbb, temp_lock, LCK_EX, LCK_WAIT))
LCK_release(tdbb, temp_lock);
@@ -4134,7 +4134,7 @@
item->locked = false;
item->lock = FB_NEW_RPT(*attachment->att_pool, key.length())
Lock(tdbb, key.length(), LCK_dsql_cache, item, blocking_ast_dsql_cache);
- memcpy(item->lock->lck_key.lck_string, key.c_str(), key.length());
+ memcpy(item->lock->getKeyString(), key.c_str(), key.length());
}
else
{
--- a/src/jrd/GlobalRWLock.cpp
+++ b/src/jrd/GlobalRWLock.cpp
@@ -78,7 +78,7 @@
cachedLock = FB_NEW_RPT(getPool(), lockLen)
Lock(tdbb, lockLen, lckType, this, lockCaching ? blocking_ast_cached_lock : NULL);
- memcpy(&cachedLock->lck_key, lockStr, lockLen);
+ memcpy(cachedLock->getKeyString(), lockStr, lockLen);
}
GlobalRWLock::~GlobalRWLock()
--- End Message ---