dyl

package module
v0.0.0-...-af222ab Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 20, 2020 License: Apache-2.0 Imports: 15 Imported by: 0

README

CircleCI Maintainability Test Coverage Go Report Card License

/*

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 (
	"go-ml.dev/dyl"
	"runtime"
	"unsafe"
)

func init() {
    urlbase := "https://github.com/sudachen/go-ml/nativelibs/releases/download/files/"
    if runtime.GOOS == "linux" && runtime.GOARCH == "amd64"{
        so := dyl.Load(
            dyl.Cache("go-ml/dyl/libfunction.so"),
            dyl.LzmaExternal(urlbase+"libfunction_lin64.lzma"))
    } else if runtime.GOOS == "windows" && runtime.GOARCH == "amd64" {
        so := dyl.Load(
            dyl.Cache("go-ml/dyl/function.dll"),
            dyl.LzmaExternal(urlbase+"libfunction_win64.lzma"))
    }
    so.Bind("function",unsafe.Pointer(&C._dyl_function))
}

func main() {
    C.function(0)
}

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Cached

type Cached string

Cached specifies cache file and enables loading file from the Internet

func (Cached) Preload

func (c Cached) Preload(a ...interface{})

Preload loads shared library from the Internet

func (Cached) Remove

func (c Cached) Remove() (err error)

Remove removes cached file

type Custom

type Custom string

Custom specifies full path to load specific shared library

func (Custom) Preload

func (c Custom) Preload(a ...interface{})

Preload loads shared library from the Internet

type External

type External string

External specifies url to the uncompressed shared library

type GzipExternal

type GzipExternal string

GzipExternal specifies url to the Gzip compressed shared library

type LzmaExternal

type LzmaExternal string

LzmaExternal specifies url to the LZMA2 compressed shared library

type OnError

type OnError func(error)

OnError defines function for error processing

type SO

type SO struct {
	// contains filtered or unexported fields
}

SO object incapacitates shared library handle

func Load

func Load(a ...interface{}) SO

Load finds and loads shared library. Can download library form the Internet if it's required

func (SO) Bind

func (so SO) Bind(funcname string, ptrptr unsafe.Pointer)

Bind binds the pointer to the shared library function

func (SO) Ok

func (so SO) Ok() bool

Ok returns true if SO object is associated with a shared library

type System

type System string

System specifies system shared dll

type Verbose

type Verbose func(string, int)

Verbose defines function to print information messages

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL