aboutsummaryrefslogtreecommitdiff
path: root/libgo/go/internal
diff options
context:
space:
mode:
authorIan Lance Taylor <iant@golang.org>2020-10-24 14:47:44 -0700
committerIan Lance Taylor <iant@golang.org>2020-10-27 13:58:02 -0700
commit668894d7b584b40ddb46e9e2e2ffa637f4d732e5 (patch)
tree6c97d325215c8462f375f142d1e91099cc4edb68 /libgo/go/internal
parent2b3e722a3ca1b9dcfff1c016e651d0d681de1af0 (diff)
downloadgcc-668894d7b584b40ddb46e9e2e2ffa637f4d732e5.zip
gcc-668894d7b584b40ddb46e9e2e2ffa637f4d732e5.tar.gz
gcc-668894d7b584b40ddb46e9e2e2ffa637f4d732e5.tar.bz2
libgo: update to Go 1.15.3 release
Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/265717
Diffstat (limited to 'libgo/go/internal')
-rw-r--r--libgo/go/internal/bytealg/index_generic.go38
-rw-r--r--libgo/go/internal/poll/fd_unix.go12
2 files changed, 8 insertions, 42 deletions
diff --git a/libgo/go/internal/bytealg/index_generic.go b/libgo/go/internal/bytealg/index_generic.go
index 3dc1c6b..c595c23 100644
--- a/libgo/go/internal/bytealg/index_generic.go
+++ b/libgo/go/internal/bytealg/index_generic.go
@@ -17,42 +17,8 @@ func Index(a, b []byte) int {
// IndexString returns the index of the first instance of b in a, or -1 if b is not present in a.
// Requires 2 <= len(b) <= MaxLen.
-func IndexString(s, substr string) int {
- // This is a partial copy of strings.Index, here because bytes.IndexAny and bytes.LastIndexAny
- // call bytealg.IndexString. Some platforms have an optimized assembly version of this function.
- // This implementation is used for those that do not. Although the pure Go implementation here
- // works for the case of len(b) > MaxLen, we do not require that its assembly implementation also
- // supports the case of len(b) > MaxLen. And we do not guarantee that this function supports the
- // case of len(b) > MaxLen.
- n := len(substr)
- c0 := substr[0]
- c1 := substr[1]
- i := 0
- t := len(s) - n + 1
- fails := 0
- for i < t {
- if s[i] != c0 {
- o := IndexByteString(s[i:t], c0)
- if o < 0 {
- return -1
- }
- i += o
- }
- if s[i+1] == c1 && s[i:i+n] == substr {
- return i
- }
- i++
- fails++
- if fails >= 4+i>>4 && i < t {
- // See comment in src/bytes/bytes.go.
- j := IndexRabinKarp(s[i:], substr)
- if j < 0 {
- return -1
- }
- return i + j
- }
- }
- return -1
+func IndexString(a, b string) int {
+ panic("unimplemented")
}
// Cutover reports the number of failures of IndexByte we should tolerate
diff --git a/libgo/go/internal/poll/fd_unix.go b/libgo/go/internal/poll/fd_unix.go
index f177ccf..10cf173 100644
--- a/libgo/go/internal/poll/fd_unix.go
+++ b/libgo/go/internal/poll/fd_unix.go
@@ -152,7 +152,7 @@ func (fd *FD) Read(p []byte) (int, error) {
p = p[:maxRW]
}
for {
- n, err := ignoringEINTR(syscall.Read, fd.Sysfd, p)
+ n, err := ignoringEINTR(func() (int, error) { return syscall.Read(fd.Sysfd, p) })
if err != nil {
n = 0
if err == syscall.EAGAIN && fd.pd.pollable() {
@@ -264,7 +264,7 @@ func (fd *FD) Write(p []byte) (int, error) {
if fd.IsStream && max-nn > maxRW {
max = nn + maxRW
}
- n, err := ignoringEINTR(syscall.Write, fd.Sysfd, p[nn:max])
+ n, err := ignoringEINTR(func() (int, error) { return syscall.Write(fd.Sysfd, p[nn:max]) })
if n > 0 {
nn += n
}
@@ -423,7 +423,7 @@ func (fd *FD) ReadDirent(buf []byte) (int, error) {
}
defer fd.decref()
for {
- n, err := ignoringEINTR(syscall.ReadDirent, fd.Sysfd, buf)
+ n, err := ignoringEINTR(func() (int, error) { return syscall.ReadDirent(fd.Sysfd, buf) })
if err != nil {
n = 0
if err == syscall.EAGAIN && fd.pd.pollable() {
@@ -514,7 +514,7 @@ func (fd *FD) WriteOnce(p []byte) (int, error) {
return 0, err
}
defer fd.writeUnlock()
- return ignoringEINTR(syscall.Write, fd.Sysfd, p)
+ return ignoringEINTR(func() (int, error) { return syscall.Write(fd.Sysfd, p) })
}
// RawRead invokes the user-defined function f for a read operation.
@@ -562,9 +562,9 @@ func (fd *FD) RawWrite(f func(uintptr) bool) error {
// installed without setting SA_RESTART. None of these are the common case,
// but there are enough of them that it seems that we can't avoid
// an EINTR loop.
-func ignoringEINTR(fn func(fd int, p []byte) (int, error), fd int, p []byte) (int, error) {
+func ignoringEINTR(fn func() (int, error)) (int, error) {
for {
- n, err := fn(fd, p)
+ n, err := fn()
if err != syscall.EINTR {
return n, err
}