From f9acdeae5f29f42f287f8a6a28c75a40e93049fb Mon Sep 17 00:00:00 2001 From: Dmitry Ng <19asdek91@gmail.com> Date: Fri, 5 May 2023 16:29:58 +0300 Subject: [PATCH] Added arch i386 support (#3) * feat: added arch i386 support * fix: using another actions for i386 according to https://github.com/uraimo/run-on-arch-action/pull/58 * fix: using refs for actions link * fix: refs to full commit version hash * fix: changed base action image to own fork * fix: arch typo 386 => i386 --- .github/workflows/test.yml | 22 +++++++++++++++++++++- goid/goid_386.go | 7 +++++++ goid/goid_386.s | 8 ++++++++ 3 files changed, 36 insertions(+), 1 deletion(-) create mode 100644 goid/goid_386.go create mode 100644 goid/goid_386.s diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 6d57183..8d54f77 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -18,6 +18,7 @@ jobs: fail-fast: false matrix: arch: + - i386 - arm64 - amd64 go: @@ -44,6 +45,25 @@ jobs: if: ${{ matrix.arch == 'amd64' }} run: go test -bench=. -benchmem -race -v ./... + # 386 + - name: 'Build with ${{ matrix.go }} for i386' + if: ${{ matrix.arch == 'i386' }} + env: + GOARCH: 386 + run: | + go test -c *.go && cd goid && go test -c ./... + + - name: 'Test and Bench with ${{ matrix.go }} on i386' + if: ${{ matrix.arch == 'i386' }} + uses: vxcontrol/run-on-arch-action@0.9.0 + with: + arch: i386 + distro: bullseye + dockerRunArgs: --mount type=bind,source="$(pwd)",target=/checkout,readonly + run: | + find /checkout -name '*.test' -type f -executable -print0 | \ + xargs -t -0 -I '{}' sh -c '{} -test.v && {} -test.bench=. -test.benchmem -test.v' + # arm64 - name: 'Build with ${{ matrix.go }} for arm64' if: ${{ matrix.arch == 'arm64' }} @@ -54,7 +74,7 @@ jobs: - name: 'Test and Bench with ${{ matrix.go }} on arm64' if: ${{ matrix.arch == 'arm64' }} - uses: uraimo/run-on-arch-action@v2 + uses: vxcontrol/run-on-arch-action@0.9.0 with: arch: aarch64 distro: bullseye diff --git a/goid/goid_386.go b/goid/goid_386.go new file mode 100644 index 0000000..58531e9 --- /dev/null +++ b/goid/goid_386.go @@ -0,0 +1,7 @@ +package goid + +func getg() *g + +func Get() int64 { + return getg().goid +} diff --git a/goid/goid_386.s b/goid/goid_386.s new file mode 100644 index 0000000..4dd1ccf --- /dev/null +++ b/goid/goid_386.s @@ -0,0 +1,8 @@ +#include "go_asm.h" +#include "textflag.h" + +TEXT ·getg(SB), NOSPLIT, $0-4 + MOVL TLS, CX + MOVL 0(CX)(TLS*1), AX + MOVL AX, ret+0(FP) + RET