summaryrefslogtreecommitdiff
path: root/libgo/go
diff options
context:
space:
mode:
authorian <ian@138bc75d-0d04-0410-961f-82ee72b054a4>2016-11-01 14:07:43 +0000
committerian <ian@138bc75d-0d04-0410-961f-82ee72b054a4>2016-11-01 14:07:43 +0000
commit84efd5236a882ce3dcc9617cb97cd54004f626a9 (patch)
treebdab38bdf1e983238d837d86f35cbba75f56a769 /libgo/go
parent6a192a8f5146a39ed59bad30892d3ae30f62dde9 (diff)
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 git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@241743 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'libgo/go')
-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 5df3aa3904de..bf5791e06ff1 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)
+}