aboutsummaryrefslogtreecommitdiff
path: root/nexgb/xgbgen/go.go
diff options
context:
space:
mode:
Diffstat (limited to 'nexgb/xgbgen/go.go')
-rw-r--r--nexgb/xgbgen/go.go18
1 files changed, 15 insertions, 3 deletions
diff --git a/nexgb/xgbgen/go.go b/nexgb/xgbgen/go.go
index 6c680e8..ace4e00 100644
--- a/nexgb/xgbgen/go.go
+++ b/nexgb/xgbgen/go.go
@@ -103,15 +103,27 @@ func (td *TypeDef) Define(c *Context) {
// Pad fields
func (f *PadField) Define(c *Context) {
- c.Putln("// padding: %d bytes", f.Bytes)
+ if f.Align > 0 {
+ c.Putln("// alignment gap to multiple of %d", f.Align)
+ } else {
+ c.Putln("// padding: %d bytes", f.Bytes)
+ }
}
func (f *PadField) Read(c *Context, prefix string) {
- c.Putln("b += %s // padding", f.Size())
+ if f.Align > 0 {
+ c.Putln("b = (b + %d) & ^%d // alignment gap", f.Align-1, f.Align-1)
+ } else {
+ c.Putln("b += %s // padding", f.Size())
+ }
}
func (f *PadField) Write(c *Context, prefix string) {
- c.Putln("b += %s // padding", f.Size())
+ if f.Align > 0 {
+ c.Putln("b = (b + %d) & ^%d // alignment gap", f.Align-1, f.Align-1)
+ } else {
+ c.Putln("b += %s // padding", f.Size())
+ }
}
// Local fields