Check alignment.
parent
c210aa8a95
commit
114432703b
|
@ -15,6 +15,7 @@
|
||||||
package buffer
|
package buffer
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"log"
|
||||||
"unsafe"
|
"unsafe"
|
||||||
|
|
||||||
"github.com/jacobsa/fuse/internal/fusekernel"
|
"github.com/jacobsa/fuse/internal/fusekernel"
|
||||||
|
@ -36,6 +37,17 @@ type OutMessage struct {
|
||||||
storage [outMessageSize]byte
|
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
|
// Reset the message so that it is ready to be used again. Afterward, the
|
||||||
// contents are solely a zeroed header.
|
// contents are solely a zeroed header.
|
||||||
func (m *OutMessage) Reset() {
|
func (m *OutMessage) Reset() {
|
||||||
|
|
Loading…
Reference in New Issue