From 69907c4ad5807b54920b25dac6ee21adddced8eb Mon Sep 17 00:00:00 2001 From: Ian Lance Taylor Date: Tue, 1 Nov 2016 14:07:43 +0000 Subject: [PATCH] runtime: recreate function called by cgo -gccgo When using cgo -gccgo calls to C.GoString, C.GoStringN, and C.GoBytes are turned into calls to __go_byte_array_to_string and __go_string_to_byte_array. Those functions were removed when the string code was copied from Go 1.7, but we still need them for cgo. While cgo should be updated, old versions will exist for some time. Reviewed-on: https://go-review.googlesource.com/32474 From-SVN: r241743 --- gcc/go/gofrontend/MERGE | 2 +- libgo/go/runtime/string.go | 17 +++++++++++++++++ 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/gcc/go/gofrontend/MERGE b/gcc/go/gofrontend/MERGE index 4dd1f8c4ead..db435a26161 100644 --- a/gcc/go/gofrontend/MERGE +++ b/gcc/go/gofrontend/MERGE @@ -1,4 +1,4 @@ -90f12ac1fa72a95e73cb88b6114fa3131c4ca8ee +069ed35ecbefd2f138ea3132a557ad23a6936a45 The first line of this file holds the git revision number of the last merge done from the gofrontend repository. diff --git a/libgo/go/runtime/string.go b/libgo/go/runtime/string.go index 5df3aa3904d..bf5791e06ff 100644 --- a/libgo/go/runtime/string.go +++ b/libgo/go/runtime/string.go @@ -444,3 +444,20 @@ func gostringw(strw *uint16) string { b[n2] = 0 // for luck return s[:n2] } + +// These two functions are called by code generated by cgo -gccgo. + +//go:linkname __go_byte_array_to_string __go_byte_array_to_string +func __go_byte_array_to_string(p unsafe.Pointer, l int) string { + if l == 0 { + return "" + } + s, c := rawstringtmp(nil, l) + memmove(unsafe.Pointer(&c[0]), p, uintptr(l)) + return s +} + +//go:linkname __go_string_to_byte_array __go_string_to_byte_array +func __go_string_to_byte_array(s string) []byte { + return stringtoslicebyte(nil, s) +} -- 2.30.2