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

Side by Side Diff: nss/lib/freebl/mpi/mplogic.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 /* 1 /*
2 * mplogic.c 2 * mplogic.c
3 * 3 *
4 * Bitwise logical operations on MPI values 4 * Bitwise logical operations on MPI values
5 * 5 *
6 * This Source Code Form is subject to the terms of the Mozilla Public 6 * This Source Code Form is subject to the terms of the Mozilla Public
7 * License, v. 2.0. If a copy of the MPL was not distributed with this 7 * License, v. 2.0. If a copy of the MPL was not distributed with this
8 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 8 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
9 9
10 #include "mpi-priv.h" 10 #include "mpi-priv.h"
(...skipping 385 matching lines...) Expand 10 before | Expand all | Expand 10 after
396 mask &= ((digit[0] >> rshift) | (digit[1] << (MP_DIGIT_BIT - rshift))); 396 mask &= ((digit[0] >> rshift) | (digit[1] << (MP_DIGIT_BIT - rshift)));
397 } 397 }
398 return (mp_err)mask; 398 return (mp_err)mask;
399 } 399 }
400 400
401 /* 401 /*
402 mpl_significant_bits 402 mpl_significant_bits
403 returns number of significnant bits in abs(a). 403 returns number of significnant bits in abs(a).
404 returns 1 if value is zero. 404 returns 1 if value is zero.
405 */ 405 */
406 mp_err mpl_significant_bits(const mp_int *a) 406 mp_size mpl_significant_bits(const mp_int *a)
407 { 407 {
408 mp_err bits » = 0; 408 mp_size bits = 0;
409 int ix; 409 int ix;
410 410
411 ARGCHK(a != NULL, MP_BADARG); 411 ARGCHK(a != NULL, MP_BADARG);
412 412
413 ix = MP_USED(a); 413 ix = MP_USED(a);
414 for (ix = MP_USED(a); ix > 0; ) { 414 for (ix = MP_USED(a); ix > 0; ) {
415 mp_digit d; 415 mp_digit d;
416 d = MP_DIGIT(a, --ix); 416 d = MP_DIGIT(a, --ix);
417 if (d) { 417 if (d) {
418 while (d) { 418 while (d) {
419 ++bits; 419 ++bits;
420 d >>= 1; 420 d >>= 1;
421 } 421 }
422 break; 422 break;
423 } 423 }
424 } 424 }
425 bits += ix * MP_DIGIT_BIT; 425 bits += ix * MP_DIGIT_BIT;
426 if (!bits) 426 if (!bits)
427 bits = 1; 427 bits = 1;
428 return bits; 428 return bits;
429 } 429 }
430 430
431 /*------------------------------------------------------------------------*/ 431 /*------------------------------------------------------------------------*/
432 /* HERE THERE BE DRAGONS */ 432 /* HERE THERE BE DRAGONS */
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698