 Timestamp:
 Mar 21, 2006, 12:05:56 PM (15 years ago)
 File:

 1 edited
Legend:
 Unmodified
 Added
 Removed

libcaca/trunk/cucul/math.c
r568 r656 71 71 } 72 72 73 74 73 /** 75 74 * \brief powf substitute (x^y) 76 75 * \param x The value to be raised 77 * \param y The power to raise x of.76 * \param y The power to raise x to (only works with integers) 78 77 * \return \p x raised to the power of \p y 79 78 */ 80 81 79 float cucul_powf(float x, float y) 82 80 { 83 int i=((int)y); 84 float r=x; 81 #ifdef __i386__ 82 /* FIXME: this can be optimised by directly calling fyl2x for x and y */ 83 register double logx; 84 register long double v, e; 85 85 86 if(((int)y)==1  ((int)x)==1)87 return x;86 asm volatile("fldln2; fxch; fyl2x" 87 : "=t" (logx) : "0" (x) : "st(1)"); 88 88 89 i; 90 while(i) 91 { 92 r*=x; 93 } 94 return r; 89 asm volatile("fldl2e\n\t" 90 "fmul %%st(1)\n\t" 91 "fst %%st(1)\n\t" 92 "frndint\n\t" 93 "fxch\n\t" 94 "fsub %%st(1)\n\t" 95 "f2xm1\n\t" 96 : "=t" (v), "=u" (e) : "0" (y * logx)); 97 v += 1.0; 98 asm volatile("fscale" 99 : "=t" (v) : "0" (v), "u" (e)); 100 101 return v; 102 #else 103 return x; /* HAHAHA VIEUX PORC */ 104 #endif 95 105 }
Note: See TracChangeset
for help on using the changeset viewer.