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

Function AtomicMultiplyAdd

src/cryptlib/integer.cpp:275–320  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

273}
274
275static word AtomicMultiplyAdd(word *C, word A0, word A1, word B0, word B1)
276{
277 word s;
278 dword_union d;
279
280 if (A1 >= A0)
281 if (B0 >= B1)
282 {
283 s = 0;
284 d.dw = (dword)(A1-A0)*(B0-B1);
285 }
286 else
287 {
288 s = (A1-A0);
289 d.dw = (dword)s*(word)(B0-B1);
290 }
291 else
292 if (B0 > B1)
293 {
294 s = (B0-B1);
295 d.dw = (word)(A1-A0)*(dword)s;
296 }
297 else
298 {
299 s = 0;
300 d.dw = (dword)(A0-A1)*(B1-B0);
301 }
302
303 dword_union A0B0;
304 A0B0.dw = (dword)A0*B0;
305 dword_union t;
306 t.dw = A0B0.dw + C[0];
307 C[0] = t.low;
308
309 dword_union A1B1;
310 A1B1.dw = (dword)A1*B1;
311 t.dw = (dword) t.high + A0B0.low + d.low + A1B1.low + C[1];
312 C[1] = t.low;
313
314 t.dw = (dword) t.high + A1B1.low + A0B0.high + d.high + A1B1.high - s + C[2];
315 C[2] = t.low;
316
317 t.dw = (dword) t.high + A1B1.high + C[3];
318 C[3] = t.low;
319 return t.high;
320}
321
322static inline void AtomicSquare(word *C, word A, word B)
323{

Callers 1

CorrectQuotientEstimateFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected