diff options
Diffstat (limited to 'sysdeps/m68k/fpu')
-rw-r--r-- | sysdeps/m68k/fpu/bits/mathdef.h | 6 | ||||
-rw-r--r-- | sysdeps/m68k/fpu/bits/mathinline.h | 23 | ||||
-rw-r--r-- | sysdeps/m68k/fpu/e_scalb.c | 63 | ||||
-rw-r--r-- | sysdeps/m68k/fpu/e_scalbf.c | 5 | ||||
-rw-r--r-- | sysdeps/m68k/fpu/e_scalbl.c | 5 | ||||
-rw-r--r-- | sysdeps/m68k/fpu/s_scalbn.c | 2 |
6 files changed, 82 insertions, 22 deletions
diff --git a/sysdeps/m68k/fpu/bits/mathdef.h b/sysdeps/m68k/fpu/bits/mathdef.h index 4d07176405..4eaa58a3a9 100644 --- a/sysdeps/m68k/fpu/bits/mathdef.h +++ b/sysdeps/m68k/fpu/bits/mathdef.h @@ -17,7 +17,7 @@ Boston, MA 02111-1307, USA. */ #ifndef _MATH_H -#error "Never use <bits/mathdef.h> directly; include <math.h> instead" +# error "Never use <bits/mathdef.h> directly; include <math.h> instead" #endif @@ -34,3 +34,7 @@ typedef long double double_t; /* `double' expressions are evaluated as /* Define `INFINITY' as value of type `float_t'. */ #define INFINITY HUGE_VALL + +/* The values returned by `ilogb' for 0 and NaN respectively. */ +#define FP_ILOGB0 0 +#define FP_ILOGBNAN 0x7fffffff diff --git a/sysdeps/m68k/fpu/bits/mathinline.h b/sysdeps/m68k/fpu/bits/mathinline.h index bdeaa9efb0..8899b752ff 100644 --- a/sysdeps/m68k/fpu/bits/mathinline.h +++ b/sysdeps/m68k/fpu/bits/mathinline.h @@ -138,14 +138,6 @@ __m81_defun (float_type, __CONCAT(__ieee754_fmod,s), \ float_type __result; \ __asm("fmod%.x %1, %0" : "=f" (__result) : "f" (__y), "0" (__x)); \ return __result; \ -} \ - \ -__m81_defun (float_type, __CONCAT(__ieee754_scalb,s), \ - (float_type __x, float_type __n)) \ -{ \ - float_type __result; \ - __asm ("fscale%.x %1, %0" : "=f" (__result) : "f" (__n), "0" (__x)); \ - return __result; \ } __internal_inline_functions (double,) @@ -268,13 +260,16 @@ __m81_defun (int, __CONCAT(__signbit,s), (float_type __value)) \ __m81_defun (int, __CONCAT(__ilogb,s), (float_type __x)) \ { \ float_type __result; \ - if (__x == 0.0) \ - return 0x80000001; \ + if (__m81_u(__CONCAT(__isnan,s)) (__x)) \ + /* The stupid standard requires us to return a specific value where \ + it would depend on the bitpattern of the NaN. */ \ + return 0x7fffffff; \ __asm("fgetexp%.x %1, %0" : "=f" (__result) : "f" (__x)); \ return (int) __result; \ } \ \ -__m81_defun (float_type, __CONCAT(__scalbn,s), (float_type __x, int __n)) \ +__m81_defun (float_type, __CONCAT(__scalbn,s), \ + (float_type __x, long int __n)) \ { \ float_type __result; \ __asm ("fscale%.l %1, %0" : "=f" (__result) : "dmi" (__n), "0" (__x)); \ @@ -340,7 +335,7 @@ __inline_forward_c(double,ceil, (double __x), (__x)) #ifdef __USE_MISC __inline_forward_c(int,isinf, (double __value), (__value)) __inline_forward_c(int,finite, (double __value), (__value)) -__inline_forward_c(double,scalbn, (double __x, int __n), (__x, __n)) +__inline_forward_c(double,scalbn, (double __x, long int __n), (__x, __n)) #endif #if defined __USE_MISC || defined __USE_XOPEN #ifndef __USE_ISOC9X /* Conflict with macro of same name. */ @@ -365,7 +360,7 @@ __inline_forward_c(float,ceilf, (float __x), (__x)) #ifdef __USE_MISC __inline_forward_c(int,isinff, (float __value), (__value)) __inline_forward_c(int,finitef, (float __value), (__value)) -__inline_forward_c(float,scalbnf, (float __x, int __n), (__x, __n)) +__inline_forward_c(float,scalbnf, (float __x, long int __n), (__x, __n)) __inline_forward_c(int,isnanf, (float __value), (__value)) __inline_forward_c(int,ilogbf, (float __value), (__value)) #endif @@ -384,7 +379,7 @@ __inline_forward_c(long double,ceill, (long double __x), (__x)) #ifdef __USE_MISC __inline_forward_c(int,isinfl, (long double __value), (__value)) __inline_forward_c(int,finitel, (long double __value), (__value)) -__inline_forward_c(long double,scalbnl, (long double __x, int __n), +__inline_forward_c(long double,scalbnl, (long double __x, long int __n), (__x, __n)) __inline_forward_c(int,isnanl, (long double __value), (__value)) __inline_forward_c(int,ilogbl, (long double __value), (__value)) diff --git a/sysdeps/m68k/fpu/e_scalb.c b/sysdeps/m68k/fpu/e_scalb.c index 51d9beefa6..a5923ab450 100644 --- a/sysdeps/m68k/fpu/e_scalb.c +++ b/sysdeps/m68k/fpu/e_scalb.c @@ -1,2 +1,61 @@ -#define FUNC __ieee754_scalb -#include <e_fmod.c> +/* Copyright (C) 1997 Free Software Foundation, Inc. + This file is part of the GNU C Library. + Contributed by Andreas Schwab <schwab@issan.informatik.uni-dortmund.de>. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public License as + published by the Free Software Foundation; either version 2 of the + License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public + License along with the GNU C Library; see the file COPYING.LIB. If not, + write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. */ + +#define __LIBC_M81_MATH_INLINES +#include <math.h> + +#ifndef SUFF +#define SUFF +#endif +#ifndef float_type +#define float_type double +#endif + +#define CONCATX(a,b) __CONCAT(a,b) +#define s(name) CONCATX(name,SUFF) +#define m81(func) __m81_u(s(func)) + +float_type +s(__ieee754_scalb) (float_type x, float_type fn) +{ + float_type retval; + unsigned long x_cond = __m81_test (x); + unsigned long fn_cond = __m81_test (fn); + + if ((x_cond | fn_cond) & __M81_COND_NAN) + return x * fn; + + if (fn_cond & __M81_COND_INF) + { + if (!(fn_cond & __M81_COND_NEG)) + return x * fn; + else if (x_cond & __M81_COND_ZERO) + return x; + else if (x_cond & __M81_COND_INF) + return 0.0/0.0; + else + return x / -fn; + } + + if (m81(__rint) (fn) != fn) + return 0.0/0.0; + + __asm ("fscale%.x %1, %0" : "=f" (retval) : "f" (fn), "0" (x)); + return retval; +} diff --git a/sysdeps/m68k/fpu/e_scalbf.c b/sysdeps/m68k/fpu/e_scalbf.c index 1d2beae9ee..7943571246 100644 --- a/sysdeps/m68k/fpu/e_scalbf.c +++ b/sysdeps/m68k/fpu/e_scalbf.c @@ -1,2 +1,3 @@ -#define FUNC __ieee754_scalbf -#include <e_fmodf.c> +#define SUFF f +#define float_type float +#include <e_scalb.c> diff --git a/sysdeps/m68k/fpu/e_scalbl.c b/sysdeps/m68k/fpu/e_scalbl.c index 92ab7a4ad1..35fb2dc0ed 100644 --- a/sysdeps/m68k/fpu/e_scalbl.c +++ b/sysdeps/m68k/fpu/e_scalbl.c @@ -1,2 +1,3 @@ -#define FUNC __ieee754_scalbl -#include <e_fmodl.c> +#define SUFF l +#define float_type long double +#include <e_scalb.c> diff --git a/sysdeps/m68k/fpu/s_scalbn.c b/sysdeps/m68k/fpu/s_scalbn.c index 1d43a75de0..d3ba27fa46 100644 --- a/sysdeps/m68k/fpu/s_scalbn.c +++ b/sysdeps/m68k/fpu/s_scalbn.c @@ -31,7 +31,7 @@ float_type __CONCATX(__,FUNC) (x, exp) float_type x; - int exp; + long int exp; { return __m81_u(__CONCATX(__,FUNC))(x, exp); } |