detached 1bd362f

all: Add support for NetBSD (#268)

Closes #249
commit
1bd362fd71e2804641291345ff5506b1798fe0a9
author
TotallyGamerJet · · 2025-03-08 19:43 UTC
committer
GitHub · · 2025-03-08 19:43 UTC
parent
3999af5
signature
GPG UnverifiedB5690EEEBB952194 The key is unknown
48 files · +391 -117
M .github/ISSUE_TEMPLATE/00-bug.yml +1 -0
@@ -17,6 +17,7 @@ body:
1717 - label: macOS
1818 - label: Linux
1919 - label: FreeBSD
20+ - label: NetBSD
2021 - label: Android
2122 - label: iOS
2223 validations:
@@ -17,6 +17,7 @@ body:
17 - label: macOS17 - label: macOS
18 - label: Linux18 - label: Linux
19 - label: FreeBSD19 - label: FreeBSD
20+ - label: NetBSD
20 - label: Android21 - label: Android
21 - label: iOS22 - label: iOS
22 validations:23 validations:
A .github/scripts/bsd_tests.sh +81 -0
@@ -0,0 +1,81 @@
1+#!/bin/sh
2+
3+# SPDX-License-Identifier: Apache-2.0
4+# SPDX-FileCopyrightText: 2025 The Ebitengine Authors
5+
6+# FreeBSD & NetBSD tests run within QEMU on Ubuntu.
7+# vmactions/freebsd-vm only supports a single "step" where it
8+# brings down the VM at the end of the step, so all
9+# the commands to run need to be put into this single block.
10+
11+echo "Running tests on $(uname -a) at $PWD"
12+
13+PATH=$PATH:/usr/local/go/bin/
14+
15+# verify Go is available
16+go version
17+
18+echo "=> go build"
19+go build -v ./...
20+# Compile without optimization to check potential stack overflow.
21+# The option '-gcflags=all=-N -l' is often used at Visual Studio Code.
22+# See also https://go.googlesource.com/vscode-go/+/HEAD/docs/debugging.md#launch and the issue hajimehoshi/ebiten#2120.
23+go build "-gcflags=all=-N -l" -v ./...
24+
25+# Check cross-compiling Windows binaries.
26+env GOOS=windows GOARCH=386 go build -v ./...
27+env GOOS=windows GOARCH=amd64 go build -v ./...
28+env GOOS=windows GOARCH=arm go build -v ./...
29+env GOOS=windows GOARCH=arm64 go build -v ./...
30+
31+# Check cross-compiling macOS binaries.
32+env GOOS=darwin GOARCH=amd64 go build -v ./...
33+env GOOS=darwin GOARCH=arm64 go build -v ./...
34+
35+# Check cross-compiling Linux binaries.
36+env GOOS=linux GOARCH=amd64 go build -v ./...
37+env GOOS=linux GOARCH=arm64 go build -v ./...
38+
39+# Check cross-compiling FreeBSD binaries.
40+env GOOS=freebsd GOARCH=amd64 go build -gcflags="github.com/ebitengine/purego/internal/fakecgo=-std" -v ./...
41+env GOOS=freebsd GOARCH=arm64 go build -gcflags="github.com/ebitengine/purego/internal/fakecgo=-std" -v ./...
42+
43+# Check cross-compiling NetBSD binaries.
44+env GOOS=netbsd GOARCH=amd64 go build -v ./...
45+env GOOS=netbsd GOARCH=arm64 go build -v ./...
46+
47+echo "=> go build (plugin)"
48+# Make sure that plugin buildmode works since we save the R15 register (#254)
49+go build -buildmode=plugin ./examples/libc
50+
51+echo "=> go mod vendor"
52+mkdir /tmp/vendoring
53+cd /tmp/vendoring
54+go mod init foo
55+echo 'package main' > main.go
56+echo 'import (' >> main.go
57+echo ' _ "github.com/ebitengine/purego"' >> main.go
58+echo ')' >> main.go
59+echo 'func main() {}' >> main.go
60+go mod edit -replace github.com/ebitengine/purego=$GITHUB_WORKSPACE
61+go mod tidy
62+go mod vendor
63+go build -v .
64+
65+cd $GITHUB_WORKSPACE
66+echo "=> go test CGO_ENABLED=0"
67+env CGO_ENABLED=0 go test -gcflags="github.com/ebitengine/purego/internal/fakecgo=-std" -shuffle=on -v -count=10 ./...
68+
69+echo "=> go test CGO_ENABLED=1"
70+env CGO_ENABLED=1 go test -shuffle=on -v -count=10 ./...
71+
72+echo "=> go test CGO_ENABLED=0 w/o optimization"
73+env CGO_ENABLED=0 go test "-gcflags=all=-N -l" -v ./...
74+
75+echo "=> go test CGO_ENABLED=1 w/o optimization"
76+env CGO_ENABLED=1 go test "-gcflags=all=-N -l" -v ./...
77+
78+if [ -z "$(go version | grep '^1.1')" ]; then
79+ echo "=> go test race"
80+ go test -race -shuffle=on -v -count=10 ./...
81+fi
@@ -0,0 +1,81 @@
1+#!/bin/sh
2+
3+# SPDX-License-Identifier: Apache-2.0
4+# SPDX-FileCopyrightText: 2025 The Ebitengine Authors
5+
6+# FreeBSD & NetBSD tests run within QEMU on Ubuntu.
7+# vmactions/freebsd-vm only supports a single "step" where it
8+# brings down the VM at the end of the step, so all
9+# the commands to run need to be put into this single block.
10+
11+echo "Running tests on $(uname -a) at $PWD"
12+
13+PATH=$PATH:/usr/local/go/bin/
14+
15+# verify Go is available
16+go version
17+
18+echo "=> go build"
19+go build -v ./...
20+# Compile without optimization to check potential stack overflow.
21+# The option '-gcflags=all=-N -l' is often used at Visual Studio Code.
22+# See also https://go.googlesource.com/vscode-go/+/HEAD/docs/debugging.md#launch and the issue hajimehoshi/ebiten#2120.
23+go build "-gcflags=all=-N -l" -v ./...
24+
25+# Check cross-compiling Windows binaries.
26+env GOOS=windows GOARCH=386 go build -v ./...
27+env GOOS=windows GOARCH=amd64 go build -v ./...
28+env GOOS=windows GOARCH=arm go build -v ./...
29+env GOOS=windows GOARCH=arm64 go build -v ./...
30+
31+# Check cross-compiling macOS binaries.
32+env GOOS=darwin GOARCH=amd64 go build -v ./...
33+env GOOS=darwin GOARCH=arm64 go build -v ./...
34+
35+# Check cross-compiling Linux binaries.
36+env GOOS=linux GOARCH=amd64 go build -v ./...
37+env GOOS=linux GOARCH=arm64 go build -v ./...
38+
39+# Check cross-compiling FreeBSD binaries.
40+env GOOS=freebsd GOARCH=amd64 go build -gcflags="github.com/ebitengine/purego/internal/fakecgo=-std" -v ./...
41+env GOOS=freebsd GOARCH=arm64 go build -gcflags="github.com/ebitengine/purego/internal/fakecgo=-std" -v ./...
42+
43+# Check cross-compiling NetBSD binaries.
44+env GOOS=netbsd GOARCH=amd64 go build -v ./...
45+env GOOS=netbsd GOARCH=arm64 go build -v ./...
46+
47+echo "=> go build (plugin)"
48+# Make sure that plugin buildmode works since we save the R15 register (#254)
49+go build -buildmode=plugin ./examples/libc
50+
51+echo "=> go mod vendor"
52+mkdir /tmp/vendoring
53+cd /tmp/vendoring
54+go mod init foo
55+echo 'package main' > main.go
56+echo 'import (' >> main.go
57+echo ' _ "github.com/ebitengine/purego"' >> main.go
58+echo ')' >> main.go
59+echo 'func main() {}' >> main.go
60+go mod edit -replace github.com/ebitengine/purego=$GITHUB_WORKSPACE
61+go mod tidy
62+go mod vendor
63+go build -v .
64+
65+cd $GITHUB_WORKSPACE
66+echo "=> go test CGO_ENABLED=0"
67+env CGO_ENABLED=0 go test -gcflags="github.com/ebitengine/purego/internal/fakecgo=-std" -shuffle=on -v -count=10 ./...
68+
69+echo "=> go test CGO_ENABLED=1"
70+env CGO_ENABLED=1 go test -shuffle=on -v -count=10 ./...
71+
72+echo "=> go test CGO_ENABLED=0 w/o optimization"
73+env CGO_ENABLED=0 go test "-gcflags=all=-N -l" -v ./...
74+
75+echo "=> go test CGO_ENABLED=1 w/o optimization"
76+env CGO_ENABLED=1 go test "-gcflags=all=-N -l" -v ./...
77+
78+if [ -z "$(go version | grep '^1.1')" ]; then
79+ echo "=> go test race"
80+ go test -race -shuffle=on -v -count=10 ./...
81+fi
M .github/workflows/test.yml +25 -74
@@ -65,7 +65,11 @@ jobs:
6565 # gcflags -std is necessary to make fakecgo the Cgo for
6666 # FreeBSD to add the symbols that libc.so depends on.
6767 env GOOS=freebsd GOARCH=amd64 go build -gcflags="github.com/ebitengine/purego/internal/fakecgo=-std" -v ./...
68- env GOOS=freebsd GOARCH=arm64 go build -gcflags="github.com/ebitengine/purego/internal/fakecgo=-std" -v ./...
68+ env GOOS=freebsd GOARCH=arm64 go build -gcflags="github.com/ebitengine/purego/internal/fakecgo=-std" -v ./...
69+
70+ # Check cross-compiling NetBSD binaries.
71+ env GOOS=netbsd GOARCH=amd64 go build -v ./...
72+ env GOOS=netbsd GOARCH=arm64 go build -v ./...
6973
7074 - name: go build (plugin)
7175 if: runner.os == 'Linux' || runner.os == 'macOS'
@@ -134,11 +138,12 @@ jobs:
134138 run: |
135139 go test -race -shuffle=on -v -count=10 ./...
136140
137- freebsd:
141+ bsd:
138142 strategy:
139143 matrix:
144+ os: ['FreeBSD', 'NetBSD']
140145 go: ['1.18.10', '1.19.13', '1.20.14', '1.21.13', '1.22.12', '1.23.6', '1.24.0']
141- name: Test with Go ${{ matrix.go }} on FreeBSD
146+ name: Test with Go ${{ matrix.go }} on ${{ matrix.os }}
142147 runs-on: ubuntu-22.04
143148 defaults:
144149 run:
@@ -146,6 +151,7 @@ jobs:
146151 steps:
147152 - uses: actions/checkout@v4
148153 - name: Run in freebsd
154+ if: matrix.os == 'FreeBSD'
149155 uses: vmactions/freebsd-vm@v1
150156 with:
151157 usesh: true
@@ -153,74 +159,19 @@ jobs:
153159 fetch https://go.dev/dl/go${{matrix.go}}.freebsd-amd64.tar.gz
154160 rm -fr /usr/local/go && tar -C /usr/local -xf go${{matrix.go}}.freebsd-amd64.tar.gz
155161 ln -s /usr/local/go/bin/go /usr/local/bin
156- run: |
157- # FreeBSD tests run within QEMU on Ubuntu.
158- # vmactions/freebsd-vm only supports a single "step" where it
159- # brings down the VM at the end of the step, so all
160- # the commands to run need to be put into this single block.
161-
162- echo "Running tests on $(uname -a) at $PWD"
163-
164- # verify Go is available
165- go version
166-
167- echo "=> go build"
168- go build -v ./...
169- # Compile without optimization to check potential stack overflow.
170- # The option '-gcflags=all=-N -l' is often used at Visual Studio Code.
171- # See also https://go.googlesource.com/vscode-go/+/HEAD/docs/debugging.md#launch and the issue hajimehoshi/ebiten#2120.
172- go build "-gcflags=all=-N -l" -v ./...
173-
174- # Check cross-compiling Windows binaries.
175- env GOOS=windows GOARCH=386 go build -v ./...
176- env GOOS=windows GOARCH=amd64 go build -v ./...
177- env GOOS=windows GOARCH=arm go build -v ./...
178- env GOOS=windows GOARCH=arm64 go build -v ./...
179-
180- # Check cross-compiling macOS binaries.
181- env GOOS=darwin GOARCH=amd64 go build -v ./...
182- env GOOS=darwin GOARCH=arm64 go build -v ./...
183-
184- # Check cross-compiling Linux binaries.
185- env GOOS=linux GOARCH=amd64 go build -v ./...
186- env GOOS=linux GOARCH=arm64 go build -v ./...
187-
188- # Check cross-compiling FreeBSD binaries.
189- env GOOS=freebsd GOARCH=amd64 go build -gcflags="github.com/ebitengine/purego/internal/fakecgo=-std" -v ./...
190- env GOOS=freebsd GOARCH=arm64 go build -gcflags="github.com/ebitengine/purego/internal/fakecgo=-std" -v ./...
191-
192- echo "=> go build (plugin)"
193- # Make sure that plugin buildmode works since we save the R15 register (#254)
194- go build -buildmode=plugin ./examples/libc
195-
196- echo "=> go mod vendor"
197- mkdir /tmp/vendoring
198- cd /tmp/vendoring
199- go mod init foo
200- echo 'package main' > main.go
201- echo 'import (' >> main.go
202- echo ' _ "github.com/ebitengine/purego"' >> main.go
203- echo ')' >> main.go
204- echo 'func main() {}' >> main.go
205- go mod edit -replace github.com/ebitengine/purego=$GITHUB_WORKSPACE
206- go mod tidy
207- go mod vendor
208- go build -v .
209-
210- cd $GITHUB_WORKSPACE
211- echo "=> go test CGO_ENABLED=0"
212- env CGO_ENABLED=0 go test -gcflags="github.com/ebitengine/purego/internal/fakecgo=-std" -shuffle=on -v -count=10 ./...
213-
214- echo "=> go test CGO_ENABLED=1"
215- env CGO_ENABLED=1 go test -shuffle=on -v -count=10 ./...
216-
217- echo "=> go test CGO_ENABLED=0 w/o optimization"
218- env CGO_ENABLED=0 go test "-gcflags=all=-N -l" -v ./...
219-
220- echo "=> go test CGO_ENABLED=1 w/o optimization"
221- env CGO_ENABLED=1 go test "-gcflags=all=-N -l" -v ./...
222-
223- if [ -z "$(echo ${{matrix.go}} | grep '^1.1')" ]; then
224- echo "=> go test race"
225- go test -race -shuffle=on -v -count=10 ./...
226- fi
162+ chmod +x $GITHUB_WORKSPACE/.github/scripts/bsd_tests.sh
163+ run: $GITHUB_WORKSPACE/.github/scripts/bsd_tests.sh
164+ - name: Run in netbsd
165+ # there are no prebuilt download links for these versions of Go for NetBSD
166+ if: matrix.os == 'NetBSD' && !startsWith(matrix.go, '1.18.') && !startsWith(matrix.go, '1.19.') && !startsWith(matrix.go, '1.20.')
167+ uses: vmactions/netbsd-vm@v1
168+ with:
169+ usesh: true
170+ prepare: |
171+ /usr/sbin/pkg_add -v bash
172+ ftp https://go.dev/dl/go${{matrix.go}}.netbsd-amd64.tar.gz
173+ mkdir /usr/local
174+ rm -fr /usr/local/go && tar -C /usr/local -xf go${{matrix.go}}.netbsd-amd64.tar.gz
175+ ln -s /usr/local/go/bin/go /usr/local/bin
176+ chmod +x $GITHUB_WORKSPACE/.github/scripts/bsd_tests.sh
177+ run: $GITHUB_WORKSPACE/.github/scripts/bsd_tests.sh
@@ -65,7 +65,11 @@ jobs:
65 # gcflags -std is necessary to make fakecgo the Cgo for65 # gcflags -std is necessary to make fakecgo the Cgo for
66 # FreeBSD to add the symbols that libc.so depends on.66 # FreeBSD to add the symbols that libc.so depends on.
67 env GOOS=freebsd GOARCH=amd64 go build -gcflags="github.com/ebitengine/purego/internal/fakecgo=-std" -v ./...67 env GOOS=freebsd GOARCH=amd64 go build -gcflags="github.com/ebitengine/purego/internal/fakecgo=-std" -v ./...
68- env GOOS=freebsd GOARCH=arm64 go build -gcflags="github.com/ebitengine/purego/internal/fakecgo=-std" -v ./...68+ env GOOS=freebsd GOARCH=arm64 go build -gcflags="github.com/ebitengine/purego/internal/fakecgo=-std" -v ./...
69+
70+ # Check cross-compiling NetBSD binaries.
71+ env GOOS=netbsd GOARCH=amd64 go build -v ./...
72+ env GOOS=netbsd GOARCH=arm64 go build -v ./...
69 73
70 - name: go build (plugin)74 - name: go build (plugin)
71 if: runner.os == 'Linux' || runner.os == 'macOS'75 if: runner.os == 'Linux' || runner.os == 'macOS'
@@ -134,11 +138,12 @@ jobs:
134 run: |138 run: |
135 go test -race -shuffle=on -v -count=10 ./...139 go test -race -shuffle=on -v -count=10 ./...
136 140
137- freebsd:141+ bsd:
138 strategy:142 strategy:
139 matrix:143 matrix:
144+ os: ['FreeBSD', 'NetBSD']
140 go: ['1.18.10', '1.19.13', '1.20.14', '1.21.13', '1.22.12', '1.23.6', '1.24.0']145 go: ['1.18.10', '1.19.13', '1.20.14', '1.21.13', '1.22.12', '1.23.6', '1.24.0']
141- name: Test with Go ${{ matrix.go }} on FreeBSD146+ name: Test with Go ${{ matrix.go }} on ${{ matrix.os }}
142 runs-on: ubuntu-22.04147 runs-on: ubuntu-22.04
143 defaults:148 defaults:
144 run:149 run:
@@ -146,6 +151,7 @@ jobs:
146 steps:151 steps:
147 - uses: actions/checkout@v4152 - uses: actions/checkout@v4
148 - name: Run in freebsd153 - name: Run in freebsd
154+ if: matrix.os == 'FreeBSD'
149 uses: vmactions/freebsd-vm@v1155 uses: vmactions/freebsd-vm@v1
150 with:156 with:
151 usesh: true157 usesh: true
@@ -153,74 +159,19 @@ jobs:
153 fetch https://go.dev/dl/go${{matrix.go}}.freebsd-amd64.tar.gz159 fetch https://go.dev/dl/go${{matrix.go}}.freebsd-amd64.tar.gz
154 rm -fr /usr/local/go && tar -C /usr/local -xf go${{matrix.go}}.freebsd-amd64.tar.gz160 rm -fr /usr/local/go && tar -C /usr/local -xf go${{matrix.go}}.freebsd-amd64.tar.gz
155 ln -s /usr/local/go/bin/go /usr/local/bin161 ln -s /usr/local/go/bin/go /usr/local/bin
156- run: |162+ chmod +x $GITHUB_WORKSPACE/.github/scripts/bsd_tests.sh
157- # FreeBSD tests run within QEMU on Ubuntu.163+ run: $GITHUB_WORKSPACE/.github/scripts/bsd_tests.sh
158- # vmactions/freebsd-vm only supports a single "step" where it164+ - name: Run in netbsd
159- # brings down the VM at the end of the step, so all165+ # there are no prebuilt download links for these versions of Go for NetBSD
160- # the commands to run need to be put into this single block.166+ if: matrix.os == 'NetBSD' && !startsWith(matrix.go, '1.18.') && !startsWith(matrix.go, '1.19.') && !startsWith(matrix.go, '1.20.')
161-167+ uses: vmactions/netbsd-vm@v1
162- echo "Running tests on $(uname -a) at $PWD"168+ with:
163-169+ usesh: true
164- # verify Go is available170+ prepare: |
165- go version171+ /usr/sbin/pkg_add -v bash
166-172+ ftp https://go.dev/dl/go${{matrix.go}}.netbsd-amd64.tar.gz
167- echo "=> go build"173+ mkdir /usr/local
168- go build -v ./...174+ rm -fr /usr/local/go && tar -C /usr/local -xf go${{matrix.go}}.netbsd-amd64.tar.gz
169- # Compile without optimization to check potential stack overflow.175+ ln -s /usr/local/go/bin/go /usr/local/bin
170- # The option '-gcflags=all=-N -l' is often used at Visual Studio Code.176+ chmod +x $GITHUB_WORKSPACE/.github/scripts/bsd_tests.sh
171- # See also https://go.googlesource.com/vscode-go/+/HEAD/docs/debugging.md#launch and the issue hajimehoshi/ebiten#2120.177+ run: $GITHUB_WORKSPACE/.github/scripts/bsd_tests.sh
172- go build "-gcflags=all=-N -l" -v ./...
173-
174- # Check cross-compiling Windows binaries.
175- env GOOS=windows GOARCH=386 go build -v ./...
176- env GOOS=windows GOARCH=amd64 go build -v ./...
177- env GOOS=windows GOARCH=arm go build -v ./...
178- env GOOS=windows GOARCH=arm64 go build -v ./...
179-
180- # Check cross-compiling macOS binaries.
181- env GOOS=darwin GOARCH=amd64 go build -v ./...
182- env GOOS=darwin GOARCH=arm64 go build -v ./...
183-
184- # Check cross-compiling Linux binaries.
185- env GOOS=linux GOARCH=amd64 go build -v ./...
186- env GOOS=linux GOARCH=arm64 go build -v ./...
187-
188- # Check cross-compiling FreeBSD binaries.
189- env GOOS=freebsd GOARCH=amd64 go build -gcflags="github.com/ebitengine/purego/internal/fakecgo=-std" -v ./...
190- env GOOS=freebsd GOARCH=arm64 go build -gcflags="github.com/ebitengine/purego/internal/fakecgo=-std" -v ./...
191-
192- echo "=> go build (plugin)"
193- # Make sure that plugin buildmode works since we save the R15 register (#254)
194- go build -buildmode=plugin ./examples/libc
195-
196- echo "=> go mod vendor"
197- mkdir /tmp/vendoring
198- cd /tmp/vendoring
199- go mod init foo
200- echo 'package main' > main.go
201- echo 'import (' >> main.go
202- echo ' _ "github.com/ebitengine/purego"' >> main.go
203- echo ')' >> main.go
204- echo 'func main() {}' >> main.go
205- go mod edit -replace github.com/ebitengine/purego=$GITHUB_WORKSPACE
206- go mod tidy
207- go mod vendor
208- go build -v .
209-
210- cd $GITHUB_WORKSPACE
211- echo "=> go test CGO_ENABLED=0"
212- env CGO_ENABLED=0 go test -gcflags="github.com/ebitengine/purego/internal/fakecgo=-std" -shuffle=on -v -count=10 ./...
213-
214- echo "=> go test CGO_ENABLED=1"
215- env CGO_ENABLED=1 go test -shuffle=on -v -count=10 ./...
216-
217- echo "=> go test CGO_ENABLED=0 w/o optimization"
218- env CGO_ENABLED=0 go test "-gcflags=all=-N -l" -v ./...
219-
220- echo "=> go test CGO_ENABLED=1 w/o optimization"
221- env CGO_ENABLED=1 go test "-gcflags=all=-N -l" -v ./...
222-
223- if [ -z "$(echo ${{matrix.go}} | grep '^1.1')" ]; then
224- echo "=> go test race"
225- go test -race -shuffle=on -v -count=10 ./...
226- fi
M README.md +1 -0
@@ -92,6 +92,7 @@ This is a list of the copied files:
9292 * `internal/fakecgo/iscgo.go` from package `runtime/cgo`
9393 * `internal/fakecgo/setenv.go` from package `runtime/cgo`
9494 * `internal/fakecgo/freebsd.go` from package `runtime/cgo`
95+* `internal/fakecgo/netbsd.go` from package `runtime/cgo`
9596
9697 The files `abi_*.h` and `internal/fakecgo/abi_*.h` are the same because Bazel does not support cross-package use of
9798 `#include` so we need each one once per package. (cf. [issue](https://github.com/bazelbuild/rules_go/issues/3636))
@@ -92,6 +92,7 @@ This is a list of the copied files:
92 * `internal/fakecgo/iscgo.go` from package `runtime/cgo`92 * `internal/fakecgo/iscgo.go` from package `runtime/cgo`
93 * `internal/fakecgo/setenv.go` from package `runtime/cgo`93 * `internal/fakecgo/setenv.go` from package `runtime/cgo`
94 * `internal/fakecgo/freebsd.go` from package `runtime/cgo`94 * `internal/fakecgo/freebsd.go` from package `runtime/cgo`
95+* `internal/fakecgo/netbsd.go` from package `runtime/cgo`
95 96
96 The files `abi_*.h` and `internal/fakecgo/abi_*.h` are the same because Bazel does not support cross-package use of97 The files `abi_*.h` and `internal/fakecgo/abi_*.h` are the same because Bazel does not support cross-package use of
97 `#include` so we need each one once per package. (cf. [issue](https://github.com/bazelbuild/rules_go/issues/3636))98 `#include` so we need each one once per package. (cf. [issue](https://github.com/bazelbuild/rules_go/issues/3636))
M cgo.go +1 -1
@@ -1,7 +1,7 @@
11 // SPDX-License-Identifier: Apache-2.0
22 // SPDX-FileCopyrightText: 2022 The Ebitengine Authors
33
4-//go:build cgo && (darwin || freebsd || linux)
4+//go:build cgo && (darwin || freebsd || linux || netbsd)
55
66 package purego
77
@@ -1,7 +1,7 @@
1 // SPDX-License-Identifier: Apache-2.01 // SPDX-License-Identifier: Apache-2.0
2 // SPDX-FileCopyrightText: 2022 The Ebitengine Authors2 // SPDX-FileCopyrightText: 2022 The Ebitengine Authors
3 3
4-//go:build cgo && (darwin || freebsd || linux)4+//go:build cgo && (darwin || freebsd || linux || netbsd)
5 5
6 package purego6 package purego
7 7
M dlerror.go +1 -1
@@ -1,7 +1,7 @@
11 // SPDX-License-Identifier: Apache-2.0
22 // SPDX-FileCopyrightText: 2023 The Ebitengine Authors
33
4-//go:build darwin || freebsd || linux
4+//go:build darwin || freebsd || linux || netbsd
55
66 package purego
77
@@ -1,7 +1,7 @@
1 // SPDX-License-Identifier: Apache-2.01 // SPDX-License-Identifier: Apache-2.0
2 // SPDX-FileCopyrightText: 2023 The Ebitengine Authors2 // SPDX-FileCopyrightText: 2023 The Ebitengine Authors
3 3
4-//go:build darwin || freebsd || linux4+//go:build darwin || freebsd || linux || netbsd
5 5
6 package purego6 package purego
7 7
M dlfcn.go +1 -1
@@ -1,7 +1,7 @@
11 // SPDX-License-Identifier: Apache-2.0
22 // SPDX-FileCopyrightText: 2022 The Ebitengine Authors
33
4-//go:build (darwin || freebsd || linux) && !android && !faketime
4+//go:build (darwin || freebsd || linux || netbsd) && !android && !faketime
55
66 package purego
77
@@ -1,7 +1,7 @@
1 // SPDX-License-Identifier: Apache-2.01 // SPDX-License-Identifier: Apache-2.0
2 // SPDX-FileCopyrightText: 2022 The Ebitengine Authors2 // SPDX-FileCopyrightText: 2022 The Ebitengine Authors
3 3
4-//go:build (darwin || freebsd || linux) && !android && !faketime4+//go:build (darwin || freebsd || linux || netbsd) && !android && !faketime
5 5
6 package purego6 package purego
7 7
A dlfcn_netbsd.go +15 -0
@@ -0,0 +1,15 @@
1+// SPDX-License-Identifier: Apache-2.0
2+// SPDX-FileCopyrightText: 2025 The Ebitengine Authors
3+
4+package purego
5+
6+// Source for constants: https://github.com/NetBSD/src/blob/trunk/include/dlfcn.h
7+
8+const (
9+ intSize = 32 << (^uint(0) >> 63) // 32 or 64
10+ RTLD_DEFAULT = 1<<intSize - 2 // Pseudo-handle for dlsym so search for any loaded symbol
11+ RTLD_LAZY = 0x00000001 // Relocations are performed at an implementation-dependent time.
12+ RTLD_NOW = 0x00000002 // Relocations are performed when the object is loaded.
13+ RTLD_LOCAL = 0x00000000 // All symbols are not made available for relocation processing by other modules.
14+ RTLD_GLOBAL = 0x00000100 // All symbols are available for relocation processing of other modules.
15+)
@@ -0,0 +1,15 @@
1+// SPDX-License-Identifier: Apache-2.0
2+// SPDX-FileCopyrightText: 2025 The Ebitengine Authors
3+
4+package purego
5+
6+// Source for constants: https://github.com/NetBSD/src/blob/trunk/include/dlfcn.h
7+
8+const (
9+ intSize = 32 << (^uint(0) >> 63) // 32 or 64
10+ RTLD_DEFAULT = 1<<intSize - 2 // Pseudo-handle for dlsym so search for any loaded symbol
11+ RTLD_LAZY = 0x00000001 // Relocations are performed at an implementation-dependent time.
12+ RTLD_NOW = 0x00000002 // Relocations are performed when the object is loaded.
13+ RTLD_LOCAL = 0x00000000 // All symbols are not made available for relocation processing by other modules.
14+ RTLD_GLOBAL = 0x00000100 // All symbols are available for relocation processing of other modules.
15+)
A dlfcn_nocgo_netbsd.go +9 -0
@@ -0,0 +1,9 @@
1+// SPDX-License-Identifier: Apache-2.0
2+// SPDX-FileCopyrightText: 2025 The Ebitengine Authors
3+
4+package purego
5+
6+//go:cgo_import_dynamic purego_dlopen dlopen "libc.so"
7+//go:cgo_import_dynamic purego_dlsym dlsym "libc.so"
8+//go:cgo_import_dynamic purego_dlerror dlerror "libc.so"
9+//go:cgo_import_dynamic purego_dlclose dlclose "libc.so"
@@ -0,0 +1,9 @@
1+// SPDX-License-Identifier: Apache-2.0
2+// SPDX-FileCopyrightText: 2025 The Ebitengine Authors
3+
4+package purego
5+
6+//go:cgo_import_dynamic purego_dlopen dlopen "libc.so"
7+//go:cgo_import_dynamic purego_dlsym dlsym "libc.so"
8+//go:cgo_import_dynamic purego_dlerror dlerror "libc.so"
9+//go:cgo_import_dynamic purego_dlclose dlclose "libc.so"
M dlfcn_stubs.s +1 -1
@@ -1,7 +1,7 @@
11 // SPDX-License-Identifier: Apache-2.0
22 // SPDX-FileCopyrightText: 2022 The Ebitengine Authors
33
4-//go:build darwin || !cgo && (freebsd || linux) && !faketime
4+//go:build darwin || !cgo && (freebsd || linux || netbsd) && !faketime
55
66 #include "textflag.h"
77
@@ -1,7 +1,7 @@
1 // SPDX-License-Identifier: Apache-2.01 // SPDX-License-Identifier: Apache-2.0
2 // SPDX-FileCopyrightText: 2022 The Ebitengine Authors2 // SPDX-FileCopyrightText: 2022 The Ebitengine Authors
3 3
4-//go:build darwin || !cgo && (freebsd || linux) && !faketime4+//go:build darwin || !cgo && (freebsd || linux || netbsd) && !faketime
5 5
6 #include "textflag.h"6 #include "textflag.h"
7 7
M dlfcn_test.go +2 -7
@@ -1,7 +1,7 @@
11 // SPDX-License-Identifier: Apache-2.0
22 // SPDX-FileCopyrightText: 2023 The Ebitengine Authors
33
4-//go:build darwin || freebsd || linux
4+//go:build darwin || freebsd || linux || netbsd
55
66 package purego_test
77
@@ -53,12 +53,7 @@ func buildSharedLib(compilerEnv, libFile string, sources ...string) error {
5353 return errors.New("compiler not found")
5454 }
5555
56- var args []string
57- if runtime.GOOS == "freebsd" {
58- args = []string{"-shared", "-Wall", "-Werror", "-fPIC", "-o", libFile}
59- } else {
60- args = []string{"-shared", "-Wall", "-Werror", "-o", libFile}
61- }
56+ args := []string{"-shared", "-Wall", "-Werror", "-fPIC", "-o", libFile}
6257 if runtime.GOARCH == "386" {
6358 args = append(args, "-m32")
6459 }
@@ -1,7 +1,7 @@
1 // SPDX-License-Identifier: Apache-2.01 // SPDX-License-Identifier: Apache-2.0
2 // SPDX-FileCopyrightText: 2023 The Ebitengine Authors2 // SPDX-FileCopyrightText: 2023 The Ebitengine Authors
3 3
4-//go:build darwin || freebsd || linux4+//go:build darwin || freebsd || linux || netbsd
5 5
6 package purego_test6 package purego_test
7 7
@@ -53,12 +53,7 @@ func buildSharedLib(compilerEnv, libFile string, sources ...string) error {
53 return errors.New("compiler not found")53 return errors.New("compiler not found")
54 }54 }
55 55
56- var args []string56+ args := []string{"-shared", "-Wall", "-Werror", "-fPIC", "-o", libFile}
57- if runtime.GOOS == "freebsd" {
58- args = []string{"-shared", "-Wall", "-Werror", "-fPIC", "-o", libFile}
59- } else {
60- args = []string{"-shared", "-Wall", "-Werror", "-o", libFile}
61- }
62 if runtime.GOARCH == "386" {57 if runtime.GOARCH == "386" {
63 args = append(args, "-m32")58 args = append(args, "-m32")
64 }59 }
M examples/libc/main.go +3 -1
@@ -1,7 +1,7 @@
11 // SPDX-License-Identifier: Apache-2.0
22 // SPDX-FileCopyrightText: 2022 The Ebitengine Authors
33
4-//go:build darwin || freebsd || linux || windows
4+//go:build darwin || freebsd || linux || netbsd || windows
55
66 package main
77
@@ -20,6 +20,8 @@ func getSystemLibrary() string {
2020 return "libc.so.6"
2121 case "freebsd":
2222 return "libc.so.7"
23+ case "netbsd":
24+ return "libc.so"
2325 case "windows":
2426 return "ucrtbase.dll"
2527 default:
@@ -1,7 +1,7 @@
1 // SPDX-License-Identifier: Apache-2.01 // SPDX-License-Identifier: Apache-2.0
2 // SPDX-FileCopyrightText: 2022 The Ebitengine Authors2 // SPDX-FileCopyrightText: 2022 The Ebitengine Authors
3 3
4-//go:build darwin || freebsd || linux || windows4+//go:build darwin || freebsd || linux || netbsd || windows
5 5
6 package main6 package main
7 7
@@ -20,6 +20,8 @@ func getSystemLibrary() string {
20 return "libc.so.6"20 return "libc.so.6"
21 case "freebsd":21 case "freebsd":
22 return "libc.so.7"22 return "libc.so.7"
23+ case "netbsd":
24+ return "libc.so"
23 case "windows":25 case "windows":
24 return "ucrtbase.dll"26 return "ucrtbase.dll"
25 default:27 default:
M examples/libc/main_unix.go +1 -1
@@ -1,7 +1,7 @@
11 // SPDX-License-Identifier: Apache-2.0
22 // SPDX-FileCopyrightText: 2023 The Ebitengine Authors
33
4-//go:build darwin || freebsd || linux
4+//go:build darwin || freebsd || linux || netbsd
55
66 package main
77
@@ -1,7 +1,7 @@
1 // SPDX-License-Identifier: Apache-2.01 // SPDX-License-Identifier: Apache-2.0
2 // SPDX-FileCopyrightText: 2023 The Ebitengine Authors2 // SPDX-FileCopyrightText: 2023 The Ebitengine Authors
3 3
4-//go:build darwin || freebsd || linux4+//go:build darwin || freebsd || linux || netbsd
5 5
6 package main6 package main
7 7
M func.go +1 -1
@@ -1,7 +1,7 @@
11 // SPDX-License-Identifier: Apache-2.0
22 // SPDX-FileCopyrightText: 2022 The Ebitengine Authors
33
4-//go:build darwin || freebsd || linux || windows
4+//go:build darwin || freebsd || linux || netbsd || windows
55
66 package purego
77
@@ -1,7 +1,7 @@
1 // SPDX-License-Identifier: Apache-2.01 // SPDX-License-Identifier: Apache-2.0
2 // SPDX-FileCopyrightText: 2022 The Ebitengine Authors2 // SPDX-FileCopyrightText: 2022 The Ebitengine Authors
3 3
4-//go:build darwin || freebsd || linux || windows4+//go:build darwin || freebsd || linux || netbsd || windows
5 5
6 package purego6 package purego
7 7
M func_test.go +4 -2
@@ -17,10 +17,12 @@ func getSystemLibrary() (string, error) {
1717 switch runtime.GOOS {
1818 case "darwin":
1919 return "/usr/lib/libSystem.B.dylib", nil
20- case "linux":
21- return "libc.so.6", nil
2220 case "freebsd":
2321 return "libc.so.7", nil
22+ case "linux":
23+ return "libc.so.6", nil
24+ case "netbsd":
25+ return "libc.so", nil
2426 case "windows":
2527 return "ucrtbase.dll", nil
2628 default:
@@ -17,10 +17,12 @@ func getSystemLibrary() (string, error) {
17 switch runtime.GOOS {17 switch runtime.GOOS {
18 case "darwin":18 case "darwin":
19 return "/usr/lib/libSystem.B.dylib", nil19 return "/usr/lib/libSystem.B.dylib", nil
20- case "linux":
21- return "libc.so.6", nil
22 case "freebsd":20 case "freebsd":
23 return "libc.so.7", nil21 return "libc.so.7", nil
22+ case "linux":
23+ return "libc.so.6", nil
24+ case "netbsd":
25+ return "libc.so", nil
24 case "windows":26 case "windows":
25 return "ucrtbase.dll", nil27 return "ucrtbase.dll", nil
26 default:28 default:
M go_runtime.go +1 -1
@@ -1,7 +1,7 @@
11 // SPDX-License-Identifier: Apache-2.0
22 // SPDX-FileCopyrightText: 2022 The Ebitengine Authors
33
4-//go:build darwin || freebsd || linux || windows
4+//go:build darwin || freebsd || linux || netbsd || windows
55
66 package purego
77
@@ -1,7 +1,7 @@
1 // SPDX-License-Identifier: Apache-2.01 // SPDX-License-Identifier: Apache-2.0
2 // SPDX-FileCopyrightText: 2022 The Ebitengine Authors2 // SPDX-FileCopyrightText: 2022 The Ebitengine Authors
3 3
4-//go:build darwin || freebsd || linux || windows4+//go:build darwin || freebsd || linux || netbsd || windows
5 5
6 package purego6 package purego
7 7
M internal/cgo/dlfcn_cgo_unix.go +2 -2
@@ -1,12 +1,12 @@
11 // SPDX-License-Identifier: Apache-2.0
22 // SPDX-FileCopyrightText: 2024 The Ebitengine Authors
33
4-//go:build freebsd || linux
4+//go:build freebsd || linux || netbsd
55
66 package cgo
77
88 /*
9- #cgo LDFLAGS: -ldl
9+#cgo !netbsd LDFLAGS: -ldl
1010
1111 #include <dlfcn.h>
1212 #include <stdlib.h>
@@ -1,12 +1,12 @@
1 // SPDX-License-Identifier: Apache-2.01 // SPDX-License-Identifier: Apache-2.0
2 // SPDX-FileCopyrightText: 2024 The Ebitengine Authors2 // SPDX-FileCopyrightText: 2024 The Ebitengine Authors
3 3
4-//go:build freebsd || linux4+//go:build freebsd || linux || netbsd
5 5
6 package cgo6 package cgo
7 7
8 /*8 /*
9- #cgo LDFLAGS: -ldl9+#cgo !netbsd LDFLAGS: -ldl
10 10
11 #include <dlfcn.h>11 #include <dlfcn.h>
12 #include <stdlib.h>12 #include <stdlib.h>
M internal/cgo/syscall_cgo_unix.go +2 -2
@@ -1,7 +1,7 @@
11 // SPDX-License-Identifier: Apache-2.0
22 // SPDX-FileCopyrightText: 2022 The Ebitengine Authors
33
4-//go:build freebsd || (linux && !(arm64 || amd64))
4+//go:build freebsd || (linux && !(arm64 || amd64)) || netbsd
55
66 package cgo
77
@@ -9,7 +9,7 @@ package cgo
99 // because Cgo and assembly files can't be in the same package.
1010
1111 /*
12- #cgo LDFLAGS: -ldl
12+#cgo !netbsd LDFLAGS: -ldl
1313
1414 #include <stdint.h>
1515 #include <dlfcn.h>
@@ -1,7 +1,7 @@
1 // SPDX-License-Identifier: Apache-2.01 // SPDX-License-Identifier: Apache-2.0
2 // SPDX-FileCopyrightText: 2022 The Ebitengine Authors2 // SPDX-FileCopyrightText: 2022 The Ebitengine Authors
3 3
4-//go:build freebsd || (linux && !(arm64 || amd64))4+//go:build freebsd || (linux && !(arm64 || amd64)) || netbsd
5 5
6 package cgo6 package cgo
7 7
@@ -9,7 +9,7 @@ package cgo
9 // because Cgo and assembly files can't be in the same package.9 // because Cgo and assembly files can't be in the same package.
10 10
11 /*11 /*
12- #cgo LDFLAGS: -ldl12+#cgo !netbsd LDFLAGS: -ldl
13 13
14 #include <stdint.h>14 #include <stdint.h>
15 #include <dlfcn.h>15 #include <dlfcn.h>
M internal/fakecgo/callbacks.go +1 -1
@@ -2,7 +2,7 @@
22 // Use of this source code is governed by a BSD-style
33 // license that can be found in the LICENSE file.
44
5-//go:build !cgo && (darwin || freebsd || linux)
5+//go:build !cgo && (darwin || freebsd || linux || netbsd)
66
77 package fakecgo
88
@@ -2,7 +2,7 @@
2 // Use of this source code is governed by a BSD-style2 // Use of this source code is governed by a BSD-style
3 // license that can be found in the LICENSE file.3 // license that can be found in the LICENSE file.
4 4
5-//go:build !cgo && (darwin || freebsd || linux)5+//go:build !cgo && (darwin || freebsd || linux || netbsd)
6 6
7 package fakecgo7 package fakecgo
8 8
M internal/fakecgo/doc.go +1 -1
@@ -1,7 +1,7 @@
11 // SPDX-License-Identifier: Apache-2.0
22 // SPDX-FileCopyrightText: 2022 The Ebitengine Authors
33
4-//go:build !cgo && (darwin || freebsd || linux)
4+//go:build !cgo && (darwin || freebsd || linux || netbsd)
55
66 // Package fakecgo implements the Cgo runtime (runtime/cgo) entirely in Go.
77 // This allows code that calls into C to function properly when CGO_ENABLED=0.
@@ -1,7 +1,7 @@
1 // SPDX-License-Identifier: Apache-2.01 // SPDX-License-Identifier: Apache-2.0
2 // SPDX-FileCopyrightText: 2022 The Ebitengine Authors2 // SPDX-FileCopyrightText: 2022 The Ebitengine Authors
3 3
4-//go:build !cgo && (darwin || freebsd || linux)4+//go:build !cgo && (darwin || freebsd || linux || netbsd)
5 5
6 // Package fakecgo implements the Cgo runtime (runtime/cgo) entirely in Go.6 // Package fakecgo implements the Cgo runtime (runtime/cgo) entirely in Go.
7 // This allows code that calls into C to function properly when CGO_ENABLED=0.7 // This allows code that calls into C to function properly when CGO_ENABLED=0.
M internal/fakecgo/gen.go +7 -3
@@ -20,7 +20,7 @@ const templateSymbols = `// Code generated by 'go generate' with gen.go. DO NOT
2020 // SPDX-License-Identifier: Apache-2.0
2121 // SPDX-FileCopyrightText: 2022 The Ebitengine Authors
2222
23-//go:build !cgo && (darwin || freebsd || linux)
23+//go:build !cgo && (darwin || freebsd || linux || netbsd)
2424
2525 package fakecgo
2626
@@ -86,7 +86,7 @@ const templateTrampolinesStubs = `// Code generated by 'go generate' with gen.go
8686 // SPDX-License-Identifier: Apache-2.0
8787 // SPDX-FileCopyrightText: 2022 The Ebitengine Authors
8888
89-//go:build !cgo && (darwin || freebsd || linux)
89+//go:build !cgo && (darwin || freebsd || linux || netbsd)
9090
9191 #include "textflag.h"
9292
@@ -139,6 +139,7 @@ var (
139139 {"sigfillset", [5]Arg{{"set", "*sigset_t"}}, "int32"},
140140 {"nanosleep", [5]Arg{{"ts", "*syscall.Timespec"}, {"rem", "*syscall.Timespec"}}, "int32"},
141141 {"abort", [5]Arg{}, ""},
142+ {"sigaltstack", [5]Arg{{"ss", "*stack_t"}, {"old_ss", "*stack_t"}}, "int32"},
142143 }
143144 pthreadSymbols = []Symbol{
144145 {"pthread_attr_init", [5]Arg{{"attr", "*pthread_attr_t"}}, "int32"},
@@ -199,7 +200,7 @@ func run() error {
199200 if err != nil {
200201 return err
201202 }
202- for _, goos := range []string{"darwin", "linux", "freebsd"} {
203+ for _, goos := range []string{"darwin", "freebsd", "linux", "netbsd"} {
203204 f, err = os.Create(fmt.Sprintf("symbols_%s.go", goos))
204205 defer f.Close()
205206 if err != nil {
@@ -217,6 +218,9 @@ func run() error {
217218 case "linux":
218219 libcSO = "libc.so.6"
219220 pthreadSO = "libpthread.so.0"
221+ case "netbsd":
222+ libcSO = "libc.so"
223+ pthreadSO = "libpthread.so"
220224 default:
221225 return fmt.Errorf("unsupported OS: %s", goos)
222226 }
@@ -20,7 +20,7 @@ const templateSymbols = `// Code generated by 'go generate' with gen.go. DO NOT
20 // SPDX-License-Identifier: Apache-2.020 // SPDX-License-Identifier: Apache-2.0
21 // SPDX-FileCopyrightText: 2022 The Ebitengine Authors21 // SPDX-FileCopyrightText: 2022 The Ebitengine Authors
22 22
23-//go:build !cgo && (darwin || freebsd || linux)23+//go:build !cgo && (darwin || freebsd || linux || netbsd)
24 24
25 package fakecgo25 package fakecgo
26 26
@@ -86,7 +86,7 @@ const templateTrampolinesStubs = `// Code generated by 'go generate' with gen.go
86 // SPDX-License-Identifier: Apache-2.086 // SPDX-License-Identifier: Apache-2.0
87 // SPDX-FileCopyrightText: 2022 The Ebitengine Authors87 // SPDX-FileCopyrightText: 2022 The Ebitengine Authors
88 88
89-//go:build !cgo && (darwin || freebsd || linux)89+//go:build !cgo && (darwin || freebsd || linux || netbsd)
90 90
91 #include "textflag.h"91 #include "textflag.h"
92 92
@@ -139,6 +139,7 @@ var (
139 {"sigfillset", [5]Arg{{"set", "*sigset_t"}}, "int32"},139 {"sigfillset", [5]Arg{{"set", "*sigset_t"}}, "int32"},
140 {"nanosleep", [5]Arg{{"ts", "*syscall.Timespec"}, {"rem", "*syscall.Timespec"}}, "int32"},140 {"nanosleep", [5]Arg{{"ts", "*syscall.Timespec"}, {"rem", "*syscall.Timespec"}}, "int32"},
141 {"abort", [5]Arg{}, ""},141 {"abort", [5]Arg{}, ""},
142+ {"sigaltstack", [5]Arg{{"ss", "*stack_t"}, {"old_ss", "*stack_t"}}, "int32"},
142 }143 }
143 pthreadSymbols = []Symbol{144 pthreadSymbols = []Symbol{
144 {"pthread_attr_init", [5]Arg{{"attr", "*pthread_attr_t"}}, "int32"},145 {"pthread_attr_init", [5]Arg{{"attr", "*pthread_attr_t"}}, "int32"},
@@ -199,7 +200,7 @@ func run() error {
199 if err != nil {200 if err != nil {
200 return err201 return err
201 }202 }
202- for _, goos := range []string{"darwin", "linux", "freebsd"} {203+ for _, goos := range []string{"darwin", "freebsd", "linux", "netbsd"} {
203 f, err = os.Create(fmt.Sprintf("symbols_%s.go", goos))204 f, err = os.Create(fmt.Sprintf("symbols_%s.go", goos))
204 defer f.Close()205 defer f.Close()
205 if err != nil {206 if err != nil {
@@ -217,6 +218,9 @@ func run() error {
217 case "linux":218 case "linux":
218 libcSO = "libc.so.6"219 libcSO = "libc.so.6"
219 pthreadSO = "libpthread.so.0"220 pthreadSO = "libpthread.so.0"
221+ case "netbsd":
222+ libcSO = "libc.so"
223+ pthreadSO = "libpthread.so"
220 default:224 default:
221 return fmt.Errorf("unsupported OS: %s", goos)225 return fmt.Errorf("unsupported OS: %s", goos)
222 }226 }
M internal/fakecgo/go_libinit.go +1 -1
@@ -1,7 +1,7 @@
11 // SPDX-License-Identifier: Apache-2.0
22 // SPDX-FileCopyrightText: 2022 The Ebitengine Authors
33
4-//go:build !cgo && (darwin || freebsd || linux)
4+//go:build !cgo && (darwin || freebsd || linux || netbsd)
55
66 package fakecgo
77
@@ -1,7 +1,7 @@
1 // SPDX-License-Identifier: Apache-2.01 // SPDX-License-Identifier: Apache-2.0
2 // SPDX-FileCopyrightText: 2022 The Ebitengine Authors2 // SPDX-FileCopyrightText: 2022 The Ebitengine Authors
3 3
4-//go:build !cgo && (darwin || freebsd || linux)4+//go:build !cgo && (darwin || freebsd || linux || netbsd)
5 5
6 package fakecgo6 package fakecgo
7 7
A internal/fakecgo/go_netbsd.go +106 -0
@@ -0,0 +1,106 @@
1+// Copyright 2011 The Go Authors. All rights reserved.
2+// Use of this source code is governed by a BSD-style
3+// license that can be found in the LICENSE file.
4+
5+//go:build !cgo && (amd64 || arm64)
6+
7+package fakecgo
8+
9+import "unsafe"
10+
11+//go:nosplit
12+func _cgo_sys_thread_start(ts *ThreadStart) {
13+ var attr pthread_attr_t
14+ var ign, oset sigset_t
15+ var p pthread_t
16+ var size size_t
17+ var err int
18+
19+ // fprintf(stderr, "runtime/cgo: _cgo_sys_thread_start: fn=%p, g=%p\n", ts->fn, ts->g); // debug
20+ sigfillset(&ign)
21+ pthread_sigmask(SIG_SETMASK, &ign, &oset)
22+
23+ pthread_attr_init(&attr)
24+ pthread_attr_getstacksize(&attr, &size)
25+ // Leave stacklo=0 and set stackhi=size; mstart will do the rest.
26+ ts.g.stackhi = uintptr(size)
27+
28+ err = _cgo_try_pthread_create(&p, &attr, unsafe.Pointer(threadentry_trampolineABI0), ts)
29+
30+ pthread_sigmask(SIG_SETMASK, &oset, nil)
31+
32+ if err != 0 {
33+ print("fakecgo: pthread_create failed: ")
34+ println(err)
35+ abort()
36+ }
37+}
38+
39+// threadentry_trampolineABI0 maps the C ABI to Go ABI then calls the Go function
40+//
41+//go:linkname x_threadentry_trampoline threadentry_trampoline
42+var x_threadentry_trampoline byte
43+var threadentry_trampolineABI0 = &x_threadentry_trampoline
44+
45+//go:nosplit
46+func threadentry(v unsafe.Pointer) unsafe.Pointer {
47+ var ss stack_t
48+ ts := *(*ThreadStart)(v)
49+ free(v)
50+
51+ // On NetBSD, a new thread inherits the signal stack of the
52+ // creating thread. That confuses minit, so we remove that
53+ // signal stack here before calling the regular mstart. It's
54+ // a bit baroque to remove a signal stack here only to add one
55+ // in minit, but it's a simple change that keeps NetBSD
56+ // working like other OS's. At this point all signals are
57+ // blocked, so there is no race.
58+ ss.ss_flags = SS_DISABLE
59+ sigaltstack(&ss, nil)
60+
61+ setg_trampoline(setg_func, uintptr(unsafe.Pointer(ts.g)))
62+
63+ // faking funcs in go is a bit a... involved - but the following works :)
64+ fn := uintptr(unsafe.Pointer(&ts.fn))
65+ (*(*func())(unsafe.Pointer(&fn)))()
66+
67+ return nil
68+}
69+
70+// here we will store a pointer to the provided setg func
71+var setg_func uintptr
72+
73+//go:nosplit
74+func x_cgo_init(g *G, setg uintptr) {
75+ var size size_t
76+ var attr *pthread_attr_t
77+
78+ /* The memory sanitizer distributed with versions of clang
79+ before 3.8 has a bug: if you call mmap before malloc, mmap
80+ may return an address that is later overwritten by the msan
81+ library. Avoid this problem by forcing a call to malloc
82+ here, before we ever call malloc.
83+
84+ This is only required for the memory sanitizer, so it's
85+ unfortunate that we always run it. It should be possible
86+ to remove this when we no longer care about versions of
87+ clang before 3.8. The test for this is
88+ misc/cgo/testsanitizers.
89+
90+ GCC works hard to eliminate a seemingly unnecessary call to
91+ malloc, so we actually use the memory we allocate. */
92+
93+ setg_func = setg
94+ attr = (*pthread_attr_t)(malloc(unsafe.Sizeof(*attr)))
95+ if attr == nil {
96+ println("fakecgo: malloc failed")
97+ abort()
98+ }
99+ pthread_attr_init(attr)
100+ pthread_attr_getstacksize(attr, &size)
101+ // runtime/cgo uses __builtin_frame_address(0) instead of `uintptr(unsafe.Pointer(&size))`
102+ // but this should be OK since we are taking the address of the first variable in this function.
103+ g.stacklo = uintptr(unsafe.Pointer(&size)) - uintptr(size) + 4096
104+ pthread_attr_destroy(attr)
105+ free(unsafe.Pointer(attr))
106+}
@@ -0,0 +1,106 @@
1+// Copyright 2011 The Go Authors. All rights reserved.
2+// Use of this source code is governed by a BSD-style
3+// license that can be found in the LICENSE file.
4+
5+//go:build !cgo && (amd64 || arm64)
6+
7+package fakecgo
8+
9+import "unsafe"
10+
11+//go:nosplit
12+func _cgo_sys_thread_start(ts *ThreadStart) {
13+ var attr pthread_attr_t
14+ var ign, oset sigset_t
15+ var p pthread_t
16+ var size size_t
17+ var err int
18+
19+ // fprintf(stderr, "runtime/cgo: _cgo_sys_thread_start: fn=%p, g=%p\n", ts->fn, ts->g); // debug
20+ sigfillset(&ign)
21+ pthread_sigmask(SIG_SETMASK, &ign, &oset)
22+
23+ pthread_attr_init(&attr)
24+ pthread_attr_getstacksize(&attr, &size)
25+ // Leave stacklo=0 and set stackhi=size; mstart will do the rest.
26+ ts.g.stackhi = uintptr(size)
27+
28+ err = _cgo_try_pthread_create(&p, &attr, unsafe.Pointer(threadentry_trampolineABI0), ts)
29+
30+ pthread_sigmask(SIG_SETMASK, &oset, nil)
31+
32+ if err != 0 {
33+ print("fakecgo: pthread_create failed: ")
34+ println(err)
35+ abort()
36+ }
37+}
38+
39+// threadentry_trampolineABI0 maps the C ABI to Go ABI then calls the Go function
40+//
41+//go:linkname x_threadentry_trampoline threadentry_trampoline
42+var x_threadentry_trampoline byte
43+var threadentry_trampolineABI0 = &x_threadentry_trampoline
44+
45+//go:nosplit
46+func threadentry(v unsafe.Pointer) unsafe.Pointer {
47+ var ss stack_t
48+ ts := *(*ThreadStart)(v)
49+ free(v)
50+
51+ // On NetBSD, a new thread inherits the signal stack of the
52+ // creating thread. That confuses minit, so we remove that
53+ // signal stack here before calling the regular mstart. It's
54+ // a bit baroque to remove a signal stack here only to add one
55+ // in minit, but it's a simple change that keeps NetBSD
56+ // working like other OS's. At this point all signals are
57+ // blocked, so there is no race.
58+ ss.ss_flags = SS_DISABLE
59+ sigaltstack(&ss, nil)
60+
61+ setg_trampoline(setg_func, uintptr(unsafe.Pointer(ts.g)))
62+
63+ // faking funcs in go is a bit a... involved - but the following works :)
64+ fn := uintptr(unsafe.Pointer(&ts.fn))
65+ (*(*func())(unsafe.Pointer(&fn)))()
66+
67+ return nil
68+}
69+
70+// here we will store a pointer to the provided setg func
71+var setg_func uintptr
72+
73+//go:nosplit
74+func x_cgo_init(g *G, setg uintptr) {
75+ var size size_t
76+ var attr *pthread_attr_t
77+
78+ /* The memory sanitizer distributed with versions of clang
79+ before 3.8 has a bug: if you call mmap before malloc, mmap
80+ may return an address that is later overwritten by the msan
81+ library. Avoid this problem by forcing a call to malloc
82+ here, before we ever call malloc.
83+
84+ This is only required for the memory sanitizer, so it's
85+ unfortunate that we always run it. It should be possible
86+ to remove this when we no longer care about versions of
87+ clang before 3.8. The test for this is
88+ misc/cgo/testsanitizers.
89+
90+ GCC works hard to eliminate a seemingly unnecessary call to
91+ malloc, so we actually use the memory we allocate. */
92+
93+ setg_func = setg
94+ attr = (*pthread_attr_t)(malloc(unsafe.Sizeof(*attr)))
95+ if attr == nil {
96+ println("fakecgo: malloc failed")
97+ abort()
98+ }
99+ pthread_attr_init(attr)
100+ pthread_attr_getstacksize(attr, &size)
101+ // runtime/cgo uses __builtin_frame_address(0) instead of `uintptr(unsafe.Pointer(&size))`
102+ // but this should be OK since we are taking the address of the first variable in this function.
103+ g.stacklo = uintptr(unsafe.Pointer(&size)) - uintptr(size) + 4096
104+ pthread_attr_destroy(attr)
105+ free(unsafe.Pointer(attr))
106+}
M internal/fakecgo/go_setenv.go +1 -1
@@ -1,7 +1,7 @@
11 // SPDX-License-Identifier: Apache-2.0
22 // SPDX-FileCopyrightText: 2022 The Ebitengine Authors
33
4-//go:build !cgo && (darwin || freebsd || linux)
4+//go:build !cgo && (darwin || freebsd || linux || netbsd)
55
66 package fakecgo
77
@@ -1,7 +1,7 @@
1 // SPDX-License-Identifier: Apache-2.01 // SPDX-License-Identifier: Apache-2.0
2 // SPDX-FileCopyrightText: 2022 The Ebitengine Authors2 // SPDX-FileCopyrightText: 2022 The Ebitengine Authors
3 3
4-//go:build !cgo && (darwin || freebsd || linux)4+//go:build !cgo && (darwin || freebsd || linux || netbsd)
5 5
6 package fakecgo6 package fakecgo
7 7
M internal/fakecgo/go_util.go +1 -1
@@ -1,7 +1,7 @@
11 // SPDX-License-Identifier: Apache-2.0
22 // SPDX-FileCopyrightText: 2022 The Ebitengine Authors
33
4-//go:build !cgo && (darwin || freebsd || linux)
4+//go:build !cgo && (darwin || freebsd || linux || netbsd)
55
66 package fakecgo
77
@@ -1,7 +1,7 @@
1 // SPDX-License-Identifier: Apache-2.01 // SPDX-License-Identifier: Apache-2.0
2 // SPDX-FileCopyrightText: 2022 The Ebitengine Authors2 // SPDX-FileCopyrightText: 2022 The Ebitengine Authors
3 3
4-//go:build !cgo && (darwin || freebsd || linux)4+//go:build !cgo && (darwin || freebsd || linux || netbsd)
5 5
6 package fakecgo6 package fakecgo
7 7
M internal/fakecgo/iscgo.go +1 -1
@@ -2,7 +2,7 @@
22 // Use of this source code is governed by a BSD-style
33 // license that can be found in the LICENSE file.
44
5-//go:build !cgo && (darwin || freebsd || linux)
5+//go:build !cgo && (darwin || freebsd || linux || netbsd)
66
77 // The runtime package contains an uninitialized definition
88 // for runtime·iscgo. Override it to tell the runtime we're here.
@@ -2,7 +2,7 @@
2 // Use of this source code is governed by a BSD-style2 // Use of this source code is governed by a BSD-style
3 // license that can be found in the LICENSE file.3 // license that can be found in the LICENSE file.
4 4
5-//go:build !cgo && (darwin || freebsd || linux)5+//go:build !cgo && (darwin || freebsd || linux || netbsd)
6 6
7 // The runtime package contains an uninitialized definition7 // The runtime package contains an uninitialized definition
8 // for runtime·iscgo. Override it to tell the runtime we're here.8 // for runtime·iscgo. Override it to tell the runtime we're here.
M internal/fakecgo/libcgo.go +1 -1
@@ -1,7 +1,7 @@
11 // SPDX-License-Identifier: Apache-2.0
22 // SPDX-FileCopyrightText: 2022 The Ebitengine Authors
33
4-//go:build !cgo && (darwin || freebsd || linux)
4+//go:build !cgo && (darwin || freebsd || linux || netbsd)
55
66 package fakecgo
77
@@ -1,7 +1,7 @@
1 // SPDX-License-Identifier: Apache-2.01 // SPDX-License-Identifier: Apache-2.0
2 // SPDX-FileCopyrightText: 2022 The Ebitengine Authors2 // SPDX-FileCopyrightText: 2022 The Ebitengine Authors
3 3
4-//go:build !cgo && (darwin || freebsd || linux)4+//go:build !cgo && (darwin || freebsd || linux || netbsd)
5 5
6 package fakecgo6 package fakecgo
7 7
M internal/fakecgo/libcgo_darwin.go +4 -0
@@ -20,3 +20,7 @@ var (
2020 PTHREAD_COND_INITIALIZER = pthread_cond_t{sig: 0x3CB0B1BB}
2121 PTHREAD_MUTEX_INITIALIZER = pthread_mutex_t{sig: 0x32AAABA7}
2222 )
23+
24+type stack_t struct {
25+ /* not implemented */
26+}
@@ -20,3 +20,7 @@ var (
20 PTHREAD_COND_INITIALIZER = pthread_cond_t{sig: 0x3CB0B1BB}20 PTHREAD_COND_INITIALIZER = pthread_cond_t{sig: 0x3CB0B1BB}
21 PTHREAD_MUTEX_INITIALIZER = pthread_mutex_t{sig: 0x32AAABA7}21 PTHREAD_MUTEX_INITIALIZER = pthread_mutex_t{sig: 0x32AAABA7}
22 )22 )
23+
24+type stack_t struct {
25+ /* not implemented */
26+}
M internal/fakecgo/libcgo_freebsd.go +4 -0
@@ -14,3 +14,7 @@ var (
1414 PTHREAD_COND_INITIALIZER = pthread_cond_t(0)
1515 PTHREAD_MUTEX_INITIALIZER = pthread_mutex_t(0)
1616 )
17+
18+type stack_t struct {
19+ /* not implemented */
20+}
@@ -14,3 +14,7 @@ var (
14 PTHREAD_COND_INITIALIZER = pthread_cond_t(0)14 PTHREAD_COND_INITIALIZER = pthread_cond_t(0)
15 PTHREAD_MUTEX_INITIALIZER = pthread_mutex_t(0)15 PTHREAD_MUTEX_INITIALIZER = pthread_mutex_t(0)
16 )16 )
17+
18+type stack_t struct {
19+ /* not implemented */
20+}
M internal/fakecgo/libcgo_linux.go +4 -0
@@ -14,3 +14,7 @@ var (
1414 PTHREAD_COND_INITIALIZER = pthread_cond_t{}
1515 PTHREAD_MUTEX_INITIALIZER = pthread_mutex_t{}
1616 )
17+
18+type stack_t struct {
19+ /* not implemented */
20+}
@@ -14,3 +14,7 @@ var (
14 PTHREAD_COND_INITIALIZER = pthread_cond_t{}14 PTHREAD_COND_INITIALIZER = pthread_cond_t{}
15 PTHREAD_MUTEX_INITIALIZER = pthread_mutex_t{}15 PTHREAD_MUTEX_INITIALIZER = pthread_mutex_t{}
16 )16 )
17+
18+type stack_t struct {
19+ /* not implemented */
20+}
A internal/fakecgo/libcgo_netbsd.go +26 -0
@@ -0,0 +1,26 @@
1+// SPDX-License-Identifier: Apache-2.0
2+// SPDX-FileCopyrightText: 2025 The Ebitengine Authors
3+
4+//go:build !cgo
5+
6+package fakecgo
7+
8+type (
9+ pthread_cond_t uintptr
10+ pthread_mutex_t uintptr
11+)
12+
13+var (
14+ PTHREAD_COND_INITIALIZER = pthread_cond_t(0)
15+ PTHREAD_MUTEX_INITIALIZER = pthread_mutex_t(0)
16+)
17+
18+// Source: https://github.com/NetBSD/src/blob/613e27c65223fd2283b6ed679da1197e12f50e27/sys/compat/linux/arch/m68k/linux_signal.h#L133
19+type stack_t struct {
20+ ss_sp uintptr
21+ ss_flags int32
22+ ss_size uintptr
23+}
24+
25+// Source: https://github.com/NetBSD/src/blob/613e27c65223fd2283b6ed679da1197e12f50e27/sys/sys/signal.h#L261
26+const SS_DISABLE = 0x004
@@ -0,0 +1,26 @@
1+// SPDX-License-Identifier: Apache-2.0
2+// SPDX-FileCopyrightText: 2025 The Ebitengine Authors
3+
4+//go:build !cgo
5+
6+package fakecgo
7+
8+type (
9+ pthread_cond_t uintptr
10+ pthread_mutex_t uintptr
11+)
12+
13+var (
14+ PTHREAD_COND_INITIALIZER = pthread_cond_t(0)
15+ PTHREAD_MUTEX_INITIALIZER = pthread_mutex_t(0)
16+)
17+
18+// Source: https://github.com/NetBSD/src/blob/613e27c65223fd2283b6ed679da1197e12f50e27/sys/compat/linux/arch/m68k/linux_signal.h#L133
19+type stack_t struct {
20+ ss_sp uintptr
21+ ss_flags int32
22+ ss_size uintptr
23+}
24+
25+// Source: https://github.com/NetBSD/src/blob/613e27c65223fd2283b6ed679da1197e12f50e27/sys/sys/signal.h#L261
26+const SS_DISABLE = 0x004
A internal/fakecgo/netbsd.go +23 -0
@@ -0,0 +1,23 @@
1+// Copyright 2010 The Go Authors. All rights reserved.
2+// Use of this source code is governed by a BSD-style
3+// license that can be found in the LICENSE file.
4+
5+//go:build netbsd
6+
7+package fakecgo
8+
9+import _ "unsafe" // for go:linkname
10+
11+// Supply environ and __progname, because we don't
12+// link against the standard NetBSD crt0.o and the
13+// libc dynamic library needs them.
14+
15+//go:linkname _environ environ
16+//go:linkname _progname __progname
17+//go:linkname ___ps_strings __ps_strings
18+
19+var (
20+ _environ uintptr
21+ _progname uintptr
22+ ___ps_strings uintptr
23+)
@@ -0,0 +1,23 @@
1+// Copyright 2010 The Go Authors. All rights reserved.
2+// Use of this source code is governed by a BSD-style
3+// license that can be found in the LICENSE file.
4+
5+//go:build netbsd
6+
7+package fakecgo
8+
9+import _ "unsafe" // for go:linkname
10+
11+// Supply environ and __progname, because we don't
12+// link against the standard NetBSD crt0.o and the
13+// libc dynamic library needs them.
14+
15+//go:linkname _environ environ
16+//go:linkname _progname __progname
17+//go:linkname ___ps_strings __ps_strings
18+
19+var (
20+ _environ uintptr
21+ _progname uintptr
22+ ___ps_strings uintptr
23+)
M internal/fakecgo/setenv.go +1 -1
@@ -2,7 +2,7 @@
22 // Use of this source code is governed by a BSD-style
33 // license that can be found in the LICENSE file.
44
5-//go:build !cgo && (darwin || freebsd || linux)
5+//go:build !cgo && (darwin || freebsd || linux || netbsd)
66
77 package fakecgo
88
@@ -2,7 +2,7 @@
2 // Use of this source code is governed by a BSD-style2 // Use of this source code is governed by a BSD-style
3 // license that can be found in the LICENSE file.3 // license that can be found in the LICENSE file.
4 4
5-//go:build !cgo && (darwin || freebsd || linux)5+//go:build !cgo && (darwin || freebsd || linux || netbsd)
6 6
7 package fakecgo7 package fakecgo
8 8
M internal/fakecgo/symbols.go +10 -1
@@ -3,7 +3,7 @@
33 // SPDX-License-Identifier: Apache-2.0
44 // SPDX-FileCopyrightText: 2022 The Ebitengine Authors
55
6-//go:build !cgo && (darwin || freebsd || linux)
6+//go:build !cgo && (darwin || freebsd || linux || netbsd)
77
88 package fakecgo
99
@@ -55,6 +55,11 @@ func abort() {
5555 call5(abortABI0, 0, 0, 0, 0, 0)
5656 }
5757
58+//go:nosplit
59+func sigaltstack(ss *stack_t, old_ss *stack_t) int32 {
60+ return int32(call5(sigaltstackABI0, uintptr(unsafe.Pointer(ss)), uintptr(unsafe.Pointer(old_ss)), 0, 0, 0))
61+}
62+
5863 //go:nosplit
5964 func pthread_attr_init(attr *pthread_attr_t) int32 {
6065 return int32(call5(pthread_attr_initABI0, uintptr(unsafe.Pointer(attr)), 0, 0, 0, 0))
@@ -148,6 +153,10 @@ var nanosleepABI0 = uintptr(unsafe.Pointer(&_nanosleep))
148153 var _abort uintptr
149154 var abortABI0 = uintptr(unsafe.Pointer(&_abort))
150155
156+//go:linkname _sigaltstack _sigaltstack
157+var _sigaltstack uintptr
158+var sigaltstackABI0 = uintptr(unsafe.Pointer(&_sigaltstack))
159+
151160 //go:linkname _pthread_attr_init _pthread_attr_init
152161 var _pthread_attr_init uintptr
153162 var pthread_attr_initABI0 = uintptr(unsafe.Pointer(&_pthread_attr_init))
@@ -3,7 +3,7 @@
3 // SPDX-License-Identifier: Apache-2.03 // SPDX-License-Identifier: Apache-2.0
4 // SPDX-FileCopyrightText: 2022 The Ebitengine Authors4 // SPDX-FileCopyrightText: 2022 The Ebitengine Authors
5 5
6-//go:build !cgo && (darwin || freebsd || linux)6+//go:build !cgo && (darwin || freebsd || linux || netbsd)
7 7
8 package fakecgo8 package fakecgo
9 9
@@ -55,6 +55,11 @@ func abort() {
55 call5(abortABI0, 0, 0, 0, 0, 0)55 call5(abortABI0, 0, 0, 0, 0, 0)
56 }56 }
57 57
58+//go:nosplit
59+func sigaltstack(ss *stack_t, old_ss *stack_t) int32 {
60+ return int32(call5(sigaltstackABI0, uintptr(unsafe.Pointer(ss)), uintptr(unsafe.Pointer(old_ss)), 0, 0, 0))
61+}
62+
58 //go:nosplit63 //go:nosplit
59 func pthread_attr_init(attr *pthread_attr_t) int32 {64 func pthread_attr_init(attr *pthread_attr_t) int32 {
60 return int32(call5(pthread_attr_initABI0, uintptr(unsafe.Pointer(attr)), 0, 0, 0, 0))65 return int32(call5(pthread_attr_initABI0, uintptr(unsafe.Pointer(attr)), 0, 0, 0, 0))
@@ -148,6 +153,10 @@ var nanosleepABI0 = uintptr(unsafe.Pointer(&_nanosleep))
148 var _abort uintptr153 var _abort uintptr
149 var abortABI0 = uintptr(unsafe.Pointer(&_abort))154 var abortABI0 = uintptr(unsafe.Pointer(&_abort))
150 155
156+//go:linkname _sigaltstack _sigaltstack
157+var _sigaltstack uintptr
158+var sigaltstackABI0 = uintptr(unsafe.Pointer(&_sigaltstack))
159+
151 //go:linkname _pthread_attr_init _pthread_attr_init160 //go:linkname _pthread_attr_init _pthread_attr_init
152 var _pthread_attr_init uintptr161 var _pthread_attr_init uintptr
153 var pthread_attr_initABI0 = uintptr(unsafe.Pointer(&_pthread_attr_init))162 var pthread_attr_initABI0 = uintptr(unsafe.Pointer(&_pthread_attr_init))
M internal/fakecgo/symbols_darwin.go +1 -0
@@ -14,6 +14,7 @@ package fakecgo
1414 //go:cgo_import_dynamic purego_sigfillset sigfillset "/usr/lib/libSystem.B.dylib"
1515 //go:cgo_import_dynamic purego_nanosleep nanosleep "/usr/lib/libSystem.B.dylib"
1616 //go:cgo_import_dynamic purego_abort abort "/usr/lib/libSystem.B.dylib"
17+//go:cgo_import_dynamic purego_sigaltstack sigaltstack "/usr/lib/libSystem.B.dylib"
1718 //go:cgo_import_dynamic purego_pthread_attr_init pthread_attr_init "/usr/lib/libSystem.B.dylib"
1819 //go:cgo_import_dynamic purego_pthread_create pthread_create "/usr/lib/libSystem.B.dylib"
1920 //go:cgo_import_dynamic purego_pthread_detach pthread_detach "/usr/lib/libSystem.B.dylib"
@@ -14,6 +14,7 @@ package fakecgo
14 //go:cgo_import_dynamic purego_sigfillset sigfillset "/usr/lib/libSystem.B.dylib"14 //go:cgo_import_dynamic purego_sigfillset sigfillset "/usr/lib/libSystem.B.dylib"
15 //go:cgo_import_dynamic purego_nanosleep nanosleep "/usr/lib/libSystem.B.dylib"15 //go:cgo_import_dynamic purego_nanosleep nanosleep "/usr/lib/libSystem.B.dylib"
16 //go:cgo_import_dynamic purego_abort abort "/usr/lib/libSystem.B.dylib"16 //go:cgo_import_dynamic purego_abort abort "/usr/lib/libSystem.B.dylib"
17+//go:cgo_import_dynamic purego_sigaltstack sigaltstack "/usr/lib/libSystem.B.dylib"
17 //go:cgo_import_dynamic purego_pthread_attr_init pthread_attr_init "/usr/lib/libSystem.B.dylib"18 //go:cgo_import_dynamic purego_pthread_attr_init pthread_attr_init "/usr/lib/libSystem.B.dylib"
18 //go:cgo_import_dynamic purego_pthread_create pthread_create "/usr/lib/libSystem.B.dylib"19 //go:cgo_import_dynamic purego_pthread_create pthread_create "/usr/lib/libSystem.B.dylib"
19 //go:cgo_import_dynamic purego_pthread_detach pthread_detach "/usr/lib/libSystem.B.dylib"20 //go:cgo_import_dynamic purego_pthread_detach pthread_detach "/usr/lib/libSystem.B.dylib"
M internal/fakecgo/symbols_freebsd.go +1 -0
@@ -14,6 +14,7 @@ package fakecgo
1414 //go:cgo_import_dynamic purego_sigfillset sigfillset "libc.so.7"
1515 //go:cgo_import_dynamic purego_nanosleep nanosleep "libc.so.7"
1616 //go:cgo_import_dynamic purego_abort abort "libc.so.7"
17+//go:cgo_import_dynamic purego_sigaltstack sigaltstack "libc.so.7"
1718 //go:cgo_import_dynamic purego_pthread_attr_init pthread_attr_init "libpthread.so"
1819 //go:cgo_import_dynamic purego_pthread_create pthread_create "libpthread.so"
1920 //go:cgo_import_dynamic purego_pthread_detach pthread_detach "libpthread.so"
@@ -14,6 +14,7 @@ package fakecgo
14 //go:cgo_import_dynamic purego_sigfillset sigfillset "libc.so.7"14 //go:cgo_import_dynamic purego_sigfillset sigfillset "libc.so.7"
15 //go:cgo_import_dynamic purego_nanosleep nanosleep "libc.so.7"15 //go:cgo_import_dynamic purego_nanosleep nanosleep "libc.so.7"
16 //go:cgo_import_dynamic purego_abort abort "libc.so.7"16 //go:cgo_import_dynamic purego_abort abort "libc.so.7"
17+//go:cgo_import_dynamic purego_sigaltstack sigaltstack "libc.so.7"
17 //go:cgo_import_dynamic purego_pthread_attr_init pthread_attr_init "libpthread.so"18 //go:cgo_import_dynamic purego_pthread_attr_init pthread_attr_init "libpthread.so"
18 //go:cgo_import_dynamic purego_pthread_create pthread_create "libpthread.so"19 //go:cgo_import_dynamic purego_pthread_create pthread_create "libpthread.so"
19 //go:cgo_import_dynamic purego_pthread_detach pthread_detach "libpthread.so"20 //go:cgo_import_dynamic purego_pthread_detach pthread_detach "libpthread.so"
M internal/fakecgo/symbols_linux.go +1 -0
@@ -14,6 +14,7 @@ package fakecgo
1414 //go:cgo_import_dynamic purego_sigfillset sigfillset "libc.so.6"
1515 //go:cgo_import_dynamic purego_nanosleep nanosleep "libc.so.6"
1616 //go:cgo_import_dynamic purego_abort abort "libc.so.6"
17+//go:cgo_import_dynamic purego_sigaltstack sigaltstack "libc.so.6"
1718 //go:cgo_import_dynamic purego_pthread_attr_init pthread_attr_init "libpthread.so.0"
1819 //go:cgo_import_dynamic purego_pthread_create pthread_create "libpthread.so.0"
1920 //go:cgo_import_dynamic purego_pthread_detach pthread_detach "libpthread.so.0"
@@ -14,6 +14,7 @@ package fakecgo
14 //go:cgo_import_dynamic purego_sigfillset sigfillset "libc.so.6"14 //go:cgo_import_dynamic purego_sigfillset sigfillset "libc.so.6"
15 //go:cgo_import_dynamic purego_nanosleep nanosleep "libc.so.6"15 //go:cgo_import_dynamic purego_nanosleep nanosleep "libc.so.6"
16 //go:cgo_import_dynamic purego_abort abort "libc.so.6"16 //go:cgo_import_dynamic purego_abort abort "libc.so.6"
17+//go:cgo_import_dynamic purego_sigaltstack sigaltstack "libc.so.6"
17 //go:cgo_import_dynamic purego_pthread_attr_init pthread_attr_init "libpthread.so.0"18 //go:cgo_import_dynamic purego_pthread_attr_init pthread_attr_init "libpthread.so.0"
18 //go:cgo_import_dynamic purego_pthread_create pthread_create "libpthread.so.0"19 //go:cgo_import_dynamic purego_pthread_create pthread_create "libpthread.so.0"
19 //go:cgo_import_dynamic purego_pthread_detach pthread_detach "libpthread.so.0"20 //go:cgo_import_dynamic purego_pthread_detach pthread_detach "libpthread.so.0"
A internal/fakecgo/symbols_netbsd.go +30 -0
@@ -0,0 +1,30 @@
1+// Code generated by 'go generate' with gen.go. DO NOT EDIT.
2+
3+// SPDX-License-Identifier: Apache-2.0
4+// SPDX-FileCopyrightText: 2022 The Ebitengine Authors
5+
6+//go:build !cgo
7+
8+package fakecgo
9+
10+//go:cgo_import_dynamic purego_malloc malloc "libc.so"
11+//go:cgo_import_dynamic purego_free free "libc.so"
12+//go:cgo_import_dynamic purego_setenv setenv "libc.so"
13+//go:cgo_import_dynamic purego_unsetenv unsetenv "libc.so"
14+//go:cgo_import_dynamic purego_sigfillset sigfillset "libc.so"
15+//go:cgo_import_dynamic purego_nanosleep nanosleep "libc.so"
16+//go:cgo_import_dynamic purego_abort abort "libc.so"
17+//go:cgo_import_dynamic purego_sigaltstack sigaltstack "libc.so"
18+//go:cgo_import_dynamic purego_pthread_attr_init pthread_attr_init "libpthread.so"
19+//go:cgo_import_dynamic purego_pthread_create pthread_create "libpthread.so"
20+//go:cgo_import_dynamic purego_pthread_detach pthread_detach "libpthread.so"
21+//go:cgo_import_dynamic purego_pthread_sigmask pthread_sigmask "libpthread.so"
22+//go:cgo_import_dynamic purego_pthread_self pthread_self "libpthread.so"
23+//go:cgo_import_dynamic purego_pthread_get_stacksize_np pthread_get_stacksize_np "libpthread.so"
24+//go:cgo_import_dynamic purego_pthread_attr_getstacksize pthread_attr_getstacksize "libpthread.so"
25+//go:cgo_import_dynamic purego_pthread_attr_setstacksize pthread_attr_setstacksize "libpthread.so"
26+//go:cgo_import_dynamic purego_pthread_attr_destroy pthread_attr_destroy "libpthread.so"
27+//go:cgo_import_dynamic purego_pthread_mutex_lock pthread_mutex_lock "libpthread.so"
28+//go:cgo_import_dynamic purego_pthread_mutex_unlock pthread_mutex_unlock "libpthread.so"
29+//go:cgo_import_dynamic purego_pthread_cond_broadcast pthread_cond_broadcast "libpthread.so"
30+//go:cgo_import_dynamic purego_pthread_setspecific pthread_setspecific "libpthread.so"
@@ -0,0 +1,30 @@
1+// Code generated by 'go generate' with gen.go. DO NOT EDIT.
2+
3+// SPDX-License-Identifier: Apache-2.0
4+// SPDX-FileCopyrightText: 2022 The Ebitengine Authors
5+
6+//go:build !cgo
7+
8+package fakecgo
9+
10+//go:cgo_import_dynamic purego_malloc malloc "libc.so"
11+//go:cgo_import_dynamic purego_free free "libc.so"
12+//go:cgo_import_dynamic purego_setenv setenv "libc.so"
13+//go:cgo_import_dynamic purego_unsetenv unsetenv "libc.so"
14+//go:cgo_import_dynamic purego_sigfillset sigfillset "libc.so"
15+//go:cgo_import_dynamic purego_nanosleep nanosleep "libc.so"
16+//go:cgo_import_dynamic purego_abort abort "libc.so"
17+//go:cgo_import_dynamic purego_sigaltstack sigaltstack "libc.so"
18+//go:cgo_import_dynamic purego_pthread_attr_init pthread_attr_init "libpthread.so"
19+//go:cgo_import_dynamic purego_pthread_create pthread_create "libpthread.so"
20+//go:cgo_import_dynamic purego_pthread_detach pthread_detach "libpthread.so"
21+//go:cgo_import_dynamic purego_pthread_sigmask pthread_sigmask "libpthread.so"
22+//go:cgo_import_dynamic purego_pthread_self pthread_self "libpthread.so"
23+//go:cgo_import_dynamic purego_pthread_get_stacksize_np pthread_get_stacksize_np "libpthread.so"
24+//go:cgo_import_dynamic purego_pthread_attr_getstacksize pthread_attr_getstacksize "libpthread.so"
25+//go:cgo_import_dynamic purego_pthread_attr_setstacksize pthread_attr_setstacksize "libpthread.so"
26+//go:cgo_import_dynamic purego_pthread_attr_destroy pthread_attr_destroy "libpthread.so"
27+//go:cgo_import_dynamic purego_pthread_mutex_lock pthread_mutex_lock "libpthread.so"
28+//go:cgo_import_dynamic purego_pthread_mutex_unlock pthread_mutex_unlock "libpthread.so"
29+//go:cgo_import_dynamic purego_pthread_cond_broadcast pthread_cond_broadcast "libpthread.so"
30+//go:cgo_import_dynamic purego_pthread_setspecific pthread_setspecific "libpthread.so"
M internal/fakecgo/trampolines_stubs.s +5 -1
@@ -3,7 +3,7 @@
33 // SPDX-License-Identifier: Apache-2.0
44 // SPDX-FileCopyrightText: 2022 The Ebitengine Authors
55
6-//go:build !cgo && (darwin || freebsd || linux)
6+//go:build !cgo && (darwin || freebsd || linux || netbsd)
77
88 #include "textflag.h"
99
@@ -37,6 +37,10 @@ TEXT _abort(SB), NOSPLIT|NOFRAME, $0-0
3737 JMP purego_abort(SB)
3838 RET
3939
40+TEXT _sigaltstack(SB), NOSPLIT|NOFRAME, $0-0
41+ JMP purego_sigaltstack(SB)
42+ RET
43+
4044 TEXT _pthread_attr_init(SB), NOSPLIT|NOFRAME, $0-0
4145 JMP purego_pthread_attr_init(SB)
4246 RET
@@ -3,7 +3,7 @@
3 // SPDX-License-Identifier: Apache-2.03 // SPDX-License-Identifier: Apache-2.0
4 // SPDX-FileCopyrightText: 2022 The Ebitengine Authors4 // SPDX-FileCopyrightText: 2022 The Ebitengine Authors
5 5
6-//go:build !cgo && (darwin || freebsd || linux)6+//go:build !cgo && (darwin || freebsd || linux || netbsd)
7 7
8 #include "textflag.h"8 #include "textflag.h"
9 9
@@ -37,6 +37,10 @@ TEXT _abort(SB), NOSPLIT|NOFRAME, $0-0
37 JMP purego_abort(SB)37 JMP purego_abort(SB)
38 RET38 RET
39 39
40+TEXT _sigaltstack(SB), NOSPLIT|NOFRAME, $0-0
41+ JMP purego_sigaltstack(SB)
42+ RET
43+
40 TEXT _pthread_attr_init(SB), NOSPLIT|NOFRAME, $0-044 TEXT _pthread_attr_init(SB), NOSPLIT|NOFRAME, $0-0
41 JMP purego_pthread_attr_init(SB)45 JMP purego_pthread_attr_init(SB)
42 RET46 RET
M internal/load/load_unix.go +1 -1
@@ -1,7 +1,7 @@
11 // SPDX-License-Identifier: Apache-2.0
22 // SPDX-FileCopyrightText: 2024 The Ebitengine Authors
33
4-//go:build darwin || freebsd || linux
4+//go:build darwin || freebsd || linux || netbsd
55
66 package load
77
@@ -1,7 +1,7 @@
1 // SPDX-License-Identifier: Apache-2.01 // SPDX-License-Identifier: Apache-2.0
2 // SPDX-FileCopyrightText: 2024 The Ebitengine Authors2 // SPDX-FileCopyrightText: 2024 The Ebitengine Authors
3 3
4-//go:build darwin || freebsd || linux4+//go:build darwin || freebsd || linux || netbsd
5 5
6 package load6 package load
7 7
M nocgo.go +1 -1
@@ -1,7 +1,7 @@
11 // SPDX-License-Identifier: Apache-2.0
22 // SPDX-FileCopyrightText: 2022 The Ebitengine Authors
33
4-//go:build !cgo && (darwin || freebsd || linux)
4+//go:build !cgo && (darwin || freebsd || linux || netbsd)
55
66 package purego
77
@@ -1,7 +1,7 @@
1 // SPDX-License-Identifier: Apache-2.01 // SPDX-License-Identifier: Apache-2.0
2 // SPDX-FileCopyrightText: 2022 The Ebitengine Authors2 // SPDX-FileCopyrightText: 2022 The Ebitengine Authors
3 3
4-//go:build !cgo && (darwin || freebsd || linux)4+//go:build !cgo && (darwin || freebsd || linux || netbsd)
5 5
6 package purego6 package purego
7 7
M sys_amd64.s +1 -1
@@ -1,7 +1,7 @@
11 // SPDX-License-Identifier: Apache-2.0
22 // SPDX-FileCopyrightText: 2022 The Ebitengine Authors
33
4-//go:build darwin || freebsd || linux
4+//go:build darwin || freebsd || linux || netbsd
55
66 #include "textflag.h"
77 #include "abi_amd64.h"
@@ -1,7 +1,7 @@
1 // SPDX-License-Identifier: Apache-2.01 // SPDX-License-Identifier: Apache-2.0
2 // SPDX-FileCopyrightText: 2022 The Ebitengine Authors2 // SPDX-FileCopyrightText: 2022 The Ebitengine Authors
3 3
4-//go:build darwin || freebsd || linux4+//go:build darwin || freebsd || linux || netbsd
5 5
6 #include "textflag.h"6 #include "textflag.h"
7 #include "abi_amd64.h"7 #include "abi_amd64.h"
M sys_arm64.s +1 -1
@@ -1,7 +1,7 @@
11 // SPDX-License-Identifier: Apache-2.0
22 // SPDX-FileCopyrightText: 2022 The Ebitengine Authors
33
4-//go:build darwin || freebsd || linux || windows
4+//go:build darwin || freebsd || linux || netbsd || windows
55
66 #include "textflag.h"
77 #include "go_asm.h"
@@ -1,7 +1,7 @@
1 // SPDX-License-Identifier: Apache-2.01 // SPDX-License-Identifier: Apache-2.0
2 // SPDX-FileCopyrightText: 2022 The Ebitengine Authors2 // SPDX-FileCopyrightText: 2022 The Ebitengine Authors
3 3
4-//go:build darwin || freebsd || linux || windows4+//go:build darwin || freebsd || linux || netbsd || windows
5 5
6 #include "textflag.h"6 #include "textflag.h"
7 #include "go_asm.h"7 #include "go_asm.h"
M sys_unix_arm64.s +1 -1
@@ -1,7 +1,7 @@
11 // SPDX-License-Identifier: Apache-2.0
22 // SPDX-FileCopyrightText: 2023 The Ebitengine Authors
33
4-//go:build darwin || freebsd || linux
4+//go:build darwin || freebsd || linux || netbsd
55
66 #include "textflag.h"
77 #include "go_asm.h"
@@ -1,7 +1,7 @@
1 // SPDX-License-Identifier: Apache-2.01 // SPDX-License-Identifier: Apache-2.0
2 // SPDX-FileCopyrightText: 2023 The Ebitengine Authors2 // SPDX-FileCopyrightText: 2023 The Ebitengine Authors
3 3
4-//go:build darwin || freebsd || linux4+//go:build darwin || freebsd || linux || netbsd
5 5
6 #include "textflag.h"6 #include "textflag.h"
7 #include "go_asm.h"7 #include "go_asm.h"
M syscall.go +1 -1
@@ -1,7 +1,7 @@
11 // SPDX-License-Identifier: Apache-2.0
22 // SPDX-FileCopyrightText: 2022 The Ebitengine Authors
33
4-//go:build darwin || freebsd || linux || windows
4+//go:build darwin || freebsd || linux || netbsd || windows
55
66 package purego
77
@@ -1,7 +1,7 @@
1 // SPDX-License-Identifier: Apache-2.01 // SPDX-License-Identifier: Apache-2.0
2 // SPDX-FileCopyrightText: 2022 The Ebitengine Authors2 // SPDX-FileCopyrightText: 2022 The Ebitengine Authors
3 3
4-//go:build darwin || freebsd || linux || windows4+//go:build darwin || freebsd || linux || netbsd || windows
5 5
6 package purego6 package purego
7 7
M syscall_sysv.go +1 -1
@@ -1,7 +1,7 @@
11 // SPDX-License-Identifier: Apache-2.0
22 // SPDX-FileCopyrightText: 2022 The Ebitengine Authors
33
4-//go:build darwin || freebsd || (linux && (amd64 || arm64))
4+//go:build darwin || freebsd || (linux && (amd64 || arm64)) || netbsd
55
66 package purego
77
@@ -1,7 +1,7 @@
1 // SPDX-License-Identifier: Apache-2.01 // SPDX-License-Identifier: Apache-2.0
2 // SPDX-FileCopyrightText: 2022 The Ebitengine Authors2 // SPDX-FileCopyrightText: 2022 The Ebitengine Authors
3 3
4-//go:build darwin || freebsd || (linux && (amd64 || arm64))4+//go:build darwin || freebsd || (linux && (amd64 || arm64)) || netbsd
5 5
6 package purego6 package purego
7 7
M zcallback_amd64.s +1 -1
@@ -1,6 +1,6 @@
11 // Code generated by wincallback.go using 'go generate'. DO NOT EDIT.
22
3-//go:build darwin || freebsd || linux
3+//go:build darwin || freebsd || linux || netbsd
44
55 // runtime·callbackasm is called by external code to
66 // execute Go implemented callback function. It is not
@@ -1,6 +1,6 @@
1 // Code generated by wincallback.go using 'go generate'. DO NOT EDIT.1 // Code generated by wincallback.go using 'go generate'. DO NOT EDIT.
2 2
3-//go:build darwin || freebsd || linux3+//go:build darwin || freebsd || linux || netbsd
4 4
5 // runtime·callbackasm is called by external code to5 // runtime·callbackasm is called by external code to
6 // execute Go implemented callback function. It is not6 // execute Go implemented callback function. It is not
M zcallback_arm64.s +1 -1
@@ -1,6 +1,6 @@
11 // Code generated by wincallback.go using 'go generate'. DO NOT EDIT.
22
3-//go:build darwin || freebsd || linux
3+//go:build darwin || freebsd || linux || netbsd
44
55 // External code calls into callbackasm at an offset corresponding
66 // to the callback index. Callbackasm is a table of MOV and B instructions.
@@ -1,6 +1,6 @@
1 // Code generated by wincallback.go using 'go generate'. DO NOT EDIT.1 // Code generated by wincallback.go using 'go generate'. DO NOT EDIT.
2 2
3-//go:build darwin || freebsd || linux3+//go:build darwin || freebsd || linux || netbsd
4 4
5 // External code calls into callbackasm at an offset corresponding5 // External code calls into callbackasm at an offset corresponding
6 // to the callback index. Callbackasm is a table of MOV and B instructions.6 // to the callback index. Callbackasm is a table of MOV and B instructions.

Keyboard shortcuts

Single-key shortcuts are on. ctrl k and esc work whatever this says.

ctrl k :
go to a section, branch, tag, file or repository
?
this list
j k
move the row cursor down / up
enter
open the row under the cursor; on Files, a directory opens or closes in place
↑ ↓ ← → home end
in the file tree (focus on a row): previous / next row, close / open a directory or go to its parent / first entry, first / last row. They never open a file
l h
on Files: open a directory or a file / close a directory or go up to its parent, then to the parent page. Elsewhere: into the side panel (on a merge request, its files) / back to the content; there j k move between its controls
g g G
first / last row
/
filter the list; on Files, find a file anywhere in the repository (esc clears, enter opens the best match)
b
switch branch or tag
g s g f g c g b g m g i g r g a
tabs: summary, files, commits, branches & tags, merge requests, issues, releases, actions (when available)
g h
home
w
wide mode: use the whole width of the screen, or not (remembered)
y
copy a permalink pinned to the commit
d u x
diff: split / unified / collapse or expand all
e E
diff: the whole file in view / every file, with the lines the hunks hide
n
merge request: next note in the diff
esc
close a dialog, leave a field

Branches 1

Tags 102

↑↓ moveenter openesc close