]> git.ipfire.org Git - thirdparty/glibc.git/commitdiff
Define it here. Handle zero, NaN and infinity specially.
authorUlrich Drepper <drepper@redhat.com>
Thu, 26 Jun 1997 22:19:45 +0000 (22:19 +0000)
committerUlrich Drepper <drepper@redhat.com>
Thu, 26 Jun 1997 22:19:45 +0000 (22:19 +0000)
sysdeps/m68k/fpu/s_ilogb.c

index a081a884d4bc097fb5752bf0be021a924866e293..2d8f7d5082a9a9bfa469bc46634ad95b67867ae1 100644 (file)
 #define __LIBC_M81_MATH_INLINES
 #include <math.h>
 
-#ifndef FUNC
-#define FUNC ilogb
+#ifndef SUFF
+#define SUFF
 #endif
 #ifndef float_type
 #define float_type double
 #endif
 
-#define __CONCATX(a,b) __CONCAT(a,b)
+#define CONCATX(a,b) __CONCAT(a,b)
+#define s(name) CONCATX(name,SUFF)
+#define m81(func) __m81_u(s(func))
 
 int
-__CONCATX(__,FUNC) (x)
-     float_type x;
+s(__ilogb) (float_type x)
 {
-  return __m81_u(__CONCATX(__,FUNC))(x);
+  float_type result;
+  unsigned long x_cond;
+
+  x_cond = __m81_test (x);
+  /* We must return consistent values for zero and NaN.  */
+  if (x_cond & __M81_COND_ZERO)
+    return FP_ILOGB0;
+  if (x_cond & (__M81_COND_NAN | __M81_COND_INF))
+    return FP_ILOGBNAN;
+
+  __asm ("fgetexp%.x %1, %0" : "=f" (result) : "f" (x));
+  return (int) result;
 }
 
 #define weak_aliasx(a,b) weak_alias(a,b)
-weak_aliasx (__CONCATX(__,FUNC), FUNC)
+weak_aliasx (s(__ilogb), s(ilogb))