Lines Matching full:a
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * You should have received a copy of the GNU General Public License
66 /* Return a constant MPI descripbed by NO which is one of the
81 * Note: It was a bad idea to use the number of limbs to allocate
82 * because on a alpha the limbs are large but we normally need
85 * But mpi_alloc is used in a lot of places :-)
89 MPI a; in mpi_alloc() local
91 a = kmalloc(sizeof *a, GFP_KERNEL); in mpi_alloc()
92 if (!a) in mpi_alloc()
93 return a; in mpi_alloc()
96 a->d = mpi_alloc_limb_space(nlimbs); in mpi_alloc()
97 if (!a->d) { in mpi_alloc()
98 kfree(a); in mpi_alloc()
102 a->d = NULL; in mpi_alloc()
105 a->alloced = nlimbs; in mpi_alloc()
106 a->nlimbs = 0; in mpi_alloc()
107 a->sign = 0; in mpi_alloc()
108 a->flags = 0; in mpi_alloc()
109 a->nbits = 0; in mpi_alloc()
110 return a; in mpi_alloc()
124 void mpi_free_limb_space(mpi_ptr_t a) in mpi_free_limb_space() argument
126 if (!a) in mpi_free_limb_space()
129 kfree_sensitive(a); in mpi_free_limb_space()
132 void mpi_assign_limb_space(MPI a, mpi_ptr_t ap, unsigned nlimbs) in mpi_assign_limb_space() argument
134 mpi_free_limb_space(a->d); in mpi_assign_limb_space()
135 a->d = ap; in mpi_assign_limb_space()
136 a->alloced = nlimbs; in mpi_assign_limb_space()
140 * Resize the array of A to NLIMBS. the additional space is cleared
143 int mpi_resize(MPI a, unsigned nlimbs) in mpi_resize() argument
147 if (nlimbs <= a->alloced) in mpi_resize()
150 if (a->d) { in mpi_resize()
154 memcpy(p, a->d, a->alloced * sizeof(mpi_limb_t)); in mpi_resize()
155 kfree_sensitive(a->d); in mpi_resize()
156 a->d = p; in mpi_resize()
158 a->d = kcalloc(nlimbs, sizeof(mpi_limb_t), GFP_KERNEL); in mpi_resize()
159 if (!a->d) in mpi_resize()
162 a->alloced = nlimbs; in mpi_resize()
166 void mpi_clear(MPI a) in mpi_clear() argument
168 if (!a) in mpi_clear()
170 a->nlimbs = 0; in mpi_clear()
171 a->flags = 0; in mpi_clear()
175 void mpi_free(MPI a) in mpi_free() argument
177 if (!a) in mpi_free()
180 if (a->flags & 4) in mpi_free()
181 kfree_sensitive(a->d); in mpi_free()
183 mpi_free_limb_space(a->d); in mpi_free()
185 if (a->flags & ~7) in mpi_free()
187 kfree(a); in mpi_free()
195 MPI mpi_copy(MPI a) in mpi_copy() argument
200 if (a) { in mpi_copy()
201 b = mpi_alloc(a->nlimbs); in mpi_copy()
202 b->nlimbs = a->nlimbs; in mpi_copy()
203 b->sign = a->sign; in mpi_copy()
204 b->flags = a->flags; in mpi_copy()
207 b->d[i] = a->d[i]; in mpi_copy()
215 * a value as large as the one given in the argument and allocates it
216 * with the same flags as A.
218 MPI mpi_alloc_like(MPI a) in mpi_alloc_like() argument
222 if (a) { in mpi_alloc_like()
223 b = mpi_alloc(a->nlimbs); in mpi_alloc_like()
226 b->flags = a->flags; in mpi_alloc_like()
296 * Swap the value of A and B, when SWAP is 1.
300 void mpi_swap_cond(MPI a, MPI b, unsigned long swap) in mpi_swap_cond() argument
307 if (a->alloced > b->alloced) in mpi_swap_cond()
310 nlimbs = a->alloced; in mpi_swap_cond()
311 if (a->nlimbs > nlimbs || b->nlimbs > nlimbs) in mpi_swap_cond()
315 x = mask & (a->d[i] ^ b->d[i]); in mpi_swap_cond()
316 a->d[i] = a->d[i] ^ x; in mpi_swap_cond()
320 x = mask & (a->nlimbs ^ b->nlimbs); in mpi_swap_cond()
321 a->nlimbs = a->nlimbs ^ x; in mpi_swap_cond()
324 x = mask & (a->sign ^ b->sign); in mpi_swap_cond()
325 a->sign = a->sign ^ x; in mpi_swap_cond()