]>
Commit | Line | Data |
---|---|---|
716154c5 BB |
1 | /*****************************************************************************\ |
2 | * Copyright (C) 2007-2010 Lawrence Livermore National Security, LLC. | |
3 | * Copyright (C) 2007 The Regents of the University of California. | |
4 | * Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER). | |
5 | * Written by Brian Behlendorf <behlendorf1@llnl.gov>. | |
715f6251 | 6 | * UCRL-CODE-235197 |
7 | * | |
716154c5 BB |
8 | * This file is part of the SPL, Solaris Porting Layer. |
9 | * For details, see <http://github.com/behlendorf/spl/>. | |
10 | * | |
11 | * The SPL is free software; you can redistribute it and/or modify it | |
12 | * under the terms of the GNU General Public License as published by the | |
13 | * Free Software Foundation; either version 2 of the License, or (at your | |
14 | * option) any later version. | |
715f6251 | 15 | * |
716154c5 | 16 | * The SPL is distributed in the hope that it will be useful, but WITHOUT |
715f6251 | 17 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
18 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License | |
19 | * for more details. | |
20 | * | |
21 | * You should have received a copy of the GNU General Public License along | |
716154c5 BB |
22 | * with the SPL. If not, see <http://www.gnu.org/licenses/>. |
23 | \*****************************************************************************/ | |
715f6251 | 24 | |
09b414e8 | 25 | #ifndef _SPL_CONDVAR_H |
26 | #define _SPL_CONDVAR_H | |
f1ca4da6 | 27 | |
f1b59d26 | 28 | #include <linux/module.h> |
f1ca4da6 | 29 | #include <linux/wait.h> |
4d54fdee | 30 | #include <sys/kmem.h> |
4efd4118 | 31 | #include <sys/mutex.h> |
f1ca4da6 | 32 | |
716154c5 BB |
33 | /* |
34 | * The kcondvar_t struct is protected by mutex taken externally before | |
f1ca4da6 | 35 | * calling any of the wait/signal funs, and passed into the wait funs. |
36 | */ | |
37 | #define CV_MAGIC 0x346545f4 | |
d2733258 | 38 | #define CV_DESTROY 0x346545f5 |
f1ca4da6 | 39 | |
40 | typedef struct { | |
41 | int cv_magic; | |
f1ca4da6 | 42 | wait_queue_head_t cv_event; |
d599e4fa | 43 | wait_queue_head_t cv_destroy; |
d2733258 | 44 | atomic_t cv_refs; |
f1ca4da6 | 45 | atomic_t cv_waiters; |
4efd4118 | 46 | kmutex_t *cv_mutex; |
f1ca4da6 | 47 | } kcondvar_t; |
48 | ||
49 | typedef enum { CV_DEFAULT=0, CV_DRIVER } kcv_type_t; | |
50 | ||
4efd4118 | 51 | extern void __cv_init(kcondvar_t *cvp, char *name, kcv_type_t type, void *arg); |
52 | extern void __cv_destroy(kcondvar_t *cvp); | |
53 | extern void __cv_wait(kcondvar_t *cvp, kmutex_t *mp); | |
46a75aad | 54 | extern void __cv_wait_io(kcondvar_t *cvp, kmutex_t *mp); |
f752b46e BB |
55 | extern void __cv_wait_interruptible(kcondvar_t *cvp, kmutex_t *mp); |
56 | extern clock_t __cv_timedwait(kcondvar_t *cvp, kmutex_t *mp, clock_t exp_time); | |
3f688a8c NK |
57 | extern clock_t __cv_timedwait_interruptible(kcondvar_t *cvp, kmutex_t *mp, |
58 | clock_t exp_time); | |
4efd4118 | 59 | extern void __cv_signal(kcondvar_t *cvp); |
60 | extern void __cv_broadcast(kcondvar_t *cvp); | |
61 | ||
b29012b9 | 62 | #define cv_init(cvp, name, type, arg) __cv_init(cvp, name, type, arg) |
3f688a8c NK |
63 | #define cv_destroy(cvp) __cv_destroy(cvp) |
64 | #define cv_wait(cvp, mp) __cv_wait(cvp, mp) | |
46a75aad | 65 | #define cv_wait_io(cvp, mp) __cv_wait_io(cvp, mp) |
3f688a8c NK |
66 | #define cv_wait_interruptible(cvp, mp) __cv_wait_interruptible(cvp,mp) |
67 | #define cv_timedwait(cvp, mp, t) __cv_timedwait(cvp, mp, t) | |
68 | #define cv_timedwait_interruptible(cvp, mp, t) \ | |
69 | __cv_timedwait_interruptible(cvp, mp, t) | |
70 | #define cv_signal(cvp) __cv_signal(cvp) | |
71 | #define cv_broadcast(cvp) __cv_broadcast(cvp) | |
f1ca4da6 | 72 | |
09b414e8 | 73 | #endif /* _SPL_CONDVAR_H */ |