mirror of
https://git.rwth-aachen.de/acs/public/villas/node/
synced 2025-03-09 00:00:00 +01:00
fix compiler errors on OS X
This commit is contained in:
parent
8c9348cfc0
commit
9beda12c4c
7 changed files with 56 additions and 31 deletions
|
@ -31,10 +31,10 @@ static char *config;
|
|||
void api_restart_handler()
|
||||
{
|
||||
int ret;
|
||||
|
||||
|
||||
char *argv[] = { "villas-node", config, NULL };
|
||||
|
||||
ret = execvpe("/proc/self/exe", argv, environ);
|
||||
ret = execvp("/proc/self/exe", argv);
|
||||
if (ret)
|
||||
serror("Failed to restart");
|
||||
}
|
||||
|
@ -43,11 +43,11 @@ static int api_restart(struct api_action *h, json_t *args, json_t **resp, struct
|
|||
{
|
||||
int ret;
|
||||
json_error_t err;
|
||||
|
||||
|
||||
/* If no config is provided via request, we will use the previous one */
|
||||
if (s->api->super_node->uri)
|
||||
config = strdup(s->api->super_node->uri);
|
||||
|
||||
|
||||
if (args) {
|
||||
ret = json_unpack_ex(args, &err, 0, "{ s?: s }", "config", &config);
|
||||
if (ret < 0) {
|
||||
|
@ -64,7 +64,7 @@ static int api_restart(struct api_action *h, json_t *args, json_t **resp, struct
|
|||
|
||||
/* We pass some env variables to the new process */
|
||||
setenv("VILLAS_API_RESTART_COUNT", buf, 1);
|
||||
|
||||
|
||||
*resp = json_pack("{ s: i, s: s }",
|
||||
"restarts", cnt,
|
||||
"config", config
|
||||
|
@ -74,7 +74,7 @@ static int api_restart(struct api_action *h, json_t *args, json_t **resp, struct
|
|||
ret = atexit(api_restart_handler);
|
||||
if (ret)
|
||||
return 0;
|
||||
|
||||
|
||||
/* Properly terminate current instance */
|
||||
killme(SIGTERM);
|
||||
|
||||
|
|
|
@ -24,6 +24,7 @@
|
|||
#include "plugin.h"
|
||||
#include "utils.h"
|
||||
#include "io/raw.h"
|
||||
#include "compat.h"
|
||||
|
||||
/** Convert float to host byte order */
|
||||
#define SWAP_FLT_TOH(o, n) ({ \
|
||||
|
|
|
@ -20,10 +20,10 @@
|
|||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
###################################################################################
|
||||
|
||||
LIB_SRCS += $(addprefix lib/nodes/, cbuilder.c loopback.c)
|
||||
|
||||
ifeq ($(PLATFORM),Linux)
|
||||
WITH_FPGA ?= 1
|
||||
WITH_CBUILDER ?= 1
|
||||
WITH_LOOPBACK ?= 1
|
||||
endif
|
||||
|
||||
WITH_TEST_RTT ?= 0
|
||||
|
@ -37,6 +37,18 @@ WITH_NANOMSG ?= 1
|
|||
WITH_SHMEM ?= 1
|
||||
WITH_STATS ?= 1
|
||||
|
||||
# Enabled loopback node-type
|
||||
ifeq ($(WITH_LOOPBACK),1)
|
||||
LIB_SRCS += lib/nodes/loopback.c
|
||||
LIB_CFLAGS += -DWITH_LOOPBACK
|
||||
endif
|
||||
|
||||
# Enabled Cbuilder node-type
|
||||
ifeq ($(WITH_CBUILDER),1)
|
||||
LIB_SRCS += lib/nodes/cbuilder.c
|
||||
LIB_CFLAGS += -DWITH_CBUILDER
|
||||
endif
|
||||
|
||||
# Enable stats node-type
|
||||
ifeq ($(WITH_STATS),1)
|
||||
LIB_SRCS += lib/nodes/stats.c
|
||||
|
|
|
@ -229,12 +229,18 @@ int file_start(struct node *n)
|
|||
struct sample s = { .capacity = 0 };
|
||||
struct sample *smps[] = { &s };
|
||||
|
||||
ret = io_scan(&f->io, smps, 1);
|
||||
if (ret != 1)
|
||||
error("Failed to read first timestamp of node %s", node_name(n));
|
||||
|
||||
f->first = s.ts.origin;
|
||||
f->offset = file_calc_offset(&f->first, &f->epoch, f->epoch_mode);
|
||||
if (io_eof(&f->io)) {
|
||||
warn("Empty file");
|
||||
}
|
||||
else {
|
||||
ret = io_scan(&f->io, smps, 1);
|
||||
if (ret == 1) {
|
||||
f->first = s.ts.origin;
|
||||
f->offset = file_calc_offset(&f->first, &f->epoch, f->epoch_mode);
|
||||
}
|
||||
else
|
||||
warn("Failed to read first timestamp of node %s", node_name(n));
|
||||
}
|
||||
}
|
||||
|
||||
io_rewind(&f->io);
|
||||
|
|
|
@ -157,10 +157,12 @@ check: if (optarg == endptr)
|
|||
|
||||
type = argv[optind];
|
||||
|
||||
s->type = signal_lookup_type(type);
|
||||
if (s->type == -1)
|
||||
int t = signal_lookup_type(type);
|
||||
if (t == -1)
|
||||
error("Invalid signal type: %s", type);
|
||||
|
||||
s->type = t;
|
||||
|
||||
/* We know the expected number of values. */
|
||||
n->samplelen = s->values;
|
||||
|
||||
|
|
|
@ -31,7 +31,7 @@
|
|||
static void queue_signalled_cleanup(void *p)
|
||||
{
|
||||
struct queue_signalled *qs = p;
|
||||
|
||||
|
||||
if (qs->mode == QUEUE_SIGNALLED_PTHREAD)
|
||||
pthread_mutex_unlock(&qs->pthread.mutex);
|
||||
}
|
||||
|
@ -39,9 +39,9 @@ static void queue_signalled_cleanup(void *p)
|
|||
int queue_signalled_init(struct queue_signalled *qs, size_t size, struct memtype *mem, int flags)
|
||||
{
|
||||
int ret;
|
||||
|
||||
|
||||
qs->mode = flags & QUEUE_SIGNALLED_MASK;
|
||||
|
||||
|
||||
if (qs->mode == 0) {
|
||||
#ifdef __linux__
|
||||
if (flags & QUEUE_SIGNALLED_PROCESS_SHARED)
|
||||
|
@ -60,7 +60,7 @@ int queue_signalled_init(struct queue_signalled *qs, size_t size, struct memtype
|
|||
if (qs->mode == QUEUE_SIGNALLED_PTHREAD) {
|
||||
pthread_condattr_t cvattr;
|
||||
pthread_mutexattr_t mtattr;
|
||||
|
||||
|
||||
pthread_mutexattr_init(&mtattr);
|
||||
pthread_condattr_init(&cvattr);
|
||||
|
||||
|
@ -98,7 +98,7 @@ int queue_signalled_destroy(struct queue_signalled *qs)
|
|||
ret = queue_destroy(&qs->queue);
|
||||
if (ret < 0)
|
||||
return ret;
|
||||
|
||||
|
||||
if (qs->mode == QUEUE_SIGNALLED_PTHREAD) {
|
||||
pthread_cond_destroy(&qs->pthread.ready);
|
||||
pthread_mutex_destroy(&qs->pthread.mutex);
|
||||
|
@ -121,12 +121,12 @@ int queue_signalled_destroy(struct queue_signalled *qs)
|
|||
|
||||
int queue_signalled_push(struct queue_signalled *qs, void *ptr)
|
||||
{
|
||||
int ret, pushed;
|
||||
int pushed;
|
||||
|
||||
pushed = queue_push(&qs->queue, ptr);
|
||||
if (pushed < 0)
|
||||
return pushed;
|
||||
|
||||
|
||||
if (qs->mode == QUEUE_SIGNALLED_PTHREAD) {
|
||||
pthread_mutex_lock(&qs->pthread.mutex);
|
||||
pthread_cond_broadcast(&qs->pthread.ready);
|
||||
|
@ -137,6 +137,7 @@ int queue_signalled_push(struct queue_signalled *qs, void *ptr)
|
|||
}
|
||||
#ifdef __linux__
|
||||
else if (qs->mode == QUEUE_SIGNALLED_EVENTFD) {
|
||||
int ret;
|
||||
uint64_t incr = 1;
|
||||
ret = write(qs->eventfd, &incr, sizeof(incr));
|
||||
if (ret < 0)
|
||||
|
@ -151,7 +152,7 @@ int queue_signalled_push(struct queue_signalled *qs, void *ptr)
|
|||
|
||||
int queue_signalled_push_many(struct queue_signalled *qs, void *ptr[], size_t cnt)
|
||||
{
|
||||
int ret, pushed;
|
||||
int pushed;
|
||||
|
||||
pushed = queue_push_many(&qs->queue, ptr, cnt);
|
||||
if (pushed < 0)
|
||||
|
@ -167,6 +168,7 @@ int queue_signalled_push_many(struct queue_signalled *qs, void *ptr[], size_t cn
|
|||
}
|
||||
#ifdef __linux__
|
||||
else if (qs->mode == QUEUE_SIGNALLED_EVENTFD) {
|
||||
int ret;
|
||||
uint64_t incr = 1;
|
||||
ret = write(qs->eventfd, &incr, sizeof(incr));
|
||||
if (ret < 0)
|
||||
|
@ -181,7 +183,7 @@ int queue_signalled_push_many(struct queue_signalled *qs, void *ptr[], size_t cn
|
|||
|
||||
int queue_signalled_pull(struct queue_signalled *qs, void **ptr)
|
||||
{
|
||||
int ret, pulled = 0;
|
||||
int pulled = 0;
|
||||
|
||||
/* Make sure that qs->mutex is unlocked if this thread gets cancelled. */
|
||||
pthread_cleanup_push(queue_signalled_cleanup, qs);
|
||||
|
@ -200,6 +202,7 @@ int queue_signalled_pull(struct queue_signalled *qs, void **ptr)
|
|||
continue; /* Try again */
|
||||
#ifdef __linux__
|
||||
else if (qs->mode == QUEUE_SIGNALLED_EVENTFD) {
|
||||
int ret;
|
||||
uint64_t cntr;
|
||||
ret = read(qs->eventfd, &cntr, sizeof(cntr));
|
||||
if (ret < 0)
|
||||
|
@ -221,7 +224,7 @@ int queue_signalled_pull(struct queue_signalled *qs, void **ptr)
|
|||
|
||||
int queue_signalled_pull_many(struct queue_signalled *qs, void *ptr[], size_t cnt)
|
||||
{
|
||||
int ret, pulled = 0;
|
||||
int pulled = 0;
|
||||
|
||||
/* Make sure that qs->mutex is unlocked if this thread gets cancelled. */
|
||||
pthread_cleanup_push(queue_signalled_cleanup, qs);
|
||||
|
@ -240,6 +243,7 @@ int queue_signalled_pull_many(struct queue_signalled *qs, void *ptr[], size_t cn
|
|||
continue; /* Try again */
|
||||
#ifdef __linux__
|
||||
else if (qs->mode == QUEUE_SIGNALLED_EVENTFD) {
|
||||
int ret;
|
||||
uint64_t cntr;
|
||||
ret = read(qs->eventfd, &cntr, sizeof(cntr));
|
||||
if (ret < 0)
|
||||
|
@ -253,7 +257,7 @@ int queue_signalled_pull_many(struct queue_signalled *qs, void *ptr[], size_t cn
|
|||
|
||||
if (qs->mode == QUEUE_SIGNALLED_PTHREAD)
|
||||
pthread_mutex_unlock(&qs->pthread.mutex);
|
||||
|
||||
|
||||
pthread_cleanup_pop(0);
|
||||
|
||||
return pulled;
|
||||
|
@ -267,7 +271,7 @@ int queue_signalled_close(struct queue_signalled *qs)
|
|||
pthread_mutex_lock(&qs->pthread.mutex);
|
||||
|
||||
ret = queue_close(&qs->queue);
|
||||
|
||||
|
||||
if (qs->mode == QUEUE_SIGNALLED_PTHREAD) {
|
||||
pthread_cond_broadcast(&qs->pthread.ready);
|
||||
pthread_mutex_unlock(&qs->pthread.mutex);
|
||||
|
@ -300,6 +304,6 @@ int queue_signalled_fd(struct queue_signalled *qs)
|
|||
#endif
|
||||
default: { }
|
||||
}
|
||||
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
|
|
@ -151,7 +151,7 @@ int sample_cmp(struct sample *a, struct sample *b, double epsilon, int flags)
|
|||
}
|
||||
|
||||
if (a->format != b->format) {
|
||||
printf("format: %#lx != %#lx\n", a->format, b->format);
|
||||
printf("format: %#llx != %#llx\n", a->format, b->format);
|
||||
return 6;
|
||||
}
|
||||
|
||||
|
@ -166,7 +166,7 @@ int sample_cmp(struct sample *a, struct sample *b, double epsilon, int flags)
|
|||
|
||||
case SAMPLE_DATA_FORMAT_INT:
|
||||
if (a->data[i].i != b->data[i].i) {
|
||||
printf("data[%d].i: %ld != %ld\n", i, a->data[i].i, b->data[i].i);
|
||||
printf("data[%d].i: %lld != %lld\n", i, a->data[i].i, b->data[i].i);
|
||||
return 5;
|
||||
}
|
||||
break;
|
||||
|
|
Loading…
Add table
Reference in a new issue