Debian Codegraph @

libgo/go/syscall/syscall_dragonfly.go

raw
1 // Copyright 2009 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
5 package syscall
6
7 import (
8 "sync"
9 "unsafe"
10 )
11
12 const _SYS_DUP3 = 0
13
14 // See version list in https://github.com/DragonFlyBSD/DragonFlyBSD/blob/master/sys/sys/param.h
15 var (
16 osreldateOnce sync.Once
17 osreldate uint32
18 )
19
20 // First __DragonFly_version after September 2019 ABI changes
21 // http://lists.dragonflybsd.org/pipermail/users/2019-September/358280.html
22 const _dragonflyABIChangeVersion = 500705
23
24 func supportsABI(ver uint32) bool {
25 osreldateOnce.Do(func() { osreldate, _ = SysctlUint32("kern.osreldate") })
26 return osreldate >= ver
27 }
28
29 func direntIno(buf []byte) (uint64, bool) {
30 return readInt(buf, unsafe.Offsetof(Dirent{}.Fileno), unsafe.Sizeof(Dirent{}.Fileno))
31 }
32
33 func direntReclen(buf []byte) (uint64, bool) {
34 namlen, ok := direntNamlen(buf)
35 if !ok {
36 return 0, false
37 }
38 return (16 + namlen + 1 + 7) &^ 7, true
39 }
40
41 func direntNamlen(buf []byte) (uint64, bool) {
42 return readInt(buf, unsafe.Offsetof(Dirent{}.Namlen), unsafe.Sizeof(Dirent{}.Namlen))
43 }