- Timestamp:
- Mar 22, 2006, 2:15:08 PM (15 years ago)
- Location:
- libcaca/trunk/cucul
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
libcaca/trunk/cucul/cucul.h
r653 r658 177 177 int cucul_rand(int, int); 178 178 unsigned int cucul_sqrt(unsigned int); 179 float cucul_powf(float x, float y);180 179 /* @} */ 181 180 -
libcaca/trunk/cucul/math.c
r656 r658 26 26 #include "cucul.h" 27 27 #include "cucul_internals.h" 28 29 static float powf_internal(float x, float y); 28 30 29 31 /** … … 71 73 } 72 74 73 /**74 * \brief powf substitute (x^y)75 * \param x The value to be raised76 * \param y The power to raise x to (only works with integers)77 * \return \p x raised to the power of \p y78 */79 float cucul_powf(float x, float y)80 {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 86 asm volatile("fldln2; fxch; fyl2x"87 : "=t" (logx) : "0" (x) : "st(1)");88 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 #else103 return x; /* HAHAHA VIEUX PORC */104 #endif105 }
Note: See TracChangeset
for help on using the changeset viewer.