Commit 9eb5e079 authored by Aaron Jacobs's avatar Aaron Jacobs

buffer: define OutMessage's contents.

parent 6e5247d1
......@@ -33,12 +33,18 @@ const OutMessageHeaderSize = unsafe.Sizeof(fusekernel.OutHeader{})
//
// Must be initialized with Reset.
type OutMessage struct {
// The offset into payload to which we're currently writing.
payloadOffset int
header [OutMessageHeaderSize]byte
payload [MaxReadSize]byte
}
// Make sure alignment works out correctly, at least for the header.
// Make sure that the header field is aligned correctly for
// fusekernel.OutHeader type punning.
func init() {
a := unsafe.Alignof(OutMessage{})
o := unsafe.Offsetof(OutMessage{}.storage)
o := unsafe.Offsetof(OutMessage{}.header)
e := unsafe.Alignof(fusekernel.OutHeader{})
if a%e != 0 || o%e != 0 {
......@@ -46,6 +52,18 @@ func init() {
}
}
// Make sure that the header and payload are contiguous.
func init() {
a := unsafe.Offsetof(OutMessage{}.header) + OutMessageHeaderSize
b := unsafe.Offsetof(OutMessage{}.payload)
if a != b {
log.Panicf(
"header ends at offset %d, but payload starts at offset %d",
a, b)
}
}
// Reset resets m so that it's ready to be used again. Afterward, the contents
// are solely a zeroed fusekernel.OutHeader struct.
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