Skip to content

Commit

Permalink
feat: add windows support
Browse files Browse the repository at this point in the history
  • Loading branch information
Youssef ahmed committed May 10, 2023
1 parent f7d25f5 commit c334b3b
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 2 deletions.
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module github.com/joetifa2003/mm-go

go 1.19
go 1.20

require (
github.com/ebitengine/purego v0.4.0-alpha.4
Expand Down
2 changes: 1 addition & 1 deletion malloc/malloc.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ func getSystemLibrary() string {
}

func init() {
libc, err := purego.Dlopen(getSystemLibrary(), purego.RTLD_NOW|purego.RTLD_GLOBAL)
libc, err := openLibrary(getSystemLibrary())
if err != nil {
panic(err)
}
Expand Down
9 changes: 9 additions & 0 deletions malloc/malloc_unix.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
//go:build darwin || linux

package malloc

import "github.com/ebitengine/purego"

func openLibrary(name string) (uintptr, error) {
return purego.Dlopen(name, purego.RTLD_NOW|purego.RTLD_GLOBAL)
}
10 changes: 10 additions & 0 deletions malloc/malloc_windows.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
//go:build windows

package malloc

import "golang.org/x/sys/windows"

func openLibrary(name string) (uintptr, error) {
handle, err := windows.LoadLibrary(name)
return uintptr(handle), err
}

0 comments on commit c334b3b

Please sign in to comment.