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

refactor: list_* -> vlist_*

This commit is contained in:
Steffen Vogel 2019-01-07 10:28:55 +01:00
parent 5b443aeff4
commit d18d786801
64 changed files with 490 additions and 490 deletions

2
common

@ -1 +1 @@
Subproject commit 47ee3e423f6a03be79d34c6bbfbf2fff7bd7d72b
Subproject commit e08b8ac8cf4f36bb98cc5410dc94b4433494f080

View file

@ -29,7 +29,7 @@ extern "C" {
/* Forward declaration */
struct msg;
struct sample;
struct list;
struct vlist;
/** Convert msg from network to host byteorder */
void msg_ntoh(struct msg *m);
@ -54,10 +54,10 @@ void msg_hdr_ntoh(struct msg *m);
int msg_verify(struct msg *m);
/** Copy fields from \p msg into \p smp. */
int msg_to_sample(struct msg *msg, struct sample *smp, struct list *signals);
int msg_to_sample(struct msg *msg, struct sample *smp, struct vlist *signals);
/** Copy fields form \p smp into \p msg. */
int msg_from_sample(struct msg *msg, struct sample *smp, struct list *signals);
int msg_from_sample(struct msg *msg, struct sample *smp, struct vlist *signals);
#ifdef __cplusplus
}

View file

@ -44,7 +44,7 @@ extern "C" {
/* Forward declarations */
struct path;
struct sample;
struct list;
struct vlist;
/** Descriptor for user defined hooks. See hooks[]. */
struct hook {
@ -63,7 +63,7 @@ struct hook {
};
int hook_init(struct hook *h, struct hook_type *vt, struct path *p, struct node *n);
int hook_init_builtin_list(struct list *l, bool builtin, int mask, struct path *p, struct node *n);
int hook_init_builtin_list(struct vlist *l, bool builtin, int mask, struct path *p, struct node *n);
int hook_parse(struct hook *h, json_t *cfg);
@ -76,9 +76,9 @@ int hook_periodic(struct hook *h);
int hook_restart(struct hook *h);
int hook_process(struct hook *h, struct sample *smps[], unsigned *cnt);
int hook_process_list(struct list *hs, struct sample *smps[], unsigned cnt);
int hook_process_list(struct vlist *hs, struct sample *smps[], unsigned cnt);
/** Compare two hook functions with their priority. Used by list_sort() */
/** Compare two hook functions with their priority. Used by vlist_sort() */
int hook_cmp_priority(const void *a, const void *b);
/** Parses an object of hooks
@ -95,7 +95,7 @@ int hook_cmp_priority(const void *a, const void *b);
* hooks = [ "print" ]
* }
*/
int hook_parse_list(struct list *list, json_t *cfg, int mask, struct path *p, struct node *n);
int hook_parse_list(struct vlist *list, json_t *cfg, int mask, struct path *p, struct node *n);
#ifdef __cplusplus
}

View file

@ -71,7 +71,7 @@ struct io {
size_t buflen;
} in, out;
struct list *signals; /**< Signal meta data for parsed samples by io_scan() */
struct vlist *signals; /**< Signal meta data for parsed samples by io_scan() */
bool header_printed;
enum io_mode mode;
@ -80,7 +80,7 @@ struct io {
const struct format_type *_vt;
};
int io_init(struct io *io, const struct format_type *fmt, struct list *signals, int flags);
int io_init(struct io *io, const struct format_type *fmt, struct vlist *signals, int flags);
int io_init_auto(struct io *io, const struct format_type *fmt, int len, int flags);

View file

@ -57,7 +57,7 @@ struct interface {
char irqs[IF_IRQ_MAX]; /**< List of IRQs of the NIC. */
int affinity; /**< IRQ / Core Affinity of this interface. */
struct list sockets; /**< Linked list of associated sockets. */
struct vlist sockets; /**< Linked list of associated sockets. */
};
/** Add a new interface to the global list and lookup name, irqs...

View file

@ -36,7 +36,7 @@ extern "C" {
struct node;
struct sample;
struct signal;
struct list;
struct vlist;
enum mapping_type {
MAPPING_TYPE_DATA,
@ -98,15 +98,15 @@ struct mapping_entry {
};
};
int mapping_remap(const struct list *m, struct sample *remapped, const struct sample *original, const struct stats *s);
int mapping_remap(const struct vlist *m, struct sample *remapped, const struct sample *original, const struct stats *s);
int mapping_update(const struct mapping_entry *e, struct sample *remapped, const struct sample *original, const struct stats *s);
int mapping_parse(struct mapping_entry *e, json_t *cfg, struct list *nodes);
int mapping_parse(struct mapping_entry *e, json_t *cfg, struct vlist *nodes);
int mapping_parse_str(struct mapping_entry *e, const char *str, struct list *nodes);
int mapping_parse_str(struct mapping_entry *e, const char *str, struct vlist *nodes);
int mapping_parse_list(struct list *l, json_t *cfg, struct list *nodes);
int mapping_parse_list(struct vlist *l, json_t *cfg, struct vlist *nodes);
int mapping_to_str(const struct mapping_entry *me, unsigned index, char **str);

View file

@ -47,7 +47,7 @@ struct node_direction {
int builtin; /**< This node should use built-in hooks by default. */
int vectorize; /**< Number of messages to send / recv at once (scatter / gather) */
struct list hooks; /**< List of write hooks (struct hook). */
struct vlist hooks; /**< List of write hooks (struct hook). */
json_t *cfg; /**< A JSON object containing the configuration of the node. */
};
@ -71,7 +71,7 @@ struct node
struct node_direction in, out;
struct list signals; /**< Signal meta data for data which is __received__ by node_read(). */
struct vlist signals; /**< Signal meta data for data which is __received__ by node_read(). */
enum state state;
@ -105,10 +105,10 @@ int node_parse(struct node *n, json_t *cfg, const char *name);
* @param nodes The nodes will be added to this list.
* @param all This list contains all valid nodes.
*/
int node_parse_list(struct list *list, json_t *cfg, struct list *all);
int node_parse_list(struct vlist *list, json_t *cfg, struct vlist *all);
/** Parse the list of signal definitions. */
int node_parse_signals(struct list *list, json_t *cfg);
int node_parse_signals(struct vlist *list, json_t *cfg);
/** Validate node configuration. */
int node_check(struct node *n);

View file

@ -52,7 +52,7 @@ struct node_type {
enum state state; /**< State of this node-type. */
struct list instances; /**< A list of all existing nodes of this type. */
struct vlist instances; /**< A list of all existing nodes of this type. */
size_t size; /**< Size of private data bock. @see node::_vd */
size_t pool_size;

View file

@ -61,7 +61,7 @@ struct comedi_direction {
size_t counter; ///< Number of villas samples transfered
struct comedi_chanspec *chanspecs; ///< Range and maxdata config of channels
unsigned *chanlist; ///< Channel list in comedi's packed format
size_t chanlist_len; ///< Number of channels for this direction
size_t chanvlist_len; ///< Number of channels for this direction
char* buffer;
char* bufptr;

View file

@ -108,7 +108,7 @@ int iec61850_type_stop();
const struct iec61850_type_descriptor * iec61850_lookup_type(const char *name);
int iec61850_parse_signals(json_t *json_signals, struct list *signals, struct list *node_signals);
int iec61850_parse_signals(json_t *json_signals, struct vlist *signals, struct vlist *node_signals);
struct iec61850_receiver * iec61850_receiver_lookup(enum iec61850_receiver_type t, const char *intf);

View file

@ -58,7 +58,7 @@ struct iec61850_sv {
struct queue_signalled queue;
struct pool pool;
struct list signals; /**< Mappings of type struct iec61850_type_descriptor */
struct vlist signals; /**< Mappings of type struct iec61850_type_descriptor */
int total_size;
} in;
@ -76,7 +76,7 @@ struct iec61850_sv {
int smprate;
int confrev;
struct list signals; /**< Mappings of type struct iec61850_type_descriptor */
struct vlist signals; /**< Mappings of type struct iec61850_type_descriptor */
int total_size;
} out;
};

View file

@ -47,7 +47,7 @@ struct influxdb {
char *port;
char *key;
struct list fields;
struct vlist fields;
int sd;
};

View file

@ -46,7 +46,7 @@ struct format_type;
struct nanomsg {
struct {
int socket;
struct list endpoints;
struct vlist endpoints;
} in, out;
struct format_type *format;

View file

@ -65,7 +65,7 @@ struct ngsi {
CURL *curl; /**< libcurl: handle */
struct list mapping; /**< A mapping between indices of the VILLASnode samples and the attributes in ngsi::context */
struct vlist mapping; /**< A mapping between indices of the VILLASnode samples and the attributes in ngsi::context */
};
/** Initialize global NGSI settings and maps shared memory regions.

View file

@ -60,7 +60,7 @@ struct test_rtt {
int current; /**< Index of current test in test_rtt::cases */
int counter;
struct list cases; /**< List of test cases */
struct vlist cases; /**< List of test cases */
char *output; /**< The directory where we place the results. */
char *prefix; /**< An optional prefix in the filename. */

View file

@ -49,7 +49,7 @@ struct lws;
/** Internal data per websocket node */
struct websocket {
struct list destinations; /**< List of websocket servers connect to in client mode (struct websocket_destination). */
struct vlist destinations; /**< List of websocket servers connect to in client mode (struct websocket_destination). */
struct pool pool;
struct queue_signalled queue; /**< For samples which are received from WebSockets */

View file

@ -79,7 +79,7 @@ struct zeromq {
struct {
void *socket; /**< ZeroMQ socket. */
struct list endpoints;
struct vlist endpoints;
char *filter;
} out;
};

View file

@ -55,7 +55,7 @@ struct path_source {
bool masked;
struct pool pool;
struct list mappings; /**< List of mappings (struct mapping_entry). */
struct vlist mappings; /**< List of mappings (struct mapping_entry). */
};
struct path_destination {
@ -85,10 +85,10 @@ struct path {
struct sample *last_sample;
int last_sequence;
struct list sources; /**< List of all incoming nodes (struct path_source). */
struct list destinations; /**< List of all outgoing nodes (struct path_destination). */
struct list hooks; /**< List of processing hooks (struct hook). */
struct list signals; /**< List of signals which this path creates (struct signal). */
struct vlist sources; /**< List of all incoming nodes (struct path_source). */
struct vlist destinations; /**< List of all outgoing nodes (struct path_destination). */
struct vlist hooks; /**< List of processing hooks (struct hook). */
struct vlist signals; /**< List of signals which this path creates (struct signal). */
struct task timeout;
@ -170,7 +170,7 @@ int path_uses_node(struct path *p, struct node *n);
* @retval 0 Success. Everything went well.
* @retval <0 Error. Something went wrong.
*/
int path_parse(struct path *p, json_t *cfg, struct list *nodes);
int path_parse(struct path *p, json_t *cfg, struct vlist *nodes);
/** @} */

View file

@ -48,15 +48,15 @@ extern "C" {
#define REGISTER_PLUGIN(p) \
__attribute__((constructor(110))) static void UNIQUE(__ctor)() {\
if (plugins.state == STATE_DESTROYED) \
list_init(&plugins); \
list_push(&plugins, p); \
vlist_init(&plugins); \
vlist_push(&plugins, p); \
} \
__attribute__((destructor(110))) static void UNIQUE(__dtor)() { \
if (plugins.state != STATE_DESTROYED) \
list_remove(&plugins, p); \
vlist_remove(&plugins, p); \
}
extern struct list plugins;
extern struct vlist plugins;
enum plugin_type {
PLUGIN_TYPE_HOOK,

View file

@ -70,7 +70,7 @@ struct sample {
int capacity; /**< The number of values in sample::values for which memory is reserved. */
int flags; /**< Flags are used to store binary properties of a sample. */
struct list *signals; /**< The list of signal descriptors. */
struct vlist *signals; /**< The list of signal descriptors. */
atomic_int refcnt; /**< Reference counter. */
ptrdiff_t pool_off; /**< This sample belongs to this memory pool (relative pointer). See sample_pool(). */

View file

@ -38,7 +38,7 @@ extern "C" {
#endif
/* Forward declarations */
struct list;
struct vlist;
struct node;
struct mapping_entry;
@ -106,11 +106,11 @@ int signal_parse(struct signal *s, json_t *cfg);
/** Initialize signal from a mapping_entry. */
int signal_init_from_mapping(struct signal *s, const struct mapping_entry *me, unsigned index);
int signal_list_parse(struct list *list, json_t *cfg);
int signal_vlist_parse(struct vlist *list, json_t *cfg);
int signal_list_generate(struct list *list, unsigned len, enum signal_type fmt);
int signal_vlist_generate(struct vlist *list, unsigned len, enum signal_type fmt);
void signal_list_dump(const struct list *list);
void signal_vlist_dump(const struct vlist *list);
enum signal_type signal_type_from_str(const char *str);

View file

@ -21,12 +21,12 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*********************************************************************************/
struct list;
struct vlist;
struct super_node;
struct list * super_node_get_nodes(struct super_node *sn);
struct vlist * super_node_get_nodes(struct super_node *sn);
struct list * super_node_get_nodes(struct super_node *sn);
struct vlist * super_node_get_nodes(struct super_node *sn);
struct lws_context * super_node_get_web_context(struct super_node *sn);

View file

@ -47,9 +47,9 @@ protected:
static Logger logger;
struct list nodes;
struct list paths;
struct list plugins;
struct vlist nodes;
struct vlist paths;
struct vlist plugins;
#ifdef WITH_API
Api api;
@ -96,15 +96,15 @@ public:
struct node * getNode(const std::string &name)
{
return (struct node *) list_lookup(&nodes, name.c_str());
return (struct node *) vlist_lookup(&nodes, name.c_str());
}
struct list * getNodes()
struct vlist * getNodes()
{
return &nodes;
}
struct list * getPaths() {
struct vlist * getPaths() {
return &paths;
}

View file

@ -53,8 +53,8 @@ public:
if (ret)
return ret;
struct list *nodes = session->getSuperNode()->getNodes();
struct node *n = (struct node *) list_lookup(nodes, node_str);
struct vlist *nodes = session->getSuperNode()->getNodes();
struct node *n = (struct node *) vlist_lookup(nodes, node_str);
if (!n)
return -1;

View file

@ -41,10 +41,10 @@ public:
{
json_t *json_nodes = json_array();
struct list *nodes = session->getSuperNode()->getNodes();
struct vlist *nodes = session->getSuperNode()->getNodes();
for (size_t i = 0; i < list_length(nodes); i++) {
struct node *n = (struct node *) list_at(nodes, i);
for (size_t i = 0; i < vlist_length(nodes); i++) {
struct node *n = (struct node *) vlist_at(nodes, i);
json_t *json_node = json_pack("{ s: s, s: s, s: i, s: { s: i }, s: { s: i } }",
"name", node_name_short(n),

View file

@ -40,10 +40,10 @@ public:
{
json_t *json_paths = json_array();
struct list *paths = session->getSuperNode()->getPaths();
struct vlist *paths = session->getSuperNode()->getPaths();
for (size_t i = 0; i < list_length(paths); i++) {
struct path *p = (struct path *) list_at(paths, i);
for (size_t i = 0; i < vlist_length(paths); i++) {
struct path *p = (struct path *) vlist_at(paths, i);
json_t *json_path = json_pack("{ s: i }",
"state", p->state

View file

@ -59,7 +59,7 @@ static size_t csv_sprint_single(struct io *io, char *buf, size_t len, const stru
if (io->flags & SAMPLE_HAS_DATA) {
for (int i = 0; i < smp->length; i++) {
sig = list_at_safe(smp->signals, i);
sig = vlist_at_safe(smp->signals, i);
if (!sig)
break;
@ -113,7 +113,7 @@ static size_t csv_sscan_single(struct io *io, const char *buf, size_t len, struc
if (*end == io->delimiter)
goto out;
struct signal *sig = (struct signal *) list_at_safe(smp->signals, i);
struct signal *sig = (struct signal *) vlist_at_safe(smp->signals, i);
if (!sig)
goto out;
@ -195,7 +195,7 @@ void csv_header(struct io *io, const struct sample *smp)
if (io->flags & SAMPLE_HAS_DATA) {
for (int i = 0; i < smp->length; i++) {
struct signal *sig = (struct signal *) list_at(smp->signals, i);
struct signal *sig = (struct signal *) vlist_at(smp->signals, i);
if (sig->name)
fprintf(f, "%s", sig->name);

View file

@ -208,7 +208,7 @@ static int json_unpack_sample(struct io *io, json_t *json_smp, struct sample *sm
if (i >= smp->capacity)
break;
struct signal *sig = list_at_safe(smp->signals, i);
struct signal *sig = vlist_at_safe(smp->signals, i);
if (!sig)
return -1;

View file

@ -50,7 +50,7 @@ static int json_reserve_pack_sample(struct io *io, json_t **j, struct sample *sm
for (int i = 0; i < smp->length; i++) {
struct signal *sig;
sig = list_at_safe(smp->signals, i);
sig = vlist_at_safe(smp->signals, i);
if (!sig)
return -1;
@ -186,12 +186,12 @@ static int json_reserve_unpack_sample(struct io *io, json_t *json_smp, struct sa
struct signal *sig;
sig = (struct signal *) list_lookup(io->signals, name);
sig = (struct signal *) vlist_lookup(io->signals, name);
if (sig) {
if (!sig->enabled)
continue;
idx = list_index(io->signals, sig);
idx = vlist_index(io->signals, sig);
}
else {
ret = sscanf(name, "signal_%d", &idx);

View file

@ -73,7 +73,7 @@ int msg_verify(struct msg *m)
return 0;
}
int msg_to_sample(struct msg *msg, struct sample *smp, struct list *signals)
int msg_to_sample(struct msg *msg, struct sample *smp, struct vlist *signals)
{
int ret;
@ -87,7 +87,7 @@ int msg_to_sample(struct msg *msg, struct sample *smp, struct list *signals)
smp->ts.origin = MSG_TS(msg);
for (int i = 0; i < smp->length; i++) {
struct signal *sig = list_at(signals, i);
struct signal *sig = vlist_at(signals, i);
switch (sig->type) {
case SIGNAL_TYPE_FLOAT:
@ -106,7 +106,7 @@ int msg_to_sample(struct msg *msg, struct sample *smp, struct list *signals)
return 0;
}
int msg_from_sample(struct msg *msg, struct sample *smp, struct list *signals)
int msg_from_sample(struct msg *msg, struct sample *smp, struct vlist *signals)
{
*msg = MSG_INIT(smp->length, smp->sequence);
@ -114,7 +114,7 @@ int msg_from_sample(struct msg *msg, struct sample *smp, struct list *signals)
msg->ts.nsec = smp->ts.origin.tv_nsec;
for (int i = 0; i < smp->length; i++) {
struct signal *sig = list_at(signals, i);
struct signal *sig = vlist_at(signals, i);
switch (sig->type) {
case SIGNAL_TYPE_FLOAT:

View file

@ -177,7 +177,7 @@ int protobuf_sscan(struct io *io, const char *buf, size_t len, size_t *rbytes, s
enum signal_type fmt = protobuf_detect_format(pb_val);
struct signal *sig = (struct signal *) list_at_safe(smp->signals, j);
struct signal *sig = (struct signal *) vlist_at_safe(smp->signals, j);
if (!sig)
return -1;

View file

@ -58,7 +58,7 @@ static size_t villas_human_sprint_single(struct io *io, char *buf, size_t len, c
if (io->flags & SAMPLE_HAS_DATA) {
for (int i = 0; i < smp->length; i++) {
sig = list_at_safe(smp->signals, i);
sig = vlist_at_safe(smp->signals, i);
if (!sig)
break;
@ -138,7 +138,7 @@ static size_t villas_human_sscan_single(struct io *io, const char *buf, size_t l
if (*end == io->delimiter)
goto out;
struct signal *sig = (struct signal *) list_at_safe(io->signals, i);
struct signal *sig = (struct signal *) vlist_at_safe(io->signals, i);
if (!sig)
goto out;
@ -228,7 +228,7 @@ void villas_human_header(struct io *io, const struct sample *smp)
if (io->flags & SAMPLE_HAS_DATA) {
for (int i = 0; i < smp->length; i++) {
struct signal *sig = (struct signal *) list_at(smp->signals, i);
struct signal *sig = (struct signal *) vlist_at(smp->signals, i);
if (sig->name)
fprintf(f, "%c%s", io->separator, sig->name);

View file

@ -166,12 +166,12 @@ int hook_process(struct hook *h, struct sample *smps[], unsigned *cnt)
return 0;
}
int hook_process_list(struct list *hs, struct sample *smps[], unsigned cnt)
int hook_process_list(struct vlist *hs, struct sample *smps[], unsigned cnt)
{
unsigned ret;
for (size_t i = 0; i < list_length(hs); i++) {
struct hook *h = (struct hook *) list_at(hs, i);
for (size_t i = 0; i < vlist_length(hs); i++) {
struct hook *h = (struct hook *) vlist_at(hs, i);
ret = hook_process(h, smps, &cnt);
if (ret || !cnt)
@ -191,7 +191,7 @@ int hook_cmp_priority(const void *a, const void *b)
return ha->priority - hb->priority;
}
int hook_parse_list(struct list *list, json_t *cfg, int mask, struct path *o, struct node *n)
int hook_parse_list(struct vlist *list, json_t *cfg, int mask, struct path *o, struct node *n)
{
if (!json_is_array(cfg))
error("Hooks must be configured as a list of objects");
@ -225,20 +225,20 @@ int hook_parse_list(struct list *list, json_t *cfg, int mask, struct path *o, st
if (ret)
jerror(&err, "Failed to parse hook configuration");
list_push(list, h);
vlist_push(list, h);
}
return 0;
}
int hook_init_builtin_list(struct list *l, bool builtin, int mask, struct path *p, struct node *n)
int hook_init_builtin_list(struct vlist *l, bool builtin, int mask, struct path *p, struct node *n)
{
int ret;
assert(l->state == STATE_INITIALIZED);
for (size_t i = 0; i < list_length(&plugins); i++) {
struct plugin *q = (struct plugin *) list_at(&plugins, i);
for (size_t i = 0; i < vlist_length(&plugins); i++) {
struct plugin *q = (struct plugin *) vlist_at(&plugins, i);
struct hook *h;
struct hook_type *vt = &q->hook;
@ -259,7 +259,7 @@ int hook_init_builtin_list(struct list *l, bool builtin, int mask, struct path *
if (ret)
return ret;
list_push(l, h);
vlist_push(l, h);
}
}

View file

@ -34,16 +34,16 @@
#include <villas/sample.h>
struct cast {
struct list operations;
struct vlist operations;
struct list signals;
struct vlist signals;
};
static int cast_init(struct hook *h)
{
int ret;
struct cast *c = (struct cast *) h->_vd;
struct list *orig_signals;
struct vlist *orig_signals;
if (h->node)
orig_signals = &h->node->signals;
@ -52,16 +52,16 @@ static int cast_init(struct hook *h)
else
return -1;
ret = list_init(&c->signals);
ret = vlist_init(&c->signals);
if (ret)
return ret;
/* Copy original signal list */
for (int i = 0; i < list_length(orig_signals); i++) {
struct signal *orig_sig = list_at(orig_signals, i);
for (int i = 0; i < vlist_length(orig_signals); i++) {
struct signal *orig_sig = vlist_at(orig_signals, i);
struct signal *new_sig = signal_copy(orig_sig);
list_push(&c->signals, new_sig);
vlist_push(&c->signals, new_sig);
}
return 0;
@ -72,7 +72,7 @@ static int cast_destroy(struct hook *h)
int ret;
struct cast *c = (struct cast *) h->_vd;
ret = list_destroy(&c->signals, (dtor_cb_t) signal_decref, false);
ret = vlist_destroy(&c->signals, (dtor_cb_t) signal_decref, false);
if (ret)
return ret;
@ -124,8 +124,8 @@ static int cast_parse(struct hook *h, json_t *cfg)
return -1;
sig = name
? list_lookup(&c->signals, name)
: list_at_safe(&c->signals, index);
? vlist_lookup(&c->signals, name)
: vlist_at_safe(&c->signals, index);
if (!sig)
return -1;
@ -168,8 +168,8 @@ static int cast_process(struct hook *h, struct sample *smps[], unsigned *cnt)
struct sample *smp = smps[i];
for (int j = 0; j < smp->length; j++) {
struct signal *orig_sig = list_at(smp->signals, j);
struct signal *new_sig = list_at(&c->signals, j);
struct signal *orig_sig = vlist_at(smp->signals, j);
struct signal *new_sig = vlist_at(&c->signals, j);
signal_data_cast(&smp->data[j], orig_sig, new_sig);
}

View file

@ -56,7 +56,7 @@ static int print_start(struct hook *h)
struct print *p = (struct print *) h->_vd;
int ret;
struct list *signals;
struct vlist *signals;
if (h->node)
signals = &h->node->signals;

View file

@ -74,14 +74,14 @@ static int restart_process(struct hook *h, struct sample *smps[], unsigned *cnt)
cur->flags |= SAMPLE_IS_FIRST;
/* Run restart hooks */
for (size_t i = 0; i < list_length(&h->node->in.hooks); i++) {
struct hook *k = (struct hook *) list_at(&h->node->in.hooks, i);
for (size_t i = 0; i < vlist_length(&h->node->in.hooks); i++) {
struct hook *k = (struct hook *) vlist_at(&h->node->in.hooks, i);
hook_restart(k);
}
for (size_t i = 0; i < list_length(&h->node->out.hooks); i++) {
struct hook *k = (struct hook *) list_at(&h->node->out.hooks, i);
for (size_t i = 0; i < vlist_length(&h->node->out.hooks); i++) {
struct hook *k = (struct hook *) vlist_at(&h->node->out.hooks, i);
hook_restart(k);
}

View file

@ -79,7 +79,7 @@ skip: bytes = getdelim(&io->in.buffer, &io->in.buflen, io->delimiter, f);
return i;
}
int io_init(struct io *io, const struct format_type *fmt, struct list *signals, int flags)
int io_init(struct io *io, const struct format_type *fmt, struct vlist *signals, int flags)
{
int ret;
@ -112,17 +112,17 @@ int io_init(struct io *io, const struct format_type *fmt, struct list *signals,
int io_init_auto(struct io *io, const struct format_type *fmt, int len, int flags)
{
int ret;
struct list *signals;
struct vlist *signals;
signals = alloc(sizeof(struct list));
signals = alloc(sizeof(struct vlist));
signals->state = STATE_DESTROYED;
ret = list_init(signals);
ret = vlist_init(signals);
if (ret)
return ret;
ret = signal_list_generate(signals, len, SIGNAL_TYPE_AUTO);
ret = signal_vlist_generate(signals, len, SIGNAL_TYPE_AUTO);
if (ret)
return ret;
@ -146,7 +146,7 @@ int io_destroy(struct io *io)
free(io->out.buffer);
if (io->flags & IO_DESTROY_SIGNALS) {
ret = list_destroy(io->signals, (dtor_cb_t) signal_decref, false);
ret = vlist_destroy(io->signals, (dtor_cb_t) signal_decref, false);
if (ret)
return ret;
}
@ -160,8 +160,8 @@ int io_check(struct io *io)
{
assert(io->state != STATE_DESTROYED);
for (size_t i = 0; i < list_length(io->signals); i++) {
struct signal *sig = (struct signal *) list_at(io->signals, i);
for (size_t i = 0; i < vlist_length(io->signals); i++) {
struct signal *sig = (struct signal *) vlist_at(io->signals, i);
if (sig->type == SIGNAL_TYPE_AUTO) {
if (io_type(io)->flags & IO_AUTO_DETECT_FORMAT)

View file

@ -50,7 +50,7 @@ int if_init(struct interface *i, struct rtnl_link *link)
else
warning("Did not found any interrupts for interface '%s'", rtnl_link_get_name(i->nl_link));
list_init(&i->sockets);
vlist_init(&i->sockets);
return 0;
}
@ -58,7 +58,7 @@ int if_init(struct interface *i, struct rtnl_link *link)
int if_destroy(struct interface *i)
{
/* List members are freed by the nodes they belong to. */
list_destroy(&i->sockets, NULL, false);
vlist_destroy(&i->sockets, NULL, false);
rtnl_qdisc_put(i->tc_qdisc);
@ -69,7 +69,7 @@ int if_destroy(struct interface *i)
int if_start(struct interface *i)
{
info("Starting interface '%s' which is used by %zu sockets", rtnl_link_get_name(i->nl_link), list_length(&i->sockets));
info("Starting interface '%s' which is used by %zu sockets", rtnl_link_get_name(i->nl_link), vlist_length(&i->sockets));
{
/* Set affinity for network interfaces (skip _loopback_ dev) */
@ -77,8 +77,8 @@ int if_start(struct interface *i)
/* Assign fwmark's to socket nodes which have netem options */
int ret, mark = 0;
for (size_t j = 0; j < list_length(&i->sockets); j++) {
struct socket *s = (struct socket *) list_at(&i->sockets, j);
for (size_t j = 0; j < vlist_length(&i->sockets); j++) {
struct socket *s = (struct socket *) vlist_at(&i->sockets, j);
if (s->tc_qdisc)
s->mark = 1 + mark++;
@ -97,8 +97,8 @@ int if_start(struct interface *i)
error("Failed to setup priority queuing discipline: %s", nl_geterror(ret));
/* Create netem qdisks and appropriate filter per netem node */
for (size_t j = 0; j < list_length(&i->sockets); j++) {
struct socket *s = (struct socket *) list_at(&i->sockets, j);
for (size_t j = 0; j < vlist_length(&i->sockets); j++) {
struct socket *s = (struct socket *) vlist_at(&i->sockets, j);
if (s->tc_qdisc) {
ret = tc_mark(i, &s->tc_classifier, TC_HANDLE(1, s->mark), s->mark);

View file

@ -30,7 +30,7 @@
#include <villas/node.h>
#include <villas/signal.h>
int mapping_parse_str(struct mapping_entry *me, const char *str, struct list *nodes)
int mapping_parse_str(struct mapping_entry *me, const char *str, struct vlist *nodes)
{
int id;
char *cpy, *node, *type, *field, *subfield, *end;
@ -46,7 +46,7 @@ int mapping_parse_str(struct mapping_entry *me, const char *str, struct list *no
goto invalid_format;
}
me->node = list_lookup(nodes, node);
me->node = vlist_lookup(nodes, node);
if (!me->node) {
warning("Unknown node %s", node);
goto invalid_format;
@ -154,7 +154,7 @@ int mapping_parse_str(struct mapping_entry *me, const char *str, struct list *no
first_str = strtok(NULL, "-]");
if (first_str) {
if (me->node)
first = list_lookup_index(&me->node->signals, first_str);
first = vlist_lookup_index(&me->node->signals, first_str);
if (first < 0) {
char *endptr;
@ -168,14 +168,14 @@ int mapping_parse_str(struct mapping_entry *me, const char *str, struct list *no
else {
/* Map all signals */
me->data.offset = 0;
me->length = me->node ? list_length(&me->node->signals) : 0;
me->length = me->node ? vlist_length(&me->node->signals) : 0;
goto end;
}
last_str = strtok(NULL, "]");
if (last_str) {
if (me->node)
last = list_lookup_index(&me->node->signals, last_str);
last = vlist_lookup_index(&me->node->signals, last_str);
if (last < 0) {
char *endptr;
@ -214,7 +214,7 @@ invalid_format:
return -1;
}
int mapping_parse(struct mapping_entry *me, json_t *cfg, struct list *nodes)
int mapping_parse(struct mapping_entry *me, json_t *cfg, struct vlist *nodes)
{
const char *str;
@ -225,7 +225,7 @@ int mapping_parse(struct mapping_entry *me, json_t *cfg, struct list *nodes)
return mapping_parse_str(me, str, nodes);
}
int mapping_parse_list(struct list *l, json_t *cfg, struct list *nodes)
int mapping_parse_list(struct vlist *l, json_t *cfg, struct vlist *nodes)
{
int ret, off;
@ -253,7 +253,7 @@ int mapping_parse_list(struct list *l, json_t *cfg, struct list *nodes)
me->offset = off;
off += me->length;
list_push(l, me);
vlist_push(l, me);
}
ret = 0;
@ -354,12 +354,12 @@ int mapping_update(const struct mapping_entry *me, struct sample *remapped, cons
return 0;
}
int mapping_remap(const struct list *m, struct sample *remapped, const struct sample *original, const struct stats *s)
int mapping_remap(const struct vlist *m, struct sample *remapped, const struct sample *original, const struct stats *s)
{
int ret;
for (size_t i = 0; i < list_length(m); i++) {
struct mapping_entry *me = (struct mapping_entry *) list_at(m, i);
for (size_t i = 0; i < vlist_length(m); i++) {
struct mapping_entry *me = (struct mapping_entry *) vlist_at(m, i);
ret = mapping_update(me, remapped, original, s);
if (ret)
@ -451,8 +451,8 @@ int mapping_to_str(const struct mapping_entry *me, unsigned index, char **str)
break;
case MAPPING_TYPE_DATA:
if (me->node && index < list_length(&me->node->signals)) {
struct signal *s = list_at(&me->node->signals, index);
if (me->node && index < vlist_length(&me->node->signals)) {
struct signal *s = vlist_at(&me->node->signals, index);
strcatf(str, "data[%s]", s->name);
}

View file

@ -47,7 +47,7 @@ static int node_direction_init2(struct node_direction *nd, struct node *n)
return ret;
/* We sort the hooks according to their priority before starting the path */
list_sort(&nd->hooks, hook_cmp_priority);
vlist_sort(&nd->hooks, hook_cmp_priority);
#endif /* WITH_HOOKS */
return 0;
@ -62,7 +62,7 @@ static int node_direction_init(struct node_direction *nd, struct node *n)
nd->builtin = 1;
nd->hooks.state = STATE_DESTROYED;
ret = list_init(&nd->hooks);
ret = vlist_init(&nd->hooks);
if (ret)
return ret;
@ -74,7 +74,7 @@ static int node_direction_destroy(struct node_direction *nd, struct node *n)
int ret = 0;
#ifdef WITH_HOOKS
ret = list_destroy(&nd->hooks, (dtor_cb_t) hook_destroy, true);
ret = vlist_destroy(&nd->hooks, (dtor_cb_t) hook_destroy, true);
if (ret)
return ret;
#endif
@ -133,8 +133,8 @@ static int node_direction_start(struct node_direction *nd, struct node *n)
#ifdef WITH_HOOKS
int ret;
for (size_t i = 0; i < list_length(&nd->hooks); i++) {
struct hook *h = (struct hook *) list_at(&nd->hooks, i);
for (size_t i = 0; i < vlist_length(&nd->hooks); i++) {
struct hook *h = (struct hook *) vlist_at(&nd->hooks, i);
ret = hook_start(h);
if (ret)
@ -150,8 +150,8 @@ static int node_direction_stop(struct node_direction *nd, struct node *n)
#ifdef WITH_HOOKS
int ret;
for (size_t i = 0; i < list_length(&nd->hooks); i++) {
struct hook *h = (struct hook *) list_at(&nd->hooks, i);
for (size_t i = 0; i < vlist_length(&nd->hooks); i++) {
struct hook *h = (struct hook *) vlist_at(&nd->hooks, i);
ret = hook_stop(h);
if (ret)
@ -176,7 +176,7 @@ int node_init(struct node *n, struct node_type *vt)
n->_name_long = NULL;
n->signals.state = STATE_DESTROYED;
list_init(&n->signals);
vlist_init(&n->signals);
/* Default values */
ret = node_direction_init(&n->in, n);
@ -189,7 +189,7 @@ int node_init(struct node *n, struct node_type *vt)
n->state = STATE_INITIALIZED;
list_push(&vt->instances, n);
vlist_push(&vt->instances, n);
return 0;
}
@ -240,7 +240,7 @@ int node_parse(struct node *n, json_t *json, const char *name)
}
else if (json_signals) {
if (json_is_array(json_signals)) {
ret = signal_list_parse(&n->signals, json_signals);
ret = signal_vlist_parse(&n->signals, json_signals);
if (ret)
error("Failed to parse signal definition of node %s", node_name(n));
}
@ -257,13 +257,13 @@ int node_parse(struct node *n, json_t *json, const char *name)
if (type < 0)
error("Invalid signal type %s", type_str);
signal_list_generate(&n->signals, count, type);
signal_vlist_generate(&n->signals, count, type);
}
}
else {
warning("No signal definition found for node %s. Using the default config of %d floating point signals.", node_name(n), DEFAULT_SAMPLE_LENGTH);
signal_list_generate(&n->signals, DEFAULT_SAMPLE_LENGTH, SIGNAL_TYPE_FLOAT);
signal_vlist_generate(&n->signals, DEFAULT_SAMPLE_LENGTH, SIGNAL_TYPE_FLOAT);
}
struct {
@ -446,7 +446,7 @@ int node_destroy(struct node *n)
int ret;
assert(n->state != STATE_DESTROYED && n->state != STATE_STARTED);
ret = list_destroy(&n->signals, (dtor_cb_t) signal_decref, false);
ret = vlist_destroy(&n->signals, (dtor_cb_t) signal_decref, false);
if (ret)
return ret;
@ -464,7 +464,7 @@ int node_destroy(struct node *n)
return ret;
}
list_remove(&node_type(n)->instances, n);
vlist_remove(&node_type(n)->instances, n);
if (n->_vd)
free(n->_vd);
@ -580,9 +580,9 @@ char * node_name_long(struct node *n)
char *name_long = vt->print(n);
strcatf(&n->_name_long, "%s: #in.signals=%zu, #in.hooks=%zu, in.vectorize=%d, #out.hooks=%zu, out.vectorize=%d, %s",
node_name(n),
list_length(&n->signals),
list_length(&n->in.hooks), n->in.vectorize,
list_length(&n->out.hooks), n->out.vectorize,
vlist_length(&n->signals),
vlist_length(&n->in.hooks), n->in.vectorize,
vlist_length(&n->out.hooks), n->out.vectorize,
name_long
);
@ -622,7 +622,7 @@ struct memory_type * node_memory_type(struct node *n, struct memory_type *parent
return node_type(n)->memory_type ? node_type(n)->memory_type(n, parent) : &memory_hugepage;
}
int node_parse_list(struct list *list, json_t *cfg, struct list *all)
int node_parse_list(struct vlist *list, json_t *cfg, struct vlist *all)
{
struct node *node;
const char *str;
@ -634,11 +634,11 @@ int node_parse_list(struct list *list, json_t *cfg, struct list *all)
switch (json_typeof(cfg)) {
case JSON_STRING:
str = json_string_value(cfg);
node = list_lookup(all, str);
node = vlist_lookup(all, str);
if (!node)
goto invalid2;
list_push(list, node);
vlist_push(list, node);
break;
case JSON_ARRAY:
@ -646,11 +646,11 @@ int node_parse_list(struct list *list, json_t *cfg, struct list *all)
if (!json_is_string(elm))
goto invalid;
node = list_lookup(all, json_string_value(elm));
node = vlist_lookup(all, json_string_value(elm));
if (!node)
goto invalid;
list_push(list, node);
vlist_push(list, node);
}
break;
@ -666,8 +666,8 @@ invalid:
return -1;
invalid2:
for (size_t i = 0; i < list_length(all); i++) {
struct node *n = (struct node *) list_at(all, i);
for (size_t i = 0; i < vlist_length(all); i++) {
struct node *n = (struct node *) vlist_at(all, i);
strcatf(&allstr, " %s", node_name_short(n));
}

View file

@ -35,7 +35,7 @@ int node_type_start(struct node_type *vt, struct super_node *sn)
if (vt->state != STATE_DESTROYED)
return 0;
info("Initializing " CLR_YEL("%s") " node type which is used by %zu nodes", node_type_name(vt), list_length(&vt->instances));
info("Initializing " CLR_YEL("%s") " node type which is used by %zu nodes", node_type_name(vt), vlist_length(&vt->instances));
ret = vt->type.start ? vt->type.start(sn) : 0;
if (ret == 0)

View file

@ -64,16 +64,16 @@ static int comedi_parse_direction(struct comedi *c, struct comedi_direction *d,
size_t i;
json_t *json_chan;
d->chanlist_len = json_array_size(json_chans);
if (d->chanlist_len == 0) {
d->chanvlist_len = json_array_size(json_chans);
if (d->chanvlist_len == 0) {
error("No channels configured");
return 0;
}
d->chanlist = alloc(d->chanlist_len * sizeof(*d->chanlist));
d->chanlist = alloc(d->chanvlist_len * sizeof(*d->chanlist));
assert(d->chanlist != NULL);
d->chanspecs = alloc(d->chanlist_len * sizeof(*d->chanspecs));
d->chanspecs = alloc(d->chanvlist_len * sizeof(*d->chanspecs));
assert(d->chanspecs != NULL);
json_array_foreach(json_chans, i, json_chan) {
@ -109,7 +109,7 @@ static int comedi_start_common(struct node *n)
continue;
/* Sanity-check channel config and populate chanspec for later */
for (int i = 0; i < d->chanlist_len; i++) {
for (int i = 0; i < d->chanvlist_len; i++) {
const unsigned int channel = CR_CHAN(d->chanlist[i]);
const int range = CR_RANGE(d->chanlist[i]);
@ -207,13 +207,13 @@ static int comedi_start_in(struct node *n)
/* Terminate scan after each channel has been converted */
cmd.scan_end_src = TRIG_COUNT;
cmd.scan_end_arg = d->chanlist_len;
cmd.scan_end_arg = d->chanvlist_len;
/* Contionous sampling */
cmd.stop_src = TRIG_NONE;
cmd.chanlist = d->chanlist;
cmd.chanlist_len = d->chanlist_len;
cmd.chanvlist_len = d->chanvlist_len;
/* First run might change command, second should return successfully */
ret = comedi_command_test(c->dev, &cmd);
@ -292,14 +292,14 @@ static int comedi_start_out(struct node *n)
cmd.convert_arg = 0;
cmd.scan_end_src = TRIG_COUNT;
cmd.scan_end_arg = d->chanlist_len;
cmd.scan_end_arg = d->chanvlist_len;
/* Continous sampling */
cmd.stop_src = TRIG_NONE;
cmd.stop_arg = 0;
cmd.chanlist = d->chanlist;
cmd.chanlist_len = d->chanlist_len;
cmd.chanvlist_len = d->chanvlist_len;
/* First run might change command, second should return successfully */
ret = comedi_command_test(c->dev, &cmd);
@ -323,13 +323,13 @@ static int comedi_start_out(struct node *n)
/* Allocate buffer for one complete villas sample */
/** @todo: maybe increase buffer size according to c->vectorize */
const size_t local_buffer_size = d->sample_size * d->chanlist_len;
const size_t local_buffer_size = d->sample_size * d->chanvlist_len;
d->buffer = alloc(local_buffer_size);
d->bufptr = d->buffer;
assert(d->buffer != NULL);
/* Initialize local buffer used for write() syscalls */
for (int channel = 0; channel < d->chanlist_len; channel++) {
for (int channel = 0; channel < d->chanvlist_len; channel++) {
const unsigned raw = comedi_from_phys(0.0f, d->chanspecs[channel].range, d->chanspecs[channel].maxdata);
if (d->sample_size == sizeof(sampl_t))
@ -348,7 +348,7 @@ static int comedi_start_out(struct node *n)
}
}
const size_t villas_samples_in_kernel_buf = d->buffer_size / (d->sample_size * d->chanlist_len);
const size_t villas_samples_in_kernel_buf = d->buffer_size / (d->sample_size * d->chanvlist_len);
const double latencyMs = (double)villas_samples_in_kernel_buf / d->sample_rate_hz * 1e3;
info("Added latency due to buffering: %4.1f ms\n", latencyMs);
@ -515,7 +515,7 @@ int comedi_read(struct node *n, struct sample *smps[], unsigned cnt, unsigned *r
int ret;
struct comedi *c = (struct comedi *) n->_vd;
struct comedi_direction *d = &c->in;
const size_t villas_sample_size = d->chanlist_len * d->sample_size;
const size_t villas_sample_size = d->chanvlist_len * d->sample_size;
ret = comedi_get_buffer_contents(c->dev, d->subdevice);
if (ret < 0) {
@ -557,7 +557,7 @@ int comedi_read(struct node *n, struct sample *smps[], unsigned cnt, unsigned *r
/* Sample handling here */
const size_t bytes_available = ret;
const size_t raw_samples_available = bytes_available / d->sample_size;
const size_t villas_samples_available = raw_samples_available / d->chanlist_len;
const size_t villas_samples_available = raw_samples_available / d->chanvlist_len;
info("there are %ld bytes available (%ld requested) => %ld villas samples",
bytes_available, bytes_requested, villas_samples_available);
@ -572,19 +572,19 @@ int comedi_read(struct node *n, struct sample *smps[], unsigned cnt, unsigned *r
d->counter++;
smps[i]->flags = SAMPLE_HAS_TS_ORIGIN | SAMPLE_HAS_DATA | SAMPLE_HAS_SEQUENCE;
smps[i]->sequence = d->counter / d->chanlist_len;
smps[i]->sequence = d->counter / d->chanvlist_len;
struct timespec offset = time_from_double(d->counter * 1.0 / d->sample_rate_hz);
smps[i]->ts.origin = time_add(&d->started, &offset);
smps[i]->length = d->chanlist_len;
smps[i]->length = d->chanvlist_len;
if (smps[i]->capacity < d->chanlist_len) {
if (smps[i]->capacity < d->chanvlist_len) {
error("Sample has insufficient capacity: %d < %ld",
smps[i]->capacity, d->chanlist_len);
smps[i]->capacity, d->chanvlist_len);
}
for (int si = 0; si < d->chanlist_len; si++) {
for (int si = 0; si < d->chanvlist_len; si++) {
unsigned int raw;
if (d->sample_size == sizeof(sampl_t))
@ -633,7 +633,7 @@ int comedi_read(struct node *n, struct sample *smps[], unsigned cnt, unsigned *r
struct comedi *c = (struct comedi *) n->_vd;
struct comedi_direction *d = &c->in;
const size_t villas_sample_size = d->chanlist_len * d->sample_size;
const size_t villas_sample_size = d->chanvlist_len * d->sample_size;
comedi_set_read_subdevice(c->dev, d->subdevice);
@ -662,11 +662,11 @@ int comedi_read(struct node *n, struct sample *smps[], unsigned cnt, unsigned *r
const size_t bytes_available = ret;
const size_t raw_sample_count = bytes_available / d->sample_size;
size_t villas_sample_count = raw_sample_count / d->chanlist_len;
size_t villas_sample_count = raw_sample_count / d->chanvlist_len;
if (villas_sample_count == 0)
return 0;
info("there are %ld villas samples (%ld raw bytes, %ld channels)", villas_sample_count, bytes_available, d->chanlist_len);
info("there are %ld villas samples (%ld raw bytes, %ld channels)", villas_sample_count, bytes_available, d->chanvlist_len);
#if 0
if (villas_sample_count == 1)
@ -717,18 +717,18 @@ int comedi_read(struct node *n, struct sample *smps[], unsigned cnt, unsigned *r
d->counter++;
smps[i]->flags = SAMPLE_HAS_TS_ORIGIN | SAMPLE_HAS_DATA | SAMPLE_HAS_SEQUENCE;
smps[i]->sequence = d->counter / d->chanlist_len;
smps[i]->sequence = d->counter / d->chanvlist_len;
struct timespec offset = time_from_double(d->counter * 1.0 / d->sample_rate_hz);
smps[i]->ts.origin = time_add(&d->started, &offset);
smps[i]->length = d->chanlist_len;
smps[i]->length = d->chanvlist_len;
if (smps[i]->capacity < d->chanlist_len)
if (smps[i]->capacity < d->chanvlist_len)
error("Sample has insufficient capacity: %d < %ld",
smps[i]->capacity, d->chanlist_len);
smps[i]->capacity, d->chanvlist_len);
for (int si = 0; si < d->chanlist_len; si++) {
for (int si = 0; si < d->chanvlist_len; si++) {
unsigned int raw;
if (d->sample_size == sizeof(sampl_t))
@ -833,8 +833,8 @@ int comedi_write(struct node *n, struct sample *smps[], unsigned cnt, unsigned *
}
const size_t buffer_capacity_raw = d->buffer_size / d->sample_size;
const size_t buffer_capacity_villas = buffer_capacity_raw / d->chanlist_len;
const size_t villas_sample_size = d->sample_size * d->chanlist_len;
const size_t buffer_capacity_villas = buffer_capacity_raw / d->chanvlist_len;
const size_t villas_sample_size = d->sample_size * d->chanvlist_len;
ret = comedi_get_buffer_contents(c->dev, d->subdevice);
if (ret < 0) {
@ -846,7 +846,7 @@ int comedi_write(struct node *n, struct sample *smps[], unsigned cnt, unsigned *
const size_t bytes_in_buffer = ret;
const size_t raw_samples_in_buffer = bytes_in_buffer / d->sample_size;
const size_t villas_samples_in_buffer = raw_samples_in_buffer / d->chanlist_len;
const size_t villas_samples_in_buffer = raw_samples_in_buffer / d->chanvlist_len;
if (villas_samples_in_buffer == buffer_capacity_villas) {
warning("Comedi buffer is full");
@ -867,9 +867,9 @@ int comedi_write(struct node *n, struct sample *smps[], unsigned cnt, unsigned *
while (villas_samples_written < cnt) {
struct sample *sample = smps[villas_samples_written];
if (sample->length != d->chanlist_len)
if (sample->length != d->chanvlist_len)
error("Value count in sample (%d) != configured output channels (%ld)",
sample->length, d->chanlist_len);
sample->length, d->chanvlist_len);
d->bufptr = d->buffer;

View file

@ -60,7 +60,7 @@ const struct iec61850_type_descriptor type_descriptors[] = {
};
/** Each network interface needs a separate receiver */
static struct list receivers;
static struct vlist receivers;
static pthread_t thread;
static EthernetHandleSet hset;
static int users = 0;
@ -76,8 +76,8 @@ static void * iec61850_thread(void *ctx)
if (ret < 0)
continue;
for (unsigned i = 0; i < list_length(&receivers); i++) {
struct iec61850_receiver *r = (struct iec61850_receiver *) list_at(&receivers, i);
for (unsigned i = 0; i < vlist_length(&receivers); i++) {
struct iec61850_receiver *r = (struct iec61850_receiver *) vlist_at(&receivers, i);
switch (r->type) {
case IEC61850_RECEIVER_GOOSE: GooseReceiver_tick(r->goose); break;
@ -99,12 +99,12 @@ const struct iec61850_type_descriptor * iec61850_lookup_type(const char *name)
return NULL;
}
int iec61850_parse_signals(json_t *json_signals, struct list *signals, struct list *node_signals)
int iec61850_parse_signals(json_t *json_signals, struct vlist *signals, struct vlist *node_signals)
{
int ret, total_size = 0;
const char *iec_type;
ret = list_init(signals);
ret = vlist_init(signals);
if (ret)
return ret;
@ -123,7 +123,7 @@ int iec61850_parse_signals(json_t *json_signals, struct list *signals, struct li
if (!node_signals)
return -1;
sig = list_at(node_signals, i);
sig = vlist_at(node_signals, i);
if (!sig)
return -1;
@ -149,7 +149,7 @@ int iec61850_parse_signals(json_t *json_signals, struct list *signals, struct li
if (!td)
return -1;
list_push(signals, (void *) td);
vlist_push(signals, (void *) td);
total_size += td->size;
}
@ -181,8 +181,8 @@ int iec61850_type_stop()
if (--users > 0)
return 0;
for (unsigned i = 0; i < list_length(&receivers); i++) {
struct iec61850_receiver *r = (struct iec61850_receiver *) list_at(&receivers, i);
for (unsigned i = 0; i < vlist_length(&receivers); i++) {
struct iec61850_receiver *r = (struct iec61850_receiver *) vlist_at(&receivers, i);
iec61850_receiver_stop(r);
}
@ -197,7 +197,7 @@ int iec61850_type_stop()
EthernetHandleSet_destroy(hset);
list_destroy(&receivers, (dtor_cb_t) iec61850_receiver_destroy, true);
vlist_destroy(&receivers, (dtor_cb_t) iec61850_receiver_destroy, true);
return 0;
}
@ -255,8 +255,8 @@ int iec61850_receiver_destroy(struct iec61850_receiver *r)
struct iec61850_receiver * iec61850_receiver_lookup(enum iec61850_receiver_type t, const char *intf)
{
for (unsigned i = 0; i < list_length(&receivers); i++) {
struct iec61850_receiver *r = (struct iec61850_receiver *) list_at(&receivers, i);
for (unsigned i = 0; i < vlist_length(&receivers); i++) {
struct iec61850_receiver *r = (struct iec61850_receiver *) vlist_at(&receivers, i);
if (r->type == t && strcmp(r->interface, intf) == 0)
return r;
@ -293,7 +293,7 @@ struct iec61850_receiver * iec61850_receiver_create(enum iec61850_receiver_type
iec61850_receiver_start(r);
list_push(&receivers, r);
vlist_push(&receivers, r);
}
return r;

View file

@ -85,9 +85,9 @@ static void iec61850_sv_listener(SVSubscriber subscriber, void *ctx, SVSubscribe
}
unsigned offset = 0;
for (size_t j = 0; j < list_length(&i->in.signals); j++) {
struct iec61850_type_descriptor *td = (struct iec61850_type_descriptor *) list_at(&i->in.signals, j);
struct signal *sig = (struct signal *) list_at_safe(smp->signals, j);
for (size_t j = 0; j < vlist_length(&i->in.signals); j++) {
struct iec61850_type_descriptor *td = (struct iec61850_type_descriptor *) vlist_at(&i->in.signals, j);
struct signal *sig = (struct signal *) vlist_at_safe(smp->signals, j);
if (!sig)
continue;
@ -231,13 +231,13 @@ char * iec61850_sv_print(struct node *n)
i->out.vlan_priority,
i->out.vlan_id,
i->out.confrev,
list_length(&i->out.signals)
vlist_length(&i->out.signals)
);
}
/* Subscriber part */
if (i->in.enabled)
strcatf(&buf, ", sub.#fields=%zu", list_length(&i->in.signals));
strcatf(&buf, ", sub.#fields=%zu", vlist_length(&i->in.signals));
return buf;
}
@ -252,8 +252,8 @@ int iec61850_sv_start(struct node *n)
i->out.publisher = SVPublisher_create(NULL, i->interface);
i->out.asdu = SVPublisher_addASDU(i->out.publisher, i->out.svid, node_name_short(n), i->out.confrev);
for (unsigned k = 0; k < list_length(&i->out.signals); k++) {
struct iec61850_type_descriptor *m = (struct iec61850_type_descriptor *) list_at(&i->out.signals, k);
for (unsigned k = 0; k < vlist_length(&i->out.signals); k++) {
struct iec61850_type_descriptor *m = (struct iec61850_type_descriptor *) vlist_at(&i->out.signals, k);
switch (m->type) {
case IEC61850_TYPE_INT8: SVPublisher_ASDU_addINT8(i->out.asdu); break;
@ -288,7 +288,7 @@ int iec61850_sv_start(struct node *n)
SVReceiver_addSubscriber(i->in.receiver, i->in.subscriber);
/* Initialize pool and queue to pass samples between threads */
ret = pool_init(&i->in.pool, 1024, SAMPLE_LENGTH(list_length(&n->signals)), &memory_hugepage);
ret = pool_init(&i->in.pool, 1024, SAMPLE_LENGTH(vlist_length(&n->signals)), &memory_hugepage);
if (ret)
return ret;
@ -296,9 +296,9 @@ int iec61850_sv_start(struct node *n)
if (ret)
return ret;
for (unsigned k = 0; k < list_length(&i->in.signals); k++) {
struct iec61850_type_descriptor *m = (struct iec61850_type_descriptor *) list_at(&i->in.signals, k);
struct signal *sig = (struct signal *) list_at(&n->signals, k);
for (unsigned k = 0; k < vlist_length(&i->in.signals); k++) {
struct iec61850_type_descriptor *m = (struct iec61850_type_descriptor *) vlist_at(&i->in.signals, k);
struct signal *sig = (struct signal *) vlist_at(&n->signals, k);
if (sig->type == SIGNAL_TYPE_AUTO)
sig->type = m->format;
@ -369,8 +369,8 @@ int iec61850_sv_write(struct node *n, struct sample *smps[], unsigned cnt, unsig
for (unsigned j = 0; j < cnt; j++) {
unsigned offset = 0;
for (unsigned k = 0; k < MIN(smps[j]->length, list_length(&i->out.signals)); k++) {
struct iec61850_type_descriptor *m = (struct iec61850_type_descriptor *) list_at(&i->out.signals, k);
for (unsigned k = 0; k < MIN(smps[j]->length, vlist_length(&i->out.signals)); k++) {
struct iec61850_type_descriptor *m = (struct iec61850_type_descriptor *) vlist_at(&i->out.signals, k);
int ival = 0;
double fval = 0;

View file

@ -132,7 +132,7 @@ int influxdb_write(struct node *n, struct sample *smps[], unsigned cnt, unsigned
/* Fields */
for (int j = 0; j < smp->length; j++) {
struct signal *sig = (struct signal *) list_at(smp->signals, j);
struct signal *sig = (struct signal *) vlist_at(smp->signals, j);
union signal_data *data = &smp->data[k];
if (sig->type == SIGNAL_TYPE_AUTO || sig->type == SIGNAL_TYPE_COMPLEX) {
@ -142,7 +142,7 @@ int influxdb_write(struct node *n, struct sample *smps[], unsigned cnt, unsigned
strcatf(&buf, "%c", j == 0 ? ' ' : ',');
sig = (struct signal *) list_at(smp->signals, j);
sig = (struct signal *) vlist_at(smp->signals, j);
if (!sig)
return -1;

View file

@ -74,7 +74,7 @@ int loopback_start(struct node *n)
int ret;
struct loopback *l = (struct loopback *) n->_vd;
ret = pool_init(&l->pool, l->queuelen, SAMPLE_LENGTH(list_length(&n->signals)), &memory_hugepage);
ret = pool_init(&l->pool, l->queuelen, SAMPLE_LENGTH(vlist_length(&n->signals)), &memory_hugepage);
if (ret)
return ret;

View file

@ -307,7 +307,7 @@ int mqtt_start(struct node *n)
if (ret)
return ret;
ret = pool_init(&m->pool, 1024, SAMPLE_LENGTH(list_length(&n->signals)), &memory_hugepage);
ret = pool_init(&m->pool, 1024, SAMPLE_LENGTH(vlist_length(&n->signals)), &memory_hugepage);
if (ret)
return ret;

View file

@ -33,20 +33,20 @@ int nanomsg_reverse(struct node *n)
{
struct nanomsg *m = (struct nanomsg *) n->_vd;
if (list_length(&m->out.endpoints) != 1 ||
list_length(&m->in.endpoints) != 1)
if (vlist_length(&m->out.endpoints) != 1 ||
vlist_length(&m->in.endpoints) != 1)
return -1;
char *subscriber = list_first(&m->in.endpoints);
char *publisher = list_first(&m->out.endpoints);
char *subscriber = vlist_first(&m->in.endpoints);
char *publisher = vlist_first(&m->out.endpoints);
list_set(&m->in.endpoints, 0, publisher);
list_set(&m->out.endpoints, 0, subscriber);
vlist_set(&m->in.endpoints, 0, publisher);
vlist_set(&m->out.endpoints, 0, subscriber);
return 0;
}
static int nanomsg_parse_endpoints(struct list *l, json_t *cfg)
static int nanomsg_parse_endpoints(struct vlist *l, json_t *cfg)
{
const char *ep;
@ -60,14 +60,14 @@ static int nanomsg_parse_endpoints(struct list *l, json_t *cfg)
if (!ep)
return -1;
list_push(l, strdup(ep));
vlist_push(l, strdup(ep));
}
break;
case JSON_STRING:
ep = json_string_value(cfg);
list_push(l, strdup(ep));
vlist_push(l, strdup(ep));
break;
default:
@ -89,8 +89,8 @@ int nanomsg_parse(struct node *n, json_t *cfg)
json_t *json_out_endpoints = NULL;
json_t *json_in_endpoints = NULL;
list_init(&m->out.endpoints);
list_init(&m->in.endpoints);
vlist_init(&m->out.endpoints);
vlist_init(&m->in.endpoints);
ret = json_unpack_ex(cfg, &err, 0, "{ s?: s, s?: { s?: o }, s?: { s?: o } }",
"format", &format,
@ -129,16 +129,16 @@ char * nanomsg_print(struct node *n)
strcatf(&buf, "format=%s, in.endpoints=[ ", format_type_name(m->format));
for (size_t i = 0; i < list_length(&m->in.endpoints); i++) {
char *ep = (char *) list_at(&m->in.endpoints, i);
for (size_t i = 0; i < vlist_length(&m->in.endpoints); i++) {
char *ep = (char *) vlist_at(&m->in.endpoints, i);
strcatf(&buf, "%s ", ep);
}
strcatf(&buf, "], out.endpoints=[ ");
for (size_t i = 0; i < list_length(&m->out.endpoints); i++) {
char *ep = (char *) list_at(&m->out.endpoints, i);
for (size_t i = 0; i < vlist_length(&m->out.endpoints); i++) {
char *ep = (char *) vlist_at(&m->out.endpoints, i);
strcatf(&buf, "%s ", ep);
}
@ -179,8 +179,8 @@ int nanomsg_start(struct node *n)
return ret;
/* Bind publisher to socket */
for (size_t i = 0; i < list_length(&m->out.endpoints); i++) {
char *ep = (char *) list_at(&m->out.endpoints, i);
for (size_t i = 0; i < vlist_length(&m->out.endpoints); i++) {
char *ep = (char *) vlist_at(&m->out.endpoints, i);
ret = nn_bind(m->out.socket, ep);
if (ret < 0) {
@ -190,8 +190,8 @@ int nanomsg_start(struct node *n)
}
/* Connect subscribers socket */
for (size_t i = 0; i < list_length(&m->in.endpoints); i++) {
char *ep = (char *) list_at(&m->in.endpoints, i);
for (size_t i = 0; i < vlist_length(&m->in.endpoints); i++) {
char *ep = (char *) vlist_at(&m->in.endpoints, i);
ret = nn_connect(m->in.socket, ep);
if (ret < 0) {

View file

@ -54,7 +54,7 @@ struct ngsi_attribute {
char *type;
int index;
struct list metadata;
struct vlist metadata;
};
struct ngsi_response {
@ -73,8 +73,8 @@ static json_t* ngsi_build_entity(struct ngsi *i, struct sample *smps[], unsigned
if (flags & NGSI_ENTITY_ATTRIBUTES) {
json_t *attributes = json_array();
for (size_t j = 0; j < list_length(&i->mapping); j++) {
struct ngsi_attribute *map = (struct ngsi_attribute *) list_at(&i->mapping, j);
for (size_t j = 0; j < vlist_length(&i->mapping); j++) {
struct ngsi_attribute *map = (struct ngsi_attribute *) vlist_at(&i->mapping, j);
json_t *attribute = json_pack("{ s: s, s: s }",
"name", map->name,
@ -97,8 +97,8 @@ static json_t* ngsi_build_entity(struct ngsi *i, struct sample *smps[], unsigned
if (flags & NGSI_ENTITY_METADATA) { /* Create Metadata for attribute */
json_t *metadatas = json_array();
for (size_t i = 0; i < list_length(&map->metadata); i++) {
struct ngsi_metadata *meta = (struct ngsi_metadata *) list_at(&map->metadata, i);
for (size_t i = 0; i < vlist_length(&map->metadata); i++) {
struct ngsi_metadata *meta = (struct ngsi_metadata *) vlist_at(&map->metadata, i);
json_array_append_new(metadatas, json_pack("{ s: s, s: s, s: s }",
"name", meta->name,
@ -156,7 +156,7 @@ static int ngsi_parse_entity(json_t *entity, struct ngsi *i, struct sample *smps
return -3;
/* Check attribute name and type */
map = list_lookup(&i->mapping, name);
map = vlist_lookup(&i->mapping, name);
if (!map || strcmp(map->type, type))
return -4;
@ -196,12 +196,12 @@ static int ngsi_parse_entity(json_t *entity, struct ngsi *i, struct sample *smps
return cnt;
}
static int ngsi_parse_mapping(struct list *mapping, json_t *cfg)
static int ngsi_parse_mapping(struct vlist *mapping, json_t *cfg)
{
if (!json_is_array(cfg))
return -1;
list_init(mapping);
vlist_init(mapping);
size_t j;
json_t *json_token;
@ -225,11 +225,11 @@ static int ngsi_parse_mapping(struct list *mapping, json_t *cfg)
token += bytes;
/* MetadataName(MetadataType)=MetadataValue */
list_init(&a->metadata);
vlist_init(&a->metadata);
struct ngsi_metadata m;
while (sscanf(token, " %m[^(](%m[^)])=%ms%n", &m.name, &m.type, &m.value, &bytes) == 3) {
list_push(&a->metadata, memdup(&m, sizeof(m)));
vlist_push(&a->metadata, memdup(&m, sizeof(m)));
token += bytes;
}
@ -247,10 +247,10 @@ static int ngsi_parse_mapping(struct list *mapping, json_t *cfg)
};
assert(asprintf(&i.value, "%zu", j));
list_push(&a->metadata, memdup(&s, sizeof(s)));
list_push(&a->metadata, memdup(&i, sizeof(i)));
vlist_push(&a->metadata, memdup(&s, sizeof(s)));
vlist_push(&a->metadata, memdup(&i, sizeof(i)));
list_push(mapping, a);
vlist_push(mapping, a);
}
return 0;
@ -442,7 +442,7 @@ char * ngsi_print(struct node *n)
struct ngsi *i = (struct ngsi *) n->_vd;
return strf("endpoint=%s, timeout=%.3f secs, #mappings=%zu",
i->endpoint, i->timeout, list_length(&i->mapping));
i->endpoint, i->timeout, vlist_length(&i->mapping));
}
static int ngsi_metadata_destroy(struct ngsi_metadata *meta)
@ -459,7 +459,7 @@ static int ngsi_attribute_destroy(struct ngsi_attribute *attr)
free(attr->name);
free(attr->type);
list_destroy(&attr->metadata, (dtor_cb_t) ngsi_metadata_destroy, true);
vlist_destroy(&attr->metadata, (dtor_cb_t) ngsi_metadata_destroy, true);
return 0;
}
@ -468,7 +468,7 @@ int ngsi_destroy(struct node *n)
{
struct ngsi *i = (struct ngsi *) n->_vd;
list_destroy(&i->mapping, (dtor_cb_t) ngsi_attribute_destroy, true);
vlist_destroy(&i->mapping, (dtor_cb_t) ngsi_attribute_destroy, true);
return 0;
}
@ -484,7 +484,7 @@ int ngsi_start(struct node *n)
if (i->access_token) {
char buf[128];
snprintf(buf, sizeof(buf), "Auth-Token: %s", i->access_token);
i->headers = curl_slist_append(i->headers, buf);
i->headers = curl_svlist_append(i->headers, buf);
}
/* Create task */
@ -495,8 +495,8 @@ int ngsi_start(struct node *n)
if (ret)
serror("Failed to create task");
i->headers = curl_slist_append(i->headers, "Accept: application/json");
i->headers = curl_slist_append(i->headers, "Content-Type: application/json");
i->headers = curl_svlist_append(i->headers, "Accept: application/json");
i->headers = curl_svlist_append(i->headers, "Content-Type: application/json");
curl_easy_setopt(i->curl, CURLOPT_SSL_VERIFYPEER, i->ssl_verify);
curl_easy_setopt(i->curl, CURLOPT_TIMEOUT_MS, i->timeout * 1e3);
@ -528,7 +528,7 @@ int ngsi_stop(struct node *n)
json_decref(entity);
curl_easy_cleanup(i->curl);
curl_slist_free_all(i->headers);
curl_svlist_free_all(i->headers);
return ret;
}

View file

@ -47,7 +47,7 @@ int shmem_parse(struct node *n, json_t *cfg)
/* Default values */
shm->conf.queuelen = MAX(DEFAULT_SHMEM_QUEUELEN, n->in.vectorize);
shm->conf.samplelen = list_length(&n->signals);
shm->conf.samplelen = vlist_length(&n->signals);
shm->conf.polling = false;
shm->exec = NULL;

View file

@ -86,7 +86,7 @@ static void signal_generator_init_signals(struct node *n)
{
struct signal_generator *s = (struct signal_generator *) n->_vd;
assert(list_length(&n->signals) == 0);
assert(vlist_length(&n->signals) == 0);
for (int i = 0; i < s->values; i++) {
struct signal *sig = alloc(sizeof(struct signal));
@ -96,7 +96,7 @@ static void signal_generator_init_signals(struct node *n)
sig->name = strdup(signal_generator_type_str(rtype));
sig->type = SIGNAL_TYPE_FLOAT; /* All generated signals are of type float */
list_push(&n->signals, sig);
vlist_push(&n->signals, sig);
}
}

View file

@ -51,7 +51,7 @@
static struct plugin p;
/* Private static storage */
struct list interfaces = { .state = STATE_DESTROYED };
struct vlist interfaces = { .state = STATE_DESTROYED };
int socket_type_start(struct super_node *sn)
{
@ -59,11 +59,11 @@ int socket_type_start(struct super_node *sn)
int ret;
nl_init(); /* Fill link cache */
list_init(&interfaces);
vlist_init(&interfaces);
/* Gather list of used network interfaces */
for (size_t i = 0; i < list_length(&p.node.instances); i++) {
struct node *n = (struct node *) list_at(&p.node.instances, i);
for (size_t i = 0; i < vlist_length(&p.node.instances); i++) {
struct node *n = (struct node *) vlist_at(&p.node.instances, i);
struct socket *s = (struct socket *) n->_vd;
struct rtnl_link *link;
@ -83,8 +83,8 @@ int socket_type_start(struct super_node *sn)
/* Search of existing interface with correct ifindex */
struct interface *i;
for (size_t k = 0; k < list_length(&interfaces); k++) {
i = (struct interface *) list_at(&interfaces, k);
for (size_t k = 0; k < vlist_length(&interfaces); k++) {
i = (struct interface *) vlist_at(&interfaces, k);
if (rtnl_link_get_ifindex(i->nl_link) == rtnl_link_get_ifindex(link))
goto found;
@ -97,13 +97,13 @@ int socket_type_start(struct super_node *sn)
if (ret)
continue;
list_push(&interfaces, i);
vlist_push(&interfaces, i);
found: list_push(&i->sockets, s);
found: vlist_push(&i->sockets, s);
}
for (size_t j = 0; j < list_length(&interfaces); j++) {
struct interface *i = (struct interface *) list_at(&interfaces, j);
for (size_t j = 0; j < vlist_length(&interfaces); j++) {
struct interface *i = (struct interface *) vlist_at(&interfaces, j);
if_start(i);
}
@ -115,13 +115,13 @@ found: list_push(&i->sockets, s);
int socket_type_stop()
{
#ifdef WITH_NETEM
for (size_t j = 0; j < list_length(&interfaces); j++) {
struct interface *i = (struct interface *) list_at(&interfaces, j);
for (size_t j = 0; j < vlist_length(&interfaces); j++) {
struct interface *i = (struct interface *) vlist_at(&interfaces, j);
if_stop(i);
}
list_destroy(&interfaces, (dtor_cb_t) if_destroy, false);
vlist_destroy(&interfaces, (dtor_cb_t) if_destroy, false);
#endif /* WITH_NETEM */
return 0;

View file

@ -36,7 +36,7 @@
#define STATS_METRICS 6
static struct list *nodes; /** The global list of nodes */
static struct vlist *nodes; /** The global list of nodes */
static void stats_init_signals(struct node *n)
{
@ -50,42 +50,42 @@ static void stats_init_signals(struct node *n)
sig = alloc(sizeof(struct signal));
sig->name = strf("%s.%s", desc->name, "total");
sig->type = SIGNAL_TYPE_INTEGER;
list_push(&n->signals, sig);
vlist_push(&n->signals, sig);
/* Last */
sig = alloc(sizeof(struct signal));
sig->name = strf("%s.%s", desc->name, "last");
sig->unit = strdup(desc->unit);
sig->type = SIGNAL_TYPE_FLOAT;
list_push(&n->signals, sig);
vlist_push(&n->signals, sig);
/* Highest */
sig = alloc(sizeof(struct signal));
sig->name = strf("%s.%s", desc->name, "highest");
sig->unit = strdup(desc->unit);
sig->type = SIGNAL_TYPE_FLOAT;
list_push(&n->signals, sig);
vlist_push(&n->signals, sig);
/* Lowest */
sig = alloc(sizeof(struct signal));
sig->name = strf("%s.%s", desc->name, "lowest");
sig->unit = strdup(desc->unit);
sig->type = SIGNAL_TYPE_FLOAT;
list_push(&n->signals, sig);
vlist_push(&n->signals, sig);
/* Mean */
sig = alloc(sizeof(struct signal));
sig->name = strf("%s.%s", desc->name, "mean");
sig->unit = strdup(desc->unit);
sig->type = SIGNAL_TYPE_FLOAT;
list_push(&n->signals, sig);
vlist_push(&n->signals, sig);
/* Variance */
sig = alloc(sizeof(struct signal));
sig->name = strf("%s.%s", desc->name, "var");
sig->unit = strf("%s^2", desc->unit); // variance has squared unit of variable
sig->type = SIGNAL_TYPE_FLOAT;
list_push(&n->signals, sig);
vlist_push(&n->signals, sig);
}
}
@ -105,7 +105,7 @@ int stats_node_start(struct node *n)
if (ret)
serror("Failed to create task");
s->node = list_lookup(nodes, s->node_str);
s->node = vlist_lookup(nodes, s->node_str);
if (!s->node)
error("Invalid reference node %s for setting 'node' of node %s", s->node_str, node_name(n));

View file

@ -33,7 +33,7 @@
static int test_rtt_case_start(struct test_rtt *t, int id)
{
int ret;
struct test_rtt_case *c = (struct test_rtt_case *) list_at(&t->cases, id);
struct test_rtt_case *c = (struct test_rtt_case *) vlist_at(&t->cases, id);
/* Open file */
ret = io_open(&t->io, c->filename);
@ -91,7 +91,7 @@ int test_rtt_parse(struct node *n, json_t *cfg)
t->cooldown = 1.0;
/* Generate list of test cases */
list_init(&t->cases);
vlist_init(&t->cases);
ret = json_unpack_ex(cfg, &err, 0, "{ s?: s, s?: s, s?: s, s?: F, s: o }",
"prefix", &prefix,
@ -112,7 +112,7 @@ int test_rtt_parse(struct node *n, json_t *cfg)
error("Invalid value for setting 'format' of node %s", node_name(n));
/* Construct list of test cases */
/* Construct vlist of test cases */
if (!json_is_array(json_cases))
error("The 'cases' setting of node %s must be an array.", node_name(n));
@ -192,7 +192,7 @@ int test_rtt_parse(struct node *n, json_t *cfg)
c->filename = strf("%s/%s_%d_%.0f.log", t->output, t->prefix, c->values, c->rate);
list_push(&t->cases, c);
vlist_push(&t->cases, c);
}
}
}
@ -208,7 +208,7 @@ int test_rtt_destroy(struct node *n)
int ret;
struct test_rtt *t = (struct test_rtt *) n->_vd;
ret = list_destroy(&t->cases, NULL, true);
ret = vlist_destroy(&t->cases, NULL, true);
if (ret)
return ret;
@ -229,7 +229,7 @@ char * test_rtt_print(struct node *n)
{
struct test_rtt *t = (struct test_rtt *) n->_vd;
return strf("output=%s, prefix=%s, cooldown=%f, #cases=%zu", t->output, t->prefix, t->cooldown, list_length(&t->cases));
return strf("output=%s, prefix=%s, cooldown=%f, #cases=%zu", t->output, t->prefix, t->cooldown, vlist_length(&t->cases));
}
int test_rtt_start(struct node *n)
@ -237,7 +237,7 @@ int test_rtt_start(struct node *n)
int ret;
struct stat st;
struct test_rtt *t = (struct test_rtt *) n->_vd;
struct test_rtt_case *c = list_first(&t->cases);
struct test_rtt_case *c = vlist_first(&t->cases);
/* Create folder for results if not present */
ret = stat(t->output, &st);
@ -306,13 +306,13 @@ int test_rtt_read(struct node *n, struct sample *smps[], unsigned cnt, unsigned
t->current++;
}
if (t->current >= list_length(&t->cases)) {
if (t->current >= vlist_length(&t->cases)) {
info("This was the last case. Terminating.");
killme(SIGTERM);
pause();
}
else {
struct test_rtt_case *c = (struct test_rtt_case *) list_at(&t->cases, t->current);
struct test_rtt_case *c = (struct test_rtt_case *) vlist_at(&t->cases, t->current);
info("Starting case #%d: filename=%s, rate=%f, values=%d, limit=%d", t->current, c->filename, c->rate, c->values, c->limit);
ret = test_rtt_case_start(t, t->current);
if (ret)
@ -320,7 +320,7 @@ int test_rtt_read(struct node *n, struct sample *smps[], unsigned cnt, unsigned
}
}
struct test_rtt_case *c = (struct test_rtt_case *) list_at(&t->cases, t->current);
struct test_rtt_case *c = (struct test_rtt_case *) vlist_at(&t->cases, t->current);
/* Wait */
steps = task_wait(&t->task);
@ -365,7 +365,7 @@ int test_rtt_write(struct node *n, struct sample *smps[], unsigned cnt, unsigned
if (t->current < 0)
return 0;
struct test_rtt_case *c = (struct test_rtt_case *) list_at(&t->cases, t->current);
struct test_rtt_case *c = (struct test_rtt_case *) vlist_at(&t->cases, t->current);
int i;
for (i = 0; i < cnt; i++) {

View file

@ -40,7 +40,7 @@
#define DEFAULT_WEBSOCKET_BUFFER_SIZE (1 << 12)
/* Private static storage */
static struct list connections = { .state = STATE_DESTROYED }; /**< List of active libwebsocket connections which receive samples from all nodes (catch all) */
static struct vlist connections = { .state = STATE_DESTROYED }; /**< List of active libwebsocket connections which receive samples from all nodes (catch all) */
// @todo: port to C++
//static struct web *web;
@ -228,7 +228,7 @@ int websocket_protocol_cb(struct lws *wsi, enum lws_callback_reasons reason, voi
format = "villas.web";
/* Search for node whose name matches the URI. */
c->node = list_lookup(&p.node.instances, node);
c->node = vlist_lookup(&p.node.instances, node);
if (!c->node) {
websocket_connection_close(c, wsi, LWS_CLOSE_STATUS_POLICY_VIOLATION, "Unknown node");
warning("Failed to find node: node=%s", node);
@ -250,7 +250,7 @@ int websocket_protocol_cb(struct lws *wsi, enum lws_callback_reasons reason, voi
return -1;
}
list_push(&connections, c);
vlist_push(&connections, c);
debug(LOG_WEBSOCKET | 10, "Initialized WebSocket connection: %s", websocket_connection_name(c));
break;
@ -270,7 +270,7 @@ int websocket_protocol_cb(struct lws *wsi, enum lws_callback_reasons reason, voi
}
if (connections.state == STATE_INITIALIZED)
list_remove(&connections, c);
vlist_remove(&connections, c);
if (c->state == WEBSOCKET_CONNECTION_STATE_INITIALIZED)
websocket_connection_destroy(c);
@ -375,7 +375,7 @@ int websocket_protocol_cb(struct lws *wsi, enum lws_callback_reasons reason, voi
int websocket_type_start(struct super_node *ssn)
{
list_init(&connections);
vlist_init(&connections);
//web = NULL; /// @todo: Port to C++ &sn->web;
sn = ssn;
@ -401,9 +401,9 @@ int websocket_start(struct node *n)
if (ret)
return ret;
for (int i = 0; i < list_length(&w->destinations); i++) {
for (int i = 0; i < vlist_length(&w->destinations); i++) {
const char *format;
struct websocket_destination *d = (struct websocket_destination *) list_at(&w->destinations, i);
struct websocket_destination *d = (struct websocket_destination *) vlist_at(&w->destinations, i);
struct websocket_connection *c = (struct websocket_connection *) alloc(sizeof(struct websocket_connection));
c->state = WEBSOCKET_CONNECTION_STATE_CONNECTING;
@ -434,8 +434,8 @@ int websocket_stop(struct node *n)
int ret;
struct websocket *w = (struct websocket *) n->_vd;
for (size_t i = 0; i < list_length(&connections); i++) {
struct websocket_connection *c = (struct websocket_connection *) list_at(&connections, i);
for (size_t i = 0; i < vlist_length(&connections); i++) {
struct websocket_connection *c = (struct websocket_connection *) vlist_at(&connections, i);
if (c->node != n)
continue;
@ -450,8 +450,8 @@ int websocket_stop(struct node *n)
int open_connections = 0;
/* Count open connections belonging to this node */
for (int i = 0; i < list_length(&connections); i++) {
struct websocket_connection *c = (struct websocket_connection *) list_at(&connections, i);
for (int i = 0; i < vlist_length(&connections); i++) {
struct websocket_connection *c = (struct websocket_connection *) vlist_at(&connections, i);
if (c->node == n)
open_connections++;
@ -460,7 +460,7 @@ int websocket_stop(struct node *n)
if (open_connections == 0)
break;
info("Waiting for shutdown of %zu connections... %d/10", list_length(&connections), j);
info("Waiting for shutdown of %zu connections... %d/10", vlist_length(&connections), j);
sleep(1);
}
@ -480,7 +480,7 @@ int websocket_destroy(struct node *n)
struct websocket *w = (struct websocket *) n->_vd;
int ret;
ret = list_destroy(&w->destinations, (dtor_cb_t) websocket_destination_destroy, true);
ret = vlist_destroy(&w->destinations, (dtor_cb_t) websocket_destination_destroy, true);
if (ret)
return ret;
@ -518,8 +518,8 @@ int websocket_write(struct node *n, struct sample *smps[], unsigned cnt, unsigne
sample_copy_many(cpys, smps, avail);
for (size_t i = 0; i < list_length(&connections); i++) {
struct websocket_connection *c = (struct websocket_connection *) list_at(&connections, i);
for (size_t i = 0; i < vlist_length(&connections); i++) {
struct websocket_connection *c = (struct websocket_connection *) vlist_at(&connections, i);
if (c->node == n)
websocket_connection_write(c, cpys, cnt);
@ -540,7 +540,7 @@ int websocket_parse(struct node *n, json_t *cfg)
json_t *json_dest;
json_error_t err;
list_init(&w->destinations);
vlist_init(&w->destinations);
ret = json_unpack_ex(cfg, &err, 0, "{ s?: o }", "destinations", &json_dests);
if (ret)
@ -573,7 +573,7 @@ int websocket_parse(struct node *n, json_t *cfg)
d->info.ietf_version_or_minus_one = -1;
d->info.protocol = "live";
list_push(&w->destinations, d);
vlist_push(&w->destinations, d);
}
}
@ -588,8 +588,8 @@ char * websocket_print(struct node *n)
buf = strcatf(&buf, "destinations=[ ");
for (size_t i = 0; i < list_length(&w->destinations); i++) {
struct websocket_destination *d = (struct websocket_destination *) list_at(&w->destinations, i);
for (size_t i = 0; i < vlist_length(&w->destinations); i++) {
struct websocket_destination *d = (struct websocket_destination *) vlist_at(&w->destinations, i);
buf = strcatf(&buf, "%s://%s:%d/%s ",
d->info.ssl_connection ? "wss" : "ws",

View file

@ -79,14 +79,14 @@ int zeromq_reverse(struct node *n)
{
struct zeromq *z = (struct zeromq *) n->_vd;
if (list_length(&z->out.endpoints) != 1)
if (vlist_length(&z->out.endpoints) != 1)
return -1;
char *subscriber = z->in.endpoint;
char *publisher = list_first(&z->out.endpoints);
char *publisher = vlist_first(&z->out.endpoints);
z->in.endpoint = publisher;
list_set(&z->out.endpoints, 0, subscriber);
vlist_set(&z->out.endpoints, 0, subscriber);
return 0;
}
@ -108,7 +108,7 @@ int zeromq_parse(struct node *n, json_t *cfg)
json_t *json_val;
json_error_t err;
list_init(&z->out.endpoints);
vlist_init(&z->out.endpoints);
z->curve.enabled = false;
z->ipv6 = 0;
@ -144,14 +144,14 @@ int zeromq_parse(struct node *n, json_t *cfg)
if (!ep)
error("All 'publish' settings must be strings");
list_push(&z->out.endpoints, strdup(ep));
vlist_push(&z->out.endpoints, strdup(ep));
}
break;
case JSON_STRING:
ep = json_string_value(json_pub);
list_push(&z->out.endpoints, strdup(ep));
vlist_push(&z->out.endpoints, strdup(ep));
break;
@ -223,8 +223,8 @@ char * zeromq_print(struct node *n)
z->in.endpoint ? z->in.endpoint : ""
);
for (size_t i = 0; i < list_length(&z->out.endpoints); i++) {
char *ep = (char *) list_at(&z->out.endpoints, i);
for (size_t i = 0; i < vlist_length(&z->out.endpoints); i++) {
char *ep = (char *) vlist_at(&z->out.endpoints, i);
strcatf(&buf, "%s ", ep);
}
@ -365,8 +365,8 @@ int zeromq_start(struct node *n)
#endif
/* Spawn server for publisher */
for (size_t i = 0; i < list_length(&z->out.endpoints); i++) {
char *ep = (char *) list_at(&z->out.endpoints, i);
for (size_t i = 0; i < vlist_length(&z->out.endpoints); i++) {
char *ep = (char *) vlist_at(&z->out.endpoints, i);
ret = zmq_bind(z->out.socket, ep);
if (ret < 0)
@ -432,7 +432,7 @@ int zeromq_destroy(struct node *n)
if (z->out.filter)
free(z->out.filter);
ret = list_destroy(&z->out.endpoints, NULL, true);
ret = vlist_destroy(&z->out.endpoints, NULL, true);
if (ret)
return ret;

View file

@ -51,7 +51,7 @@ static int path_source_init(struct path_source *ps)
if (ps->node->_vt->pool_size)
pool_size = ps->node->_vt->pool_size;
ret = pool_init(&ps->pool, pool_size, SAMPLE_LENGTH(list_length(&ps->node->signals)), node_memory_type(ps->node, &memory_hugepage));
ret = pool_init(&ps->pool, pool_size, SAMPLE_LENGTH(vlist_length(&ps->node->signals)), node_memory_type(ps->node, &memory_hugepage));
if (ret)
return ret;
@ -66,7 +66,7 @@ static int path_source_destroy(struct path_source *ps)
if (ret)
return ret;
ret = list_destroy(&ps->mappings, NULL, true);
ret = vlist_destroy(&ps->mappings, NULL, true);
if (ret)
return ret;
@ -195,8 +195,8 @@ static void path_destination_enqueue(struct path *p, struct sample *smps[], unsi
if (cloned < cnt)
warning("Pool underrun in path %s", path_name(p));
for (size_t i = 0; i < list_length(&p->destinations); i++) {
struct path_destination *pd = (struct path_destination *) list_at(&p->destinations, i);
for (size_t i = 0; i < vlist_length(&p->destinations); i++) {
struct path_destination *pd = (struct path_destination *) vlist_at(&p->destinations, i);
enqueued = queue_push_many(&pd->queue, (void **) clones, cloned);
if (enqueued != cnt)
@ -248,15 +248,15 @@ static void path_destination_write(struct path_destination *pd, struct path *p)
static void * path_run_single(void *arg)
{
struct path *p = arg;
struct path_source *ps = (struct path_source *) list_at(&p->sources, 0);
struct path_source *ps = (struct path_source *) vlist_at(&p->sources, 0);
debug(1, "Started path %s in single mode", path_name(p));
for (;;) {
path_source_read(ps, p, 0);
for (size_t i = 0; i < list_length(&p->destinations); i++) {
struct path_destination *pd = (struct path_destination *) list_at(&p->destinations, i);
for (size_t i = 0; i < vlist_length(&p->destinations); i++) {
struct path_destination *pd = (struct path_destination *) vlist_at(&p->destinations, i);
path_destination_write(pd, p);
}
@ -283,7 +283,7 @@ static void * path_run_poll(void *arg)
debug(10, "Path %s returned from poll(2)", path_name(p));
for (int i = 0; i < p->reader.nfds; i++) {
struct path_source *ps = (struct path_source *) list_at(&p->sources, i);
struct path_source *ps = (struct path_source *) vlist_at(&p->sources, i);
if (p->reader.pfds[i].revents & POLLIN) {
/* Timeout: re-enqueue the last sample */
@ -301,8 +301,8 @@ static void * path_run_poll(void *arg)
}
}
for (size_t i = 0; i < list_length(&p->destinations); i++) {
struct path_destination *pd = (struct path_destination *) list_at(&p->destinations, i);
for (size_t i = 0; i < vlist_length(&p->destinations); i++) {
struct path_destination *pd = (struct path_destination *) vlist_at(&p->destinations, i);
path_destination_write(pd, p);
}
@ -317,19 +317,19 @@ int path_init(struct path *p)
assert(p->state == STATE_DESTROYED);
ret = list_init(&p->destinations);
ret = vlist_init(&p->destinations);
if (ret)
return ret;
ret = list_init(&p->sources);
ret = vlist_init(&p->sources);
if (ret)
return ret;
ret = list_init(&p->signals);
ret = vlist_init(&p->signals);
if (ret)
return ret;
ret = list_init(&p->hooks);
ret = vlist_init(&p->hooks);
if (ret)
return ret;
@ -355,15 +355,15 @@ int path_init_poll(struct path *p)
{
int ret, nfds;
nfds = list_length(&p->sources);
nfds = vlist_length(&p->sources);
if (p->rate > 0)
nfds++;
p->reader.nfds = nfds;
p->reader.pfds = alloc(sizeof(struct pollfd) * p->reader.nfds);
for (int i = 0; i < list_length(&p->sources); i++) {
struct path_source *ps = (struct path_source *) list_at(&p->sources, i);
for (int i = 0; i < vlist_length(&p->sources); i++) {
struct path_source *ps = (struct path_source *) vlist_at(&p->sources, i);
/* This slot is only used if it is not masked */
p->reader.pfds[i].events = POLLIN;
@ -401,15 +401,15 @@ int path_init2(struct path *p)
return ret;
/* We sort the hooks according to their priority before starting the path */
list_sort(&p->hooks, hook_cmp_priority);
vlist_sort(&p->hooks, hook_cmp_priority);
#endif /* WITH_HOOKS */
/* Initialize destinations */
struct memory_type *pool_mt = &memory_hugepage;
int pool_size = MAX(1, list_length(&p->destinations)) * p->queuelen;
int pool_size = MAX(1, vlist_length(&p->destinations)) * p->queuelen;
for (size_t i = 0; i < list_length(&p->destinations); i++) {
struct path_destination *pd = (struct path_destination *) list_at(&p->destinations, i);
for (size_t i = 0; i < vlist_length(&p->destinations); i++) {
struct path_destination *pd = (struct path_destination *) vlist_at(&p->destinations, i);
if (pd->node->_vt->pool_size > pool_size)
pool_size = pd->node->_vt->pool_size;
@ -422,12 +422,12 @@ int path_init2(struct path *p)
return ret;
}
bitset_init(&p->received, list_length(&p->sources));
bitset_init(&p->mask, list_length(&p->sources));
bitset_init(&p->received, vlist_length(&p->sources));
bitset_init(&p->mask, vlist_length(&p->sources));
/* Initialize sources */
for (size_t i = 0; i < list_length(&p->sources); i++) {
struct path_source *ps = (struct path_source *) list_at(&p->sources, i);
for (size_t i = 0; i < vlist_length(&p->sources); i++) {
struct path_source *ps = (struct path_source *) vlist_at(&p->sources, i);
ret = path_source_init(ps);
if (ret)
@ -436,8 +436,8 @@ int path_init2(struct path *p)
if (ps->masked)
bitset_set(&p->mask, i);
for (size_t i = 0; i < list_length(&ps->mappings); i++) {
struct mapping_entry *me = (struct mapping_entry *) list_at(&ps->mappings, i);
for (size_t i = 0; i < vlist_length(&ps->mappings); i++) {
struct mapping_entry *me = (struct mapping_entry *) vlist_at(&ps->mappings, i);
int off = me->offset;
int len = me->length;
@ -448,7 +448,7 @@ int path_init2(struct path *p)
/* For data mappings we simple refer to the existing
* signal descriptors of the source node. */
if (me->type == MAPPING_TYPE_DATA) {
sig = (struct signal *) list_at_safe(&me->node->signals, me->data.offset + j);
sig = (struct signal *) vlist_at_safe(&me->node->signals, me->data.offset + j);
if (!sig) {
warning("Failed to create signal description for path %s", path_name(p));
continue;
@ -465,13 +465,13 @@ int path_init2(struct path *p)
return -1;
}
list_extend(&p->signals, off + j + 1, NULL);
list_set(&p->signals, off + j, sig);
vlist_extend(&p->signals, off + j + 1, NULL);
vlist_set(&p->signals, off + j, sig);
}
}
}
ret = pool_init(&p->pool, pool_size, SAMPLE_LENGTH(list_length(&p->signals)), pool_mt);
ret = pool_init(&p->pool, pool_size, SAMPLE_LENGTH(vlist_length(&p->signals)), pool_mt);
if (ret)
return ret;
@ -485,7 +485,7 @@ int path_init2(struct path *p)
return 0;
}
int path_parse(struct path *p, json_t *cfg, struct list *nodes)
int path_parse(struct path *p, json_t *cfg, struct vlist *nodes)
{
int ret;
@ -497,11 +497,11 @@ int path_parse(struct path *p, json_t *cfg, struct list *nodes)
const char *mode = NULL;
struct list sources = { .state = STATE_DESTROYED };
struct list destinations = { .state = STATE_DESTROYED };
struct vlist sources = { .state = STATE_DESTROYED };
struct vlist destinations = { .state = STATE_DESTROYED };
list_init(&sources);
list_init(&destinations);
vlist_init(&sources);
vlist_init(&destinations);
ret = json_unpack_ex(cfg, &err, 0, "{ s: o, s?: o, s?: o, s?: b, s?: b, s?: b, s?: i, s?: s, s?: b, s?: F, s?: o, s?: b}",
"in", &json_in,
@ -543,13 +543,13 @@ int path_parse(struct path *p, json_t *cfg, struct list *nodes)
jerror(&err, "Failed to parse output nodes");
}
for (size_t i = 0; i < list_length(&sources); i++) {
struct mapping_entry *me = (struct mapping_entry *) list_at(&sources, i);
for (size_t i = 0; i < vlist_length(&sources); i++) {
struct mapping_entry *me = (struct mapping_entry *) vlist_at(&sources, i);
struct path_source *ps = NULL;
/* Check if there is already a path_source for this source */
for (size_t j = 0; j < list_length(&p->sources); j++) {
struct path_source *pt = (struct path_source *) list_at(&p->sources, j);
for (size_t j = 0; j < vlist_length(&p->sources); j++) {
struct path_source *pt = (struct path_source *) vlist_at(&p->sources, j);
if (pt->node == me->node) {
ps = pt;
@ -566,22 +566,22 @@ int path_parse(struct path *p, json_t *cfg, struct list *nodes)
ps->mappings.state = STATE_DESTROYED;
list_init(&ps->mappings);
vlist_init(&ps->mappings);
list_push(&p->sources, ps);
vlist_push(&p->sources, ps);
}
list_push(&ps->mappings, me);
vlist_push(&ps->mappings, me);
}
for (size_t i = 0; i < list_length(&destinations); i++) {
struct node *n = (struct node *) list_at(&destinations, i);
for (size_t i = 0; i < vlist_length(&destinations); i++) {
struct node *n = (struct node *) vlist_at(&destinations, i);
struct path_destination *pd = (struct path_destination *) alloc(sizeof(struct path_destination));
pd->node = n;
list_push(&p->destinations, pd);
vlist_push(&p->destinations, pd);
}
if (json_mask) {
@ -600,13 +600,13 @@ int path_parse(struct path *p, json_t *cfg, struct list *nodes)
if (!name)
error("The 'mask' setting must be a list of node names");
node = list_lookup(nodes, name);
node = vlist_lookup(nodes, name);
if (!node)
error("The 'mask' entry '%s' is not a valid node name", name);
/* Search correspondending path_source to node */
for (size_t i = 0; i < list_length(&p->sources); i++) {
struct path_source *pt = (struct path_source *) list_at(&p->sources, i);
for (size_t i = 0; i < vlist_length(&p->sources); i++) {
struct path_source *pt = (struct path_source *) vlist_at(&p->sources, i);
if (pt->node == node) {
ps = pt;
@ -622,8 +622,8 @@ int path_parse(struct path *p, json_t *cfg, struct list *nodes)
}
/* Enable all by default */
else {
for (size_t i = 0; i < list_length(&p->sources); i++) {
struct path_source *ps = (struct path_source *) list_at(&p->sources, i);
for (size_t i = 0; i < vlist_length(&p->sources); i++) {
struct path_source *ps = (struct path_source *) vlist_at(&p->sources, i);
ps->masked = true;
}
@ -639,20 +639,20 @@ int path_parse(struct path *p, json_t *cfg, struct list *nodes)
/* Autodetect whether to use poll() for this path or not */
if (p->poll == -1) {
struct path_source *ps = (struct path_source *) list_at(&p->sources, 0);
struct path_source *ps = (struct path_source *) vlist_at(&p->sources, 0);
p->poll = (
p->rate > 0 ||
list_length(&p->sources) > 1
vlist_length(&p->sources) > 1
)
&& node_fd(ps->node) != 1;
}
ret = list_destroy(&sources, NULL, false);
ret = vlist_destroy(&sources, NULL, false);
if (ret)
return ret;
ret = list_destroy(&destinations, NULL, false);
ret = vlist_destroy(&destinations, NULL, false);
if (ret)
return ret;
@ -669,15 +669,15 @@ int path_check(struct path *p)
if (p->rate < 0)
error("Setting 'rate' of path %s must be a positive number.", path_name(p));
for (size_t i = 0; i < list_length(&p->sources); i++) {
struct path_source *ps = (struct path_source *) list_at(&p->sources, i);
for (size_t i = 0; i < vlist_length(&p->sources); i++) {
struct path_source *ps = (struct path_source *) vlist_at(&p->sources, i);
if (!ps->node->_vt->read)
error("Source node %s is not supported as a source for path %s", node_name(ps->node), path_name(p));
}
for (size_t i = 0; i < list_length(&p->destinations); i++) {
struct path_destination *pd = (struct path_destination *) list_at(&p->destinations, i);
for (size_t i = 0; i < vlist_length(&p->destinations); i++) {
struct path_destination *pd = (struct path_destination *) vlist_at(&p->destinations, i);
if (!pd->node->_vt->write)
error("Destiation node %s is not supported as a sink for path %s", node_name(pd->node), path_name(p));
@ -710,7 +710,7 @@ int path_start(struct path *p)
info("Starting path %s: #signals=%zu, mode=%s, poll=%s, mask=%s, rate=%.2f, enabled=%s, reversed=%s, queuelen=%d, #hooks=%zu, #sources=%zu, #destinations=%zu, #original_sequence_no=%s",
path_name(p),
list_length(&p->signals),
vlist_length(&p->signals),
mode,
p->poll ? "yes" : "no",
mask,
@ -718,17 +718,17 @@ int path_start(struct path *p)
p->enabled ? "yes" : "no",
p->reverse ? "yes" : "no",
p->queuelen,
list_length(&p->hooks),
list_length(&p->sources),
list_length(&p->destinations),
vlist_length(&p->hooks),
vlist_length(&p->sources),
vlist_length(&p->destinations),
p->original_sequence_no ? "yes" : "no"
);
free(mask);
#ifdef WITH_HOOKS
for (size_t i = 0; i < list_length(&p->hooks); i++) {
struct hook *h = (struct hook *) list_at(&p->hooks, i);
for (size_t i = 0; i < vlist_length(&p->hooks); i++) {
struct hook *h = (struct hook *) vlist_at(&p->hooks, i);
ret = hook_start(h);
if (ret)
@ -745,13 +745,13 @@ int path_start(struct path *p)
if (!p->last_sample)
return -1;
p->last_sample->length = list_length(&p->signals);
p->last_sample->length = vlist_length(&p->signals);
p->last_sample->signals = &p->signals;
p->last_sample->sequence = 0;
p->last_sample->flags = 0;
for (size_t i = 0; i < p->last_sample->length; i++) {
struct signal *sig = (struct signal *) list_at(p->last_sample->signals, i);
struct signal *sig = (struct signal *) vlist_at(p->last_sample->signals, i);
p->last_sample->data[i] = sig->init;
}
@ -789,8 +789,8 @@ int path_stop(struct path *p)
return ret;
#ifdef WITH_HOOKS
for (size_t i = 0; i < list_length(&p->hooks); i++) {
struct hook *h = (struct hook *) list_at(&p->hooks, i);
for (size_t i = 0; i < vlist_length(&p->hooks); i++) {
struct hook *h = (struct hook *) vlist_at(&p->hooks, i);
ret = hook_stop(h);
if (ret)
@ -811,11 +811,11 @@ int path_destroy(struct path *p)
return 0;
#ifdef WITH_HOOKS
list_destroy(&p->hooks, (dtor_cb_t) hook_destroy, true);
vlist_destroy(&p->hooks, (dtor_cb_t) hook_destroy, true);
#endif
list_destroy(&p->sources, (dtor_cb_t) path_source_destroy, true);
list_destroy(&p->destinations, (dtor_cb_t) path_destination_destroy, true);
list_destroy(&p->signals, (dtor_cb_t) signal_decref, false);
vlist_destroy(&p->sources, (dtor_cb_t) path_source_destroy, true);
vlist_destroy(&p->destinations, (dtor_cb_t) path_destination_destroy, true);
vlist_destroy(&p->signals, (dtor_cb_t) signal_decref, false);
if (p->reader.pfds)
free(p->reader.pfds);
@ -838,16 +838,16 @@ const char * path_name(struct path *p)
if (!p->_name) {
strcatf(&p->_name, "[");
for (size_t i = 0; i < list_length(&p->sources); i++) {
struct path_source *ps = (struct path_source *) list_at(&p->sources, i);
for (size_t i = 0; i < vlist_length(&p->sources); i++) {
struct path_source *ps = (struct path_source *) vlist_at(&p->sources, i);
strcatf(&p->_name, " %s", node_name_short(ps->node));
}
strcatf(&p->_name, " ] " CLR_MAG("=>") " [");
for (size_t i = 0; i < list_length(&p->destinations); i++) {
struct path_destination *pd = (struct path_destination *) list_at(&p->destinations, i);
for (size_t i = 0; i < vlist_length(&p->destinations); i++) {
struct path_destination *pd = (struct path_destination *) vlist_at(&p->destinations, i);
strcatf(&p->_name, " %s", node_name_short(pd->node));
}
@ -860,15 +860,15 @@ const char * path_name(struct path *p)
int path_uses_node(struct path *p, struct node *n)
{
for (size_t i = 0; i < list_length(&p->destinations); i++) {
struct path_destination *pd = (struct path_destination *) list_at(&p->destinations, i);
for (size_t i = 0; i < vlist_length(&p->destinations); i++) {
struct path_destination *pd = (struct path_destination *) vlist_at(&p->destinations, i);
if (pd->node == n)
return 0;
}
for (size_t i = 0; i < list_length(&p->sources); i++) {
struct path_source *ps = (struct path_source *) list_at(&p->sources, i);
for (size_t i = 0; i < vlist_length(&p->sources); i++) {
struct path_source *ps = (struct path_source *) vlist_at(&p->sources, i);
if (ps->node == n)
return 0;
@ -879,15 +879,15 @@ int path_uses_node(struct path *p, struct node *n)
int path_reverse(struct path *p, struct path *r)
{
if (list_length(&p->destinations) != 1 || list_length(&p->sources) != 1)
if (vlist_length(&p->destinations) != 1 || vlist_length(&p->sources) != 1)
return -1;
/* General */
r->enabled = p->enabled;
/* Source / Destinations */
struct path_destination *orig_pd = list_first(&p->destinations);
struct path_source *orig_ps = list_first(&p->sources);
struct path_destination *orig_pd = vlist_first(&p->destinations);
struct path_source *orig_ps = vlist_first(&p->sources);
struct path_destination *new_pd = (struct path_destination *) alloc(sizeof(struct path_destination));
struct path_source *new_ps = (struct path_source *) alloc(sizeof(struct path_source));
@ -901,24 +901,24 @@ int path_reverse(struct path *p, struct path *r)
new_me->data.offset = 0;
new_me->length = 0;
list_init(&new_ps->mappings);
list_push(&new_ps->mappings, new_me);
vlist_init(&new_ps->mappings);
vlist_push(&new_ps->mappings, new_me);
list_push(&r->destinations, new_pd);
list_push(&r->sources, new_ps);
vlist_push(&r->destinations, new_pd);
vlist_push(&r->sources, new_ps);
#ifdef WITH_HOOKS
for (size_t i = 0; i < list_length(&p->hooks); i++) {
for (size_t i = 0; i < vlist_length(&p->hooks); i++) {
int ret;
struct hook *h = (struct hook *) list_at(&p->hooks, i);
struct hook *h = (struct hook *) vlist_at(&p->hooks, i);
struct hook *g = (struct hook *) alloc(sizeof(struct hook));
ret = hook_init(g, h->_vt, r, NULL);
if (ret)
return ret;
list_push(&r->hooks, g);
vlist_push(&r->hooks, g);
}
#endif /* WITH_HOOKS */
return 0;

View file

@ -26,7 +26,7 @@
#include <villas/plugin.h>
/** Global list of all known plugins */
struct list plugins = { .state = STATE_DESTROYED };
struct vlist plugins = { .state = STATE_DESTROYED };
LIST_INIT_STATIC(&plugins)
@ -90,8 +90,8 @@ int plugin_destroy(struct plugin *p)
struct plugin * plugin_lookup(enum plugin_type type, const char *name)
{
for (size_t i = 0; i < list_length(&plugins); i++) {
struct plugin *p = (struct plugin *) list_at(&plugins, i);
for (size_t i = 0; i < vlist_length(&plugins); i++) {
struct plugin *p = (struct plugin *) vlist_at(&plugins, i);
if (p->type == type && strcmp(p->name, name) == 0)
return p;
@ -102,8 +102,8 @@ struct plugin * plugin_lookup(enum plugin_type type, const char *name)
void plugin_dump(enum plugin_type type)
{
for (size_t i = 0; i < list_length(&plugins); i++) {
struct plugin *p = (struct plugin *) list_at(&plugins, i);
for (size_t i = 0; i < vlist_length(&plugins); i++) {
struct plugin *p = (struct plugin *) vlist_at(&plugins, i);
if (p->type == type)
printf(" - %-13s: %s\n", p->name, p->description);

View file

@ -280,7 +280,7 @@ enum signal_type sample_format(const struct sample *s, unsigned idx)
{
struct signal *sig;
sig = (struct signal *) list_at_safe(s->signals, idx);
sig = (struct signal *) vlist_at_safe(s->signals, idx);
return sig ? sig->type : SIGNAL_TYPE_AUTO;
}

View file

@ -223,7 +223,7 @@ int signal_parse(struct signal *s, json_t *cfg)
/* Signal list */
int signal_list_parse(struct list *list, json_t *cfg)
int signal_vlist_parse(struct vlist *list, json_t *cfg)
{
int ret;
struct signal *s;
@ -246,13 +246,13 @@ int signal_list_parse(struct list *list, json_t *cfg)
if (ret)
return ret;
list_push(list, s);
vlist_push(list, s);
}
return 0;
}
int signal_list_generate(struct list *list, unsigned len, enum signal_type fmt)
int signal_vlist_generate(struct vlist *list, unsigned len, enum signal_type fmt)
{
for (int i = 0; i < len; i++) {
char name[32];
@ -262,18 +262,18 @@ int signal_list_generate(struct list *list, unsigned len, enum signal_type fmt)
if (!sig)
return -1;
list_push(list, sig);
vlist_push(list, sig);
}
return 0;
}
void signal_list_dump(const struct list *list)
void signal_vlist_dump(const struct vlist *list)
{
info ("Signals:");
for (int i = 0; i < list_length(list); i++) {
struct signal *sig = list_at(list, i);
for (int i = 0; i < vlist_length(list); i++) {
struct signal *sig = vlist_at(list, i);
if (sig->unit)
info(" %d: %s [%s] = %s", i, sig->name, sig->unit, signal_type_to_str(sig->type));

View file

@ -58,9 +58,9 @@ SuperNode::SuperNode() :
paths.state = STATE_DESTROYED;
plugins.state = STATE_DESTROYED;
list_init(&nodes);
list_init(&paths);
list_init(&plugins);
vlist_init(&nodes);
vlist_init(&paths);
vlist_init(&plugins);
char hname[128];
gethostname(hname, 128);
@ -214,7 +214,7 @@ int SuperNode::parseJson(json_t *j)
if (ret)
throw RuntimeError("Failed to parse plugin");
list_push(&plugins, p);
vlist_push(&plugins, p);
}
}
@ -247,7 +247,7 @@ int SuperNode::parseJson(json_t *j)
if (ret)
throw RuntimeError("Failed to parse node");
list_push(&nodes, n);
vlist_push(&nodes, n);
}
}
@ -269,7 +269,7 @@ int SuperNode::parseJson(json_t *j)
if (ret)
throw RuntimeError("Failed to parse path");
list_push(&paths, p);
vlist_push(&paths, p);
if (p->reverse) {
path *r = (path *) alloc(sizeof(path));
@ -282,7 +282,7 @@ int SuperNode::parseJson(json_t *j)
if (ret)
throw RuntimeError("Failed to reverse path {}", path_name(p));
list_push(&paths, r);
vlist_push(&paths, r);
}
}
}
@ -300,16 +300,16 @@ int SuperNode::check()
assert(state == STATE_INITIALIZED || state == STATE_PARSED || state == STATE_CHECKED);
for (size_t i = 0; i < list_length(&nodes); i++) {
auto *n = (struct node *) list_at(&nodes, i);
for (size_t i = 0; i < vlist_length(&nodes); i++) {
auto *n = (struct node *) vlist_at(&nodes, i);
ret = node_check(n);
if (ret)
throw RuntimeError("Invalid configuration for node {}", node_name(n));
}
for (size_t i = 0; i < list_length(&paths); i++) {
auto *p = (struct path *) list_at(&paths, i);
for (size_t i = 0; i < vlist_length(&paths); i++) {
auto *p = (struct path *) vlist_at(&paths, i);
ret = path_check(p);
if (ret)
@ -339,8 +339,8 @@ int SuperNode::start()
#endif
logger->info("Starting node-types");
for (size_t i = 0; i < list_length(&nodes); i++) {
auto *n = (struct node *) list_at(&nodes, i);
for (size_t i = 0; i < vlist_length(&nodes); i++) {
auto *n = (struct node *) vlist_at(&nodes, i);
ret = node_type_start(n->_vt, reinterpret_cast<super_node *>(this));
if (ret)
@ -348,14 +348,14 @@ int SuperNode::start()
}
logger->info("Starting nodes");
for (size_t i = 0; i < list_length(&nodes); i++) {
auto *n = (struct node *) list_at(&nodes, i);
for (size_t i = 0; i < vlist_length(&nodes); i++) {
auto *n = (struct node *) vlist_at(&nodes, i);
ret = node_init2(n);
if (ret)
throw RuntimeError("Failed to prepare node: {}", node_name(n));
int refs = list_count(&paths, (cmp_cb_t) path_uses_node, n);
int refs = vlist_count(&paths, (cmp_cb_t) path_uses_node, n);
if (refs > 0) {
ret = node_start(n);
if (ret)
@ -366,8 +366,8 @@ int SuperNode::start()
}
logger->info("Starting paths");
for (size_t i = 0; i < list_length(&paths); i++) {
auto *p = (struct path *) list_at(&paths, i);
for (size_t i = 0; i < vlist_length(&paths); i++) {
auto *p = (struct path *) vlist_at(&paths, i);
if (p->enabled) {
ret = path_init2(p);
@ -412,8 +412,8 @@ int SuperNode::stop()
#endif /* WITH_HOOKS */
logger->info("Stopping paths");
for (size_t i = 0; i < list_length(&paths); i++) {
auto *p = (struct path *) list_at(&paths, i);
for (size_t i = 0; i < vlist_length(&paths); i++) {
auto *p = (struct path *) vlist_at(&paths, i);
ret = path_stop(p);
if (ret)
@ -421,8 +421,8 @@ int SuperNode::stop()
}
logger->info("Stopping nodes");
for (size_t i = 0; i < list_length(&nodes); i++) {
auto *n = (struct node *) list_at(&nodes, i);
for (size_t i = 0; i < vlist_length(&nodes); i++) {
auto *n = (struct node *) vlist_at(&nodes, i);
ret = node_stop(n);
if (ret)
@ -430,8 +430,8 @@ int SuperNode::stop()
}
logger->info("Stopping node-types");
for (size_t i = 0; i < list_length(&plugins); i++) {
auto *p = (struct plugin *) list_at(&plugins, i);
for (size_t i = 0; i < vlist_length(&plugins); i++) {
auto *p = (struct plugin *) vlist_at(&plugins, i);
if (p->type == PLUGIN_TYPE_NODE) {
ret = node_type_stop(&p->node);
@ -466,9 +466,9 @@ SuperNode::~SuperNode()
{
assert(state != STATE_STARTED);
list_destroy(&plugins, (dtor_cb_t) plugin_destroy, false);
list_destroy(&paths, (dtor_cb_t) path_destroy, true);
list_destroy(&nodes, (dtor_cb_t) node_destroy, true);
vlist_destroy(&plugins, (dtor_cb_t) plugin_destroy, false);
vlist_destroy(&paths, (dtor_cb_t) path_destroy, true);
vlist_destroy(&nodes, (dtor_cb_t) node_destroy, true);
if (json)
json_decref(json);
@ -479,14 +479,14 @@ int SuperNode::periodic()
#ifdef WITH_HOOKS
int ret;
for (size_t i = 0; i < list_length(&paths); i++) {
auto *p = (struct path *) list_at(&paths, i);
for (size_t i = 0; i < vlist_length(&paths); i++) {
auto *p = (struct path *) vlist_at(&paths, i);
if (p->state != STATE_STARTED)
continue;
for (size_t j = 0; j < list_length(&p->hooks); j++) {
hook *h = (struct hook *) list_at(&p->hooks, j);
for (size_t j = 0; j < vlist_length(&p->hooks); j++) {
hook *h = (struct hook *) vlist_at(&p->hooks, j);
ret = hook_periodic(h);
if (ret)
@ -494,22 +494,22 @@ int SuperNode::periodic()
}
}
for (size_t i = 0; i < list_length(&nodes); i++) {
auto *n = (struct node *) list_at(&nodes, i);
for (size_t i = 0; i < vlist_length(&nodes); i++) {
auto *n = (struct node *) vlist_at(&nodes, i);
if (n->state != STATE_STARTED)
continue;
for (size_t j = 0; j < list_length(&n->in.hooks); j++) {
auto *h = (struct hook *) list_at(&n->in.hooks, j);
for (size_t j = 0; j < vlist_length(&n->in.hooks); j++) {
auto *h = (struct hook *) vlist_at(&n->in.hooks, j);
ret = hook_periodic(h);
if (ret)
return ret;
}
for (size_t j = 0; j < list_length(&n->out.hooks); j++) {
auto *h = (struct hook *) list_at(&n->out.hooks, j);
for (size_t j = 0; j < vlist_length(&n->out.hooks); j++) {
auto *h = (struct hook *) vlist_at(&n->out.hooks, j);
ret = hook_periodic(h);
if (ret)
@ -523,7 +523,7 @@ int SuperNode::periodic()
/* C-compatability */
extern "C" {
struct list * super_node_get_nodes(struct super_node *sn)
struct vlist * super_node_get_nodes(struct super_node *sn)
{
SuperNode *ssn = reinterpret_cast<SuperNode *>(sn);

View file

@ -221,7 +221,7 @@ int main(int argc, char *argv[])
if (ret)
throw RuntimeError("Failed to verify node configuration");
ret = pool_init(&q, 16, SAMPLE_LENGTH(list_length(&n.signals)), &memory_heap);
ret = pool_init(&q, 16, SAMPLE_LENGTH(vlist_length(&n.signals)), &memory_heap);
if (ret)
throw RuntimeError("Failed to initialize pool");

View file

@ -67,7 +67,7 @@ static struct param params[] = {
#endif
};
void fill_sample_data(struct list *signals, struct sample *smps[], unsigned cnt)
void fill_sample_data(struct vlist *signals, struct sample *smps[], unsigned cnt)
{
struct timespec delta, now;
@ -78,13 +78,13 @@ void fill_sample_data(struct list *signals, struct sample *smps[], unsigned cnt)
struct sample *smp = smps[i];
smps[i]->flags = SAMPLE_HAS_SEQUENCE | SAMPLE_HAS_DATA | SAMPLE_HAS_TS_ORIGIN;
smps[i]->length = list_length(signals);
smps[i]->length = vlist_length(signals);
smps[i]->sequence = 235 + i;
smps[i]->ts.origin = now;
smps[i]->signals = signals;
for (size_t j = 0; j < list_length(signals); j++) {
struct signal *sig = (struct signal *) list_at(signals, j);
for (size_t j = 0; j < vlist_length(signals); j++) {
struct signal *sig = (struct signal *) vlist_at(signals, j);
union signal_data *data = &smp->data[j];
switch (sig->type) {
@ -223,15 +223,15 @@ ParameterizedTest(struct param *p, io, lowlevel, .init = init_memory)
struct pool pool = { .state = STATE_DESTROYED };
struct io io = { .state = STATE_DESTROYED };
struct list signals = { .state = STATE_DESTROYED };
struct vlist signals = { .state = STATE_DESTROYED };
struct sample *smps[p->cnt];
struct sample *smpt[p->cnt];
ret = pool_init(&pool, 2 * p->cnt, SAMPLE_LENGTH(NUM_VALUES), &memory_hugepage);
cr_assert_eq(ret, 0);
list_init(&signals);
signal_list_generate(&signals, NUM_VALUES, SIGNAL_TYPE_FLOAT);
vlist_init(&signals);
signal_vlist_generate(&signals, NUM_VALUES, SIGNAL_TYPE_FLOAT);
ret = sample_alloc_many(&pool, smps, p->cnt);
cr_assert_eq(ret, p->cnt);
@ -292,7 +292,7 @@ ParameterizedTest(struct param *p, io, highlevel, .init = init_memory)
struct io io = { .state = STATE_DESTROYED };
struct pool pool = { .state = STATE_DESTROYED };
struct list signals = { .state = STATE_DESTROYED };
struct vlist signals = { .state = STATE_DESTROYED };
struct sample *smps[p->cnt];
struct sample *smpt[p->cnt];
@ -306,8 +306,8 @@ ParameterizedTest(struct param *p, io, highlevel, .init = init_memory)
ret = sample_alloc_many(&pool, smpt, p->cnt);
cr_assert_eq(ret, p->cnt);
list_init(&signals);
signal_list_generate(&signals, NUM_VALUES, SIGNAL_TYPE_FLOAT);
vlist_init(&signals);
signal_vlist_generate(&signals, NUM_VALUES, SIGNAL_TYPE_FLOAT);
fill_sample_data(&signals, smps, p->cnt);

View file

@ -32,7 +32,7 @@ Test(mapping, parse_nodes)
{
int ret;
struct mapping_entry m;
struct list nodes = { .state = STATE_DESTROYED };
struct vlist nodes = { .state = STATE_DESTROYED };
const char *node_names[3] = { "apple", "cherry", "carrot" };
const char *signal_names[3][4] = {
@ -41,7 +41,7 @@ Test(mapping, parse_nodes)
{ "o", "sole", "mio", "italia" }
};
list_init(&nodes);
vlist_init(&nodes);
for (unsigned i = 0; i < ARRAY_LEN(node_names); i++) {
struct node *n = new struct node;
@ -49,7 +49,7 @@ Test(mapping, parse_nodes)
n->name = strdup(node_names[i]);
n->signals.state = STATE_DESTROYED;
list_init(&n->signals);
vlist_init(&n->signals);
for (unsigned j = 0; j < ARRAY_LEN(signal_names[i]); j++) {
struct signal *sig;
@ -57,54 +57,54 @@ Test(mapping, parse_nodes)
sig = signal_create(signal_names[i][j], nullptr, SIGNAL_TYPE_AUTO);
cr_assert_not_null(sig);
list_push(&n->signals, sig);
vlist_push(&n->signals, sig);
}
list_push(&nodes, n);
vlist_push(&nodes, n);
}
ret = mapping_parse_str(&m, "apple.ts.origin", &nodes);
cr_assert_eq(ret, 0);
cr_assert_eq(m.node, list_lookup(&nodes, "apple"));
cr_assert_eq(m.node, vlist_lookup(&nodes, "apple"));
cr_assert_eq(m.type, MAPPING_TYPE_TIMESTAMP);
cr_assert_eq(m.timestamp.type, MAPPING_TIMESTAMP_TYPE_ORIGIN);
ret = mapping_parse_str(&m, "cherry.stats.owd.mean", &nodes);
cr_assert_eq(ret, 0);
cr_assert_eq(m.node, list_lookup(&nodes, "cherry"));
cr_assert_eq(m.node, vlist_lookup(&nodes, "cherry"));
cr_assert_eq(m.type, MAPPING_TYPE_STATS);
cr_assert_eq(m.stats.id, STATS_OWD);
cr_assert_eq(m.stats.type, MAPPING_STATS_TYPE_MEAN);
ret = mapping_parse_str(&m, "carrot.data[1-2]", &nodes);
cr_assert_eq(ret, 0);
cr_assert_eq(m.node, list_lookup(&nodes, "carrot"));
cr_assert_eq(m.node, vlist_lookup(&nodes, "carrot"));
cr_assert_eq(m.type, MAPPING_TYPE_DATA);
cr_assert_eq(m.data.offset, 1);
cr_assert_eq(m.length, 2);
ret = mapping_parse_str(&m, "carrot", &nodes);
cr_assert_eq(ret, 0);
cr_assert_eq(m.node, list_lookup(&nodes, "carrot"));
cr_assert_eq(m.node, vlist_lookup(&nodes, "carrot"));
cr_assert_eq(m.type, MAPPING_TYPE_DATA);
cr_assert_eq(m.data.offset, 0);
cr_assert_eq(m.length, list_length(&m.node->signals));
cr_assert_eq(m.length, vlist_length(&m.node->signals));
ret = mapping_parse_str(&m, "carrot.data[sole]", &nodes);
cr_assert_eq(ret, 0);
cr_assert_eq(m.node, list_lookup(&nodes, "carrot"));
cr_assert_eq(m.node, vlist_lookup(&nodes, "carrot"));
cr_assert_eq(m.type, MAPPING_TYPE_DATA);
cr_assert_eq(m.data.offset, 1);
cr_assert_eq(m.length, 1);
ret = mapping_parse_str(&m, "carrot.data[sole-mio]", &nodes);
cr_assert_eq(ret, 0);
cr_assert_eq(m.node, list_lookup(&nodes, "carrot"));
cr_assert_eq(m.node, vlist_lookup(&nodes, "carrot"));
cr_assert_eq(m.type, MAPPING_TYPE_DATA);
cr_assert_eq(m.data.offset, 1);
cr_assert_eq(m.length, 2);
ret = list_destroy(&nodes, nullptr, true);
ret = vlist_destroy(&nodes, nullptr, true);
cr_assert_eq(ret, 0);
}