Commit 11443270 authored by Aaron Jacobs's avatar Aaron Jacobs

Check alignment.

parent c210aa8a
......@@ -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() {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment