Git Product home page Git Product logo

Comments (4)

AsterDY avatar AsterDY commented on August 16, 2024

didn't try before. Are you interested in giving a PR?

from sonic.

vendion avatar vendion commented on August 16, 2024

Well it is a very simple change as the syscalls for the BSDs should match those for Darwin (based on BSD anyways) & Linux so something like this should be more than enough:

diff --git a/loader/mmap_unix.go b/loader/mmap_unix.go
index 3ea944e..1d15e54 100644
--- a/loader/mmap_unix.go
+++ b/loader/mmap_unix.go
@@ -1,5 +1,5 @@
-//go:build darwin || linux
-// +build darwin linux
+//go:build !windows
+// +build !windows

 /**
  * Copyright 2023 ByteDance Inc.

Unless you have reasons for being explict in this case.

from sonic.

vendion avatar vendion commented on August 16, 2024

I didn't submit a PR, as it's a one line change and that the formatting of the file doesn't follow the standard gofmt standard so the whole flie would end up being needlessly modified.

diff --git a/loader/mmap_unix.go b/loader/mmap_unix.go
index 3ea944e..1d15e54 100644
--- a/loader/mmap_unix.go
+++ b/loader/mmap_unix.go
@@ -1,5 +1,5 @@
-//go:build darwin || linux
-// +build darwin linux
+//go:build !windows
+// +build !windows

 /**
  * Copyright 2023 ByteDance Inc.
@@ -20,26 +20,25 @@
 package loader

 import (
-    `syscall`
+	"syscall"
 )

 const (
-    _AP = syscall.MAP_ANON  | syscall.MAP_PRIVATE
-    _RX = syscall.PROT_READ | syscall.PROT_EXEC
-    _RW = syscall.PROT_READ | syscall.PROT_WRITE
+	_AP = syscall.MAP_ANON | syscall.MAP_PRIVATE
+	_RX = syscall.PROT_READ | syscall.PROT_EXEC
+	_RW = syscall.PROT_READ | syscall.PROT_WRITE
 )

-
 func mmap(nb int) uintptr {
-    if m, _, e := syscall.RawSyscall6(syscall.SYS_MMAP, 0, uintptr(nb), _RW, _AP, 0, 0); e != 0 {
-        panic(e)
-    } else {
-        return m
-    }
+	if m, _, e := syscall.RawSyscall6(syscall.SYS_MMAP, 0, uintptr(nb), _RW, _AP, 0, 0); e != 0 {
+		panic(e)
+	} else {
+		return m
+	}
 }

 func mprotect(p uintptr, nb int) {
-    if _, _, err := syscall.RawSyscall(syscall.SYS_MPROTECT, p, uintptr(nb), _RX); err != 0 {
-        panic(err)
-    }
+	if _, _, err := syscall.RawSyscall(syscall.SYS_MPROTECT, p, uintptr(nb), _RX); err != 0 {
+		panic(err)
+	}
 }

from sonic.

AsterDY avatar AsterDY commented on August 16, 2024

ok,I will submit it

from sonic.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.