diff options
author | Ian Lance Taylor <ian@gcc.gnu.org> | 2019-08-31 03:01:15 +0000 |
---|---|---|
committer | Ian Lance Taylor <ian@gcc.gnu.org> | 2019-08-31 03:01:15 +0000 |
commit | c70ff9f9be0c7360a37519ec68ac4dd41e8d0a3c (patch) | |
tree | 2a189fbed2324d7708bfe231203bd294028057c9 | |
parent | e7c8f75569e792f81a4f4ceee4e1b20f2544e7a4 (diff) | |
download | gcc-c70ff9f9be0c7360a37519ec68ac4dd41e8d0a3c.zip gcc-c70ff9f9be0c7360a37519ec68ac4dd41e8d0a3c.tar.gz gcc-c70ff9f9be0c7360a37519ec68ac4dd41e8d0a3c.tar.bz2 |
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
39 files changed, 297 insertions, 293 deletions
diff --git a/gcc/go/gofrontend/MERGE b/gcc/go/gofrontend/MERGE index 888e96d..025e66e 100644 --- a/gcc/go/gofrontend/MERGE +++ b/gcc/go/gofrontend/MERGE @@ -1,4 +1,4 @@ -80403eb9e95c9642ebabb4d7c43deedaa763211f +289d94b9e6303ec74649d1f08d418300f2b4d0fd The first line of this file holds the git revision number of the last merge done from the gofrontend repository. diff --git a/gcc/go/gofrontend/gogo.cc b/gcc/go/gofrontend/gogo.cc index f8114ece..d39a4fb 100644 --- a/gcc/go/gofrontend/gogo.cc +++ b/gcc/go/gofrontend/gogo.cc @@ -2531,9 +2531,22 @@ Gogo::add_linkname(const std::string& go_name, bool is_exported, if (no == NULL) go_error_at(loc, "%s is not defined", go_name.c_str()); 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()) - 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 go_error_at(loc, ("%s is not a function; " @@ -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_defer_retaddr_(false), is_type_specific_function_(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) if (this->is_referenced_by_inline_) 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 // can't inline it, because recover behaves differently in a // function passed directly to defer. If this is a recover diff --git a/gcc/go/gofrontend/gogo.h b/gcc/go/gofrontend/gogo.h index 087e890..e742b6e 100644 --- a/gcc/go/gofrontend/gogo.h +++ b/gcc/go/gofrontend/gogo.h @@ -547,7 +547,9 @@ class Gogo { this->file_block_names_[name] = location; } // 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 add_linkname(const std::string& go_name, bool is_exported, const std::string& ext_name, Location location); @@ -1359,6 +1361,11 @@ class Function set_asm_name(const std::string& 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. unsigned int pragmas() const @@ -1706,6 +1713,9 @@ class Function // True if this function is referenced from an inlined body that // will be put into the export data. 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. diff --git a/gcc/go/gofrontend/lex.cc b/gcc/go/gofrontend/lex.cc index 3276de4..f023613 100644 --- a/gcc/go/gofrontend/lex.cc +++ b/gcc/go/gofrontend/lex.cc @@ -1996,7 +1996,7 @@ Lex::skip_cpp_comment() while (ps < pend && *ps != ' ' && *ps != '\t') ++ps; - if (ps < pend) + if (ps <= pend) go_name = std::string(pg, ps - pg); while (ps < pend && (*ps == ' ' || *ps == '\t')) ++ps; @@ -2015,8 +2015,8 @@ Lex::skip_cpp_comment() ext_name.clear(); } } - if (go_name.empty() || ext_name.empty()) - go_error_at(loc, "usage: %<//go:linkname%> localname linkname"); + if (go_name.empty()) + go_error_at(loc, "usage: %<//go:linkname%> localname [linkname]"); else { if (this->linknames_ == NULL) diff --git a/gcc/go/gofrontend/lex.h b/gcc/go/gofrontend/lex.h index 59b770c..3be3806 100644 --- a/gcc/go/gofrontend/lex.h +++ b/gcc/go/gofrontend/lex.h @@ -380,7 +380,7 @@ class Lex 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. Location loc; // Location of go:linkname directive. diff --git a/libgo/go/runtime/alg.go b/libgo/go/runtime/alg.go index a2bb5bb..0daddf1 100644 --- a/libgo/go/runtime/alg.go +++ b/libgo/go/runtime/alg.go @@ -10,44 +10,43 @@ import ( "unsafe" ) -// For gccgo, use go:linkname to rename compiler-called functions to -// themselves, so that the compiler will export them. +// For gccgo, use go:linkname to export compiler-called functions. // -//go:linkname memhash0 runtime.memhash0 -//go:linkname memhash8 runtime.memhash8 -//go:linkname memhash16 runtime.memhash16 -//go:linkname memhash32 runtime.memhash32 -//go:linkname memhash64 runtime.memhash64 -//go:linkname memhash128 runtime.memhash128 -//go:linkname strhash runtime.strhash -//go:linkname f32hash runtime.f32hash -//go:linkname f64hash runtime.f64hash -//go:linkname c64hash runtime.c64hash -//go:linkname c128hash runtime.c128hash -//go:linkname interhash runtime.interhash -//go:linkname nilinterhash runtime.nilinterhash -//go:linkname memequal0 runtime.memequal0 -//go:linkname memequal8 runtime.memequal8 -//go:linkname memequal16 runtime.memequal16 -//go:linkname memequal32 runtime.memequal32 -//go:linkname memequal64 runtime.memequal64 -//go:linkname memequal128 runtime.memequal128 -//go:linkname strequal runtime.strequal -//go:linkname f32equal runtime.f32equal -//go:linkname f64equal runtime.f64equal -//go:linkname c64equal runtime.c64equal -//go:linkname c128equal runtime.c128equal -//go:linkname interequal runtime.interequal -//go:linkname nilinterequal runtime.nilinterequal -//go:linkname efaceeq runtime.efaceeq -//go:linkname ifaceeq runtime.ifaceeq -//go:linkname ifacevaleq runtime.ifacevaleq -//go:linkname ifaceefaceeq runtime.ifaceefaceeq -//go:linkname efacevaleq runtime.efacevaleq -//go:linkname cmpstring runtime.cmpstring +//go:linkname memhash0 +//go:linkname memhash8 +//go:linkname memhash16 +//go:linkname memhash32 +//go:linkname memhash64 +//go:linkname memhash128 +//go:linkname strhash +//go:linkname f32hash +//go:linkname f64hash +//go:linkname c64hash +//go:linkname c128hash +//go:linkname interhash +//go:linkname nilinterhash +//go:linkname memequal0 +//go:linkname memequal8 +//go:linkname memequal16 +//go:linkname memequal32 +//go:linkname memequal64 +//go:linkname memequal128 +//go:linkname strequal +//go:linkname f32equal +//go:linkname f64equal +//go:linkname c64equal +//go:linkname c128equal +//go:linkname interequal +//go:linkname nilinterequal +//go:linkname efaceeq +//go:linkname ifaceeq +//go:linkname ifacevaleq +//go:linkname ifaceefaceeq +//go:linkname efacevaleq +//go:linkname cmpstring // // Temporary to be called from C code. -//go:linkname alginit runtime.alginit +//go:linkname alginit const ( c0 = uintptr((8-sys.PtrSize)/4*2860486313 + (sys.PtrSize-4)/4*33054211828000289) diff --git a/libgo/go/runtime/cgocall.go b/libgo/go/runtime/cgocall.go index 57b42ff..69c3e44 100644 --- a/libgo/go/runtime/cgocall.go +++ b/libgo/go/runtime/cgocall.go @@ -12,8 +12,8 @@ import ( ) // Functions called by cgo-generated code. -//go:linkname cgoCheckPointer runtime.cgoCheckPointer -//go:linkname cgoCheckResult runtime.cgoCheckResult +//go:linkname cgoCheckPointer +//go:linkname cgoCheckResult // Pointer checking for cgo code. diff --git a/libgo/go/runtime/chan.go b/libgo/go/runtime/chan.go index 6c8d6f7..a1216cf 100644 --- a/libgo/go/runtime/chan.go +++ b/libgo/go/runtime/chan.go @@ -23,18 +23,17 @@ import ( "unsafe" ) -// For gccgo, use go:linkname to rename compiler-called functions to -// themselves, so that the compiler will export them. +// For gccgo, use go:linkname to export compiler-called functions. // -//go:linkname makechan runtime.makechan -//go:linkname makechan64 runtime.makechan64 -//go:linkname chansend1 runtime.chansend1 -//go:linkname chanrecv1 runtime.chanrecv1 -//go:linkname chanrecv2 runtime.chanrecv2 -//go:linkname closechan runtime.closechan -//go:linkname selectnbsend runtime.selectnbsend -//go:linkname selectnbrecv runtime.selectnbrecv -//go:linkname selectnbrecv2 runtime.selectnbrecv2 +//go:linkname makechan +//go:linkname makechan64 +//go:linkname chansend1 +//go:linkname chanrecv1 +//go:linkname chanrecv2 +//go:linkname closechan +//go:linkname selectnbsend +//go:linkname selectnbrecv +//go:linkname selectnbrecv2 const ( maxAlign = 8 diff --git a/libgo/go/runtime/ffi.go b/libgo/go/runtime/ffi.go index e8088ec..be79224 100644 --- a/libgo/go/runtime/ffi.go +++ b/libgo/go/runtime/ffi.go @@ -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 // 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. func ffiFuncToCIF(ft *functype, isInterface bool, isMethod bool, cif *_ffi_cif) { diff --git a/libgo/go/runtime/hash32.go b/libgo/go/runtime/hash32.go index 3449127..fba6bc3 100644 --- a/libgo/go/runtime/hash32.go +++ b/libgo/go/runtime/hash32.go @@ -12,10 +12,9 @@ package runtime import "unsafe" -// For gccgo, use go:linkname to rename compiler-called functions to -// themselves, so that the compiler will export them. +// For gccgo, use go:linkname to export compiler-called functions. // -//go:linkname memhash runtime.memhash +//go:linkname memhash const ( // Constants for multiplication: four random odd 32-bit numbers. diff --git a/libgo/go/runtime/hash64.go b/libgo/go/runtime/hash64.go index 7c6513e..3f94256 100644 --- a/libgo/go/runtime/hash64.go +++ b/libgo/go/runtime/hash64.go @@ -12,10 +12,9 @@ package runtime import "unsafe" -// For gccgo, use go:linkname to rename compiler-called functions to -// themselves, so that the compiler will export them. +// For gccgo, use go:linkname to export compiler-called functions. // -//go:linkname memhash runtime.memhash +//go:linkname memhash const ( // Constants for multiplication: four random odd 64-bit numbers. diff --git a/libgo/go/runtime/iface.go b/libgo/go/runtime/iface.go index d434f9e..3fa5dd6 100644 --- a/libgo/go/runtime/iface.go +++ b/libgo/go/runtime/iface.go @@ -10,23 +10,22 @@ import ( "unsafe" ) -// For gccgo, use go:linkname to rename compiler-called functions to -// themselves, so that the compiler will export them. +// For gccgo, use go:linkname to export compiler-called functions. // -//go:linkname requireitab runtime.requireitab -//go:linkname assertitab runtime.assertitab -//go:linkname panicdottype runtime.panicdottype -//go:linkname ifaceE2E2 runtime.ifaceE2E2 -//go:linkname ifaceI2E2 runtime.ifaceI2E2 -//go:linkname ifaceE2I2 runtime.ifaceE2I2 -//go:linkname ifaceI2I2 runtime.ifaceI2I2 -//go:linkname ifaceE2T2P runtime.ifaceE2T2P -//go:linkname ifaceI2T2P runtime.ifaceI2T2P -//go:linkname ifaceE2T2 runtime.ifaceE2T2 -//go:linkname ifaceI2T2 runtime.ifaceI2T2 -//go:linkname ifaceT2Ip runtime.ifaceT2Ip +//go:linkname requireitab +//go:linkname assertitab +//go:linkname panicdottype +//go:linkname ifaceE2E2 +//go:linkname ifaceI2E2 +//go:linkname ifaceE2I2 +//go:linkname ifaceI2I2 +//go:linkname ifaceE2T2P +//go:linkname ifaceI2T2P +//go:linkname ifaceE2T2 +//go:linkname ifaceI2T2 +//go:linkname ifaceT2Ip // Temporary for C code to call: -//go:linkname getitab runtime.getitab +//go:linkname getitab // The gccgo itab structure is different than the gc one. // diff --git a/libgo/go/runtime/lock_futex.go b/libgo/go/runtime/lock_futex.go index 9cede2d..6f86e91 100644 --- a/libgo/go/runtime/lock_futex.go +++ b/libgo/go/runtime/lock_futex.go @@ -12,16 +12,15 @@ import ( ) // For gccgo, while we still have C runtime code, use go:linkname to -// rename some functions to themselves, so that the compiler will -// export them. +// export some functions. // -//go:linkname lock runtime.lock -//go:linkname unlock runtime.unlock -//go:linkname noteclear runtime.noteclear -//go:linkname notewakeup runtime.notewakeup -//go:linkname notesleep runtime.notesleep -//go:linkname notetsleep runtime.notetsleep -//go:linkname notetsleepg runtime.notetsleepg +//go:linkname lock +//go:linkname unlock +//go:linkname noteclear +//go:linkname notewakeup +//go:linkname notesleep +//go:linkname notetsleep +//go:linkname notetsleepg // This implementation depends on OS-specific implementations of // diff --git a/libgo/go/runtime/lock_sema.go b/libgo/go/runtime/lock_sema.go index 7e69114..bf9211a 100644 --- a/libgo/go/runtime/lock_sema.go +++ b/libgo/go/runtime/lock_sema.go @@ -12,16 +12,15 @@ import ( ) // For gccgo, while we still have C runtime code, use go:linkname to -// rename some functions to themselves, so that the compiler will -// export them. +// export some functions. // -//go:linkname lock runtime.lock -//go:linkname unlock runtime.unlock -//go:linkname noteclear runtime.noteclear -//go:linkname notewakeup runtime.notewakeup -//go:linkname notesleep runtime.notesleep -//go:linkname notetsleep runtime.notetsleep -//go:linkname notetsleepg runtime.notetsleepg +//go:linkname lock +//go:linkname unlock +//go:linkname noteclear +//go:linkname notewakeup +//go:linkname notesleep +//go:linkname notetsleep +//go:linkname notetsleepg // This implementation depends on OS-specific implementations of // diff --git a/libgo/go/runtime/malloc.go b/libgo/go/runtime/malloc.go index 68e5494..e1e908b 100644 --- a/libgo/go/runtime/malloc.go +++ b/libgo/go/runtime/malloc.go @@ -114,13 +114,12 @@ import ( // C function to get the end of the program's memory. func getEnd() uintptr -// For gccgo, use go:linkname to rename compiler-called functions to -// themselves, so that the compiler will export them. +// For gccgo, use go:linkname to export compiler-called functions. // -//go:linkname newobject runtime.newobject +//go:linkname newobject // Functions called by C code. -//go:linkname mallocgc runtime.mallocgc +//go:linkname mallocgc const ( debugMalloc = false diff --git a/libgo/go/runtime/map.go b/libgo/go/runtime/map.go index b210f5a..eebb210 100644 --- a/libgo/go/runtime/map.go +++ b/libgo/go/runtime/map.go @@ -60,21 +60,20 @@ import ( "unsafe" ) -// For gccgo, use go:linkname to rename compiler-called functions to -// themselves, so that the compiler will export them. +// For gccgo, use go:linkname to export compiler-called functions. // -//go:linkname makemap runtime.makemap -//go:linkname makemap64 runtime.makemap64 -//go:linkname makemap_small runtime.makemap_small -//go:linkname mapaccess1 runtime.mapaccess1 -//go:linkname mapaccess2 runtime.mapaccess2 -//go:linkname mapaccess1_fat runtime.mapaccess1_fat -//go:linkname mapaccess2_fat runtime.mapaccess2_fat -//go:linkname mapassign runtime.mapassign -//go:linkname mapdelete runtime.mapdelete -//go:linkname mapclear runtime.mapclear -//go:linkname mapiterinit runtime.mapiterinit -//go:linkname mapiternext runtime.mapiternext +//go:linkname makemap +//go:linkname makemap64 +//go:linkname makemap_small +//go:linkname mapaccess1 +//go:linkname mapaccess2 +//go:linkname mapaccess1_fat +//go:linkname mapaccess2_fat +//go:linkname mapassign +//go:linkname mapdelete +//go:linkname mapclear +//go:linkname mapiterinit +//go:linkname mapiternext const ( // Maximum number of key/value pairs a bucket can hold. diff --git a/libgo/go/runtime/map_fast32.go b/libgo/go/runtime/map_fast32.go index 07a35e1..67d6df8 100644 --- a/libgo/go/runtime/map_fast32.go +++ b/libgo/go/runtime/map_fast32.go @@ -9,14 +9,13 @@ import ( "unsafe" ) -// For gccgo, use go:linkname to rename compiler-called functions to -// themselves, so that the compiler will export them. +// For gccgo, use go:linkname to export compiler-called functions. // -//go:linkname mapaccess1_fast32 runtime.mapaccess1_fast32 -//go:linkname mapaccess2_fast32 runtime.mapaccess2_fast32 -//go:linkname mapassign_fast32 runtime.mapassign_fast32 -//go:linkname mapassign_fast32ptr runtime.mapassign_fast32ptr -//go:linkname mapdelete_fast32 runtime.mapdelete_fast32 +//go:linkname mapaccess1_fast32 +//go:linkname mapaccess2_fast32 +//go:linkname mapassign_fast32 +//go:linkname mapassign_fast32ptr +//go:linkname mapdelete_fast32 func mapaccess1_fast32(t *maptype, h *hmap, key uint32) unsafe.Pointer { if raceenabled && h != nil { diff --git a/libgo/go/runtime/map_fast64.go b/libgo/go/runtime/map_fast64.go index d21bf06..b62ecb1 100644 --- a/libgo/go/runtime/map_fast64.go +++ b/libgo/go/runtime/map_fast64.go @@ -9,14 +9,13 @@ import ( "unsafe" ) -// For gccgo, use go:linkname to rename compiler-called functions to -// themselves, so that the compiler will export them. +// For gccgo, use go:linkname to export compiler-called functions. // -//go:linkname mapaccess1_fast64 runtime.mapaccess1_fast64 -//go:linkname mapaccess2_fast64 runtime.mapaccess2_fast64 -//go:linkname mapassign_fast64 runtime.mapassign_fast64 -//go:linkname mapassign_fast64ptr runtime.mapassign_fast64ptr -//go:linkname mapdelete_fast64 runtime.mapdelete_fast64 +//go:linkname mapaccess1_fast64 +//go:linkname mapaccess2_fast64 +//go:linkname mapassign_fast64 +//go:linkname mapassign_fast64ptr +//go:linkname mapdelete_fast64 func mapaccess1_fast64(t *maptype, h *hmap, key uint64) unsafe.Pointer { if raceenabled && h != nil { diff --git a/libgo/go/runtime/map_faststr.go b/libgo/go/runtime/map_faststr.go index 083980f..2202695 100644 --- a/libgo/go/runtime/map_faststr.go +++ b/libgo/go/runtime/map_faststr.go @@ -9,13 +9,12 @@ import ( "unsafe" ) -// For gccgo, use go:linkname to rename compiler-called functions to -// themselves, so that the compiler will export them. +// For gccgo, use go:linkname to export compiler-called functions. // -//go:linkname mapaccess1_faststr runtime.mapaccess1_faststr -//go:linkname mapaccess2_faststr runtime.mapaccess2_faststr -//go:linkname mapassign_faststr runtime.mapassign_faststr -//go:linkname mapdelete_faststr runtime.mapdelete_faststr +//go:linkname mapaccess1_faststr +//go:linkname mapaccess2_faststr +//go:linkname mapassign_faststr +//go:linkname mapdelete_faststr func mapaccess1_faststr(t *maptype, h *hmap, ky string) unsafe.Pointer { if raceenabled && h != nil { diff --git a/libgo/go/runtime/mbarrier.go b/libgo/go/runtime/mbarrier.go index 89febb9..00e5eb8 100644 --- a/libgo/go/runtime/mbarrier.go +++ b/libgo/go/runtime/mbarrier.go @@ -18,12 +18,11 @@ import ( "unsafe" ) -// For gccgo, use go:linkname to rename compiler-called functions to -// themselves, so that the compiler will export them. +// For gccgo, use go:linkname to export compiler-called functions. // -//go:linkname typedmemmove runtime.typedmemmove -//go:linkname typedslicecopy runtime.typedslicecopy -//go:linkname memclrHasPointers runtime.memclrHasPointers +//go:linkname typedmemmove +//go:linkname typedslicecopy +//go:linkname memclrHasPointers // Go uses a hybrid barrier that combines a Yuasa-style deletion // barrier—which shades the object whose reference is being diff --git a/libgo/go/runtime/mem_gccgo.go b/libgo/go/runtime/mem_gccgo.go index 9874678..5ce816c 100644 --- a/libgo/go/runtime/mem_gccgo.go +++ b/libgo/go/runtime/mem_gccgo.go @@ -12,8 +12,8 @@ import ( ) // Functions called by C code. -//go:linkname sysAlloc runtime.sysAlloc -//go:linkname sysFree runtime.sysFree +//go:linkname sysAlloc +//go:linkname sysFree //extern mmap func sysMmap(addr unsafe.Pointer, n uintptr, prot, flags, fd int32, off uintptr) unsafe.Pointer diff --git a/libgo/go/runtime/mgc_gccgo.go b/libgo/go/runtime/mgc_gccgo.go index 8504517..d7ae260 100644 --- a/libgo/go/runtime/mgc_gccgo.go +++ b/libgo/go/runtime/mgc_gccgo.go @@ -11,10 +11,9 @@ import ( "unsafe" ) -// For gccgo, use go:linkname to rename compiler-called functions to -// themselves, so that the compiler will export them. +// For gccgo, use go:linkname to export compiler-called functions. // -//go:linkname gcWriteBarrier runtime.gcWriteBarrier +//go:linkname gcWriteBarrier // gcRoot is a single GC root: a variable plus a ptrmask. //go:notinheap @@ -130,7 +129,7 @@ func createGcRootsIndex() { } // 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 // roots for a package. The init functions are run sequentially at diff --git a/libgo/go/runtime/mgcmark.go b/libgo/go/runtime/mgcmark.go index 2463a48..b6b69dd 100644 --- a/libgo/go/runtime/mgcmark.go +++ b/libgo/go/runtime/mgcmark.go @@ -1042,7 +1042,7 @@ func scanobject(b uintptr, gcw *gcWork) { gcw.scanWork += int64(i) } -//go:linkname scanstackblock runtime.scanstackblock +//go:linkname scanstackblock // scanstackblock is called by the stack scanning code in C to // actually find and mark pointers in the stack block. This is like @@ -1064,7 +1064,7 @@ func scanstackblock(b, n uintptr, gcw *gcWork) { // scanstackblockwithmap is like scanstackblock, but with an explicit // pointer bitmap. This is used only when precise stack scan is enabled. -//go:linkname scanstackblockwithmap runtime.scanstackblockwithmap +//go:linkname scanstackblockwithmap //go:nowritebarrier func scanstackblockwithmap(pc, b0, n0 uintptr, ptrmask *uint8, gcw *gcWork) { // Use local copies of original parameters, so that a stack trace diff --git a/libgo/go/runtime/netpoll.go b/libgo/go/runtime/netpoll.go index 3515922..00c7f52 100644 --- a/libgo/go/runtime/netpoll.go +++ b/libgo/go/runtime/netpoll.go @@ -12,7 +12,7 @@ import ( ) // Export temporarily for gccgo's C code to call: -//go:linkname netpoll runtime.netpoll +//go:linkname netpoll // Integrated network poller (platform-independent part). // A particular implementation (epoll/kqueue) must define the following functions: diff --git a/libgo/go/runtime/os_gccgo.go b/libgo/go/runtime/os_gccgo.go index 08511fd..ef33d67 100644 --- a/libgo/go/runtime/os_gccgo.go +++ b/libgo/go/runtime/os_gccgo.go @@ -9,7 +9,7 @@ import ( ) // For C code to call: -//go:linkname minit runtime.minit +//go:linkname minit func goenvs() { goenvs_unix() diff --git a/libgo/go/runtime/panic.go b/libgo/go/runtime/panic.go index 5868430..8e56bbe 100644 --- a/libgo/go/runtime/panic.go +++ b/libgo/go/runtime/panic.go @@ -9,39 +9,38 @@ import ( "unsafe" ) -// For gccgo, use go:linkname to rename compiler-called functions to -// themselves, so that the compiler will export them. +// For gccgo, use go:linkname to export compiler-called functions. // -//go:linkname deferproc runtime.deferproc -//go:linkname deferprocStack runtime.deferprocStack -//go:linkname deferreturn runtime.deferreturn -//go:linkname setdeferretaddr runtime.setdeferretaddr -//go:linkname checkdefer runtime.checkdefer -//go:linkname gopanic runtime.gopanic -//go:linkname canrecover runtime.canrecover -//go:linkname makefuncfficanrecover runtime.makefuncfficanrecover -//go:linkname makefuncreturning runtime.makefuncreturning -//go:linkname gorecover runtime.gorecover -//go:linkname deferredrecover runtime.deferredrecover -//go:linkname goPanicIndex runtime.goPanicIndex -//go:linkname goPanicIndexU runtime.goPanicIndexU -//go:linkname goPanicSliceAlen runtime.goPanicSliceAlen -//go:linkname goPanicSliceAlenU runtime.goPanicSliceAlenU -//go:linkname goPanicSliceAcap runtime.goPanicSliceAcap -//go:linkname goPanicSliceAcapU runtime.goPanicSliceAcapU -//go:linkname goPanicSliceB runtime.goPanicSliceB -//go:linkname goPanicSliceBU runtime.goPanicSliceBU -//go:linkname goPanicSlice3Alen runtime.goPanicSlice3Alen -//go:linkname goPanicSlice3AlenU runtime.goPanicSlice3AlenU -//go:linkname goPanicSlice3Acap runtime.goPanicSlice3Acap -//go:linkname goPanicSlice3AcapU runtime.goPanicSlice3AcapU -//go:linkname goPanicSlice3B runtime.goPanicSlice3B -//go:linkname goPanicSlice3BU runtime.goPanicSlice3BU -//go:linkname goPanicSlice3C runtime.goPanicSlice3C -//go:linkname goPanicSlice3CU runtime.goPanicSlice3CU -//go:linkname panicmem runtime.panicmem +//go:linkname deferproc +//go:linkname deferprocStack +//go:linkname deferreturn +//go:linkname setdeferretaddr +//go:linkname checkdefer +//go:linkname gopanic +//go:linkname canrecover +//go:linkname makefuncfficanrecover +//go:linkname makefuncreturning +//go:linkname gorecover +//go:linkname deferredrecover +//go:linkname goPanicIndex +//go:linkname goPanicIndexU +//go:linkname goPanicSliceAlen +//go:linkname goPanicSliceAlenU +//go:linkname goPanicSliceAcap +//go:linkname goPanicSliceAcapU +//go:linkname goPanicSliceB +//go:linkname goPanicSliceBU +//go:linkname goPanicSlice3Alen +//go:linkname goPanicSlice3AlenU +//go:linkname goPanicSlice3Acap +//go:linkname goPanicSlice3AcapU +//go:linkname goPanicSlice3B +//go:linkname goPanicSlice3BU +//go:linkname goPanicSlice3C +//go:linkname goPanicSlice3CU +//go:linkname panicmem // 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 // was generated from the runtime, or from inside malloc, then convert diff --git a/libgo/go/runtime/panic32.go b/libgo/go/runtime/panic32.go index c8861c9..fa314af 100644 --- a/libgo/go/runtime/panic32.go +++ b/libgo/go/runtime/panic32.go @@ -6,25 +6,24 @@ package runtime import _ "unsafe" // for go:linkname -// For gccgo, use go:linkname to rename compiler-called functions to -// themselves, so that the compiler will export them. +// For gccgo, use go:linkname to export compiler-called functions. // -//go:linkname goPanicExtendIndex runtime.goPanicExtendIndex -//go:linkname goPanicExtendIndexU runtime.goPanicExtendIndexU -//go:linkname goPanicExtendSliceAlen runtime.goPanicExtendSliceAlen -//go:linkname goPanicExtendSliceAlenU runtime.goPanicExtendSliceAlenU -//go:linkname goPanicExtendSliceAcap runtime.goPanicExtendSliceAcap -//go:linkname goPanicExtendSliceAcapU runtime.goPanicExtendSliceAcapU -//go:linkname goPanicExtendSliceB runtime.goPanicExtendSliceB -//go:linkname goPanicExtendSliceBU runtime.goPanicExtendSliceBU -//go:linkname goPanicExtendSlice3Alen runtime.goPanicExtendSlice3Alen -//go:linkname goPanicExtendSlice3AlenU runtime.goPanicExtendSlice3AlenU -//go:linkname goPanicExtendSlice3Acap runtime.goPanicExtendSlice3Acap -//go:linkname goPanicExtendSlice3AcapU runtime.goPanicExtendSlice3AcapU -//go:linkname goPanicExtendSlice3B runtime.goPanicExtendSlice3B -//go:linkname goPanicExtendSlice3BU runtime.goPanicExtendSlice3BU -//go:linkname goPanicExtendSlice3C runtime.goPanicExtendSlice3C -//go:linkname goPanicExtendSlice3CU runtime.goPanicExtendSlice3CU +//go:linkname goPanicExtendIndex +//go:linkname goPanicExtendIndexU +//go:linkname goPanicExtendSliceAlen +//go:linkname goPanicExtendSliceAlenU +//go:linkname goPanicExtendSliceAcap +//go:linkname goPanicExtendSliceAcapU +//go:linkname goPanicExtendSliceB +//go:linkname goPanicExtendSliceBU +//go:linkname goPanicExtendSlice3Alen +//go:linkname goPanicExtendSlice3AlenU +//go:linkname goPanicExtendSlice3Acap +//go:linkname goPanicExtendSlice3AcapU +//go:linkname goPanicExtendSlice3B +//go:linkname goPanicExtendSlice3BU +//go:linkname goPanicExtendSlice3C +//go:linkname goPanicExtendSlice3CU // Additional index/slice error paths for 32-bit platforms. // Used when the high word of a 64-bit index is not zero. diff --git a/libgo/go/runtime/print.go b/libgo/go/runtime/print.go index 14d546d..7729ddc 100644 --- a/libgo/go/runtime/print.go +++ b/libgo/go/runtime/print.go @@ -9,27 +9,26 @@ import ( "unsafe" ) -// For gccgo, use go:linkname to rename compiler-called functions to -// themselves, so that the compiler will export them. +// For gccgo, use go:linkname to export compiler-called functions. // -//go:linkname printbool runtime.printbool -//go:linkname printfloat runtime.printfloat -//go:linkname printint runtime.printint -//go:linkname printhex runtime.printhex -//go:linkname printuint runtime.printuint -//go:linkname printcomplex runtime.printcomplex -//go:linkname printstring runtime.printstring -//go:linkname printpointer runtime.printpointer -//go:linkname printiface runtime.printiface -//go:linkname printeface runtime.printeface -//go:linkname printslice runtime.printslice -//go:linkname printnl runtime.printnl -//go:linkname printsp runtime.printsp -//go:linkname printlock runtime.printlock -//go:linkname printunlock runtime.printunlock +//go:linkname printbool +//go:linkname printfloat +//go:linkname printint +//go:linkname printhex +//go:linkname printuint +//go:linkname printcomplex +//go:linkname printstring +//go:linkname printpointer +//go:linkname printiface +//go:linkname printeface +//go:linkname printslice +//go:linkname printnl +//go:linkname printsp +//go:linkname printlock +//go:linkname printunlock // Temporary for C code to call: -//go:linkname gwrite runtime.gwrite -//go:linkname printhex runtime.printhex +//go:linkname gwrite +//go:linkname printhex // The compiler knows that a print of a value of this type // should use printhex instead of printuint (decimal). diff --git a/libgo/go/runtime/proc.go b/libgo/go/runtime/proc.go index b40198e..fa85d26 100644 --- a/libgo/go/runtime/proc.go +++ b/libgo/go/runtime/proc.go @@ -12,37 +12,37 @@ import ( ) // Functions called by C code. -//go:linkname main runtime.main -//go:linkname goparkunlock runtime.goparkunlock -//go:linkname newextram runtime.newextram -//go:linkname acquirep runtime.acquirep -//go:linkname releasep runtime.releasep -//go:linkname incidlelocked runtime.incidlelocked -//go:linkname ginit runtime.ginit -//go:linkname schedinit runtime.schedinit -//go:linkname ready runtime.ready -//go:linkname stopm runtime.stopm -//go:linkname handoffp runtime.handoffp -//go:linkname wakep runtime.wakep -//go:linkname stoplockedm runtime.stoplockedm -//go:linkname schedule runtime.schedule -//go:linkname execute runtime.execute -//go:linkname goexit1 runtime.goexit1 -//go:linkname reentersyscall runtime.reentersyscall -//go:linkname reentersyscallblock runtime.reentersyscallblock -//go:linkname exitsyscall runtime.exitsyscall -//go:linkname gfget runtime.gfget -//go:linkname kickoff runtime.kickoff -//go:linkname mstart1 runtime.mstart1 -//go:linkname mexit runtime.mexit -//go:linkname globrunqput runtime.globrunqput -//go:linkname pidleget runtime.pidleget +//go:linkname main +//go:linkname goparkunlock +//go:linkname newextram +//go:linkname acquirep +//go:linkname releasep +//go:linkname incidlelocked +//go:linkname ginit +//go:linkname schedinit +//go:linkname ready +//go:linkname stopm +//go:linkname handoffp +//go:linkname wakep +//go:linkname stoplockedm +//go:linkname schedule +//go:linkname execute +//go:linkname goexit1 +//go:linkname reentersyscall +//go:linkname reentersyscallblock +//go:linkname exitsyscall +//go:linkname gfget +//go:linkname kickoff +//go:linkname mstart1 +//go:linkname mexit +//go:linkname globrunqput +//go:linkname pidleget // Exported for test (see runtime/testdata/testprogcgo/dropm_stub.go). -//go:linkname getm runtime.getm +//go:linkname getm // Function called by misc/cgo/test. -//go:linkname lockedOSThread runtime.lockedOSThread +//go:linkname lockedOSThread // C functions for thread and context management. func newosproc(*m) diff --git a/libgo/go/runtime/runtime.go b/libgo/go/runtime/runtime.go index d19d6afe..abc5eab 100644 --- a/libgo/go/runtime/runtime.go +++ b/libgo/go/runtime/runtime.go @@ -14,10 +14,9 @@ import ( //go:generate go run mkfastlog2table.go // For gccgo, while we still have C runtime code, use go:linkname to -// rename some functions to themselves, so that the compiler will -// export them. +// export some functions. // -//go:linkname tickspersecond runtime.tickspersecond +//go:linkname tickspersecond var ticksLock mutex var ticksVal uint64 diff --git a/libgo/go/runtime/runtime1.go b/libgo/go/runtime/runtime1.go index 2424f20..d9309cc 100644 --- a/libgo/go/runtime/runtime1.go +++ b/libgo/go/runtime/runtime1.go @@ -11,16 +11,15 @@ import ( ) // For gccgo, while we still have C runtime code, use go:linkname to -// rename some functions to themselves, so that the compiler will -// export them. +// export some functions to themselves. // -//go:linkname gotraceback runtime.gotraceback -//go:linkname args runtime.args -//go:linkname goargs runtime.goargs -//go:linkname check runtime.check -//go:linkname goenvs_unix runtime.goenvs_unix -//go:linkname parsedebugvars runtime.parsedebugvars -//go:linkname timediv runtime.timediv +//go:linkname gotraceback +//go:linkname args +//go:linkname goargs +//go:linkname check +//go:linkname goenvs_unix +//go:linkname parsedebugvars +//go:linkname timediv // Keep a cached value to make gotraceback fast, // since we call it on every call to gentraceback. diff --git a/libgo/go/runtime/runtime2.go b/libgo/go/runtime/runtime2.go index e4dfbdf..fd77c4c 100644 --- a/libgo/go/runtime/runtime2.go +++ b/libgo/go/runtime/runtime2.go @@ -930,7 +930,7 @@ type sigset _sigset_t // getMemstats returns a pointer to the internal memstats variable, // for C code. -//go:linkname getMemstats runtime.getMemstats +//go:linkname getMemstats func getMemstats() *mstats { return &memstats } diff --git a/libgo/go/runtime/select.go b/libgo/go/runtime/select.go index 16de9b8..41e5e88 100644 --- a/libgo/go/runtime/select.go +++ b/libgo/go/runtime/select.go @@ -10,11 +10,10 @@ import ( "unsafe" ) -// For gccgo, use go:linkname to rename compiler-called functions to -// themselves, so that the compiler will export them. +// For gccgo, use go:linkname to export compiler-called functions. // -//go:linkname selectgo runtime.selectgo -//go:linkname block runtime.block +//go:linkname selectgo +//go:linkname block const debugSelect = false diff --git a/libgo/go/runtime/signal_unix.go b/libgo/go/runtime/signal_unix.go index 0ba21e1..e1bab8c 100644 --- a/libgo/go/runtime/signal_unix.go +++ b/libgo/go/runtime/signal_unix.go @@ -12,8 +12,8 @@ import ( ) // For gccgo's C code to call: -//go:linkname initsig runtime.initsig -//go:linkname sigtrampgo runtime.sigtrampgo +//go:linkname initsig +//go:linkname sigtrampgo // sigTabT is the type of an entry in the global sigtable array. // sigtable is inherently system dependent, and appears in OS-specific files, diff --git a/libgo/go/runtime/slice.go b/libgo/go/runtime/slice.go index 9137951..4b15f82 100644 --- a/libgo/go/runtime/slice.go +++ b/libgo/go/runtime/slice.go @@ -10,14 +10,13 @@ import ( "unsafe" ) -// For gccgo, use go:linkname to rename compiler-called functions to -// themselves, so that the compiler will export them. +// For gccgo, use go:linkname to export compiler-called functions. // -//go:linkname makeslice runtime.makeslice -//go:linkname makeslice64 runtime.makeslice64 -//go:linkname growslice runtime.growslice -//go:linkname slicecopy runtime.slicecopy -//go:linkname slicestringcopy runtime.slicestringcopy +//go:linkname makeslice +//go:linkname makeslice64 +//go:linkname growslice +//go:linkname slicecopy +//go:linkname slicestringcopy type slice struct { array unsafe.Pointer diff --git a/libgo/go/runtime/string.go b/libgo/go/runtime/string.go index 9bcfc996..d225dc3 100644 --- a/libgo/go/runtime/string.go +++ b/libgo/go/runtime/string.go @@ -9,19 +9,18 @@ import ( "unsafe" ) -// For gccgo, use go:linkname to rename compiler-called functions to -// themselves, so that the compiler will export them. +// For gccgo, use go:linkname to export compiler-called functions. // -//go:linkname concatstrings runtime.concatstrings -//go:linkname slicebytetostring runtime.slicebytetostring -//go:linkname slicebytetostringtmp runtime.slicebytetostringtmp -//go:linkname stringtoslicebyte runtime.stringtoslicebyte -//go:linkname stringtoslicerune runtime.stringtoslicerune -//go:linkname slicerunetostring runtime.slicerunetostring -//go:linkname intstring runtime.intstring +//go:linkname concatstrings +//go:linkname slicebytetostring +//go:linkname slicebytetostringtmp +//go:linkname stringtoslicebyte +//go:linkname stringtoslicerune +//go:linkname slicerunetostring +//go:linkname intstring // Temporary for C code to call: -//go:linkname gostringnocopy runtime.gostringnocopy -//go:linkname findnull runtime.findnull +//go:linkname gostringnocopy +//go:linkname findnull // The constant is known to the compiler. // There is no fundamental theory behind this number. diff --git a/libgo/go/runtime/stubs.go b/libgo/go/runtime/stubs.go index a81bf92..4662251 100644 --- a/libgo/go/runtime/stubs.go +++ b/libgo/go/runtime/stubs.go @@ -165,7 +165,6 @@ func breakpoint() func asminit() {} -//go:linkname reflectcall runtime.reflectcall //go:noescape func reflectcall(fntype *functype, fn *funcval, isInterface, isMethod bool, params, results *unsafe.Pointer) @@ -280,13 +279,13 @@ func osyield() func syscall(trap uintptr, a1, a2, a3, a4, a5, a6 uintptr) uintptr // For gccgo, to communicate from the C code to the Go code. -//go:linkname setIsCgo runtime.setIsCgo +//go:linkname setIsCgo func setIsCgo() { iscgo = true } // For gccgo, to communicate from the C code to the Go code. -//go:linkname setSupportAES runtime.setSupportAES +//go:linkname setSupportAES func setSupportAES(v bool) { support_aes = v } @@ -320,7 +319,7 @@ func dumpregs(*_siginfo_t, unsafe.Pointer) func setRandomNumber(uint32) // Called by gccgo's proc.c. -//go:linkname allocg runtime.allocg +//go:linkname allocg func allocg() *g { return new(g) } @@ -368,17 +367,16 @@ func abort() var usestackmaps bool // probestackmaps detects whether there are stack maps. -//go:linkname probestackmaps runtime.probestackmaps func probestackmaps() bool // For the math/bits packages for gccgo. -//go:linkname getDivideError runtime.getDivideError +//go:linkname getDivideError func getDivideError() error { return divideError } // For the math/bits packages for gccgo. -//go:linkname getOverflowError runtime.getOverflowError +//go:linkname getOverflowError func getOverflowError() error { return overflowError } diff --git a/libgo/go/runtime/type.go b/libgo/go/runtime/type.go index 8af6246..1390535 100644 --- a/libgo/go/runtime/type.go +++ b/libgo/go/runtime/type.go @@ -179,7 +179,7 @@ var typelistLock mutex // type descriptors. // p points to a list of *typeDescriptorList, n is the length // of the list. -//go:linkname registerTypeDescriptors runtime.registerTypeDescriptors +//go:linkname registerTypeDescriptors func registerTypeDescriptors(n int, p unsafe.Pointer) { *(*slice)(unsafe.Pointer(&typelist.lists)) = slice{p, n, n} } diff --git a/libgo/go/runtime/utf8.go b/libgo/go/runtime/utf8.go index 0ba0dad..6590472 100644 --- a/libgo/go/runtime/utf8.go +++ b/libgo/go/runtime/utf8.go @@ -6,10 +6,9 @@ package runtime import _ "unsafe" // For go:linkname. -// For gccgo, use go:linkname to rename compiler-called functions to -// themselves, so that the compiler will export them. +// For gccgo, use go:linkname to export compiler-called functions. // -//go:linkname decoderune runtime.decoderune +//go:linkname decoderune // Numbers fundamental to the encoding. const ( |