refact API documentation
This commit is contained in:
parent
5c5d6eb1fb
commit
9521eca272
|
@ -74,17 +74,28 @@ target_include_directories(api INTERFACE "include/client")
|
||||||
# src
|
# src
|
||||||
add_subdirectory(source)
|
add_subdirectory(source)
|
||||||
|
|
||||||
# docs
|
# docs
|
||||||
|
# https://vicrucann.github.io/tutorials/quick-cmake-doxygen/
|
||||||
if(${BUILD_DOCS})
|
if(${BUILD_DOCS})
|
||||||
find_program(DOC_GENERATOR doxygen)
|
find_package(Doxygen)
|
||||||
if(NOT DOC_GENERATOR)
|
if (DOXYGEN_FOUND)
|
||||||
message("doxygen is not found, skip doc build")
|
# Build the doc
|
||||||
else()
|
set(DOXYGEN_IN ${CMAKE_SOURCE_DIR}/docs/Doxyfile.in)
|
||||||
execute_process(
|
set(DOXYGEN_OUT ${CMAKE_BINARY_DIR}/Doxyfile)
|
||||||
COMMAND doxygen ${CMAKE_SOURCE_DIR}/docs/Doxyfile
|
|
||||||
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
|
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})
|
endif(${BUILD_DOCS})
|
||||||
|
|
||||||
# tests (TODO)
|
# tests (TODO)
|
||||||
|
|
|
@ -40,5 +40,5 @@ option(
|
||||||
option(
|
option(
|
||||||
BUILD_DOCS
|
BUILD_DOCS
|
||||||
"If use doxygen build documents"
|
"If use doxygen build documents"
|
||||||
OFF
|
ON
|
||||||
)
|
)
|
|
@ -15,6 +15,9 @@
|
||||||
|
|
||||||
#include "vnodeDef.h"
|
#include "vnodeDef.h"
|
||||||
|
|
||||||
|
#define VNODE_HEAP_ALLOCATOR 0
|
||||||
|
#define VNODE_ARENA_ALLOCATOR 1
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
uint64_t tsize;
|
uint64_t tsize;
|
||||||
uint64_t used;
|
uint64_t used;
|
||||||
|
@ -22,9 +25,13 @@ typedef struct {
|
||||||
|
|
||||||
typedef struct SVArenaNode {
|
typedef struct SVArenaNode {
|
||||||
struct SVArenaNode *prev;
|
struct SVArenaNode *prev;
|
||||||
|
void * nptr;
|
||||||
|
char data[];
|
||||||
} SVArenaNode;
|
} SVArenaNode;
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
|
SVArenaNode *inuse;
|
||||||
|
SVArenaNode node;
|
||||||
} SVArenaAllocator;
|
} SVArenaAllocator;
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
|
@ -37,9 +44,43 @@ typedef struct {
|
||||||
};
|
};
|
||||||
} SVMemAllocator;
|
} SVMemAllocator;
|
||||||
|
|
||||||
SMemAllocator *vnodeCreateMemAllocator(int8_t type, uint64_t size) {
|
SMemAllocator *vnodeCreateMemAllocator(int8_t type, uint64_t tsize, uint64_t ssize /* step size only for arena */) {
|
||||||
/* TODO */
|
SMemAllocator * pma;
|
||||||
return NULL;
|
uint64_t msize;
|
||||||
|
SVMemAllocator *pva;
|
||||||
|
|
||||||
|
msize = sizeof(*pma) + sizeof(SVMemAllocator);
|
||||||
|
if (type == VNODE_ARENA_ALLOCATOR) {
|
||||||
|
msize += tsize;
|
||||||
|
}
|
||||||
|
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
|
||||||
|
return pma;
|
||||||
}
|
}
|
||||||
|
|
||||||
void vnodeDestroyMemAllocator(SMemAllocator *pma) {
|
void vnodeDestroyMemAllocator(SMemAllocator *pma) {
|
||||||
|
@ -56,45 +97,4 @@ void vnodeUnrefMemAllocator(SMemAllocator *pma) {
|
||||||
|
|
||||||
/* ------------------------ Heap Allocator IMPL ------------------------ */
|
/* ------------------------ Heap Allocator IMPL ------------------------ */
|
||||||
|
|
||||||
SMemAllocator *vhaCreate(uint64_t size) {
|
|
||||||
SMemAllocator *pma;
|
|
||||||
|
|
||||||
pma = (SMemAllocator *)calloc(1, sizeof(*pma) + sizeof(SVHeapAllocator));
|
|
||||||
if (pma == NULL) {
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
pma->impl = POINTER_SHIFT(pma, sizeof(*pma));
|
|
||||||
|
|
||||||
/* TODO */
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
void vhaDestroy(SMemAllocator *pma) { /* TODO */
|
|
||||||
}
|
|
||||||
|
|
||||||
static void *vhaMalloc(SMemAllocator *pma, uint64_t size) {
|
|
||||||
SVHeapAllocator *pvha = (SVHeapAllocator *)(pma->impl);
|
|
||||||
/* TODO */
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
static void *vhaCalloc(SMemAllocator *pma, size_t nmemb, uint64_t size) {
|
|
||||||
// todo
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
static void *vhaRealloc(SMemAllocator *pma, void *ptr, uint64_t size) {
|
|
||||||
/* TODO */
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
static void vhaFree(SMemAllocator *pma, void *ptr) { /* TODO */
|
|
||||||
}
|
|
||||||
|
|
||||||
static uint64_t vhaUsage(SMemAllocator *pma) {
|
|
||||||
/* TODO */
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* ------------------------ Arena Allocator IMPL ------------------------ */
|
/* ------------------------ Arena Allocator IMPL ------------------------ */
|
Loading…
Reference in New Issue