Subversion Repositories Kolibri OS

Rev

Go to most recent revision | Blame | Last modification | View Log | Download | RSS feed

  1. /*
  2.  * Written by J.T. Conklin <jtc@netbsd.org>.
  3.  * Public domain.
  4.  */
  5.  
  6. #include <math.h>
  7.  
  8. float
  9. acosf (float x)
  10. {
  11.   float res;
  12.  
  13.   /* acosl = atanl (sqrtl(1 - x^2) / x) */
  14.   asm ( "fld    %%st\n\t"
  15.         "fmul   %%st(0)\n\t"            /* x^2 */
  16.         "fld1\n\t"
  17.         "fsubp\n\t"                     /* 1 - x^2 */
  18.         "fsqrt\n\t"                     /* sqrtl (1 - x^2) */
  19.         "fxch   %%st(1)\n\t"
  20.         "fpatan"
  21.         : "=t" (res) : "0" (x) : "st(1)");
  22.   return res;
  23. }
  24.  
  25. double
  26. acos (double x)
  27. {
  28.   double res;
  29.  
  30.   /* acosl = atanl (sqrtl(1 - x^2) / x) */
  31.   asm ( "fld    %%st\n\t"
  32.         "fmul   %%st(0)\n\t"            /* x^2 */
  33.         "fld1\n\t"
  34.         "fsubp\n\t"                     /* 1 - x^2 */
  35.         "fsqrt\n\t"                     /* sqrtl (1 - x^2) */
  36.         "fxch   %%st(1)\n\t"
  37.         "fpatan"
  38.         : "=t" (res) : "0" (x) : "st(1)");
  39.   return res;
  40. }
  41.