Files
kotlin-fork/backend.native/tests/main.c
T
Alexander Gorshenev bd5b4b2f52 Annotation used
2016-11-30 17:45:07 +04:00

37 lines
709 B
C

#ifdef __linux__
# define _GNU_SOURCE
#endif
#include <dlfcn.h>
#include <stdlib.h>
#include <stdio.h>
/**
* > llc-mp-3.8 b.out -o b.S
* > /opt/local/libexec/llvm-3.8/bin/clang main.c b.S -o sum-test
*/
extern int run_test();
void * resolve_symbol(char *name) {
/* here we can add here some magic to resolve symbols in kotlin native*/
void* symbol = dlsym(RTLD_DEFAULT, name);
if (!symbol) {
printf("Could not find kotlin symbol '%s': %s\n", name, dlerror());
exit(1);
}
return symbol;
}
int
kotlinNativeMain() {
#ifdef RUN_TEST
void (*main)(void *) = resolve_symbol("kfun:main(Array<String>)");
main((void *)0);
return 0;
#else
exit(run_test());
#endif
}