sys_dragonfly.go 925 B

1234567891011121314151617181920212223242526272829303132
  1. // Copyright 2017 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 socket
  5. import (
  6. "sync"
  7. "syscall"
  8. "unsafe"
  9. )
  10. // See version list in https://github.com/DragonFlyBSD/DragonFlyBSD/blob/master/sys/sys/param.h
  11. var (
  12. osreldateOnce sync.Once
  13. osreldate uint32
  14. )
  15. // First __DragonFly_version after September 2019 ABI changes
  16. // http://lists.dragonflybsd.org/pipermail/users/2019-September/358280.html
  17. const _dragonflyABIChangeVersion = 500705
  18. func probeProtocolStack() int {
  19. osreldateOnce.Do(func() { osreldate, _ = syscall.SysctlUint32("kern.osreldate") })
  20. var p uintptr
  21. if int(unsafe.Sizeof(p)) == 8 && osreldate >= _dragonflyABIChangeVersion {
  22. return int(unsafe.Sizeof(p))
  23. }
  24. // 64-bit Dragonfly before the September 2019 ABI changes still requires
  25. // 32-bit aligned access to network subsystem.
  26. return 4
  27. }