From 12e07bde626971f0b6038b2e0779443ce161e178 Mon Sep 17 00:00:00 2001 From: Tobias Weingartner Date: Thu, 13 Aug 2009 13:24:56 +0000 Subject: A new(er) mtx_enter_try(). Ok oga@, "the time is now" deraadt@. --- sys/arch/sh/sh/mutex.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) (limited to 'sys/arch/sh') diff --git a/sys/arch/sh/sh/mutex.c b/sys/arch/sh/sh/mutex.c index 591b434417f..66f08391e9b 100644 --- a/sys/arch/sh/sh/mutex.c +++ b/sys/arch/sh/sh/mutex.c @@ -1,4 +1,4 @@ -/* $OpenBSD: mutex.c,v 1.3 2009/04/27 21:48:56 kettenis Exp $ */ +/* $OpenBSD: mutex.c,v 1.4 2009/08/13 13:24:55 weingart Exp $ */ /* * Copyright (c) 2004 Artur Grabowski @@ -57,6 +57,17 @@ mtx_enter(struct mutex *mtx) mtx->mtx_lock = 1; } +int +mtx_enter_try(struct mutex *mtx) +{ + if (mtx->mtx_wantipl != IPL_NONE) + mtx->mtx_oldipl = _cpu_intr_raise(mtx->mtx_wantipl); + MUTEX_ASSERT_UNLOCKED(mtx); + mtx->mtx_lock = 1; + + return 1; +} + void mtx_leave(struct mutex *mtx) { -- cgit v1.2.3