completion.h revision 294839
1214501Srpaulo/*-
2214501Srpaulo * Copyright (c) 2010 Isilon Systems, Inc.
3214501Srpaulo * Copyright (c) 2010 iX Systems, Inc.
4214501Srpaulo * Copyright (c) 2010 Panasas, Inc.
5252726Srpaulo * Copyright (c) 2013, 2014 Mellanox Technologies, Ltd.
6252726Srpaulo * All rights reserved.
7214501Srpaulo *
8214501Srpaulo * Redistribution and use in source and binary forms, with or without
9214501Srpaulo * modification, are permitted provided that the following conditions
10214501Srpaulo * are met:
11214501Srpaulo * 1. Redistributions of source code must retain the above copyright
12214501Srpaulo *    notice unmodified, this list of conditions, and the following
13214501Srpaulo *    disclaimer.
14214501Srpaulo * 2. Redistributions in binary form must reproduce the above copyright
15214501Srpaulo *    notice, this list of conditions and the following disclaimer in the
16214501Srpaulo *    documentation and/or other materials provided with the distribution.
17289549Srpaulo *
18281806Srpaulo * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
19346981Scy * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
20346981Scy * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
21351611Scy * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
22214501Srpaulo * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
23281806Srpaulo * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
24281806Srpaulo * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
25214501Srpaulo * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
26214501Srpaulo * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
27281806Srpaulo * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28281806Srpaulo *
29214501Srpaulo * $FreeBSD: head/sys/compat/linuxkpi/common/include/linux/completion.h 294839 2016-01-26 15:26:35Z hselasky $
30214501Srpaulo */
31214501Srpaulo#ifndef	_LINUX_COMPLETION_H_
32214501Srpaulo#define	_LINUX_COMPLETION_H_
33214501Srpaulo
34214501Srpaulo#include <linux/errno.h>
35214501Srpaulo
36214501Srpaulostruct completion {
37214501Srpaulo	unsigned int done;
38214501Srpaulo};
39214501Srpaulo
40214501Srpaulo#define	INIT_COMPLETION(c) \
41214501Srpaulo	((c).done = 0)
42214501Srpaulo#define	init_completion(c) \
43214501Srpaulo	do { (c)->done = 0; } while (0)
44214501Srpaulo#define	reinit_completion(c) \
45214501Srpaulo	do { (c)->done = 0; } while (0)
46214501Srpaulo#define	complete(c)				\
47289549Srpaulo	linux_complete_common((c), 0)
48281806Srpaulo#define	complete_all(c)				\
49252726Srpaulo	linux_complete_common((c), 1)
50281806Srpaulo#define	wait_for_completion(c)			\
51214501Srpaulo	linux_wait_for_common((c), 0)
52214501Srpaulo#define	wait_for_completion_interuptible(c)	\
53214501Srpaulo	linux_wait_for_common((c), 1)
54214501Srpaulo#define	wait_for_completion_timeout(c, timeout)	\
55337817Scy	linux_wait_for_timeout_common((c), (timeout), 0)
56337817Scy#define	wait_for_completion_interruptible_timeout(c, timeout)	\
57252726Srpaulo	linux_wait_for_timeout_common((c), (timeout), 1)
58281806Srpaulo#define	try_wait_for_completion(c) \
59337817Scy	linux_try_wait_for_completion(c)
60337817Scy#define	completion_done(c) \
61351611Scy	linux_completion_done(c)
62351611Scy
63346981Scyextern void linux_complete_common(struct completion *, int);
64346981Scyextern long linux_wait_for_common(struct completion *, int);
65351611Scyextern long linux_wait_for_timeout_common(struct completion *, long, int);
66337817Scyextern int linux_try_wait_for_completion(struct completion *);
67214501Srpauloextern int linux_completion_done(struct completion *);
68214501Srpaulo
69214501Srpaulo#endif					/* _LINUX_COMPLETION_H_ */
70214501Srpaulo