23#if defined(__windows__)
25#define EX_LIBRARY "kernel32.dll"
27#define EX_SYMBOL "GetTickCount"
28#elif defined(__APPLE__)
29#define EX_LIBRARY "libSystem.dylib"
30#define EX_SYMBOL "cos"
34#define EX_LIBRARY "libm.so.6"
36#define EX_SYMBOL "cos"
56 while ((opt = getopt(argc, argv,
"V:")) != -1) {
66int main(
int argc,
char** argv) {
72 fprintf(stderr,
"usage: %s [-V LOGLEVEL]\n", argv[0]);
80 module = n_module_open(EX_LIBRARY);
81 expect_true(
"the system library opens", module != NULL);
84 expect_true(
"its function is found", symbol != NULL);
85#if !defined(__windows__)
87 double (*fn)(double) = NULL;
89 memcpy((
void*)&fn, (
const void*)&symbol,
sizeof(fn));
90 expect_true(
"calling it gives cos(0) = 1", fn(0.0) == 1.0);
97 expect_true(
"close sets the handle to NULL", module == NULL);
102 module = n_module_open("n_module_no_such_library.so");
103 expect_true(
"a missing library is NULL", module == NULL);
static void expect_true(const char *label, int cond)
#define EX_SYMBOL
a function whose answer is known
static int parse_args(int argc, char **argv)
read -V LOGLEVEL
#define n_log(__LEVEL__,...)
Logging function wrapper to get line and func.
#define LOG_ERR
error conditions
void set_log_level(const int log_level)
Set the global log level value ( static int LOG_LEVEL ).
#define LOG_NOTICE
normal but significant condition
#define LOG_INFO
informational
const char * n_module_extension(void)
The file extension shared libraries have on this platform.
int n_module_close(N_MODULE **module)
Close a library and free its handle.
void * n_module_symbol(N_MODULE *module, const char *name)
Find a symbol in an opened library.
const char * n_module_error(void)
What the system said about this thread's last failed call.
Common headers and low-level functions & define.
Load a shared library at runtime and find its symbols.