From acc91bc260046e228d8043e91d33d6793fb41c1a Mon Sep 17 00:00:00 2001 From: midipix Date: Sat, 25 May 2024 18:18:11 +0000 Subject: driver: implemented internal queue vectorization. --- src/logic/tpax_queue_vector.c | 60 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 60 insertions(+) create mode 100644 src/logic/tpax_queue_vector.c (limited to 'src/logic/tpax_queue_vector.c') diff --git a/src/logic/tpax_queue_vector.c b/src/logic/tpax_queue_vector.c new file mode 100644 index 0000000..092f39f --- /dev/null +++ b/src/logic/tpax_queue_vector.c @@ -0,0 +1,60 @@ +/**************************************************************/ +/* tpax: a topological pax implementation */ +/* Copyright (C) 2020--2024 SysDeer Technologies, LLC */ +/* Released under GPLv2 and GPLv3; see COPYING.TPAX. */ +/**************************************************************/ + +#include +#include + +#include +#include "tpax_driver_impl.h" +#include "tpax_errinfo_impl.h" +#include "tpax_visibility_impl.h" + +tpax_hidden int tpax_update_queue_vector(const struct tpax_driver_ctx * dctx) +{ + uintptr_t addr; + struct tpax_driver_ctx_impl * ictx; + struct tpax_dirent_buffer * dentbuf; + struct tpax_dirent ** direntv; + struct tpax_dirent * cdent; + struct tpax_dirent * cnext; + size_t arrsize; + + /* driver */ + ictx = tpax_get_driver_ictx(dctx); + + /* vector alloc */ + if (ictx->direntv) + free(ictx->direntv); + + arrsize = ictx->nqueued + 1; + + if (!(ictx->direntv = calloc(arrsize,sizeof(struct tpax_dirent *)))) + return TPAX_SYSTEM_ERROR(dctx); + + if (ictx->nqueued == 0) + return 0; + + /* queue vector */ + dentbuf = tpax_get_driver_dirents(dctx); + cdent = dentbuf->dbuf; + + for (direntv=ictx->direntv; cdent; direntv++) { + *direntv = cdent; + + addr = (uintptr_t)cdent; + addr += cdent->nsize; + cnext = (struct tpax_dirent *)addr; + + if (cnext == dentbuf->cdent) { + dentbuf = dentbuf->next; + cnext = dentbuf ? dentbuf->dbuf : 0; + } + + cdent = cnext; + } + + return 0; +} -- cgit v1.2.3