Move to kernel style SPDX license identifiers
[lttng-ust.git] / liblttng-ust / error.h
1 /*
2 * SPDX-License-Identifier: LGPL-2.1-only
3 *
4 * Copyright (C) 2011 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
5 */
6
7 #ifndef _LTTNG_ERROR_H
8 #define _LTTNG_ERROR_H
9
10 #include <urcu/compiler.h>
11 #include <unistd.h>
12
13 #define MAX_ERRNO 4095
14
15 static inline
16 int IS_ERR_VALUE(long value)
17 {
18 if (caa_unlikely((unsigned long) value >= (unsigned long) -MAX_ERRNO))
19 return 1;
20 else
21 return 0;
22 }
23
24 static inline
25 void *ERR_PTR(long error)
26 {
27 return (void *) error;
28 }
29
30 static inline
31 long PTR_ERR(const void *ptr)
32 {
33 return (long) ptr;
34 }
35
36 static inline
37 int IS_ERR(const void *ptr)
38 {
39 return IS_ERR_VALUE((long) ptr);
40 }
41
42 #endif /* _LTTNG_ERROR_H */
This page took 0.029651 seconds and 4 git commands to generate.