diff --git a/common/CMakeLists.txt b/common/CMakeLists.txt index ff61c052f..200574d0b 100644 --- a/common/CMakeLists.txt +++ b/common/CMakeLists.txt @@ -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) diff --git a/common/include/villas/common.hpp b/common/include/villas/common.hpp index a73239add..538c02d04 100644 --- a/common/include/villas/common.hpp +++ b/common/include/villas/common.hpp @@ -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, diff --git a/common/include/villas/compat.hpp b/common/include/villas/compat.hpp index 799120f68..8ca1de16d 100644 --- a/common/include/villas/compat.hpp +++ b/common/include/villas/compat.hpp @@ -24,7 +24,7 @@ #include -#include +#include #if JANSSON_VERSION_HEX < 0x020A00 size_t json_dumpb(const json_t *json, char *buffer, size_t size, size_t flags); diff --git a/common/include/villas/config.h.in b/common/include/villas/config.hpp.in similarity index 92% rename from common/include/villas/config.h.in rename to common/include/villas/config.hpp.in index 2a0f9e5e9..1840b38f8 100644 --- a/common/include/villas/config.h.in +++ b/common/include/villas/config.hpp.in @@ -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 diff --git a/common/include/villas/exceptions.hpp b/common/include/villas/exceptions.hpp index 0310b6fd2..40d628ec4 100644 --- a/common/include/villas/exceptions.hpp +++ b/common/include/villas/exceptions.hpp @@ -32,7 +32,7 @@ #include #include -#include +#include namespace villas { diff --git a/common/include/villas/hist.hpp b/common/include/villas/hist.hpp index c9d90412f..43f61fbf1 100644 --- a/common/include/villas/hist.hpp +++ b/common/include/villas/hist.hpp @@ -41,7 +41,7 @@ public: using cnt_t = uintmax_t; using idx_t = std::vector::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. */ diff --git a/common/include/villas/kernel/pci.hpp b/common/include/villas/kernel/pci.hpp index 8732255c5..d37b63a5e 100644 --- a/common/include/villas/kernel/pci.hpp +++ b/common/include/villas/kernel/pci.hpp @@ -21,8 +21,6 @@ * along with this program. If not, see . *********************************************************************************/ -/** @addtogroup fpga Kernel @{ */ - #pragma once #include @@ -140,5 +138,3 @@ public: } /* namespace pci */ } /* namespace kernel */ } /* namespace villas */ - -/** @} */ diff --git a/common/include/villas/kernel/rt.hpp b/common/include/villas/kernel/rt.hpp index 79a90bfca..eab5a8caa 100644 --- a/common/include/villas/kernel/rt.hpp +++ b/common/include/villas/kernel/rt.hpp @@ -22,10 +22,6 @@ * along with this program. If not, see . *********************************************************************************/ -/** @addtogroup kernel Kernel - * @{ - */ - #pragma once #include @@ -53,5 +49,3 @@ bool isPreemptible(); } /* namespace villas */ } /* namespace kernel */ } /* namespace rt */ - -/** @} */ diff --git a/common/include/villas/kernel/vfio.hpp b/common/include/villas/kernel/vfio.hpp index 452aa372d..448ffb971 100644 --- a/common/include/villas/kernel/vfio.hpp +++ b/common/include/villas/kernel/vfio.hpp @@ -7,8 +7,6 @@ * @copyright 2018, Daniel Krebs *********************************************************************************/ -/** @addtogroup fpga Kernel @{ */ - #pragma once #include @@ -175,8 +173,6 @@ private: std::list> groups; }; -/** @} */ - } /* namespace vfio */ } /* namespace kernel */ } /* namespace villas */ diff --git a/common/include/villas/list.h b/common/include/villas/list.hpp similarity index 68% rename from common/include/villas/list.h rename to common/include/villas/list.hpp index 12dd5a553..43515c5f3 100644 --- a/common/include/villas/list.h +++ b/common/include/villas/list.hpp @@ -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 -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(a); auto *s = reinterpret_cast(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 -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(l, name); + auto *f = list_lookup_name(l, name); - return f ? vlist_index(l, f) : -1; + return f ? list_index(l, f) : -1; } + +} /* namespace villas */ diff --git a/common/include/villas/table.hpp b/common/include/villas/table.hpp index 36c8b8000..bd194a407 100644 --- a/common/include/villas/table.hpp +++ b/common/include/villas/table.hpp @@ -21,10 +21,6 @@ * along with this program. If not, see . *********************************************************************************/ -/** @addtogroup table Print fancy tables - * @{ - */ - #pragma once #include @@ -104,5 +100,3 @@ public: }; } /* namespace villas */ - -/** @} */ diff --git a/common/include/villas/task.hpp b/common/include/villas/task.hpp index 11e808a18..402b8636e 100644 --- a/common/include/villas/task.hpp +++ b/common/include/villas/task.hpp @@ -44,7 +44,7 @@ #endif #if PERIODIC_TASK_IMPL == RDTSC - #include + #include #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. */ diff --git a/common/include/villas/timing.h b/common/include/villas/timing.hpp similarity index 100% rename from common/include/villas/timing.h rename to common/include/villas/timing.hpp diff --git a/common/include/villas/tool.hpp b/common/include/villas/tool.hpp index af203cd98..043ae27d0 100644 --- a/common/include/villas/tool.hpp +++ b/common/include/villas/tool.hpp @@ -25,7 +25,7 @@ #include #include -#include +#include #include #include diff --git a/common/include/villas/tsc.h b/common/include/villas/tsc.hpp similarity index 90% rename from common/include/villas/tsc.h rename to common/include/villas/tsc.hpp index 8f650968d..a647c42bc 100644 --- a/common/include/villas/tsc.h +++ b/common/include/villas/tsc.hpp @@ -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); diff --git a/common/include/villas/utils.hpp b/common/include/villas/utils.hpp index e108439c4..390f7b19c 100644 --- a/common/include/villas/utils.hpp +++ b/common/include/villas/utils.hpp @@ -37,7 +37,7 @@ #include -#include +#include #ifdef __GNUC__ #define LIKELY(x) __builtin_expect((x),1) diff --git a/common/lib/hist.cpp b/common/lib/hist.cpp index 7211a5214..1dbf3a6ec 100644 --- a/common/lib/hist.cpp +++ b/common/lib/hist.cpp @@ -26,7 +26,7 @@ #include #include -#include +#include #include #include diff --git a/common/lib/kernel/kernel.cpp b/common/lib/kernel/kernel.cpp index c16bb5439..72fffecc1 100644 --- a/common/lib/kernel/kernel.cpp +++ b/common/lib/kernel/kernel.cpp @@ -34,7 +34,7 @@ #include #include -#include +#include #include #include diff --git a/common/lib/kernel/pci.cpp b/common/lib/kernel/pci.cpp index f837fbb7a..f34018b5b 100644 --- a/common/lib/kernel/pci.cpp +++ b/common/lib/kernel/pci.cpp @@ -29,7 +29,7 @@ #include #include #include -#include +#include #include using namespace villas::kernel::pci; diff --git a/common/lib/kernel/rt.cpp b/common/lib/kernel/rt.cpp index 190395069..395921d47 100644 --- a/common/lib/kernel/rt.cpp +++ b/common/lib/kernel/rt.cpp @@ -25,7 +25,7 @@ #include #include -#include +#include #include #include diff --git a/common/lib/list.cpp b/common/lib/list.cpp index 89e64edcf..ef4ad598c 100644 --- a/common/lib/list.cpp +++ b/common/lib/list.cpp @@ -28,10 +28,12 @@ #include #include -#include +#include #include -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; diff --git a/common/lib/task.cpp b/common/lib/task.cpp index f5b942e24..fa937ca6e 100644 --- a/common/lib/task.cpp +++ b/common/lib/task.cpp @@ -26,7 +26,7 @@ #include #include -#include +#include #include using namespace villas; diff --git a/common/lib/timing.cpp b/common/lib/timing.cpp index 560bd787a..07fa347a0 100644 --- a/common/lib/timing.cpp +++ b/common/lib/timing.cpp @@ -22,7 +22,7 @@ #include -#include +#include struct timespec time_now() { diff --git a/common/lib/tsc.cpp b/common/lib/tsc.cpp index 377212095..a435f5325 100644 --- a/common/lib/tsc.cpp +++ b/common/lib/tsc.cpp @@ -21,11 +21,11 @@ * along with this program. If not, see . *********************************************************************************/ -#include +#include 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; } diff --git a/common/lib/utils.cpp b/common/lib/utils.cpp index 61d099d28..9314ff12c 100644 --- a/common/lib/utils.cpp +++ b/common/lib/utils.cpp @@ -42,7 +42,7 @@ #include #include -#include +#include #include #include #include diff --git a/common/tests/unit/list.cpp b/common/tests/unit/list.cpp index d5cc0f524..891c9576c 100644 --- a/common/tests/unit/list.cpp +++ b/common/tests/unit/list.cpp @@ -26,7 +26,7 @@ #include #include -#include +#include 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); } diff --git a/common/tests/unit/task.cpp b/common/tests/unit/task.cpp index a846b4cb6..f00f5a5e0 100644 --- a/common/tests/unit/task.cpp +++ b/common/tests/unit/task.cpp @@ -25,7 +25,7 @@ #include #include -#include +#include // cppcheck-suppress unknownMacro TestSuite(task, .description = "Periodic timer tasks"); diff --git a/common/tests/unit/timing.cpp b/common/tests/unit/timing.cpp index 8f455a21f..8e738f6d2 100644 --- a/common/tests/unit/timing.cpp +++ b/common/tests/unit/timing.cpp @@ -24,7 +24,7 @@ #include #include -#include +#include // cppcheck-suppress unknownMacro TestSuite(timing, .description = "Time measurements"); diff --git a/common/tests/unit/tsc.cpp b/common/tests/unit/tsc.cpp index a4e7cfb0c..c86635721 100644 --- a/common/tests/unit/tsc.cpp +++ b/common/tests/unit/tsc.cpp @@ -24,16 +24,17 @@ #include #include -#include +#include #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);