]> git.proxmox.com Git - mirror_spl-debian.git/blame - include/sys/condvar.h
New upstream version 0.7.11
[mirror_spl-debian.git] / include / sys / condvar.h
CommitLineData
f6188ddd 1/*
716154c5
BB
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 8 * This file is part of the SPL, Solaris Porting Layer.
3d6af2dd 9 * For details, see <http://zfsonlinux.org/>.
716154c5
BB
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 22 * with the SPL. If not, see <http://www.gnu.org/licenses/>.
f6188ddd 23 */
715f6251 24
09b414e8 25#ifndef _SPL_CONDVAR_H
f6188ddd 26#define _SPL_CONDVAR_H
f1ca4da6 27
f1b59d26 28#include <linux/module.h>
ec06701b 29#include <linux/wait_compat.h>
33a20369 30#include <linux/delay_compat.h>
4d54fdee 31#include <sys/kmem.h>
4efd4118 32#include <sys/mutex.h>
33a20369 33#include <sys/callo.h>
b97c7791 34#include <sys/time.h>
f1ca4da6 35
716154c5
BB
36/*
37 * The kcondvar_t struct is protected by mutex taken externally before
f1ca4da6 38 * calling any of the wait/signal funs, and passed into the wait funs.
39 */
f6188ddd
AX
40#define CV_MAGIC 0x346545f4
41#define CV_DESTROY 0x346545f5
f1ca4da6 42
43typedef struct {
44 int cv_magic;
ec06701b
AX
45 spl_wait_queue_head_t cv_event;
46 spl_wait_queue_head_t cv_destroy;
d2733258 47 atomic_t cv_refs;
f1ca4da6 48 atomic_t cv_waiters;
4efd4118 49 kmutex_t *cv_mutex;
f1ca4da6 50} kcondvar_t;
51
f6188ddd 52typedef enum { CV_DEFAULT = 0, CV_DRIVER } kcv_type_t;
f1ca4da6 53
f6188ddd
AX
54extern void __cv_init(kcondvar_t *, char *, kcv_type_t, void *);
55extern void __cv_destroy(kcondvar_t *);
56extern void __cv_wait(kcondvar_t *, kmutex_t *);
57extern void __cv_wait_io(kcondvar_t *, kmutex_t *);
58extern void __cv_wait_sig(kcondvar_t *, kmutex_t *);
59extern clock_t __cv_timedwait(kcondvar_t *, kmutex_t *, clock_t);
34ee731f 60extern clock_t __cv_timedwait_io(kcondvar_t *, kmutex_t *, clock_t);
f6188ddd
AX
61extern clock_t __cv_timedwait_sig(kcondvar_t *, kmutex_t *, clock_t);
62extern clock_t cv_timedwait_hires(kcondvar_t *, kmutex_t *, hrtime_t,
63 hrtime_t res, int flag);
ec06701b
AX
64extern clock_t cv_timedwait_sig_hires(kcondvar_t *, kmutex_t *, hrtime_t,
65 hrtime_t res, int flag);
f6188ddd
AX
66extern void __cv_signal(kcondvar_t *);
67extern void __cv_broadcast(kcondvar_t *c);
4efd4118 68
f6188ddd
AX
69#define cv_init(cvp, name, type, arg) __cv_init(cvp, name, type, arg)
70#define cv_destroy(cvp) __cv_destroy(cvp)
71#define cv_wait(cvp, mp) __cv_wait(cvp, mp)
72#define cv_wait_io(cvp, mp) __cv_wait_io(cvp, mp)
73#define cv_wait_sig(cvp, mp) __cv_wait_sig(cvp, mp)
74#define cv_wait_interruptible(cvp, mp) cv_wait_sig(cvp, mp)
75#define cv_timedwait(cvp, mp, t) __cv_timedwait(cvp, mp, t)
34ee731f 76#define cv_timedwait_io(cvp, mp, t) __cv_timedwait_io(cvp, mp, t)
f6188ddd
AX
77#define cv_timedwait_sig(cvp, mp, t) __cv_timedwait_sig(cvp, mp, t)
78#define cv_timedwait_interruptible(cvp, mp, t) cv_timedwait_sig(cvp, mp, t)
79#define cv_signal(cvp) __cv_signal(cvp)
80#define cv_broadcast(cvp) __cv_broadcast(cvp)
f1ca4da6 81
09b414e8 82#endif /* _SPL_CONDVAR_H */