Move to kernel style SPDX license identifiers
[lttng-ust.git] / liblttng-ust / wait.h
CommitLineData
b5234c06 1/*
c0c0989a 2 * SPDX-License-Identifier: LGPL-2.1-only
b5234c06 3 *
c0c0989a 4 * Copyright (C) 2011 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
b5234c06
MD
5 */
6
c0c0989a
MJ
7#ifndef _UST_WAIT_H
8#define _UST_WAIT_H
9
b5234c06
MD
10#include <poll.h>
11
12/*
13 * Wait until "cond" gets true or timeout (in ms).
14 */
15#define wait_cond_interruptible_timeout(_cond, _timeout) \
16 ({ \
17 int __ret = 0, __pollret; \
18 int __timeout = _timeout; \
19 \
20 for (;;) { \
b472cfc0 21 if (_cond) \
b5234c06
MD
22 break; \
23 if (__timeout <= 0) { \
24 __ret = -ETIMEDOUT; \
25 break; \
26 } \
27 __pollret = poll(NULL, 0, 10); /* wait 10ms */ \
28 if (__pollret < 0) { \
9dcb02ef 29 __ret = -errno; \
b5234c06
MD
30 break; \
31 } \
32 __timeout -= 10; \
33 } \
34 __ret; \
35 })
36
37
38#endif /* _UST_WAIT_H */
This page took 0.032553 seconds and 4 git commands to generate.