From: Robert-André Mauchin From: Maytham Alsudany Origin: upstream, https://github.com/cronokirby/saferith/pull/54 Bug: https://github.com/cronokirby/saferith/issues/52 Subject: Fix build for s390x architectures - Prefix addvectorfacility/subvectorfacility in arith_s390x.s to avoid conflict with math/big - Correct package name in architecture arith_s390x_test.go - Add additional code required for arith_s390x_test.go --- a/arith_s390x.s +++ b/arith_s390x.s @@ -23,13 +23,13 @@ // func addVV(z, x, y []Word) (c Word) TEXT ·addVV(SB), NOSPLIT, $0 - MOVD addvectorfacility+0x00(SB), R1 + MOVD saferith_addvectorfacility+0x00(SB), R1 BR (R1) TEXT ·addVV_check(SB), NOSPLIT, $0 MOVB ·hasVX(SB), R1 CMPBEQ R1, $1, vectorimpl // vectorfacility = 1, vector supported - MOVD $addvectorfacility+0x00(SB), R1 + MOVD $saferith_addvectorfacility+0x00(SB), R1 MOVD $·addVV_novec(SB), R2 MOVD R2, 0(R1) @@ -37,15 +37,15 @@ BR ·addVV_novec(SB) vectorimpl: - MOVD $addvectorfacility+0x00(SB), R1 + MOVD $saferith_addvectorfacility+0x00(SB), R1 MOVD $·addVV_vec(SB), R2 MOVD R2, 0(R1) // MOVD $·addVV_vec(SB), 0(R1) BR ·addVV_vec(SB) -GLOBL addvectorfacility+0x00(SB), NOPTR, $8 -DATA addvectorfacility+0x00(SB)/8, $·addVV_check(SB) +GLOBL saferith_addvectorfacility+0x00(SB), NOPTR, $8 +DATA saferith_addvectorfacility+0x00(SB)/8, $·addVV_check(SB) TEXT ·addVV_vec(SB), NOSPLIT, $0 MOVD z_len+8(FP), R3 @@ -265,13 +265,13 @@ RET TEXT ·subVV(SB), NOSPLIT, $0 - MOVD subvectorfacility+0x00(SB), R1 + MOVD saferith_subvectorfacility+0x00(SB), R1 BR (R1) TEXT ·subVV_check(SB), NOSPLIT, $0 MOVB ·hasVX(SB), R1 CMPBEQ R1, $1, vectorimpl // vectorfacility = 1, vector supported - MOVD $subvectorfacility+0x00(SB), R1 + MOVD $saferith_subvectorfacility+0x00(SB), R1 MOVD $·subVV_novec(SB), R2 MOVD R2, 0(R1) @@ -279,15 +279,15 @@ BR ·subVV_novec(SB) vectorimpl: - MOVD $subvectorfacility+0x00(SB), R1 + MOVD $saferith_subvectorfacility+0x00(SB), R1 MOVD $·subVV_vec(SB), R2 MOVD R2, 0(R1) // MOVD $·subVV_vec(SB), 0(R1) BR ·subVV_vec(SB) -GLOBL subvectorfacility+0x00(SB), NOPTR, $8 -DATA subvectorfacility+0x00(SB)/8, $·subVV_check(SB) +GLOBL saferith_subvectorfacility+0x00(SB), NOPTR, $8 +DATA saferith_subvectorfacility+0x00(SB)/8, $·subVV_check(SB) // DI = R3, CX = R4, SI = r10, r8 = r8, r9=r9, r10 = r2, r11 = r5, r12 = r6, r13 = r7, r14 = r1 (R0 set to 0) + use R11 // func subVV(z, x, y []Word) (c Word) --- a/arith_s390x_test.go +++ b/arith_s390x_test.go @@ -5,12 +5,47 @@ //go:build s390x && !math_big_pure_go // +build s390x,!math_big_pure_go -package big +package saferith import ( "testing" ) +type nat []Word + +type funVV func(z, x, y []Word) (c Word) + +type argVV struct { + z, x, y nat + c Word +} + +var sumVV = []argVV{ + {}, + {nat{0}, nat{0}, nat{0}, 0}, + {nat{1}, nat{1}, nat{0}, 0}, + {nat{0}, nat{_M}, nat{1}, 1}, + {nat{80235}, nat{12345}, nat{67890}, 0}, + {nat{_M - 1}, nat{_M}, nat{_M}, 1}, + {nat{0, 0, 0, 0}, nat{_M, _M, _M, _M}, nat{1, 0, 0, 0}, 1}, + {nat{0, 0, 0, _M}, nat{_M, _M, _M, _M - 1}, nat{1, 0, 0, 0}, 0}, + {nat{0, 0, 0, 0}, nat{_M, 0, _M, 0}, nat{1, _M, 0, _M}, 1}, +} + +func testFunVV(t *testing.T, msg string, f funVV, a argVV) { + z := make(nat, len(a.z)) + c := f(z, a.x, a.y) + for i, zi := range z { + if zi != a.z[i] { + t.Errorf("%s%+v\n\tgot z[%d] = %#x; want %#x", msg, a, i, zi, a.z[i]) + break + } + } + if c != a.c { + t.Errorf("%s%+v\n\tgot c = %#x; want %#x", msg, a, c, a.c) + } +} + // Tests whether the non vector routines are working, even when the tests are run on a // vector-capable machine