From c70ff9f9be0c7360a37519ec68ac4dd41e8d0a3c Mon Sep 17 00:00:00 2001 From: Ian Lance Taylor Date: Sat, 31 Aug 2019 03:01:15 +0000 Subject: [PATCH] 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 --- gcc/go/gofrontend/MERGE | 2 +- gcc/go/gofrontend/gogo.cc | 25 ++++++++++-- gcc/go/gofrontend/gogo.h | 12 +++++- gcc/go/gofrontend/lex.cc | 6 +-- gcc/go/gofrontend/lex.h | 2 +- libgo/go/runtime/alg.go | 69 ++++++++++++++++----------------- libgo/go/runtime/cgocall.go | 4 +- libgo/go/runtime/chan.go | 21 +++++----- libgo/go/runtime/ffi.go | 2 +- libgo/go/runtime/hash32.go | 5 +-- libgo/go/runtime/hash64.go | 5 +-- libgo/go/runtime/iface.go | 29 +++++++------- libgo/go/runtime/lock_futex.go | 17 ++++---- libgo/go/runtime/lock_sema.go | 17 ++++---- libgo/go/runtime/malloc.go | 7 ++-- libgo/go/runtime/map.go | 27 +++++++------ libgo/go/runtime/map_fast32.go | 13 +++---- libgo/go/runtime/map_fast64.go | 13 +++---- libgo/go/runtime/map_faststr.go | 11 +++--- libgo/go/runtime/mbarrier.go | 9 ++--- libgo/go/runtime/mem_gccgo.go | 4 +- libgo/go/runtime/mgc_gccgo.go | 7 ++-- libgo/go/runtime/mgcmark.go | 4 +- libgo/go/runtime/netpoll.go | 2 +- libgo/go/runtime/os_gccgo.go | 2 +- libgo/go/runtime/panic.go | 61 ++++++++++++++--------------- libgo/go/runtime/panic32.go | 35 ++++++++--------- libgo/go/runtime/print.go | 37 +++++++++--------- libgo/go/runtime/proc.go | 54 +++++++++++++------------- libgo/go/runtime/runtime.go | 5 +-- libgo/go/runtime/runtime1.go | 17 ++++---- libgo/go/runtime/runtime2.go | 2 +- libgo/go/runtime/select.go | 7 ++-- libgo/go/runtime/signal_unix.go | 4 +- libgo/go/runtime/slice.go | 13 +++---- libgo/go/runtime/string.go | 21 +++++----- libgo/go/runtime/stubs.go | 12 +++--- libgo/go/runtime/type.go | 2 +- libgo/go/runtime/utf8.go | 5 +-- 39 files changed, 297 insertions(+), 293 deletions(-) diff --git a/gcc/go/gofrontend/MERGE b/gcc/go/gofrontend/MERGE index 888e96d1911a..025e66ea99b4 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 f8114eceac32..d39a4fb51aac 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, + ("//% 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 087e89057ac8..e742b6eb8e3f 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 3276de4f5d84..f0236132328d 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: % localname linkname"); + if (go_name.empty()) + go_error_at(loc, "usage: % localname [linkname]"); else { if (this->linknames_ == NULL) diff --git a/gcc/go/gofrontend/lex.h b/gcc/go/gofrontend/lex.h index 59b770ca94a0..3be38062150b 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 a2bb5bb0b998..0daddf10e11a 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 57b42ff2eae4..69c3e4431378 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 6c8d6f70ebda..a1216cf32239 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 e8088ec39472..be79224a4fb7 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 344912711d95..fba6bc354b14 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 7c6513ebd2be..3f94256ad33e 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 d434f9e0afc1..3fa5dd6deec6 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 9cede2d41c30..6f86e91264bc 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 7e691149d68f..bf9211a6c3b9 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 68e549493507..e1e908b28591 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 b210f5a53209..eebb2103bb23 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 07a35e18fc6d..67d6df8c9a32 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 d21bf0663435..b62ecb106cc0 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 083980fac454..2202695a45bb 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 89febb9d4a23..00e5eb8baa52 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 987467814543..5ce816c323a4 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 85045170b3c0..d7ae26090f53 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 2463a48d4284..b6b69ddd2e16 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 35159221dc25..00c7f5251478 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 08511fd2acaa..ef33d679fe49 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 58684305ac05..8e56bbe8b56b 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 c8861c9c11c3..fa314afc20a3 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 14d546d6d33c..7729ddc0a748 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 b40198e9d3e0..fa85d262efea 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 d19d6afed388..abc5eab00d50 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 2424f2030cd2..d9309cca771c 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 e4dfbdfeaf49..fd77c4ca84e0 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 16de9b88f6c1..41e5e88b286a 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 0ba21e14e64e..e1bab8caba39 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 9137951bfe9a..4b15f82a54ef 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 9bcfc9961c82..d225dc3a6437 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 a81bf92ad4f9..4662251da7f2 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 8af624636725..13905353f83a 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 0ba0dad835cd..6590472c0d3c 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 ( -- 2.43.5