Check alignment.
parent
c210aa8a95
commit
114432703b
|
@ -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() {
|
||||
|
|
Loading…
Reference in New Issue