-
Notifications
You must be signed in to change notification settings - Fork 316
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
12 changed files
with
59 additions
and
75 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,3 +3,9 @@ | |
|
||
package link | ||
|
||
import ( | ||
_ "embed" | ||
) | ||
|
||
//go:embed libsonic_rs_aarch64-apple-darwin.dylib | ||
var sonic_rs_blob []byte |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,40 +1,21 @@ | ||
// +build cgo | ||
// +build !cgo | ||
|
||
package link | ||
|
||
// #cgo LDFLAGS: -ldl | ||
// #include <dlfcn.h> | ||
import "C" | ||
import "unsafe" | ||
|
||
func DlOpen(filename string, flags int32) unsafe.Pointer { | ||
handle := C.dlopen(C.CString(filename), C.int(flags)) | ||
if handle == nil { | ||
panic("dlopen failed") | ||
} | ||
return handle | ||
panic("must enable cgo") | ||
} | ||
|
||
func DlClose(handle unsafe.Pointer) int32 { | ||
ret := int32(C.dlclose(handle)) | ||
if ret != 0 { | ||
panic("dlcolse failed") | ||
} | ||
return ret | ||
panic("must enable cgo") | ||
} | ||
|
||
func DlSym(handle unsafe.Pointer, symbol string) unsafe.Pointer { | ||
addr := C.dlsym(handle, C.CString(symbol)) | ||
if addr == nil { | ||
panic(DlError()) | ||
} | ||
return addr | ||
panic("must enable cgo") | ||
} | ||
|
||
func DlError() (err string) { | ||
cerr := C.dlerror() | ||
if cerr != nil { | ||
err = C.GoString(cerr) | ||
} | ||
return | ||
panic("must enable cgo") | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
// +build cgo | ||
|
||
package link | ||
|
||
// #cgo LDFLAGS: -ldl | ||
// #include <dlfcn.h> | ||
import "C" | ||
import "unsafe" | ||
|
||
func DlOpen(filename string, flags int32) unsafe.Pointer { | ||
handle := C.dlopen(C.CString(filename), C.int(flags)) | ||
if handle == nil { | ||
panic("dlopen failed") | ||
} | ||
return handle | ||
} | ||
|
||
func DlClose(handle unsafe.Pointer) int32 { | ||
ret := int32(C.dlclose(handle)) | ||
if ret != 0 { | ||
panic("dlcolse failed") | ||
} | ||
return ret | ||
} | ||
|
||
func DlSym(handle unsafe.Pointer, symbol string) unsafe.Pointer { | ||
addr := C.dlsym(handle, C.CString(symbol)) | ||
if addr == nil { | ||
panic(DlError()) | ||
} | ||
return addr | ||
} | ||
|
||
func DlError() (err string) { | ||
cerr := C.dlerror() | ||
if cerr != nil { | ||
err = C.GoString(cerr) | ||
} | ||
return | ||
} |
Binary file not shown.
This file was deleted.
Oops, something went wrong.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.