Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use go:linkname instead of asm jmp. #15

Merged
merged 1 commit into from
Jan 26, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 0 additions & 36 deletions arith_386.s

This file was deleted.

38 changes: 0 additions & 38 deletions arith_amd64.s

This file was deleted.

36 changes: 0 additions & 36 deletions arith_arm.s

This file was deleted.

36 changes: 0 additions & 36 deletions arith_arm64.s

This file was deleted.

21 changes: 19 additions & 2 deletions arith_decl.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,30 @@

package bigfft

import . "math/big"
import (
"math/big"
_ "unsafe"
)

// implemented in arith_$GOARCH.s
type Word = big.Word

//go:linkname addVV math/big.addVV
func addVV(z, x, y []Word) (c Word)

//go:linkname subVV math/big.subVV
func subVV(z, x, y []Word) (c Word)

//go:linkname addVW math/big.addVW
func addVW(z, x []Word, y Word) (c Word)

//go:linkname subVW math/big.subVW
func subVW(z, x []Word, y Word) (c Word)

//go:linkname shlVU math/big.shlVU
func shlVU(z, x []Word, s uint) (c Word)

//go:linkname mulAddVWW math/big.mulAddVWW
func mulAddVWW(z, x []Word, y, r Word) (c Word)

//go:linkname addMulVVW math/big.addMulVVW
func addMulVVW(z, x []Word, y Word) (c Word)
40 changes: 0 additions & 40 deletions arith_mips64x.s

This file was deleted.

40 changes: 0 additions & 40 deletions arith_mipsx.s

This file was deleted.

38 changes: 0 additions & 38 deletions arith_ppc64x.s

This file was deleted.

37 changes: 0 additions & 37 deletions arith_s390x.s

This file was deleted.

14 changes: 9 additions & 5 deletions fermat_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,14 @@ package bigfft

import (
"fmt"
. "math/big"
"math/big"
"testing"
)

type (
Int = big.Int
)

// parseHex reads an hex-formatted number modulo 2^bits+1.
func parseHex(s string, bits int) fermat {
z := new(Int)
Expand Down Expand Up @@ -35,9 +39,9 @@ func TestFermatShift(t *testing.T) {
for i := 0; i < n; i++ {
f[i] = Word(rnd.Int63())
}
b := NewInt(1)
b := big.NewInt(1)
b = b.Lsh(b, uint(n*_W))
b = b.Add(b, NewInt(1))
b = b.Add(b, big.NewInt(1))
z := make(fermat, len(f)) // Test with uninitialized z.
for shift := -2048; shift < 2048; shift++ {
z.Shift(f, shift)
Expand All @@ -61,9 +65,9 @@ func TestFermatShiftHalf(t *testing.T) {
for i := 0; i < n; i++ {
f[i] = ^Word(0)
}
b := NewInt(1)
b := big.NewInt(1)
b = b.Lsh(b, uint(n*_W))
b = b.Add(b, NewInt(1))
b = b.Add(b, big.NewInt(1))
z := make(fermat, len(f)) // Test with uninitialized z.
tmp := make(fermat, len(f))
tmp2 := make(fermat, len(f))
Expand Down
Loading