1
0
Fork 0
mirror of https://git.rwth-aachen.de/acs/public/villas/node/ synced 2025-03-09 00:00:00 +01:00

a lots of small cleanups

This commit is contained in:
Steffen Vogel 2015-03-21 15:29:00 +01:00
parent 08c41db911
commit b89f65debc
12 changed files with 31 additions and 33 deletions

View file

@ -20,7 +20,7 @@
#define IF_IRQ_MAX 3 /**< Maxmimal number of IRQs of an interface */
#ifndef SO_MARK
#define SO_MARK 36 /**< Workaround: add missing constant for OPAL-RT Redhawk target */
#define SO_MARK 36 /**< Workaround: add missing constant for OPAL-RT Redhawk target */
#endif
struct socket;

View file

@ -14,7 +14,7 @@
#define _BSD_SOURCE 1
#include <endian.h>
#elif defined(__PPC__) /* Xilinx toolchain */
#include <lwip/arch.h>
#include <lwip/arch.h>
#endif
#include "config.h"
@ -30,8 +30,8 @@
#define MSG_TYPE_START 1 /**< Message marks the beginning of a new simulation case */
#define MSG_TYPE_STOP 2 /**< Message marks the end of a simulation case */
#define MSG_ENDIAN_LITTLE 0 /**< Message values are in little endian format (float too!) */
#define MSG_ENDIAN_BIG 1 /**< Message values are in bit endian format */
#define MSG_ENDIAN_LITTLE 0 /**< Message values are in little endian format (float too!) */
#define MSG_ENDIAN_BIG 1 /**< Message values are in bit endian format */
#if BYTE_ORDER == LITTLE_ENDIAN
#define MSG_ENDIAN_HOST MSG_ENDIAN_LITTLE

View file

@ -133,7 +133,7 @@ struct node * node_lookup_name(const char *str, struct list *nodes);
* This is usefull for the helper programs: send, receive, test
* because they usually use the same configuration file as the
* server and therefore the direction needs to be swapped. */
int node_reverse(struct node *n);
void node_reverse(struct node *n);
/** Create a node by allocating dynamic memory. */
struct node * node_create();

View file

@ -243,19 +243,14 @@ int config_parse_node(config_setting_t *cfg, struct list *nodes)
if (!n->name)
cerror(cfg, "Missing node name");
if (config_setting_lookup_string(cfg, "type", &type)) {
n->vt = node_lookup_vtable(type);
if (!n->vt)
cerror(cfg, "Invalid type for node '%s'", n->name);
if (!n->vt->parse)
cerror(cfg, "Node type '%s' is not allowed in the config", type);
}
else
n->vt = node_lookup_vtable("udp");
if (!config_setting_lookup_string(cfg, "type", &type))
cerror(cfg, "Missing node name");
n->vt = node_lookup_vtable(type);
if (!n->vt)
cerror(cfg, "Invalid type for node '%s'", n->name);
ret = n->vt->parse(cfg, n);
if (!ret)
list_push(nodes, n);
@ -273,7 +268,7 @@ int config_parse_opal(config_setting_t *cfg, struct node *n)
return -1;
}
struct opal *o = (struct opal *) alloc(sizeof(struct opal));
struct opal *o = alloc(sizeof(struct opal));
config_setting_lookup_int(cfg, "send_id", &o->send_id);
config_setting_lookup_int(cfg, "recv_id", &o->recv_id);
@ -334,7 +329,7 @@ int config_parse_socket(config_setting_t *cfg, struct node *n)
/** @todo Netem settings are not usable AF_UNIX */
config_setting_t *cfg_netem = config_setting_get_member(cfg, "netem");
if (cfg_netem) {
s->netem = (struct netem *) alloc(sizeof(struct netem));
s->netem = alloc(sizeof(struct netem));
config_parse_netem(cfg_netem, s->netem);
}

View file

