diff options
author | Ben Johnson <benbjohnson@yahoo.com> | 2016-09-06 14:07:22 -0600 |
---|---|---|
committer | GitHub <noreply@github.com> | 2016-09-06 14:07:22 -0600 |
commit | de827651490d8e41c73f66cc6fc121b85d2d6496 (patch) | |
tree | 1b0e0eae0426c88e6c0a83ec0247052b309529b3 /bucket.go | |
parent | Merge pull request #590 from benbjohnson/vincent-petithory-compact-db (diff) | |
parent | bucket: correct broken unaligned load/store in armv5 (diff) | |
download | dedo-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.go | 10 |
1 files changed, 9 insertions, 1 deletions
@@ -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 { |