Debian Codegraph @

debian/patches/fix-failing-s390x-build.patch

raw
1 From: Robert-André Mauchin <[email protected]>
2 From: Maytham Alsudany <[email protected]>
3 Origin: upstream, https://github.com/cronokirby/saferith/pull/54
4 Bug: https://github.com/cronokirby/saferith/issues/52
5 Subject: Fix build for s390x architectures
6
7 - Prefix addvectorfacility/subvectorfacility in arith_s390x.s to avoid
8 conflict with math/big
9 - Correct package name in architecture arith_s390x_test.go
10 - Add additional code required for arith_s390x_test.go
11
12 --- a/arith_s390x.s
13 +++ b/arith_s390x.s
14 @@ -23,13 +23,13 @@
15 // func addVV(z, x, y []Word) (c Word)
16
17 TEXT ·addVV(SB), NOSPLIT, $0
18 - MOVD addvectorfacility+0x00(SB), R1
19 + MOVD saferith_addvectorfacility+0x00(SB), R1
20 BR (R1)
21
22 TEXT ·addVV_check(SB), NOSPLIT, $0
23 MOVB ·hasVX(SB), R1
24 CMPBEQ R1, $1, vectorimpl // vectorfacility = 1, vector supported
25 - MOVD $addvectorfacility+0x00(SB), R1
26 + MOVD $saferith_addvectorfacility+0x00(SB), R1
27 MOVD $·addVV_novec(SB), R2
28 MOVD R2, 0(R1)
29
30 @@ -37,15 +37,15 @@
31 BR ·addVV_novec(SB)
32
33 vectorimpl:
34 - MOVD $addvectorfacility+0x00(SB), R1
35 + MOVD $saferith_addvectorfacility+0x00(SB), R1
36 MOVD $·addVV_vec(SB), R2
37 MOVD R2, 0(R1)
38
39 // MOVD $·addVV_vec(SB), 0(R1)
40 BR ·addVV_vec(SB)
41
42 -GLOBL addvectorfacility+0x00(SB), NOPTR, $8
43 -DATA addvectorfacility+0x00(SB)/8, $·addVV_check(SB)
44 +GLOBL saferith_addvectorfacility+0x00(SB), NOPTR, $8
45 +DATA saferith_addvectorfacility+0x00(SB)/8, $·addVV_check(SB)
46
47 TEXT ·addVV_vec(SB), NOSPLIT, $0
48 MOVD z_len+8(FP), R3
49 @@ -265,13 +265,13 @@
50 RET
51
52 TEXT ·subVV(SB), NOSPLIT, $0
53 - MOVD subvectorfacility+0x00(SB), R1
54 + MOVD saferith_subvectorfacility+0x00(SB), R1
55 BR (R1)
56
57 TEXT ·subVV_check(SB), NOSPLIT, $0
58 MOVB ·hasVX(SB), R1
59 CMPBEQ R1, $1, vectorimpl // vectorfacility = 1, vector supported
60 - MOVD $subvectorfacility+0x00(SB), R1
61 + MOVD $saferith_subvectorfacility+0x00(SB), R1
62 MOVD $·subVV_novec(SB), R2
63 MOVD R2, 0(R1)
64
65 @@ -279,15 +279,15 @@
66 BR ·subVV_novec(SB)
67
68 vectorimpl:
69 - MOVD $subvectorfacility+0x00(SB), R1
70 + MOVD $saferith_subvectorfacility+0x00(SB), R1
71 MOVD $·subVV_vec(SB), R2
72 MOVD R2, 0(R1)
73
74 // MOVD $·subVV_vec(SB), 0(R1)
75 BR ·subVV_vec(SB)
76
77 -GLOBL subvectorfacility+0x00(SB), NOPTR, $8
78 -DATA subvectorfacility+0x00(SB)/8, $·subVV_check(SB)
79 +GLOBL saferith_subvectorfacility+0x00(SB), NOPTR, $8
80 +DATA saferith_subvectorfacility+0x00(SB)/8, $·subVV_check(SB)
81
82 // 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
83 // func subVV(z, x, y []Word) (c Word)
84 --- a/arith_s390x_test.go
85 +++ b/arith_s390x_test.go
86 @@ -5,12 +5,47 @@
87 //go:build s390x && !math_big_pure_go
88 // +build s390x,!math_big_pure_go
89
90 -package big
91 +package saferith
92
93 import (
94 "testing"
95 )
96
97 +type nat []Word
98 +
99 +type funVV func(z, x, y []Word) (c Word)
100 +
101 +type argVV struct {
102 + z, x, y nat
103 + c Word
104 +}
105 +
106 +var sumVV = []argVV{
107 + {},
108 + {nat{0}, nat{0}, nat{0}, 0},
109 + {nat{1}, nat{1}, nat{0}, 0},
110 + {nat{0}, nat{_M}, nat{1}, 1},
111 + {nat{80235}, nat{12345}, nat{67890}, 0},
112 + {nat{_M - 1}, nat{_M}, nat{_M}, 1},
113 + {nat{0, 0, 0, 0}, nat{_M, _M, _M, _M}, nat{1, 0, 0, 0}, 1},
114 + {nat{0, 0, 0, _M}, nat{_M, _M, _M, _M - 1}, nat{1, 0, 0, 0}, 0},
115 + {nat{0, 0, 0, 0}, nat{_M, 0, _M, 0}, nat{1, _M, 0, _M}, 1},
116 +}
117 +
118 +func testFunVV(t *testing.T, msg string, f funVV, a argVV) {
119 + z := make(nat, len(a.z))
120 + c := f(z, a.x, a.y)
121 + for i, zi := range z {
122 + if zi != a.z[i] {
123 + t.Errorf("%s%+v\n\tgot z[%d] = %#x; want %#x", msg, a, i, zi, a.z[i])
124 + break
125 + }
126 + }
127 + if c != a.c {
128 + t.Errorf("%s%+v\n\tgot c = %#x; want %#x", msg, a, c, a.c)
129 + }
130 +}
131 +
132 // Tests whether the non vector routines are working, even when the tests are run on a
133 // vector-capable machine
134