diff --git a/.gitmodules b/.gitmodules new file mode 100644 index 0000000..bff9634 --- /dev/null +++ b/.gitmodules @@ -0,0 +1,3 @@ +[submodule "arena.h"] + path = arena.h + url = ssh://gitea@188.157.159.51:8122/prenex/arena.h.git diff --git a/VirtualMemList.hpp b/VirtualMemList.hpp index e0cd345..915f24f 100644 --- a/VirtualMemList.hpp +++ b/VirtualMemList.hpp @@ -1,6 +1,6 @@ #ifndef VIRTUAL_MEM_LIST_H #define VIRTUAL_MEM_LIST_H -#include "arena.h" +#include "arena.h/arena.h" #ifndef VML_NOINLINE #define VML_NOINLINE __attribute__((noinline)) @@ -29,7 +29,7 @@ class VirtualMemList { public: VML_INLINE VirtualMemList(uint32_t initial_size = 0) noexcept { a = newarena((ptrdiff_t)1 << 33); - base = ((T*) alloc(&a, sizeof(T), sizeof(T), 1)) + 1; + base = ((T*) aralloc(&a, sizeof(T), sizeof(T), 1)) + 1; end = initial_size; } @@ -46,11 +46,11 @@ public: // base[end++] = elem; // Non-working, but logically better solution: - // T *value = (T*) alloc(&a, sizeof(T), sizeof(T), 1); + // T *value = (T*) aralloc(&a, sizeof(T), sizeof(T), 1); // *value = elem; // Longer solution (more correct - but I let it waste a bit of memory) - T *value = (T*) alloc(&a, sizeof(T), sizeof(T), 1); + T *value = (T*) aralloc(&a, sizeof(T), sizeof(T), 1); base[end++] = elem; } diff --git a/arena.h b/arena.h new file mode 160000 index 0000000..3037bf6 --- /dev/null +++ b/arena.h @@ -0,0 +1 @@ +Subproject commit 3037bf6bec96b0ebc231510d308da1daece276fd diff --git a/main.cpp b/main.cpp index 8a302c7..d5498ae 100644 --- a/main.cpp +++ b/main.cpp @@ -10,7 +10,7 @@ #define TLT int #include "turbolist.h" -#include"arena.h" +#include"arena.h/arena.h" // #define PRINT_DBG // #define N 65535 @@ -133,7 +133,7 @@ int main() { // malloc-like [](size_t size) { static thread_local arena a = newarena((ptrdiff_t)1 << 33); - return (void*) alloc(&a, sizeof(uint8_t), sizeof(uint8_t), size); + return (void*) aralloc(&a, sizeof(uint8_t), sizeof(uint8_t), size); }, // free-like [](void *ptr) {}, @@ -174,29 +174,29 @@ int main() { arena a9 = newarena((ptrdiff_t)1 << 33); */ // steps at first real elem, there should be N from here! - int *arenalist = ((int*)alloc(&a, sizeof(int), sizeof(int), 1)) + 1; + int *arenalist = ((int *)aralloc(&a, sizeof(int), sizeof(int), 1)) + 1; for(int i = 0; i < N; ++i) { - int *value = (int*)alloc(&a, sizeof(int), sizeof(int), 1); + int *value = (int *)aralloc(&a, sizeof(int), sizeof(int), 1); *value = i; /* - value = (int*)alloc(&a1, sizeof(int), sizeof(int), 1); + value = (int*)aralloc(&a1, sizeof(int), sizeof(int), 1); *value = i; - value = (int*)alloc(&a2, sizeof(int), sizeof(int), 1); + value = (int*)aralloc(&a2, sizeof(int), sizeof(int), 1); *value = i; - value = (int*)alloc(&a3, sizeof(int), sizeof(int), 1); + value = (int*)aralloc(&a3, sizeof(int), sizeof(int), 1); *value = i; - value = (int*)alloc(&a4, sizeof(int), sizeof(int), 1); + value = (int*)aralloc(&a4, sizeof(int), sizeof(int), 1); *value = i; - value = (int*)alloc(&a5, sizeof(int), sizeof(int), 1); + value = (int*)aralloc(&a5, sizeof(int), sizeof(int), 1); *value = i; - value = (int*)alloc(&a6, sizeof(int), sizeof(int), 1); + value = (int*)aralloc(&a6, sizeof(int), sizeof(int), 1); *value = i; - value = (int*)alloc(&a7, sizeof(int), sizeof(int), 1); + value = (int*)aralloc(&a7, sizeof(int), sizeof(int), 1); *value = i; - value = (int*)alloc(&a8, sizeof(int), sizeof(int), 1); + value = (int*)aralloc(&a8, sizeof(int), sizeof(int), 1); *value = i; - value = (int*)alloc(&a9, sizeof(int), sizeof(int), 1); + value = (int*)aralloc(&a9, sizeof(int), sizeof(int), 1); *value = i; */ }