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

port large parts to C++

This commit is contained in:
Steffen Vogel 2021-08-11 12:40:19 -04:00
parent ecf10bd43c
commit f6caa4f2d5
29 changed files with 134 additions and 158 deletions

View file

@ -69,8 +69,8 @@ if(CRITERION_FOUND AND TOPLEVEL_PROJECT)
endif()
configure_file(
${CMAKE_CURRENT_SOURCE_DIR}/include/villas/config.h.in
${CMAKE_CURRENT_BINARY_DIR}/include/villas/config.h
${CMAKE_CURRENT_SOURCE_DIR}/include/villas/config.hpp.in
${CMAKE_CURRENT_BINARY_DIR}/include/villas/config.hpp
)
if(TOPLEVEL_PROJECT)

View file

@ -32,11 +32,7 @@ enum class State {
PARSED = 2,
CHECKED = 3,
STARTED = 4,
LOADED = 4, /* alias for STARTED used by struct plugin */
OPENED = 4, /* alias for STARTED used by IO */
STOPPED = 5,
UNLOADED = 5, /* alias for STARTED used by struct plugin */
CLOSED = 5, /* alias for STARTED used by struct io */
PENDING_CONNECT = 6,
CONNECTED = 7,
PAUSED = 8,

View file

@ -24,7 +24,7 @@
#include <jansson.h>
#include <villas/config.h>
#include <villas/config.hpp>
#if JANSSON_VERSION_HEX < 0x020A00
size_t json_dumpb(const json_t *json, char *buffer, size_t size, size_t flags);

View file

@ -55,10 +55,3 @@
/** Width of log output in characters */
#define LOG_WIDTH 80
#define LOG_HEIGHT 25
/* Hard-coded cache line size */
#if defined(__x86_64__) || defined(__i386__) || defined(__arm__) || defined(__aarch64__)
#define CACHELINE_SIZE 64
#else
#error "Unsupported architecture"
#endif

View file

@ -32,7 +32,7 @@
#include <fmt/core.h>
#include <jansson.h>
#include <villas/config.h>
#include <villas/config.hpp>
namespace villas {

View file

@ -41,7 +41,7 @@ public:
using cnt_t = uintmax_t;
using idx_t = std::vector<cnt_t>::difference_type;
/** Initialize struct hist with supplied values and allocate memory for buckets. */
/** Initialize struct Hist with supplied values and allocate memory for buckets. */
Hist(int buckets = 0, cnt_t warmup = 0);
/** Reset all counters and values back to zero. */

View file

@ -21,8 +21,6 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*********************************************************************************/
/** @addtogroup fpga Kernel @{ */
#pragma once
#include <cstddef>
@ -140,5 +138,3 @@ public:
} /* namespace pci */
} /* namespace kernel */
} /* namespace villas */
/** @} */

View file

@ -22,10 +22,6 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*********************************************************************************/
/** @addtogroup kernel Kernel
* @{
*/
#pragma once
#include <pthread.h>
@ -53,5 +49,3 @@ bool isPreemptible();
} /* namespace villas */
} /* namespace kernel */
} /* namespace rt */
/** @} */

View file

@ -7,8 +7,6 @@
* @copyright 2018, Daniel Krebs
*********************************************************************************/
/** @addtogroup fpga Kernel @{ */
#pragma once
#include <list>
@ -175,8 +173,6 @@ private:
std::list<std::unique_ptr<Group>> groups;
};
/** @} */
} /* namespace vfio */
} /* namespace kernel */
} /* namespace villas */

View file