@ -71,7 +71,7 @@ int hook_log(struct msg *m, struct path *p)
if (file)
debug(5, "Opened log file for path %s: %s", pstr, fstr);
pthread_key_create(&pkey, (void (*)(void *)) fclose);
pthread_key_create(&pkey, (dtor_cb_t) fclose);
pthread_setspecific(pkey, file);
}
@ -128,7 +128,6 @@ int hook_fir(struct msg *m, struct path *p)
/* Create thread local storage for circular history buffer */
if (!history) {
history = alloc(len * sizeof(float));
pthread_key_create(&pkey, free);
pthread_setspecific(pkey, history);
}

View file

@ -60,6 +60,7 @@ int if_start(struct interface *i, int affinity)
int mark = 0;
FOREACH(&i->sockets, it) {
struct socket *s = it->socket;
if (s->netem) {
s->mark = 1 + mark++;
@ -88,7 +89,7 @@ int if_start(struct interface *i, int affinity)
int if_stop(struct interface *i)
{ INDENT
info("Stopping interface '%s'", i->name);
info("Stopping interface '%s'", i->name);
{ INDENT
if_setaffinity(i, -1L);

View file

@ -60,7 +60,7 @@ struct node_vtable const * node_lookup_vtable(const char *str)
}
int node_start(struct node *n)
{
{ INDENT
if (!n->refcnt) {
warn("Node '%s' is unused. Skipping...", n->name);
return -1;
@ -98,7 +98,7 @@ int node_start_defer(struct node *n)
}
int node_stop(struct node *n)
{
{ INDENT
int ret;
info("Stopping node '%s'", n->name);
@ -109,7 +109,7 @@ int node_stop(struct node *n)
return ret;
}
int node_reverse(struct node *n)
void node_reverse(struct node *n)
{
switch (n->vt->type) {
case IEEE_802_3:
@ -120,7 +120,7 @@ int node_reverse(struct node *n)
break;
default: { }
}
return n->vt->open == socket_open;
}
struct node * node_create()
{

View file

@ -22,7 +22,7 @@ int opal_init(int argc, char *argv[])
if (argc != 4)
return -1;
struct opal_global *g = (struct opal_global *) alloc(sizeof(struct opal_global));
struct opal_global *g = alloc(sizeof(struct opal_global));
pthread_mutex_init(&g->lock, NULL);

View file

@ -16,7 +16,9 @@
#include "utils.h"
#include "path.h"
#define sigev_notify_thread_id _sigev_un._tid
#ifndef sigev_notify_thread_id
#define sigev_notify_thread_id _sigev_un._tid
#endif
/** Linked list of paths. */
struct list paths;

View file

@ -22,7 +22,7 @@
void tick(int sig, siginfo_t *si, void *ptr)
{
struct msg *m = (struct msg*) si->si_value.sival_ptr;
struct msg *m = (struct msg *) si->si_value.sival_ptr;
msg_random(m);
msg_fprint(stdout, m);

View file

@ -150,16 +150,17 @@ int main(int argc, char *argv[])
info("Setup signals:");
signals_init();
info("Parsing configuration:");
config_init(&config);
#ifdef ENABLE_OPAL_ASYNC
/* Check if called as asynchronous process from RT-LAB */
/* Check if called we are called as an asynchronous process from RT-LAB. */
opal_init(argc, argv);
/* @todo: look in predefined locations for a file */
char *configfile = "opal-shmem.conf";
#else
char *configfile = argv[1];
#endif

View file

@ -34,8 +34,8 @@ int socket_print(struct node *n, char *buf, int len)
char local[INET6_ADDRSTRLEN + 16];
char remote[INET6_ADDRSTRLEN + 16];
socket_print_addr(local, sizeof(local), (struct sockaddr*) &s->local);
socket_print_addr(remote, sizeof(remote), (struct sockaddr*) &s->remote);
socket_print_addr(local, sizeof(local), (struct sockaddr *) &s->local);
socket_print_addr(remote, sizeof(remote), (struct sockaddr *) &s->remote);
return snprintf(buf, len, "local=%s, remote=%s", local, remote);
}