home *** CD-ROM | disk | FTP | other *** search
/ Il CD di internet / CD.iso / SOURCE / D / LIBC / LIBC-4.6 / LIBC-4 / libc-linux / sysdeps / linux / i386 / math / log1pl.c < prev    next >
Encoding:
C/C++ Source or Header  |  1994-11-26  |  1.3 KB  |  56 lines

  1. /* Copyright (C) 1993  Hongjiu Lu
  2. This file is part of the Linux C Library.
  3.  
  4. The Linux C Library is free software; you can redistribute it and/or
  5. modify it under the terms of the GNU Library General Public License as
  6. published by the Free Software Foundation; either version 2 of the
  7. License, or (at your option) any later version.
  8.  
  9. The Linux C Library is distributed in the hope that it will be useful,
  10. but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  12. Library General Public License for more details.  */
  13.  
  14. #include <ansidecl.h>
  15. #include "mathl.h"
  16. #include <errno.h>
  17. #include <fp.h>
  18.  
  19. static inline long double
  20. domain ( long double x)
  21. {
  22.     /* perror("log1pl"); */
  23.     if (x < -1.0)
  24.       return __infnanl( EDOM);
  25.     else /* i.e. x == -1.0 */
  26.       return __infnanl(-ERANGE);
  27. }
  28.  
  29. long double
  30. DEFUN(log1pl, (x), long double x)
  31. {
  32.   if (x <= -1.0L) return domain (x);
  33.  
  34. #ifndef CYRIX_83D87
  35.   /* lousy 387 can only handle abs(x) < 1-sqrt(2)/2 in fly2xp1. */
  36.   if (fabsl (x) < 0.2929)
  37.   {
  38. #endif
  39.       __asm__ __volatile__ ("fldln2\n\t"
  40.             "fxch %%st(1)\n\t"
  41.             "fyl2xp1"
  42.             :"=t" (x) : "0" (x));
  43. #ifndef CYRIX_83D87
  44.   }
  45.   else
  46.   {
  47.       x += 1.0L;
  48.       __asm__ __volatile__ ("fldln2\n\t"
  49.             "fxch %%st(1)\n\t"
  50.             "fyl2x"
  51.             :"=t" (x) : "0" (x));
  52.   }
  53. #endif
  54.   return x;
  55. }
  56.