Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(79)

Side by Side Diff: nss/lib/freebl/ecl/ecl_gf.c

Issue 1504923011: Update NSS to 3.21 RTM and NSPR to 4.11 RTM (Closed) Base URL: http://src.chromium.org/svn/trunk/deps/third_party/nss
Patch Set: Created 5 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 /* This Source Code Form is subject to the terms of the Mozilla Public 1 /* This Source Code Form is subject to the terms of the Mozilla Public
2 * License, v. 2.0. If a copy of the MPL was not distributed with this 2 * License, v. 2.0. If a copy of the MPL was not distributed with this
3 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 3 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
4 4
5 #include "mpi.h" 5 #include "mpi.h"
6 #include "mp_gf2m.h" 6 #include "mp_gf2m.h"
7 #include "ecl-priv.h" 7 #include "ecl-priv.h"
8 #include "mpi-priv.h" 8 #include "mpi-priv.h"
9 #include <stdlib.h> 9 #include <stdlib.h>
10 10
(...skipping 224 matching lines...) Expand 10 before | Expand all | Expand 10 after
235 switch(MP_USED(b)) { 235 switch(MP_USED(b)) {
236 case 3: 236 case 3:
237 r2 = MP_DIGIT(b,2); 237 r2 = MP_DIGIT(b,2);
238 case 2: 238 case 2:
239 r1 = MP_DIGIT(b,1); 239 r1 = MP_DIGIT(b,1);
240 case 1: 240 case 1:
241 r0 = MP_DIGIT(b,0); 241 r0 = MP_DIGIT(b,0);
242 } 242 }
243 243
244 #ifndef MPI_AMD64_ADD 244 #ifndef MPI_AMD64_ADD
245 » MP_ADD_CARRY(a0, r0, r0, 0, carry); 245 carry = 0;
246 » MP_ADD_CARRY(a1, r1, r1, carry, carry); 246 » MP_ADD_CARRY(a0, r0, r0, carry);
247 » MP_ADD_CARRY(a2, r2, r2, carry, carry); 247 » MP_ADD_CARRY(a1, r1, r1, carry);
248 » MP_ADD_CARRY(a2, r2, r2, carry);
248 #else 249 #else
249 __asm__ ( 250 __asm__ (
250 "xorq %3,%3 \n\t" 251 "xorq %3,%3 \n\t"
251 "addq %4,%0 \n\t" 252 "addq %4,%0 \n\t"
252 "adcq %5,%1 \n\t" 253 "adcq %5,%1 \n\t"
253 "adcq %6,%2 \n\t" 254 "adcq %6,%2 \n\t"
254 "adcq $0,%3 \n\t" 255 "adcq $0,%3 \n\t"
255 : "=r"(r0), "=r"(r1), "=r"(r2), "=r"(carry) 256 : "=r"(r0), "=r"(r1), "=r"(r2), "=r"(carry)
256 : "r" (a0), "r" (a1), "r" (a2), 257 : "r" (a0), "r" (a1), "r" (a2),
257 "0" (r0), "1" (r1), "2" (r2) 258 "0" (r0), "1" (r1), "2" (r2)
258 : "%cc" ); 259 : "%cc" );
259 #endif 260 #endif
260 261
261 MP_CHECKOK(s_mp_pad(r, 3)); 262 MP_CHECKOK(s_mp_pad(r, 3));
262 MP_DIGIT(r, 2) = r2; 263 MP_DIGIT(r, 2) = r2;
263 MP_DIGIT(r, 1) = r1; 264 MP_DIGIT(r, 1) = r1;
264 MP_DIGIT(r, 0) = r0; 265 MP_DIGIT(r, 0) = r0;
265 MP_SIGN(r) = MP_ZPOS; 266 MP_SIGN(r) = MP_ZPOS;
266 MP_USED(r) = 3; 267 MP_USED(r) = 3;
267 268
268 /* Do quick 'subract' if we've gone over 269 /* Do quick 'subract' if we've gone over
269 * (add the 2's complement of the curve field) */ 270 * (add the 2's complement of the curve field) */
270 a2 = MP_DIGIT(&meth->irr,2); 271 a2 = MP_DIGIT(&meth->irr,2);
271 if (carry || r2 > a2 || 272 if (carry || r2 > a2 ||
272 ((r2 == a2) && mp_cmp(r,&meth->irr) != MP_LT)) { 273 ((r2 == a2) && mp_cmp(r,&meth->irr) != MP_LT)) {
273 a1 = MP_DIGIT(&meth->irr,1); 274 a1 = MP_DIGIT(&meth->irr,1);
274 a0 = MP_DIGIT(&meth->irr,0); 275 a0 = MP_DIGIT(&meth->irr,0);
275 #ifndef MPI_AMD64_ADD 276 #ifndef MPI_AMD64_ADD
276 » » MP_SUB_BORROW(r0, a0, r0, 0, carry); 277 carry = 0;
277 » » MP_SUB_BORROW(r1, a1, r1, carry, carry); 278 » » MP_SUB_BORROW(r0, a0, r0, carry);
278 » » MP_SUB_BORROW(r2, a2, r2, carry, carry); 279 » » MP_SUB_BORROW(r1, a1, r1, carry);
280 » » MP_SUB_BORROW(r2, a2, r2, carry);
279 #else 281 #else
280 __asm__ ( 282 __asm__ (
281 "subq %3,%0 \n\t" 283 "subq %3,%0 \n\t"
282 "sbbq %4,%1 \n\t" 284 "sbbq %4,%1 \n\t"
283 "sbbq %5,%2 \n\t" 285 "sbbq %5,%2 \n\t"
284 : "=r"(r0), "=r"(r1), "=r"(r2) 286 : "=r"(r0), "=r"(r1), "=r"(r2)
285 : "r" (a0), "r" (a1), "r" (a2), 287 : "r" (a0), "r" (a1), "r" (a2),
286 "0" (r0), "1" (r1), "2" (r2) 288 "0" (r0), "1" (r1), "2" (r2)
287 : "%cc" ); 289 : "%cc" );
288 #endif 290 #endif
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
322 r3 = MP_DIGIT(b,3); 324 r3 = MP_DIGIT(b,3);
323 case 3: 325 case 3:
324 r2 = MP_DIGIT(b,2); 326 r2 = MP_DIGIT(b,2);
325 case 2: 327 case 2:
326 r1 = MP_DIGIT(b,1); 328 r1 = MP_DIGIT(b,1);
327 case 1: 329 case 1:
328 r0 = MP_DIGIT(b,0); 330 r0 = MP_DIGIT(b,0);
329 } 331 }
330 332
331 #ifndef MPI_AMD64_ADD 333 #ifndef MPI_AMD64_ADD
332 » MP_ADD_CARRY(a0, r0, r0, 0, carry); 334 carry = 0;
333 » MP_ADD_CARRY(a1, r1, r1, carry, carry); 335 » MP_ADD_CARRY(a0, r0, r0, carry);
334 » MP_ADD_CARRY(a2, r2, r2, carry, carry); 336 » MP_ADD_CARRY(a1, r1, r1, carry);
335 » MP_ADD_CARRY(a3, r3, r3, carry, carry); 337 » MP_ADD_CARRY(a2, r2, r2, carry);
338 » MP_ADD_CARRY(a3, r3, r3, carry);
336 #else 339 #else
337 __asm__ ( 340 __asm__ (
338 "xorq %4,%4 \n\t" 341 "xorq %4,%4 \n\t"
339 "addq %5,%0 \n\t" 342 "addq %5,%0 \n\t"
340 "adcq %6,%1 \n\t" 343 "adcq %6,%1 \n\t"
341 "adcq %7,%2 \n\t" 344 "adcq %7,%2 \n\t"
342 "adcq %8,%3 \n\t" 345 "adcq %8,%3 \n\t"
343 "adcq $0,%4 \n\t" 346 "adcq $0,%4 \n\t"
344 : "=r"(r0), "=r"(r1), "=r"(r2), "=r"(r3), "=r"(carry) 347 : "=r"(r0), "=r"(r1), "=r"(r2), "=r"(r3), "=r"(carry)
345 : "r" (a0), "r" (a1), "r" (a2), "r" (a3), 348 : "r" (a0), "r" (a1), "r" (a2), "r" (a3),
(...skipping 11 matching lines...) Expand all
357 360
358 /* Do quick 'subract' if we've gone over 361 /* Do quick 'subract' if we've gone over
359 * (add the 2's complement of the curve field) */ 362 * (add the 2's complement of the curve field) */
360 a3 = MP_DIGIT(&meth->irr,3); 363 a3 = MP_DIGIT(&meth->irr,3);
361 if (carry || r3 > a3 || 364 if (carry || r3 > a3 ||
362 ((r3 == a3) && mp_cmp(r,&meth->irr) != MP_LT)) { 365 ((r3 == a3) && mp_cmp(r,&meth->irr) != MP_LT)) {
363 a2 = MP_DIGIT(&meth->irr,2); 366 a2 = MP_DIGIT(&meth->irr,2);
364 a1 = MP_DIGIT(&meth->irr,1); 367 a1 = MP_DIGIT(&meth->irr,1);
365 a0 = MP_DIGIT(&meth->irr,0); 368 a0 = MP_DIGIT(&meth->irr,0);
366 #ifndef MPI_AMD64_ADD 369 #ifndef MPI_AMD64_ADD
367 » » MP_SUB_BORROW(r0, a0, r0, 0, carry); 370 carry = 0;
368 » » MP_SUB_BORROW(r1, a1, r1, carry, carry); 371 » » MP_SUB_BORROW(r0, a0, r0, carry);
369 » » MP_SUB_BORROW(r2, a2, r2, carry, carry); 372 » » MP_SUB_BORROW(r1, a1, r1, carry);
370 » » MP_SUB_BORROW(r3, a3, r3, carry, carry); 373 » » MP_SUB_BORROW(r2, a2, r2, carry);
374 » » MP_SUB_BORROW(r3, a3, r3, carry);
371 #else 375 #else
372 __asm__ ( 376 __asm__ (
373 "subq %4,%0 \n\t" 377 "subq %4,%0 \n\t"
374 "sbbq %5,%1 \n\t" 378 "sbbq %5,%1 \n\t"
375 "sbbq %6,%2 \n\t" 379 "sbbq %6,%2 \n\t"
376 "sbbq %7,%3 \n\t" 380 "sbbq %7,%3 \n\t"
377 : "=r"(r0), "=r"(r1), "=r"(r2), "=r"(r3) 381 : "=r"(r0), "=r"(r1), "=r"(r2), "=r"(r3)
378 : "r" (a0), "r" (a1), "r" (a2), "r" (a3), 382 : "r" (a0), "r" (a1), "r" (a2), "r" (a3),
379 "0" (r0), "1" (r1), "2" (r2), "3" (r3) 383 "0" (r0), "1" (r1), "2" (r2), "3" (r3)
380 : "%cc" ); 384 : "%cc" );
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
419 case 4: 423 case 4:
420 r3 = MP_DIGIT(b,3); 424 r3 = MP_DIGIT(b,3);
421 case 3: 425 case 3:
422 r2 = MP_DIGIT(b,2); 426 r2 = MP_DIGIT(b,2);
423 case 2: 427 case 2:
424 r1 = MP_DIGIT(b,1); 428 r1 = MP_DIGIT(b,1);
425 case 1: 429 case 1:
426 r0 = MP_DIGIT(b,0); 430 r0 = MP_DIGIT(b,0);
427 } 431 }
428 432
429 » MP_ADD_CARRY(a0, r0, r0, 0, carry); 433 carry = 0;
430 » MP_ADD_CARRY(a1, r1, r1, carry, carry); 434 » MP_ADD_CARRY(a0, r0, r0, carry);
431 » MP_ADD_CARRY(a2, r2, r2, carry, carry); 435 » MP_ADD_CARRY(a1, r1, r1, carry);
432 » MP_ADD_CARRY(a3, r3, r3, carry, carry); 436 » MP_ADD_CARRY(a2, r2, r2, carry);
433 » MP_ADD_CARRY(a4, r4, r4, carry, carry); 437 » MP_ADD_CARRY(a3, r3, r3, carry);
438 » MP_ADD_CARRY(a4, r4, r4, carry);
434 439
435 MP_CHECKOK(s_mp_pad(r, 5)); 440 MP_CHECKOK(s_mp_pad(r, 5));
436 MP_DIGIT(r, 4) = r4; 441 MP_DIGIT(r, 4) = r4;
437 MP_DIGIT(r, 3) = r3; 442 MP_DIGIT(r, 3) = r3;
438 MP_DIGIT(r, 2) = r2; 443 MP_DIGIT(r, 2) = r2;
439 MP_DIGIT(r, 1) = r1; 444 MP_DIGIT(r, 1) = r1;
440 MP_DIGIT(r, 0) = r0; 445 MP_DIGIT(r, 0) = r0;
441 MP_SIGN(r) = MP_ZPOS; 446 MP_SIGN(r) = MP_ZPOS;
442 MP_USED(r) = 5; 447 MP_USED(r) = 5;
443 448
444 /* Do quick 'subract' if we've gone over 449 /* Do quick 'subract' if we've gone over
445 * (add the 2's complement of the curve field) */ 450 * (add the 2's complement of the curve field) */
446 a4 = MP_DIGIT(&meth->irr,4); 451 a4 = MP_DIGIT(&meth->irr,4);
447 if (carry || r4 > a4 || 452 if (carry || r4 > a4 ||
448 ((r4 == a4) && mp_cmp(r,&meth->irr) != MP_LT)) { 453 ((r4 == a4) && mp_cmp(r,&meth->irr) != MP_LT)) {
449 a3 = MP_DIGIT(&meth->irr,3); 454 a3 = MP_DIGIT(&meth->irr,3);
450 a2 = MP_DIGIT(&meth->irr,2); 455 a2 = MP_DIGIT(&meth->irr,2);
451 a1 = MP_DIGIT(&meth->irr,1); 456 a1 = MP_DIGIT(&meth->irr,1);
452 a0 = MP_DIGIT(&meth->irr,0); 457 a0 = MP_DIGIT(&meth->irr,0);
453 » » MP_SUB_BORROW(r0, a0, r0, 0, carry); 458 carry = 0;
454 » » MP_SUB_BORROW(r1, a1, r1, carry, carry); 459 » » MP_SUB_BORROW(r0, a0, r0, carry);
455 » » MP_SUB_BORROW(r2, a2, r2, carry, carry); 460 » » MP_SUB_BORROW(r1, a1, r1, carry);
456 » » MP_SUB_BORROW(r3, a3, r3, carry, carry); 461 » » MP_SUB_BORROW(r2, a2, r2, carry);
457 » » MP_SUB_BORROW(r4, a4, r4, carry, carry); 462 » » MP_SUB_BORROW(r3, a3, r3, carry);
463 » » MP_SUB_BORROW(r4, a4, r4, carry);
458 MP_DIGIT(r, 4) = r4; 464 MP_DIGIT(r, 4) = r4;
459 MP_DIGIT(r, 3) = r3; 465 MP_DIGIT(r, 3) = r3;
460 MP_DIGIT(r, 2) = r2; 466 MP_DIGIT(r, 2) = r2;
461 MP_DIGIT(r, 1) = r1; 467 MP_DIGIT(r, 1) = r1;
462 MP_DIGIT(r, 0) = r0; 468 MP_DIGIT(r, 0) = r0;
463 } 469 }
464 470
465 s_mp_clamp(r); 471 s_mp_clamp(r);
466 472
467 CLEANUP: 473 CLEANUP:
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
500 case 4: 506 case 4:
501 r3 = MP_DIGIT(b,3); 507 r3 = MP_DIGIT(b,3);
502 case 3: 508 case 3:
503 r2 = MP_DIGIT(b,2); 509 r2 = MP_DIGIT(b,2);
504 case 2: 510 case 2:
505 r1 = MP_DIGIT(b,1); 511 r1 = MP_DIGIT(b,1);
506 case 1: 512 case 1:
507 r0 = MP_DIGIT(b,0); 513 r0 = MP_DIGIT(b,0);
508 } 514 }
509 515
510 » MP_ADD_CARRY(a0, r0, r0, 0, carry); 516 carry = 0;
511 » MP_ADD_CARRY(a1, r1, r1, carry, carry); 517 » MP_ADD_CARRY(a0, r0, r0, carry);
512 » MP_ADD_CARRY(a2, r2, r2, carry, carry); 518 » MP_ADD_CARRY(a1, r1, r1, carry);
513 » MP_ADD_CARRY(a3, r3, r3, carry, carry); 519 » MP_ADD_CARRY(a2, r2, r2, carry);
514 » MP_ADD_CARRY(a4, r4, r4, carry, carry); 520 » MP_ADD_CARRY(a3, r3, r3, carry);
515 » MP_ADD_CARRY(a5, r5, r5, carry, carry); 521 » MP_ADD_CARRY(a4, r4, r4, carry);
522 » MP_ADD_CARRY(a5, r5, r5, carry);
516 523
517 MP_CHECKOK(s_mp_pad(r, 6)); 524 MP_CHECKOK(s_mp_pad(r, 6));
518 MP_DIGIT(r, 5) = r5; 525 MP_DIGIT(r, 5) = r5;
519 MP_DIGIT(r, 4) = r4; 526 MP_DIGIT(r, 4) = r4;
520 MP_DIGIT(r, 3) = r3; 527 MP_DIGIT(r, 3) = r3;
521 MP_DIGIT(r, 2) = r2; 528 MP_DIGIT(r, 2) = r2;
522 MP_DIGIT(r, 1) = r1; 529 MP_DIGIT(r, 1) = r1;
523 MP_DIGIT(r, 0) = r0; 530 MP_DIGIT(r, 0) = r0;
524 MP_SIGN(r) = MP_ZPOS; 531 MP_SIGN(r) = MP_ZPOS;
525 MP_USED(r) = 6; 532 MP_USED(r) = 6;
526 533
527 /* Do quick 'subract' if we've gone over 534 /* Do quick 'subract' if we've gone over
528 * (add the 2's complement of the curve field) */ 535 * (add the 2's complement of the curve field) */
529 a5 = MP_DIGIT(&meth->irr,5); 536 a5 = MP_DIGIT(&meth->irr,5);
530 if (carry || r5 > a5 || 537 if (carry || r5 > a5 ||
531 ((r5 == a5) && mp_cmp(r,&meth->irr) != MP_LT)) { 538 ((r5 == a5) && mp_cmp(r,&meth->irr) != MP_LT)) {
532 a4 = MP_DIGIT(&meth->irr,4); 539 a4 = MP_DIGIT(&meth->irr,4);
533 a3 = MP_DIGIT(&meth->irr,3); 540 a3 = MP_DIGIT(&meth->irr,3);
534 a2 = MP_DIGIT(&meth->irr,2); 541 a2 = MP_DIGIT(&meth->irr,2);
535 a1 = MP_DIGIT(&meth->irr,1); 542 a1 = MP_DIGIT(&meth->irr,1);
536 a0 = MP_DIGIT(&meth->irr,0); 543 a0 = MP_DIGIT(&meth->irr,0);
537 » » MP_SUB_BORROW(r0, a0, r0, 0, carry); 544 carry = 0;
538 » » MP_SUB_BORROW(r1, a1, r1, carry, carry); 545 » » MP_SUB_BORROW(r0, a0, r0, carry);
539 » » MP_SUB_BORROW(r2, a2, r2, carry, carry); 546 » » MP_SUB_BORROW(r1, a1, r1, carry);
540 » » MP_SUB_BORROW(r3, a3, r3, carry, carry); 547 » » MP_SUB_BORROW(r2, a2, r2, carry);
541 » » MP_SUB_BORROW(r4, a4, r4, carry, carry); 548 » » MP_SUB_BORROW(r3, a3, r3, carry);
542 » » MP_SUB_BORROW(r5, a5, r5, carry, carry); 549 » » MP_SUB_BORROW(r4, a4, r4, carry);
550 » » MP_SUB_BORROW(r5, a5, r5, carry);
543 MP_DIGIT(r, 5) = r5; 551 MP_DIGIT(r, 5) = r5;
544 MP_DIGIT(r, 4) = r4; 552 MP_DIGIT(r, 4) = r4;
545 MP_DIGIT(r, 3) = r3; 553 MP_DIGIT(r, 3) = r3;
546 MP_DIGIT(r, 2) = r2; 554 MP_DIGIT(r, 2) = r2;
547 MP_DIGIT(r, 1) = r1; 555 MP_DIGIT(r, 1) = r1;
548 MP_DIGIT(r, 0) = r0; 556 MP_DIGIT(r, 0) = r0;
549 } 557 }
550 558
551 s_mp_clamp(r); 559 s_mp_clamp(r);
552 560
(...skipping 27 matching lines...) Expand all
580 switch(MP_USED(b)) { 588 switch(MP_USED(b)) {
581 case 3: 589 case 3:
582 b2 = MP_DIGIT(b,2); 590 b2 = MP_DIGIT(b,2);
583 case 2: 591 case 2:
584 b1 = MP_DIGIT(b,1); 592 b1 = MP_DIGIT(b,1);
585 case 1: 593 case 1:
586 b0 = MP_DIGIT(b,0); 594 b0 = MP_DIGIT(b,0);
587 } 595 }
588 596
589 #ifndef MPI_AMD64_ADD 597 #ifndef MPI_AMD64_ADD
590 » MP_SUB_BORROW(r0, b0, r0, 0, borrow); 598 borrow = 0;
591 » MP_SUB_BORROW(r1, b1, r1, borrow, borrow); 599 » MP_SUB_BORROW(r0, b0, r0, borrow);
592 » MP_SUB_BORROW(r2, b2, r2, borrow, borrow); 600 » MP_SUB_BORROW(r1, b1, r1, borrow);
601 » MP_SUB_BORROW(r2, b2, r2, borrow);
593 #else 602 #else
594 __asm__ ( 603 __asm__ (
595 "xorq %3,%3 \n\t" 604 "xorq %3,%3 \n\t"
596 "subq %4,%0 \n\t" 605 "subq %4,%0 \n\t"
597 "sbbq %5,%1 \n\t" 606 "sbbq %5,%1 \n\t"
598 "sbbq %6,%2 \n\t" 607 "sbbq %6,%2 \n\t"
599 "adcq $0,%3 \n\t" 608 "adcq $0,%3 \n\t"
600 : "=r"(r0), "=r"(r1), "=r"(r2), "=r" (borrow) 609 : "=r"(r0), "=r"(r1), "=r"(r2), "=r" (borrow)
601 : "r" (b0), "r" (b1), "r" (b2), 610 : "r" (b0), "r" (b1), "r" (b2),
602 "0" (r0), "1" (r1), "2" (r2) 611 "0" (r0), "1" (r1), "2" (r2)
603 : "%cc" ); 612 : "%cc" );
604 #endif 613 #endif
605 614
606 /* Do quick 'add' if we've gone under 0 615 /* Do quick 'add' if we've gone under 0
607 * (subtract the 2's complement of the curve field) */ 616 * (subtract the 2's complement of the curve field) */
608 if (borrow) { 617 if (borrow) {
609 b2 = MP_DIGIT(&meth->irr,2); 618 b2 = MP_DIGIT(&meth->irr,2);
610 b1 = MP_DIGIT(&meth->irr,1); 619 b1 = MP_DIGIT(&meth->irr,1);
611 b0 = MP_DIGIT(&meth->irr,0); 620 b0 = MP_DIGIT(&meth->irr,0);
612 #ifndef MPI_AMD64_ADD 621 #ifndef MPI_AMD64_ADD
613 » » MP_ADD_CARRY(b0, r0, r0, 0, borrow); 622 borrow = 0;
614 » » MP_ADD_CARRY(b1, r1, r1, borrow, borrow); 623 » » MP_ADD_CARRY(b0, r0, r0, borrow);
615 » » MP_ADD_CARRY(b2, r2, r2, borrow, borrow); 624 » » MP_ADD_CARRY(b1, r1, r1, borrow);
625 » » MP_ADD_CARRY(b2, r2, r2, borrow);
616 #else 626 #else
617 __asm__ ( 627 __asm__ (
618 "addq %3,%0 \n\t" 628 "addq %3,%0 \n\t"
619 "adcq %4,%1 \n\t" 629 "adcq %4,%1 \n\t"
620 "adcq %5,%2 \n\t" 630 "adcq %5,%2 \n\t"
621 : "=r"(r0), "=r"(r1), "=r"(r2) 631 : "=r"(r0), "=r"(r1), "=r"(r2)
622 : "r" (b0), "r" (b1), "r" (b2), 632 : "r" (b0), "r" (b1), "r" (b2),
623 "0" (r0), "1" (r1), "2" (r2) 633 "0" (r0), "1" (r1), "2" (r2)
624 : "%cc" ); 634 : "%cc" );
625 #endif 635 #endif
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
668 b3 = MP_DIGIT(b,3); 678 b3 = MP_DIGIT(b,3);
669 case 3: 679 case 3:
670 b2 = MP_DIGIT(b,2); 680 b2 = MP_DIGIT(b,2);
671 case 2: 681 case 2:
672 b1 = MP_DIGIT(b,1); 682 b1 = MP_DIGIT(b,1);
673 case 1: 683 case 1:
674 b0 = MP_DIGIT(b,0); 684 b0 = MP_DIGIT(b,0);
675 } 685 }
676 686
677 #ifndef MPI_AMD64_ADD 687 #ifndef MPI_AMD64_ADD
678 » MP_SUB_BORROW(r0, b0, r0, 0, borrow); 688 borrow = 0;
679 » MP_SUB_BORROW(r1, b1, r1, borrow, borrow); 689 » MP_SUB_BORROW(r0, b0, r0, borrow);
680 » MP_SUB_BORROW(r2, b2, r2, borrow, borrow); 690 » MP_SUB_BORROW(r1, b1, r1, borrow);
681 » MP_SUB_BORROW(r3, b3, r3, borrow, borrow); 691 » MP_SUB_BORROW(r2, b2, r2, borrow);
692 » MP_SUB_BORROW(r3, b3, r3, borrow);
682 #else 693 #else
683 __asm__ ( 694 __asm__ (
684 "xorq %4,%4 \n\t" 695 "xorq %4,%4 \n\t"
685 "subq %5,%0 \n\t" 696 "subq %5,%0 \n\t"
686 "sbbq %6,%1 \n\t" 697 "sbbq %6,%1 \n\t"
687 "sbbq %7,%2 \n\t" 698 "sbbq %7,%2 \n\t"
688 "sbbq %8,%3 \n\t" 699 "sbbq %8,%3 \n\t"
689 "adcq $0,%4 \n\t" 700 "adcq $0,%4 \n\t"
690 : "=r"(r0), "=r"(r1), "=r"(r2), "=r"(r3), "=r" (borrow) 701 : "=r"(r0), "=r"(r1), "=r"(r2), "=r"(r3), "=r" (borrow)
691 : "r" (b0), "r" (b1), "r" (b2), "r" (b3), 702 : "r" (b0), "r" (b1), "r" (b2), "r" (b3),
692 "0" (r0), "1" (r1), "2" (r2), "3" (r3) 703 "0" (r0), "1" (r1), "2" (r2), "3" (r3)
693 : "%cc" ); 704 : "%cc" );
694 #endif 705 #endif
695 706
696 /* Do quick 'add' if we've gone under 0 707 /* Do quick 'add' if we've gone under 0
697 * (subtract the 2's complement of the curve field) */ 708 * (subtract the 2's complement of the curve field) */
698 if (borrow) { 709 if (borrow) {
699 b3 = MP_DIGIT(&meth->irr,3); 710 b3 = MP_DIGIT(&meth->irr,3);
700 b2 = MP_DIGIT(&meth->irr,2); 711 b2 = MP_DIGIT(&meth->irr,2);
701 b1 = MP_DIGIT(&meth->irr,1); 712 b1 = MP_DIGIT(&meth->irr,1);
702 b0 = MP_DIGIT(&meth->irr,0); 713 b0 = MP_DIGIT(&meth->irr,0);
703 #ifndef MPI_AMD64_ADD 714 #ifndef MPI_AMD64_ADD
704 » » MP_ADD_CARRY(b0, r0, r0, 0, borrow); 715 borrow = 0;
705 » » MP_ADD_CARRY(b1, r1, r1, borrow, borrow); 716 » » MP_ADD_CARRY(b0, r0, r0, borrow);
706 » » MP_ADD_CARRY(b2, r2, r2, borrow, borrow); 717 » » MP_ADD_CARRY(b1, r1, r1, borrow);
707 » » MP_ADD_CARRY(b3, r3, r3, borrow, borrow); 718 » » MP_ADD_CARRY(b2, r2, r2, borrow);
719 » » MP_ADD_CARRY(b3, r3, r3, borrow);
708 #else 720 #else
709 __asm__ ( 721 __asm__ (
710 "addq %4,%0 \n\t" 722 "addq %4,%0 \n\t"
711 "adcq %5,%1 \n\t" 723 "adcq %5,%1 \n\t"
712 "adcq %6,%2 \n\t" 724 "adcq %6,%2 \n\t"
713 "adcq %7,%3 \n\t" 725 "adcq %7,%3 \n\t"
714 : "=r"(r0), "=r"(r1), "=r"(r2), "=r"(r3) 726 : "=r"(r0), "=r"(r1), "=r"(r2), "=r"(r3)
715 : "r" (b0), "r" (b1), "r" (b2), "r" (b3), 727 : "r" (b0), "r" (b1), "r" (b2), "r" (b3),
716 "0" (r0), "1" (r1), "2" (r2), "3" (r3) 728 "0" (r0), "1" (r1), "2" (r2), "3" (r3)
717 : "%cc" ); 729 : "%cc" );
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
764 case 4: 776 case 4:
765 b3 = MP_DIGIT(b,3); 777 b3 = MP_DIGIT(b,3);
766 case 3: 778 case 3:
767 b2 = MP_DIGIT(b,2); 779 b2 = MP_DIGIT(b,2);
768 case 2: 780 case 2:
769 b1 = MP_DIGIT(b,1); 781 b1 = MP_DIGIT(b,1);
770 case 1: 782 case 1:
771 b0 = MP_DIGIT(b,0); 783 b0 = MP_DIGIT(b,0);
772 } 784 }
773 785
774 » MP_SUB_BORROW(r0, b0, r0, 0, borrow); 786 borrow = 0;
775 » MP_SUB_BORROW(r1, b1, r1, borrow, borrow); 787 » MP_SUB_BORROW(r0, b0, r0, borrow);
776 » MP_SUB_BORROW(r2, b2, r2, borrow, borrow); 788 » MP_SUB_BORROW(r1, b1, r1, borrow);
777 » MP_SUB_BORROW(r3, b3, r3, borrow, borrow); 789 » MP_SUB_BORROW(r2, b2, r2, borrow);
778 » MP_SUB_BORROW(r4, b4, r4, borrow, borrow); 790 » MP_SUB_BORROW(r3, b3, r3, borrow);
791 » MP_SUB_BORROW(r4, b4, r4, borrow);
779 792
780 /* Do quick 'add' if we've gone under 0 793 /* Do quick 'add' if we've gone under 0
781 * (subtract the 2's complement of the curve field) */ 794 * (subtract the 2's complement of the curve field) */
782 if (borrow) { 795 if (borrow) {
783 b4 = MP_DIGIT(&meth->irr,4); 796 b4 = MP_DIGIT(&meth->irr,4);
784 b3 = MP_DIGIT(&meth->irr,3); 797 b3 = MP_DIGIT(&meth->irr,3);
785 b2 = MP_DIGIT(&meth->irr,2); 798 b2 = MP_DIGIT(&meth->irr,2);
786 b1 = MP_DIGIT(&meth->irr,1); 799 b1 = MP_DIGIT(&meth->irr,1);
787 b0 = MP_DIGIT(&meth->irr,0); 800 b0 = MP_DIGIT(&meth->irr,0);
788 » » MP_ADD_CARRY(b0, r0, r0, 0, borrow); 801 borrow = 0;
789 » » MP_ADD_CARRY(b1, r1, r1, borrow, borrow); 802 » » MP_ADD_CARRY(b0, r0, r0, borrow);
790 » » MP_ADD_CARRY(b2, r2, r2, borrow, borrow); 803 » » MP_ADD_CARRY(b1, r1, r1, borrow);
791 » » MP_ADD_CARRY(b3, r3, r3, borrow, borrow); 804 » » MP_ADD_CARRY(b2, r2, r2, borrow);
805 » » MP_ADD_CARRY(b3, r3, r3, borrow);
792 } 806 }
793 MP_CHECKOK(s_mp_pad(r, 5)); 807 MP_CHECKOK(s_mp_pad(r, 5));
794 MP_DIGIT(r, 4) = r4; 808 MP_DIGIT(r, 4) = r4;
795 MP_DIGIT(r, 3) = r3; 809 MP_DIGIT(r, 3) = r3;
796 MP_DIGIT(r, 2) = r2; 810 MP_DIGIT(r, 2) = r2;
797 MP_DIGIT(r, 1) = r1; 811 MP_DIGIT(r, 1) = r1;
798 MP_DIGIT(r, 0) = r0; 812 MP_DIGIT(r, 0) = r0;
799 MP_SIGN(r) = MP_ZPOS; 813 MP_SIGN(r) = MP_ZPOS;
800 MP_USED(r) = 5; 814 MP_USED(r) = 5;
801 s_mp_clamp(r); 815 s_mp_clamp(r);
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
836 case 4: 850 case 4:
837 b3 = MP_DIGIT(b,3); 851 b3 = MP_DIGIT(b,3);
838 case 3: 852 case 3:
839 b2 = MP_DIGIT(b,2); 853 b2 = MP_DIGIT(b,2);
840 case 2: 854 case 2:
841 b1 = MP_DIGIT(b,1); 855 b1 = MP_DIGIT(b,1);
842 case 1: 856 case 1:
843 b0 = MP_DIGIT(b,0); 857 b0 = MP_DIGIT(b,0);
844 } 858 }
845 859
846 » MP_SUB_BORROW(r0, b0, r0, 0, borrow); 860 borrow = 0;
847 » MP_SUB_BORROW(r1, b1, r1, borrow, borrow); 861 » MP_SUB_BORROW(r0, b0, r0, borrow);
848 » MP_SUB_BORROW(r2, b2, r2, borrow, borrow); 862 » MP_SUB_BORROW(r1, b1, r1, borrow);
849 » MP_SUB_BORROW(r3, b3, r3, borrow, borrow); 863 » MP_SUB_BORROW(r2, b2, r2, borrow);
850 » MP_SUB_BORROW(r4, b4, r4, borrow, borrow); 864 » MP_SUB_BORROW(r3, b3, r3, borrow);
851 » MP_SUB_BORROW(r5, b5, r5, borrow, borrow); 865 » MP_SUB_BORROW(r4, b4, r4, borrow);
866 » MP_SUB_BORROW(r5, b5, r5, borrow);
852 867
853 /* Do quick 'add' if we've gone under 0 868 /* Do quick 'add' if we've gone under 0
854 * (subtract the 2's complement of the curve field) */ 869 * (subtract the 2's complement of the curve field) */
855 if (borrow) { 870 if (borrow) {
856 b5 = MP_DIGIT(&meth->irr,5); 871 b5 = MP_DIGIT(&meth->irr,5);
857 b4 = MP_DIGIT(&meth->irr,4); 872 b4 = MP_DIGIT(&meth->irr,4);
858 b3 = MP_DIGIT(&meth->irr,3); 873 b3 = MP_DIGIT(&meth->irr,3);
859 b2 = MP_DIGIT(&meth->irr,2); 874 b2 = MP_DIGIT(&meth->irr,2);
860 b1 = MP_DIGIT(&meth->irr,1); 875 b1 = MP_DIGIT(&meth->irr,1);
861 b0 = MP_DIGIT(&meth->irr,0); 876 b0 = MP_DIGIT(&meth->irr,0);
862 » » MP_ADD_CARRY(b0, r0, r0, 0, borrow); 877 borrow = 0;
863 » » MP_ADD_CARRY(b1, r1, r1, borrow, borrow); 878 » » MP_ADD_CARRY(b0, r0, r0, borrow);
864 » » MP_ADD_CARRY(b2, r2, r2, borrow, borrow); 879 » » MP_ADD_CARRY(b1, r1, r1, borrow);
865 » » MP_ADD_CARRY(b3, r3, r3, borrow, borrow); 880 » » MP_ADD_CARRY(b2, r2, r2, borrow);
866 » » MP_ADD_CARRY(b4, r4, r4, borrow, borrow); 881 » » MP_ADD_CARRY(b3, r3, r3, borrow);
882 » » MP_ADD_CARRY(b4, r4, r4, borrow);
867 } 883 }
868 884
869 MP_CHECKOK(s_mp_pad(r, 6)); 885 MP_CHECKOK(s_mp_pad(r, 6));
870 MP_DIGIT(r, 5) = r5; 886 MP_DIGIT(r, 5) = r5;
871 MP_DIGIT(r, 4) = r4; 887 MP_DIGIT(r, 4) = r4;
872 MP_DIGIT(r, 3) = r3; 888 MP_DIGIT(r, 3) = r3;
873 MP_DIGIT(r, 2) = r2; 889 MP_DIGIT(r, 2) = r2;
874 MP_DIGIT(r, 1) = r1; 890 MP_DIGIT(r, 1) = r1;
875 MP_DIGIT(r, 0) = r0; 891 MP_DIGIT(r, 0) = r0;
876 MP_SIGN(r) = MP_ZPOS; 892 MP_SIGN(r) = MP_ZPOS;
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after
988 MP_CHECKOK(mp_init(&t)); 1004 MP_CHECKOK(mp_init(&t));
989 MP_CHECKOK(mp_set_int(&t, 1)); 1005 MP_CHECKOK(mp_set_int(&t, 1));
990 MP_CHECKOK(mp_bdivmod(&t, b, &meth->irr, meth->irr_arr, r)); 1006 MP_CHECKOK(mp_bdivmod(&t, b, &meth->irr, meth->irr_arr, r));
991 CLEANUP: 1007 CLEANUP:
992 mp_clear(&t); 1008 mp_clear(&t);
993 return res; 1009 return res;
994 } else { 1010 } else {
995 return mp_bdivmod(a, b, &meth->irr, meth->irr_arr, r); 1011 return mp_bdivmod(a, b, &meth->irr, meth->irr_arr, r);
996 } 1012 }
997 } 1013 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698