Check alignment.

geesefs-0-30-9
Aaron Jacobs 2015-07-28 16:23:10 +10:00
parent c210aa8a95
commit 114432703b
1 changed files with 12 additions and 0 deletions

View File

@ -15,6 +15,7 @@
package buffer
import (
"log"
"unsafe"
"github.com/jacobsa/fuse/internal/fusekernel"
@ -36,6 +37,17 @@ type OutMessage struct {
storage [outMessageSize]byte
}
// Make sure alignment works out correctly, at least for the header.
func init() {
a := unsafe.Alignof(OutMessage{})
o := unsafe.Offsetof(OutMessage{}.storage)
e := unsafe.Alignof(fusekernel.OutHeader{})
if a%e != 0 || o%e != 0 {
log.Panicf("Bad alignment or offset: %d, %d, need %d", a, o, e)
}
}
// Reset the message so that it is ready to be used again. Afterward, the
// contents are solely a zeroed header.
func (m *OutMessage) Reset() {