github.com/nicocha30/gvisor-ligolo@v0.0.0-20230726075806-989fa2c0a413/pkg/abi/linux/futex.go (about) 1 // Copyright 2018 The gVisor Authors. 2 // 3 // Licensed under the Apache License, Version 2.0 (the "License"); 4 // you may not use this file except in compliance with the License. 5 // You may obtain a copy of the License at 6 // 7 // http://www.apache.org/licenses/LICENSE-2.0 8 // 9 // Unless required by applicable law or agreed to in writing, software 10 // distributed under the License is distributed on an "AS IS" BASIS, 11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 // See the License for the specific language governing permissions and 13 // limitations under the License. 14 15 package linux 16 17 // From <linux/futex.h> and <sys/time.h>. 18 // Flags are used in syscall futex(2). 19 const ( 20 FUTEX_WAIT = 0 21 FUTEX_WAKE = 1 22 FUTEX_FD = 2 23 FUTEX_REQUEUE = 3 24 FUTEX_CMP_REQUEUE = 4 25 FUTEX_WAKE_OP = 5 26 FUTEX_LOCK_PI = 6 27 FUTEX_UNLOCK_PI = 7 28 FUTEX_TRYLOCK_PI = 8 29 FUTEX_WAIT_BITSET = 9 30 FUTEX_WAKE_BITSET = 10 31 FUTEX_WAIT_REQUEUE_PI = 11 32 FUTEX_CMP_REQUEUE_PI = 12 33 34 FUTEX_PRIVATE_FLAG = 128 35 FUTEX_CLOCK_REALTIME = 256 36 ) 37 38 // These are flags are from <linux/futex.h> and are used in FUTEX_WAKE_OP 39 // to define the operations. 40 const ( 41 FUTEX_OP_SET = 0 42 FUTEX_OP_ADD = 1 43 FUTEX_OP_OR = 2 44 FUTEX_OP_ANDN = 3 45 FUTEX_OP_XOR = 4 46 FUTEX_OP_OPARG_SHIFT = 8 47 FUTEX_OP_CMP_EQ = 0 48 FUTEX_OP_CMP_NE = 1 49 FUTEX_OP_CMP_LT = 2 50 FUTEX_OP_CMP_LE = 3 51 FUTEX_OP_CMP_GT = 4 52 FUTEX_OP_CMP_GE = 5 53 ) 54 55 // FUTEX_TID_MASK is the TID portion of a PI futex word. 56 const FUTEX_TID_MASK = 0x3fffffff 57 58 // Constants used for priority-inheritance futexes. 59 const ( 60 FUTEX_WAITERS = 0x80000000 61 FUTEX_OWNER_DIED = 0x40000000 62 ) 63 64 // FUTEX_BITSET_MATCH_ANY has all bits set. 65 const FUTEX_BITSET_MATCH_ANY = 0xffffffff 66 67 // ROBUST_LIST_LIMIT protects against a deliberately circular list. 68 const ROBUST_LIST_LIMIT = 2048 69 70 // RobustListHead corresponds to Linux's struct robust_list_head. 71 // 72 // +marshal 73 type RobustListHead struct { 74 List uint64 75 FutexOffset uint64 76 ListOpPending uint64 77 } 78 79 // SizeOfRobustListHead is the size of a RobustListHead struct. 80 var SizeOfRobustListHead = (*RobustListHead)(nil).SizeBytes()