=================================================================== RCS file: /home/cvs/OpenXM_contrib2/asir2000/asm/ddM.c,v retrieving revision 1.1 retrieving revision 1.7 diff -u -p -r1.1 -r1.7 --- OpenXM_contrib2/asir2000/asm/ddM.c 1999/12/03 07:39:06 1.1 +++ OpenXM_contrib2/asir2000/asm/ddM.c 2004/06/25 14:09:03 1.7 @@ -1,24 +1,62 @@ -/* $OpenXM: OpenXM/src/asir99/asm/ddM.c,v 1.1.1.1 1999/11/10 08:12:25 noro Exp $ */ +/* + * Copyright (c) 1994-2000 FUJITSU LABORATORIES LIMITED + * All rights reserved. + * + * FUJITSU LABORATORIES LIMITED ("FLL") hereby grants you a limited, + * non-exclusive and royalty-free license to use, copy, modify and + * redistribute, solely for non-commercial and non-profit purposes, the + * computer program, "Risa/Asir" ("SOFTWARE"), subject to the terms and + * conditions of this Agreement. For the avoidance of doubt, you acquire + * only a limited right to use the SOFTWARE hereunder, and FLL or any + * third party developer retains all rights, including but not limited to + * copyrights, in and to the SOFTWARE. + * + * (1) FLL does not grant you a license in any way for commercial + * purposes. You may use the SOFTWARE only for non-commercial and + * non-profit purposes only, such as academic, research and internal + * business use. + * (2) The SOFTWARE is protected by the Copyright Law of Japan and + * international copyright treaties. If you make copies of the SOFTWARE, + * with or without modification, as permitted hereunder, you shall affix + * to all such copies of the SOFTWARE the above copyright notice. + * (3) An explicit reference to this SOFTWARE and its copyright owner + * shall be made on your publication or presentation in any form of the + * results obtained by use of the SOFTWARE. + * (4) In the event that you modify the SOFTWARE, you shall notify FLL by + * e-mail at risa-admin@sec.flab.fujitsu.co.jp of the detailed specification + * for such modification or the source code of the modified part of the + * SOFTWARE. + * + * THE SOFTWARE IS PROVIDED AS IS WITHOUT ANY WARRANTY OF ANY KIND. FLL + * MAKES ABSOLUTELY NO WARRANTIES, EXPRESSED, IMPLIED OR STATUTORY, AND + * EXPRESSLY DISCLAIMS ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS + * FOR A PARTICULAR PURPOSE OR NONINFRINGEMENT OF THIRD PARTIES' + * RIGHTS. NO FLL DEALER, AGENT, EMPLOYEES IS AUTHORIZED TO MAKE ANY + * MODIFICATIONS, EXTENSIONS, OR ADDITIONS TO THIS WARRANTY. + * UNDER NO CIRCUMSTANCES AND UNDER NO LEGAL THEORY, TORT, CONTRACT, + * OR OTHERWISE, SHALL FLL BE LIABLE TO YOU OR ANY OTHER PERSON FOR ANY + * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, PUNITIVE OR CONSEQUENTIAL + * DAMAGES OF ANY CHARACTER, INCLUDING, WITHOUT LIMITATION, DAMAGES + * ARISING OUT OF OR RELATING TO THE SOFTWARE OR THIS AGREEMENT, DAMAGES + * FOR LOSS OF GOODWILL, WORK STOPPAGE, OR LOSS OF DATA, OR FOR ANY + * DAMAGES, EVEN IF FLL SHALL HAVE BEEN INFORMED OF THE POSSIBILITY OF + * SUCH DAMAGES, OR FOR ANY CLAIM BY ANY OTHER PARTY. EVEN IF A PART + * OF THE SOFTWARE HAS BEEN DEVELOPED BY A THIRD PARTY, THE THIRD PARTY + * DEVELOPER SHALL HAVE NO LIABILITY IN CONNECTION WITH THE USE, + * PERFORMANCE OR NON-PERFORMANCE OF THE SOFTWARE. + * + * $OpenXM: OpenXM_contrib2/asir2000/asm/ddM.c,v 1.6 2004/06/25 09:53:11 noro Exp $ +*/ #include "ca.h" #include "base.h" #include "inline.h" -void ksquareummain(int,UM,UM); -void kmulummain(int,UM,UM,UM); -void c_copyum(UM,int,int *); -void copyum(UM,UM); -void extractum(UM,int,int,UM); -void ksquareum(int,UM,UM); -void kmulum(int,UM,UM,UM); - /* * mod is declared as 'int', because several xxxum functions contains signed * integer addition/subtraction. So mod should be less than 2^31. */ -void mulum(mod,p1,p2,pr) -int mod; -UM p1,p2,pr; +void mulum(int mod,UM p1,UM p2,UM pr) { int *pc1,*pcr; int *c1,*c2,*cr; @@ -39,9 +77,7 @@ UM p1,p2,pr; DEG(pr) = d1 + d2; } -void mulsum(mod,p,n,pr) -int mod,n; -UM p,pr; +void mulsum(int mod,UM p,int n,UM pr) { int *sp,*dp; int i; @@ -52,9 +88,7 @@ UM p,pr; } } -int divum(mod,p1,p2,pq) -int mod; -UM p1,p2,pq; +int divum(int mod,UM p1,UM p2,UM pq) { int *pc1,*pct; int *c1,*c2,*ct; @@ -94,13 +128,13 @@ UM p1,p2,pq; return i; } -void diffum(mod,f,fd) -int mod; -UM f,fd; +void diffum(int mod,UM f,UM fd) { int *dp,*sp; int i; +#if !defined(VISUAL) UL ltmp; +#endif for ( i = DEG(f), dp = COEF(fd)+i-1, sp = COEF(f)+i; i >= 1; i--, dp--, sp-- ) { @@ -109,9 +143,7 @@ UM f,fd; degum(fd,DEG(f) - 1); } -unsigned int pwrm(mod,a,n) -int mod,a; -int n; +unsigned int pwrm(int mod,int a,int n) { unsigned int s,t; @@ -130,9 +162,7 @@ int n; } } -unsigned int invm(s,mod) -unsigned int s; -int mod; +unsigned int invm(unsigned int s,int mod) { unsigned int r,a2,q; unsigned int f1,f2,a1; @@ -154,9 +184,7 @@ int mod; return a2; } -unsigned int rem(n,m) -N n; -unsigned int m; +unsigned int rem(N n,int m) { unsigned int *x; unsigned int t,r; @@ -165,7 +193,7 @@ unsigned int m; if ( !n ) return 0; for ( i = PL(n)-1, x = BD(n)+i, r = 0; i >= 0; i--, x-- ) { -#if defined(sparc) +#if defined(sparc) && !defined(__sparcv9) r = dsar(m,r,*x); #else DSAB(m,r,*x,t,r) @@ -174,11 +202,8 @@ unsigned int m; return r; } -#ifndef sparc -void addpadic(mod,n,n1,n2) -int mod; -int n; -unsigned int *n1,*n2; +#if !defined(sparc) || defined(__sparcv9) +void addpadic(int mod,int n,unsigned int *n1,unsigned int *n2) { unsigned int carry,tmp; int i; @@ -194,11 +219,7 @@ unsigned int *n1,*n2; } #endif -void mulpadic(mod,n,n1,n2,nr) -int mod; -int n; -unsigned int *n1; -unsigned int *n2,*nr; +void mulpadic(int mod,int n,unsigned int *n1,unsigned int *n2,unsigned int *nr) { unsigned int *pn1,*pnr; unsigned int carry,mul; @@ -216,8 +237,7 @@ unsigned int *n2,*nr; extern up_kara_mag; -void kmulum(mod,n1,n2,nr) -UM n1,n2,nr; +void kmulum(int mod,UM n1,UM n2,UM nr) { UM n,t,s,m,carry; int d,d1,d2,len,i,l; @@ -245,7 +265,7 @@ UM n1,n2,nr; carry = W_UMALLOC(d2+1); t = W_UMALLOC(d1+d2+1); s = W_UMALLOC(d1+d2+1); - for ( carry = 0, i = 0, r = r0; i < d; i++, r += d2 ) { + for ( DEG(carry) = -1, i = 0, r = r0; i < d; i++, r += d2 ) { extractum(n1,i*d2,d2,m); if ( m ) { kmulum(mod,m,n2,t); @@ -264,9 +284,7 @@ UM n1,n2,nr; bcopy((char *)r0,(char *)COEF(nr),l*sizeof(int)); } -void ksquareum(mod,n1,nr) -int mod; -UM n1,nr; +void ksquareum(int mod,UM n1,UM nr) { int d1; @@ -280,10 +298,7 @@ UM n1,nr; ksquareummain(mod,n1,nr); } -void extractum(n,index,len,nr) -UM n; -int index,len; -UM nr; +void extractum(UM n,int index,int len,UM nr) { int *m; int l; @@ -304,25 +319,19 @@ UM nr; } } -void copyum(n1,n2) -UM n1,n2; +void copyum(UM n1,UM n2) { n2->d = n1->d; bcopy((char *)n1->c,(char *)n2->c,(n1->d+1)*sizeof(int)); } -void c_copyum(n,len,p) -UM n; -int len; -int *p; +void c_copyum(UM n,int len,int *p) { if ( n ) bcopy((char *)COEF(n),(char *)p,MIN((DEG(n)+1),len)*sizeof(int)); } -void kmulummain(mod,n1,n2,nr) -int mod; -UM n1,n2,nr; +void kmulummain(int mod,UM n1,UM n2,UM nr) { int d1,d2,h,len; UM n1lo,n1hi,n2lo,n2hi,hi,lo,mid1,mid2,mid,s1,s2,t1,t2; @@ -356,9 +365,7 @@ UM n1,n2,nr; copyum(t1,nr); } -void ksquareummain(mod,n1,nr) -int mod; -UM n1,nr; +void ksquareummain(int mod,UM n1,UM nr) { int d1,h,len; UM n1lo,n1hi,hi,lo,mid1,mid2,mid,s1,t1,t2;