2023-02-08 18:12:00 +01:00
|
|
|
/* Simple Plugin API */
|
|
|
|
|
/* SPDX-FileCopyrightText: Copyright © 2018 Wim Taymans */
|
|
|
|
|
/* SPDX-License-Identifier: MIT */
|
2019-02-20 17:51:05 +01:00
|
|
|
|
|
|
|
|
#ifndef SPA_UTILS_RESULT_H
|
|
|
|
|
#define SPA_UTILS_RESULT_H
|
|
|
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
|
extern "C" {
|
|
|
|
|
#endif
|
|
|
|
|
|
2021-05-21 14:03:07 +10:00
|
|
|
/**
|
2021-10-02 20:55:53 +03:00
|
|
|
* \defgroup spa_result Result handling
|
2021-10-04 00:00:41 +03:00
|
|
|
* Asynchronous result utilities
|
2021-10-02 20:55:53 +03:00
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* \addtogroup spa_result
|
2021-05-21 14:03:07 +10:00
|
|
|
* \{
|
|
|
|
|
*/
|
|
|
|
|
|
2024-11-26 12:21:05 +01:00
|
|
|
#include <errno.h>
|
|
|
|
|
|
2019-02-20 17:51:05 +01:00
|
|
|
#include <spa/utils/defs.h>
|
2024-11-26 12:21:05 +01:00
|
|
|
|
|
|
|
|
#ifndef SPA_API_RESULT
|
|
|
|
|
#ifdef SPA_API_IMPL
|
|
|
|
|
#define SPA_API_RESULT SPA_API_IMPL
|
|
|
|
|
#else
|
|
|
|
|
#define SPA_API_RESULT static inline
|
|
|
|
|
#endif
|
|
|
|
|
#endif
|
|
|
|
|
|
2019-02-20 17:51:05 +01:00
|
|
|
|
|
|
|
|
#define SPA_ASYNC_BIT (1 << 30)
|
|
|
|
|
#define SPA_ASYNC_SEQ_MASK (SPA_ASYNC_BIT - 1)
|
2020-12-21 21:07:34 +01:00
|
|
|
#define SPA_ASYNC_MASK (~SPA_ASYNC_SEQ_MASK)
|
2019-02-20 17:51:05 +01:00
|
|
|
|
|
|
|
|
#define SPA_RESULT_IS_OK(res) ((res) >= 0)
|
|
|
|
|
#define SPA_RESULT_IS_ERROR(res) ((res) < 0)
|
|
|
|
|
#define SPA_RESULT_IS_ASYNC(res) (((res) & SPA_ASYNC_MASK) == SPA_ASYNC_BIT)
|
|
|
|
|
|
|
|
|
|
#define SPA_RESULT_ASYNC_SEQ(res) ((res) & SPA_ASYNC_SEQ_MASK)
|
|
|
|
|
#define SPA_RESULT_RETURN_ASYNC(seq) (SPA_ASYNC_BIT | SPA_RESULT_ASYNC_SEQ(seq))
|
|
|
|
|
|
2024-11-26 12:21:05 +01:00
|
|
|
SPA_API_RESULT const char *spa_strerror(int err)
|
|
|
|
|
{
|
|
|
|
|
int _err = -(err);
|
|
|
|
|
if (SPA_RESULT_IS_ASYNC(err))
|
|
|
|
|
_err = EINPROGRESS;
|
|
|
|
|
return strerror(_err);
|
|
|
|
|
}
|
2019-10-25 15:01:02 +02:00
|
|
|
|
2021-05-21 14:03:07 +10:00
|
|
|
/**
|
|
|
|
|
* \}
|
|
|
|
|
*/
|
|
|
|
|
|
2019-02-20 17:51:05 +01:00
|
|
|
#ifdef __cplusplus
|
|
|
|
|
} /* extern "C" */
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
#endif /* SPA_UTILS_RESULT_H */
|