Sync to the latest version.

Can be broken or partially implemented.
This commit is contained in:
2024-04-23 23:45:43 +03:00
parent ec499b6cfc
commit 692b5b4297
26 changed files with 785 additions and 60 deletions

View File

View File

12
include/bh/internal/io.h Normal file
View File

@@ -0,0 +1,12 @@
#ifndef BHLIB_INTERNAL_IO_H
#define BHLIB_INTERNAL_IO_H
#include <bh/io.h>
void bh_io_init(bh_io_t *io,
bh_io_table_t *table);
void bh_io_destroy(bh_io_t *io);
#endif /* BHLIB_INTERNAL_IO_H */

View File

@@ -0,0 +1,28 @@
struct bh_thread_s
{
void *handle;
};
struct bh_mutex_s
{
void *handle;
};
struct bh_cond_s
{
void *handle;
};
int bh_thread_init(bh_thread_t *thread,
bh_task_t *task);
int bh_mutex_init(bh_mutex_t *mutex);
void bh_mutex_destroy(bh_mutex_t *mutex);
int bh_cond_init(bh_cond_t *cond);
void bh_cond_destroy(bh_cond_t *cond);
int bh_thread_pool_init(bh_thread_pool_t *pool,
size_t size);
void bh_thread_pool_destroy(bh_thread_pool_t *pool);

View File

@@ -3,6 +3,7 @@
struct bh_thread_s
{
pthread_t handle;
int allocated;
};
struct bh_mutex_s
@@ -27,4 +28,4 @@ void bh_cond_destroy(bh_cond_t *cond);
int bh_thread_pool_init(bh_thread_pool_t *pool,
size_t size);
void bh_thread_pool_destroy(bh_thread_pool_t *pool);
void bh_thread_pool_destroy(bh_thread_pool_t *pool);

View File

@@ -0,0 +1,48 @@
#include <process.h>
struct bh_thread_s
{
HANDLE handle;
int allocated;
};
struct bh_thread_data_s
{
bh_task_t *task;
bh_thread_end_cb_t end;
} bh_thread_data_t;
struct bh_mutex_s
{
CRITICAL_SECTION handle;
};
struct bh_cond_s
{
void *handle;
};
int bh_thread_init_base(bh_thread_t *thread,
bh_task_t *task,
bh_thread_begin_cb_t begin,
bh_thread_end_cb_t end);
#define bh_thread_init(thread, task) \
bh_thread_init_base((thread), (task), _beginthreadex, _endthreadex)
int bh_mutex_init(bh_mutex_t *mutex);
void bh_mutex_destroy(bh_mutex_t *mutex);
int bh_cond_init(bh_cond_t *cond);
void bh_cond_destroy(bh_cond_t *cond);
int bh_thread_pool_init_base(bh_thread_pool_t *pool,
size_t size,
bh_thread_begin_cb_t begin,
bh_thread_end_cb_t end);
#define bh_thread_pool_init(pool, size) \
bh_thread_pool_init_base((pool), (size), _beginthreadex, _endthreadex)
void bh_thread_pool_destroy(bh_thread_pool_t *pool);