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