diff --git a/CMakeLists.txt b/CMakeLists.txt index 538d761e16dfae5855d96a51a3640cbbf0e34773..adeaa2ae0a78ad1400ae050745c117f7dcabae6f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -74,17 +74,28 @@ target_include_directories(api INTERFACE "include/client") # src add_subdirectory(source) -# docs +# docs +# https://vicrucann.github.io/tutorials/quick-cmake-doxygen/ if(${BUILD_DOCS}) - find_program(DOC_GENERATOR doxygen) - if(NOT DOC_GENERATOR) - message("doxygen is not found, skip doc build") - else() - execute_process( - COMMAND doxygen ${CMAKE_SOURCE_DIR}/docs/Doxyfile - WORKING_DIRECTORY ${CMAKE_SOURCE_DIR} + find_package(Doxygen) + if (DOXYGEN_FOUND) + # Build the doc + set(DOXYGEN_IN ${CMAKE_SOURCE_DIR}/docs/Doxyfile.in) + set(DOXYGEN_OUT ${CMAKE_BINARY_DIR}/Doxyfile) + + configure_file(${DOXYGEN_IN} ${DOXYGEN_OUT} @ONLY) + message("Doxygen build start") + + add_custom_target( + tdengine_doxygen ALL + COMMAND ${DOXYGEN_EXECUTABLE} ${DOXYGEN_OUT} + WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} + COMMENT "Generating API doxumentation with Doxygen" + VERBATIM ) - endif(NOT DOC_GENERATOR) + else(DOXYGEN_FOUND) + message("Doxygen need to be installed to generate the doxygen documentation") + endif(DOXYGEN_FOUND) endif(${BUILD_DOCS}) # tests (TODO) diff --git a/cmake/cmake.options b/cmake/cmake.options index 88f2b88fa639e2c39c0a70632a5b47132f15922a..7b5aeb8e652f4537efd65f6ec103124f6ec96126 100644 --- a/cmake/cmake.options +++ b/cmake/cmake.options @@ -40,5 +40,5 @@ option( option( BUILD_DOCS "If use doxygen build documents" - OFF + ON ) \ No newline at end of file diff --git a/docs/Doxyfile b/docs/Doxyfile.in similarity index 100% rename from docs/Doxyfile rename to docs/Doxyfile.in diff --git a/source/dnode/vnode/impl/src/vnodeMemAllocator.c b/source/dnode/vnode/impl/src/vnodeMemAllocator.c index a61b8808da87abc0e2c875f89ad6fe0f4a447e43..3771a14113f1802aace28ecde6c5a3a0c7b1c4bd 100644 --- a/source/dnode/vnode/impl/src/vnodeMemAllocator.c +++ b/source/dnode/vnode/impl/src/vnodeMemAllocator.c @@ -15,6 +15,9 @@ #include "vnodeDef.h" +#define VNODE_HEAP_ALLOCATOR 0 +#define VNODE_ARENA_ALLOCATOR 1 + typedef struct { uint64_t tsize; uint64_t used; @@ -22,9 +25,13 @@ typedef struct { typedef struct SVArenaNode { struct SVArenaNode *prev; + void * nptr; + char data[]; } SVArenaNode; typedef struct { + SVArenaNode *inuse; + SVArenaNode node; } SVArenaAllocator; typedef struct { @@ -37,64 +44,57 @@ typedef struct { }; } SVMemAllocator; -SMemAllocator *vnodeCreateMemAllocator(int8_t type, uint64_t size) { - /* TODO */ - return NULL; -} - -void vnodeDestroyMemAllocator(SMemAllocator *pma) { - // TODO -} - -void vnodeRefMemAllocator(SMemAllocator *pma) { - // TODO -} - -void vnodeUnrefMemAllocator(SMemAllocator *pma) { - // TODO -} - -/* ------------------------ Heap Allocator IMPL ------------------------ */ +SMemAllocator *vnodeCreateMemAllocator(int8_t type, uint64_t tsize, uint64_t ssize /* step size only for arena */) { + SMemAllocator * pma; + uint64_t msize; + SVMemAllocator *pva; -SMemAllocator *vhaCreate(uint64_t size) { - SMemAllocator *pma; + msize = sizeof(*pma) + sizeof(SVMemAllocator); + if (type == VNODE_ARENA_ALLOCATOR) { + msize += tsize; + } - pma = (SMemAllocator *)calloc(1, sizeof(*pma) + sizeof(SVHeapAllocator)); + pma = (SMemAllocator *)calloc(1, msize); if (pma == NULL) { return NULL; } pma->impl = POINTER_SHIFT(pma, sizeof(*pma)); + pva = (SVMemAllocator *)(pma->impl); + pva->type = type; + pva->tsize = tsize; + + if (type == VNODE_HEAP_ALLOCATOR) { + pma->malloc = NULL; + pma->calloc = NULL; + pma->realloc = NULL; + pma->free = NULL; + pma->usage = NULL; + } else if (type == VNODE_ARENA_ALLOCATOR) { + pma->malloc = NULL; + pma->calloc = NULL; + pma->realloc = NULL; + pma->free = NULL; + pma->usage = NULL; + } else { + ASSERT(0); + } - /* TODO */ - return NULL; -} - -void vhaDestroy(SMemAllocator *pma) { /* TODO */ -} - -static void *vhaMalloc(SMemAllocator *pma, uint64_t size) { - SVHeapAllocator *pvha = (SVHeapAllocator *)(pma->impl); - /* TODO */ - return NULL; + return pma; } -static void *vhaCalloc(SMemAllocator *pma, size_t nmemb, uint64_t size) { - // todo - return NULL; +void vnodeDestroyMemAllocator(SMemAllocator *pma) { + // TODO } -static void *vhaRealloc(SMemAllocator *pma, void *ptr, uint64_t size) { - /* TODO */ - return NULL; +void vnodeRefMemAllocator(SMemAllocator *pma) { + // TODO } -static void vhaFree(SMemAllocator *pma, void *ptr) { /* TODO */ +void vnodeUnrefMemAllocator(SMemAllocator *pma) { + // TODO } -static uint64_t vhaUsage(SMemAllocator *pma) { - /* TODO */ - return 0; -} +/* ------------------------ Heap Allocator IMPL ------------------------ */ /* ------------------------ Arena Allocator IMPL ------------------------ */ \ No newline at end of file