]> git.proxmox.com Git - mirror_spl.git/blame - include/sys/condvar.h
Add 3 missing typedefs.
[mirror_spl.git] / include / sys / condvar.h
CommitLineData
715f6251 1/*
2 * This file is part of the SPL: Solaris Porting Layer.
3 *
4 * Copyright (c) 2008 Lawrence Livermore National Security, LLC.
5 * Produced at Lawrence Livermore National Laboratory
6 * Written by:
7 * Brian Behlendorf <behlendorf1@llnl.gov>,
8 * Herb Wartens <wartens2@llnl.gov>,
9 * Jim Garlick <garlick@llnl.gov>
10 * UCRL-CODE-235197
11 *
12 * This is free software; you can redistribute it and/or modify it
13 * under the terms of the GNU General Public License as published by
14 * the Free Software Foundation; either version 2 of the License, or
15 * (at your option) any later version.
16 *
17 * This is distributed in the hope that it will be useful, but WITHOUT
18 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
19 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
20 * for more details.
21 *
22 * You should have received a copy of the GNU General Public License along
23 * with this program; if not, write to the Free Software Foundation, Inc.,
24 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
25 */
26
09b414e8 27#ifndef _SPL_CONDVAR_H
28#define _SPL_CONDVAR_H
f1ca4da6 29
30#ifdef __cplusplus
31extern "C" {
32#endif
33
f1b59d26 34#include <linux/module.h>
f1ca4da6 35#include <linux/wait.h>
4d54fdee 36#include <sys/kmem.h>
4efd4118 37#include <sys/mutex.h>
f1ca4da6 38
39/* The kcondvar_t struct is protected by mutex taken externally before
40 * calling any of the wait/signal funs, and passed into the wait funs.
41 */
42#define CV_MAGIC 0x346545f4
43#define CV_POISON 0x95
44
45typedef struct {
46 int cv_magic;
47 char *cv_name;
4efd4118 48 int cv_name_size;
f1ca4da6 49 wait_queue_head_t cv_event;
50 atomic_t cv_waiters;
4efd4118 51 kmutex_t *cv_mutex;
12ea9230 52 spinlock_t cv_lock;
f1ca4da6 53} kcondvar_t;
54
55typedef enum { CV_DEFAULT=0, CV_DRIVER } kcv_type_t;
56
4efd4118 57extern void __cv_init(kcondvar_t *cvp, char *name, kcv_type_t type, void *arg);
58extern void __cv_destroy(kcondvar_t *cvp);
59extern void __cv_wait(kcondvar_t *cvp, kmutex_t *mp);
f752b46e
BB
60extern void __cv_wait_interruptible(kcondvar_t *cvp, kmutex_t *mp);
61extern clock_t __cv_timedwait(kcondvar_t *cvp, kmutex_t *mp, clock_t exp_time);
4efd4118 62extern void __cv_signal(kcondvar_t *cvp);
63extern void __cv_broadcast(kcondvar_t *cvp);
64
65#define cv_init(cvp, name, type, arg) \
66({ \
67 if ((name) == NULL) \
68 __cv_init(cvp, #cvp, type, arg); \
69 else \
70 __cv_init(cvp, name, type, arg); \
71})
72#define cv_destroy(cvp) __cv_destroy(cvp)
73#define cv_wait(cvp, mp) __cv_wait(cvp, mp)
f752b46e 74#define cv_wait_interruptible(cvp, mp) __cv_wait_interruptible(cvp, mp)
4efd4118 75#define cv_timedwait(cvp, mp, t) __cv_timedwait(cvp, mp, t)
76#define cv_signal(cvp) __cv_signal(cvp)
77#define cv_broadcast(cvp) __cv_broadcast(cvp)
f1ca4da6 78
09b414e8 79#endif /* _SPL_CONDVAR_H */