/*
int function(int);
#define DEFINE_JUMPER(x) \
void *_dyl_##x = (void*)0; \
__asm__(".global "#x"\n\t"#x":\n\tmovq _dyl_"#x"(%rip),%rax\n\tjmp *%rax\n")
DEFINE_JUMPER(function);
*/
import "C"
import (
"go4ml.xyz/dyl"
"runtime"
"unsafe"
)
func init() {
urlbase := "https://github.com/go4ml/nativelibs/releases/download/files/"
if runtime.GOOS == "linux" && runtime.GOARCH == "amd64"{
so := dyl.Load(
dyl.Cache("go4ml/dyl/libfunction.so"),
dyl.LzmaExternal(urlbase+"libfunction_lin64.xz"))
} else if runtime.GOOS == "windows" && runtime.GOARCH == "amd64" {
so := dyl.Load(
dyl.Cache("go4ml/dyl/function.dll"),
dyl.LzmaExternal(urlbase+"libfunction_win64.xz"))
}
so.Bind("function",unsafe.Pointer(&C._dyl_function))
}
func main() {
C.function(0)
}
-
Notifications
You must be signed in to change notification settings - Fork 0
Dynamic Library Loader
License
go4ml/dyl
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
About
Dynamic Library Loader
Resources
License
Stars
Watchers
Forks
Releases
No releases published
Packages 0
No packages published