1*5f97768dSMatthew Dillon /*
2*5f97768dSMatthew Dillon * SUBR_RBTREE.C - Generic red-black tree support
3*5f97768dSMatthew Dillon *
4*5f97768dSMatthew Dillon * Copyright (c) 2011 The DragonFly Project. All rights reserved.
5*5f97768dSMatthew Dillon *
6*5f97768dSMatthew Dillon * This code is derived from software contributed to The DragonFly Project
7*5f97768dSMatthew Dillon * by Matthew Dillon <dillon@backplane.com>
8*5f97768dSMatthew Dillon *
9*5f97768dSMatthew Dillon * Redistribution and use in source and binary forms, with or without
10*5f97768dSMatthew Dillon * modification, are permitted provided that the following conditions
11*5f97768dSMatthew Dillon * are met:
12*5f97768dSMatthew Dillon *
13*5f97768dSMatthew Dillon * 1. Redistributions of source code must retain the above copyright
14*5f97768dSMatthew Dillon * notice, this list of conditions and the following disclaimer.
15*5f97768dSMatthew Dillon * 2. Redistributions in binary form must reproduce the above copyright
16*5f97768dSMatthew Dillon * notice, this list of conditions and the following disclaimer in
17*5f97768dSMatthew Dillon * the documentation and/or other materials provided with the
18*5f97768dSMatthew Dillon * distribution.
19*5f97768dSMatthew Dillon * 3. Neither the name of The DragonFly Project nor the names of its
20*5f97768dSMatthew Dillon * contributors may be used to endorse or promote products derived
21*5f97768dSMatthew Dillon * from this software without specific, prior written permission.
22*5f97768dSMatthew Dillon *
23*5f97768dSMatthew Dillon * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
24*5f97768dSMatthew Dillon * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
25*5f97768dSMatthew Dillon * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
26*5f97768dSMatthew Dillon * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
27*5f97768dSMatthew Dillon * COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
28*5f97768dSMatthew Dillon * INCIDENTAL, SPECIAL, EXEMPLARY OR CONSEQUENTIAL DAMAGES (INCLUDING,
29*5f97768dSMatthew Dillon * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30*5f97768dSMatthew Dillon * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
31*5f97768dSMatthew Dillon * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
32*5f97768dSMatthew Dillon * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
33*5f97768dSMatthew Dillon * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
34*5f97768dSMatthew Dillon * SUCH DAMAGE.
35*5f97768dSMatthew Dillon */
36*5f97768dSMatthew Dillon
37*5f97768dSMatthew Dillon #include <sys/param.h>
38*5f97768dSMatthew Dillon #include <sys/kernel.h>
39*5f97768dSMatthew Dillon #include <sys/spinlock.h>
40*5f97768dSMatthew Dillon #include <sys/tree.h>
41*5f97768dSMatthew Dillon
42*5f97768dSMatthew Dillon #include <sys/spinlock2.h>
43*5f97768dSMatthew Dillon
44*5f97768dSMatthew Dillon /*
45*5f97768dSMatthew Dillon * Support function for RB_SCAN. The info linkage functions require a
46*5f97768dSMatthew Dillon * temporary spinlock to avoid running over each other when RB_SCAN()
47*5f97768dSMatthew Dillon * is called with a shared lock held instread of an exclusive lock.
48*5f97768dSMatthew Dillon *
49*5f97768dSMatthew Dillon * (e.g. shared VM object locks).
50*5f97768dSMatthew Dillon */
51*5f97768dSMatthew Dillon void
rb_spin_lock(struct spinlock * spin)52*5f97768dSMatthew Dillon rb_spin_lock(struct spinlock *spin)
53*5f97768dSMatthew Dillon {
54*5f97768dSMatthew Dillon spin_lock(spin);
55*5f97768dSMatthew Dillon }
56*5f97768dSMatthew Dillon
57*5f97768dSMatthew Dillon void
rb_spin_unlock(struct spinlock * spin)58*5f97768dSMatthew Dillon rb_spin_unlock(struct spinlock *spin)
59*5f97768dSMatthew Dillon {
60*5f97768dSMatthew Dillon spin_unlock(spin);
61*5f97768dSMatthew Dillon }
62