c++ compiler fixes

This commit is contained in:
Wim Taymans 2018-02-08 11:24:20 +01:00
parent f049d3dc7f
commit 21e3b4cec7
5 changed files with 26 additions and 16 deletions

View file

@ -134,28 +134,28 @@ static inline bool spa_graph_data_iterate(struct spa_graph_data *data)
static inline int spa_graph_impl_need_input(void *data, struct spa_graph_node *node) static inline int spa_graph_impl_need_input(void *data, struct spa_graph_node *node)
{ {
struct spa_graph_data *d = data; struct spa_graph_data *d = (struct spa_graph_data *) data;
spa_debug("node %p start pull", node); spa_debug("node %p start pull", node);
node->state = SPA_GRAPH_STATE_CHECK_IN; node->state = SPA_GRAPH_STATE_CHECK_IN;
d->node = node; d->node = node;
if (node->ready_link.next == NULL) if (node->ready_link.next == NULL)
spa_list_append(&d->ready, &node->ready_link); spa_list_append(&d->ready, &node->ready_link);
while(spa_graph_data_iterate(data)); while(spa_graph_data_iterate(d));
return 0; return 0;
} }
static inline int spa_graph_impl_have_output(void *data, struct spa_graph_node *node) static inline int spa_graph_impl_have_output(void *data, struct spa_graph_node *node)
{ {
struct spa_graph_data *d = data; struct spa_graph_data *d = (struct spa_graph_data *) data;
spa_debug("node %p start push", node); spa_debug("node %p start push", node);
node->state = SPA_GRAPH_STATE_OUT; node->state = SPA_GRAPH_STATE_OUT;
d->node = node; d->node = node;
if (node->ready_link.next == NULL) if (node->ready_link.next == NULL)
spa_list_append(&d->ready, &node->ready_link); spa_list_append(&d->ready, &node->ready_link);
while(spa_graph_data_iterate(data)); while(spa_graph_data_iterate(d));
return 0; return 0;
} }

View file

