| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
/* auto-generated: cd cryptoint; ./autogen */ |
|
2
|
|
|
|
|
|
|
/* cryptoint 20250414 (plus __FILC__ tweak) */ |
|
3
|
|
|
|
|
|
|
|
|
4
|
|
|
|
|
|
|
#ifndef crypto_int64_h |
|
5
|
|
|
|
|
|
|
#define crypto_int64_h |
|
6
|
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
#include |
|
8
|
|
|
|
|
|
|
#define crypto_int64 int64_t |
|
9
|
|
|
|
|
|
|
#define crypto_int64_unsigned uint64_t |
|
10
|
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
#define crypto_int64_optblocker djbsort_int64_optblocker |
|
12
|
|
|
|
|
|
|
extern volatile crypto_int64 crypto_int64_optblocker; |
|
13
|
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
__attribute__((unused)) |
|
15
|
|
|
|
|
|
|
static inline |
|
16
|
|
|
|
|
|
|
crypto_int64 crypto_int64_load(const unsigned char *crypto_int64_s) { |
|
17
|
|
|
|
|
|
|
crypto_int64 crypto_int64_z = 0; |
|
18
|
|
|
|
|
|
|
crypto_int64_z |= ((crypto_int64) (*crypto_int64_s++)) << 0; |
|
19
|
|
|
|
|
|
|
crypto_int64_z |= ((crypto_int64) (*crypto_int64_s++)) << 8; |
|
20
|
|
|
|
|
|
|
crypto_int64_z |= ((crypto_int64) (*crypto_int64_s++)) << 16; |
|
21
|
|
|
|
|
|
|
crypto_int64_z |= ((crypto_int64) (*crypto_int64_s++)) << 24; |
|
22
|
|
|
|
|
|
|
crypto_int64_z |= ((crypto_int64) (*crypto_int64_s++)) << 32; |
|
23
|
|
|
|
|
|
|
crypto_int64_z |= ((crypto_int64) (*crypto_int64_s++)) << 40; |
|
24
|
|
|
|
|
|
|
crypto_int64_z |= ((crypto_int64) (*crypto_int64_s++)) << 48; |
|
25
|
|
|
|
|
|
|
crypto_int64_z |= ((crypto_int64) (*crypto_int64_s++)) << 56; |
|
26
|
|
|
|
|
|
|
return crypto_int64_z; |
|
27
|
|
|
|
|
|
|
} |
|
28
|
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
__attribute__((unused)) |
|
30
|
|
|
|
|
|
|
static inline |
|
31
|
|
|
|
|
|
|
crypto_int64 crypto_int64_load_bigendian(const unsigned char *crypto_int64_s) { |
|
32
|
|
|
|
|
|
|
crypto_int64 crypto_int64_z = 0; |
|
33
|
|
|
|
|
|
|
crypto_int64_z |= ((crypto_int64) (*crypto_int64_s++)) << 56; |
|
34
|
|
|
|
|
|
|
crypto_int64_z |= ((crypto_int64) (*crypto_int64_s++)) << 48; |
|
35
|
|
|
|
|
|
|
crypto_int64_z |= ((crypto_int64) (*crypto_int64_s++)) << 40; |
|
36
|
|
|
|
|
|
|
crypto_int64_z |= ((crypto_int64) (*crypto_int64_s++)) << 32; |
|
37
|
|
|
|
|
|
|
crypto_int64_z |= ((crypto_int64) (*crypto_int64_s++)) << 24; |
|
38
|
|
|
|
|
|
|
crypto_int64_z |= ((crypto_int64) (*crypto_int64_s++)) << 16; |
|
39
|
|
|
|
|
|
|
crypto_int64_z |= ((crypto_int64) (*crypto_int64_s++)) << 8; |
|
40
|
|
|
|
|
|
|
crypto_int64_z |= ((crypto_int64) (*crypto_int64_s++)) << 0; |
|
41
|
|
|
|
|
|
|
return crypto_int64_z; |
|
42
|
|
|
|
|
|
|
} |
|
43
|
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
__attribute__((unused)) |
|
45
|
|
|
|
|
|
|
static inline |
|
46
|
|
|
|
|
|
|
void crypto_int64_store(unsigned char *crypto_int64_s,crypto_int64 crypto_int64_x) { |
|
47
|
|
|
|
|
|
|
*crypto_int64_s++ = crypto_int64_x >> 0; |
|
48
|
|
|
|
|
|
|
*crypto_int64_s++ = crypto_int64_x >> 8; |
|
49
|
|
|
|
|
|
|
*crypto_int64_s++ = crypto_int64_x >> 16; |
|
50
|
|
|
|
|
|
|
*crypto_int64_s++ = crypto_int64_x >> 24; |
|
51
|
|
|
|
|
|
|
*crypto_int64_s++ = crypto_int64_x >> 32; |
|
52
|
|
|
|
|
|
|
*crypto_int64_s++ = crypto_int64_x >> 40; |
|
53
|
|
|
|
|
|
|
*crypto_int64_s++ = crypto_int64_x >> 48; |
|
54
|
|
|
|
|
|
|
*crypto_int64_s++ = crypto_int64_x >> 56; |
|
55
|
|
|
|
|
|
|
} |
|
56
|
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
__attribute__((unused)) |
|
58
|
|
|
|
|
|
|
static inline |
|
59
|
|
|
|
|
|
|
void crypto_int64_store_bigendian(unsigned char *crypto_int64_s,crypto_int64 crypto_int64_x) { |
|
60
|
|
|
|
|
|
|
*crypto_int64_s++ = crypto_int64_x >> 56; |
|
61
|
|
|
|
|
|
|
*crypto_int64_s++ = crypto_int64_x >> 48; |
|
62
|
|
|
|
|
|
|
*crypto_int64_s++ = crypto_int64_x >> 40; |
|
63
|
|
|
|
|
|
|
*crypto_int64_s++ = crypto_int64_x >> 32; |
|
64
|
|
|
|
|
|
|
*crypto_int64_s++ = crypto_int64_x >> 24; |
|
65
|
|
|
|
|
|
|
*crypto_int64_s++ = crypto_int64_x >> 16; |
|
66
|
|
|
|
|
|
|
*crypto_int64_s++ = crypto_int64_x >> 8; |
|
67
|
|
|
|
|
|
|
*crypto_int64_s++ = crypto_int64_x >> 0; |
|
68
|
|
|
|
|
|
|
} |
|
69
|
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
__attribute__((unused)) |
|
71
|
|
|
|
|
|
|
static inline |
|
72
|
20
|
|
|
|
|
|
crypto_int64 crypto_int64_negative_mask(crypto_int64 crypto_int64_x) { |
|
73
|
|
|
|
|
|
|
#if (defined(__GNUASM__) || (defined(__GNUC__) && !defined(__FILC__))) && defined(__x86_64__) |
|
74
|
20
|
|
|
|
|
|
__asm__ ("sarq $63,%0" : "+r"(crypto_int64_x) : : "cc"); |
|
75
|
20
|
|
|
|
|
|
return crypto_int64_x; |
|
76
|
|
|
|
|
|
|
#elif (defined(__GNUASM__) || (defined(__GNUC__) && !defined(__FILC__))) && defined(__aarch64__) |
|
77
|
|
|
|
|
|
|
crypto_int64 crypto_int64_y; |
|
78
|
|
|
|
|
|
|
__asm__ ("asr %0,%1,63" : "=r"(crypto_int64_y) : "r"(crypto_int64_x) : ); |
|
79
|
|
|
|
|
|
|
return crypto_int64_y; |
|
80
|
|
|
|
|
|
|
#elif (defined(__GNUASM__) || (defined(__GNUC__) && !defined(__FILC__))) && defined(__arm__) && defined(__ARM_ARCH) && (__ARM_ARCH >= 6) && !defined(__thumb__) |
|
81
|
|
|
|
|
|
|
crypto_int64 crypto_int64_y; |
|
82
|
|
|
|
|
|
|
__asm__ ("asr %Q0,%R1,#31\n mov %R0,%Q0" : "=r"(crypto_int64_y) : "r"(crypto_int64_x) : ); |
|
83
|
|
|
|
|
|
|
return crypto_int64_y; |
|
84
|
|
|
|
|
|
|
#elif (defined(__GNUASM__) || (defined(__GNUC__) && !defined(__FILC__))) && defined(__sparc_v8__) |
|
85
|
|
|
|
|
|
|
crypto_int64 crypto_int64_y; |
|
86
|
|
|
|
|
|
|
__asm__ ("sra %H1,31,%L0\n mov %L0,%H0" : "=r"(crypto_int64_y) : "r"(crypto_int64_x) : ); |
|
87
|
|
|
|
|
|
|
return crypto_int64_y; |
|
88
|
|
|
|
|
|
|
#else |
|
89
|
|
|
|
|
|
|
crypto_int64_x >>= 64-6; |
|
90
|
|
|
|
|
|
|
crypto_int64_x += crypto_int64_optblocker; |
|
91
|
|
|
|
|
|
|
crypto_int64_x >>= 5; |
|
92
|
|
|
|
|
|
|
return crypto_int64_x; |
|
93
|
|
|
|
|
|
|
#endif |
|
94
|
|
|
|
|
|
|
} |
|
95
|
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
__attribute__((unused)) |
|
97
|
|
|
|
|
|
|
static inline |
|
98
|
|
|
|
|
|
|
crypto_int64_unsigned crypto_int64_unsigned_topbit_01(crypto_int64_unsigned crypto_int64_x) { |
|
99
|
|
|
|
|
|
|
#if (defined(__GNUASM__) || (defined(__GNUC__) && !defined(__FILC__))) && defined(__x86_64__) |
|
100
|
|
|
|
|
|
|
__asm__ ("shrq $63,%0" : "+r"(crypto_int64_x) : : "cc"); |
|
101
|
|
|
|
|
|
|
return crypto_int64_x; |
|
102
|
|
|
|
|
|
|
#elif (defined(__GNUASM__) || (defined(__GNUC__) && !defined(__FILC__))) && defined(__aarch64__) |
|
103
|
|
|
|
|
|
|
crypto_int64_unsigned crypto_int64_y; |
|
104
|
|
|
|
|
|
|
__asm__ ("lsr %0,%1,63" : "=r"(crypto_int64_y) : "r"(crypto_int64_x) : ); |
|
105
|
|
|
|
|
|
|
return crypto_int64_y; |
|
106
|
|
|
|
|
|
|
#elif (defined(__GNUASM__) || (defined(__GNUC__) && !defined(__FILC__))) && defined(__arm__) && defined(__ARM_ARCH) && (__ARM_ARCH >= 6) && !defined(__thumb__) |
|
107
|
|
|
|
|
|
|
crypto_int64 crypto_int64_y; |
|
108
|
|
|
|
|
|
|
__asm__ ("lsr %Q0,%R1,#31\n mov %R0,#0" : "=r"(crypto_int64_y) : "r"(crypto_int64_x) : ); |
|
109
|
|
|
|
|
|
|
return crypto_int64_y; |
|
110
|
|
|
|
|
|
|
#elif (defined(__GNUASM__) || (defined(__GNUC__) && !defined(__FILC__))) && defined(__sparc_v8__) |
|
111
|
|
|
|
|
|
|
crypto_int64_unsigned crypto_int64_y; |
|
112
|
|
|
|
|
|
|
__asm__ ("srl %H1,31,%L0\n mov 0,%H0" : "=r"(crypto_int64_y) : "r"(crypto_int64_x) : ); |
|
113
|
|
|
|
|
|
|
return crypto_int64_y; |
|
114
|
|
|
|
|
|
|
#else |
|
115
|
|
|
|
|
|
|
crypto_int64_x >>= 64-6; |
|
116
|
|
|
|
|
|
|
crypto_int64_x += crypto_int64_optblocker; |
|
117
|
|
|
|
|
|
|
crypto_int64_x >>= 5; |
|
118
|
|
|
|
|
|
|
return crypto_int64_x; |
|
119
|
|
|
|
|
|
|
#endif |
|
120
|
|
|
|
|
|
|
} |
|
121
|
|
|
|
|
|
|
|
|
122
|
|
|
|
|
|
|
__attribute__((unused)) |
|
123
|
|
|
|
|
|
|
static inline |
|
124
|
|
|
|
|
|
|
crypto_int64 crypto_int64_negative_01(crypto_int64 crypto_int64_x) { |
|
125
|
|
|
|
|
|
|
return crypto_int64_unsigned_topbit_01(crypto_int64_x); |
|
126
|
|
|
|
|
|
|
} |
|
127
|
|
|
|
|
|
|
|
|
128
|
|
|
|
|
|
|
__attribute__((unused)) |
|
129
|
|
|
|
|
|
|
static inline |
|
130
|
|
|
|
|
|
|
crypto_int64 crypto_int64_topbit_mask(crypto_int64 crypto_int64_x) { |
|
131
|
|
|
|
|
|
|
return crypto_int64_negative_mask(crypto_int64_x); |
|
132
|
|
|
|
|
|
|
} |
|
133
|
|
|
|
|
|
|
|
|
134
|
|
|
|
|
|
|
__attribute__((unused)) |
|
135
|
|
|
|
|
|
|
static inline |
|
136
|
|
|
|
|
|
|
crypto_int64 crypto_int64_topbit_01(crypto_int64 crypto_int64_x) { |
|
137
|
|
|
|
|
|
|
return crypto_int64_unsigned_topbit_01(crypto_int64_x); |
|
138
|
|
|
|
|
|
|
} |
|
139
|
|
|
|
|
|
|
|
|
140
|
|
|
|
|
|
|
__attribute__((unused)) |
|
141
|
|
|
|
|
|
|
static inline |
|
142
|
|
|
|
|
|
|
crypto_int64 crypto_int64_bottombit_mask(crypto_int64 crypto_int64_x) { |
|
143
|
|
|
|
|
|
|
#if (defined(__GNUASM__) || (defined(__GNUC__) && !defined(__FILC__))) && defined(__x86_64__) |
|
144
|
|
|
|
|
|
|
__asm__ ("andq $1,%0" : "+r"(crypto_int64_x) : : "cc"); |
|
145
|
|
|
|
|
|
|
return -crypto_int64_x; |
|
146
|
|
|
|
|
|
|
#elif (defined(__GNUASM__) || (defined(__GNUC__) && !defined(__FILC__))) && defined(__aarch64__) |
|
147
|
|
|
|
|
|
|
crypto_int64 crypto_int64_y; |
|
148
|
|
|
|
|
|
|
__asm__ ("sbfx %0,%1,0,1" : "=r"(crypto_int64_y) : "r"(crypto_int64_x) : ); |
|
149
|
|
|
|
|
|
|
return crypto_int64_y; |
|
150
|
|
|
|
|
|
|
#elif (defined(__GNUASM__) || (defined(__GNUC__) && !defined(__FILC__))) && defined(__arm__) && defined(__ARM_ARCH) && (__ARM_ARCH >= 6) && !defined(__thumb__) |
|
151
|
|
|
|
|
|
|
crypto_int64 crypto_int64_y; |
|
152
|
|
|
|
|
|
|
__asm__ ("and %Q0,%Q1,#1\n neg %Q0,%Q0\n mov %R0,%Q0" : "=r"(crypto_int64_y) : "r"(crypto_int64_x) : ); |
|
153
|
|
|
|
|
|
|
return crypto_int64_y; |
|
154
|
|
|
|
|
|
|
#elif (defined(__GNUASM__) || (defined(__GNUC__) && !defined(__FILC__))) && defined(__sparc_v8__) |
|
155
|
|
|
|
|
|
|
crypto_int64 crypto_int64_y; |
|
156
|
|
|
|
|
|
|
__asm__ ("and %L1,1,%L0\n neg %L0,%L0\n mov %L0,%H0" : "=r"(crypto_int64_y) : "r"(crypto_int64_x) : ); |
|
157
|
|
|
|
|
|
|
return crypto_int64_y; |
|
158
|
|
|
|
|
|
|
#else |
|
159
|
|
|
|
|
|
|
crypto_int64_x &= 1 + crypto_int64_optblocker; |
|
160
|
|
|
|
|
|
|
return -crypto_int64_x; |
|
161
|
|
|
|
|
|
|
#endif |
|
162
|
|
|
|
|
|
|
} |
|
163
|
|
|
|
|
|
|
|
|
164
|
|
|
|
|
|
|
__attribute__((unused)) |
|
165
|
|
|
|
|
|
|
static inline |
|
166
|
|
|
|
|
|
|
crypto_int64 crypto_int64_bottombit_01(crypto_int64 crypto_int64_x) { |
|
167
|
|
|
|
|
|
|
#if (defined(__GNUASM__) || (defined(__GNUC__) && !defined(__FILC__))) && defined(__x86_64__) |
|
168
|
|
|
|
|
|
|
__asm__ ("andq $1,%0" : "+r"(crypto_int64_x) : : "cc"); |
|
169
|
|
|
|
|
|
|
return crypto_int64_x; |
|
170
|
|
|
|
|
|
|
#elif (defined(__GNUASM__) || (defined(__GNUC__) && !defined(__FILC__))) && defined(__aarch64__) |
|
171
|
|
|
|
|
|
|
crypto_int64 crypto_int64_y; |
|
172
|
|
|
|
|
|
|
__asm__ ("ubfx %0,%1,0,1" : "=r"(crypto_int64_y) : "r"(crypto_int64_x) : ); |
|
173
|
|
|
|
|
|
|
return crypto_int64_y; |
|
174
|
|
|
|
|
|
|
#elif (defined(__GNUASM__) || (defined(__GNUC__) && !defined(__FILC__))) && defined(__arm__) && defined(__ARM_ARCH) && (__ARM_ARCH >= 6) && !defined(__thumb__) |
|
175
|
|
|
|
|
|
|
crypto_int64 crypto_int64_y; |
|
176
|
|
|
|
|
|
|
__asm__ ("and %Q0,%Q1,#1\n mov %R0,#0" : "=r"(crypto_int64_y) : "r"(crypto_int64_x) : ); |
|
177
|
|
|
|
|
|
|
return crypto_int64_y; |
|
178
|
|
|
|
|
|
|
#elif (defined(__GNUASM__) || (defined(__GNUC__) && !defined(__FILC__))) && defined(__sparc_v8__) |
|
179
|
|
|
|
|
|
|
crypto_int64 crypto_int64_y; |
|
180
|
|
|
|
|
|
|
__asm__ ("and %L1,1,%L0\n mov 0,%H0" : "=r"(crypto_int64_y) : "r"(crypto_int64_x) : ); |
|
181
|
|
|
|
|
|
|
return crypto_int64_y; |
|
182
|
|
|
|
|
|
|
#else |
|
183
|
|
|
|
|
|
|
crypto_int64_x &= 1 + crypto_int64_optblocker; |
|
184
|
|
|
|
|
|
|
return crypto_int64_x; |
|
185
|
|
|
|
|
|
|
#endif |
|
186
|
|
|
|
|
|
|
} |
|
187
|
|
|
|
|
|
|
|
|
188
|
|
|
|
|
|
|
__attribute__((unused)) |
|
189
|
|
|
|
|
|
|
static inline |
|
190
|
|
|
|
|
|
|
crypto_int64 crypto_int64_bitinrangepublicpos_mask(crypto_int64 crypto_int64_x,crypto_int64 crypto_int64_s) { |
|
191
|
|
|
|
|
|
|
#if (defined(__GNUASM__) || (defined(__GNUC__) && !defined(__FILC__))) && defined(__x86_64__) |
|
192
|
|
|
|
|
|
|
__asm__ ("sarq %%cl,%0" : "+r"(crypto_int64_x) : "c"(crypto_int64_s) : "cc"); |
|
193
|
|
|
|
|
|
|
#elif (defined(__GNUASM__) || (defined(__GNUC__) && !defined(__FILC__))) && defined(__aarch64__) |
|
194
|
|
|
|
|
|
|
__asm__ ("asr %0,%0,%1" : "+r"(crypto_int64_x) : "r"(crypto_int64_s) : ); |
|
195
|
|
|
|
|
|
|
#elif (defined(__GNUASM__) || (defined(__GNUC__) && !defined(__FILC__))) && defined(__arm__) && defined(__ARM_ARCH) && (__ARM_ARCH >= 6) && !defined(__thumb__) |
|
196
|
|
|
|
|
|
|
__asm__ ("and %Q0,%Q0,#63\n lsr %Q1,%Q1,%Q0\n rsb %R0,%Q0,#32\n orr %Q1,%Q1,%R1,lsl %R0\n subs %R0,%Q0,#32\n orrhs %Q1,%Q1,%R1,asr %R0\n asr %R1,%R1,%Q0" : "+&r"(crypto_int64_s), "+r"(crypto_int64_x) : : "cc"); |
|
197
|
|
|
|
|
|
|
#elif (defined(__GNUASM__) || (defined(__GNUC__) && !defined(__FILC__))) && defined(__sparc_v8__) |
|
198
|
|
|
|
|
|
|
crypto_int64 crypto_int64_y, crypto_int64_z; |
|
199
|
|
|
|
|
|
|
__asm__ ("not %L0,%H0\n sll %L0,26,%H1\n sll %H3,1,%L1\n srl %L3,%L0,%L2\n sll %L1,%H0,%L1\n sra %H3,%L0,%H2\n sra %H1,31,%H1\n or %L2,%L1,%L2\n xor %L2,%H2,%L1\n and %H1,%L1,%L1\n sra %H2,%H1,%H3\n xor %L2,%L1,%L3" : "+&r"(crypto_int64_s), "=&r"(crypto_int64_z), "=&r"(crypto_int64_y), "+r"(crypto_int64_x) : : ); |
|
200
|
|
|
|
|
|
|
#else |
|
201
|
|
|
|
|
|
|
crypto_int64_x >>= crypto_int64_s ^ crypto_int64_optblocker; |
|
202
|
|
|
|
|
|
|
#endif |
|
203
|
|
|
|
|
|
|
return crypto_int64_bottombit_mask(crypto_int64_x); |
|
204
|
|
|
|
|
|
|
} |
|
205
|
|
|
|
|
|
|
|
|
206
|
|
|
|
|
|
|
__attribute__((unused)) |
|
207
|
|
|
|
|
|
|
static inline |
|
208
|
|
|
|
|
|
|
crypto_int64 crypto_int64_bitinrangepublicpos_01(crypto_int64 crypto_int64_x,crypto_int64 crypto_int64_s) { |
|
209
|
|
|
|
|
|
|
#if (defined(__GNUASM__) || (defined(__GNUC__) && !defined(__FILC__))) && defined(__x86_64__) |
|
210
|
|
|
|
|
|
|
__asm__ ("sarq %%cl,%0" : "+r"(crypto_int64_x) : "c"(crypto_int64_s) : "cc"); |
|
211
|
|
|
|
|
|
|
#elif (defined(__GNUASM__) || (defined(__GNUC__) && !defined(__FILC__))) && defined(__aarch64__) |
|
212
|
|
|
|
|
|
|
__asm__ ("asr %0,%0,%1" : "+r"(crypto_int64_x) : "r"(crypto_int64_s) : ); |
|
213
|
|
|
|
|
|
|
#elif (defined(__GNUASM__) || (defined(__GNUC__) && !defined(__FILC__))) && defined(__arm__) && defined(__ARM_ARCH) && (__ARM_ARCH >= 6) && !defined(__thumb__) |
|
214
|
|
|
|
|
|
|
__asm__ ("and %Q0,%Q0,#63\n lsr %Q1,%Q1,%Q0\n rsb %R0,%Q0,#32\n orr %Q1,%Q1,%R1,lsl %R0\n subs %R0,%Q0,#32\n orrhs %Q1,%Q1,%R1,asr %R0\n asr %R1,%R1,%Q0" : "+&r"(crypto_int64_s), "+r"(crypto_int64_x) : : "cc"); |
|
215
|
|
|
|
|
|
|
#elif (defined(__GNUASM__) || (defined(__GNUC__) && !defined(__FILC__))) && defined(__sparc_v8__) |
|
216
|
|
|
|
|
|
|
crypto_int64 crypto_int64_y, crypto_int64_z; |
|
217
|
|
|
|
|
|
|
__asm__ ("not %L0,%H0\n sll %L0,26,%H1\n sll %H3,1,%L1\n srl %L3,%L0,%L2\n sll %L1,%H0,%L1\n sra %H3,%L0,%H2\n sra %H1,31,%H1\n or %L2,%L1,%L2\n xor %L2,%H2,%L1\n and %H1,%L1,%L1\n sra %H2,%H1,%H3\n xor %L2,%L1,%L3" : "+&r"(crypto_int64_s), "=&r"(crypto_int64_z), "=&r"(crypto_int64_y), "+r"(crypto_int64_x) : : ); |
|
218
|
|
|
|
|
|
|
#else |
|
219
|
|
|
|
|
|
|
crypto_int64_x >>= crypto_int64_s ^ crypto_int64_optblocker; |
|
220
|
|
|
|
|
|
|
#endif |
|
221
|
|
|
|
|
|
|
return crypto_int64_bottombit_01(crypto_int64_x); |
|
222
|
|
|
|
|
|
|
} |
|
223
|
|
|
|
|
|
|
|
|
224
|
|
|
|
|
|
|
__attribute__((unused)) |
|
225
|
|
|
|
|
|
|
static inline |
|
226
|
|
|
|
|
|
|
crypto_int64 crypto_int64_shlmod(crypto_int64 crypto_int64_x,crypto_int64 crypto_int64_s) { |
|
227
|
|
|
|
|
|
|
#if (defined(__GNUASM__) || (defined(__GNUC__) && !defined(__FILC__))) && defined(__x86_64__) |
|
228
|
|
|
|
|
|
|
__asm__ ("shlq %%cl,%0" : "+r"(crypto_int64_x) : "c"(crypto_int64_s) : "cc"); |
|
229
|
|
|
|
|
|
|
#elif (defined(__GNUASM__) || (defined(__GNUC__) && !defined(__FILC__))) && defined(__aarch64__) |
|
230
|
|
|
|
|
|
|
__asm__ ("lsl %0,%0,%1" : "+r"(crypto_int64_x) : "r"(crypto_int64_s) : ); |
|
231
|
|
|
|
|
|
|
#elif (defined(__GNUASM__) || (defined(__GNUC__) && !defined(__FILC__))) && defined(__arm__) && defined(__ARM_ARCH) && (__ARM_ARCH >= 6) && !defined(__thumb__) |
|
232
|
|
|
|
|
|
|
__asm__ ("and %Q0,%Q0,#63\n lsl %R1,%R1,%Q0\n sub %R0,%Q0,#32\n orr %R1,%R1,%Q1,lsl %R0\n rsb %R0,%Q0,#32\n orr %R1,%R1,%Q1,lsr %R0\n lsl %Q1,%Q1,%Q0" : "+&r"(crypto_int64_s), "+r"(crypto_int64_x) : : ); |
|
233
|
|
|
|
|
|
|
#elif (defined(__GNUASM__) || (defined(__GNUC__) && !defined(__FILC__))) && defined(__sparc_v8__) |
|
234
|
|
|
|
|
|
|
crypto_int64 crypto_int64_y, crypto_int64_z; |
|
235
|
|
|
|
|
|
|
__asm__ ("not %L0,%H0\n sll %L0,26,%H1\n srl %L3,1,%L1\n sll %L3,%L0,%L2\n srl %L1,%H0,%L1\n sll %H3,%L0,%H2\n sra %H1,31,%H1\n or %H2,%L1,%H2\n xor %L2,%H2,%L1\n and %H1,%L2,%L3\n and %H1,%L1,%L1\n xor %L3,%L2,%L3\n xor %H2,%L1,%H3" : "+&r"(crypto_int64_s), "=&r"(crypto_int64_z), "=&r"(crypto_int64_y), "+r"(crypto_int64_x) : : ); |
|
236
|
|
|
|
|
|
|
#else |
|
237
|
|
|
|
|
|
|
int crypto_int64_k, crypto_int64_l; |
|
238
|
|
|
|
|
|
|
for (crypto_int64_l = 0,crypto_int64_k = 1;crypto_int64_k < 64;++crypto_int64_l,crypto_int64_k *= 2) |
|
239
|
|
|
|
|
|
|
crypto_int64_x ^= (crypto_int64_x ^ (crypto_int64_x << crypto_int64_k)) & crypto_int64_bitinrangepublicpos_mask(crypto_int64_s,crypto_int64_l); |
|
240
|
|
|
|
|
|
|
#endif |
|
241
|
|
|
|
|
|
|
return crypto_int64_x; |
|
242
|
|
|
|
|
|
|
} |
|
243
|
|
|
|
|
|
|
|
|
244
|
|
|
|
|
|
|
__attribute__((unused)) |
|
245
|
|
|
|
|
|
|
static inline |
|
246
|
|
|
|
|
|
|
crypto_int64 crypto_int64_shrmod(crypto_int64 crypto_int64_x,crypto_int64 crypto_int64_s) { |
|
247
|
|
|
|
|
|
|
#if (defined(__GNUASM__) || (defined(__GNUC__) && !defined(__FILC__))) && defined(__x86_64__) |
|
248
|
|
|
|
|
|
|
__asm__ ("sarq %%cl,%0" : "+r"(crypto_int64_x) : "c"(crypto_int64_s) : "cc"); |
|
249
|
|
|
|
|
|
|
#elif (defined(__GNUASM__) || (defined(__GNUC__) && !defined(__FILC__))) && defined(__aarch64__) |
|
250
|
|
|
|
|
|
|
__asm__ ("asr %0,%0,%1" : "+r"(crypto_int64_x) : "r"(crypto_int64_s) : ); |
|
251
|
|
|
|
|
|
|
#elif (defined(__GNUASM__) || (defined(__GNUC__) && !defined(__FILC__))) && defined(__arm__) && defined(__ARM_ARCH) && (__ARM_ARCH >= 6) && !defined(__thumb__) |
|
252
|
|
|
|
|
|
|
__asm__ ("and %Q0,%Q0,#63\n lsr %Q1,%Q1,%Q0\n rsb %R0,%Q0,#32\n orr %Q1,%Q1,%R1,lsl %R0\n subs %R0,%Q0,#32\n orrhs %Q1,%Q1,%R1,asr %R0\n asr %R1,%R1,%Q0" : "+&r"(crypto_int64_s), "+r"(crypto_int64_x) : : "cc"); |
|
253
|
|
|
|
|
|
|
#elif (defined(__GNUASM__) || (defined(__GNUC__) && !defined(__FILC__))) && defined(__sparc_v8__) |
|
254
|
|
|
|
|
|
|
crypto_int64 crypto_int64_y, crypto_int64_z; |
|
255
|
|
|
|
|
|
|
__asm__ ("not %L0,%H0\n sll %L0,26,%H1\n sll %H3,1,%L1\n srl %L3,%L0,%L2\n sll %L1,%H0,%L1\n sra %H3,%L0,%H2\n sra %H1,31,%H1\n or %L2,%L1,%L2\n xor %L2,%H2,%L1\n and %H1,%L1,%L1\n sra %H2,%H1,%H3\n xor %L2,%L1,%L3" : "+&r"(crypto_int64_s), "=&r"(crypto_int64_z), "=&r"(crypto_int64_y), "+r"(crypto_int64_x) : : ); |
|
256
|
|
|
|
|
|
|
#else |
|
257
|
|
|
|
|
|
|
int crypto_int64_k, crypto_int64_l; |
|
258
|
|
|
|
|
|
|
for (crypto_int64_l = 0,crypto_int64_k = 1;crypto_int64_k < 64;++crypto_int64_l,crypto_int64_k *= 2) |
|
259
|
|
|
|
|
|
|
crypto_int64_x ^= (crypto_int64_x ^ (crypto_int64_x >> crypto_int64_k)) & crypto_int64_bitinrangepublicpos_mask(crypto_int64_s,crypto_int64_l); |
|
260
|
|
|
|
|
|
|
#endif |
|
261
|
|
|
|
|
|
|
return crypto_int64_x; |
|
262
|
|
|
|
|
|
|
} |
|
263
|
|
|
|
|
|
|
|
|
264
|
|
|
|
|
|
|
__attribute__((unused)) |
|
265
|
|
|
|
|
|
|
static inline |
|
266
|
|
|
|
|
|
|
crypto_int64 crypto_int64_bitmod_mask(crypto_int64 crypto_int64_x,crypto_int64 crypto_int64_s) { |
|
267
|
|
|
|
|
|
|
crypto_int64_x = crypto_int64_shrmod(crypto_int64_x,crypto_int64_s); |
|
268
|
|
|
|
|
|
|
return crypto_int64_bottombit_mask(crypto_int64_x); |
|
269
|
|
|
|
|
|
|
} |
|
270
|
|
|
|
|
|
|
|
|
271
|
|
|
|
|
|
|
__attribute__((unused)) |
|
272
|
|
|
|
|
|
|
static inline |
|
273
|
|
|
|
|
|
|
crypto_int64 crypto_int64_bitmod_01(crypto_int64 crypto_int64_x,crypto_int64 crypto_int64_s) { |
|
274
|
|
|
|
|
|
|
crypto_int64_x = crypto_int64_shrmod(crypto_int64_x,crypto_int64_s); |
|
275
|
|
|
|
|
|
|
return crypto_int64_bottombit_01(crypto_int64_x); |
|
276
|
|
|
|
|
|
|
} |
|
277
|
|
|
|
|
|
|
|
|
278
|
|
|
|
|
|
|
__attribute__((unused)) |
|
279
|
|
|
|
|
|
|
static inline |
|
280
|
|
|
|
|
|
|
crypto_int64 crypto_int64_nonzero_mask(crypto_int64 crypto_int64_x) { |
|
281
|
|
|
|
|
|
|
#if (defined(__GNUASM__) || (defined(__GNUC__) && !defined(__FILC__))) && defined(__x86_64__) |
|
282
|
|
|
|
|
|
|
crypto_int64 crypto_int64_q,crypto_int64_z; |
|
283
|
|
|
|
|
|
|
__asm__ ("xorq %0,%0\n movq $-1,%1\n testq %2,%2\n cmovneq %1,%0" : "=&r"(crypto_int64_z), "=&r"(crypto_int64_q) : "r"(crypto_int64_x) : "cc"); |
|
284
|
|
|
|
|
|
|
return crypto_int64_z; |
|
285
|
|
|
|
|
|
|
#elif (defined(__GNUASM__) || (defined(__GNUC__) && !defined(__FILC__))) && defined(__aarch64__) |
|
286
|
|
|
|
|
|
|
crypto_int64 crypto_int64_z; |
|
287
|
|
|
|
|
|
|
__asm__ ("cmp %1,0\n csetm %0,ne" : "=r"(crypto_int64_z) : "r"(crypto_int64_x) : "cc"); |
|
288
|
|
|
|
|
|
|
return crypto_int64_z; |
|
289
|
|
|
|
|
|
|
#elif (defined(__GNUASM__) || (defined(__GNUC__) && !defined(__FILC__))) && defined(__arm__) && defined(__ARM_ARCH) && (__ARM_ARCH >= 6) && !defined(__thumb__) |
|
290
|
|
|
|
|
|
|
__asm__ ("orrs %Q0,%Q0,%R0\n movne %Q0,#-1\n mov %R0,%Q0" : "+r"(crypto_int64_x) : : "cc"); |
|
291
|
|
|
|
|
|
|
return crypto_int64_x; |
|
292
|
|
|
|
|
|
|
#elif (defined(__GNUASM__) || (defined(__GNUC__) && !defined(__FILC__))) && defined(__sparc_v8__) |
|
293
|
|
|
|
|
|
|
crypto_int64 crypto_int64_z; |
|
294
|
|
|
|
|
|
|
__asm__ ("or %L1,%H1,%L0\n cmp %%g0,%L0\n subx %%g0,0,%L0\n mov %L0,%H0" : "=r"(crypto_int64_z) : "r"(crypto_int64_x) : "cc"); |
|
295
|
|
|
|
|
|
|
return crypto_int64_z; |
|
296
|
|
|
|
|
|
|
#else |
|
297
|
|
|
|
|
|
|
crypto_int64_x |= -crypto_int64_x; |
|
298
|
|
|
|
|
|
|
return crypto_int64_negative_mask(crypto_int64_x); |
|
299
|
|
|
|
|
|
|
#endif |
|
300
|
|
|
|
|
|
|
} |
|
301
|
|
|
|
|
|
|
|
|
302
|
|
|
|
|
|
|
__attribute__((unused)) |
|
303
|
|
|
|
|
|
|
static inline |
|
304
|
|
|
|
|
|
|
crypto_int64 crypto_int64_nonzero_01(crypto_int64 crypto_int64_x) { |
|
305
|
|
|
|
|
|
|
#if (defined(__GNUASM__) || (defined(__GNUC__) && !defined(__FILC__))) && defined(__x86_64__) |
|
306
|
|
|
|
|
|
|
crypto_int64 crypto_int64_q,crypto_int64_z; |
|
307
|
|
|
|
|
|
|
__asm__ ("xorq %0,%0\n movq $1,%1\n testq %2,%2\n cmovneq %1,%0" : "=&r"(crypto_int64_z), "=&r"(crypto_int64_q) : "r"(crypto_int64_x) : "cc"); |
|
308
|
|
|
|
|
|
|
return crypto_int64_z; |
|
309
|
|
|
|
|
|
|
#elif (defined(__GNUASM__) || (defined(__GNUC__) && !defined(__FILC__))) && defined(__aarch64__) |
|
310
|
|
|
|
|
|
|
crypto_int64 crypto_int64_z; |
|
311
|
|
|
|
|
|
|
__asm__ ("cmp %1,0\n cset %0,ne" : "=r"(crypto_int64_z) : "r"(crypto_int64_x) : "cc"); |
|
312
|
|
|
|
|
|
|
return crypto_int64_z; |
|
313
|
|
|
|
|
|
|
#elif (defined(__GNUASM__) || (defined(__GNUC__) && !defined(__FILC__))) && defined(__arm__) && defined(__ARM_ARCH) && (__ARM_ARCH >= 6) && !defined(__thumb__) |
|
314
|
|
|
|
|
|
|
__asm__ ("orrs %Q0,%Q0,%R0\n movne %Q0,#1\n mov %R0,#0" : "+r"(crypto_int64_x) : : "cc"); |
|
315
|
|
|
|
|
|
|
return crypto_int64_x; |
|
316
|
|
|
|
|
|
|
#elif (defined(__GNUASM__) || (defined(__GNUC__) && !defined(__FILC__))) && defined(__sparc_v8__) |
|
317
|
|
|
|
|
|
|
crypto_int64 crypto_int64_z; |
|
318
|
|
|
|
|
|
|
__asm__ ("or %L1,%H1,%L0\n cmp %%g0,%L0\n addx %%g0,0,%L0\n mov 0,%H0" : "=r"(crypto_int64_z) : "r"(crypto_int64_x) : "cc"); |
|
319
|
|
|
|
|
|
|
return crypto_int64_z; |
|
320
|
|
|
|
|
|
|
#else |
|
321
|
|
|
|
|
|
|
crypto_int64_x |= -crypto_int64_x; |
|
322
|
|
|
|
|
|
|
return crypto_int64_unsigned_topbit_01(crypto_int64_x); |
|
323
|
|
|
|
|
|
|
#endif |
|
324
|
|
|
|
|
|
|
} |
|
325
|
|
|
|
|
|
|
|
|
326
|
|
|
|
|
|
|
__attribute__((unused)) |
|
327
|
|
|
|
|
|
|
static inline |
|
328
|
|
|
|
|
|
|
crypto_int64 crypto_int64_positive_mask(crypto_int64 crypto_int64_x) { |
|
329
|
|
|
|
|
|
|
#if (defined(__GNUASM__) || (defined(__GNUC__) && !defined(__FILC__))) && defined(__x86_64__) |
|
330
|
|
|
|
|
|
|
crypto_int64 crypto_int64_q,crypto_int64_z; |
|
331
|
|
|
|
|
|
|
__asm__ ("xorq %0,%0\n movq $-1,%1\n testq %2,%2\n cmovgq %1,%0" : "=&r"(crypto_int64_z), "=&r"(crypto_int64_q) : "r"(crypto_int64_x) : "cc"); |
|
332
|
|
|
|
|
|
|
return crypto_int64_z; |
|
333
|
|
|
|
|
|
|
#elif (defined(__GNUASM__) || (defined(__GNUC__) && !defined(__FILC__))) && defined(__aarch64__) |
|
334
|
|
|
|
|
|
|
crypto_int64 crypto_int64_z; |
|
335
|
|
|
|
|
|
|
__asm__ ("cmp %1,0\n csetm %0,gt" : "=r"(crypto_int64_z) : "r"(crypto_int64_x) : "cc"); |
|
336
|
|
|
|
|
|
|
return crypto_int64_z; |
|
337
|
|
|
|
|
|
|
#elif (defined(__GNUASM__) || (defined(__GNUC__) && !defined(__FILC__))) && defined(__sparc_v8__) |
|
338
|
|
|
|
|
|
|
crypto_int64 crypto_int64_z; |
|
339
|
|
|
|
|
|
|
__asm__ ("sra %H1,31,%L0\n subcc %L0,%L1,%H0\n subx %L0,%H1,%H0\n sra %H0,31,%H0\n mov %H0,%L0" : "=&r"(crypto_int64_z) : "r"(crypto_int64_x) : "cc"); |
|
340
|
|
|
|
|
|
|
return crypto_int64_z; |
|
341
|
|
|
|
|
|
|
#else |
|
342
|
|
|
|
|
|
|
crypto_int64 crypto_int64_z = -crypto_int64_x; |
|
343
|
|
|
|
|
|
|
crypto_int64_z ^= crypto_int64_x & crypto_int64_z; |
|
344
|
|
|
|
|
|
|
return crypto_int64_negative_mask(crypto_int64_z); |
|
345
|
|
|
|
|
|
|
#endif |
|
346
|
|
|
|
|
|
|
} |
|
347
|
|
|
|
|
|
|
|
|
348
|
|
|
|
|
|
|
__attribute__((unused)) |
|
349
|
|
|
|
|
|
|
static inline |
|
350
|
|
|
|
|
|
|
crypto_int64 crypto_int64_positive_01(crypto_int64 crypto_int64_x) { |
|
351
|
|
|
|
|
|
|
#if (defined(__GNUASM__) || (defined(__GNUC__) && !defined(__FILC__))) && defined(__x86_64__) |
|
352
|
|
|
|
|
|
|
crypto_int64 crypto_int64_q,crypto_int64_z; |
|
353
|
|
|
|
|
|
|
__asm__ ("xorq %0,%0\n movq $1,%1\n testq %2,%2\n cmovgq %1,%0" : "=&r"(crypto_int64_z), "=&r"(crypto_int64_q) : "r"(crypto_int64_x) : "cc"); |
|
354
|
|
|
|
|
|
|
return crypto_int64_z; |
|
355
|
|
|
|
|
|
|
#elif (defined(__GNUASM__) || (defined(__GNUC__) && !defined(__FILC__))) && defined(__aarch64__) |
|
356
|
|
|
|
|
|
|
crypto_int64 crypto_int64_z; |
|
357
|
|
|
|
|
|
|
__asm__ ("cmp %1,0\n cset %0,gt" : "=r"(crypto_int64_z) : "r"(crypto_int64_x) : "cc"); |
|
358
|
|
|
|
|
|
|
return crypto_int64_z; |
|
359
|
|
|
|
|
|
|
#elif (defined(__GNUASM__) || (defined(__GNUC__) && !defined(__FILC__))) && defined(__sparc_v8__) |
|
360
|
|
|
|
|
|
|
crypto_int64 crypto_int64_z; |
|
361
|
|
|
|
|
|
|
__asm__ ("sra %H1,31,%H0\n subcc %H0,%L1,%L0\n subx %H0,%H1,%L0\n srl %L0,31,%L0\n mov 0,%H0" : "=&r"(crypto_int64_z) : "r"(crypto_int64_x) : "cc"); |
|
362
|
|
|
|
|
|
|
return crypto_int64_z; |
|
363
|
|
|
|
|
|
|
#else |
|
364
|
|
|
|
|
|
|
crypto_int64 crypto_int64_z = -crypto_int64_x; |
|
365
|
|
|
|
|
|
|
crypto_int64_z ^= crypto_int64_x & crypto_int64_z; |
|
366
|
|
|
|
|
|
|
return crypto_int64_unsigned_topbit_01(crypto_int64_z); |
|
367
|
|
|
|
|
|
|
#endif |
|
368
|
|
|
|
|
|
|
} |
|
369
|
|
|
|
|
|
|
|
|
370
|
|
|
|
|
|
|
__attribute__((unused)) |
|
371
|
|
|
|
|
|
|
static inline |
|
372
|
|
|
|
|
|
|
crypto_int64 crypto_int64_zero_mask(crypto_int64 crypto_int64_x) { |
|
373
|
|
|
|
|
|
|
#if (defined(__GNUASM__) || (defined(__GNUC__) && !defined(__FILC__))) && defined(__x86_64__) |
|
374
|
|
|
|
|
|
|
crypto_int64 crypto_int64_q,crypto_int64_z; |
|
375
|
|
|
|
|
|
|
__asm__ ("xorq %0,%0\n movq $-1,%1\n testq %2,%2\n cmoveq %1,%0" : "=&r"(crypto_int64_z), "=&r"(crypto_int64_q) : "r"(crypto_int64_x) : "cc"); |
|
376
|
|
|
|
|
|
|
return crypto_int64_z; |
|
377
|
|
|
|
|
|
|
#elif (defined(__GNUASM__) || (defined(__GNUC__) && !defined(__FILC__))) && defined(__aarch64__) |
|
378
|
|
|
|
|
|
|
crypto_int64 crypto_int64_z; |
|
379
|
|
|
|
|
|
|
__asm__ ("cmp %1,0\n csetm %0,eq" : "=r"(crypto_int64_z) : "r"(crypto_int64_x) : "cc"); |
|
380
|
|
|
|
|
|
|
return crypto_int64_z; |
|
381
|
|
|
|
|
|
|
#elif (defined(__GNUASM__) || (defined(__GNUC__) && !defined(__FILC__))) && defined(__sparc_v8__) |
|
382
|
|
|
|
|
|
|
crypto_int64 crypto_int64_z; |
|
383
|
|
|
|
|
|
|
__asm__ ("or %L1,%H1,%L0\n cmp %%g0,%L0\n addx %%g0,-1,%L0\n mov %L0,%H0" : "=r"(crypto_int64_z) : "r"(crypto_int64_x) : "cc"); |
|
384
|
|
|
|
|
|
|
return crypto_int64_z; |
|
385
|
|
|
|
|
|
|
#else |
|
386
|
|
|
|
|
|
|
return ~crypto_int64_nonzero_mask(crypto_int64_x); |
|
387
|
|
|
|
|
|
|
#endif |
|
388
|
|
|
|
|
|
|
} |
|
389
|
|
|
|
|
|
|
|
|
390
|
|
|
|
|
|
|
__attribute__((unused)) |
|
391
|
|
|
|
|
|
|
static inline |
|
392
|
|
|
|
|
|
|
crypto_int64 crypto_int64_zero_01(crypto_int64 crypto_int64_x) { |
|
393
|
|
|
|
|
|
|
#if (defined(__GNUASM__) || (defined(__GNUC__) && !defined(__FILC__))) && defined(__x86_64__) |
|
394
|
|
|
|
|
|
|
crypto_int64 crypto_int64_q,crypto_int64_z; |
|
395
|
|
|
|
|
|
|
__asm__ ("xorq %0,%0\n movq $1,%1\n testq %2,%2\n cmoveq %1,%0" : "=&r"(crypto_int64_z), "=&r"(crypto_int64_q) : "r"(crypto_int64_x) : "cc"); |
|
396
|
|
|
|
|
|
|
return crypto_int64_z; |
|
397
|
|
|
|
|
|
|
#elif (defined(__GNUASM__) || (defined(__GNUC__) && !defined(__FILC__))) && defined(__aarch64__) |
|
398
|
|
|
|
|
|
|
crypto_int64 crypto_int64_z; |
|
399
|
|
|
|
|
|
|
__asm__ ("cmp %1,0\n cset %0,eq" : "=r"(crypto_int64_z) : "r"(crypto_int64_x) : "cc"); |
|
400
|
|
|
|
|
|
|
return crypto_int64_z; |
|
401
|
|
|
|
|
|
|
#elif (defined(__GNUASM__) || (defined(__GNUC__) && !defined(__FILC__))) && defined(__sparc_v8__) |
|
402
|
|
|
|
|
|
|
crypto_int64 crypto_int64_z; |
|
403
|
|
|
|
|
|
|
__asm__ ("or %L1,%H1,%L0\n cmp %%g0,%L0\n subx %%g0,-1,%L0\n mov 0,%H0" : "=r"(crypto_int64_z) : "r"(crypto_int64_x) : "cc"); |
|
404
|
|
|
|
|
|
|
return crypto_int64_z; |
|
405
|
|
|
|
|
|
|
#else |
|
406
|
|
|
|
|
|
|
return 1-crypto_int64_nonzero_01(crypto_int64_x); |
|
407
|
|
|
|
|
|
|
#endif |
|
408
|
|
|
|
|
|
|
} |
|
409
|
|
|
|
|
|
|
|
|
410
|
|
|
|
|
|
|
__attribute__((unused)) |
|
411
|
|
|
|
|
|
|
static inline |
|
412
|
|
|
|
|
|
|
crypto_int64 crypto_int64_unequal_mask(crypto_int64 crypto_int64_x,crypto_int64 crypto_int64_y) { |
|
413
|
|
|
|
|
|
|
#if (defined(__GNUASM__) || (defined(__GNUC__) && !defined(__FILC__))) && defined(__x86_64__) |
|
414
|
|
|
|
|
|
|
crypto_int64 crypto_int64_q,crypto_int64_z; |
|
415
|
|
|
|
|
|
|
__asm__ ("xorq %0,%0\n movq $-1,%1\n cmpq %3,%2\n cmovneq %1,%0" : "=&r"(crypto_int64_z), "=&r"(crypto_int64_q) : "r"(crypto_int64_x), "r"(crypto_int64_y) : "cc"); |
|
416
|
|
|
|
|
|
|
return crypto_int64_z; |
|
417
|
|
|
|
|
|
|
#elif (defined(__GNUASM__) || (defined(__GNUC__) && !defined(__FILC__))) && defined(__aarch64__) |
|
418
|
|
|
|
|
|
|
crypto_int64 crypto_int64_z; |
|
419
|
|
|
|
|
|
|
__asm__ ("cmp %1,%2\n csetm %0,ne" : "=r"(crypto_int64_z) : "r"(crypto_int64_x), "r"(crypto_int64_y) : "cc"); |
|
420
|
|
|
|
|
|
|
return crypto_int64_z; |
|
421
|
|
|
|
|
|
|
#else |
|
422
|
|
|
|
|
|
|
return crypto_int64_nonzero_mask(crypto_int64_x ^ crypto_int64_y); |
|
423
|
|
|
|
|
|
|
#endif |
|
424
|
|
|
|
|
|
|
} |
|
425
|
|
|
|
|
|
|
|
|
426
|
|
|
|
|
|
|
__attribute__((unused)) |
|
427
|
|
|
|
|
|
|
static inline |
|
428
|
|
|
|
|
|
|
crypto_int64 crypto_int64_unequal_01(crypto_int64 crypto_int64_x,crypto_int64 crypto_int64_y) { |
|
429
|
|
|
|
|
|
|
#if (defined(__GNUASM__) || (defined(__GNUC__) && !defined(__FILC__))) && defined(__x86_64__) |
|
430
|
|
|
|
|
|
|
crypto_int64 crypto_int64_q,crypto_int64_z; |
|
431
|
|
|
|
|
|
|
__asm__ ("xorq %0,%0\n movq $1,%1\n cmpq %3,%2\n cmovneq %1,%0" : "=&r"(crypto_int64_z), "=&r"(crypto_int64_q) : "r"(crypto_int64_x), "r"(crypto_int64_y) : "cc"); |
|
432
|
|
|
|
|
|
|
return crypto_int64_z; |
|
433
|
|
|
|
|
|
|
#elif (defined(__GNUASM__) || (defined(__GNUC__) && !defined(__FILC__))) && defined(__aarch64__) |
|
434
|
|
|
|
|
|
|
crypto_int64 crypto_int64_z; |
|
435
|
|
|
|
|
|
|
__asm__ ("cmp %1,%2\n cset %0,ne" : "=r"(crypto_int64_z) : "r"(crypto_int64_x), "r"(crypto_int64_y) : "cc"); |
|
436
|
|
|
|
|
|
|
return crypto_int64_z; |
|
437
|
|
|
|
|
|
|
#else |
|
438
|
|
|
|
|
|
|
return crypto_int64_nonzero_01(crypto_int64_x ^ crypto_int64_y); |
|
439
|
|
|
|
|
|
|
#endif |
|
440
|
|
|
|
|
|
|
} |
|
441
|
|
|
|
|
|
|
|
|
442
|
|
|
|
|
|
|
__attribute__((unused)) |
|
443
|
|
|
|
|
|
|
static inline |
|
444
|
|
|
|
|
|
|
crypto_int64 crypto_int64_equal_mask(crypto_int64 crypto_int64_x,crypto_int64 crypto_int64_y) { |
|
445
|
|
|
|
|
|
|
#if (defined(__GNUASM__) || (defined(__GNUC__) && !defined(__FILC__))) && defined(__x86_64__) |
|
446
|
|
|
|
|
|
|
crypto_int64 crypto_int64_q,crypto_int64_z; |
|
447
|
|
|
|
|
|
|
__asm__ ("xorq %0,%0\n movq $-1,%1\n cmpq %3,%2\n cmoveq %1,%0" : "=&r"(crypto_int64_z), "=&r"(crypto_int64_q) : "r"(crypto_int64_x), "r"(crypto_int64_y) : "cc"); |
|
448
|
|
|
|
|
|
|
return crypto_int64_z; |
|
449
|
|
|
|
|
|
|
#elif (defined(__GNUASM__) || (defined(__GNUC__) && !defined(__FILC__))) && defined(__aarch64__) |
|
450
|
|
|
|
|
|
|
crypto_int64 crypto_int64_z; |
|
451
|
|
|
|
|
|
|
__asm__ ("cmp %1,%2\n csetm %0,eq" : "=r"(crypto_int64_z) : "r"(crypto_int64_x), "r"(crypto_int64_y) : "cc"); |
|
452
|
|
|
|
|
|
|
return crypto_int64_z; |
|
453
|
|
|
|
|
|
|
#else |
|
454
|
|
|
|
|
|
|
return crypto_int64_zero_mask(crypto_int64_x ^ crypto_int64_y); |
|
455
|
|
|
|
|
|
|
#endif |
|
456
|
|
|
|
|
|
|
} |
|
457
|
|
|
|
|
|
|
|
|
458
|
|
|
|
|
|
|
__attribute__((unused)) |
|
459
|
|
|
|
|
|
|
static inline |
|
460
|
|
|
|
|
|
|
crypto_int64 crypto_int64_equal_01(crypto_int64 crypto_int64_x,crypto_int64 crypto_int64_y) { |
|
461
|
|
|
|
|
|
|
#if (defined(__GNUASM__) || (defined(__GNUC__) && !defined(__FILC__))) && defined(__x86_64__) |
|
462
|
|
|
|
|
|
|
crypto_int64 crypto_int64_q,crypto_int64_z; |
|
463
|
|
|
|
|
|
|
__asm__ ("xorq %0,%0\n movq $1,%1\n cmpq %3,%2\n cmoveq %1,%0" : "=&r"(crypto_int64_z), "=&r"(crypto_int64_q) : "r"(crypto_int64_x), "r"(crypto_int64_y) : "cc"); |
|
464
|
|
|
|
|
|
|
return crypto_int64_z; |
|
465
|
|
|
|
|
|
|
#elif (defined(__GNUASM__) || (defined(__GNUC__) && !defined(__FILC__))) && defined(__aarch64__) |
|
466
|
|
|
|
|
|
|
crypto_int64 crypto_int64_z; |
|
467
|
|
|
|
|
|
|
__asm__ ("cmp %1,%2\n cset %0,eq" : "=r"(crypto_int64_z) : "r"(crypto_int64_x), "r"(crypto_int64_y) : "cc"); |
|
468
|
|
|
|
|
|
|
return crypto_int64_z; |
|
469
|
|
|
|
|
|
|
#else |
|
470
|
|
|
|
|
|
|
return crypto_int64_zero_01(crypto_int64_x ^ crypto_int64_y); |
|
471
|
|
|
|
|
|
|
#endif |
|
472
|
|
|
|
|
|
|
} |
|
473
|
|
|
|
|
|
|
|
|
474
|
|
|
|
|
|
|
__attribute__((unused)) |
|
475
|
|
|
|
|
|
|
static inline |
|
476
|
|
|
|
|
|
|
crypto_int64 crypto_int64_min(crypto_int64 crypto_int64_x,crypto_int64 crypto_int64_y) { |
|
477
|
|
|
|
|
|
|
#if (defined(__GNUASM__) || (defined(__GNUC__) && !defined(__FILC__))) && defined(__x86_64__) |
|
478
|
|
|
|
|
|
|
__asm__ ("cmpq %1,%0\n cmovgq %1,%0" : "+r"(crypto_int64_x) : "r"(crypto_int64_y) : "cc"); |
|
479
|
|
|
|
|
|
|
return crypto_int64_x; |
|
480
|
|
|
|
|
|
|
#elif (defined(__GNUASM__) || (defined(__GNUC__) && !defined(__FILC__))) && defined(__aarch64__) |
|
481
|
|
|
|
|
|
|
__asm__ ("cmp %0,%1\n csel %0,%0,%1,lt" : "+r"(crypto_int64_x) : "r"(crypto_int64_y) : "cc"); |
|
482
|
|
|
|
|
|
|
return crypto_int64_x; |
|
483
|
|
|
|
|
|
|
#else |
|
484
|
|
|
|
|
|
|
crypto_int64 crypto_int64_r = crypto_int64_y ^ crypto_int64_x; |
|
485
|
|
|
|
|
|
|
crypto_int64 crypto_int64_z = crypto_int64_y - crypto_int64_x; |
|
486
|
|
|
|
|
|
|
crypto_int64_z ^= crypto_int64_r & (crypto_int64_z ^ crypto_int64_y); |
|
487
|
|
|
|
|
|
|
crypto_int64_z = crypto_int64_negative_mask(crypto_int64_z); |
|
488
|
|
|
|
|
|
|
crypto_int64_z &= crypto_int64_r; |
|
489
|
|
|
|
|
|
|
return crypto_int64_x ^ crypto_int64_z; |
|
490
|
|
|
|
|
|
|
#endif |
|
491
|
|
|
|
|
|
|
} |
|
492
|
|
|
|
|
|
|
|
|
493
|
|
|
|
|
|
|
__attribute__((unused)) |
|
494
|
|
|
|
|
|
|
static inline |
|
495
|
|
|
|
|
|
|
crypto_int64 crypto_int64_max(crypto_int64 crypto_int64_x,crypto_int64 crypto_int64_y) { |
|
496
|
|
|
|
|
|
|
#if (defined(__GNUASM__) || (defined(__GNUC__) && !defined(__FILC__))) && defined(__x86_64__) |
|
497
|
|
|
|
|
|
|
__asm__ ("cmpq %1,%0\n cmovlq %1,%0" : "+r"(crypto_int64_x) : "r"(crypto_int64_y) : "cc"); |
|
498
|
|
|
|
|
|
|
return crypto_int64_x; |
|
499
|
|
|
|
|
|
|
#elif (defined(__GNUASM__) || (defined(__GNUC__) && !defined(__FILC__))) && defined(__aarch64__) |
|
500
|
|
|
|
|
|
|
__asm__ ("cmp %0,%1\n csel %0,%1,%0,lt" : "+r"(crypto_int64_x) : "r"(crypto_int64_y) : "cc"); |
|
501
|
|
|
|
|
|
|
return crypto_int64_x; |
|
502
|
|
|
|
|
|
|
#else |
|
503
|
|
|
|
|
|
|
crypto_int64 crypto_int64_r = crypto_int64_y ^ crypto_int64_x; |
|
504
|
|
|
|
|
|
|
crypto_int64 crypto_int64_z = crypto_int64_y - crypto_int64_x; |
|
505
|
|
|
|
|
|
|
crypto_int64_z ^= crypto_int64_r & (crypto_int64_z ^ crypto_int64_y); |
|
506
|
|
|
|
|
|
|
crypto_int64_z = crypto_int64_negative_mask(crypto_int64_z); |
|
507
|
|
|
|
|
|
|
crypto_int64_z &= crypto_int64_r; |
|
508
|
|
|
|
|
|
|
return crypto_int64_y ^ crypto_int64_z; |
|
509
|
|
|
|
|
|
|
#endif |
|
510
|
|
|
|
|
|
|
} |
|
511
|
|
|
|
|
|
|
|
|
512
|
|
|
|
|
|
|
__attribute__((unused)) |
|
513
|
|
|
|
|
|
|
static inline |
|
514
|
|
|
|
|
|
|
void crypto_int64_minmax(crypto_int64 *crypto_int64_p,crypto_int64 *crypto_int64_q) { |
|
515
|
|
|
|
|
|
|
crypto_int64 crypto_int64_x = *crypto_int64_p; |
|
516
|
|
|
|
|
|
|
crypto_int64 crypto_int64_y = *crypto_int64_q; |
|
517
|
|
|
|
|
|
|
#if (defined(__GNUASM__) || (defined(__GNUC__) && !defined(__FILC__))) && defined(__x86_64__) |
|
518
|
|
|
|
|
|
|
crypto_int64 crypto_int64_z; |
|
519
|
|
|
|
|
|
|
__asm__ ("cmpq %2,%1\n movq %1,%0\n cmovgq %2,%1\n cmovgq %0,%2" : "=&r"(crypto_int64_z), "+&r"(crypto_int64_x), "+r"(crypto_int64_y) : : "cc"); |
|
520
|
|
|
|
|
|
|
*crypto_int64_p = crypto_int64_x; |
|
521
|
|
|
|
|
|
|
*crypto_int64_q = crypto_int64_y; |
|
522
|
|
|
|
|
|
|
#elif (defined(__GNUASM__) || (defined(__GNUC__) && !defined(__FILC__))) && defined(__aarch64__) |
|
523
|
|
|
|
|
|
|
crypto_int64 crypto_int64_r, crypto_int64_s; |
|
524
|
|
|
|
|
|
|
__asm__ ("cmp %2,%3\n csel %0,%2,%3,lt\n csel %1,%3,%2,lt" : "=&r"(crypto_int64_r), "=r"(crypto_int64_s) : "r"(crypto_int64_x), "r"(crypto_int64_y) : "cc"); |
|
525
|
|
|
|
|
|
|
*crypto_int64_p = crypto_int64_r; |
|
526
|
|
|
|
|
|
|
*crypto_int64_q = crypto_int64_s; |
|
527
|
|
|
|
|
|
|
#else |
|
528
|
|
|
|
|
|
|
crypto_int64 crypto_int64_r = crypto_int64_y ^ crypto_int64_x; |
|
529
|
|
|
|
|
|
|
crypto_int64 crypto_int64_z = crypto_int64_y - crypto_int64_x; |
|
530
|
|
|
|
|
|
|
crypto_int64_z ^= crypto_int64_r & (crypto_int64_z ^ crypto_int64_y); |
|
531
|
|
|
|
|
|
|
crypto_int64_z = crypto_int64_negative_mask(crypto_int64_z); |
|
532
|
|
|
|
|
|
|
crypto_int64_z &= crypto_int64_r; |
|
533
|
|
|
|
|
|
|
crypto_int64_x ^= crypto_int64_z; |
|
534
|
|
|
|
|
|
|
crypto_int64_y ^= crypto_int64_z; |
|
535
|
|
|
|
|
|
|
*crypto_int64_p = crypto_int64_x; |
|
536
|
|
|
|
|
|
|
*crypto_int64_q = crypto_int64_y; |
|
537
|
|
|
|
|
|
|
#endif |
|
538
|
|
|
|
|
|
|
} |
|
539
|
|
|
|
|
|
|
|
|
540
|
|
|
|
|
|
|
__attribute__((unused)) |
|
541
|
|
|
|
|
|
|
static inline |
|
542
|
|
|
|
|
|
|
crypto_int64 crypto_int64_smaller_mask(crypto_int64 crypto_int64_x,crypto_int64 crypto_int64_y) { |
|
543
|
|
|
|
|
|
|
#if (defined(__GNUASM__) || (defined(__GNUC__) && !defined(__FILC__))) && defined(__x86_64__) |
|
544
|
|
|
|
|
|
|
crypto_int64 crypto_int64_q,crypto_int64_z; |
|
545
|
|
|
|
|
|
|
__asm__ ("xorq %0,%0\n movq $-1,%1\n cmpq %3,%2\n cmovlq %1,%0" : "=&r"(crypto_int64_z), "=&r"(crypto_int64_q) : "r"(crypto_int64_x), "r"(crypto_int64_y) : "cc"); |
|
546
|
|
|
|
|
|
|
return crypto_int64_z; |
|
547
|
|
|
|
|
|
|
#elif (defined(__GNUASM__) || (defined(__GNUC__) && !defined(__FILC__))) && defined(__aarch64__) |
|
548
|
|
|
|
|
|
|
crypto_int64 crypto_int64_z; |
|
549
|
|
|
|
|
|
|
__asm__ ("cmp %1,%2\n csetm %0,lt" : "=r"(crypto_int64_z) : "r"(crypto_int64_x), "r"(crypto_int64_y) : "cc"); |
|
550
|
|
|
|
|
|
|
return crypto_int64_z; |
|
551
|
|
|
|
|
|
|
#else |
|
552
|
|
|
|
|
|
|
crypto_int64 crypto_int64_r = crypto_int64_x ^ crypto_int64_y; |
|
553
|
|
|
|
|
|
|
crypto_int64 crypto_int64_z = crypto_int64_x - crypto_int64_y; |
|
554
|
|
|
|
|
|
|
crypto_int64_z ^= crypto_int64_r & (crypto_int64_z ^ crypto_int64_x); |
|
555
|
|
|
|
|
|
|
return crypto_int64_negative_mask(crypto_int64_z); |
|
556
|
|
|
|
|
|
|
#endif |
|
557
|
|
|
|
|
|
|
} |
|
558
|
|
|
|
|
|
|
|
|
559
|
|
|
|
|
|
|
__attribute__((unused)) |
|
560
|
|
|
|
|
|
|
static inline |
|
561
|
|
|
|
|
|
|
crypto_int64 crypto_int64_smaller_01(crypto_int64 crypto_int64_x,crypto_int64 crypto_int64_y) { |
|
562
|
|
|
|
|
|
|
#if (defined(__GNUASM__) || (defined(__GNUC__) && !defined(__FILC__))) && defined(__x86_64__) |
|
563
|
|
|
|
|
|
|
crypto_int64 crypto_int64_q,crypto_int64_z; |
|
564
|
|
|
|
|
|
|
__asm__ ("xorq %0,%0\n movq $1,%1\n cmpq %3,%2\n cmovlq %1,%0" : "=&r"(crypto_int64_z), "=&r"(crypto_int64_q) : "r"(crypto_int64_x), "r"(crypto_int64_y) : "cc"); |
|
565
|
|
|
|
|
|
|
return crypto_int64_z; |
|
566
|
|
|
|
|
|
|
#elif (defined(__GNUASM__) || (defined(__GNUC__) && !defined(__FILC__))) && defined(__aarch64__) |
|
567
|
|
|
|
|
|
|
crypto_int64 crypto_int64_z; |
|
568
|
|
|
|
|
|
|
__asm__ ("cmp %1,%2\n cset %0,lt" : "=r"(crypto_int64_z) : "r"(crypto_int64_x), "r"(crypto_int64_y) : "cc"); |
|
569
|
|
|
|
|
|
|
return crypto_int64_z; |
|
570
|
|
|
|
|
|
|
#else |
|
571
|
|
|
|
|
|
|
crypto_int64 crypto_int64_r = crypto_int64_x ^ crypto_int64_y; |
|
572
|
|
|
|
|
|
|
crypto_int64 crypto_int64_z = crypto_int64_x - crypto_int64_y; |
|
573
|
|
|
|
|
|
|
crypto_int64_z ^= crypto_int64_r & (crypto_int64_z ^ crypto_int64_x); |
|
574
|
|
|
|
|
|
|
return crypto_int64_unsigned_topbit_01(crypto_int64_z); |
|
575
|
|
|
|
|
|
|
#endif |
|
576
|
|
|
|
|
|
|
} |
|
577
|
|
|
|
|
|
|
|
|
578
|
|
|
|
|
|
|
__attribute__((unused)) |
|
579
|
|
|
|
|
|
|
static inline |
|
580
|
|
|
|
|
|
|
crypto_int64 crypto_int64_leq_mask(crypto_int64 crypto_int64_x,crypto_int64 crypto_int64_y) { |
|
581
|
|
|
|
|
|
|
#if (defined(__GNUASM__) || (defined(__GNUC__) && !defined(__FILC__))) && defined(__x86_64__) |
|
582
|
|
|
|
|
|
|
crypto_int64 crypto_int64_q,crypto_int64_z; |
|
583
|
|
|
|
|
|
|
__asm__ ("xorq %0,%0\n movq $-1,%1\n cmpq %3,%2\n cmovleq %1,%0" : "=&r"(crypto_int64_z), "=&r"(crypto_int64_q) : "r"(crypto_int64_x), "r"(crypto_int64_y) : "cc"); |
|
584
|
|
|
|
|
|
|
return crypto_int64_z; |
|
585
|
|
|
|
|
|
|
#elif (defined(__GNUASM__) || (defined(__GNUC__) && !defined(__FILC__))) && defined(__aarch64__) |
|
586
|
|
|
|
|
|
|
crypto_int64 crypto_int64_z; |
|
587
|
|
|
|
|
|
|
__asm__ ("cmp %1,%2\n csetm %0,le" : "=r"(crypto_int64_z) : "r"(crypto_int64_x), "r"(crypto_int64_y) : "cc"); |
|
588
|
|
|
|
|
|
|
return crypto_int64_z; |
|
589
|
|
|
|
|
|
|
#else |
|
590
|
|
|
|
|
|
|
return ~crypto_int64_smaller_mask(crypto_int64_y,crypto_int64_x); |
|
591
|
|
|
|
|
|
|
#endif |
|
592
|
|
|
|
|
|
|
} |
|
593
|
|
|
|
|
|
|
|
|
594
|
|
|
|
|
|
|
__attribute__((unused)) |
|
595
|
|
|
|
|
|
|
static inline |
|
596
|
|
|
|
|
|
|
crypto_int64 crypto_int64_leq_01(crypto_int64 crypto_int64_x,crypto_int64 crypto_int64_y) { |
|
597
|
|
|
|
|
|
|
#if (defined(__GNUASM__) || (defined(__GNUC__) && !defined(__FILC__))) && defined(__x86_64__) |
|
598
|
|
|
|
|
|
|
crypto_int64 crypto_int64_q,crypto_int64_z; |
|
599
|
|
|
|
|
|
|
__asm__ ("xorq %0,%0\n movq $1,%1\n cmpq %3,%2\n cmovleq %1,%0" : "=&r"(crypto_int64_z), "=&r"(crypto_int64_q) : "r"(crypto_int64_x), "r"(crypto_int64_y) : "cc"); |
|
600
|
|
|
|
|
|
|
return crypto_int64_z; |
|
601
|
|
|
|
|
|
|
#elif (defined(__GNUASM__) || (defined(__GNUC__) && !defined(__FILC__))) && defined(__aarch64__) |
|
602
|
|
|
|
|
|
|
crypto_int64 crypto_int64_z; |
|
603
|
|
|
|
|
|
|
__asm__ ("cmp %1,%2\n cset %0,le" : "=r"(crypto_int64_z) : "r"(crypto_int64_x), "r"(crypto_int64_y) : "cc"); |
|
604
|
|
|
|
|
|
|
return crypto_int64_z; |
|
605
|
|
|
|
|
|
|
#else |
|
606
|
|
|
|
|
|
|
return 1-crypto_int64_smaller_01(crypto_int64_y,crypto_int64_x); |
|
607
|
|
|
|
|
|
|
#endif |
|
608
|
|
|
|
|
|
|
} |
|
609
|
|
|
|
|
|
|
|
|
610
|
|
|
|
|
|
|
__attribute__((unused)) |
|
611
|
|
|
|
|
|
|
static inline |
|
612
|
|
|
|
|
|
|
int crypto_int64_ones_num(crypto_int64 crypto_int64_x) { |
|
613
|
|
|
|
|
|
|
crypto_int64_unsigned crypto_int64_y = crypto_int64_x; |
|
614
|
|
|
|
|
|
|
const crypto_int64 C0 = 0x5555555555555555; |
|
615
|
|
|
|
|
|
|
const crypto_int64 C1 = 0x3333333333333333; |
|
616
|
|
|
|
|
|
|
const crypto_int64 C2 = 0x0f0f0f0f0f0f0f0f; |
|
617
|
|
|
|
|
|
|
crypto_int64_y -= ((crypto_int64_y >> 1) & C0); |
|
618
|
|
|
|
|
|
|
crypto_int64_y = (crypto_int64_y & C1) + ((crypto_int64_y >> 2) & C1); |
|
619
|
|
|
|
|
|
|
crypto_int64_y = (crypto_int64_y + (crypto_int64_y >> 4)) & C2; |
|
620
|
|
|
|
|
|
|
crypto_int64_y += crypto_int64_y >> 8; |
|
621
|
|
|
|
|
|
|
crypto_int64_y += crypto_int64_y >> 16; |
|
622
|
|
|
|
|
|
|
crypto_int64_y = (crypto_int64_y + (crypto_int64_y >> 32)) & 0xff; |
|
623
|
|
|
|
|
|
|
return crypto_int64_y; |
|
624
|
|
|
|
|
|
|
} |
|
625
|
|
|
|
|
|
|
|
|
626
|
|
|
|
|
|
|
__attribute__((unused)) |
|
627
|
|
|
|
|
|
|
static inline |
|
628
|
|
|
|
|
|
|
int crypto_int64_bottomzeros_num(crypto_int64 crypto_int64_x) { |
|
629
|
|
|
|
|
|
|
#if (defined(__GNUASM__) || (defined(__GNUC__) && !defined(__FILC__))) && defined(__x86_64__) |
|
630
|
|
|
|
|
|
|
crypto_int64 fallback = 64; |
|
631
|
|
|
|
|
|
|
__asm__ ("bsfq %0,%0\n cmoveq %1,%0" : "+&r"(crypto_int64_x) : "r"(fallback) : "cc"); |
|
632
|
|
|
|
|
|
|
return crypto_int64_x; |
|
633
|
|
|
|
|
|
|
#elif (defined(__GNUASM__) || (defined(__GNUC__) && !defined(__FILC__))) && defined(__aarch64__) |
|
634
|
|
|
|
|
|
|
int64_t crypto_int64_y; |
|
635
|
|
|
|
|
|
|
__asm__ ("rbit %0,%1\n clz %0,%0" : "=r"(crypto_int64_y) : "r"(crypto_int64_x) : ); |
|
636
|
|
|
|
|
|
|
return crypto_int64_y; |
|
637
|
|
|
|
|
|
|
#else |
|
638
|
|
|
|
|
|
|
crypto_int64 crypto_int64_y = crypto_int64_x ^ (crypto_int64_x-1); |
|
639
|
|
|
|
|
|
|
crypto_int64_y = ((crypto_int64) crypto_int64_y) >> 1; |
|
640
|
|
|
|
|
|
|
crypto_int64_y &= ~(crypto_int64_x & (((crypto_int64) 1) << (64-1))); |
|
641
|
|
|
|
|
|
|
return crypto_int64_ones_num(crypto_int64_y); |
|
642
|
|
|
|
|
|
|
#endif |
|
643
|
|
|
|
|
|
|
} |
|
644
|
|
|
|
|
|
|
|
|
645
|
|
|
|
|
|
|
#endif |