Commit c70ff9f9 by Ian Lance Taylor

compiler, runtime: support and use single argument go:linkname

    
    The gc compiler has started permitting go:linkname comments with a
    single argument to mean that a function should be externally visible
    outside the package.  Implement this in the Go frontend.
    
    Change the libgo runtime package to use it, rather than repeating the
    name just to export a function.
    
    Remove a couple of unnecessary go:linkname comments on declarations.
    
    Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/192197

From-SVN: r275239
parent e7c8f755
80403eb9e95c9642ebabb4d7c43deedaa763211f 289d94b9e6303ec74649d1f08d418300f2b4d0fd
The first line of this file holds the git revision number of the last The first line of this file holds the git revision number of the last
merge done from the gofrontend repository. merge done from the gofrontend repository.
...@@ -2531,9 +2531,22 @@ Gogo::add_linkname(const std::string& go_name, bool is_exported, ...@@ -2531,9 +2531,22 @@ Gogo::add_linkname(const std::string& go_name, bool is_exported,
if (no == NULL) if (no == NULL)
go_error_at(loc, "%s is not defined", go_name.c_str()); go_error_at(loc, "%s is not defined", go_name.c_str());
else if (no->is_function()) else if (no->is_function())
no->func_value()->set_asm_name(ext_name); {
if (ext_name.empty())
no->func_value()->set_is_exported_by_linkname();
else
no->func_value()->set_asm_name(ext_name);
}
else if (no->is_function_declaration()) else if (no->is_function_declaration())
no->func_declaration_value()->set_asm_name(ext_name); {
if (ext_name.empty())
go_error_at(loc,
("//%<go:linkname%> missing external name "
"for declaration of %s"),
go_name.c_str());
else
no->func_declaration_value()->set_asm_name(ext_name);
}
else else
go_error_at(loc, go_error_at(loc,
("%s is not a function; " ("%s is not a function; "
...@@ -5465,7 +5478,8 @@ Function::Function(Function_type* type, Named_object* enclosing, Block* block, ...@@ -5465,7 +5478,8 @@ Function::Function(Function_type* type, Named_object* enclosing, Block* block,
calls_recover_(false), is_recover_thunk_(false), has_recover_thunk_(false), calls_recover_(false), is_recover_thunk_(false), has_recover_thunk_(false),
calls_defer_retaddr_(false), is_type_specific_function_(false), calls_defer_retaddr_(false), is_type_specific_function_(false),
in_unique_section_(false), export_for_inlining_(false), in_unique_section_(false), export_for_inlining_(false),
is_inline_only_(false), is_referenced_by_inline_(false) is_inline_only_(false), is_referenced_by_inline_(false),
is_exported_by_linkname_(false)
{ {
} }
...@@ -6220,6 +6234,11 @@ Function::get_or_make_decl(Gogo* gogo, Named_object* no) ...@@ -6220,6 +6234,11 @@ Function::get_or_make_decl(Gogo* gogo, Named_object* no)
if (this->is_referenced_by_inline_) if (this->is_referenced_by_inline_)
flags |= Backend::function_is_visible; flags |= Backend::function_is_visible;
// A go:linkname directive can be used to force a function to be
// visible.
if (this->is_exported_by_linkname_)
flags |= Backend::function_is_visible;
// If a function calls the predeclared recover function, we // If a function calls the predeclared recover function, we
// can't inline it, because recover behaves differently in a // can't inline it, because recover behaves differently in a
// function passed directly to defer. If this is a recover // function passed directly to defer. If this is a recover
......
...@@ -547,7 +547,9 @@ class Gogo ...@@ -547,7 +547,9 @@ class Gogo
{ this->file_block_names_[name] = location; } { this->file_block_names_[name] = location; }
// Add a linkname, from the go:linkname compiler directive. This // Add a linkname, from the go:linkname compiler directive. This
// changes the externally visible name of go_name to be ext_name. // changes the externally visible name of GO_NAME to be EXT_NAME.
// If EXT_NAME is the empty string, GO_NAME is unchanged, but the
// symbol is made publicly visible.
void void
add_linkname(const std::string& go_name, bool is_exported, add_linkname(const std::string& go_name, bool is_exported,
const std::string& ext_name, Location location); const std::string& ext_name, Location location);
...@@ -1359,6 +1361,11 @@ class Function ...@@ -1359,6 +1361,11 @@ class Function
set_asm_name(const std::string& asm_name) set_asm_name(const std::string& asm_name)
{ this->asm_name_ = asm_name; } { this->asm_name_ = asm_name; }
// Mark this symbol as exported by a linkname directive.
void
set_is_exported_by_linkname()
{ this->is_exported_by_linkname_ = true; }
// Return the pragmas for this function. // Return the pragmas for this function.
unsigned int unsigned int
pragmas() const pragmas() const
...@@ -1706,6 +1713,9 @@ class Function ...@@ -1706,6 +1713,9 @@ class Function
// True if this function is referenced from an inlined body that // True if this function is referenced from an inlined body that
// will be put into the export data. // will be put into the export data.
bool is_referenced_by_inline_ : 1; bool is_referenced_by_inline_ : 1;
// True if we should make this function visible to other packages
// because of a go:linkname directive.
bool is_exported_by_linkname_ : 1;
}; };
// A snapshot of the current binding state. // A snapshot of the current binding state.
......
...@@ -1996,7 +1996,7 @@ Lex::skip_cpp_comment() ...@@ -1996,7 +1996,7 @@ Lex::skip_cpp_comment()
while (ps < pend && *ps != ' ' && *ps != '\t') while (ps < pend && *ps != ' ' && *ps != '\t')
++ps; ++ps;
if (ps < pend) if (ps <= pend)
go_name = std::string(pg, ps - pg); go_name = std::string(pg, ps - pg);
while (ps < pend && (*ps == ' ' || *ps == '\t')) while (ps < pend && (*ps == ' ' || *ps == '\t'))
++ps; ++ps;
...@@ -2015,8 +2015,8 @@ Lex::skip_cpp_comment() ...@@ -2015,8 +2015,8 @@ Lex::skip_cpp_comment()
ext_name.clear(); ext_name.clear();
} }
} }
if (go_name.empty() || ext_name.empty()) if (go_name.empty())
go_error_at(loc, "usage: %<//go:linkname%> localname linkname"); go_error_at(loc, "usage: %<//go:linkname%> localname [linkname]");
else else
{ {
if (this->linknames_ == NULL) if (this->linknames_ == NULL)
......
...@@ -380,7 +380,7 @@ class Lex ...@@ -380,7 +380,7 @@ class Lex
struct Linkname struct Linkname
{ {
std::string ext_name; // External name. std::string ext_name; // External name; empty to just export.
bool is_exported; // Whether the internal name is exported. bool is_exported; // Whether the internal name is exported.
Location loc; // Location of go:linkname directive. Location loc; // Location of go:linkname directive.
......
...@@ -10,44 +10,43 @@ import ( ...@@ -10,44 +10,43 @@ import (
"unsafe" "unsafe"
) )
// For gccgo, use go:linkname to rename compiler-called functions to // For gccgo, use go:linkname to export compiler-called functions.
// themselves, so that the compiler will export them.
// //
//go:linkname memhash0 runtime.memhash0 //go:linkname memhash0
//go:linkname memhash8 runtime.memhash8 //go:linkname memhash8
//go:linkname memhash16 runtime.memhash16 //go:linkname memhash16
//go:linkname memhash32 runtime.memhash32 //go:linkname memhash32
//go:linkname memhash64 runtime.memhash64 //go:linkname memhash64
//go:linkname memhash128 runtime.memhash128 //go:linkname memhash128
//go:linkname strhash runtime.strhash //go:linkname strhash
//go:linkname f32hash runtime.f32hash //go:linkname f32hash
//go:linkname f64hash runtime.f64hash //go:linkname f64hash
//go:linkname c64hash runtime.c64hash //go:linkname c64hash
//go:linkname c128hash runtime.c128hash //go:linkname c128hash
//go:linkname interhash runtime.interhash //go:linkname interhash
//go:linkname nilinterhash runtime.nilinterhash //go:linkname nilinterhash
//go:linkname memequal0 runtime.memequal0 //go:linkname memequal0
//go:linkname memequal8 runtime.memequal8 //go:linkname memequal8
//go:linkname memequal16 runtime.memequal16 //go:linkname memequal16
//go:linkname memequal32 runtime.memequal32 //go:linkname memequal32
//go:linkname memequal64 runtime.memequal64 //go:linkname memequal64
//go:linkname memequal128 runtime.memequal128 //go:linkname memequal128
//go:linkname strequal runtime.strequal //go:linkname strequal
//go:linkname f32equal runtime.f32equal //go:linkname f32equal
//go:linkname f64equal runtime.f64equal //go:linkname f64equal
//go:linkname c64equal runtime.c64equal //go:linkname c64equal
//go:linkname c128equal runtime.c128equal //go:linkname c128equal
//go:linkname interequal runtime.interequal //go:linkname interequal
//go:linkname nilinterequal runtime.nilinterequal //go:linkname nilinterequal
//go:linkname efaceeq runtime.efaceeq //go:linkname efaceeq
//go:linkname ifaceeq runtime.ifaceeq //go:linkname ifaceeq
//go:linkname ifacevaleq runtime.ifacevaleq //go:linkname ifacevaleq
//go:linkname ifaceefaceeq runtime.ifaceefaceeq //go:linkname ifaceefaceeq
//go:linkname efacevaleq runtime.efacevaleq //go:linkname efacevaleq
//go:linkname cmpstring runtime.cmpstring //go:linkname cmpstring
// //
// Temporary to be called from C code. // Temporary to be called from C code.
//go:linkname alginit runtime.alginit //go:linkname alginit
const ( const (
c0 = uintptr((8-sys.PtrSize)/4*2860486313 + (sys.PtrSize-4)/4*33054211828000289) c0 = uintptr((8-sys.PtrSize)/4*2860486313 + (sys.PtrSize-4)/4*33054211828000289)
......
...@@ -12,8 +12,8 @@ import ( ...@@ -12,8 +12,8 @@ import (
) )
// Functions called by cgo-generated code. // Functions called by cgo-generated code.
//go:linkname cgoCheckPointer runtime.cgoCheckPointer //go:linkname cgoCheckPointer
//go:linkname cgoCheckResult runtime.cgoCheckResult //go:linkname cgoCheckResult
// Pointer checking for cgo code. // Pointer checking for cgo code.
......
...@@ -23,18 +23,17 @@ import ( ...@@ -23,18 +23,17 @@ import (
"unsafe" "unsafe"
) )
// For gccgo, use go:linkname to rename compiler-called functions to // For gccgo, use go:linkname to export compiler-called functions.
// themselves, so that the compiler will export them.
// //
//go:linkname makechan runtime.makechan //go:linkname makechan
//go:linkname makechan64 runtime.makechan64 //go:linkname makechan64
//go:linkname chansend1 runtime.chansend1 //go:linkname chansend1
//go:linkname chanrecv1 runtime.chanrecv1 //go:linkname chanrecv1
//go:linkname chanrecv2 runtime.chanrecv2 //go:linkname chanrecv2
//go:linkname closechan runtime.closechan //go:linkname closechan
//go:linkname selectnbsend runtime.selectnbsend //go:linkname selectnbsend
//go:linkname selectnbrecv runtime.selectnbrecv //go:linkname selectnbrecv
//go:linkname selectnbrecv2 runtime.selectnbrecv2 //go:linkname selectnbrecv2
const ( const (
maxAlign = 8 maxAlign = 8
......
...@@ -37,7 +37,7 @@ func ffi_type_void() *__ffi_type ...@@ -37,7 +37,7 @@ func ffi_type_void() *__ffi_type
func ffi_prep_cif(*_ffi_cif, _ffi_abi, uint32, *__ffi_type, **__ffi_type) _ffi_status func ffi_prep_cif(*_ffi_cif, _ffi_abi, uint32, *__ffi_type, **__ffi_type) _ffi_status
// ffiFuncToCIF is called from C code. // ffiFuncToCIF is called from C code.
//go:linkname ffiFuncToCIF runtime.ffiFuncToCIF //go:linkname ffiFuncToCIF
// ffiFuncToCIF builds an _ffi_cif struct for function described by ft. // ffiFuncToCIF builds an _ffi_cif struct for function described by ft.
func ffiFuncToCIF(ft *functype, isInterface bool, isMethod bool, cif *_ffi_cif) { func ffiFuncToCIF(ft *functype, isInterface bool, isMethod bool, cif *_ffi_cif) {
......
...@@ -12,10 +12,9 @@ package runtime ...@@ -12,10 +12,9 @@ package runtime
import "unsafe" import "unsafe"
// For gccgo, use go:linkname to rename compiler-called functions to // For gccgo, use go:linkname to export compiler-called functions.
// themselves, so that the compiler will export them.
// //
//go:linkname memhash runtime.memhash //go:linkname memhash
const ( const (
// Constants for multiplication: four random odd 32-bit numbers. // Constants for multiplication: four random odd 32-bit numbers.
......
...@@ -12,10 +12,9 @@ package runtime ...@@ -12,10 +12,9 @@ package runtime
import "unsafe" import "unsafe"
// For gccgo, use go:linkname to rename compiler-called functions to // For gccgo, use go:linkname to export compiler-called functions.
// themselves, so that the compiler will export them.
// //
//go:linkname memhash runtime.memhash //go:linkname memhash
const ( const (
// Constants for multiplication: four random odd 64-bit numbers. // Constants for multiplication: four random odd 64-bit numbers.
......
...@@ -10,23 +10,22 @@ import ( ...@@ -10,23 +10,22 @@ import (
"unsafe" "unsafe"
) )
// For gccgo, use go:linkname to rename compiler-called functions to // For gccgo, use go:linkname to export compiler-called functions.
// themselves, so that the compiler will export them.
// //
//go:linkname requireitab runtime.requireitab //go:linkname requireitab
//go:linkname assertitab runtime.assertitab //go:linkname assertitab
//go:linkname panicdottype runtime.panicdottype //go:linkname panicdottype
//go:linkname ifaceE2E2 runtime.ifaceE2E2 //go:linkname ifaceE2E2
//go:linkname ifaceI2E2 runtime.ifaceI2E2 //go:linkname ifaceI2E2
//go:linkname ifaceE2I2 runtime.ifaceE2I2 //go:linkname ifaceE2I2
//go:linkname ifaceI2I2 runtime.ifaceI2I2 //go:linkname ifaceI2I2
//go:linkname ifaceE2T2P runtime.ifaceE2T2P //go:linkname ifaceE2T2P
//go:linkname ifaceI2T2P runtime.ifaceI2T2P //go:linkname ifaceI2T2P
//go:linkname ifaceE2T2 runtime.ifaceE2T2 //go:linkname ifaceE2T2
//go:linkname ifaceI2T2 runtime.ifaceI2T2 //go:linkname ifaceI2T2
//go:linkname ifaceT2Ip runtime.ifaceT2Ip //go:linkname ifaceT2Ip
// Temporary for C code to call: // Temporary for C code to call:
//go:linkname getitab runtime.getitab //go:linkname getitab
// The gccgo itab structure is different than the gc one. // The gccgo itab structure is different than the gc one.
// //
......
...@@ -12,16 +12,15 @@ import ( ...@@ -12,16 +12,15 @@ import (
) )
// For gccgo, while we still have C runtime code, use go:linkname to // For gccgo, while we still have C runtime code, use go:linkname to
// rename some functions to themselves, so that the compiler will // export some functions.
// export them.
// //
//go:linkname lock runtime.lock //go:linkname lock
//go:linkname unlock runtime.unlock //go:linkname unlock
//go:linkname noteclear runtime.noteclear //go:linkname noteclear
//go:linkname notewakeup runtime.notewakeup //go:linkname notewakeup
//go:linkname notesleep runtime.notesleep //go:linkname notesleep
//go:linkname notetsleep runtime.notetsleep //go:linkname notetsleep
//go:linkname notetsleepg runtime.notetsleepg //go:linkname notetsleepg
// This implementation depends on OS-specific implementations of // This implementation depends on OS-specific implementations of
// //
......
...@@ -12,16 +12,15 @@ import ( ...@@ -12,16 +12,15 @@ import (
) )
// For gccgo, while we still have C runtime code, use go:linkname to // For gccgo, while we still have C runtime code, use go:linkname to
// rename some functions to themselves, so that the compiler will // export some functions.
// export them.
// //
//go:linkname lock runtime.lock //go:linkname lock
//go:linkname unlock runtime.unlock //go:linkname unlock
//go:linkname noteclear runtime.noteclear //go:linkname noteclear
//go:linkname notewakeup runtime.notewakeup //go:linkname notewakeup
//go:linkname notesleep runtime.notesleep //go:linkname notesleep
//go:linkname notetsleep runtime.notetsleep //go:linkname notetsleep
//go:linkname notetsleepg runtime.notetsleepg //go:linkname notetsleepg
// This implementation depends on OS-specific implementations of // This implementation depends on OS-specific implementations of
// //
......
...@@ -114,13 +114,12 @@ import ( ...@@ -114,13 +114,12 @@ import (
// C function to get the end of the program's memory. // C function to get the end of the program's memory.
func getEnd() uintptr func getEnd() uintptr
// For gccgo, use go:linkname to rename compiler-called functions to // For gccgo, use go:linkname to export compiler-called functions.
// themselves, so that the compiler will export them.
// //
//go:linkname newobject runtime.newobject //go:linkname newobject
// Functions called by C code. // Functions called by C code.
//go:linkname mallocgc runtime.mallocgc //go:linkname mallocgc
const ( const (
debugMalloc = false debugMalloc = false
......
...@@ -60,21 +60,20 @@ import ( ...@@ -60,21 +60,20 @@ import (
"unsafe" "unsafe"
) )
// For gccgo, use go:linkname to rename compiler-called functions to // For gccgo, use go:linkname to export compiler-called functions.
// themselves, so that the compiler will export them.
// //
//go:linkname makemap runtime.makemap //go:linkname makemap
//go:linkname makemap64 runtime.makemap64 //go:linkname makemap64
//go:linkname makemap_small runtime.makemap_small //go:linkname makemap_small
//go:linkname mapaccess1 runtime.mapaccess1 //go:linkname mapaccess1
//go:linkname mapaccess2 runtime.mapaccess2 //go:linkname mapaccess2
//go:linkname mapaccess1_fat runtime.mapaccess1_fat //go:linkname mapaccess1_fat
//go:linkname mapaccess2_fat runtime.mapaccess2_fat //go:linkname mapaccess2_fat
//go:linkname mapassign runtime.mapassign //go:linkname mapassign
//go:linkname mapdelete runtime.mapdelete //go:linkname mapdelete
//go:linkname mapclear runtime.mapclear //go:linkname mapclear
//go:linkname mapiterinit runtime.mapiterinit //go:linkname mapiterinit
//go:linkname mapiternext runtime.mapiternext //go:linkname mapiternext
const ( const (
// Maximum number of key/value pairs a bucket can hold. // Maximum number of key/value pairs a bucket can hold.
......
...@@ -9,14 +9,13 @@ import ( ...@@ -9,14 +9,13 @@ import (
"unsafe" "unsafe"
) )
// For gccgo, use go:linkname to rename compiler-called functions to // For gccgo, use go:linkname to export compiler-called functions.
// themselves, so that the compiler will export them.
// //
//go:linkname mapaccess1_fast32 runtime.mapaccess1_fast32 //go:linkname mapaccess1_fast32
//go:linkname mapaccess2_fast32 runtime.mapaccess2_fast32 //go:linkname mapaccess2_fast32
//go:linkname mapassign_fast32 runtime.mapassign_fast32 //go:linkname mapassign_fast32
//go:linkname mapassign_fast32ptr runtime.mapassign_fast32ptr //go:linkname mapassign_fast32ptr
//go:linkname mapdelete_fast32 runtime.mapdelete_fast32 //go:linkname mapdelete_fast32
func mapaccess1_fast32(t *maptype, h *hmap, key uint32) unsafe.Pointer { func mapaccess1_fast32(t *maptype, h *hmap, key uint32) unsafe.Pointer {
if raceenabled && h != nil { if raceenabled && h != nil {
......
...@@ -9,14 +9,13 @@ import ( ...@@ -9,14 +9,13 @@ import (
"unsafe" "unsafe"
) )
// For gccgo, use go:linkname to rename compiler-called functions to // For gccgo, use go:linkname to export compiler-called functions.
// themselves, so that the compiler will export them.
// //
//go:linkname mapaccess1_fast64 runtime.mapaccess1_fast64 //go:linkname mapaccess1_fast64
//go:linkname mapaccess2_fast64 runtime.mapaccess2_fast64 //go:linkname mapaccess2_fast64
//go:linkname mapassign_fast64 runtime.mapassign_fast64 //go:linkname mapassign_fast64
//go:linkname mapassign_fast64ptr runtime.mapassign_fast64ptr //go:linkname mapassign_fast64ptr
//go:linkname mapdelete_fast64 runtime.mapdelete_fast64 //go:linkname mapdelete_fast64
func mapaccess1_fast64(t *maptype, h *hmap, key uint64) unsafe.Pointer { func mapaccess1_fast64(t *maptype, h *hmap, key uint64) unsafe.Pointer {
if raceenabled && h != nil { if raceenabled && h != nil {
......
...@@ -9,13 +9,12 @@ import ( ...@@ -9,13 +9,12 @@ import (
"unsafe" "unsafe"
) )
// For gccgo, use go:linkname to rename compiler-called functions to // For gccgo, use go:linkname to export compiler-called functions.
// themselves, so that the compiler will export them.
// //
//go:linkname mapaccess1_faststr runtime.mapaccess1_faststr //go:linkname mapaccess1_faststr
//go:linkname mapaccess2_faststr runtime.mapaccess2_faststr //go:linkname mapaccess2_faststr
//go:linkname mapassign_faststr runtime.mapassign_faststr //go:linkname mapassign_faststr
//go:linkname mapdelete_faststr runtime.mapdelete_faststr //go:linkname mapdelete_faststr
func mapaccess1_faststr(t *maptype, h *hmap, ky string) unsafe.Pointer { func mapaccess1_faststr(t *maptype, h *hmap, ky string) unsafe.Pointer {
if raceenabled && h != nil { if raceenabled && h != nil {
......
...@@ -18,12 +18,11 @@ import ( ...@@ -18,12 +18,11 @@ import (
"unsafe" "unsafe"
) )
// For gccgo, use go:linkname to rename compiler-called functions to // For gccgo, use go:linkname to export compiler-called functions.
// themselves, so that the compiler will export them.
// //
//go:linkname typedmemmove runtime.typedmemmove //go:linkname typedmemmove
//go:linkname typedslicecopy runtime.typedslicecopy //go:linkname typedslicecopy
//go:linkname memclrHasPointers runtime.memclrHasPointers //go:linkname memclrHasPointers
// Go uses a hybrid barrier that combines a Yuasa-style deletion // Go uses a hybrid barrier that combines a Yuasa-style deletion
// barrier—which shades the object whose reference is being // barrier—which shades the object whose reference is being
......
...@@ -12,8 +12,8 @@ import ( ...@@ -12,8 +12,8 @@ import (
) )
// Functions called by C code. // Functions called by C code.
//go:linkname sysAlloc runtime.sysAlloc //go:linkname sysAlloc
//go:linkname sysFree runtime.sysFree //go:linkname sysFree
//extern mmap //extern mmap
func sysMmap(addr unsafe.Pointer, n uintptr, prot, flags, fd int32, off uintptr) unsafe.Pointer func sysMmap(addr unsafe.Pointer, n uintptr, prot, flags, fd int32, off uintptr) unsafe.Pointer
......
...@@ -11,10 +11,9 @@ import ( ...@@ -11,10 +11,9 @@ import (
"unsafe" "unsafe"
) )
// For gccgo, use go:linkname to rename compiler-called functions to // For gccgo, use go:linkname to export compiler-called functions.
// themselves, so that the compiler will export them.
// //
//go:linkname gcWriteBarrier runtime.gcWriteBarrier //go:linkname gcWriteBarrier
// gcRoot is a single GC root: a variable plus a ptrmask. // gcRoot is a single GC root: a variable plus a ptrmask.
//go:notinheap //go:notinheap
...@@ -130,7 +129,7 @@ func createGcRootsIndex() { ...@@ -130,7 +129,7 @@ func createGcRootsIndex() {
} }
// registerGCRoots is called by compiler-generated code. // registerGCRoots is called by compiler-generated code.
//go:linkname registerGCRoots runtime.registerGCRoots //go:linkname registerGCRoots
// registerGCRoots is called by init functions to register the GC // registerGCRoots is called by init functions to register the GC
// roots for a package. The init functions are run sequentially at // roots for a package. The init functions are run sequentially at
......
...@@ -1042,7 +1042,7 @@ func scanobject(b uintptr, gcw *gcWork) { ...@@ -1042,7 +1042,7 @@ func scanobject(b uintptr, gcw *gcWork) {
gcw.scanWork += int64(i) gcw.scanWork += int64(i)
} }
//go:linkname scanstackblock runtime.scanstackblock //go:linkname scanstackblock
// scanstackblock is called by the stack scanning code in C to // scanstackblock is called by the stack scanning code in C to
// actually find and mark pointers in the stack block. This is like // actually find and mark pointers in the stack block. This is like
...@@ -1064,7 +1064,7 @@ func scanstackblock(b, n uintptr, gcw *gcWork) { ...@@ -1064,7 +1064,7 @@ func scanstackblock(b, n uintptr, gcw *gcWork) {
// scanstackblockwithmap is like scanstackblock, but with an explicit // scanstackblockwithmap is like scanstackblock, but with an explicit
// pointer bitmap. This is used only when precise stack scan is enabled. // pointer bitmap. This is used only when precise stack scan is enabled.
//go:linkname scanstackblockwithmap runtime.scanstackblockwithmap //go:linkname scanstackblockwithmap
//go:nowritebarrier //go:nowritebarrier
func scanstackblockwithmap(pc, b0, n0 uintptr, ptrmask *uint8, gcw *gcWork) { func scanstackblockwithmap(pc, b0, n0 uintptr, ptrmask *uint8, gcw *gcWork) {
// Use local copies of original parameters, so that a stack trace // Use local copies of original parameters, so that a stack trace
......
...@@ -12,7 +12,7 @@ import ( ...@@ -12,7 +12,7 @@ import (
) )
// Export temporarily for gccgo's C code to call: // Export temporarily for gccgo's C code to call:
//go:linkname netpoll runtime.netpoll //go:linkname netpoll
// Integrated network poller (platform-independent part). // Integrated network poller (platform-independent part).
// A particular implementation (epoll/kqueue) must define the following functions: // A particular implementation (epoll/kqueue) must define the following functions:
......
...@@ -9,7 +9,7 @@ import ( ...@@ -9,7 +9,7 @@ import (
) )
// For C code to call: // For C code to call:
//go:linkname minit runtime.minit //go:linkname minit
func goenvs() { func goenvs() {
goenvs_unix() goenvs_unix()
......
...@@ -9,39 +9,38 @@ import ( ...@@ -9,39 +9,38 @@ import (
"unsafe" "unsafe"
) )
// For gccgo, use go:linkname to rename compiler-called functions to // For gccgo, use go:linkname to export compiler-called functions.
// themselves, so that the compiler will export them.
// //
//go:linkname deferproc runtime.deferproc //go:linkname deferproc
//go:linkname deferprocStack runtime.deferprocStack //go:linkname deferprocStack
//go:linkname deferreturn runtime.deferreturn //go:linkname deferreturn
//go:linkname setdeferretaddr runtime.setdeferretaddr //go:linkname setdeferretaddr
//go:linkname checkdefer runtime.checkdefer //go:linkname checkdefer
//go:linkname gopanic runtime.gopanic //go:linkname gopanic
//go:linkname canrecover runtime.canrecover //go:linkname canrecover
//go:linkname makefuncfficanrecover runtime.makefuncfficanrecover //go:linkname makefuncfficanrecover
//go:linkname makefuncreturning runtime.makefuncreturning //go:linkname makefuncreturning
//go:linkname gorecover runtime.gorecover //go:linkname gorecover
//go:linkname deferredrecover runtime.deferredrecover //go:linkname deferredrecover
//go:linkname goPanicIndex runtime.goPanicIndex //go:linkname goPanicIndex
//go:linkname goPanicIndexU runtime.goPanicIndexU //go:linkname goPanicIndexU
//go:linkname goPanicSliceAlen runtime.goPanicSliceAlen //go:linkname goPanicSliceAlen
//go:linkname goPanicSliceAlenU runtime.goPanicSliceAlenU //go:linkname goPanicSliceAlenU
//go:linkname goPanicSliceAcap runtime.goPanicSliceAcap //go:linkname goPanicSliceAcap
//go:linkname goPanicSliceAcapU runtime.goPanicSliceAcapU //go:linkname goPanicSliceAcapU
//go:linkname goPanicSliceB runtime.goPanicSliceB //go:linkname goPanicSliceB
//go:linkname goPanicSliceBU runtime.goPanicSliceBU //go:linkname goPanicSliceBU
//go:linkname goPanicSlice3Alen runtime.goPanicSlice3Alen //go:linkname goPanicSlice3Alen
//go:linkname goPanicSlice3AlenU runtime.goPanicSlice3AlenU //go:linkname goPanicSlice3AlenU
//go:linkname goPanicSlice3Acap runtime.goPanicSlice3Acap //go:linkname goPanicSlice3Acap
//go:linkname goPanicSlice3AcapU runtime.goPanicSlice3AcapU //go:linkname goPanicSlice3AcapU
//go:linkname goPanicSlice3B runtime.goPanicSlice3B //go:linkname goPanicSlice3B
//go:linkname goPanicSlice3BU runtime.goPanicSlice3BU //go:linkname goPanicSlice3BU
//go:linkname goPanicSlice3C runtime.goPanicSlice3C //go:linkname goPanicSlice3C
//go:linkname goPanicSlice3CU runtime.goPanicSlice3CU //go:linkname goPanicSlice3CU
//go:linkname panicmem runtime.panicmem //go:linkname panicmem
// Temporary for C code to call: // Temporary for C code to call:
//go:linkname throw runtime.throw //go:linkname throw
// Check to make sure we can really generate a panic. If the panic // Check to make sure we can really generate a panic. If the panic
// was generated from the runtime, or from inside malloc, then convert // was generated from the runtime, or from inside malloc, then convert
......
...@@ -6,25 +6,24 @@ package runtime ...@@ -6,25 +6,24 @@ package runtime
import _ "unsafe" // for go:linkname import _ "unsafe" // for go:linkname
// For gccgo, use go:linkname to rename compiler-called functions to // For gccgo, use go:linkname to export compiler-called functions.
// themselves, so that the compiler will export them.
// //
//go:linkname goPanicExtendIndex runtime.goPanicExtendIndex //go:linkname goPanicExtendIndex
//go:linkname goPanicExtendIndexU runtime.goPanicExtendIndexU //go:linkname goPanicExtendIndexU
//go:linkname goPanicExtendSliceAlen runtime.goPanicExtendSliceAlen //go:linkname goPanicExtendSliceAlen
//go:linkname goPanicExtendSliceAlenU runtime.goPanicExtendSliceAlenU //go:linkname goPanicExtendSliceAlenU
//go:linkname goPanicExtendSliceAcap runtime.goPanicExtendSliceAcap //go:linkname goPanicExtendSliceAcap
//go:linkname goPanicExtendSliceAcapU runtime.goPanicExtendSliceAcapU //go:linkname goPanicExtendSliceAcapU
//go:linkname goPanicExtendSliceB runtime.goPanicExtendSliceB //go:linkname goPanicExtendSliceB
//go:linkname goPanicExtendSliceBU runtime.goPanicExtendSliceBU //go:linkname goPanicExtendSliceBU
//go:linkname goPanicExtendSlice3Alen runtime.goPanicExtendSlice3Alen //go:linkname goPanicExtendSlice3Alen
//go:linkname goPanicExtendSlice3AlenU runtime.goPanicExtendSlice3AlenU //go:linkname goPanicExtendSlice3AlenU
//go:linkname goPanicExtendSlice3Acap runtime.goPanicExtendSlice3Acap //go:linkname goPanicExtendSlice3Acap
//go:linkname goPanicExtendSlice3AcapU runtime.goPanicExtendSlice3AcapU //go:linkname goPanicExtendSlice3AcapU
//go:linkname goPanicExtendSlice3B runtime.goPanicExtendSlice3B //go:linkname goPanicExtendSlice3B
//go:linkname goPanicExtendSlice3BU runtime.goPanicExtendSlice3BU //go:linkname goPanicExtendSlice3BU
//go:linkname goPanicExtendSlice3C runtime.goPanicExtendSlice3C //go:linkname goPanicExtendSlice3C
//go:linkname goPanicExtendSlice3CU runtime.goPanicExtendSlice3CU //go:linkname goPanicExtendSlice3CU
// Additional index/slice error paths for 32-bit platforms. // Additional index/slice error paths for 32-bit platforms.
// Used when the high word of a 64-bit index is not zero. // Used when the high word of a 64-bit index is not zero.
......
...@@ -9,27 +9,26 @@ import ( ...@@ -9,27 +9,26 @@ import (
"unsafe" "unsafe"
) )
// For gccgo, use go:linkname to rename compiler-called functions to // For gccgo, use go:linkname to export compiler-called functions.
// themselves, so that the compiler will export them.
// //
//go:linkname printbool runtime.printbool //go:linkname printbool
//go:linkname printfloat runtime.printfloat //go:linkname printfloat
//go:linkname printint runtime.printint //go:linkname printint
//go:linkname printhex runtime.printhex //go:linkname printhex
//go:linkname printuint runtime.printuint //go:linkname printuint
//go:linkname printcomplex runtime.printcomplex //go:linkname printcomplex
//go:linkname printstring runtime.printstring //go:linkname printstring
//go:linkname printpointer runtime.printpointer //go:linkname printpointer
//go:linkname printiface runtime.printiface //go:linkname printiface
//go:linkname printeface runtime.printeface //go:linkname printeface
//go:linkname printslice runtime.printslice //go:linkname printslice
//go:linkname printnl runtime.printnl //go:linkname printnl
//go:linkname printsp runtime.printsp //go:linkname printsp
//go:linkname printlock runtime.printlock //go:linkname printlock
//go:linkname printunlock runtime.printunlock //go:linkname printunlock
// Temporary for C code to call: // Temporary for C code to call:
//go:linkname gwrite runtime.gwrite //go:linkname gwrite
//go:linkname printhex runtime.printhex //go:linkname printhex
// The compiler knows that a print of a value of this type // The compiler knows that a print of a value of this type
// should use printhex instead of printuint (decimal). // should use printhex instead of printuint (decimal).
......
...@@ -12,37 +12,37 @@ import ( ...@@ -12,37 +12,37 @@ import (
) )
// Functions called by C code. // Functions called by C code.
//go:linkname main runtime.main //go:linkname main
//go:linkname goparkunlock runtime.goparkunlock //go:linkname goparkunlock
//go:linkname newextram runtime.newextram //go:linkname newextram
//go:linkname acquirep runtime.acquirep //go:linkname acquirep
//go:linkname releasep runtime.releasep //go:linkname releasep
//go:linkname incidlelocked runtime.incidlelocked //go:linkname incidlelocked
//go:linkname ginit runtime.ginit //go:linkname ginit
//go:linkname schedinit runtime.schedinit //go:linkname schedinit
//go:linkname ready runtime.ready //go:linkname ready
//go:linkname stopm runtime.stopm //go:linkname stopm
//go:linkname handoffp runtime.handoffp //go:linkname handoffp
//go:linkname wakep runtime.wakep //go:linkname wakep
//go:linkname stoplockedm runtime.stoplockedm //go:linkname stoplockedm
//go:linkname schedule runtime.schedule //go:linkname schedule
//go:linkname execute runtime.execute //go:linkname execute
//go:linkname goexit1 runtime.goexit1 //go:linkname goexit1
//go:linkname reentersyscall runtime.reentersyscall //go:linkname reentersyscall
//go:linkname reentersyscallblock runtime.reentersyscallblock //go:linkname reentersyscallblock
//go:linkname exitsyscall runtime.exitsyscall //go:linkname exitsyscall
//go:linkname gfget runtime.gfget //go:linkname gfget
//go:linkname kickoff runtime.kickoff //go:linkname kickoff
//go:linkname mstart1 runtime.mstart1 //go:linkname mstart1
//go:linkname mexit runtime.mexit //go:linkname mexit
//go:linkname globrunqput runtime.globrunqput //go:linkname globrunqput
//go:linkname pidleget runtime.pidleget //go:linkname pidleget
// Exported for test (see runtime/testdata/testprogcgo/dropm_stub.go). // Exported for test (see runtime/testdata/testprogcgo/dropm_stub.go).
//go:linkname getm runtime.getm //go:linkname getm
// Function called by misc/cgo/test. // Function called by misc/cgo/test.
//go:linkname lockedOSThread runtime.lockedOSThread //go:linkname lockedOSThread
// C functions for thread and context management. // C functions for thread and context management.
func newosproc(*m) func newosproc(*m)
......
...@@ -14,10 +14,9 @@ import ( ...@@ -14,10 +14,9 @@ import (
//go:generate go run mkfastlog2table.go //go:generate go run mkfastlog2table.go
// For gccgo, while we still have C runtime code, use go:linkname to // For gccgo, while we still have C runtime code, use go:linkname to
// rename some functions to themselves, so that the compiler will // export some functions.
// export them.
// //
//go:linkname tickspersecond runtime.tickspersecond //go:linkname tickspersecond
var ticksLock mutex var ticksLock mutex
var ticksVal uint64 var ticksVal uint64
......
...@@ -11,16 +11,15 @@ import ( ...@@ -11,16 +11,15 @@ import (
) )
// For gccgo, while we still have C runtime code, use go:linkname to // For gccgo, while we still have C runtime code, use go:linkname to
// rename some functions to themselves, so that the compiler will // export some functions to themselves.
// export them.
// //
//go:linkname gotraceback runtime.gotraceback //go:linkname gotraceback
//go:linkname args runtime.args //go:linkname args
//go:linkname goargs runtime.goargs //go:linkname goargs
//go:linkname check runtime.check //go:linkname check
//go:linkname goenvs_unix runtime.goenvs_unix //go:linkname goenvs_unix
//go:linkname parsedebugvars runtime.parsedebugvars //go:linkname parsedebugvars
//go:linkname timediv runtime.timediv //go:linkname timediv
// Keep a cached value to make gotraceback fast, // Keep a cached value to make gotraceback fast,
// since we call it on every call to gentraceback. // since we call it on every call to gentraceback.
......
...@@ -930,7 +930,7 @@ type sigset _sigset_t ...@@ -930,7 +930,7 @@ type sigset _sigset_t
// getMemstats returns a pointer to the internal memstats variable, // getMemstats returns a pointer to the internal memstats variable,
// for C code. // for C code.
//go:linkname getMemstats runtime.getMemstats //go:linkname getMemstats
func getMemstats() *mstats { func getMemstats() *mstats {
return &memstats return &memstats
} }
...@@ -10,11 +10,10 @@ import ( ...@@ -10,11 +10,10 @@ import (
"unsafe" "unsafe"
) )
// For gccgo, use go:linkname to rename compiler-called functions to // For gccgo, use go:linkname to export compiler-called functions.
// themselves, so that the compiler will export them.
// //
//go:linkname selectgo runtime.selectgo //go:linkname selectgo
//go:linkname block runtime.block //go:linkname block
const debugSelect = false const debugSelect = false
......
...@@ -12,8 +12,8 @@ import ( ...@@ -12,8 +12,8 @@ import (
) )
// For gccgo's C code to call: // For gccgo's C code to call:
//go:linkname initsig runtime.initsig //go:linkname initsig
//go:linkname sigtrampgo runtime.sigtrampgo //go:linkname sigtrampgo
// sigTabT is the type of an entry in the global sigtable array. // sigTabT is the type of an entry in the global sigtable array.
// sigtable is inherently system dependent, and appears in OS-specific files, // sigtable is inherently system dependent, and appears in OS-specific files,
......
...@@ -10,14 +10,13 @@ import ( ...@@ -10,14 +10,13 @@ import (
"unsafe" "unsafe"
) )
// For gccgo, use go:linkname to rename compiler-called functions to // For gccgo, use go:linkname to export compiler-called functions.
// themselves, so that the compiler will export them.
// //
//go:linkname makeslice runtime.makeslice //go:linkname makeslice
//go:linkname makeslice64 runtime.makeslice64 //go:linkname makeslice64
//go:linkname growslice runtime.growslice //go:linkname growslice
//go:linkname slicecopy runtime.slicecopy //go:linkname slicecopy
//go:linkname slicestringcopy runtime.slicestringcopy //go:linkname slicestringcopy
type slice struct { type slice struct {
array unsafe.Pointer array unsafe.Pointer
......
...@@ -9,19 +9,18 @@ import ( ...@@ -9,19 +9,18 @@ import (
"unsafe" "unsafe"
) )
// For gccgo, use go:linkname to rename compiler-called functions to // For gccgo, use go:linkname to export compiler-called functions.
// themselves, so that the compiler will export them.
// //
//go:linkname concatstrings runtime.concatstrings //go:linkname concatstrings
//go:linkname slicebytetostring runtime.slicebytetostring //go:linkname slicebytetostring
//go:linkname slicebytetostringtmp runtime.slicebytetostringtmp //go:linkname slicebytetostringtmp
//go:linkname stringtoslicebyte runtime.stringtoslicebyte //go:linkname stringtoslicebyte
//go:linkname stringtoslicerune runtime.stringtoslicerune //go:linkname stringtoslicerune
//go:linkname slicerunetostring runtime.slicerunetostring //go:linkname slicerunetostring
//go:linkname intstring runtime.intstring //go:linkname intstring
// Temporary for C code to call: // Temporary for C code to call:
//go:linkname gostringnocopy runtime.gostringnocopy //go:linkname gostringnocopy
//go:linkname findnull runtime.findnull //go:linkname findnull
// The constant is known to the compiler. // The constant is known to the compiler.
// There is no fundamental theory behind this number. // There is no fundamental theory behind this number.
......
...@@ -165,7 +165,6 @@ func breakpoint() ...@@ -165,7 +165,6 @@ func breakpoint()
func asminit() {} func asminit() {}
//go:linkname reflectcall runtime.reflectcall
//go:noescape //go:noescape
func reflectcall(fntype *functype, fn *funcval, isInterface, isMethod bool, params, results *unsafe.Pointer) func reflectcall(fntype *functype, fn *funcval, isInterface, isMethod bool, params, results *unsafe.Pointer)
...@@ -280,13 +279,13 @@ func osyield() ...@@ -280,13 +279,13 @@ func osyield()
func syscall(trap uintptr, a1, a2, a3, a4, a5, a6 uintptr) uintptr func syscall(trap uintptr, a1, a2, a3, a4, a5, a6 uintptr) uintptr
// For gccgo, to communicate from the C code to the Go code. // For gccgo, to communicate from the C code to the Go code.
//go:linkname setIsCgo runtime.setIsCgo //go:linkname setIsCgo
func setIsCgo() { func setIsCgo() {
iscgo = true iscgo = true
} }
// For gccgo, to communicate from the C code to the Go code. // For gccgo, to communicate from the C code to the Go code.
//go:linkname setSupportAES runtime.setSupportAES //go:linkname setSupportAES
func setSupportAES(v bool) { func setSupportAES(v bool) {
support_aes = v support_aes = v
} }
...@@ -320,7 +319,7 @@ func dumpregs(*_siginfo_t, unsafe.Pointer) ...@@ -320,7 +319,7 @@ func dumpregs(*_siginfo_t, unsafe.Pointer)
func setRandomNumber(uint32) func setRandomNumber(uint32)
// Called by gccgo's proc.c. // Called by gccgo's proc.c.
//go:linkname allocg runtime.allocg //go:linkname allocg
func allocg() *g { func allocg() *g {
return new(g) return new(g)
} }
...@@ -368,17 +367,16 @@ func abort() ...@@ -368,17 +367,16 @@ func abort()
var usestackmaps bool var usestackmaps bool
// probestackmaps detects whether there are stack maps. // probestackmaps detects whether there are stack maps.
//go:linkname probestackmaps runtime.probestackmaps
func probestackmaps() bool func probestackmaps() bool
// For the math/bits packages for gccgo. // For the math/bits packages for gccgo.
//go:linkname getDivideError runtime.getDivideError //go:linkname getDivideError
func getDivideError() error { func getDivideError() error {
return divideError return divideError
} }
// For the math/bits packages for gccgo. // For the math/bits packages for gccgo.
//go:linkname getOverflowError runtime.getOverflowError //go:linkname getOverflowError
func getOverflowError() error { func getOverflowError() error {
return overflowError return overflowError
} }
...@@ -179,7 +179,7 @@ var typelistLock mutex ...@@ -179,7 +179,7 @@ var typelistLock mutex
// type descriptors. // type descriptors.
// p points to a list of *typeDescriptorList, n is the length // p points to a list of *typeDescriptorList, n is the length
// of the list. // of the list.
//go:linkname registerTypeDescriptors runtime.registerTypeDescriptors //go:linkname registerTypeDescriptors
func registerTypeDescriptors(n int, p unsafe.Pointer) { func registerTypeDescriptors(n int, p unsafe.Pointer) {
*(*slice)(unsafe.Pointer(&typelist.lists)) = slice{p, n, n} *(*slice)(unsafe.Pointer(&typelist.lists)) = slice{p, n, n}
} }
......
...@@ -6,10 +6,9 @@ package runtime ...@@ -6,10 +6,9 @@ package runtime
import _ "unsafe" // For go:linkname. import _ "unsafe" // For go:linkname.
// For gccgo, use go:linkname to rename compiler-called functions to // For gccgo, use go:linkname to export compiler-called functions.
// themselves, so that the compiler will export them.
// //
//go:linkname decoderune runtime.decoderune //go:linkname decoderune
// Numbers fundamental to the encoding. // Numbers fundamental to the encoding.
const ( const (
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment