aboutsummaryrefslogtreecommitdiff
path: root/libgo
diff options
context:
space:
mode:
authorIan Lance Taylor <ian@gcc.gnu.org>2016-11-01 14:07:43 +0000
committerIan Lance Taylor <ian@gcc.gnu.org>2016-11-01 14:07:43 +0000
commit69907c4ad5807b54920b25dac6ee21adddced8eb (patch)
treebdab38bdf1e983238d837d86f35cbba75f56a769 /libgo
parentf94a3edc6e4245f10e245d162737b889788f4f12 (diff)
downloadgcc-69907c4ad5807b54920b25dac6ee21adddced8eb.zip
gcc-69907c4ad5807b54920b25dac6ee21adddced8eb.tar.gz
gcc-69907c4ad5807b54920b25dac6ee21adddced8eb.tar.bz2
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
Diffstat (limited to 'libgo')
-rw-r--r--libgo/go/runtime/string.go17
1 files changed, 17 insertions, 0 deletions
diff --git a/libgo/go/runtime/string.go b/libgo/go/runtime/string.go
index 5df3aa3..bf5791e 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)
+}