@ -42,25 +42,27 @@
#define LIST_INIT_STATIC(l) \
__attribute__((constructor(105))) static void UNIQUE(__ctor)() {\
int ret __attribute__((unused)); \
ret = vlist_init(l); \
ret = list_init(l); \
} \
__attribute__((destructor(105))) static void UNIQUE(__dtor)() { \
int ret __attribute__((unused)); \
ret = vlist_destroy(l, nullptr, false); \
ret = list_destroy(l, nullptr, false); \
}
#define vlist_length(list) ((list)->length)
#define vlist_at_safe(list, index) ((list)->length > index ? (list)->array[index] : nullptr)
#define vlist_at(list, index) ((list)->array[index])
#define list_length(list) ((list)->length)
#define list_at_safe(list, index) ((list)->length > index ? (list)->array[index] : nullptr)
#define list_at(list, index) ((list)->array[index])
#define vlist_first(list) vlist_at(list, 0)
#define vlist_last(list) vlist_at(list, (list)->length-1)
#define list_first(list) list_at(list, 0)
#define list_last(list) list_at(list, (list)->length-1)
namespace villas {
/** Callback to search or sort a list. */
typedef int (*cmp_cb_t)(const void *, const void *);
/* The list data structure. */
struct vlist {
struct List {
enum State state; /**< The state of this list. */
void **array; /**< Array of pointers to list elements */
size_t capacity; /**< Size of list::array in elements */
@ -72,62 +74,62 @@ struct vlist {
*
* @param l A pointer to the list data structure.
*/
int vlist_init(struct vlist *l) __attribute__ ((warn_unused_result));
int list_init(struct List *l) __attribute__ ((warn_unused_result));
/** Destroy a list and call destructors for all list elements
*
* @param free free() all list members during when calling vlist_destroy()
* @param free free() all list members during when calling list_destroy()
* @param dtor A function pointer to a desctructor which will be called for every list item when the list is destroyed.
* @param l A pointer to the list data structure.
*/
int vlist_destroy(struct vlist *l, dtor_cb_t dtor = nullptr, bool free = false) __attribute__ ((warn_unused_result));
int list_destroy(struct List *l, dtor_cb_t dtor = nullptr, bool free = false) __attribute__ ((warn_unused_result));
/** Append an element to the end of the list */
void vlist_push(struct vlist *l, void *p);
void list_push(struct List *l, void *p);
/** Clear list */
void vlist_clear(struct vlist *l);
void list_clear(struct List *l);
/** Remove all occurences of a list item */
void vlist_remove_all(struct vlist *l, void *p);
void list_remove_all(struct List *l, void *p);
int vlist_remove(struct vlist *l, size_t idx);
int list_remove(struct List *l, size_t idx);
int vlist_insert(struct vlist *l, size_t idx, void *p);
int list_insert(struct List *l, size_t idx, void *p);
/** Return the first element of the list for which cmp returns zero */
void * vlist_search(struct vlist *l, cmp_cb_t cmp, const void *ctx);
void * list_search(struct List *l, cmp_cb_t cmp, const void *ctx);
/** Returns the number of occurences for which cmp returns zero when called on all list elements. */
int vlist_count(struct vlist *l, cmp_cb_t cmp, void *ctx);
int list_count(struct List *l, cmp_cb_t cmp, void *ctx);
/** Return 0 if list contains pointer p */
int vlist_contains(struct vlist *l, void *p);
int list_contains(struct List *l, void *p);
/** Sort the list using the quicksort algorithm of libc */
void vlist_sort(struct vlist *l, cmp_cb_t cmp);
void list_sort(struct List *l, cmp_cb_t cmp);
/** Set single element in list */
int vlist_set(struct vlist *l, unsigned index, void *value);
int list_set(struct List *l, unsigned index, void *value);
/** Return index in list for value.
*
* @retval <0 No list entry matching \p value was found.
* @retval >=0 Entry \p value was found at returned index.
*/
ssize_t vlist_index(struct vlist *l, void *value);
ssize_t list_index(struct List *l, void *value);
/** Extend the list to the given length by filling new slots with given value. */
void vlist_extend(struct vlist *l, size_t len, void *val);
void list_extend(struct List *l, size_t len, void *val);
/** Remove all elements for which the callback returns a non-zero return code. */
void vlist_filter(struct vlist *l, dtor_cb_t cb);
void list_filter(struct List *l, dtor_cb_t cb);
/** Lookup an element from the list based on a name */
template<typename T>
T * vlist_lookup_name(struct vlist *l, const std::string &name)
T * list_lookup_name(struct List *l, const std::string &name)
{
return (T *) vlist_search(l, [](const void *a, const void *b) -> int {
return (T *) list_search(l, [](const void *a, const void *b) -> int {
auto *e = reinterpret_cast<const T *>(a);
auto *s = reinterpret_cast<const std::string *>(b);
@ -137,9 +139,11 @@ T * vlist_lookup_name(struct vlist *l, const std::string &name)
/** Lookup index of list element based on name */
template<typename T>
ssize_t vlist_lookup_index(struct vlist *l, const std::string &name)
ssize_t list_lookup_index(struct List *l, const std::string &name)
{
auto *f = vlist_lookup_name<T>(l, name);
auto *f = list_lookup_name<T>(l, name);
return f ? vlist_index(l, f) : -1;
return f ? list_index(l, f) : -1;
}
} /* namespace villas */

View file

@ -21,10 +21,6 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*********************************************************************************/
/** @addtogroup table Print fancy tables
* @{
*/
#pragma once
#include <vector>
@ -104,5 +100,3 @@ public:
};
} /* namespace villas */
/** @} */

View file

@ -44,7 +44,7 @@
#endif
#if PERIODIC_TASK_IMPL == RDTSC
#include <villas/tsc.h>
#include <villas/tsc.hpp>
#endif
struct Task {
@ -61,7 +61,7 @@ struct Task {
#if PERIODIC_TASK_IMPL == TIMERFD
int fd; /**< The timerfd_create(2) file descriptior. */
#elif PERIODIC_TASK_IMPL == RDTSC
struct tsc tsc; /**< Initialized by tsc_init(). */
struct Tsc tsc; /**< Initialized by tsc_init(). */
#endif
/** Create a new task with the given rate. */

View file

@ -25,7 +25,7 @@
#include <villas/log.hpp>
#include <villas/colors.hpp>
#include <villas/config.h>
#include <villas/config.hpp>
#include <villas/exceptions.hpp>
#include <villas/utils.hpp>

View file

@ -45,7 +45,7 @@
#define bit_TSC_INVARIANT (1 << 8)
#define bit_RDTSCP (1 << 27)
struct tsc {
struct Tsc {
uint64_t frequency;
bool rdtscp_supported;
@ -53,7 +53,7 @@ struct tsc {
};
__attribute__((unused))
static uint64_t tsc_now(struct tsc *t)
static uint64_t tsc_now(struct Tsc *t)
{
uint32_t tsc_aux;
return t->rdtscp_supported
@ -61,6 +61,6 @@ static uint64_t tsc_now(struct tsc *t)
: __rdtsc();
}
int tsc_init(struct tsc *t) __attribute__ ((warn_unused_result));
int tsc_init(struct Tsc *t) __attribute__ ((warn_unused_result));
uint64_t tsc_rate_to_cycles(struct tsc *t, double rate);
uint64_t tsc_rate_to_cycles(struct Tsc *t, double rate);

View file

@ -37,7 +37,7 @@
#include <openssl/sha.h>
#include <villas/config.h>
#include <villas/config.hpp>
#ifdef __GNUC__
#define LIKELY(x) __builtin_expect((x),1)

View file

@ -26,7 +26,7 @@
#include <villas/utils.hpp>
#include <villas/hist.hpp>
#include <villas/config.h>
#include <villas/config.hpp>
#include <villas/table.hpp>
#include <villas/exceptions.hpp>

View file

@ -34,7 +34,7 @@
#include <villas/log.hpp>
#include <villas/utils.hpp>
#include <villas/config.h>
#include <villas/config.hpp>
#include <villas/kernel/kernel.hpp>
#include <villas/kernel/kernel.hpp>

View file

@ -29,7 +29,7 @@
#include <villas/log.hpp>
#include <villas/utils.hpp>
#include <villas/exceptions.hpp>
#include <villas/config.h>
#include <villas/config.hpp>
#include <villas/kernel/pci.hpp>
using namespace villas::kernel::pci;

View file

@ -25,7 +25,7 @@
#include <villas/log.hpp>
#include <villas/cpuset.hpp>
#include <villas/config.h>
#include <villas/config.hpp>
#include <villas/utils.hpp>
#include <villas/exceptions.hpp>

View file

@ -28,10 +28,12 @@
#include <cstdlib>
#include <cstring>
#include <villas/list.h>
#include <villas/list.hpp>
#include <villas/utils.hpp>
int vlist_init(struct vlist *l)
using namespace villas;
int villas::list_init(struct List *l)
{
pthread_mutex_init(&l->lock, nullptr);
@ -43,14 +45,14 @@ int vlist_init(struct vlist *l)
return 0;
}
int vlist_destroy(struct vlist *l, dtor_cb_t destructor, bool release)
int villas::list_destroy(struct List *l, dtor_cb_t destructor, bool release)
{
pthread_mutex_lock(&l->lock);
assert(l->state != State::DESTROYED);
for (size_t i = 0; i < vlist_length(l); i++) {
void *e = vlist_at(l, i);
for (size_t i = 0; i < list_length(l); i++) {
void *e = list_at(l, i);
if (destructor)
destructor(e);
@ -71,7 +73,7 @@ int vlist_destroy(struct vlist *l, dtor_cb_t destructor, bool release)
return 0;
}
void vlist_push(struct vlist *l, void *p)
void villas::list_push(struct List *l, void *p)
{
pthread_mutex_lock(&l->lock);
@ -89,7 +91,7 @@ void vlist_push(struct vlist *l, void *p)
pthread_mutex_unlock(&l->lock);
}
void vlist_clear(struct vlist *l)
void villas::list_clear(struct List *l)
{
pthread_mutex_lock(&l->lock);
@ -98,7 +100,7 @@ void vlist_clear(struct vlist *l)
pthread_mutex_unlock(&l->lock);
}
int vlist_remove(struct vlist *l, size_t idx)
int villas::list_remove(struct List *l, size_t idx)
{
pthread_mutex_lock(&l->lock);
@ -117,7 +119,7 @@ int vlist_remove(struct vlist *l, size_t idx)
return 0;
}
int vlist_insert(struct vlist *l, size_t idx, void *p)
int villas::list_insert(struct List *l, size_t idx, void *p)
{
size_t i;
void *t, *o;
@ -150,7 +152,7 @@ int vlist_insert(struct vlist *l, size_t idx, void *p)
return 0;
}
void vlist_remove_all(struct vlist *l, void *p)
void villas::list_remove_all(struct List *l, void *p)
{
int removed = 0;
@ -158,11 +160,11 @@ void vlist_remove_all(struct vlist *l, void *p)
assert(l->state == State::INITIALIZED);
for (size_t i = 0; i < vlist_length(l); i++) {
if (vlist_at(l, i) == p)
for (size_t i = 0; i < list_length(l); i++) {
if (list_at(l, i) == p)
removed++;
else
l->array[i - removed] = vlist_at(l, i);
l->array[i - removed] = list_at(l, i);
}
l->length -= removed;
@ -170,14 +172,14 @@ void vlist_remove_all(struct vlist *l, void *p)
pthread_mutex_unlock(&l->lock);
}
int vlist_contains(struct vlist *l, void *p)
int villas::list_contains(struct List *l, void *p)
{
return vlist_count(l, [](const void *a, const void *b) {
return list_count(l, [](const void *a, const void *b) {
return a == b ? 0 : 1;
}, p);
}
int vlist_count(struct vlist *l, cmp_cb_t cmp, void *ctx)
int villas::list_count(struct List *l, cmp_cb_t cmp, void *ctx)
{
int c = 0;
void *e;
@ -186,8 +188,8 @@ int vlist_count(struct vlist *l, cmp_cb_t cmp, void *ctx)
assert(l->state == State::INITIALIZED);
for (size_t i = 0; i < vlist_length(l); i++) {
e = vlist_at(l, i);
for (size_t i = 0; i < list_length(l); i++) {
e = list_at(l, i);
if (cmp(e, ctx) == 0)
c++;
}
@ -197,7 +199,7 @@ int vlist_count(struct vlist *l, cmp_cb_t cmp, void *ctx)
return c;
}
void * vlist_search(struct vlist *l, cmp_cb_t cmp, const void *ctx)
void * villas::list_search(struct List *l, cmp_cb_t cmp, const void *ctx)
{
void *e;
@ -205,8 +207,8 @@ void * vlist_search(struct vlist *l, cmp_cb_t cmp, const void *ctx)
assert(l->state == State::INITIALIZED);
for (size_t i = 0; i < vlist_length(l); i++) {
e = vlist_at(l, i);
for (size_t i = 0; i < list_length(l); i++) {
e = list_at(l, i);
if (cmp(e, ctx) == 0)
goto out;
}
@ -218,7 +220,7 @@ out: pthread_mutex_unlock(&l->lock);
return e;
}
void vlist_sort(struct vlist *l, cmp_cb_t cmp)
void villas::list_sort(struct List *l, cmp_cb_t cmp)
{
pthread_mutex_lock(&l->lock);
@ -235,7 +237,7 @@ void vlist_sort(struct vlist *l, cmp_cb_t cmp)
pthread_mutex_unlock(&l->lock);
}
int vlist_set(struct vlist *l, unsigned index, void *value)
int villas::list_set(struct List *l, unsigned index, void *value)
{
if (index >= l->length)
return -1;
@ -245,7 +247,7 @@ int vlist_set(struct vlist *l, unsigned index, void *value)
return 0;
}
ssize_t vlist_index(struct vlist *l, void *p)
ssize_t villas::list_index(struct List *l, void *p)
{
void *e;
ssize_t f;
@ -254,8 +256,8 @@ ssize_t vlist_index(struct vlist *l, void *p)
assert(l->state == State::INITIALIZED);
for (size_t i = 0; i < vlist_length(l); i++) {
e = vlist_at(l, i);
for (size_t i = 0; i < list_length(l); i++) {
e = list_at(l, i);
if (e == p) {
f = i;
goto found;
@ -269,19 +271,19 @@ found: pthread_mutex_unlock(&l->lock);
return f;
}
void vlist_extend(struct vlist *l, size_t len, void *val)
void villas::list_extend(struct List *l, size_t len, void *val)
{
while (vlist_length(l) < len)
vlist_push(l, val);
while (list_length(l) < len)
list_push(l, val);
}
void vlist_filter(struct vlist *l, dtor_cb_t cb)
void villas::list_filter(struct List *l, dtor_cb_t cb)
{
size_t i, j;
pthread_mutex_lock(&l->lock);
for (i = 0, j = 0; i < vlist_length(l); i++) {
void *e = vlist_at(l, i);
for (i = 0, j = 0; i < list_length(l); i++) {
void *e = list_at(l, i);
if (!cb(e))
l->array[j++] = e;

View file

@ -26,7 +26,7 @@
#include <villas/utils.hpp>
#include <villas/task.hpp>
#include <villas/timing.h>
#include <villas/timing.hpp>
#include <villas/exceptions.hpp>
using namespace villas;

View file

@ -22,7 +22,7 @@
#include <unistd.h>
#include <villas/timing.h>
#include <villas/timing.hpp>
struct timespec time_now()
{

View file

@ -21,11 +21,11 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*********************************************************************************/
#include <villas/tsc.h>
#include <villas/tsc.hpp>
using namespace villas;
int tsc_init(struct tsc *t)
int tsc_init(struct Tsc *t)
{
uint32_t eax = 0, ebx = 0, ecx = 0, edx = 0;
@ -73,7 +73,7 @@ int tsc_init(struct tsc *t)
return 0;
}
uint64_t tsc_rate_to_cycles(struct tsc *t, double rate)
uint64_t tsc_rate_to_cycles(struct Tsc *t, double rate)
{
return t->frequency / rate;
}

View file

@ -42,7 +42,7 @@
#include <jansson.h>
#include <uuid/uuid.h>
#include <villas/config.h>
#include <villas/config.hpp>
#include <villas/utils.hpp>
#include <villas/colors.hpp>
#include <villas/exceptions.hpp>

View file

@ -26,7 +26,7 @@
#include <villas/exceptions.hpp>
#include <villas/utils.hpp>
#include <villas/list.h>
#include <villas/list.hpp>
using namespace villas;
@ -40,33 +40,33 @@ struct data {
// cppcheck-suppress unknownMacro
TestSuite(list, .description = "List datastructure");
Test(list, vlist_search)
Test(list, list_search)
{
int ret;
struct vlist l;
struct List l;
ret = vlist_init(&l);
ret = list_init(&l);
cr_assert_eq(ret, 0);
/* Fill list */
for (unsigned i = 0; i < ARRAY_LEN(nouns); i++)
vlist_push(&l, (void *) nouns[i]);
list_push(&l, (void *) nouns[i]);
cr_assert_eq(vlist_length(&l), ARRAY_LEN(nouns));
cr_assert_eq(list_length(&l), ARRAY_LEN(nouns));
/* Declare on stack! */
char positive[] = "woman";
char negative[] = "dinosaurrier";
char *found = (char *) vlist_search(&l, (cmp_cb_t) strcmp, positive);
char *found = (char *) list_search(&l, (cmp_cb_t) strcmp, positive);
cr_assert_not_null(found);
cr_assert_eq(found, nouns[13], "found = %p, nouns[13] = %p", found, nouns[13]);
cr_assert_str_eq(found, positive);
char *not_found = (char *) vlist_search(&l, (cmp_cb_t) strcmp, negative);
char *not_found = (char *) list_search(&l, (cmp_cb_t) strcmp, negative);
cr_assert_null(not_found);
ret = vlist_destroy(&l, nullptr, false);
ret = list_destroy(&l, nullptr, false);
cr_assert_eq(ret, 0);
}
@ -86,19 +86,19 @@ static int dtor(void *ptr)
Test(list, destructor)
{
int ret;
struct vlist l;
struct List l;
struct content elm;
elm.destroyed = 0;
ret = vlist_init(&l);
ret = list_init(&l);
cr_assert_eq(ret, 0);
vlist_push(&l, &elm);
list_push(&l, &elm);
cr_assert_eq(vlist_length(&l), 1);
cr_assert_eq(list_length(&l), 1);
ret = vlist_destroy(&l, dtor, false);
ret = list_destroy(&l, dtor, false);
cr_assert_eq(ret, 0);
cr_assert_eq(elm.destroyed, 1);
@ -108,64 +108,64 @@ Test(list, basics)
{
uintptr_t i;
int ret;
struct vlist l;
struct List l;
ret = vlist_init(&l);
ret = list_init(&l);
cr_assert_eq(ret, 0);
for (i = 0; i < 100; i++) {
cr_assert_eq(vlist_length(&l), i);
cr_assert_eq(list_length(&l), i);
vlist_push(&l, (void *) i);
list_push(&l, (void *) i);
}
cr_assert_eq(vlist_at_safe(&l, 555), nullptr);
cr_assert_eq(vlist_last(&l), (void *) 99);
cr_assert_eq(vlist_first(&l), (void *) 0);
cr_assert_eq(list_at_safe(&l, 555), nullptr);
cr_assert_eq(list_last(&l), (void *) 99);
cr_assert_eq(list_first(&l), (void *) 0);
for (size_t j = 0, i = 0; j < vlist_length(&l); j++) {
void *k = vlist_at(&l, j);
for (size_t j = 0, i = 0; j < list_length(&l); j++) {
void *k = list_at(&l, j);
cr_assert_eq(k, (void *) i++);
}
vlist_sort(&l, (cmp_cb_t) [](const void *a, const void *b) -> int {
list_sort(&l, (cmp_cb_t) [](const void *a, const void *b) -> int {
return (intptr_t) b - (intptr_t) a;
});
for (size_t j = 0, i = 99; j <= 99; j++, i--) {
uintptr_t k = (uintptr_t) vlist_at(&l, j);
uintptr_t k = (uintptr_t) list_at(&l, j);
cr_assert_eq(k, i, "Is %zu, expected %zu", k, i);
}
ret = vlist_contains(&l, (void *) 55);
ret = list_contains(&l, (void *) 55);
cr_assert(ret);
void *before_ptr = vlist_at(&l, 12);
void *before_ptr = list_at(&l, 12);
ret = vlist_insert(&l, 12, (void *) 123);
ret = list_insert(&l, 12, (void *) 123);
cr_assert_eq(ret, 0);
cr_assert_eq(vlist_at(&l, 12), (void *) 123, "Is: %p", vlist_at(&l, 12));
cr_assert_eq(list_at(&l, 12), (void *) 123, "Is: %p", list_at(&l, 12));
ret = vlist_remove(&l, 12);
ret = list_remove(&l, 12);
cr_assert_eq(ret, 0);
cr_assert_eq(vlist_at(&l, 12), before_ptr);
cr_assert_eq(list_at(&l, 12), before_ptr);
int counts, before_len;
before_len = vlist_length(&l);
counts = vlist_contains(&l, (void *) 55);
before_len = list_length(&l);
counts = list_contains(&l, (void *) 55);
cr_assert_gt(counts, 0);
vlist_remove_all(&l, (void *) 55);
cr_assert_eq(vlist_length(&l), (size_t) (before_len - counts));
list_remove_all(&l, (void *) 55);
cr_assert_eq(list_length(&l), (size_t) (before_len - counts));
ret = vlist_contains(&l, (void *) 55);
ret = list_contains(&l, (void *) 55);
cr_assert(!ret);
ret = vlist_destroy(&l, nullptr, false);
ret = list_destroy(&l, nullptr, false);
cr_assert(!ret);
ret = vlist_length(&l);
ret = list_length(&l);
cr_assert_eq(ret, -1, "List not properly destroyed: l.length = %zd", l.length);
}

View file

@ -25,7 +25,7 @@
#include <math.h>
#include <villas/task.hpp>
#include <villas/timing.h>
#include <villas/timing.hpp>
// cppcheck-suppress unknownMacro
TestSuite(task, .description = "Periodic timer tasks");

View file

@ -24,7 +24,7 @@
#include <math.h>
#include <criterion/criterion.h>
#include <villas/timing.h>
#include <villas/timing.hpp>
// cppcheck-suppress unknownMacro
TestSuite(timing, .description = "Time measurements");

View file

@ -24,16 +24,17 @@
#include <villas/utils.hpp>
#include <villas/tsc.h>
#include <villas/timing.h>
#include <villas/timing.hpp>
#define CNT (1 << 18)
// cppcheck-suppress unknownMacro
TestSuite(tsc, .description = "Timestamp counters");
Test(tsc, increasing)
{
int ret;
struct tsc tsc;
struct Tsc tsc;
uint64_t *cntrs;
ret = tsc_init(&tsc);
@ -56,7 +57,7 @@ Test(tsc, sleep)
int ret;
double delta, duration = 1;
struct timespec start, stop;
struct tsc tsc;
struct Tsc tsc;
uint64_t start_cycles, end_cycles;
ret = tsc_init(&tsc);