Linux Kernel
3.7.1
Main Page
Related Pages
Modules
Namespaces
Data Structures
Files
File List
Globals
All
Data Structures
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Macros
Groups
Pages
include
asm-generic
mutex-dec.h
Go to the documentation of this file.
1
/*
2
* include/asm-generic/mutex-dec.h
3
*
4
* Generic implementation of the mutex fastpath, based on atomic
5
* decrement/increment.
6
*/
7
#ifndef _ASM_GENERIC_MUTEX_DEC_H
8
#define _ASM_GENERIC_MUTEX_DEC_H
9
20
static
inline
void
21
__mutex_fastpath_lock
(
atomic_t
*
count
,
void
(*fail_fn)(
atomic_t
*))
22
{
23
if
(
unlikely
(
atomic_dec_return
(count) < 0))
24
fail_fn(count);
25
}
26
37
static
inline
int
38
__mutex_fastpath_lock_retval
(
atomic_t
*count,
int
(*fail_fn)(
atomic_t
*))
39
{
40
if
(
unlikely
(
atomic_dec_return
(count) < 0))
41
return
fail_fn(count);
42
return
0;
43
}
44
58
static
inline
void
59
__mutex_fastpath_unlock
(
atomic_t
*count,
void
(*fail_fn)(
atomic_t
*))
60
{
61
if
(
unlikely
(
atomic_inc_return
(count) <= 0))
62
fail_fn(count);
63
}
64
65
#define __mutex_slowpath_needs_to_unlock() 1
66
82
static
inline
int
83
__mutex_fastpath_trylock
(
atomic_t
*count,
int
(*fail_fn)(
atomic_t
*))
84
{
85
if
(
likely
(
atomic_cmpxchg
(count, 1, 0) == 1))
86
return
1;
87
return
0;
88
}
89
90
#endif
Generated on Thu Jan 10 2013 14:50:52 for Linux Kernel by
1.8.2