Thu, 22 Jan 2015 13:21:57 +0100
Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6
michael@0 | 1 | /* This Source Code Form is subject to the terms of the Mozilla Public |
michael@0 | 2 | * License, v. 2.0. If a copy of the MPL was not distributed with this |
michael@0 | 3 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
michael@0 | 4 | |
michael@0 | 5 | /* The functions that are to be called from outside of the .s file have the |
michael@0 | 6 | * following interfaces and array size requirements: |
michael@0 | 7 | */ |
michael@0 | 8 | |
michael@0 | 9 | |
michael@0 | 10 | void conv_i32_to_d32(double *d32, unsigned int *i32, int len); |
michael@0 | 11 | |
michael@0 | 12 | /* Converts an array of int's to an array of doubles, so that each double |
michael@0 | 13 | * corresponds to an int. len is the number of items converted. |
michael@0 | 14 | * Does not allocate the output array. |
michael@0 | 15 | * The pointers d32 and i32 should point to arrays of size at least len |
michael@0 | 16 | * (doubles and unsigned ints, respectively) |
michael@0 | 17 | */ |
michael@0 | 18 | |
michael@0 | 19 | |
michael@0 | 20 | void conv_i32_to_d16(double *d16, unsigned int *i32, int len); |
michael@0 | 21 | |
michael@0 | 22 | /* Converts an array of int's to an array of doubles so that each element |
michael@0 | 23 | * of the int array is converted to a pair of doubles, the first one |
michael@0 | 24 | * corresponding to the lower (least significant) 16 bits of the int and |
michael@0 | 25 | * the second one corresponding to the upper (most significant) 16 bits of |
michael@0 | 26 | * the 32-bit int. len is the number of ints converted. |
michael@0 | 27 | * Does not allocate the output array. |
michael@0 | 28 | * The pointer d16 should point to an array of doubles of size at least |
michael@0 | 29 | * 2*len and i32 should point an array of ints of size at least len |
michael@0 | 30 | */ |
michael@0 | 31 | |
michael@0 | 32 | |
michael@0 | 33 | void conv_i32_to_d32_and_d16(double *d32, double *d16, |
michael@0 | 34 | unsigned int *i32, int len); |
michael@0 | 35 | |
michael@0 | 36 | /* Does the above two conversions together, it is much faster than doing |
michael@0 | 37 | * both of those in succession |
michael@0 | 38 | */ |
michael@0 | 39 | |
michael@0 | 40 | |
michael@0 | 41 | void mont_mulf_noconv(unsigned int *result, |
michael@0 | 42 | double *dm1, double *dm2, double *dt, |
michael@0 | 43 | double *dn, unsigned int *nint, |
michael@0 | 44 | int nlen, double dn0); |
michael@0 | 45 | |
michael@0 | 46 | /* Does the Montgomery multiplication of the numbers stored in the arrays |
michael@0 | 47 | * pointed to by dm1 and dm2, writing the result to the array pointed to by |
michael@0 | 48 | * result. It uses the array pointed to by dt as a temporary work area. |
michael@0 | 49 | * nint should point to the modulus in the array-of-integers representation, |
michael@0 | 50 | * dn should point to its array-of-doubles as obtained as a result of the |
michael@0 | 51 | * function call conv_i32_to_d32(dn, nint, nlen); |
michael@0 | 52 | * nlen is the length of the array containing the modulus. |
michael@0 | 53 | * The representation used for dm1 is the one that is a result of the function |
michael@0 | 54 | * call conv_i32_to_d32(dm1, m1, nlen), the representation for dm2 is the |
michael@0 | 55 | * result of the function call conv_i32_to_d16(dm2, m2, nlen). |
michael@0 | 56 | * Note that m1 and m2 should both be of length nlen, so they should be |
michael@0 | 57 | * padded with 0's if necessary before the conversion. The result comes in |
michael@0 | 58 | * this form (int representation, padded with 0's). |
michael@0 | 59 | * dn0 is the value of the 16 least significant bits of n0'. |
michael@0 | 60 | * The function does not allocate memory for any of the arrays, so the |
michael@0 | 61 | * pointers should point to arrays with the following minimal sizes: |
michael@0 | 62 | * result - nlen+1 |
michael@0 | 63 | * dm1 - nlen |
michael@0 | 64 | * dm2 - 2*nlen+1 ( the +1 is necessary for technical reasons ) |
michael@0 | 65 | * dt - 4*nlen+2 |
michael@0 | 66 | * dn - nlen |
michael@0 | 67 | * nint - nlen |
michael@0 | 68 | * No two arrays should point to overlapping areas of memory. |
michael@0 | 69 | */ |