lightningsunbird
0.9+nobinonly

00001 /* ***** BEGIN LICENSE BLOCK ***** 00002 * Version: MPL 1.1/GPL 2.0/LGPL 2.1 00003 * 00004 * The contents of this file are subject to the Mozilla Public License Version 00005 * 1.1 (the "License"); you may not use this file except in compliance with 00006 * the License. You may obtain a copy of the License at 00007 * http://www.mozilla.org/MPL/ 00008 * 00009 * Software distributed under the License is distributed on an "AS IS" basis, 00010 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License 00011 * for the specific language governing rights and limitations under the 00012 * License. 00013 * 00014 * The Original Code is interface file for SPARC Montgomery multiply functions. 00015 * 00016 * The Initial Developer of the Original Code is 00017 * Sun Microsystems Inc. 00018 * Portions created by the Initial Developer are Copyright (C) 19992000 00019 * the Initial Developer. All Rights Reserved. 00020 * 00021 * Contributor(s): 00022 * Netscape Communications Corporation 00023 * 00024 * Alternatively, the contents of this file may be used under the terms of 00025 * either the GNU General Public License Version 2 or later (the "GPL"), or 00026 * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), 00027 * in which case the provisions of the GPL or the LGPL are applicable instead 00028 * of those above. If you wish to allow use of your version of this file only 00029 * under the terms of either the GPL or the LGPL, and not to allow others to 00030 * use your version of this file under the terms of the MPL, indicate your 00031 * decision by deleting the provisions above and replace them with the notice 00032 * and other provisions required by the GPL or the LGPL. If you do not delete 00033 * the provisions above, a recipient may use your version of this file under 00034 * the terms of any one of the MPL, the GPL or the LGPL. 00035 * 00036 * ***** END LICENSE BLOCK ***** */ 00037 /* $Id: montmulf.h,v 1.4 2004/04/27 23:04:36 gerv%gerv.net Exp $ */ 00038 00039 /* The functions that are to be called from outside of the .s file have the 00040 * following interfaces and array size requirements: 00041 */ 00042 00043 00044 void conv_i32_to_d32(double *d32, unsigned int *i32, int len); 00045 00046 /* Converts an array of int's to an array of doubles, so that each double 00047 * corresponds to an int. len is the number of items converted. 00048 * Does not allocate the output array. 00049 * The pointers d32 and i32 should point to arrays of size at least len 00050 * (doubles and unsigned ints, respectively) 00051 */ 00052 00053 00054 void conv_i32_to_d16(double *d16, unsigned int *i32, int len); 00055 00056 /* Converts an array of int's to an array of doubles so that each element 00057 * of the int array is converted to a pair of doubles, the first one 00058 * corresponding to the lower (least significant) 16 bits of the int and 00059 * the second one corresponding to the upper (most significant) 16 bits of 00060 * the 32bit int. len is the number of ints converted. 00061 * Does not allocate the output array. 00062 * The pointer d16 should point to an array of doubles of size at least 00063 * 2*len and i32 should point an array of ints of size at least len 00064 */ 00065 00066 00067 void conv_i32_to_d32_and_d16(double *d32, double *d16, 00068 unsigned int *i32, int len); 00069 00070 /* Does the above two conversions together, it is much faster than doing 00071 * both of those in succession 00072 */ 00073 00074 00075 void mont_mulf_noconv(unsigned int *result, 00076 double *dm1, double *dm2, double *dt, 00077 double *dn, unsigned int *nint, 00078 int nlen, double dn0); 00079 00080 /* Does the Montgomery multiplication of the numbers stored in the arrays 00081 * pointed to by dm1 and dm2, writing the result to the array pointed to by 00082 * result. It uses the array pointed to by dt as a temporary work area. 00083 * nint should point to the modulus in the arrayofintegers representation, 00084 * dn should point to its arrayofdoubles as obtained as a result of the 00085 * function call conv_i32_to_d32(dn, nint, nlen); 00086 * nlen is the length of the array containing the modulus. 00087 * The representation used for dm1 is the one that is a result of the function 00088 * call conv_i32_to_d32(dm1, m1, nlen), the representation for dm2 is the 00089 * result of the function call conv_i32_to_d16(dm2, m2, nlen). 00090 * Note that m1 and m2 should both be of length nlen, so they should be 00091 * padded with 0's if necessary before the conversion. The result comes in 00092 * this form (int representation, padded with 0's). 00093 * dn0 is the value of the 16 least significant bits of n0'. 00094 * The function does not allocate memory for any of the arrays, so the 00095 * pointers should point to arrays with the following minimal sizes: 00096 * result  nlen+1 00097 * dm1  nlen 00098 * dm2  2*nlen+1 ( the +1 is necessary for technical reasons ) 00099 * dt  4*nlen+2 00100 * dn  nlen 00101 * nint  nlen 00102 * No two arrays should point to overlapping areas of memory. 00103 */