kern_rwlock.c (255745) | kern_rwlock.c (255788) |
---|---|
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 255745 2013-09-20 23:06:21Z davide $"); | 35__FBSDID("$FreeBSD: head/sys/kern/kern_rwlock.c 255788 2013-09-22 14:09:07Z 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> --- 98 unchanged lines hidden (view full) --- 142 143void 144lock_rw(struct lock_object *lock, uintptr_t how) 145{ 146 struct rwlock *rw; 147 148 rw = (struct rwlock *)lock; 149 if (how) | 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> --- 98 unchanged lines hidden (view full) --- 142 143void 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); | 150 rw_rlock(rw); |
151 else 152 rw_wlock(rw); |
|
153} 154 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); | 153} 154 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); |
164 return (0); | 164 return (1); |
165 } else { 166 rw_wunlock(rw); | 165 } else { 166 rw_wunlock(rw); |
167 return (1); | 167 return (0); |
168 } 169} 170 171#ifdef KDTRACE_HOOKS 172int 173owner_rw(const struct lock_object *lock, struct thread **owner) 174{ 175 const struct rwlock *rw = (const struct rwlock *)lock; --- 1057 unchanged lines hidden --- | 168 } 169} 170 171#ifdef KDTRACE_HOOKS 172int 173owner_rw(const struct lock_object *lock, struct thread **owner) 174{ 175 const struct rwlock *rw = (const struct rwlock *)lock; --- 1057 unchanged lines hidden --- |