-
Notifications
You must be signed in to change notification settings - Fork 45
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix bug with atomic for 32 bit architectures
- Loading branch information
1 parent
6bf1d84
commit f791660
Showing
3 changed files
with
30 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
package alignment | ||
|
||
import ( | ||
"fmt" | ||
"reflect" | ||
) | ||
|
||
// PrintStruct prints detailed information of struct fields alignment. | ||
func PrintStruct(v interface{}) { | ||
typ := reflect.TypeOf(v) | ||
fmt.Printf("Struct is %d bytes long\n", typ.Size()) | ||
// We can run through the fields in the structure in order | ||
n := typ.NumField() | ||
for i := 0; i < n; i++ { | ||
field := typ.Field(i) | ||
fmt.Printf("%s at offset %v, size=%d, align=%d\n", | ||
field.Name, field.Offset, field.Type.Size(), | ||
field.Type.Align()) | ||
} | ||
} |