Add a build system
This commit is contained in:
29
platform.c
29
platform.c
@@ -247,13 +247,6 @@ typedef struct {
|
||||
void *arg;
|
||||
} ThreadWrapper;
|
||||
|
||||
static void *thread_start_routine(void *arg) {
|
||||
ThreadWrapper *wrapper = (ThreadWrapper *)arg;
|
||||
void *result = wrapper->func(wrapper->arg);
|
||||
free(wrapper);
|
||||
return result;
|
||||
}
|
||||
|
||||
// Thread creation function
|
||||
static int thread_create(Thread *thread, ThreadFunc func, void *arg) {
|
||||
int ret = pthread_create(&thread->handle, NULL, func, arg);
|
||||
@@ -1200,9 +1193,9 @@ static int close_ioring(ThreadIoContext *thread_ctx) {
|
||||
(IORING_BUFFER_INFO) { .Address = (a), .Length = (uint32_t)(l) }
|
||||
|
||||
static int ioring_submit(ThreadIoContext *thread_ctx, uint32_t wait_count,
|
||||
uint32_t timeout_ms, uint32_t *submitted) {
|
||||
HRESULT hr = SubmitIoRing(thread_ctx->ring, 0, timeout_ms, submitted);
|
||||
// HRESULT hr = SubmitIoRing(ring, wait_count, timeout_ms, submitted);
|
||||
uint32_t *submitted) {
|
||||
HRESULT hr = SubmitIoRing(thread_ctx->ring, 0, SUBMIT_TIMEOUT_MS, submitted);
|
||||
// HRESULT hr = SubmitIoRing(ring, wait_count, SUBMIT_TIMEOUT_MS, submitted);
|
||||
|
||||
// The wait_count in windows is not implemented yet, so we wait with a
|
||||
// completion event for a single completion
|
||||
@@ -1214,7 +1207,6 @@ static int ioring_submit(ThreadIoContext *thread_ctx, uint32_t wait_count,
|
||||
}
|
||||
|
||||
static void ioring_register_buffers(ThreadIoContext *thread_ctx,
|
||||
uint32_t num_buffers,
|
||||
IORING_BUFFER_INFO *buf_info) {
|
||||
|
||||
HRESULT hr = BuildIoRingRegisterBuffers(
|
||||
@@ -1230,7 +1222,7 @@ static void ioring_register_buffers(ThreadIoContext *thread_ctx,
|
||||
error_msg, (unsigned int)hr);
|
||||
}
|
||||
// Submit registration
|
||||
ioring_submit(thread_ctx, 0, 0, NULL);
|
||||
ioring_submit(thread_ctx, 0, NULL);
|
||||
}
|
||||
|
||||
#if USE_REGISTERED_FILES
|
||||
@@ -1429,11 +1421,10 @@ static int close_ioring(ThreadIoContext *thread_ctx) {
|
||||
(IORING_BUFFER_INFO) { .iov_base = (a), .iov_len = (size_t)(l) }
|
||||
|
||||
static void ioring_register_buffers(ThreadIoContext *thread_ctx,
|
||||
uint32_t num_buffers,
|
||||
IORING_BUFFER_INFO *buf_info) {
|
||||
|
||||
int ret = io_uring_register_buffers(&((IoUring *)thread_ctx->ring)->ring,
|
||||
buf_info, num_buffers);
|
||||
buf_info, NUM_BUFFERS_PER_THREAD);
|
||||
|
||||
if (ret < 0) {
|
||||
if (ret == -ENOMEM) {
|
||||
@@ -1540,7 +1531,7 @@ static int ioring_build_read(ThreadIoContext *thread_ctx,
|
||||
}
|
||||
|
||||
static int ioring_submit(ThreadIoContext *thread_ctx, uint32_t wait_count,
|
||||
uint32_t timeout_ms, uint32_t *submitted) {
|
||||
uint32_t *submitted) {
|
||||
int ret;
|
||||
|
||||
if (wait_count > 0) {
|
||||
@@ -1745,7 +1736,7 @@ static ThreadIoContext *ioring_init_thread(void) {
|
||||
thread_ctx->free_count = NUM_BUFFERS_PER_THREAD;
|
||||
|
||||
// Register buffers
|
||||
ioring_register_buffers(thread_ctx, NUM_BUFFERS_PER_THREAD, buf_info);
|
||||
ioring_register_buffers(thread_ctx, buf_info);
|
||||
|
||||
#if USE_REGISTERED_FILES
|
||||
ioring_register_files(thread_ctx);
|
||||
@@ -1799,7 +1790,7 @@ static void return_buffer(ThreadIoContext *ctx, IoBuffer *buf) {
|
||||
}
|
||||
|
||||
// -------------------------- Process completions ---------------------------
|
||||
static void process_completions(ThreadIoContext *thread_ctx, FileQueue *fq) {
|
||||
static void process_completions(ThreadIoContext *thread_ctx) {
|
||||
IoRingCQE cqe;
|
||||
|
||||
while (ioring_pop_completion(thread_ctx->ring, &cqe) == 1) {
|
||||
@@ -2095,10 +2086,10 @@ static THREAD_RETURN hash_worker_ioring(void *arg) {
|
||||
wait_count = MIN(thread_ctx->num_submissions, NUM_BUFFERS_PER_THREAD - 6);
|
||||
|
||||
submitted = 0;
|
||||
ioring_submit(thread_ctx, wait_count, 0, &submitted);
|
||||
ioring_submit(thread_ctx, wait_count, &submitted);
|
||||
|
||||
// Process completions
|
||||
process_completions(thread_ctx, &fq);
|
||||
process_completions(thread_ctx);
|
||||
|
||||
#if IORING_DEBUG_STATS
|
||||
printf(
|
||||
|
||||
Reference in New Issue
Block a user