]> Cypherpunks repositories - gostls13.git/commitdiff
runtime: os.Executable runtime support for Darwin
authorShenghou Ma <minux@golang.org>
Sun, 1 Nov 2015 09:16:52 +0000 (04:16 -0500)
committerBrad Fitzpatrick <bradfitz@golang.org>
Mon, 7 Nov 2016 20:18:36 +0000 (20:18 +0000)
Change-Id: Ie21df37016c90cd0479c23ec4845f8195dd90fda
Reviewed-on: https://go-review.googlesource.com/16518
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: Russ Cox <rsc@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>

src/runtime/os_darwin.go
src/runtime/vdso_none.go

index 0dfe8778db39da0b8792f662699b023da69372b9..15281674aedc41fc27b0abea4e907cb096f1a820 100644 (file)
@@ -551,3 +551,21 @@ func sigaddset(mask *sigset, i int) {
 func sigdelset(mask *sigset, i int) {
        *mask &^= 1 << (uint32(i) - 1)
 }
+
+//go:linkname executablePath os.executablePath
+var executablePath string
+
+func sysargs(argc int32, argv **byte) {
+       // skip over argv, envv and the first string will be the path
+       n := argc + 1
+       for argv_index(argv, n) != nil {
+               n++
+       }
+       executablePath = gostringnocopy(argv_index(argv, n+1))
+
+       // strip "executable_path=" prefix if available, it's added after OS X 10.11.
+       const prefix = "executable_path="
+       if len(executablePath) > len(prefix) && executablePath[:len(prefix)] == prefix {
+               executablePath = executablePath[len(prefix):]
+       }
+}
index efae23f6eeb907821425f54dc78f49d1b9c97cb5..fc2124040fdaba36f9b86621245ed43a36c72128 100644 (file)
@@ -3,6 +3,7 @@
 // license that can be found in the LICENSE file.
 
 // +build !linux
+// +build !darwin
 
 package runtime