@ -116,13 +116,14 @@ do { \
case 's': \ case 's': \
*va_arg(args, char**) = \ *va_arg(args, char**) = \
(pod == NULL || (SPA_POD_TYPE(pod) == SPA_POD_TYPE_NONE) \ (pod == NULL || (SPA_POD_TYPE(pod) == SPA_POD_TYPE_NONE) \
? NULL : SPA_POD_CONTENTS(struct spa_pod_string, pod)); \ ? NULL \
: (char *)SPA_POD_CONTENTS(struct spa_pod_string, pod)); \
break; \ break; \
case 'S': \ case 'S': \
{ \ { \
char *dest = va_arg(args, char*); \ char *dest = va_arg(args, char*); \
uint32_t maxlen = va_arg(args, uint32_t); \ uint32_t maxlen = va_arg(args, uint32_t); \
strncpy(dest, SPA_POD_CONTENTS(struct spa_pod_string, pod), maxlen-1); \ strncpy(dest, (char *)SPA_POD_CONTENTS(struct spa_pod_string, pod), maxlen-1); \
break; \ break; \
} \ } \
case 'z': \ case 'z': \
@ -139,11 +140,12 @@ do { \
break; \ break; \
case 'B': \ case 'B': \
*va_arg(args, uint32_t **) = \ *va_arg(args, uint32_t **) = \
SPA_POD_CONTENTS(struct spa_pod_bitmap, pod); \ (uint32_t *) SPA_POD_CONTENTS(struct spa_pod_bitmap, pod); \
break; \ break; \
case 'p': \ case 'p': \
{ \ { \
struct spa_pod_pointer_body *b = SPA_POD_BODY(pod); \ struct spa_pod_pointer_body *b = \
(struct spa_pod_pointer_body *) SPA_POD_BODY(pod); \
*(va_arg(args, void **)) = b->value; \ *(va_arg(args, void **)) = b->value; \
break; \ break; \
} \ } \
@ -247,7 +249,7 @@ static inline int spa_pod_parser_getv(struct spa_pod_parser *parser,
case ':': case ':':
{ {
uint32_t key = va_arg(args, uint32_t); uint32_t key = va_arg(args, uint32_t);
const struct spa_pod *obj = parser->iter[parser->depth].data; const struct spa_pod *obj = (const struct spa_pod *) parser->iter[parser->depth].data;
prop = spa_pod_find_prop(obj, key); prop = spa_pod_find_prop(obj, key);
if (prop != NULL && (prop->body.flags & SPA_POD_PROP_FLAG_UNSET) == 0) if (prop != NULL && (prop->body.flags & SPA_POD_PROP_FLAG_UNSET) == 0)

View file

@ -24,6 +24,8 @@
extern "C" { extern "C" {
#endif #endif
#include <stdio.h>
#include <spa/support/log.h> #include <spa/support/log.h>
static inline void spa_log_impl_logv(struct spa_log *log, static inline void spa_log_impl_logv(struct spa_log *log,

View file

@ -26,10 +26,16 @@ extern "C" {
#include <spa/support/type-map.h> #include <spa/support/type-map.h>
struct spa_type_map_impl_data {
struct spa_type_map map;
unsigned int n_types;
char **types;
};
static inline uint32_t static inline uint32_t
spa_type_map_impl_get_id (struct spa_type_map *map, const char *type) spa_type_map_impl_get_id (struct spa_type_map *map, const char *type)
{ {
struct { struct spa_type_map map; uint32_t n_types; char *types[1]; } *impl = (void*) map; struct spa_type_map_impl_data *impl = (struct spa_type_map_impl_data *) map;
uint32_t i = 0; uint32_t i = 0;
for (i = 1; i <= impl->n_types; i++) { for (i = 1; i <= impl->n_types; i++) {
@ -44,7 +50,7 @@ spa_type_map_impl_get_id (struct spa_type_map *map, const char *type)
static inline const char * static inline const char *
spa_type_map_impl_get_type (const struct spa_type_map *map, uint32_t id) spa_type_map_impl_get_type (const struct spa_type_map *map, uint32_t id)
{ {
struct { struct spa_type_map map; uint32_t n_types; char *types[1]; } *impl = (void*) map; struct spa_type_map_impl_data *impl = (struct spa_type_map_impl_data *) map;
if (id <= impl->n_types) if (id <= impl->n_types)
return impl->types[id]; return impl->types[id];
return NULL; return NULL;
@ -52,7 +58,7 @@ spa_type_map_impl_get_type (const struct spa_type_map *map, uint32_t id)
static inline size_t spa_type_map_impl_get_size (const struct spa_type_map *map) static inline size_t spa_type_map_impl_get_size (const struct spa_type_map *map)
{ {
struct { struct spa_type_map map; uint32_t n_types; char *types[1]; } *impl = (void*) map; struct spa_type_map_impl_data *impl = (struct spa_type_map_impl_data *) map;
return impl->n_types; return impl->n_types;
} }

View file

@ -97,9 +97,9 @@ spa_ringbuffer_read_data(struct spa_ringbuffer *rbuf,
uint32_t offset, void *data, uint32_t len) uint32_t offset, void *data, uint32_t len)
{ {
uint32_t l0 = SPA_MIN(len, size - offset), l1 = len - l0; uint32_t l0 = SPA_MIN(len, size - offset), l1 = len - l0;
memcpy(data, buffer + offset, l0); memcpy(data, SPA_MEMBER(buffer, offset, void), l0);
if (SPA_UNLIKELY(l1 > 0)) if (SPA_UNLIKELY(l1 > 0))
memcpy(data + l0, buffer, l1); memcpy(SPA_MEMBER(data, l0, void), buffer, l1);
} }
/** /**
@ -147,9 +147,9 @@ spa_ringbuffer_write_data(struct spa_ringbuffer *rbuf,
uint32_t offset, const void *data, uint32_t len) uint32_t offset, const void *data, uint32_t len)
{ {
uint32_t l0 = SPA_MIN(len, size - offset), l1 = len - l0; uint32_t l0 = SPA_MIN(len, size - offset), l1 = len - l0;
memcpy(buffer + offset, data, l0); memcpy(SPA_MEMBER(buffer, offset, void), data, l0);
if (SPA_UNLIKELY(l1 > 0)) if (SPA_UNLIKELY(l1 > 0))
memcpy(buffer, data + l0, l1); memcpy(buffer, SPA_MEMBER(data, l0, void), l1);
} }
/** /**