summaryrefslogtreecommitdiffstats
path: root/sys/kern/kern_mtxpool.c
diff options
context:
space:
mode:
authormux <mux@FreeBSD.org>2003-06-13 19:39:21 +0000
committermux <mux@FreeBSD.org>2003-06-13 19:39:21 +0000
commitc4ee7613fb723d0e7a9cfc0902efc6036d54ad12 (patch)
treec5e05d919dd1062c4ffbaadb4e1e0dba806a4d60 /sys/kern/kern_mtxpool.c
parent83fd8b219f97b55ffe01f54ad4dc3812e2f659f6 (diff)
downloadFreeBSD-src-c4ee7613fb723d0e7a9cfc0902efc6036d54ad12.zip
FreeBSD-src-c4ee7613fb723d0e7a9cfc0902efc6036d54ad12.tar.gz
Style(9).
Diffstat (limited to 'sys/kern/kern_mtxpool.c')
-rw-r--r--sys/kern/kern_mtxpool.c31
1 files changed, 17 insertions, 14 deletions
diff --git a/sys/kern/kern_mtxpool.c b/sys/kern/kern_mtxpool.c
index 87e4adb..b93fcfa 100644
--- a/sys/kern/kern_mtxpool.c
+++ b/sys/kern/kern_mtxpool.c
@@ -1,5 +1,5 @@
/*-
- * Copyright (c) 2001 Matthew Dillon. All Rights Reserved. Copyright
+ * Copyright (c) 2001 Matthew Dillon. All Rights Reserved. Copyright
* terms are as specified in the COPYRIGHT file at the base of the source
* tree.
*
@@ -14,13 +14,13 @@
* without adding bloat to the structures.
* - mutexes can be obtained for invalid pointers, useful when uses
* mutexes to interlock destructor ops.
- * - no initialization/destructor overhead
+ * - no initialization/destructor overhead.
* - can be used with msleep.
*
* Disadvantages:
- * - should generally only be used as leaf mutexes
+ * - should generally only be used as leaf mutexes.
* - pool/pool dependancy ordering cannot be depended on.
- * - possible L1 cache mastersip contention between cpus
+ * - possible L1 cache mastersip contention between cpus.
*/
#include <sys/cdefs.h>
@@ -38,7 +38,7 @@ __FBSDID("$FreeBSD$");
#ifndef MTX_POOL_SIZE
#define MTX_POOL_SIZE 128
#endif
-#define MTX_POOL_MASK (MTX_POOL_SIZE-1)
+#define MTX_POOL_MASK (MTX_POOL_SIZE - 1)
static struct mtx mtx_pool_ary[MTX_POOL_SIZE];
@@ -48,14 +48,13 @@ int mtx_pool_valid = 0;
* Inline version of mtx_pool_find(), used to streamline our main API
* function calls.
*/
-static __inline
-struct mtx *
+static __inline struct mtx *
_mtx_pool_find(void *ptr)
{
int p;
p = (int)(uintptr_t)ptr;
- return(&mtx_pool_ary[(p ^ (p >> 6)) & MTX_POOL_MASK]);
+ return (&mtx_pool_ary[(p ^ (p >> 6)) & MTX_POOL_MASK]);
}
static void
@@ -64,7 +63,8 @@ mtx_pool_setup(void *dummy __unused)
int i;
for (i = 0; i < MTX_POOL_SIZE; ++i)
- mtx_init(&mtx_pool_ary[i], "pool mutex", NULL, MTX_DEF | MTX_NOWITNESS | MTX_QUIET);
+ mtx_init(&mtx_pool_ary[i], "pool mutex", NULL,
+ MTX_DEF | MTX_NOWITNESS | MTX_QUIET);
mtx_pool_valid = 1;
}
@@ -77,7 +77,8 @@ struct mtx *
mtx_pool_alloc(void)
{
static int si;
- return(&mtx_pool_ary[si++ & MTX_POOL_MASK]);
+
+ return (&mtx_pool_ary[si++ & MTX_POOL_MASK]);
}
/*
@@ -89,16 +90,18 @@ mtx_pool_alloc(void)
struct mtx *
mtx_pool_find(void *ptr)
{
- return(_mtx_pool_find(ptr));
+
+ return (_mtx_pool_find(ptr));
}
/*
* Combined find/lock operation. Lock the pool mutex associated with
* the specified address.
*/
-void
+void
mtx_pool_lock(void *ptr)
{
+
mtx_lock(_mtx_pool_find(ptr));
}
@@ -109,8 +112,8 @@ mtx_pool_lock(void *ptr)
void
mtx_pool_unlock(void *ptr)
{
+
mtx_unlock(_mtx_pool_find(ptr));
}
-SYSINIT(mtxpooli, SI_SUB_MTX_POOL, SI_ORDER_FIRST, mtx_pool_setup, NULL)
-
+SYSINIT(mtxpooli, SI_SUB_MTX_POOL, SI_ORDER_FIRST, mtx_pool_setup, NULL);
OpenPOWER on IntegriCloud