1/* 2 * Copyright 2022, Haiku, Inc. All rights reserved. 3 * Distributed under the terms of the MIT License. 4 */ 5#ifndef _OBSD_COMPAT_SYS_MUTEX_H_ 6#define _OBSD_COMPAT_SYS_MUTEX_H_ 7 8 9#include_next <sys/mutex.h> 10 11 12struct mutex_openbsd { 13 struct mtx mtx; 14}; 15#define mutex mutex_openbsd 16 17 18static inline void 19mtx_init_openbsd(struct mutex* mtx, int wantipl) 20{ 21 mtx_init(&mtx->mtx, "OpenBSD mutex", NULL, 22 wantipl == IPL_NONE ? 0 : MTX_SPIN); 23} 24#define mtx_init(mutex, wantipl) mtx_init_openbsd(mutex, wantipl) 25 26 27static inline void 28mtx_enter(struct mutex* mtx) 29{ 30 mtx_lock(&mtx->mtx); 31} 32 33static inline void 34mtx_leave(struct mutex* mtx) 35{ 36 mtx_unlock(&mtx->mtx); 37} 38 39 40#endif /* _OBSD_COMPAT_SYS_MUTEX_H_ */ 41