]> Git Repo - linux.git/blobdiff - lib/mpi/mpi-bit.c
drivers, usb: convert ffs_data.ref from atomic_t to refcount_t
[linux.git] / lib / mpi / mpi-bit.c
index 0c505361da197a9a46c8b2665af7b5520ad11974..503537e084369ca54ca56b27a8b939597c0cbf05 100644 (file)
@@ -45,7 +45,7 @@ unsigned mpi_get_nbits(MPI a)
        if (a->nlimbs) {
                mpi_limb_t alimb = a->d[a->nlimbs - 1];
                if (alimb)
-                       count_leading_zeros(n, alimb);
+                       n = count_leading_zeros(alimb);
                else
                        n = BITS_PER_MPI_LIMB;
                n = BITS_PER_MPI_LIMB - n + (a->nlimbs - 1) * BITS_PER_MPI_LIMB;
@@ -54,165 +54,3 @@ unsigned mpi_get_nbits(MPI a)
        return n;
 }
 EXPORT_SYMBOL_GPL(mpi_get_nbits);
-
-/****************
- * Test whether bit N is set.
- */
-int mpi_test_bit(MPI a, unsigned n)
-{
-       unsigned limbno, bitno;
-       mpi_limb_t limb;
-
-       limbno = n / BITS_PER_MPI_LIMB;
-       bitno = n % BITS_PER_MPI_LIMB;
-
-       if (limbno >= a->nlimbs)
-               return 0;       /* too far left: this is a 0 */
-       limb = a->d[limbno];
-       return (limb & (A_LIMB_1 << bitno)) ? 1 : 0;
-}
-
-/****************
- * Set bit N of A.
- */
-int mpi_set_bit(MPI a, unsigned n)
-{
-       unsigned limbno, bitno;
-
-       limbno = n / BITS_PER_MPI_LIMB;
-       bitno = n % BITS_PER_MPI_LIMB;
-
-       if (limbno >= a->nlimbs) {      /* resize */
-               if (a->alloced >= limbno)
-                       if (mpi_resize(a, limbno + 1) < 0)
-                               return -ENOMEM;
-               a->nlimbs = limbno + 1;
-       }
-       a->d[limbno] |= (A_LIMB_1 << bitno);
-       return 0;
-}
-
-/****************
- * Set bit N of A. and clear all bits above
- */
-int mpi_set_highbit(MPI a, unsigned n)
-{
-       unsigned limbno, bitno;
-
-       limbno = n / BITS_PER_MPI_LIMB;
-       bitno = n % BITS_PER_MPI_LIMB;
-
-       if (limbno >= a->nlimbs) {      /* resize */
-               if (a->alloced >= limbno)
-                       if (mpi_resize(a, limbno + 1) < 0)
-                               return -ENOMEM;
-               a->nlimbs = limbno + 1;
-       }
-       a->d[limbno] |= (A_LIMB_1 << bitno);
-       for (bitno++; bitno < BITS_PER_MPI_LIMB; bitno++)
-               a->d[limbno] &= ~(A_LIMB_1 << bitno);
-       a->nlimbs = limbno + 1;
-       return 0;
-}
-
-/****************
- * clear bit N of A and all bits above
- */
-void mpi_clear_highbit(MPI a, unsigned n)
-{
-       unsigned limbno, bitno;
-
-       limbno = n / BITS_PER_MPI_LIMB;
-       bitno = n % BITS_PER_MPI_LIMB;
-
-       if (limbno >= a->nlimbs)
-               return;         /* not allocated, so need to clear bits :-) */
-
-       for (; bitno < BITS_PER_MPI_LIMB; bitno++)
-               a->d[limbno] &= ~(A_LIMB_1 << bitno);
-       a->nlimbs = limbno + 1;
-}
-
-/****************
- * Clear bit N of A.
- */
-void mpi_clear_bit(MPI a, unsigned n)
-{
-       unsigned limbno, bitno;
-
-       limbno = n / BITS_PER_MPI_LIMB;
-       bitno = n % BITS_PER_MPI_LIMB;
-
-       if (limbno >= a->nlimbs)
-               return;         /* don't need to clear this bit, it's to far to left */
-       a->d[limbno] &= ~(A_LIMB_1 << bitno);
-}
-
-/****************
- * Shift A by N bits to the right
- * FIXME: should use alloc_limb if X and A are same.
- */
-int mpi_rshift(MPI x, MPI a, unsigned n)
-{
-       mpi_ptr_t xp;
-       mpi_size_t xsize;
-
-       xsize = a->nlimbs;
-       x->sign = a->sign;
-       if (RESIZE_IF_NEEDED(x, (size_t) xsize) < 0)
-               return -ENOMEM;
-       xp = x->d;
-
-       if (xsize) {
-               mpihelp_rshift(xp, a->d, xsize, n);
-               MPN_NORMALIZE(xp, xsize);
-       }
-       x->nlimbs = xsize;
-       return 0;
-}
-
-/****************
- * Shift A by COUNT limbs to the left
- * This is used only within the MPI library
- */
-int mpi_lshift_limbs(MPI a, unsigned int count)
-{
-       const int n = a->nlimbs;
-       mpi_ptr_t ap;
-       int i;
-
-       if (!count || !n)
-               return 0;
-
-       if (RESIZE_IF_NEEDED(a, n + count) < 0)
-               return -ENOMEM;
-
-       ap = a->d;
-       for (i = n - 1; i >= 0; i--)
-               ap[i + count] = ap[i];
-       for (i = 0; i < count; i++)
-               ap[i] = 0;
-       a->nlimbs += count;
-       return 0;
-}
-
-/****************
- * Shift A by COUNT limbs to the right
- * This is used only within the MPI library
- */
-void mpi_rshift_limbs(MPI a, unsigned int count)
-{
-       mpi_ptr_t ap = a->d;
-       mpi_size_t n = a->nlimbs;
-       unsigned int i;
-
-       if (count >= n) {
-               a->nlimbs = 0;
-               return;
-       }
-
-       for (i = 0; i < n - count; i++)
-               ap[i] = ap[i + count];
-       ap[i] = 0;
-       a->nlimbs -= count;
-}
This page took 0.038601 seconds and 4 git commands to generate.