/[gcl]/gcl/o/cmac.c
ViewVC logotype

Diff of /gcl/o/cmac.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.5 by camm, Fri Jul 12 22:00:49 2002 UTC revision 1.6 by camm, Sat Jul 20 07:10:55 2002 UTC
# Line 33  object *gclModulus; Line 33  object *gclModulus;
33    
34    
35    
36  object ctimes(),cplus(),cdifference(),cmod();  object ctimes(object a, object b),cplus(object a, object b),cdifference(object a, object b),cmod(object x);
37                        
38  object make_integer();    object make_integer(__mpz_struct *u);  
39                        
40  #define our_minus(a,b) ((FIXNUMP(a)&&FIXNUMP(b))?fixnum_sub(fix(a),fix(b)): \  #define our_minus(a,b) ((FIXNUMP(a)&&FIXNUMP(b))?fixnum_sub(fix(a),fix(b)): \
41                          number_minus(a,b))                          number_minus(a,b))
# Line 45  object make_integer(); Line 45  object make_integer();
45    
46    
47  #ifdef HAVE_LONG_LONG  #ifdef HAVE_LONG_LONG
48  dblrem(a,b,mod)  long long int
49  int a,b,mod;  dblrem(int a, int b, int mod)
50  {  {
51    return  (((long long int)a*(long long int)b)%(long long int) mod);    return  (((long long int)a*(long long int)b)%(long long int) mod);
52  }  }
# Line 69  int a,b,mod; Line 69  int a,b,mod;
69  #endif  #endif
70    
71  object      object    
72  cmod(x)  cmod(object x)
 object x;  
73  {register object mod = *gclModulus;  {register object mod = *gclModulus;
74   if (mod==Cnil) return(x);   if (mod==Cnil) return(x);
75  else  else
# Line 100  else Line 99  else
99  #define MOST_POSITIVE_FIX (((unsigned int) (~0) ) /2)  #define MOST_POSITIVE_FIX (((unsigned int) (~0) ) /2)
100  #define SMALL_MODULUS_P(mod) (FIXNUMP(mod) && (fix(mod) < (MOST_POSITIVE_FIX)/2))  #define SMALL_MODULUS_P(mod) (FIXNUMP(mod) && (fix(mod) < (MOST_POSITIVE_FIX)/2))
101  object  object
102  ctimes(a,b)  ctimes(object a, object b)
 object a,b;  
103  {object mod = *gclModulus;  {object mod = *gclModulus;
104   if (FIXNUMP(mod))   if (FIXNUMP(mod))
105       {register int res, m ;       {register int res, m ;
# Line 114  return cmod(number_times(a,b));} Line 112  return cmod(number_times(a,b));}
112    
113    
114  object  object
115  cdifference(a,b)  cdifference(object a, object b)
 object a,b;  
116  {object mod = *gclModulus;  {object mod = *gclModulus;
117   if (SMALL_MODULUS_P(mod))   if (SMALL_MODULUS_P(mod))
118     {register int res,m;     {register int res,m;
# Line 127  object a,b; Line 124  object a,b;
124   else return(cmod(number_minus(a,b)));}   else return(cmod(number_minus(a,b)));}
125    
126  object  object
127  cplus(a,b)  cplus(object a, object b)
 object a,b;  
128  {object mod = *gclModulus;  {object mod = *gclModulus;
129   if (SMALL_MODULUS_P(mod))   if (SMALL_MODULUS_P(mod))
130     {register int res,m;     {register int res,m;
# Line 179  object x0,x1; Line 175  object x0,x1;
175  }  }
176    
177  object  object
178  memq(a,b)  memq(register object a, register object b)
 register object a,b;  
179  {while (1)  {while (1)
180      {if ((a==b->c.c_car)||b==Cnil) return b;      {if ((a==b->c.c_car)||b==Cnil) return b;
181      b=b->c.c_cdr;}}      b=b->c.c_cdr;}}
182    
183    
184        void    
185  init_cmac()  init_cmac(void)
186  {  {
187  /* add_symbol("ctimes",&ctimes,"cplus",&cplus,"cdifference",&cdifference,"cmod",  /* add_symbol("ctimes",&ctimes,"cplus",&cplus,"cdifference",&cdifference,"cmod",
188   &cmod, 0); */   &cmod, 0); */

Legend:
Removed from v.1.5  
changed lines
  Added in v.1.6

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26