Skip to content

Commit

Permalink
feat: modernise tracing endian.go to use binary.NativeEndian
Browse files Browse the repository at this point in the history
  • Loading branch information
pkoutsovasilis committed Jan 24, 2024
1 parent 12e057c commit cd3c3b1
Showing 1 changed file with 1 addition and 15 deletions.
16 changes: 1 addition & 15 deletions auditbeat/tracing/endian.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,22 +21,8 @@ package tracing

import (
"encoding/binary"
"unsafe"
)

// MachineEndian is either binary.BigEndian or binary.LittleEndian, depending
// on the current architecture.
var MachineEndian = getCPUEndianness()

func getCPUEndianness() binary.ByteOrder {
myInt32 := new(uint32)
copy((*[4]byte)(unsafe.Pointer(myInt32))[:], []byte{0x12, 0x34, 0x56, 0x78})
switch *myInt32 {
case 0x12345678:
return binary.BigEndian
case 0x78563412:
return binary.LittleEndian
default:
panic("cannot determine endianness")
}
}
var MachineEndian = binary.NativeEndian

0 comments on commit cd3c3b1

Please sign in to comment.