mirror of
https://github.com/Lurkki14/tuxclocker.git
synced 2025-02-25 18:55:24 -06:00
add module loading files
This commit is contained in:
parent
5d79e59db0
commit
fb044ba9f2
2
.gitignore
vendored
Normal file
2
.gitignore
vendored
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
build
|
||||||
|
/*kdev*
|
@ -9,9 +9,15 @@ enum tc_module_category {
|
|||||||
TC_CATEGORY_INTERFACE
|
TC_CATEGORY_INTERFACE
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// Function name the module loader uses to get the module_t describing the module
|
||||||
|
#define TC_MODULE_INFO_FUNCTION_NAME "tc_get_module_handle"
|
||||||
|
|
||||||
typedef struct tc_module_t {
|
typedef struct tc_module_t {
|
||||||
enum tc_module_category category;
|
enum tc_module_category category;
|
||||||
|
// Short name of the module like nvidia, qt
|
||||||
const char *name;
|
const char *name;
|
||||||
|
// Longer description
|
||||||
|
const char *description;
|
||||||
|
|
||||||
// Initializes the module's internal state
|
// Initializes the module's internal state
|
||||||
int8_t (*init_callback)();
|
int8_t (*init_callback)();
|
||||||
@ -19,3 +25,12 @@ typedef struct tc_module_t {
|
|||||||
int8_t (*close_callback)();
|
int8_t (*close_callback)();
|
||||||
|
|
||||||
} tc_module_t;
|
} tc_module_t;
|
||||||
|
|
||||||
|
// Try to return the module handle matching the category and name. If it doesn't exist or there was a problem loading the module, returns NULL.
|
||||||
|
tc_module_t *tc_module_find(enum tc_module_category category, const char *name);
|
||||||
|
|
||||||
|
// Wrappers for platform-specific functions for loading libraries (modules) at runtime
|
||||||
|
void *tc_dlopen(const char *path);
|
||||||
|
void *tc_dlsym(void *handle, const char *name);
|
||||||
|
void tc_dlclose(void *handle);
|
||||||
|
char *tc_dlerror();
|
||||||
|
1
src/lib/posix/meson.build
Normal file
1
src/lib/posix/meson.build
Normal file
@ -0,0 +1 @@
|
|||||||
|
|
9
src/lib/posix/module.c
Normal file
9
src/lib/posix/module.c
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
#include <tc_module.h>
|
||||||
|
#include <tc_common.h>
|
||||||
|
|
||||||
|
#include <dlfcn.h>
|
||||||
|
|
||||||
|
void *tc_dlopen(const char *path) {
|
||||||
|
return dlopen(path, RTLD_LAZY);
|
||||||
|
}
|
||||||
|
|
8
src/lib/tc_module.c
Normal file
8
src/lib/tc_module.c
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
#include <stddef.h>
|
||||||
|
|
||||||
|
#include <tc_module.h>
|
||||||
|
|
||||||
|
|
||||||
|
tc_module_t *tc_module_find(enum tc_module_category category, const char *name) {
|
||||||
|
return NULL;
|
||||||
|
}
|
4
src/main/meson.build
Normal file
4
src/main/meson.build
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
executable('tuxclocker',
|
||||||
|
'tuxclocker.c',
|
||||||
|
include_directories : incdir,
|
||||||
|
link_with : libtuxclocker)
|
@ -1 +1,12 @@
|
|||||||
// Main executable for TuxClocker. Responsible for loading an interface
|
// Main executable for TuxClocker. Responsible for loading an interface
|
||||||
|
|
||||||
|
#include <tc_common.h>
|
||||||
|
#include <tc_module.h>
|
||||||
|
|
||||||
|
#include <stdio.h>
|
||||||
|
|
||||||
|
int main(int argc, char **argv) {
|
||||||
|
// Load an interface here
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
@ -1,7 +1,16 @@
|
|||||||
# Define libtuxclocker target here since others depend on it
|
# Define libtuxclocker target here since others depend on it
|
||||||
|
|
||||||
|
libtuxclocker_posix_sources = ['lib/posix/module.c']
|
||||||
|
|
||||||
|
libtuxclocker_posix_libs = [cc.find_library('dl')]
|
||||||
|
|
||||||
libtuxclocker = shared_library('libtuxclocker',
|
libtuxclocker = shared_library('libtuxclocker',
|
||||||
['lib/tc_assignable.c'],
|
['lib/tc_assignable.c',
|
||||||
include_directories : incdir)
|
'lib/tc_module.c',
|
||||||
|
libtuxclocker_posix_sources],
|
||||||
|
include_directories : incdir,
|
||||||
|
dependencies : libtuxclocker_posix_libs)
|
||||||
|
|
||||||
subdir('modules')
|
subdir('modules')
|
||||||
|
subdir('main')
|
||||||
subdir('lib')
|
subdir('lib')
|
||||||
|
@ -5,9 +5,11 @@
|
|||||||
|
|
||||||
#include <tc_assignable.h>
|
#include <tc_assignable.h>
|
||||||
#include <tc_common.h>
|
#include <tc_common.h>
|
||||||
|
#include <tc_module.h>
|
||||||
|
|
||||||
#define MAX_GPUS 32
|
#define MAX_GPUS 32
|
||||||
|
|
||||||
|
|
||||||
// Local function declarations
|
// Local function declarations
|
||||||
static int8_t init();
|
static int8_t init();
|
||||||
static int8_t close();
|
static int8_t close();
|
||||||
|
Loading…
Reference in New Issue
Block a user