make static inline -> SPA_API_IMPL

So that we can export the symbols as well.
This commit is contained in:
Wim Taymans 2024-11-20 11:48:08 +01:00
parent 84bd4b7ea9
commit 90b0e45037
91 changed files with 563 additions and 552 deletions

View file

@ -254,6 +254,11 @@ struct spa_fraction {
#define SPA_WARN_UNUSED_RESULT
#endif
#ifndef SPA_API_IMPL
#define SPA_API_PROTO static inline
#define SPA_API_IMPL static inline
#endif
#if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
#define SPA_RESTRICT restrict
#elif defined(__GNUC__) && __GNUC__ >= 4
@ -300,7 +305,7 @@ struct spa_fraction {
#endif
#endif
static inline bool spa_ptrinside(const void *p1, size_t s1, const void *p2, size_t s2,
SPA_API_IMPL bool spa_ptrinside(const void *p1, size_t s1, const void *p2, size_t s2,
size_t *remaining)
{
if (SPA_LIKELY((uintptr_t)p1 <= (uintptr_t)p2 && s2 <= s1 &&
@ -315,7 +320,7 @@ static inline bool spa_ptrinside(const void *p1, size_t s1, const void *p2, size
}
}
static inline bool spa_ptr_inside_and_aligned(const void *p1, size_t s1,
SPA_API_IMPL bool spa_ptr_inside_and_aligned(const void *p1, size_t s1,
const void *p2, size_t s2, size_t align,
size_t *remaining)
{

View file

@ -50,14 +50,14 @@ struct spa_dict {
(item) < &(dict)->items[(dict)->n_items]; \
(item)++)
static inline int spa_dict_item_compare(const void *i1, const void *i2)
SPA_API_IMPL int spa_dict_item_compare(const void *i1, const void *i2)
{
const struct spa_dict_item *it1 = (const struct spa_dict_item *)i1,
*it2 = (const struct spa_dict_item *)i2;
return strcmp(it1->key, it2->key);
}
static inline void spa_dict_qsort(struct spa_dict *dict)
SPA_API_IMPL void spa_dict_qsort(struct spa_dict *dict)
{
if (dict->n_items > 0)
qsort((void*)dict->items, dict->n_items, sizeof(struct spa_dict_item),
@ -65,7 +65,7 @@ static inline void spa_dict_qsort(struct spa_dict *dict)
SPA_FLAG_SET(dict->flags, SPA_DICT_FLAG_SORTED);
}
static inline const struct spa_dict_item *spa_dict_lookup_item(const struct spa_dict *dict,
SPA_API_IMPL const struct spa_dict_item *spa_dict_lookup_item(const struct spa_dict *dict,
const char *key)
{
const struct spa_dict_item *item;
@ -88,7 +88,7 @@ static inline const struct spa_dict_item *spa_dict_lookup_item(const struct spa_
return NULL;
}
static inline const char *spa_dict_lookup(const struct spa_dict *dict, const char *key)
SPA_API_IMPL const char *spa_dict_lookup(const struct spa_dict *dict, const char *key)
{
const struct spa_dict_item *item = spa_dict_lookup_item(dict, key);
return item ? item->value : NULL;

View file

@ -12,6 +12,8 @@ extern "C" {
#include <stddef.h>
#include <math.h>
#include <spa/utils/defs.h>
#define SPA_DLL_BW_MAX 0.128
#define SPA_DLL_BW_MIN 0.016
@ -21,13 +23,13 @@ struct spa_dll {
double w0, w1, w2;
};
static inline void spa_dll_init(struct spa_dll *dll)
SPA_API_IMPL void spa_dll_init(struct spa_dll *dll)
{
dll->bw = 0.0;
dll->z1 = dll->z2 = dll->z3 = 0.0;
}
static inline void spa_dll_set_bw(struct spa_dll *dll, double bw, unsigned period, unsigned rate)
SPA_API_IMPL void spa_dll_set_bw(struct spa_dll *dll, double bw, unsigned period, unsigned rate)
{
double w = 2 * M_PI * bw * period / rate;
dll->w0 = 1.0 - exp (-20.0 * w);
@ -36,7 +38,7 @@ static inline void spa_dll_set_bw(struct spa_dll *dll, double bw, unsigned perio
dll->bw = bw;
}
static inline double spa_dll_update(struct spa_dll *dll, double err)
SPA_API_IMPL double spa_dll_update(struct spa_dll *dll, double err)
{
dll->z1 += dll->w0 * (dll->w1 * err - dll->z1);
dll->z2 += dll->w0 * (dll->z1 - dll->z2);

View file

@ -411,18 +411,18 @@ struct spa_hook {
};
/** Initialize a hook list to the empty list*/
static inline void spa_hook_list_init(struct spa_hook_list *list)
SPA_API_IMPL void spa_hook_list_init(struct spa_hook_list *list)
{
spa_list_init(&list->list);
}
static inline bool spa_hook_list_is_empty(struct spa_hook_list *list)
SPA_API_IMPL bool spa_hook_list_is_empty(struct spa_hook_list *list)
{
return spa_list_is_empty(&list->list);
}
/** Append a hook. */
static inline void spa_hook_list_append(struct spa_hook_list *list,
SPA_API_IMPL void spa_hook_list_append(struct spa_hook_list *list,
struct spa_hook *hook,
const void *funcs, void *data)
{
@ -432,7 +432,7 @@ static inline void spa_hook_list_append(struct spa_hook_list *list,
}
/** Prepend a hook */
static inline void spa_hook_list_prepend(struct spa_hook_list *list,
SPA_API_IMPL void spa_hook_list_prepend(struct spa_hook_list *list,
struct spa_hook *hook,
const void *funcs, void *data)
{
@ -442,7 +442,7 @@ static inline void spa_hook_list_prepend(struct spa_hook_list *list,
}
/** Remove a hook */
static inline void spa_hook_remove(struct spa_hook *hook)
SPA_API_IMPL void spa_hook_remove(struct spa_hook *hook)
{
if (spa_list_is_initialized(&hook->link))
spa_list_remove(&hook->link);
@ -451,14 +451,14 @@ static inline void spa_hook_remove(struct spa_hook *hook)
}
/** Remove all hooks from the list */
static inline void spa_hook_list_clean(struct spa_hook_list *list)
SPA_API_IMPL void spa_hook_list_clean(struct spa_hook_list *list)
{
struct spa_hook *h;
spa_list_consume(h, &list->list, link)
spa_hook_remove(h);
}
static inline void
SPA_API_IMPL void
spa_hook_list_isolate(struct spa_hook_list *list,
struct spa_hook_list *save,
struct spa_hook *hook,
@ -472,7 +472,7 @@ spa_hook_list_isolate(struct spa_hook_list *list,
spa_hook_list_append(list, hook, funcs, data);
}
static inline void
SPA_API_IMPL void
spa_hook_list_join(struct spa_hook_list *list,
struct spa_hook_list *save)
{

View file

@ -41,13 +41,13 @@ struct spa_json {
#define SPA_JSON_INIT(data,size) ((struct spa_json) { (data), (data)+(size), NULL, 0, 0 })
static inline void spa_json_init(struct spa_json * iter, const char *data, size_t size)
SPA_API_IMPL void spa_json_init(struct spa_json * iter, const char *data, size_t size)
{
*iter = SPA_JSON_INIT(data, size);
}
#define SPA_JSON_ENTER(iter) ((struct spa_json) { (iter)->cur, (iter)->end, (iter), (iter)->state & 0xff0, 0 })
static inline void spa_json_enter(struct spa_json * iter, struct spa_json * sub)
SPA_API_IMPL void spa_json_enter(struct spa_json * iter, struct spa_json * sub)
{
*sub = SPA_JSON_ENTER(iter);
}
@ -58,7 +58,7 @@ static inline void spa_json_enter(struct spa_json * iter, struct spa_json * sub)
/** Get the next token. \a value points to the token and the return value
* is the length. Returns -1 on parse error, 0 on end of input. */
static inline int spa_json_next(struct spa_json * iter, const char **value)
SPA_API_IMPL int spa_json_next(struct spa_json * iter, const char **value)
{
int utf8_remain = 0, err = 0;
enum {
@ -312,7 +312,7 @@ error:
*
* \since 1.1.0
*/
static inline bool spa_json_get_error(struct spa_json *iter, const char *start,
SPA_API_IMPL bool spa_json_get_error(struct spa_json *iter, const char *start,
struct spa_error_location *loc)
{
static const char *reasons[] = {
@ -358,31 +358,31 @@ static inline bool spa_json_get_error(struct spa_json *iter, const char *start,
return true;
}
static inline int spa_json_is_container(const char *val, int len)
SPA_API_IMPL int spa_json_is_container(const char *val, int len)
{
return len > 0 && (*val == '{' || *val == '[');
}
/* object */
static inline int spa_json_is_object(const char *val, int len)
SPA_API_IMPL int spa_json_is_object(const char *val, int len)
{
return len > 0 && *val == '{';
}
/* array */
static inline bool spa_json_is_array(const char *val, int len)
SPA_API_IMPL bool spa_json_is_array(const char *val, int len)
{
return len > 0 && *val == '[';
}
/* null */
static inline bool spa_json_is_null(const char *val, int len)
SPA_API_IMPL bool spa_json_is_null(const char *val, int len)
{
return len == 4 && strncmp(val, "null", 4) == 0;
}
/* float */
static inline int spa_json_parse_float(const char *val, int len, float *result)
SPA_API_IMPL int spa_json_parse_float(const char *val, int len, float *result)
{
char buf[96];
char *end;
@ -405,13 +405,13 @@ static inline int spa_json_parse_float(const char *val, int len, float *result)
return len > 0 && end == buf + len;
}
static inline bool spa_json_is_float(const char *val, int len)
SPA_API_IMPL bool spa_json_is_float(const char *val, int len)
{
float dummy;
return spa_json_parse_float(val, len, &dummy);
}
static inline char *spa_json_format_float(char *str, int size, float val)
SPA_API_IMPL char *spa_json_format_float(char *str, int size, float val)
{
if (SPA_UNLIKELY(!isnormal(val))) {
if (isinf(val))
@ -423,7 +423,7 @@ static inline char *spa_json_format_float(char *str, int size, float val)
}
/* int */
static inline int spa_json_parse_int(const char *val, int len, int *result)
SPA_API_IMPL int spa_json_parse_int(const char *val, int len, int *result)
{
char buf[64];
char *end;
@ -437,29 +437,29 @@ static inline int spa_json_parse_int(const char *val, int len, int *result)
*result = strtol(buf, &end, 0);
return len > 0 && end == buf + len;
}
static inline bool spa_json_is_int(const char *val, int len)
SPA_API_IMPL bool spa_json_is_int(const char *val, int len)
{
int dummy;
return spa_json_parse_int(val, len, &dummy);
}
/* bool */
static inline bool spa_json_is_true(const char *val, int len)
SPA_API_IMPL bool spa_json_is_true(const char *val, int len)
{
return len == 4 && strncmp(val, "true", 4) == 0;
}
static inline bool spa_json_is_false(const char *val, int len)
SPA_API_IMPL bool spa_json_is_false(const char *val, int len)
{
return len == 5 && strncmp(val, "false", 5) == 0;
}
static inline bool spa_json_is_bool(const char *val, int len)
SPA_API_IMPL bool spa_json_is_bool(const char *val, int len)
{
return spa_json_is_true(val, len) || spa_json_is_false(val, len);
}
static inline int spa_json_parse_bool(const char *val, int len, bool *result)
SPA_API_IMPL int spa_json_parse_bool(const char *val, int len, bool *result)
{
if ((*result = spa_json_is_true(val, len)))
return 1;
@ -469,12 +469,12 @@ static inline int spa_json_parse_bool(const char *val, int len, bool *result)
}
/* string */
static inline bool spa_json_is_string(const char *val, int len)
SPA_API_IMPL bool spa_json_is_string(const char *val, int len)
{
return len > 1 && *val == '"';
}
static inline int spa_json_parse_hex(const char *p, int num, uint32_t *res)
SPA_API_IMPL int spa_json_parse_hex(const char *p, int num, uint32_t *res)
{
int i;
*res = 0;
@ -493,7 +493,7 @@ static inline int spa_json_parse_hex(const char *p, int num, uint32_t *res)
return 1;
}
static inline int spa_json_parse_stringn(const char *val, int len, char *result, int maxlen)
SPA_API_IMPL int spa_json_parse_stringn(const char *val, int len, char *result, int maxlen)
{
const char *p;
if (maxlen <= len)
@ -556,12 +556,12 @@ static inline int spa_json_parse_stringn(const char *val, int len, char *result,
return 1;
}
static inline int spa_json_parse_string(const char *val, int len, char *result)
SPA_API_IMPL int spa_json_parse_string(const char *val, int len, char *result)
{
return spa_json_parse_stringn(val, len, result, len+1);
}
static inline int spa_json_encode_string(char *str, int size, const char *val)
SPA_API_IMPL int spa_json_encode_string(char *str, int size, const char *val)
{
int len = 0;
static const char hex[] = { "0123456789abcdef" };

View file

@ -24,7 +24,7 @@ extern "C" {
* \{
*/
static inline int spa_json_to_pod_part(struct spa_pod_builder *b, uint32_t flags, uint32_t id,
SPA_API_IMPL int spa_json_to_pod_part(struct spa_pod_builder *b, uint32_t flags, uint32_t id,
const struct spa_type_info *info, struct spa_json *iter, const char *value, int len)
{
const struct spa_type_info *ti;
@ -135,7 +135,7 @@ static inline int spa_json_to_pod_part(struct spa_pod_builder *b, uint32_t flags
return 0;
}
static inline int spa_json_to_pod_checked(struct spa_pod_builder *b, uint32_t flags,
SPA_API_IMPL int spa_json_to_pod_checked(struct spa_pod_builder *b, uint32_t flags,
const struct spa_type_info *info, const char *value, int len,
struct spa_error_location *loc)
{
@ -157,7 +157,7 @@ error:
return res;
}
static inline int spa_json_to_pod(struct spa_pod_builder *b, uint32_t flags,
SPA_API_IMPL int spa_json_to_pod(struct spa_pod_builder *b, uint32_t flags,
const struct spa_type_info *info, const char *value, int len)
{
return spa_json_to_pod_checked(b, flags, info, value, len, NULL);

View file

@ -28,14 +28,14 @@ extern "C" {
* \{
*/
static inline int spa_json_begin(struct spa_json * iter, const char *data, size_t size, const char **val)
SPA_API_IMPL int spa_json_begin(struct spa_json * iter, const char *data, size_t size, const char **val)
{
spa_json_init(iter, data, size);
return spa_json_next(iter, val);
}
/* float */
static inline int spa_json_get_float(struct spa_json *iter, float *res)
SPA_API_IMPL int spa_json_get_float(struct spa_json *iter, float *res)
{
const char *value;
int len;
@ -45,7 +45,7 @@ static inline int spa_json_get_float(struct spa_json *iter, float *res)
}
/* int */
static inline int spa_json_get_int(struct spa_json *iter, int *res)
SPA_API_IMPL int spa_json_get_int(struct spa_json *iter, int *res)
{
const char *value;
int len;
@ -55,7 +55,7 @@ static inline int spa_json_get_int(struct spa_json *iter, int *res)
}
/* bool */
static inline int spa_json_get_bool(struct spa_json *iter, bool *res)
SPA_API_IMPL int spa_json_get_bool(struct spa_json *iter, bool *res)
{
const char *value;
int len;
@ -65,7 +65,7 @@ static inline int spa_json_get_bool(struct spa_json *iter, bool *res)
}
/* string */
static inline int spa_json_get_string(struct spa_json *iter, char *res, int maxlen)
SPA_API_IMPL int spa_json_get_string(struct spa_json *iter, char *res, int maxlen)
{
const char *value;
int len;
@ -75,7 +75,7 @@ static inline int spa_json_get_string(struct spa_json *iter, char *res, int maxl
}
static inline int spa_json_enter_container(struct spa_json *iter, struct spa_json *sub, char type)
SPA_API_IMPL int spa_json_enter_container(struct spa_json *iter, struct spa_json *sub, char type)
{
const char *value;
int len;
@ -89,7 +89,7 @@ static inline int spa_json_enter_container(struct spa_json *iter, struct spa_jso
return 1;
}
static inline int spa_json_begin_container(struct spa_json * iter,
SPA_API_IMPL int spa_json_begin_container(struct spa_json * iter,
const char *data, size_t size, char type, bool relax)
{
int res;
@ -106,7 +106,7 @@ static inline int spa_json_begin_container(struct spa_json * iter,
*
* \return Length of container including {} or [], or 0 on error.
*/
static inline int spa_json_container_len(struct spa_json *iter, const char *value, int len SPA_UNUSED)
SPA_API_IMPL int spa_json_container_len(struct spa_json *iter, const char *value, int len SPA_UNUSED)
{
const char *val;
struct spa_json sub;
@ -119,20 +119,20 @@ static inline int spa_json_container_len(struct spa_json *iter, const char *valu
}
/* object */
static inline int spa_json_enter_object(struct spa_json *iter, struct spa_json *sub)
SPA_API_IMPL int spa_json_enter_object(struct spa_json *iter, struct spa_json *sub)
{
return spa_json_enter_container(iter, sub, '{');
}
static inline int spa_json_begin_object_relax(struct spa_json * iter, const char *data, size_t size)
SPA_API_IMPL int spa_json_begin_object_relax(struct spa_json * iter, const char *data, size_t size)
{
return spa_json_begin_container(iter, data, size, '{', true);
}
static inline int spa_json_begin_object(struct spa_json * iter, const char *data, size_t size)
SPA_API_IMPL int spa_json_begin_object(struct spa_json * iter, const char *data, size_t size)
{
return spa_json_begin_container(iter, data, size, '{', false);
}
static inline int spa_json_object_next(struct spa_json *iter, char *key, int maxkeylen, const char **value)
SPA_API_IMPL int spa_json_object_next(struct spa_json *iter, char *key, int maxkeylen, const char **value)
{
int res1, res2;
while (true) {
@ -145,7 +145,7 @@ static inline int spa_json_object_next(struct spa_json *iter, char *key, int max
}
}
static inline int spa_json_object_find(struct spa_json *iter, const char *key, const char **value)
SPA_API_IMPL int spa_json_object_find(struct spa_json *iter, const char *key, const char **value)
{
struct spa_json obj = SPA_JSON_SAVE(iter);
int res, len = strlen(key) + 3;
@ -157,7 +157,7 @@ static inline int spa_json_object_find(struct spa_json *iter, const char *key, c
return -ENOENT;
}
static inline int spa_json_str_object_find(const char *obj, size_t obj_len,
SPA_API_IMPL int spa_json_str_object_find(const char *obj, size_t obj_len,
const char *key, char *value, size_t maxlen)
{
struct spa_json iter;
@ -172,15 +172,15 @@ static inline int spa_json_str_object_find(const char *obj, size_t obj_len,
}
/* array */
static inline int spa_json_enter_array(struct spa_json *iter, struct spa_json *sub)
SPA_API_IMPL int spa_json_enter_array(struct spa_json *iter, struct spa_json *sub)
{
return spa_json_enter_container(iter, sub, '[');
}
static inline int spa_json_begin_array_relax(struct spa_json * iter, const char *data, size_t size)
SPA_API_IMPL int spa_json_begin_array_relax(struct spa_json * iter, const char *data, size_t size)
{
return spa_json_begin_container(iter, data, size, '[', true);
}
static inline int spa_json_begin_array(struct spa_json * iter, const char *data, size_t size)
SPA_API_IMPL int spa_json_begin_array(struct spa_json * iter, const char *data, size_t size)
{
return spa_json_begin_container(iter, data, size, '[', false);
}
@ -197,7 +197,7 @@ static inline int spa_json_begin_array(struct spa_json * iter, const char *data,
return count; \
}
static inline int spa_json_str_array_uint32(const char *arr, size_t arr_len,
SPA_API_IMPL int spa_json_str_array_uint32(const char *arr, size_t arr_len,
uint32_t *values, size_t max)
{
spa_json_make_str_array_unpack(32,uint32_t, atoi);

View file

@ -9,6 +9,8 @@
extern "C" {
#endif
#include <spa/utils/defs.h>
/**
* \defgroup spa_list List
* Doubly linked list data structure
@ -26,19 +28,19 @@ struct spa_list {
#define SPA_LIST_INIT(list) ((struct spa_list){ (list), (list) })
static inline void spa_list_init(struct spa_list *list)
SPA_API_IMPL void spa_list_init(struct spa_list *list)
{
*list = SPA_LIST_INIT(list);
}
static inline int spa_list_is_initialized(struct spa_list *list)
SPA_API_IMPL int spa_list_is_initialized(struct spa_list *list)
{
return !!list->prev;
}
#define spa_list_is_empty(l) ((l)->next == (l))
static inline void spa_list_insert(struct spa_list *list, struct spa_list *elem)
SPA_API_IMPL void spa_list_insert(struct spa_list *list, struct spa_list *elem)
{
elem->prev = list;
elem->next = list->next;
@ -46,7 +48,7 @@ static inline void spa_list_insert(struct spa_list *list, struct spa_list *elem)
elem->next->prev = elem;
}
static inline void spa_list_insert_list(struct spa_list *list, struct spa_list *other)
SPA_API_IMPL void spa_list_insert_list(struct spa_list *list, struct spa_list *other)
{
if (spa_list_is_empty(other))
return;
@ -56,7 +58,7 @@ static inline void spa_list_insert_list(struct spa_list *list, struct spa_list *
list->next = other->next;
}
static inline void spa_list_remove(struct spa_list *elem)
SPA_API_IMPL void spa_list_remove(struct spa_list *elem)
{
elem->prev->next = elem->next;
elem->next->prev = elem->prev;

View file

@ -12,6 +12,8 @@ extern "C" {
#include <inttypes.h>
#include <stddef.h>
#include <spa/utils/defs.h>
struct spa_ratelimit {
uint64_t interval;
uint64_t begin;
@ -20,7 +22,7 @@ struct spa_ratelimit {
unsigned n_suppressed;
};
static inline int spa_ratelimit_test(struct spa_ratelimit *r, uint64_t now)
SPA_API_IMPL int spa_ratelimit_test(struct spa_ratelimit *r, uint64_t now)
{
unsigned suppressed = 0;
if (r->begin + r->interval < now) {

View file

@ -40,7 +40,7 @@ struct spa_ringbuffer {
*
* \param rbuf a spa_ringbuffer
*/
static inline void spa_ringbuffer_init(struct spa_ringbuffer *rbuf)
SPA_API_IMPL void spa_ringbuffer_init(struct spa_ringbuffer *rbuf)
{
*rbuf = SPA_RINGBUFFER_INIT();
}
@ -51,7 +51,7 @@ static inline void spa_ringbuffer_init(struct spa_ringbuffer *rbuf)
* \param rbuf a spa_ringbuffer
* \param size the target size of \a rbuf
*/
static inline void spa_ringbuffer_set_avail(struct spa_ringbuffer *rbuf, uint32_t size)
SPA_API_IMPL void spa_ringbuffer_set_avail(struct spa_ringbuffer *rbuf, uint32_t size)
{
rbuf->readindex = 0;
rbuf->writeindex = size;
@ -67,7 +67,7 @@ static inline void spa_ringbuffer_set_avail(struct spa_ringbuffer *rbuf, uint32_
* there was an underrun. values > rbuf->size means there
* was an overrun.
*/
static inline int32_t spa_ringbuffer_get_read_index(struct spa_ringbuffer *rbuf, uint32_t *index)
SPA_API_IMPL int32_t spa_ringbuffer_get_read_index(struct spa_ringbuffer *rbuf, uint32_t *index)
{
*index = __atomic_load_n(&rbuf->readindex, __ATOMIC_RELAXED);
return (int32_t) (__atomic_load_n(&rbuf->writeindex, __ATOMIC_ACQUIRE) - *index);
@ -84,7 +84,7 @@ static inline int32_t spa_ringbuffer_get_read_index(struct spa_ringbuffer *rbuf,
* \param data destination memory
* \param len number of bytes to read
*/
static inline void
SPA_API_IMPL void
spa_ringbuffer_read_data(struct spa_ringbuffer *rbuf SPA_UNUSED,
const void *buffer, uint32_t size,
uint32_t offset, void *data, uint32_t len)
@ -101,7 +101,7 @@ spa_ringbuffer_read_data(struct spa_ringbuffer *rbuf SPA_UNUSED,
* \param rbuf a spa_ringbuffer
* \param index new index
*/
static inline void spa_ringbuffer_read_update(struct spa_ringbuffer *rbuf, int32_t index)
SPA_API_IMPL void spa_ringbuffer_read_update(struct spa_ringbuffer *rbuf, int32_t index)
{
__atomic_store_n(&rbuf->readindex, index, __ATOMIC_RELEASE);
}
@ -117,7 +117,7 @@ static inline void spa_ringbuffer_read_update(struct spa_ringbuffer *rbuf, int32
* was an overrun. Subtract from the buffer size to get
* the number of bytes available for writing.
*/
static inline int32_t spa_ringbuffer_get_write_index(struct spa_ringbuffer *rbuf, uint32_t *index)
SPA_API_IMPL int32_t spa_ringbuffer_get_write_index(struct spa_ringbuffer *rbuf, uint32_t *index)
{
*index = __atomic_load_n(&rbuf->writeindex, __ATOMIC_RELAXED);
return (int32_t) (*index - __atomic_load_n(&rbuf->readindex, __ATOMIC_ACQUIRE));
@ -134,7 +134,7 @@ static inline int32_t spa_ringbuffer_get_write_index(struct spa_ringbuffer *rbuf
* \param data source memory
* \param len number of bytes to write
*/
static inline void
SPA_API_IMPL void
spa_ringbuffer_write_data(struct spa_ringbuffer *rbuf SPA_UNUSED,
void *buffer, uint32_t size,
uint32_t offset, const void *data, uint32_t len)
@ -151,7 +151,7 @@ spa_ringbuffer_write_data(struct spa_ringbuffer *rbuf SPA_UNUSED,
* \param rbuf a spa_ringbuffer
* \param index new index
*/
static inline void spa_ringbuffer_write_update(struct spa_ringbuffer *rbuf, int32_t index)
SPA_API_IMPL void spa_ringbuffer_write_update(struct spa_ringbuffer *rbuf, int32_t index)
{
__atomic_store_n(&rbuf->writeindex, index, __ATOMIC_RELEASE);
}

View file

@ -33,7 +33,7 @@ extern "C" {
* If both \a a and \a b are NULL, the two are considered equal.
*
*/
static inline bool spa_streq(const char *s1, const char *s2)
SPA_API_IMPL bool spa_streq(const char *s1, const char *s2)
{
return SPA_LIKELY(s1 && s2) ? strcmp(s1, s2) == 0 : s1 == s2;
}
@ -43,7 +43,7 @@ static inline bool spa_streq(const char *s1, const char *s2)
*
* If both \a a and \a b are NULL, the two are considered equal.
*/
static inline bool spa_strneq(const char *s1, const char *s2, size_t len)
SPA_API_IMPL bool spa_strneq(const char *s1, const char *s2, size_t len)
{
return SPA_LIKELY(s1 && s2) ? strncmp(s1, s2, len) == 0 : s1 == s2;
}
@ -54,7 +54,7 @@ static inline bool spa_strneq(const char *s1, const char *s2, size_t len)
* A \a s is NULL, it never starts with the given \a prefix. A \a prefix of
* NULL is a bug in the caller.
*/
static inline bool spa_strstartswith(const char *s, const char *prefix)
SPA_API_IMPL bool spa_strstartswith(const char *s, const char *prefix)
{
if (SPA_UNLIKELY(s == NULL))
return false;
@ -70,7 +70,7 @@ static inline bool spa_strstartswith(const char *s, const char *prefix)
* A \a s is NULL, it never ends with the given \a suffix. A \a suffix of
* NULL is a bug in the caller.
*/
static inline bool spa_strendswith(const char *s, const char *suffix)
SPA_API_IMPL bool spa_strendswith(const char *s, const char *suffix)
{
size_t l1, l2;
@ -92,7 +92,7 @@ static inline bool spa_strendswith(const char *s, const char *suffix)
*
* \return true on success, false otherwise
*/
static inline bool spa_atoi32(const char *str, int32_t *val, int base)
SPA_API_IMPL bool spa_atoi32(const char *str, int32_t *val, int base)
{
char *endptr;
long v;
@ -120,7 +120,7 @@ static inline bool spa_atoi32(const char *str, int32_t *val, int base)
*
* \return true on success, false otherwise
*/
static inline bool spa_atou32(const char *str, uint32_t *val, int base)
SPA_API_IMPL bool spa_atou32(const char *str, uint32_t *val, int base)
{
char *endptr;
unsigned long long v;
@ -148,7 +148,7 @@ static inline bool spa_atou32(const char *str, uint32_t *val, int base)
*
* \return true on success, false otherwise
*/
static inline bool spa_atoi64(const char *str, int64_t *val, int base)
SPA_API_IMPL bool spa_atoi64(const char *str, int64_t *val, int base)
{
char *endptr;
long long v;
@ -173,7 +173,7 @@ static inline bool spa_atoi64(const char *str, int64_t *val, int base)
*
* \return true on success, false otherwise
*/
static inline bool spa_atou64(const char *str, uint64_t *val, int base)
SPA_API_IMPL bool spa_atou64(const char *str, uint64_t *val, int base)
{
char *endptr;
unsigned long long v;
@ -196,7 +196,7 @@ static inline bool spa_atou64(const char *str, uint64_t *val, int base)
*
* \return true on success, false otherwise
*/
static inline bool spa_atob(const char *str)
SPA_API_IMPL bool spa_atob(const char *str)
{
return spa_streq(str, "true") || spa_streq(str, "1");
}
@ -210,7 +210,7 @@ static inline bool spa_atob(const char *str)
* number on error.
*/
SPA_PRINTF_FUNC(3, 0)
static inline int spa_vscnprintf(char *buffer, size_t size, const char *format, va_list args)
SPA_API_IMPL int spa_vscnprintf(char *buffer, size_t size, const char *format, va_list args)
{
int r;
@ -233,7 +233,7 @@ static inline int spa_vscnprintf(char *buffer, size_t size, const char *format,
* number on error.
*/
SPA_PRINTF_FUNC(3, 4)
static inline int spa_scnprintf(char *buffer, size_t size, const char *format, ...)
SPA_API_IMPL int spa_scnprintf(char *buffer, size_t size, const char *format, ...)
{
int r;
va_list args;
@ -253,7 +253,7 @@ static inline int spa_scnprintf(char *buffer, size_t size, const char *format, .
*
* \return the result float.
*/
static inline float spa_strtof(const char *str, char **endptr)
SPA_API_IMPL float spa_strtof(const char *str, char **endptr)
{
#ifndef __LOCALE_C_ONLY
static locale_t locale = NULL;
@ -279,7 +279,7 @@ static inline float spa_strtof(const char *str, char **endptr)
*
* \return true on success, false otherwise
*/
static inline bool spa_atof(const char *str, float *val)
SPA_API_IMPL bool spa_atof(const char *str, float *val)
{
char *endptr;
float v;
@ -303,7 +303,7 @@ static inline bool spa_atof(const char *str, float *val)
*
* \return the result float.
*/
static inline double spa_strtod(const char *str, char **endptr)
SPA_API_IMPL double spa_strtod(const char *str, char **endptr)
{
#ifndef __LOCALE_C_ONLY
static locale_t locale = NULL;
@ -329,7 +329,7 @@ static inline double spa_strtod(const char *str, char **endptr)
*
* \return true on success, false otherwise
*/
static inline bool spa_atod(const char *str, double *val)
SPA_API_IMPL bool spa_atod(const char *str, double *val)
{
char *endptr;
double v;
@ -346,7 +346,7 @@ static inline bool spa_atod(const char *str, double *val)
return true;
}
static inline char *spa_dtoa(char *str, size_t size, double val)
SPA_API_IMPL char *spa_dtoa(char *str, size_t size, double val)
{
int i, l;
l = spa_scnprintf(str, size, "%f", val);
@ -362,7 +362,7 @@ struct spa_strbuf {
size_t pos;
};
static inline void spa_strbuf_init(struct spa_strbuf *buf, char *buffer, size_t maxsize)
SPA_API_IMPL void spa_strbuf_init(struct spa_strbuf *buf, char *buffer, size_t maxsize)
{
buf->buffer = buffer;
buf->maxsize = maxsize;
@ -372,7 +372,7 @@ static inline void spa_strbuf_init(struct spa_strbuf *buf, char *buffer, size_t
}
SPA_PRINTF_FUNC(2, 3)
static inline int spa_strbuf_append(struct spa_strbuf *buf, const char *fmt, ...)
SPA_API_IMPL int spa_strbuf_append(struct spa_strbuf *buf, const char *fmt, ...)
{
size_t remain = buf->maxsize - buf->pos;
ssize_t written;

View file

@ -124,12 +124,12 @@ struct spa_type_info {
const struct spa_type_info *values;
};
static inline bool spa_type_is_a(const char *type, const char *parent)
SPA_API_IMPL bool spa_type_is_a(const char *type, const char *parent)
{
return type != NULL && parent != NULL && strncmp(type, parent, strlen(parent)) == 0;
}
static inline const char *spa_type_short_name(const char *name)
SPA_API_IMPL const char *spa_type_short_name(const char *name)
{
const char *h;
if ((h = strrchr(name, ':')) != NULL)
@ -137,7 +137,7 @@ static inline const char *spa_type_short_name(const char *name)
return name;
}
static inline uint32_t spa_type_from_short_name(const char *name,
SPA_API_IMPL uint32_t spa_type_from_short_name(const char *name,
const struct spa_type_info *info, uint32_t unknown)
{
int i;
@ -147,7 +147,7 @@ static inline uint32_t spa_type_from_short_name(const char *name,
}
return unknown;
}
static inline const char * spa_type_to_name(uint32_t type,
SPA_API_IMPL const char * spa_type_to_name(uint32_t type,
const struct spa_type_info *info, const char *unknown)
{
int i;
@ -158,7 +158,7 @@ static inline const char * spa_type_to_name(uint32_t type,
return unknown;
}
static inline const char * spa_type_to_short_name(uint32_t type,
SPA_API_IMPL const char * spa_type_to_short_name(uint32_t type,
const struct spa_type_info *info, const char *unknown)
{
const char *n = spa_type_to_name(type, info, unknown);