]> git.proxmox.com Git - mirror_spl.git/blame - include/sys/condvar.h
Go through and add a header with the proper UCRL number.
[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>
4efd4118 36#include <sys/mutex.h>
f1ca4da6 37
38/* The kcondvar_t struct is protected by mutex taken externally before
39 * calling any of the wait/signal funs, and passed into the wait funs.
40 */
41#define CV_MAGIC 0x346545f4
42#define CV_POISON 0x95
43
44typedef struct {
45 int cv_magic;
46 char *cv_name;
4efd4118 47 int cv_name_size;
f1ca4da6 48 wait_queue_head_t cv_event;
49 atomic_t cv_waiters;
4efd4118 50 kmutex_t *cv_mutex;
12ea9230 51 spinlock_t cv_lock;
f1ca4da6 52} kcondvar_t;
53
54typedef enum { CV_DEFAULT=0, CV_DRIVER } kcv_type_t;
55
4efd4118 56extern void __cv_init(kcondvar_t *cvp, char *name, kcv_type_t type, void *arg);
57extern void __cv_destroy(kcondvar_t *cvp);
58extern void __cv_wait(kcondvar_t *cvp, kmutex_t *mp);
59extern clock_t __cv_timedwait(kcondvar_t *cvp, kmutex_t *mp,
60 clock_t expire_time);
61extern void __cv_signal(kcondvar_t *cvp);
62extern void __cv_broadcast(kcondvar_t *cvp);
63
64#define cv_init(cvp, name, type, arg) \
65({ \
66 if ((name) == NULL) \
67 __cv_init(cvp, #cvp, type, arg); \
68 else \
69 __cv_init(cvp, name, type, arg); \
70})
71#define cv_destroy(cvp) __cv_destroy(cvp)
72#define cv_wait(cvp, mp) __cv_wait(cvp, mp)
73#define cv_timedwait(cvp, mp, t) __cv_timedwait(cvp, mp, t)
74#define cv_signal(cvp) __cv_signal(cvp)
75#define cv_broadcast(cvp) __cv_broadcast(cvp)
f1ca4da6 76
09b414e8 77#endif /* _SPL_CONDVAR_H */