Skip to content

Commit c334b3b

Browse files
author
Youssef ahmed
committed
feat: add windows support
1 parent f7d25f5 commit c334b3b

File tree

4 files changed

+21
-2
lines changed

4 files changed

+21
-2
lines changed

go.mod

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
module github.com/joetifa2003/mm-go
22

3-
go 1.19
3+
go 1.20
44

55
require (
66
github.com/ebitengine/purego v0.4.0-alpha.4

malloc/malloc.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ func getSystemLibrary() string {
2626
}
2727

2828
func init() {
29-
libc, err := purego.Dlopen(getSystemLibrary(), purego.RTLD_NOW|purego.RTLD_GLOBAL)
29+
libc, err := openLibrary(getSystemLibrary())
3030
if err != nil {
3131
panic(err)
3232
}

malloc/malloc_unix.go

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
//go:build darwin || linux
2+
3+
package malloc
4+
5+
import "github.com/ebitengine/purego"
6+
7+
func openLibrary(name string) (uintptr, error) {
8+
return purego.Dlopen(name, purego.RTLD_NOW|purego.RTLD_GLOBAL)
9+
}

malloc/malloc_windows.go

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
//go:build windows
2+
3+
package malloc
4+
5+
import "golang.org/x/sys/windows"
6+
7+
func openLibrary(name string) (uintptr, error) {
8+
handle, err := windows.LoadLibrary(name)
9+
return uintptr(handle), err
10+
}

0 commit comments

Comments
 (0)