Add documentation, expand error handling, implement file and buffer io
This commit is contained in:
20
include/bh/internal/buffer.h
Normal file
20
include/bh/internal/buffer.h
Normal file
@@ -0,0 +1,20 @@
|
||||
#ifndef BH_INTERNAL_BUFFER_H
|
||||
#define BH_INTERNAL_BUFFER_H
|
||||
|
||||
#include <bh/buffer.h>
|
||||
|
||||
struct bh_buffer_s
|
||||
{
|
||||
bh_io_t base;
|
||||
char *data;
|
||||
size_t capacity;
|
||||
size_t size;
|
||||
size_t at;
|
||||
int mode;
|
||||
};
|
||||
|
||||
int bh_buffer_init(bh_buffer_t *buffer);
|
||||
|
||||
void bh_buffer_destroy(bh_buffer_t *buffer);
|
||||
|
||||
#endif /* BH_INTERNAL_BUFFER_H */
|
||||
20
include/bh/internal/file.h
Normal file
20
include/bh/internal/file.h
Normal file
@@ -0,0 +1,20 @@
|
||||
#ifndef BH_INTERNAL_FILE_H
|
||||
#define BH_INTERNAL_FILE_H
|
||||
|
||||
#include "io.h"
|
||||
#include <bh/file.h>
|
||||
|
||||
#if defined(BH_PLATFORM_POSIX)
|
||||
#include "file_posix.h"
|
||||
#elif defined(BH_PLATFORM_WIN)
|
||||
#include "file_win.h"
|
||||
#else
|
||||
#include "file_null.h"
|
||||
#endif
|
||||
|
||||
int bh_file_init(bh_file_t *file,
|
||||
const char *path);
|
||||
|
||||
void bh_file_destroy(bh_file_t *file);
|
||||
|
||||
#endif /* BH_INTERNAL_FILE_H */
|
||||
4
include/bh/internal/file_null.h
Normal file
4
include/bh/internal/file_null.h
Normal file
@@ -0,0 +1,4 @@
|
||||
struct bh_file_s
|
||||
{
|
||||
bh_io_t base;
|
||||
};
|
||||
@@ -0,0 +1,9 @@
|
||||
#include <unistd.h>
|
||||
|
||||
struct bh_file_s
|
||||
{
|
||||
bh_io_t base;
|
||||
char *path;
|
||||
int mode;
|
||||
int handle;
|
||||
};
|
||||
@@ -0,0 +1,9 @@
|
||||
#include <windows.h>
|
||||
|
||||
struct bh_file_s
|
||||
{
|
||||
bh_io_t base;
|
||||
char *path;
|
||||
int mode;
|
||||
HANDLE handle;
|
||||
};
|
||||
@@ -1,5 +1,5 @@
|
||||
#ifndef BHLIB_INTERNAL_HASHMAP_H
|
||||
#define BHLIB_INTERNAL_HASHMAP_H
|
||||
#ifndef BH_INTERNAL_HASHMAP_H
|
||||
#define BH_INTERNAL_HASHMAP_H
|
||||
|
||||
#include <bh/hashmap.h>
|
||||
|
||||
@@ -27,4 +27,4 @@ void bh_hashmap_init(bh_hashmap_t *hashmap,
|
||||
|
||||
void bh_hashmap_destroy(bh_hashmap_t *hashmap);
|
||||
|
||||
#endif /* BHLIB_INTERNAL_HASHMAP_H */
|
||||
#endif /* BH_INTERNAL_HASHMAP_H */
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
#ifndef BHLIB_INTERNAL_IO_H
|
||||
#define BHLIB_INTERNAL_IO_H
|
||||
#ifndef BH_INTERNAL_IO_H
|
||||
#define BH_INTERNAL_IO_H
|
||||
|
||||
#include <bh/io.h>
|
||||
|
||||
void bh_io_init(bh_io_t *io,
|
||||
bh_io_table_t *table);
|
||||
const bh_io_table_t *table);
|
||||
|
||||
void bh_io_destroy(bh_io_t *io);
|
||||
|
||||
#endif /* BHLIB_INTERNAL_IO_H */
|
||||
#endif /* BH_INTERNAL_IO_H */
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
#ifndef BHLIB_INTERNAL_QUEUE_H
|
||||
#define BHLIB_INTERNAL_QUEUE_H
|
||||
#ifndef BH_INTERNAL_QUEUE_H
|
||||
#define BH_INTERNAL_QUEUE_H
|
||||
|
||||
#include <bh/queue.h>
|
||||
|
||||
@@ -12,24 +12,8 @@ struct bh_queue_s
|
||||
size_t capacity;
|
||||
};
|
||||
|
||||
/**
|
||||
* @internal
|
||||
* @brief Initialize embedded queue object.
|
||||
*
|
||||
* @param queue Valid pointer to the queue object.
|
||||
*
|
||||
* @sa bh_queue_destroy
|
||||
*/
|
||||
void bh_queue_init(bh_queue_t *queue);
|
||||
|
||||
/**
|
||||
* @internal
|
||||
* @brief Destroy embedded queue object.
|
||||
*
|
||||
* @param queue Valid pointer to the queue object.
|
||||
*
|
||||
* @sa bh_queue_init
|
||||
*/
|
||||
void bh_queue_destroy(bh_queue_t *queue);
|
||||
|
||||
#endif /* BHLIB_INTERNAL_QUEUE_H */
|
||||
#endif /* BH_INTERNAL_QUEUE_H */
|
||||
|
||||
@@ -1,14 +1,14 @@
|
||||
#ifndef BHLIB_INTERNAL_THREAD_H
|
||||
#define BHLIB_INTERNAL_THREAD_H
|
||||
#ifndef BH_INTERNAL_THREAD_H
|
||||
#define BH_INTERNAL_THREAD_H
|
||||
|
||||
#include <bh/thread.h>
|
||||
#include "queue.h"
|
||||
|
||||
#define BH_THREAD_DONE (1 << 8)
|
||||
#define BH_THREAD_DONE 0x0100
|
||||
|
||||
#if defined(BHLIB_USE_PTHREAD)
|
||||
#if defined(BH_USE_PTHREAD)
|
||||
#include "thread_posix.h"
|
||||
#elif defined(BHLIB_USE_WINTHREAD)
|
||||
#elif defined(BH_USE_WINTHREAD)
|
||||
#include "thread_win.h"
|
||||
#else
|
||||
#include "thread_null.h"
|
||||
@@ -42,4 +42,4 @@ void bh_task_destroy(bh_task_t *task);
|
||||
|
||||
void bh_thread_pool_worker(void *arg);
|
||||
|
||||
#endif /* BHLIB_INTERNAL_THREAD_H */
|
||||
#endif /* BH_INTERNAL_THREAD_H */
|
||||
|
||||
@@ -50,7 +50,7 @@ int bh_thread_init_base(bh_thread_t *thread,
|
||||
int bh_mutex_init(bh_mutex_t *mutex);
|
||||
void bh_mutex_destroy(bh_mutex_t *mutex);
|
||||
|
||||
int bh_semaphore_init(bh_semaphore_t *semaphore,
|
||||
int bh_semaphore_init(bh_semaphore_t *semaphore,
|
||||
int count);
|
||||
void bh_semaphore_destroy(bh_semaphore_t *semaphore);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user