mirror of https://github.com/golang/go.git
Revert "runtime: use bytes.IndexByte in findnull"
This reverts commit 7365fac2db.
Reason for revert: breaks the build on some architectures, reading unmapped pages?
Change-Id: I3a8c02dc0b649269faacea79ecd8213defa97c54
Reviewed-on: https://go-review.googlesource.com/97995
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
This commit is contained in:
parent
f1fc9da316
commit
1fadbc1a76
|
|
@ -31,8 +31,6 @@ struct S {
|
||||||
int x;
|
int x;
|
||||||
};
|
};
|
||||||
|
|
||||||
const char *cstr = "abcefghijklmnopqrstuvwxyzABCEFGHIJKLMNOPQRSTUVWXYZ1234567890";
|
|
||||||
|
|
||||||
extern enum E myConstFunc(struct S* const ctx, int const id, struct S **const filter);
|
extern enum E myConstFunc(struct S* const ctx, int const id, struct S **const filter);
|
||||||
|
|
||||||
enum E myConstFunc(struct S *const ctx, int const id, struct S **const filter) { return 0; }
|
enum E myConstFunc(struct S *const ctx, int const id, struct S **const filter) { return 0; }
|
||||||
|
|
@ -151,18 +149,6 @@ func benchCgoCall(b *testing.B) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
var sinkString string
|
|
||||||
|
|
||||||
func benchGoString(b *testing.B) {
|
|
||||||
for i := 0; i < b.N; i++ {
|
|
||||||
sinkString = C.GoString(C.cstr)
|
|
||||||
}
|
|
||||||
const want = "abcefghijklmnopqrstuvwxyzABCEFGHIJKLMNOPQRSTUVWXYZ1234567890"
|
|
||||||
if sinkString != want {
|
|
||||||
b.Fatalf("%q != %q", sinkString, want)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Issue 2470.
|
// Issue 2470.
|
||||||
func testUnsignedInt(t *testing.T) {
|
func testUnsignedInt(t *testing.T) {
|
||||||
a := (int64)(C.UINT32VAL)
|
a := (int64)(C.UINT32VAL)
|
||||||
|
|
|
||||||
|
|
@ -88,5 +88,4 @@ func Test6907Go(t *testing.T) { test6907Go(t) }
|
||||||
func Test21897(t *testing.T) { test21897(t) }
|
func Test21897(t *testing.T) { test21897(t) }
|
||||||
func Test22906(t *testing.T) { test22906(t) }
|
func Test22906(t *testing.T) { test22906(t) }
|
||||||
|
|
||||||
func BenchmarkCgoCall(b *testing.B) { benchCgoCall(b) }
|
func BenchmarkCgoCall(b *testing.B) { benchCgoCall(b) }
|
||||||
func BenchmarkGoString(b *testing.B) { benchGoString(b) }
|
|
||||||
|
|
|
||||||
|
|
@ -121,7 +121,6 @@ func printany(i interface{}) {
|
||||||
// strings.IndexByte is implemented in runtime/asm_$goarch.s
|
// strings.IndexByte is implemented in runtime/asm_$goarch.s
|
||||||
// but amusingly we need go:linkname to get access to it here in the runtime.
|
// but amusingly we need go:linkname to get access to it here in the runtime.
|
||||||
//go:linkname stringsIndexByte strings.IndexByte
|
//go:linkname stringsIndexByte strings.IndexByte
|
||||||
//go:noescape
|
|
||||||
func stringsIndexByte(s string, c byte) int
|
func stringsIndexByte(s string, c byte) int
|
||||||
|
|
||||||
// panicwrap generates a panic for a call to a wrapped value method
|
// panicwrap generates a panic for a call to a wrapped value method
|
||||||
|
|
|
||||||
|
|
@ -407,9 +407,12 @@ func findnull(s *byte) int {
|
||||||
if s == nil {
|
if s == nil {
|
||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
ss := stringStruct{unsafe.Pointer(s), maxAlloc/2 - 1}
|
p := (*[maxAlloc/2 - 1]byte)(unsafe.Pointer(s))
|
||||||
t := *(*string)(unsafe.Pointer(&ss))
|
l := 0
|
||||||
return stringsIndexByte(t, 0)
|
for p[l] != 0 {
|
||||||
|
l++
|
||||||
|
}
|
||||||
|
return l
|
||||||
}
|
}
|
||||||
|
|
||||||
func findnullw(s *uint16) int {
|
func findnullw(s *uint16) int {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue