mirror of
https://github.com/opencontainers/runc.git
synced 2025-10-09 09:20:10 +08:00

The implementation is based on https://github.com/containers/crun/blob/0.10.2/src/libcrun/ebpf.c Although ebpf.c is originally licensed under LGPL-3.0-or-later, the author Giuseppe Scrivano agreed to relicense the file in Apache License 2.0: https://github.com/opencontainers/runc/issues/2144#issuecomment-543116397 See libcontainer/cgroups/ebpf/devicefilter/devicefilter_test.go for tested configurations. Signed-off-by: Akihiro Suda <akihiro.suda.cz@hco.ntt.co.jp>
25 lines
454 B
Go
25 lines
454 B
Go
package internal
|
|
|
|
import (
|
|
"encoding/binary"
|
|
"unsafe"
|
|
)
|
|
|
|
// NativeEndian is set to either binary.BigEndian or binary.LittleEndian,
|
|
// depending on the host's endianness.
|
|
var NativeEndian binary.ByteOrder
|
|
|
|
func init() {
|
|
if isBigEndian() {
|
|
NativeEndian = binary.BigEndian
|
|
} else {
|
|
NativeEndian = binary.LittleEndian
|
|
}
|
|
}
|
|
|
|
func isBigEndian() (ret bool) {
|
|
i := int(0x1)
|
|
bs := (*[int(unsafe.Sizeof(i))]byte)(unsafe.Pointer(&i))
|
|
return bs[0] == 0
|
|
}
|