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 / logl.c < prev    next >
Encoding:
C/C++ Source or Header  |  1994-11-26  |  1.0 KB  |  40 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("logl"); */
  23.     if (x < 0.)
  24.       return __infnanl( EDOM);
  25.     else /* i.e. x== 0. */
  26.       return __infnanl(-ERANGE);
  27. }
  28.  
  29. long double
  30. DEFUN(logl, (x), long double x)
  31. {
  32.   if (x <= 0.0L) return domain (x);
  33.  
  34.   __asm__ __volatile__ ("fldln2\n\t"
  35.             "fxch %%st(1)\n\t"
  36.             "fyl2x"
  37.             :"=t" (x) : "0" (x));
  38.   return x;
  39. }
  40.