mirror of
https://github.com/djhackersdev/bemanitools.git
synced 2026-09-15 11:55:10 -05:00
Compare commits
2 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
ea835b32ee | ||
|
|
fb1442b734 |
31
src/api/log.h
Normal file
31
src/api/log.h
Normal file
@@ -0,0 +1,31 @@
|
||||
#ifndef BEMANITOOLS_API_THREAD_H
|
||||
#define BEMANITOOLS_API_THREAD_H
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#ifdef __GNUC__
|
||||
/* Bemanitools is compiled with GCC (MinGW, specifically) as of version 5 */
|
||||
#define LOG_CHECK_FMT __attribute__((format(printf, 2, 3)))
|
||||
#else
|
||||
/* Compile it out for MSVC plebs */
|
||||
#define LOG_CHECK_FMT
|
||||
#endif
|
||||
|
||||
/* An AVS-style logger function. Comes in four flavors: misc, info, warning,
|
||||
and fatal, with increasing severity. Fatal loggers do not return, they
|
||||
abort the running process after writing their message to the log.
|
||||
|
||||
"module" is an arbitrary short string identifying the source of the log
|
||||
message. The name of the calling DLL is a good default choice for this
|
||||
string, although you might want to identify a module within your DLL here
|
||||
instead.
|
||||
|
||||
"fmt" is a printf-style format string. Depending on the context in which
|
||||
your DLL is running you might end up calling a logger function exported
|
||||
from libavs, which has its own printf implementation (including a number of
|
||||
proprietary extensions), so don't use any overly exotic formats. */
|
||||
|
||||
typedef void (*btapi_log_formatter_t)(const char *module, const char *fmt, ...)
|
||||
LOG_CHECK_FMT;
|
||||
|
||||
#endif
|
||||
20
src/api/thread.h
Normal file
20
src/api/thread.h
Normal file
@@ -0,0 +1,20 @@
|
||||
#ifndef BEMANITOOLS_API_THREAD_H
|
||||
#define BEMANITOOLS_API_THREAD_H
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
/* An API for spawning threads. This API is defined by libavs, although
|
||||
Bemanitools itself may supply compatible implementations of these functions
|
||||
to your DLL, depending on the context in which it runs.
|
||||
|
||||
NOTE: You may only use the logging functions from a thread where Bemanitools
|
||||
calls you, or a thread that you create using this API. Failure to observe
|
||||
this restriction will cause the process to crash. This is a limitation of
|
||||
libavs itself, not Bemanitools. */
|
||||
|
||||
typedef int (*btapi_thread_create_t)(
|
||||
int (*proc)(void *), void *ctx, uint32_t stack_sz, unsigned int priority);
|
||||
typedef void (*btapi_thread_join_t)(int thread_id, int *result);
|
||||
typedef void (*btapi_thread_destroy_t)(int thread_id);
|
||||
|
||||
#endif
|
||||
@@ -3,4 +3,5 @@ libs += avs-util
|
||||
libs_avs-util := \
|
||||
|
||||
src_avs-util := \
|
||||
core-interop.c \
|
||||
error.c \
|
||||
|
||||
16
src/main/avs-util/core-interop.c
Normal file
16
src/main/avs-util/core-interop.c
Normal file
@@ -0,0 +1,16 @@
|
||||
#include "core/log.h"
|
||||
#include "core/thread.h"
|
||||
|
||||
#include "imports/avs.h"
|
||||
|
||||
void avs_util_core_interop_log_avs_impl_set()
|
||||
{
|
||||
core_log_impl_set(
|
||||
log_body_misc, log_body_info, log_body_warning, log_body_fatal);
|
||||
}
|
||||
|
||||
void avs_util_core_interop_thread_avs_impl_set()
|
||||
{
|
||||
core_thread_impl_set(
|
||||
avs_thread_create, avs_thread_join, avs_thread_destroy);
|
||||
}
|
||||
7
src/main/avs-util/core-interop.h
Normal file
7
src/main/avs-util/core-interop.h
Normal file
@@ -0,0 +1,7 @@
|
||||
#ifndef AVS_UTIL_CORE_INTEROP_H
|
||||
#define AVS_UTIL_CORE_INTEROP_H
|
||||
|
||||
void avs_util_core_interop_log_avs_impl_set();
|
||||
void avs_util_core_interop_thread_avs_impl_set();
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user