helper.go 532 B

123456789101112131415161718192021222324252627
  1. // Copyright 2016 The Go Authors. All rights reserved.
  2. // Use of this source code is governed by a BSD-style
  3. // license that can be found in the LICENSE file.
  4. package icmp
  5. import (
  6. "encoding/binary"
  7. "unsafe"
  8. )
  9. var (
  10. // See http://www.freebsd.org/doc/en/books/porters-handbook/freebsd-versions.html.
  11. freebsdVersion uint32
  12. nativeEndian binary.ByteOrder
  13. )
  14. func init() {
  15. i := uint32(1)
  16. b := (*[4]byte)(unsafe.Pointer(&i))
  17. if b[0] == 1 {
  18. nativeEndian = binary.LittleEndian
  19. } else {
  20. nativeEndian = binary.BigEndian
  21. }
  22. }