Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 25 Nov 2017 20:22:51 +0000 (UTC)
From:      Mateusz Guzik <mjg@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r326197 - head/sys/kern
Message-ID:  <201711252022.vAPKMpga017458@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: mjg
Date: Sat Nov 25 20:22:51 2017
New Revision: 326197
URL: https://svnweb.freebsd.org/changeset/base/326197

Log:
  rwlock: add __rw_try_{r,w}lock_int

Modified:
  head/sys/kern/kern_rwlock.c

Modified: head/sys/kern/kern_rwlock.c
==============================================================================
--- head/sys/kern/kern_rwlock.c	Sat Nov 25 20:13:50 2017	(r326196)
+++ head/sys/kern/kern_rwlock.c	Sat Nov 25 20:22:51 2017	(r326197)
@@ -284,9 +284,8 @@ _rw_wlock_cookie(volatile uintptr_t *c, const char *fi
 }
 
 int
-__rw_try_wlock(volatile uintptr_t *c, const char *file, int line)
+__rw_try_wlock_int(struct rwlock *rw LOCK_FILE_LINE_ARG_DEF)
 {
-	struct rwlock *rw;
 	struct thread *td;
 	uintptr_t tid, v;
 	int rval;
@@ -297,8 +296,6 @@ __rw_try_wlock(volatile uintptr_t *c, const char *file
 	if (SCHEDULER_STOPPED_TD(td))
 		return (1);
 
-	rw = rwlock2rw(c);
-
 	KASSERT(kdb_active != 0 || !TD_IS_IDLETHREAD(td),
 	    ("rw_try_wlock() by idle thread %p on rwlock %s @ %s:%d",
 	    curthread, rw->lock_object.lo_name, file, line));
@@ -334,6 +331,15 @@ __rw_try_wlock(volatile uintptr_t *c, const char *file
 	return (rval);
 }
 
+int
+__rw_try_wlock(volatile uintptr_t *c, const char *file, int line)
+{
+	struct rwlock *rw;
+
+	rw = rwlock2rw(c);
+	return (__rw_try_wlock_int(rw, LOCK_FILE_LINE_ARG));
+}
+
 void
 _rw_wunlock_cookie(volatile uintptr_t *c, const char *file, int line)
 {
@@ -656,16 +662,13 @@ __rw_rlock(volatile uintptr_t *c, const char *file, in
 }
 
 int
-__rw_try_rlock(volatile uintptr_t *c, const char *file, int line)
+__rw_try_rlock_int(struct rwlock *rw LOCK_FILE_LINE_ARG_DEF)
 {
-	struct rwlock *rw;
 	uintptr_t x;
 
 	if (SCHEDULER_STOPPED())
 		return (1);
 
-	rw = rwlock2rw(c);
-
 	KASSERT(kdb_active != 0 || !TD_IS_IDLETHREAD(curthread),
 	    ("rw_try_rlock() by idle thread %p on rwlock %s @ %s:%d",
 	    curthread, rw->lock_object.lo_name, file, line));
@@ -690,6 +693,15 @@ __rw_try_rlock(volatile uintptr_t *c, const char *file
 
 	LOCK_LOG_TRY("RLOCK", &rw->lock_object, 0, 0, file, line);
 	return (0);
+}
+
+int
+__rw_try_rlock(volatile uintptr_t *c, const char *file, int line)
+{
+	struct rwlock *rw;
+
+	rw = rwlock2rw(c);
+	return (__rw_try_rlock_int(rw, LOCK_FILE_LINE_ARG));
 }
 
 static bool __always_inline



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201711252022.vAPKMpga017458>