aboutsummaryrefslogtreecommitdiff
path: root/bucket.go
diff options
context:
space:
mode:
authorBen Johnson <benbjohnson@yahoo.com>2016-09-06 14:07:22 -0600
committerGitHub <noreply@github.com>2016-09-06 14:07:22 -0600
commitde827651490d8e41c73f66cc6fc121b85d2d6496 (patch)
tree1b0e0eae0426c88e6c0a83ec0247052b309529b3 /bucket.go
parentMerge pull request #590 from benbjohnson/vincent-petithory-compact-db (diff)
parentbucket: correct broken unaligned load/store in armv5 (diff)
downloaddedo-de827651490d8e41c73f66cc6fc121b85d2d6496.tar.gz
dedo-de827651490d8e41c73f66cc6fc121b85d2d6496.tar.xz
Merge pull request #578 from resin-os/align-fix
Correct broken unaligned load/store in armv5
Diffstat (limited to 'bucket.go')
-rw-r--r--bucket.go10
1 files changed, 9 insertions, 1 deletions
diff --git a/bucket.go b/bucket.go
index 8e00380..511ce72 100644
--- a/bucket.go
+++ b/bucket.go
@@ -130,9 +130,17 @@ func (b *Bucket) Bucket(name []byte) *Bucket {
func (b *Bucket) openBucket(value []byte) *Bucket {
var child = newBucket(b.tx)
+ // If unaligned load/stores are broken on this arch and value is
+ // unaligned simply clone to an aligned byte array.
+ unaligned := brokenUnaligned && uintptr(unsafe.Pointer(&value[0]))&3 != 0
+
+ if unaligned {
+ value = cloneBytes(value)
+ }
+
// If this is a writable transaction then we need to copy the bucket entry.
// Read-only transactions can point directly at the mmap entry.
- if b.tx.writable {
+ if b.tx.writable && !unaligned {
child.bucket = &bucket{}
*child.bucket = *(*bucket)(unsafe.Pointer(&value[0]))
} else {