mirror of
https://github.com/golang/go.git
synced 2025-12-08 06:10:04 +00:00
cmd/cgo: gccgo support for cgoCheckPointer
This uses weak declarations so that it will work with current versions of gccgo that do not support pointer checking. Change-Id: Ia34507e3231ac60517cb6834f0b673764715a256 Reviewed-on: https://go-review.googlesource.com/17429 Run-TryBot: Ian Lance Taylor <iant@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Russ Cox <rsc@golang.org>
This commit is contained in:
parent
2ae895c0ce
commit
fcbf04f9b9
1 changed files with 42 additions and 1 deletions
|
|
@ -103,6 +103,7 @@ func (p *Package) writeDefs() {
|
||||||
}
|
}
|
||||||
|
|
||||||
if *gccgo {
|
if *gccgo {
|
||||||
|
fmt.Fprint(fgo2, gccgoGoProlog)
|
||||||
fmt.Fprint(fc, p.cPrologGccgo())
|
fmt.Fprint(fc, p.cPrologGccgo())
|
||||||
} else {
|
} else {
|
||||||
fmt.Fprint(fgo2, goProlog)
|
fmt.Fprint(fgo2, goProlog)
|
||||||
|
|
@ -1288,6 +1289,12 @@ func _cgoCheckPointer(interface{}, ...interface{}) interface{}
|
||||||
func _cgoCheckResult(interface{})
|
func _cgoCheckResult(interface{})
|
||||||
`
|
`
|
||||||
|
|
||||||
|
const gccgoGoProlog = `
|
||||||
|
func _cgoCheckPointer(interface{}, ...interface{}) interface{}
|
||||||
|
|
||||||
|
func _cgoCheckResult(interface{})
|
||||||
|
`
|
||||||
|
|
||||||
const goStringDef = `
|
const goStringDef = `
|
||||||
//go:linkname _cgo_runtime_gostring runtime.gostring
|
//go:linkname _cgo_runtime_gostring runtime.gostring
|
||||||
func _cgo_runtime_gostring(*_Ctype_char) string
|
func _cgo_runtime_gostring(*_Ctype_char) string
|
||||||
|
|
@ -1340,7 +1347,8 @@ var builtinDefs = map[string]string{
|
||||||
}
|
}
|
||||||
|
|
||||||
func (p *Package) cPrologGccgo() string {
|
func (p *Package) cPrologGccgo() string {
|
||||||
return strings.Replace(cPrologGccgo, "PREFIX", cPrefix, -1)
|
return strings.Replace(strings.Replace(cPrologGccgo, "PREFIX", cPrefix, -1),
|
||||||
|
"GCCGOSYMBOLPREF", p.gccgoSymbolPrefix(), -1)
|
||||||
}
|
}
|
||||||
|
|
||||||
const cPrologGccgo = `
|
const cPrologGccgo = `
|
||||||
|
|
@ -1395,6 +1403,39 @@ void *_cgoPREFIX_Cfunc__CMalloc(size_t n) {
|
||||||
runtime_throw("runtime: C malloc failed");
|
runtime_throw("runtime: C malloc failed");
|
||||||
return p;
|
return p;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
struct __go_type_descriptor;
|
||||||
|
typedef struct __go_empty_interface {
|
||||||
|
const struct __go_type_descriptor *__type_descriptor;
|
||||||
|
void *__object;
|
||||||
|
} Eface;
|
||||||
|
|
||||||
|
extern Eface runtimeCgoCheckPointer(Eface, Slice)
|
||||||
|
__asm__("runtime.cgoCheckPointer")
|
||||||
|
__attribute__((weak));
|
||||||
|
|
||||||
|
extern Eface localCgoCheckPointer(Eface, Slice)
|
||||||
|
__asm__("GCCGOSYMBOLPREF._cgoCheckPointer");
|
||||||
|
|
||||||
|
Eface localCgoCheckPointer(Eface ptr, Slice args) {
|
||||||
|
if(runtimeCgoCheckPointer) {
|
||||||
|
return runtimeCgoCheckPointer(ptr, args);
|
||||||
|
}
|
||||||
|
return ptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
extern void runtimeCgoCheckResult(Eface)
|
||||||
|
__asm__("runtime.cgoCheckResult")
|
||||||
|
__attribute__((weak));
|
||||||
|
|
||||||
|
extern void localCgoCheckResult(Eface)
|
||||||
|
__asm__("GCCGOSYMBOLPREF._cgoCheckResult");
|
||||||
|
|
||||||
|
void localCgoCheckResult(Eface val) {
|
||||||
|
if(runtimeCgoCheckResult) {
|
||||||
|
runtimeCgoCheckResult(val);
|
||||||
|
}
|
||||||
|
}
|
||||||
`
|
`
|
||||||
|
|
||||||
func (p *Package) gccExportHeaderProlog() string {
|
func (p *Package) gccExportHeaderProlog() string {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue