提交 9521eca2 编写于 作者: H Hongze Cheng

refact API documentation

上级 5c5d6eb1
......@@ -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)
......@@ -40,5 +40,5 @@ option(
option(
BUILD_DOCS
"If use doxygen build documents"
OFF
ON
)
\ No newline at end of file
......@@ -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
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册