aboutsummaryrefslogtreecommitdiffstats
path: root/vendor/golang.org/x/sys/unix/affinity_linux.go
diff options
context:
space:
mode:
authorLibravatar Rutger Broekhoff2024-01-02 18:56:31 +0100
committerLibravatar Rutger Broekhoff2024-01-02 18:56:31 +0100
commit8db41da676ac8368ef7c2549d56239a5ff5eedde (patch)
tree09c427fd66de2ec1ebffc8342f5fdbb84b0701b5 /vendor/golang.org/x/sys/unix/affinity_linux.go
parentd4f75fb6db22e57577867445a022227e70958931 (diff)
downloadgitolfs3-8db41da676ac8368ef7c2549d56239a5ff5eedde.tar.gz
gitolfs3-8db41da676ac8368ef7c2549d56239a5ff5eedde.zip
Delete vendor directory
Diffstat (limited to 'vendor/golang.org/x/sys/unix/affinity_linux.go')
-rw-r--r--vendor/golang.org/x/sys/unix/affinity_linux.go86
1 files changed, 0 insertions, 86 deletions
diff --git a/vendor/golang.org/x/sys/unix/affinity_linux.go b/vendor/golang.org/x/sys/unix/affinity_linux.go
deleted file mode 100644
index 6e5c81a..0000000
--- a/vendor/golang.org/x/sys/unix/affinity_linux.go
+++ /dev/null
@@ -1,86 +0,0 @@
1// Copyright 2018 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// CPU affinity functions
6
7package unix
8
9import (
10 "math/bits"
11 "unsafe"
12)
13
14const cpuSetSize = _CPU_SETSIZE / _NCPUBITS
15
16// CPUSet represents a CPU affinity mask.
17type CPUSet [cpuSetSize]cpuMask
18
19func schedAffinity(trap uintptr, pid int, set *CPUSet) error {
20 _, _, e := RawSyscall(trap, uintptr(pid), uintptr(unsafe.Sizeof(*set)), uintptr(unsafe.Pointer(set)))
21 if e != 0 {
22 return errnoErr(e)
23 }
24 return nil
25}
26
27// SchedGetaffinity gets the CPU affinity mask of the thread specified by pid.
28// If pid is 0 the calling thread is used.
29func SchedGetaffinity(pid int, set *CPUSet) error {
30 return schedAffinity(SYS_SCHED_GETAFFINITY, pid, set)
31}
32
33// SchedSetaffinity sets the CPU affinity mask of the thread specified by pid.
34// If pid is 0 the calling thread is used.
35func SchedSetaffinity(pid int, set *CPUSet) error {
36 return schedAffinity(SYS_SCHED_SETAFFINITY, pid, set)
37}
38
39// Zero clears the set s, so that it contains no CPUs.
40func (s *CPUSet) Zero() {
41 for i := range s {
42 s[i] = 0
43 }
44}
45
46func cpuBitsIndex(cpu int) int {
47 return cpu / _NCPUBITS
48}
49
50func cpuBitsMask(cpu int) cpuMask {
51 return cpuMask(1 << (uint(cpu) % _NCPUBITS))
52}
53
54// Set adds cpu to the set s.
55func (s *CPUSet) Set(cpu int) {
56 i := cpuBitsIndex(cpu)
57 if i < len(s) {
58 s[i] |= cpuBitsMask(cpu)
59 }
60}
61
62// Clear removes cpu from the set s.
63func (s *CPUSet) Clear(cpu int) {
64 i := cpuBitsIndex(cpu)
65 if i < len(s) {
66 s[i] &^= cpuBitsMask(cpu)
67 }
68}
69
70// IsSet reports whether cpu is in the set s.
71func (s *CPUSet) IsSet(cpu int) bool {
72 i := cpuBitsIndex(cpu)
73 if i < len(s) {
74 return s[i]&cpuBitsMask(cpu) != 0
75 }
76 return false
77}
78
79// Count returns the number of CPUs in the set s.
80func (s *CPUSet) Count() int {
81 c := 0
82 for _, b := range s {
83 c += bits.OnesCount64(uint64(b))
84 }
85 return c
86}