Skip to content

Commit

Permalink
round up
Browse files Browse the repository at this point in the history
  • Loading branch information
TotallyGamerJet committed Jan 3, 2024
1 parent a1d938d commit 1724686
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions func.go
Original file line number Diff line number Diff line change
Expand Up @@ -581,11 +581,13 @@ func addStruct(v reflect.Value, numInts, numFloats, numStack *int, addInt, addFl
panic("purego: struct has field that can't be allocated")
}

func roundUpTo8(val uintptr) uintptr {
return (val + 7) &^ 7
}

func isHFA(t reflect.Type) bool {
structSize := t.Size()
// round up struct size to nearest 8 see section B.4
structSize += 7
structSize &^= 7
structSize := roundUpTo8(t.Size())
if structSize == 0 || t.NumField() > 4 {
return false
}
Expand All @@ -612,10 +614,8 @@ func isHFA(t reflect.Type) bool {
}

func isHVA(t reflect.Type) bool {
structSize := t.Size()
// round up struct size to nearest 8 see section B.4
structSize += 7
structSize &^= 7
structSize := roundUpTo8(t.Size())
if structSize == 0 || (structSize != 8 && structSize != 16) {
return false
}
Expand Down

0 comments on commit 1724686

Please sign in to comment.