PipeWire 1.4.1
All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
result.h
Go to the documentation of this file.
1/* Simple Plugin API */
2/* SPDX-FileCopyrightText: Copyright © 2018 Wim Taymans */
3/* SPDX-License-Identifier: MIT */
4
5#ifndef SPA_UTILS_RESULT_H
6#define SPA_UTILS_RESULT_H
7
8#ifdef __cplusplus
9extern "C" {
10#endif
11
22#include <errno.h>
23
24#include <spa/utils/defs.h>
25
26#ifndef SPA_API_RESULT
27 #ifdef SPA_API_IMPL
28 #define SPA_API_RESULT SPA_API_IMPL
29 #else
30 #define SPA_API_RESULT static inline
31 #endif
32#endif
33
34
35#define SPA_ASYNC_BIT (1 << 30)
36#define SPA_ASYNC_SEQ_MASK (SPA_ASYNC_BIT - 1)
37#define SPA_ASYNC_MASK (~SPA_ASYNC_SEQ_MASK)
38
39#define SPA_RESULT_IS_OK(res) ((res) >= 0)
40#define SPA_RESULT_IS_ERROR(res) ((res) < 0)
41#define SPA_RESULT_IS_ASYNC(res) (((res) & SPA_ASYNC_MASK) == SPA_ASYNC_BIT)
42
43#define SPA_RESULT_ASYNC_SEQ(res) ((res) & SPA_ASYNC_SEQ_MASK)
44#define SPA_RESULT_RETURN_ASYNC(seq) (SPA_ASYNC_BIT | SPA_RESULT_ASYNC_SEQ(seq))
46SPA_API_RESULT const char *spa_strerror(int err)
48 int _err = -(err);
49 if (SPA_RESULT_IS_ASYNC(err))
50 _err = EINPROGRESS;
51 return strerror(_err);
53
58#ifdef __cplusplus
59} /* extern "C" */
60#endif
62#endif /* SPA_UTILS_RESULT_H */
spa/utils/defs.h
#define SPA_API_RESULT
Definition result.h:37
SPA_API_RESULT const char * spa_strerror(int err)
Definition result.h:61
#define SPA_RESULT_IS_ASYNC(res)
Definition result.h:54