kern_rwlock.c (252212) | kern_rwlock.c (255745) |
---|---|
1/*- 2 * Copyright (c) 2006 John Baldwin <jhb@FreeBSD.org> 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright --- 18 unchanged lines hidden (view full) --- 27 * SUCH DAMAGE. 28 */ 29 30/* 31 * Machine independent bits of reader/writer lock implementation. 32 */ 33 34#include <sys/cdefs.h> | 1/*- 2 * Copyright (c) 2006 John Baldwin <jhb@FreeBSD.org> 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright --- 18 unchanged lines hidden (view full) --- 27 * SUCH DAMAGE. 28 */ 29 30/* 31 * Machine independent bits of reader/writer lock implementation. 32 */ 33 34#include <sys/cdefs.h> |
35__FBSDID("$FreeBSD: head/sys/kern/kern_rwlock.c 252212 2013-06-25 20:23:08Z jhb $"); | 35__FBSDID("$FreeBSD: head/sys/kern/kern_rwlock.c 255745 2013-09-20 23:06:21Z davide $"); |
36 37#include "opt_ddb.h" 38#include "opt_hwpmc_hooks.h" 39#include "opt_kdtrace.h" 40#include "opt_no_adaptive_rwlocks.h" 41 42#include <sys/param.h> 43#include <sys/kdb.h> --- 34 unchanged lines hidden (view full) --- 78#endif 79 80#ifdef DDB 81#include <ddb/ddb.h> 82 83static void db_show_rwlock(const struct lock_object *lock); 84#endif 85static void assert_rw(const struct lock_object *lock, int what); | 36 37#include "opt_ddb.h" 38#include "opt_hwpmc_hooks.h" 39#include "opt_kdtrace.h" 40#include "opt_no_adaptive_rwlocks.h" 41 42#include <sys/param.h> 43#include <sys/kdb.h> --- 34 unchanged lines hidden (view full) --- 78#endif 79 80#ifdef DDB 81#include <ddb/ddb.h> 82 83static void db_show_rwlock(const struct lock_object *lock); 84#endif 85static void assert_rw(const struct lock_object *lock, int what); |
86static void lock_rw(struct lock_object *lock, int how); | 86static void lock_rw(struct lock_object *lock, uintptr_t how); |
87#ifdef KDTRACE_HOOKS 88static int owner_rw(const struct lock_object *lock, struct thread **owner); 89#endif | 87#ifdef KDTRACE_HOOKS 88static int owner_rw(const struct lock_object *lock, struct thread **owner); 89#endif |
90static int unlock_rw(struct lock_object *lock); | 90static uintptr_t unlock_rw(struct lock_object *lock); |
91 92struct lock_class lock_class_rw = { 93 .lc_name = "rw", 94 .lc_flags = LC_SLEEPLOCK | LC_RECURSABLE | LC_UPGRADABLE, 95 .lc_assert = assert_rw, 96#ifdef DDB 97 .lc_ddb_show = db_show_rwlock, 98#endif --- 37 unchanged lines hidden (view full) --- 136void 137assert_rw(const struct lock_object *lock, int what) 138{ 139 140 rw_assert((const struct rwlock *)lock, what); 141} 142 143void | 91 92struct lock_class lock_class_rw = { 93 .lc_name = "rw", 94 .lc_flags = LC_SLEEPLOCK | LC_RECURSABLE | LC_UPGRADABLE, 95 .lc_assert = assert_rw, 96#ifdef DDB 97 .lc_ddb_show = db_show_rwlock, 98#endif --- 37 unchanged lines hidden (view full) --- 136void 137assert_rw(const struct lock_object *lock, int what) 138{ 139 140 rw_assert((const struct rwlock *)lock, what); 141} 142 143void |
144lock_rw(struct lock_object *lock, int how) | 144lock_rw(struct lock_object *lock, uintptr_t how) |
145{ 146 struct rwlock *rw; 147 148 rw = (struct rwlock *)lock; 149 if (how) 150 rw_wlock(rw); 151 else 152 rw_rlock(rw); 153} 154 | 145{ 146 struct rwlock *rw; 147 148 rw = (struct rwlock *)lock; 149 if (how) 150 rw_wlock(rw); 151 else 152 rw_rlock(rw); 153} 154 |
155int | 155uintptr_t |
156unlock_rw(struct lock_object *lock) 157{ 158 struct rwlock *rw; 159 160 rw = (struct rwlock *)lock; 161 rw_assert(rw, RA_LOCKED | LA_NOTRECURSED); 162 if (rw->rw_lock & RW_LOCK_READ) { 163 rw_runlock(rw); --- 1069 unchanged lines hidden --- | 156unlock_rw(struct lock_object *lock) 157{ 158 struct rwlock *rw; 159 160 rw = (struct rwlock *)lock; 161 rw_assert(rw, RA_LOCKED | LA_NOTRECURSED); 162 if (rw->rw_lock & RW_LOCK_READ) { 163 rw_runlock(rw); --- 1069 unchanged lines hidden --- |