MCPcopy Create free account
hub / github.com/Tripwire/tripwire-open-source / AtomicMultiply

Function AtomicMultiply

src/cryptlib/integer.cpp:232–273  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

230}
231
232static void AtomicMultiply(word *C, word A0, word A1, word B0, word B1)
233{
234 word s;
235 dword_union d;
236
237 if (A1 >= A0)
238 if (B0 >= B1)
239 {
240 s = 0;
241 d.dw = (dword)(A1-A0)*(B0-B1);
242 }
243 else
244 {
245 s = (A1-A0);
246 d.dw = (dword)s*(word)(B0-B1);
247 }
248 else
249 if (B0 > B1)
250 {
251 s = (B0-B1);
252 d.dw = (word)(A1-A0)*(dword)s;
253 }
254 else
255 {
256 s = 0;
257 d.dw = (dword)(A0-A1)*(B1-B0);
258 }
259
260 dword_union A0B0;
261 A0B0.dw = (dword)A0*B0;
262 C[0] = A0B0.low;
263
264 dword_union A1B1;
265 A1B1.dw = (dword)A1*B1;
266 dword_union t;
267 t.dw = (dword)A0B0.high + A0B0.low + d.low + A1B1.low;
268 C[1] = t.low;
269
270 t.dw = A1B1.dw + t.high + A0B0.high + d.high + A1B1.high - s;
271 C[2] = t.low;
272 C[3] = t.high;
273}
274
275static word AtomicMultiplyAdd(word *C, word A0, word A1, word B0, word B1)
276{

Callers 7

AtomicSquareFunction · 0.85
RecursiveMultiplyFunction · 0.85
RecursiveSquareFunction · 0.85
RecursiveMultiplyBottomFunction · 0.85
RecursiveMultiplyTopFunction · 0.85
AtomicDivideFunction · 0.85
CorrectQuotientEstimateFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected