/* $NetBSD: linux_futex.h,v 1.2 2005/12/11 12:20:19 christos Exp $ */12/*-3* SPDX-License-Identifier: BSD-4-Clause4*5* Copyright (c) 2005 Emmanuel Dreyfus, all rights reserved.6*7* Redistribution and use in source and binary forms, with or without8* modification, are permitted provided that the following conditions9* are met:10* 1. Redistributions of source code must retain the above copyright11* notice, this list of conditions and the following disclaimer.12* 2. Redistributions in binary form must reproduce the above copyright13* notice, this list of conditions and the following disclaimer in the14* documentation and/or other materials provided with the distribution.15* 3. All advertising materials mentioning features or use of this software16* must display the following acknowledgement:17* This product includes software developed by Emmanuel Dreyfus18* 4. The name of the author may not be used to endorse or promote19* products derived from this software without specific prior written20* permission.21*22* THIS SOFTWARE IS PROVIDED BY THE THE AUTHOR AND CONTRIBUTORS ``AS IS''23* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,24* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR25* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS26* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR27* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF28* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS29* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN30* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)31* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE32* POSSIBILITY OF SUCH DAMAGE.33*/3435#ifndef _LINUX_FUTEX_H36#define _LINUX_FUTEX_H3738#define LINUX_FUTEX_WAIT 039#define LINUX_FUTEX_WAKE 140#define LINUX_FUTEX_FD 2 /* unused */41#define LINUX_FUTEX_REQUEUE 342#define LINUX_FUTEX_CMP_REQUEUE 443#define LINUX_FUTEX_WAKE_OP 544#define LINUX_FUTEX_LOCK_PI 645#define LINUX_FUTEX_UNLOCK_PI 746#define LINUX_FUTEX_TRYLOCK_PI 847#define LINUX_FUTEX_WAIT_BITSET 948#define LINUX_FUTEX_WAKE_BITSET 1049#define LINUX_FUTEX_WAIT_REQUEUE_PI 1150#define LINUX_FUTEX_CMP_REQUEUE_PI 1251#define LINUX_FUTEX_LOCK_PI2 135253#define LINUX_FUTEX_PRIVATE_FLAG 12854#define LINUX_FUTEX_CLOCK_REALTIME 2565556#define LINUX_FUTEX_CMD_MASK ~(LINUX_FUTEX_PRIVATE_FLAG | \57LINUX_FUTEX_CLOCK_REALTIME)5859#define FUTEX_OP_SET 0 /* *(int *)UADDR2 = OPARG; */60#define FUTEX_OP_ADD 1 /* *(int *)UADDR2 += OPARG; */61#define FUTEX_OP_OR 2 /* *(int *)UADDR2 |= OPARG; */62#define FUTEX_OP_ANDN 3 /* *(int *)UADDR2 &= ~OPARG; */63#define FUTEX_OP_XOR 4 /* *(int *)UADDR2 ^= OPARG; */6465#define FUTEX_OP_OPARG_SHIFT 8 /* Use (1 << OPARG) instead of OPARG. */6667#define FUTEX_OP_CMP_EQ 0 /* if (oldval == CMPARG) wake */68#define FUTEX_OP_CMP_NE 1 /* if (oldval != CMPARG) wake */69#define FUTEX_OP_CMP_LT 2 /* if (oldval < CMPARG) wake */70#define FUTEX_OP_CMP_LE 3 /* if (oldval <= CMPARG) wake */71#define FUTEX_OP_CMP_GT 4 /* if (oldval > CMPARG) wake */72#define FUTEX_OP_CMP_GE 5 /* if (oldval >= CMPARG) wake */7374#define FUTEX_WAITERS 0x8000000075#define FUTEX_OWNER_DIED 0x4000000076#define FUTEX_TID_MASK 0x3fffffff77#define FUTEX_BITSET_MATCH_ANY 0xffffffff7879/* robust futexes */80struct linux_robust_list {81l_uintptr_t next;82};8384struct linux_robust_list_head {85struct linux_robust_list list;86l_long futex_offset;87l_uintptr_t pending_list;88};8990int futex_xchgl(int oparg, uint32_t *uaddr, int *oldval);91int futex_addl(int oparg, uint32_t *uaddr, int *oldval);92int futex_orl(int oparg, uint32_t *uaddr, int *oldval);93int futex_andl(int oparg, uint32_t *uaddr, int *oldval);94int futex_xorl(int oparg, uint32_t *uaddr, int *oldval);95int futex_wake(struct thread *td, uint32_t *uaddr, int val, bool shared);96void release_futexes(struct thread *,97struct linux_emuldata *);9899#endif /* !_LINUX_FUTEX_H */100101102