-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
bugfix, Issue #163: offset of g struct in TLS picked based on the val…
…ue of runtime.iscgo flag and runtime.buildVersion, instead of being fixed to -16
- Loading branch information
Showing
7 changed files
with
181 additions
and
22 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
package main | ||
|
||
/* | ||
char* foo(void) { return "hello, world!"; } | ||
*/ | ||
import "C" | ||
|
||
import "fmt" | ||
|
||
func main() { | ||
fmt.Println(C.GoString(C.foo())) | ||
} |
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
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 |
---|---|---|
@@ -0,0 +1,54 @@ | ||
package proc | ||
|
||
import ( | ||
"strconv" | ||
"strings" | ||
) | ||
|
||
type GoVersion struct { | ||
Major int | ||
Minor int | ||
Rev int | ||
} | ||
|
||
func parseVersionString(ver string) (GoVersion, bool) { | ||
if ver[:2] != "go" { | ||
return GoVersion{}, false | ||
} | ||
v := strings.SplitN(ver[2:], ".", 3) | ||
if len(v) != 3 { | ||
return GoVersion{}, false | ||
} | ||
|
||
var r GoVersion | ||
var err1, err2, err3 error | ||
|
||
r.Major, err1 = strconv.Atoi(v[0]) | ||
r.Minor, err2 = strconv.Atoi(v[1]) | ||
r.Rev, err3 = strconv.Atoi(v[2]) | ||
if err1 != nil || err2 != nil || err3 != nil { | ||
return GoVersion{}, false | ||
} | ||
|
||
return r, true | ||
} | ||
|
||
func (a *GoVersion) After(b GoVersion) bool { | ||
if a.Major < b.Major { | ||
return false | ||
} else if a.Major > b.Major { | ||
return true | ||
} | ||
|
||
if a.Minor < b.Minor { | ||
return false | ||
} else if a.Minor > b.Minor { | ||
return true | ||
} | ||
|
||
if a.Rev < b.Rev { | ||
return false | ||
} | ||
|
||
return true | ||
} |