-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Loading status checks…
Support attach fentry/fexit/fmod_ret
Signed-off-by: Viet Anh Duong <[email protected]>
1 parent
201f029
commit e116cd7
Showing
3 changed files
with
88 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
package byteorder | ||
|
||
import ( | ||
"encoding/binary" | ||
"unsafe" | ||
) | ||
|
||
var byteOrder binary.ByteOrder | ||
|
||
// In lack of binary.HostEndian ... | ||
func init() { | ||
byteOrder = determineHostByteOrder() | ||
} | ||
|
||
// GetHostByteOrder returns the current byte-order. | ||
func GetHostByteOrder() binary.ByteOrder { | ||
return byteOrder | ||
} | ||
|
||
func determineHostByteOrder() binary.ByteOrder { | ||
var i int32 = 0x01020304 | ||
u := unsafe.Pointer(&i) | ||
pb := (*byte)(u) | ||
b := *pb | ||
if b == 0x04 { | ||
return binary.LittleEndian | ||
} | ||
return binary.BigEndian | ||
} |
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,11 @@ | ||
package byteorder | ||
|
||
import "testing" | ||
|
||
func TestByteOrder(t *testing.T) { | ||
byteOrder = determineHostByteOrder() | ||
bo := GetHostByteOrder() | ||
if bo == nil { | ||
t.Fatal("GetHostByteOrder() returned nil") | ||
} | ||
} |