all: drop 1.16 and 1.17 (#55)
Closes #55
- commit
- 64c381bcf9c524bab94b2cbdc3619ad3053ef2c4
- author
- TotallyGamerJet · · 2022-10-30 02:05 UTC
- committer
- GitHub · · 2022-10-30 02:05 UTC
- parent
- d863f55
- signature
- GPG Unverified
4AEE18F83AFDEB23The key is unknown
8 files · +14 -74
M .github/workflows/test.yml +5 -11
| @@ -7,7 +7,7 @@ jobs: | |||
| 7 | 7 | strategy: | |
| 8 | 8 | matrix: | |
| 9 | 9 | os: [ubuntu-latest, macos-latest, windows-latest] | |
| 10 | - | go: ['1.16.x', '1.17.x', '1.18.x', '1.19.x'] | |
| 10 | + | go: ['1.18.x', '1.19.x'] | |
| 11 | 11 | name: Test with Go ${{ matrix.go }} on ${{ matrix.os }} | |
| 12 | 12 | runs-on: ${{ matrix.os }} | |
| 13 | 13 | defaults: | |
| @@ -45,17 +45,11 @@ jobs: | |||
| 45 | 45 | env GOOS=windows GOARCH=386 go build -v ./... | |
| 46 | 46 | env GOOS=windows GOARCH=amd64 go build -v ./... | |
| 47 | 47 | env GOOS=windows GOARCH=arm go build -v ./... | |
| 48 | - | ||
| 48 | + | env GOOS=windows GOARCH=arm64 go build -v ./... | |
| 49 | + | ||
| 49 | 50 | # Check cross-compiling macOS binaries. | |
| 50 | 51 | env GOOS=darwin GOARCH=amd64 go build -v ./... | |
| 51 | - | env GOOS=darwin GOARCH=arm64 go build -v ./... | |
| 52 | - | ||
| 53 | - | - name: go build (Windows, ARM64) | |
| 54 | - | # Go 1.16 and older don't support the pair GOOS=windows and GOARCH=arm64. | |
| 55 | - | if: ${{ !startsWith(matrix.go, '1.16.') }} | |
| 56 | - | run: | | |
| 57 | - | # Check cross-compiling Windows binaries. | |
| 58 | - | env GOOS=windows GOARCH=arm64 go build -v ./... | |
| 52 | + | env GOOS=darwin GOARCH=arm64 go build -v ./... | |
| 59 | 53 | ||
| 60 | 54 | - name: go mod vendor | |
| 61 | 55 | if: ${{ !startsWith(matrix.os, 'ubuntu-') }} | |
| @@ -75,4 +69,4 @@ jobs: | |||
| 75 | 69 | ||
| 76 | 70 | - name: go test | |
| 77 | 71 | run: | | |
| 78 | - | go test ${{ !startsWith(matrix.go, '1.16.') && '-shuffle=on' || '' }} -v -count=10 ./... | |
| 72 | + | go test -shuffle=on -v -count=10 ./... | |
| @@ -7,7 +7,7 @@ jobs: | |||||
| 7 | strategy: | 7 | strategy: | ||
| 8 | matrix: | 8 | matrix: | ||
| 9 | os: [ubuntu-latest, macos-latest, windows-latest] | 9 | os: [ubuntu-latest, macos-latest, windows-latest] | ||
| 10 | - | go: ['1.16.x', '1.17.x', '1.18.x', '1.19.x'] | 10 | + | go: ['1.18.x', '1.19.x'] |
| 11 | name: Test with Go ${{ matrix.go }} on ${{ matrix.os }} | 11 | name: Test with Go ${{ matrix.go }} on ${{ matrix.os }} | ||
| 12 | runs-on: ${{ matrix.os }} | 12 | runs-on: ${{ matrix.os }} | ||
| 13 | defaults: | 13 | defaults: | ||
| @@ -45,17 +45,11 @@ jobs: | |||||
| 45 | env GOOS=windows GOARCH=386 go build -v ./... | 45 | env GOOS=windows GOARCH=386 go build -v ./... | ||
| 46 | env GOOS=windows GOARCH=amd64 go build -v ./... | 46 | env GOOS=windows GOARCH=amd64 go build -v ./... | ||
| 47 | env GOOS=windows GOARCH=arm go build -v ./... | 47 | env GOOS=windows GOARCH=arm go build -v ./... | ||
| 48 | - | 48 | + | env GOOS=windows GOARCH=arm64 go build -v ./... | |
| 49 | + | ||||
| 49 | # Check cross-compiling macOS binaries. | 50 | # Check cross-compiling macOS binaries. | ||
| 50 | env GOOS=darwin GOARCH=amd64 go build -v ./... | 51 | env GOOS=darwin GOARCH=amd64 go build -v ./... | ||
| 51 | - | env GOOS=darwin GOARCH=arm64 go build -v ./... | 52 | + | env GOOS=darwin GOARCH=arm64 go build -v ./... |
| 52 | - | ||||
| 53 | - | - name: go build (Windows, ARM64) | |||
| 54 | - | # Go 1.16 and older don't support the pair GOOS=windows and GOARCH=arm64. | |||
| 55 | - | if: ${{ !startsWith(matrix.go, '1.16.') }} | |||
| 56 | - | run: | | |||
| 57 | - | # Check cross-compiling Windows binaries. | |||
| 58 | - | env GOOS=windows GOARCH=arm64 go build -v ./... | |||
| 59 | 53 | ||||
| 60 | - name: go mod vendor | 54 | - name: go mod vendor | ||
| 61 | if: ${{ !startsWith(matrix.os, 'ubuntu-') }} | 55 | if: ${{ !startsWith(matrix.os, 'ubuntu-') }} | ||
| @@ -75,4 +69,4 @@ jobs: | |||||
| 75 | 69 | ||||
| 76 | - name: go test | 70 | - name: go test | ||
| 77 | run: | | 71 | run: | | ||
| 78 | - | go test ${{ !startsWith(matrix.go, '1.16.') && '-shuffle=on' || '' }} -v -count=10 ./... | 72 | + | go test -shuffle=on -v -count=10 ./... |
M go.mod +1 -1
| @@ -1,3 +1,3 @@ | |||
| 1 | 1 | module github.com/ebitengine/purego | |
| 2 | 2 | ||
| 3 | - | go 1.16 | |
| 3 | + | go 1.18 | |
| @@ -1,3 +1,3 @@ | |||||
| 1 | module github.com/ebitengine/purego | 1 | module github.com/ebitengine/purego | ||
| 2 | 2 | ||||
| 3 | - | go 1.16 | 3 | + | go 1.18 |
M internal/strings/strings.go +2 -12
| @@ -4,7 +4,6 @@ | |||
| 4 | 4 | package strings | |
| 5 | 5 | ||
| 6 | 6 | import ( | |
| 7 | - | "reflect" | |
| 8 | 7 | "unsafe" | |
| 9 | 8 | ) | |
| 10 | 9 | ||
| @@ -32,19 +31,10 @@ func GoString(c uintptr) string { | |||
| 32 | 31 | } | |
| 33 | 32 | var length int | |
| 34 | 33 | for { | |
| 35 | - | // use unsafe.Add once we reach 1.17 | |
| 36 | - | if *(*byte)(unsafe.Pointer(uintptr(ptr) + uintptr(length))) == '\x00' { | |
| 34 | + | if *(*byte)(unsafe.Add(ptr, uintptr(length))) == '\x00' { | |
| 37 | 35 | break | |
| 38 | 36 | } | |
| 39 | 37 | length++ | |
| 40 | 38 | } | |
| 41 | - | // use unsafe.Slice once we reach 1.17 | |
| 42 | - | s := make([]byte, length) | |
| 43 | - | var src []byte | |
| 44 | - | h := (*reflect.SliceHeader)(unsafe.Pointer(&src)) | |
| 45 | - | h.Data = uintptr(ptr) | |
| 46 | - | h.Len = length | |
| 47 | - | h.Cap = length | |
| 48 | - | copy(s, src) | |
| 49 | - | return string(s) | |
| 39 | + | return string(unsafe.Slice((*byte)(ptr), length)) | |
| 50 | 40 | } | |
| @@ -4,7 +4,6 @@ | |||||
| 4 | package strings | 4 | package strings | ||
| 5 | 5 | ||||
| 6 | import ( | 6 | import ( | ||
| 7 | - | "reflect" | |||
| 8 | "unsafe" | 7 | "unsafe" | ||
| 9 | ) | 8 | ) | ||
| 10 | 9 | ||||
| @@ -32,19 +31,10 @@ func GoString(c uintptr) string { | |||||
| 32 | } | 31 | } | ||
| 33 | var length int | 32 | var length int | ||
| 34 | for { | 33 | for { | ||
| 35 | - | // use unsafe.Add once we reach 1.17 | 34 | + | if *(*byte)(unsafe.Add(ptr, uintptr(length))) == '\x00' { |
| 36 | - | if *(*byte)(unsafe.Pointer(uintptr(ptr) + uintptr(length))) == '\x00' { | |||
| 37 | break | 35 | break | ||
| 38 | } | 36 | } | ||
| 39 | length++ | 37 | length++ | ||
| 40 | } | 38 | } | ||
| 41 | - | // use unsafe.Slice once we reach 1.17 | 39 | + | return string(unsafe.Slice((*byte)(ptr), length)) |
| 42 | - | s := make([]byte, length) | |||
| 43 | - | var src []byte | |||
| 44 | - | h := (*reflect.SliceHeader)(unsafe.Pointer(&src)) | |||
| 45 | - | h.Data = uintptr(ptr) | |||
| 46 | - | h.Len = length | |||
| 47 | - | h.Cap = length | |||
| 48 | - | copy(s, src) | |||
| 49 | - | return string(s) | |||
| 50 | } | 40 | } | ||
D registercc_darwin.go +0 -12
| @@ -1,12 +0,0 @@ | |||
| 1 | - | // SPDX-License-Identifier: Apache-2.0 | |
| 2 | - | // SPDX-FileCopyrightText: 2022 The Ebitengine Authors | |
| 3 | - | ||
| 4 | - | //go:build (arm64 && go1.18) || (amd64 && go1.17) | |
| 5 | - | // +build arm64,go1.18 amd64,go1.17 | |
| 6 | - | ||
| 7 | - | package purego | |
| 8 | - | ||
| 9 | - | // stackCallingConvention represents whether the stacks or the | |
| 10 | - | // registers are used to pass parameters to functions. This is used to circumvent | |
| 11 | - | // the need for ABIInternal tag which is only allowed in the runtime. | |
| 12 | - | const stackCallingConvention = false | |
| @@ -1,12 +0,0 @@ | |||||
| 1 | - | // SPDX-License-Identifier: Apache-2.0 | |||
| 2 | - | // SPDX-FileCopyrightText: 2022 The Ebitengine Authors | |||
| 3 | - | ||||
| 4 | - | //go:build (arm64 && go1.18) || (amd64 && go1.17) | |||
| 5 | - | // +build arm64,go1.18 amd64,go1.17 | |||
| 6 | - | ||||
| 7 | - | package purego | |||
| 8 | - | ||||
| 9 | - | // stackCallingConvention represents whether the stacks or the | |||
| 10 | - | // registers are used to pass parameters to functions. This is used to circumvent | |||
| 11 | - | // the need for ABIInternal tag which is only allowed in the runtime. | |||
| 12 | - | const stackCallingConvention = false | |||
D stackcc_darwin.go +0 -12
| @@ -1,12 +0,0 @@ | |||
| 1 | - | // SPDX-License-Identifier: Apache-2.0 | |
| 2 | - | // SPDX-FileCopyrightText: 2022 The Ebitengine Authors | |
| 3 | - | ||
| 4 | - | //go:build (arm64 && !go1.18) || (amd64 && !go1.17) | |
| 5 | - | // +build arm64,!go1.18 amd64,!go1.17 | |
| 6 | - | ||
| 7 | - | package purego | |
| 8 | - | ||
| 9 | - | // stackCallingConvention represents whether the stacks or the | |
| 10 | - | // registers are used to pass parameters to functions. This is used to circumvent | |
| 11 | - | // the need for ABIInternal tag which is only allowed in the runtime. | |
| 12 | - | const stackCallingConvention = true | |
| @@ -1,12 +0,0 @@ | |||||
| 1 | - | // SPDX-License-Identifier: Apache-2.0 | |||
| 2 | - | // SPDX-FileCopyrightText: 2022 The Ebitengine Authors | |||
| 3 | - | ||||
| 4 | - | //go:build (arm64 && !go1.18) || (amd64 && !go1.17) | |||
| 5 | - | // +build arm64,!go1.18 amd64,!go1.17 | |||
| 6 | - | ||||
| 7 | - | package purego | |||
| 8 | - | ||||
| 9 | - | // stackCallingConvention represents whether the stacks or the | |||
| 10 | - | // registers are used to pass parameters to functions. This is used to circumvent | |||
| 11 | - | // the need for ABIInternal tag which is only allowed in the runtime. | |||
| 12 | - | const stackCallingConvention = true | |||
M sys_darwin_amd64.s +2 -6
| @@ -74,13 +74,9 @@ TEXT syscall9X(SB), NOSPLIT, $0 | |||
| 74 | 74 | ||
| 75 | 75 | // runtime·cgocallback expects a call to the ABIInternal function | |
| 76 | 76 | // However, the tag <ABIInternal> is only available in the runtime :( | |
| 77 | - | // This is a small wrapper function that copies both whatever is in the register | |
| 78 | - | // and is on the stack and places both on the stack. It then calls callbackWrapPicker | |
| 79 | - | // which will choose which parameter should be used depending on the version of Go. | |
| 80 | - | // It then calls the real version of callbackWrap | |
| 81 | 77 | TEXT callbackWrapInternal<>(SB), NOSPLIT, $0-0 | |
| 82 | - | MOVQ AX, arg+16(SP) | |
| 83 | - | JMP ·callbackWrapPicker(SB) | |
| 78 | + | MOVQ AX, arg+8(SP) | |
| 79 | + | JMP ·callbackWrap(SB) | |
| 84 | 80 | RET | |
| 85 | 81 | ||
| 86 | 82 | TEXT callbackasm1(SB), NOSPLIT, $0 | |
| @@ -74,13 +74,9 @@ TEXT syscall9X(SB), NOSPLIT, $0 | |||||
| 74 | 74 | ||||
| 75 | // runtime·cgocallback expects a call to the ABIInternal function | 75 | // runtime·cgocallback expects a call to the ABIInternal function | ||
| 76 | // However, the tag <ABIInternal> is only available in the runtime :( | 76 | // However, the tag <ABIInternal> is only available in the runtime :( | ||
| 77 | - | // This is a small wrapper function that copies both whatever is in the register | |||
| 78 | - | // and is on the stack and places both on the stack. It then calls callbackWrapPicker | |||
| 79 | - | // which will choose which parameter should be used depending on the version of Go. | |||
| 80 | - | // It then calls the real version of callbackWrap | |||
| 81 | TEXT callbackWrapInternal<>(SB), NOSPLIT, $0-0 | 77 | TEXT callbackWrapInternal<>(SB), NOSPLIT, $0-0 | ||
| 82 | - | MOVQ AX, arg+16(SP) | 78 | + | MOVQ AX, arg+8(SP) |
| 83 | - | JMP ·callbackWrapPicker(SB) | 79 | + | JMP ·callbackWrap(SB) |
| 84 | RET | 80 | RET | ||
| 85 | 81 | ||||
| 86 | TEXT callbackasm1(SB), NOSPLIT, $0 | 82 | TEXT callbackasm1(SB), NOSPLIT, $0 | ||
M sys_darwin_arm64.s +4 -6
| @@ -65,13 +65,11 @@ TEXT syscall9X(SB), NOSPLIT, $0 | |||
| 65 | 65 | ||
| 66 | 66 | // runtime·cgocallback expects a call to the ABIInternal function | |
| 67 | 67 | // However, the tag <ABIInternal> is only available in the runtime :( | |
| 68 | - | // This is a small wrapper function that copies both whatever is in the register | |
| 69 | - | // and is on the stack and places both on the stack. It then calls callbackWrapPicker | |
| 70 | - | // which will choose which parameter should be used depending on the version of Go. | |
| 71 | - | // It then calls the real version of callbackWrap | |
| 68 | + | // This is a small wrapper function that moves the parameter from R0 to the stack | |
| 69 | + | // where the Go function can find it. It then branches without link. | |
| 72 | 70 | TEXT callbackWrapInternal<>(SB), NOSPLIT, $0-0 | |
| 73 | - | MOVD R0, 16(RSP) | |
| 74 | - | B ·callbackWrapPicker(SB) | |
| 71 | + | MOVD R0, 8(RSP) | |
| 72 | + | B ·callbackWrap(SB) | |
| 75 | 73 | RET | |
| 76 | 74 | ||
| 77 | 75 | TEXT callbackasm1(SB), NOSPLIT, $208-0 | |
| @@ -65,13 +65,11 @@ TEXT syscall9X(SB), NOSPLIT, $0 | |||||
| 65 | 65 | ||||
| 66 | // runtime·cgocallback expects a call to the ABIInternal function | 66 | // runtime·cgocallback expects a call to the ABIInternal function | ||
| 67 | // However, the tag <ABIInternal> is only available in the runtime :( | 67 | // However, the tag <ABIInternal> is only available in the runtime :( | ||
| 68 | - | // This is a small wrapper function that copies both whatever is in the register | 68 | + | // This is a small wrapper function that moves the parameter from R0 to the stack |
| 69 | - | // and is on the stack and places both on the stack. It then calls callbackWrapPicker | 69 | + | // where the Go function can find it. It then branches without link. |
| 70 | - | // which will choose which parameter should be used depending on the version of Go. | |||
| 71 | - | // It then calls the real version of callbackWrap | |||
| 72 | TEXT callbackWrapInternal<>(SB), NOSPLIT, $0-0 | 70 | TEXT callbackWrapInternal<>(SB), NOSPLIT, $0-0 | ||
| 73 | - | MOVD R0, 16(RSP) | 71 | + | MOVD R0, 8(RSP) |
| 74 | - | B ·callbackWrapPicker(SB) | 72 | + | B ·callbackWrap(SB) |
| 75 | RET | 73 | RET | ||
| 76 | 74 | ||||
| 77 | TEXT callbackasm1(SB), NOSPLIT, $208-0 | 75 | TEXT callbackasm1(SB), NOSPLIT, $208-0 | ||
M syscall_darwin.go +0 -14
| @@ -95,20 +95,6 @@ const callbackMaxFrame = 64 * ptrSize | |||
| 95 | 95 | // callbackasmABI0 is implemented in zcallback_GOOS_GOARCH.s | |
| 96 | 96 | var callbackasmABI0 uintptr | |
| 97 | 97 | ||
| 98 | - | // callbackWrapPicker gets whatever is on the stack and in the first register. | |
| 99 | - | // Depending on which version of Go that uses stack or register-based | |
| 100 | - | // calling it passes the respective argument to the real calbackWrap function. | |
| 101 | - | // The other argument is therefore invalid and points to undefined memory so don't use it. | |
| 102 | - | // This function is necessary since we can't use the ABIInternal selector which is only | |
| 103 | - | // valid in the runtime. | |
| 104 | - | func callbackWrapPicker(stack, register *callbackArgs) { | |
| 105 | - | if stackCallingConvention { | |
| 106 | - | callbackWrap(stack) | |
| 107 | - | } else { | |
| 108 | - | callbackWrap(register) | |
| 109 | - | } | |
| 110 | - | } | |
| 111 | - | ||
| 112 | 98 | // callbackWrap is called by assembly code which determines which Go function to call. | |
| 113 | 99 | // This function takes the arguments and passes them to the Go function and returns the result. | |
| 114 | 100 | func callbackWrap(a *callbackArgs) { | |
| @@ -95,20 +95,6 @@ const callbackMaxFrame = 64 * ptrSize | |||||
| 95 | // callbackasmABI0 is implemented in zcallback_GOOS_GOARCH.s | 95 | // callbackasmABI0 is implemented in zcallback_GOOS_GOARCH.s | ||
| 96 | var callbackasmABI0 uintptr | 96 | var callbackasmABI0 uintptr | ||
| 97 | 97 | ||||
| 98 | - | // callbackWrapPicker gets whatever is on the stack and in the first register. | |||
| 99 | - | // Depending on which version of Go that uses stack or register-based | |||
| 100 | - | // calling it passes the respective argument to the real calbackWrap function. | |||
| 101 | - | // The other argument is therefore invalid and points to undefined memory so don't use it. | |||
| 102 | - | // This function is necessary since we can't use the ABIInternal selector which is only | |||
| 103 | - | // valid in the runtime. | |||
| 104 | - | func callbackWrapPicker(stack, register *callbackArgs) { | |||
| 105 | - | if stackCallingConvention { | |||
| 106 | - | callbackWrap(stack) | |||
| 107 | - | } else { | |||
| 108 | - | callbackWrap(register) | |||
| 109 | - | } | |||
| 110 | - | } | |||
| 111 | - | ||||
| 112 | // callbackWrap is called by assembly code which determines which Go function to call. | 98 | // callbackWrap is called by assembly code which determines which Go function to call. | ||
| 113 | // This function takes the arguments and passes them to the Go function and returns the result. | 99 | // This function takes the arguments and passes them to the Go function and returns the result. | ||
| 114 | func callbackWrap(a *callbackArgs) { | 100 | func callbackWrap(a *callbackArgs) { | ||