From 8ceaf7c737b375d4d90afd8051d0b23aede22d96 Mon Sep 17 00:00:00 2001 From: Joakim Tjernlund Date: Sun, 4 Feb 2007 21:25:42 +0000 Subject: Add support for PowerPC e500, libc part only. Math support to be done. From Steve Papacharalambous, stevep@freescale.com --- libc/sysdeps/linux/powerpc/Makefile.arch | 33 ++++ libc/sysdeps/linux/powerpc/__longjmp.S | 84 ---------- libc/sysdeps/linux/powerpc/bits/classic/fenv.h | 145 ++++++++++++++++ .../linux/powerpc/bits/classic/fenvinline.h | 61 +++++++ libc/sysdeps/linux/powerpc/bits/classic/mathdef.h | 75 +++++++++ .../linux/powerpc/bits/classic/mathinline.h | 182 +++++++++++++++++++++ libc/sysdeps/linux/powerpc/bits/e500/fenv.h | 79 +++++++++ libc/sysdeps/linux/powerpc/bits/e500/fenvinline.h | 2 + libc/sysdeps/linux/powerpc/bits/e500/mathdef.h | 84 ++++++++++ libc/sysdeps/linux/powerpc/bits/e500/mathinline.h | 2 + libc/sysdeps/linux/powerpc/bits/fenv.h | 145 ---------------- libc/sysdeps/linux/powerpc/bits/fenvinline.h | 61 ------- libc/sysdeps/linux/powerpc/bits/mathdef.h | 75 --------- libc/sysdeps/linux/powerpc/bits/mathinline.h | 182 --------------------- libc/sysdeps/linux/powerpc/classic/__longjmp.S | 84 ++++++++++ libc/sysdeps/linux/powerpc/classic/fpu_control.h | 71 ++++++++ libc/sysdeps/linux/powerpc/classic/setjmp.S | 82 ++++++++++ libc/sysdeps/linux/powerpc/e500/__longjmp.S | 86 ++++++++++ libc/sysdeps/linux/powerpc/e500/fenv_top.h | 136 +++++++++++++++ libc/sysdeps/linux/powerpc/e500/fpu_control.h | 66 ++++++++ libc/sysdeps/linux/powerpc/e500/setjmp.S | 84 ++++++++++ libc/sysdeps/linux/powerpc/fpu_control.h | 71 -------- libc/sysdeps/linux/powerpc/setjmp.S | 82 ---------- 23 files changed, 1272 insertions(+), 700 deletions(-) delete mode 100644 libc/sysdeps/linux/powerpc/__longjmp.S create mode 100644 libc/sysdeps/linux/powerpc/bits/classic/fenv.h create mode 100644 libc/sysdeps/linux/powerpc/bits/classic/fenvinline.h create mode 100644 libc/sysdeps/linux/powerpc/bits/classic/mathdef.h create mode 100644 libc/sysdeps/linux/powerpc/bits/classic/mathinline.h create mode 100644 libc/sysdeps/linux/powerpc/bits/e500/fenv.h create mode 100644 libc/sysdeps/linux/powerpc/bits/e500/fenvinline.h create mode 100644 libc/sysdeps/linux/powerpc/bits/e500/mathdef.h create mode 100644 libc/sysdeps/linux/powerpc/bits/e500/mathinline.h delete mode 100644 libc/sysdeps/linux/powerpc/bits/fenv.h delete mode 100644 libc/sysdeps/linux/powerpc/bits/fenvinline.h delete mode 100644 libc/sysdeps/linux/powerpc/bits/mathdef.h delete mode 100644 libc/sysdeps/linux/powerpc/bits/mathinline.h create mode 100644 libc/sysdeps/linux/powerpc/classic/__longjmp.S create mode 100644 libc/sysdeps/linux/powerpc/classic/fpu_control.h create mode 100644 libc/sysdeps/linux/powerpc/classic/setjmp.S create mode 100644 libc/sysdeps/linux/powerpc/e500/__longjmp.S create mode 100644 libc/sysdeps/linux/powerpc/e500/fenv_top.h create mode 100644 libc/sysdeps/linux/powerpc/e500/fpu_control.h create mode 100644 libc/sysdeps/linux/powerpc/e500/setjmp.S delete mode 100644 libc/sysdeps/linux/powerpc/fpu_control.h delete mode 100644 libc/sysdeps/linux/powerpc/setjmp.S (limited to 'libc/sysdeps/linux/powerpc') diff --git a/libc/sysdeps/linux/powerpc/Makefile.arch b/libc/sysdeps/linux/powerpc/Makefile.arch index eaa1cb7f8..0e3799f81 100644 --- a/libc/sysdeps/linux/powerpc/Makefile.arch +++ b/libc/sysdeps/linux/powerpc/Makefile.arch @@ -11,4 +11,37 @@ SSRC := \ __longjmp.S setjmp.S bsd-setjmp.S bsd-_setjmp.S brk.S \ clone.S __uClibc_syscall.S syscall.S vfork.S +ARCH_FPU_HEADERS := fpu_control.h +ARCH_DIR := libc/sysdeps/linux/powerpc + +arch_fpu_headers: +ifeq ($(CONFIG_E500),y) + $(LN) -fs e500/fpu_control.h $(ARCH_DIR) + $(LN) -fs e500/setjmp.S $(ARCH_DIR) + $(LN) -fs e500/__longjmp.S $(ARCH_DIR) + $(LN) -fs e500/fenv.h $(ARCH_DIR)/bits + $(LN) -fs e500/fenvinline.h $(ARCH_DIR)/bits + $(LN) -fs e500/mathinline.h $(ARCH_DIR)/bits + $(LN) -fs e500/mathdef.h $(ARCH_DIR)/bits + $(LN) -fs ../$(ARCH_DIR)/e500/fenv_top.h $(top_builddir)include/fenv.h +else + $(LN) -fs classic/fpu_control.h $(ARCH_DIR) + $(LN) -fs classic/setjmp.S $(ARCH_DIR) + $(LN) -fs classic/__longjmp.S $(ARCH_DIR) + $(LN) -fs classic/fenv.h $(ARCH_DIR)/bits + $(LN) -fs classic/fenvinline.h $(ARCH_DIR)/bits + $(LN) -fs classic/mathinline.h $(ARCH_DIR)/bits + $(LN) -fs classic/mathdef.h $(ARCH_DIR)/bits +endif + +arch_fpu_headers_clean: + $(RM) $(ARCH_DIR)/fpu_control.h + $(RM) $(ARCH_DIR)/setjmp.S + $(RM) $(ARCH_DIR)/__longjmp.S + $(RM) $(ARCH_DIR)/bits/fenv.h + $(RM) $(ARCH_DIR)/bits/fenvinline.h + $(RM) $(ARCH_DIR)/bits/mathinline.h + $(RM) $(ARCH_DIR)/bits/mathdef.h + $(RM) include/fenv.h + include $(top_srcdir)libc/sysdeps/linux/Makefile.commonarch diff --git a/libc/sysdeps/linux/powerpc/__longjmp.S b/libc/sysdeps/linux/powerpc/__longjmp.S deleted file mode 100644 index 83f094c15..000000000 --- a/libc/sysdeps/linux/powerpc/__longjmp.S +++ /dev/null @@ -1,84 +0,0 @@ -/* longjmp for PowerPC. - Copyright (C) 1995, 1996, 1997, 1999, 2000 Free Software Foundation, Inc. - This file is part of the GNU C Library. - - The GNU C Library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 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 - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with the GNU C Library; if not, write to the Free - Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA - 02111-1307 USA. */ - -#include -#include "ppc_asm.h" -#define _ASM -#define _SETJMP_H -#include - - -#if defined __UCLIBC_HAS_FLOATS__ && ! defined __UCLIBC_HAS_SOFT_FLOAT__ -#define FP(x...) x -#else -#define FP(x...) -#endif - -.globl __longjmp; -.type __longjmp, @function; -.align 2; - -__longjmp: - lwz r1,(JB_GPR1*4)(r3) - lwz r2,(JB_GPR2*4)(r3) - lwz r0,(JB_LR*4)(r3) - lwz r14,((JB_GPRS+0)*4)(r3) -FP( lfd fp14,((JB_FPRS+0*2)*4)(r3)) - lwz r15,((JB_GPRS+1)*4)(r3) -FP( lfd fp15,((JB_FPRS+1*2)*4)(r3)) - lwz r16,((JB_GPRS+2)*4)(r3) -FP( lfd fp16,((JB_FPRS+2*2)*4)(r3)) - lwz r17,((JB_GPRS+3)*4)(r3) -FP( lfd fp17,((JB_FPRS+3*2)*4)(r3)) - lwz r18,((JB_GPRS+4)*4)(r3) -FP( lfd fp18,((JB_FPRS+4*2)*4)(r3)) - lwz r19,((JB_GPRS+5)*4)(r3) -FP( lfd fp19,((JB_FPRS+5*2)*4)(r3)) - lwz r20,((JB_GPRS+6)*4)(r3) -FP( lfd fp20,((JB_FPRS+6*2)*4)(r3)) - mtlr r0 - lwz r21,((JB_GPRS+7)*4)(r3) -FP( lfd fp21,((JB_FPRS+7*2)*4)(r3)) - lwz r22,((JB_GPRS+8)*4)(r3) -FP( lfd fp22,((JB_FPRS+8*2)*4)(r3)) - lwz r0,(JB_CR*4)(r3) - lwz r23,((JB_GPRS+9)*4)(r3) -FP( lfd fp23,((JB_FPRS+9*2)*4)(r3)) - lwz r24,((JB_GPRS+10)*4)(r3) -FP( lfd fp24,((JB_FPRS+10*2)*4)(r3)) - lwz r25,((JB_GPRS+11)*4)(r3) -FP( lfd fp25,((JB_FPRS+11*2)*4)(r3)) - mtcrf 0xFF,r0 - lwz r26,((JB_GPRS+12)*4)(r3) -FP( lfd fp26,((JB_FPRS+12*2)*4)(r3)) - lwz r27,((JB_GPRS+13)*4)(r3) -FP( lfd fp27,((JB_FPRS+13*2)*4)(r3)) - lwz r28,((JB_GPRS+14)*4)(r3) -FP( lfd fp28,((JB_FPRS+14*2)*4)(r3)) - lwz r29,((JB_GPRS+15)*4)(r3) -FP( lfd fp29,((JB_FPRS+15*2)*4)(r3)) - lwz r30,((JB_GPRS+16)*4)(r3) -FP( lfd fp30,((JB_FPRS+16*2)*4)(r3)) - lwz r31,((JB_GPRS+17)*4)(r3) -FP( lfd fp31,((JB_FPRS+17*2)*4)(r3)) - mr r3,r4 - blr -.size __longjmp,.-__longjmp - -libc_hidden_def(__longjmp) diff --git a/libc/sysdeps/linux/powerpc/bits/classic/fenv.h b/libc/sysdeps/linux/powerpc/bits/classic/fenv.h new file mode 100644 index 000000000..8509b4b0c --- /dev/null +++ b/libc/sysdeps/linux/powerpc/bits/classic/fenv.h @@ -0,0 +1,145 @@ +/* Copyright (C) 1997, 1998, 1999 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 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 + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, write to the Free + Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA + 02111-1307 USA. */ + +#ifndef _FENV_H +# error "Never use directly; include instead." +#endif + + +/* Define bits representing the exception. We use the bit positions of + the appropriate bits in the FPSCR... */ +enum + { + FE_INEXACT = 1 << (31 - 6), +#define FE_INEXACT FE_INEXACT + FE_DIVBYZERO = 1 << (31 - 5), +#define FE_DIVBYZERO FE_DIVBYZERO + FE_UNDERFLOW = 1 << (31 - 4), +#define FE_UNDERFLOW FE_UNDERFLOW + FE_OVERFLOW = 1 << (31 - 3), +#define FE_OVERFLOW FE_OVERFLOW + + /* ... except for FE_INVALID, for which we use bit 31. FE_INVALID + actually corresponds to bits 7 through 12 and 21 through 23 + in the FPSCR, but we can't use that because the current draft + says that it must be a power of 2. Instead we use bit 2 which + is the summary bit for all the FE_INVALID exceptions, which + kind of makes sense. */ + FE_INVALID = 1 << (31 - 2), +#define FE_INVALID FE_INVALID + +#ifdef __USE_GNU + /* Breakdown of the FE_INVALID bits. Setting FE_INVALID on an + input to a routine is equivalent to setting all of these bits; + FE_INVALID will be set on output from a routine iff one of + these bits is set. Note, though, that you can't disable or + enable these exceptions individually. */ + + /* Operation with SNaN. */ + FE_INVALID_SNAN = 1 << (31 - 7), +# define FE_INVALID_SNAN FE_INVALID_SNAN + + /* Inf - Inf */ + FE_INVALID_ISI = 1 << (31 - 8), +# define FE_INVALID_ISI FE_INVALID_ISI + + /* Inf / Inf */ + FE_INVALID_IDI = 1 << (31 - 9), +# define FE_INVALID_IDI FE_INVALID_IDI + + /* 0 / 0 */ + FE_INVALID_ZDZ = 1 << (31 - 10), +# define FE_INVALID_ZDZ FE_INVALID_ZDZ + + /* Inf * 0 */ + FE_INVALID_IMZ = 1 << (31 - 11), +# define FE_INVALID_IMZ FE_INVALID_IMZ + + /* Comparison with NaN or SNaN. */ + FE_INVALID_COMPARE = 1 << (31 - 12), +# define FE_INVALID_COMPARE FE_INVALID_COMPARE + + /* Invalid operation flag for software (not set by hardware). */ + /* Note that some chips don't have this implemented, presumably + because no-one expected anyone to write software for them %-). */ + FE_INVALID_SOFTWARE = 1 << (31 - 21), +# define FE_INVALID_SOFTWARE FE_INVALID_SOFTWARE + + /* Square root of negative number (including -Inf). */ + /* Note that some chips don't have this implemented. */ + FE_INVALID_SQRT = 1 << (31 - 22), +# define FE_INVALID_SQRT FE_INVALID_SQRT + + /* Conversion-to-integer of a NaN or a number too large or too small. */ + FE_INVALID_INTEGER_CONVERSION = 1 << (31 - 23) +# define FE_INVALID_INTEGER_CONVERSION FE_INVALID_INTEGER_CONVERSION + +# define FE_ALL_INVALID \ + (FE_INVALID_SNAN | FE_INVALID_ISI | FE_INVALID_IDI | FE_INVALID_ZDZ \ + | FE_INVALID_IMZ | FE_INVALID_COMPARE | FE_INVALID_SOFTWARE \ + | FE_INVALID_SQRT | FE_INVALID_INTEGER_CONVERSION) +#endif + }; + +#define FE_ALL_EXCEPT \ + (FE_INEXACT | FE_DIVBYZERO | FE_UNDERFLOW | FE_OVERFLOW | FE_INVALID) + +/* PowerPC chips support all of the four defined rounding modes. We + use the bit pattern in the FPSCR as the values for the + appropriate macros. */ +enum + { + FE_TONEAREST = 0, +#define FE_TONEAREST FE_TONEAREST + FE_TOWARDZERO = 1, +#define FE_TOWARDZERO FE_TOWARDZERO + FE_UPWARD = 2, +#define FE_UPWARD FE_UPWARD + FE_DOWNWARD = 3 +#define FE_DOWNWARD FE_DOWNWARD + }; + +/* Type representing exception flags. */ +typedef unsigned int fexcept_t; + +/* Type representing floating-point environment. We leave it as 'double' + for efficiency reasons (rather than writing it to a 32-bit integer). */ +typedef double fenv_t; + +/* If the default argument is used we use this value. */ +extern const fenv_t __fe_dfl_env; +#define FE_DFL_ENV (&__fe_dfl_env) + +#ifdef __USE_GNU +/* Floating-point environment where all exceptions are enabled. Note that + this is not sufficient to give you SIGFPE. */ +extern const fenv_t __fe_enabled_env; +# define FE_ENABLED_ENV (&__fe_enabled_env) + +/* Floating-point environment with (processor-dependent) non-IEEE floating + point. */ +extern const fenv_t __fe_nonieee_env; +# define FE_NONIEEE_ENV (&__fe_nonieee_env) + +/* Floating-point environment with all exceptions enabled. Note that + just evaluating this value will set the processor into 'FPU + exceptions imprecise recoverable' mode, which may cause a significant + performance penalty (but have no other visible effect). */ +extern const fenv_t *__fe_nomask_env (void); +# define FE_NOMASK_ENV (__fe_nomask_env ()) +#endif diff --git a/libc/sysdeps/linux/powerpc/bits/classic/fenvinline.h b/libc/sysdeps/linux/powerpc/bits/classic/fenvinline.h new file mode 100644 index 000000000..f7700a49e --- /dev/null +++ b/libc/sysdeps/linux/powerpc/bits/classic/fenvinline.h @@ -0,0 +1,61 @@ +/* Inline floating-point environment handling functions for powerpc. + Copyright (C) 1995, 1996, 1997, 1998, 1999, 2006 + Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 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 + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, write to the Free + Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA + 02111-1307 USA. */ + +#if defined __GNUC__ && !defined _SOFT_FLOAT && !defined __NO_MATH_INLINES + +/* Inline definition for fegetround. */ +# define fegetround() \ + (__extension__ ({ int __fegetround_result; \ + __asm__ __volatile__ \ + ("mcrfs 7,7 ; mfcr %0" \ + : "=r"(__fegetround_result) : : "cr7"); \ + __fegetround_result & 3; })) + +/* The weird 'i#*X' constraints on the following suppress a gcc + warning when __excepts is not a constant. Otherwise, they mean the + same as just plain 'i'. */ + +/* Inline definition for feraiseexcept. */ +# define feraiseexcept(__excepts) \ + ((__builtin_constant_p (__excepts) \ + && ((__excepts) & ((__excepts)-1)) == 0 \ + && (__excepts) != FE_INVALID) \ + ? ((__excepts) != 0 \ + ? (__extension__ ({ __asm__ __volatile__ \ + ("mtfsb1 %s0" \ + : : "i#*X"(__builtin_ffs (__excepts))); \ + 0; })) \ + : 0) \ + : (feraiseexcept) (__excepts)) + +/* Inline definition for feclearexcept. */ +# define feclearexcept(__excepts) \ + ((__builtin_constant_p (__excepts) \ + && ((__excepts) & ((__excepts)-1)) == 0 \ + && (__excepts) != FE_INVALID) \ + ? ((__excepts) != 0 \ + ? (__extension__ ({ __asm__ __volatile__ \ + ("mtfsb0 %s0" \ + : : "i#*X"(__builtin_ffs (__excepts))); \ + 0; })) \ + : 0) \ + : (feclearexcept) (__excepts)) + +#endif /* __GNUC__ && !_SOFT_FLOAT */ diff --git a/libc/sysdeps/linux/powerpc/bits/classic/mathdef.h b/libc/sysdeps/linux/powerpc/bits/classic/mathdef.h new file mode 100644 index 000000000..a076fb6d7 --- /dev/null +++ b/libc/sysdeps/linux/powerpc/bits/classic/mathdef.h @@ -0,0 +1,75 @@ +/* Copyright (C) 1997,1998,1999,2000,2003,2004,2006 + Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 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 + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, write to the Free + Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA + 02111-1307 USA. */ + +#if !defined _MATH_H && !defined _COMPLEX_H +# error "Never use directly; include instead" +#endif + + +/* FIXME! This file describes properties of the compiler, not the machine; + it should not be part of libc! + + FIXME! This file does not deal with the -fshort-double option of + gcc! */ + +#if defined __USE_ISOC99 && defined _MATH_H && !defined _MATH_H_MATHDEF +# define _MATH_H_MATHDEF 1 + +# ifdef __GNUC__ +# if __STDC__ == 1 + +/* In GNU or ANSI mode, gcc leaves `float' expressions as-is. */ +typedef float float_t; /* `float' expressions are evaluated as + `float'. */ +typedef double double_t; /* `double' expressions are evaluated as + `double'. */ + +# else + +/* For `gcc -traditional', `float' expressions are evaluated as `double'. */ +typedef double float_t; /* `float' expressions are evaluated as + `double'. */ +typedef double double_t; /* `double' expressions are evaluated as + `double'. */ + +# endif +# else + +/* Wild guess at types for float_t and double_t. */ +typedef double float_t; +typedef double double_t; + +# endif + +/* The values returned by `ilogb' for 0 and NaN respectively. */ +# define FP_ILOGB0 (-2147483647) +# define FP_ILOGBNAN (2147483647) + +#endif /* ISO C99 */ + +#ifndef __NO_LONG_DOUBLE_MATH +#include +/* Signal that we do not really have a `long double'. The disables the + declaration of all the `long double' function variants. */ +# if __WORDSIZE == 32 +# define __NO_LONG_DOUBLE_MATH 1 +# elif !defined __UCLIBC_HAS_LONG_DOUBLE_MATH__ +# define __NO_LONG_DOUBLE_MATH 1 +# endif +#endif diff --git a/libc/sysdeps/linux/powerpc/bits/classic/mathinline.h b/libc/sysdeps/linux/powerpc/bits/classic/mathinline.h new file mode 100644 index 000000000..87985a744 --- /dev/null +++ b/libc/sysdeps/linux/powerpc/bits/classic/mathinline.h @@ -0,0 +1,182 @@ +/* Inline math functions for powerpc. + Copyright (C) 1995, 1996, 1997, 1998, 1999, 2000, 2004, 2006 + Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 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 + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, write to the Free + Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA + 02111-1307 USA. */ + +#ifndef _MATH_H +# error "Never use directly; include instead." +#endif + +#ifdef __cplusplus +# define __MATH_INLINE __inline +#else +# define __MATH_INLINE extern __inline +#endif /* __cplusplus */ + +#if defined __GNUC__ && !defined _SOFT_FLOAT + +#ifdef __USE_ISOC99 +# if !__GNUC_PREREQ (2,97) +# define __unordered_cmp(x, y) \ + (__extension__ \ + ({ __typeof__(x) __x = (x); __typeof__(y) __y = (y); \ + unsigned __r; \ + __asm__("fcmpu 7,%1,%2 ; mfcr %0" : "=r" (__r) : "f" (__x), "f"(__y) \ + : "cr7"); \ + __r; })) + +# undef isgreater +# undef isgreaterequal +# undef isless +# undef islessequal +# undef islessgreater +# undef isunordered + +# define isgreater(x, y) (__unordered_cmp (x, y) >> 2 & 1) +# define isgreaterequal(x, y) ((__unordered_cmp (x, y) & 6) != 0) +# define isless(x, y) (__unordered_cmp (x, y) >> 3 & 1) +# define islessequal(x, y) ((__unordered_cmp (x, y) & 0xA) != 0) +# define islessgreater(x, y) ((__unordered_cmp (x, y) & 0xC) != 0) +# define isunordered(x, y) (__unordered_cmp (x, y) & 1) + +# endif /* __GNUC_PREREQ (2,97) */ + +/* The gcc, version 2.7 or below, has problems with all this inlining + code. So disable it for this version of the compiler. */ +# if __GNUC_PREREQ (2, 8) +/* Test for negative number. Used in the signbit() macro. */ +__MATH_INLINE int +__NTH (__signbitf (float __x)) +{ + __extension__ union { float __f; int __i; } __u = { __f: __x }; + return __u.__i < 0; +} +__MATH_INLINE int +__NTH (__signbit (double __x)) +{ + __extension__ union { double __d; int __i[2]; } __u = { __d: __x }; + return __u.__i[0] < 0; +} +# endif +#endif /* __USE_ISOC99 */ + +#if !defined __NO_MATH_INLINES && defined __OPTIMIZE__ + +#ifdef __USE_ISOC99 + +# ifndef __powerpc64__ +__MATH_INLINE long int lrint (double __x) __THROW; +__MATH_INLINE long int +__NTH (lrint (double __x)) +{ + union { + double __d; + int __ll[2]; + } __u; + __asm__ ("fctiw %0,%1" : "=f"(__u.__d) : "f"(__x)); + return __u.__ll[1]; +} + +__MATH_INLINE long int lrintf (float __x) __THROW; +__MATH_INLINE long int +__NTH (lrintf (float __x)) +{ + union { + double __d; + int __ll[2]; + } __u; + __asm__ ("fctiw %0,%1" : "=f"(__u.__d) : "f"(__x)); + return __u.__ll[1]; +} +# endif + +__MATH_INLINE double fdim (double __x, double __y) __THROW; +__MATH_INLINE double +__NTH (fdim (double __x, double __y)) +{ + return __x <= __y ? 0 : __x - __y; +} + +__MATH_INLINE float fdimf (float __x, float __y) __THROW; +__MATH_INLINE float +__NTH (fdimf (float __x, float __y)) +{ + return __x <= __y ? 0 : __x - __y; +} + +#endif /* __USE_ISOC99 */ +#endif /* !__NO_MATH_INLINES && __OPTIMIZE__ */ + +/* This code is used internally in the GNU libc. */ +#if 0 /*def __LIBC_INTERNAL_MATH_INLINES*/ + +#include +#include +#include + +# if __WORDSIZE == 64 || defined _ARCH_PWR4 +# define __CPU_HAS_FSQRT 1 +# else +# define __CPU_HAS_FSQRT ((GLRO(dl_hwcap) & PPC_FEATURE_64) != 0) +# endif + +extern double __slow_ieee754_sqrt (double); +__MATH_INLINE double +__NTH (__ieee754_sqrt (double __x)) +{ + double __z; + + /* If the CPU is 64-bit we can use the optional FP instructions. */ + if (__CPU_HAS_FSQRT) + { + /* Volatile is required to prevent the compiler from moving the + fsqrt instruction above the branch. */ + __asm __volatile ( + " fsqrt %0,%1\n" + : "=f" (__z) + : "f" (__x)); + } + else + __z = __slow_ieee754_sqrt(__x); + + return __z; +} + +extern float __slow_ieee754_sqrtf (float); +__MATH_INLINE float +__NTH (__ieee754_sqrtf (float __x)) +{ + float __z; + + /* If the CPU is 64-bit we can use the optional FP instructions. */ + if (__CPU_HAS_FSQRT) + { + /* Volatile is required to prevent the compiler from moving the + fsqrts instruction above the branch. */ + __asm __volatile ( + " fsqrts %0,%1\n" + : "=f" (__z) + : "f" (__x)); + } + else + __z = __slow_ieee754_sqrtf(__x); + + return __z; +} +#endif /* __LIBC_INTERNAL_MATH_INLINES */ +#endif /* __GNUC__ && !_SOFT_FLOAT */ diff --git a/libc/sysdeps/linux/powerpc/bits/e500/fenv.h b/libc/sysdeps/linux/powerpc/bits/e500/fenv.h new file mode 100644 index 000000000..41963da38 --- /dev/null +++ b/libc/sysdeps/linux/powerpc/bits/e500/fenv.h @@ -0,0 +1,79 @@ +/* Copyright (C) 2004 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 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 + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, write to the Free + Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA + 02111-1307 USA. */ + +#ifndef _FENV_H +# error "Never use directly; include instead." +#endif + + +/* Define bits representing the exception. We use the bit positions of + the appropriate bits in the SPEFSCR... */ +enum + { + FE_INEXACT = 1 << (63 - 42), +#define FE_INEXACT FE_INEXACT + FE_INVALID = 1 << (63 - 43), +#define FE_INVALID FE_INVALID + FE_DIVBYZERO = 1 << (63 - 44), +#define FE_DIVBYZERO FE_DIVBYZERO + FE_UNDERFLOW = 1 << (63 - 45), +#define FE_UNDERFLOW FE_UNDERFLOW + FE_OVERFLOW = 1 << (63 - 46) +#define FE_OVERFLOW FE_OVERFLOW + }; + +#define FE_ALL_EXCEPT \ + (FE_INEXACT | FE_DIVBYZERO | FE_UNDERFLOW | FE_OVERFLOW | FE_INVALID) + +/* The E500 support all of the four defined rounding modes. We use + the bit pattern in the SPEFSCR as the values for the appropriate + macros. */ +enum + { + FE_TONEAREST = 0, +#define FE_TONEAREST FE_TONEAREST + FE_TOWARDZERO = 1, +#define FE_TOWARDZERO FE_TOWARDZERO + FE_UPWARD = 2, +#define FE_UPWARD FE_UPWARD + FE_DOWNWARD = 3 +#define FE_DOWNWARD FE_DOWNWARD + }; + +/* Type representing exception flags. */ +typedef unsigned int fexcept_t; + +typedef double fenv_t; + +/* If the default argument is used we use this value. */ +extern const fenv_t __fe_dfl_env; +#define FE_DFL_ENV (&__fe_dfl_env) + +#ifdef __USE_GNU +/* Floating-point environment where all exceptions are enabled. Note that + this is not sufficient to give you SIGFPE. */ +extern const fenv_t __fe_enabled_env; +# define FE_ENABLED_ENV (&__fe_enabled_env) + +/* Floating-point environment with all exceptions enabled. Note that + just evaluating this value will set the processor into 'FPU + exceptions imprecise recoverable' mode, which may cause a significant + performance penalty (but have no other visible effect). */ +extern const fenv_t *__fe_nomask_env (void); +# define FE_NOMASK_ENV (__fe_nomask_env ()) +#endif diff --git a/libc/sysdeps/linux/powerpc/bits/e500/fenvinline.h b/libc/sysdeps/linux/powerpc/bits/e500/fenvinline.h new file mode 100644 index 000000000..8dee09d18 --- /dev/null +++ b/libc/sysdeps/linux/powerpc/bits/e500/fenvinline.h @@ -0,0 +1,2 @@ +/* We don't need no stinking inline versions. Life is hard enough as it + is with this hybrid soft/hard float business. */ diff --git a/libc/sysdeps/linux/powerpc/bits/e500/mathdef.h b/libc/sysdeps/linux/powerpc/bits/e500/mathdef.h new file mode 100644 index 000000000..4a698e96c --- /dev/null +++ b/libc/sysdeps/linux/powerpc/bits/e500/mathdef.h @@ -0,0 +1,84 @@ +/* Copyright (C) 1997,1998,1999,2000,2003 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 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 + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, write to the Free + Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA + 02111-1307 USA. */ + +#if !defined _MATH_H && !defined _COMPLEX_H +# error "Never use directly; include instead" +#endif + + +/* FIXME! This file describes properties of the compiler, not the machine; + it should not be part of libc! + + FIXME! This file does not deal with the -fshort-double option of + gcc! */ + +#if defined __USE_ISOC99 && defined _MATH_H && !defined _MATH_H_MATHDEF +# define _MATH_H_MATHDEF 1 + +# ifdef __GNUC__ +# if __STDC__ == 1 + +/* In GNU or ANSI mode, gcc leaves `float' expressions as-is. */ +typedef float float_t; /* `float' expressions are evaluated as + `float'. */ +typedef double double_t; /* `double' expressions are evaluated as + `double'. */ + +/* Define `INFINITY' as value of type `float'. */ +# ifndef __UCLIBC__ +# define INFINITY HUGE_VALF +# endif + +# else + +/* For `gcc -traditional', `float' expressions are evaluated as `double'. */ +typedef double float_t; /* `float' expressions are evaluated as + `double'. */ +typedef double double_t; /* `double' expressions are evaluated as + `double'. */ + +/* Define `INFINITY' as value of type `float'. */ +# ifndef __UCLIBC__ +# define INFINITY HUGE_VALF +# endif + +# endif +# else + +/* Wild guess at types for float_t and double_t. */ +typedef double float_t; +typedef double double_t; + +/* Define `INFINITY' as value of type `float'. */ +# ifndef __UCLIBC__ +# define INFINITY HUGE_VALF +# endif + +# endif + +/* The values returned by `ilogb' for 0 and NaN respectively. */ +# define FP_ILOGB0 (-2147483647) +# define FP_ILOGBNAN (2147483647) + +#endif /* ISO C99 */ + +#ifndef __NO_LONG_DOUBLE_MATH +/* Signal that we do not really have a `long double'. The disables the + declaration of all the `long double' function variants. */ +# define __NO_LONG_DOUBLE_MATH 1 +#endif diff --git a/libc/sysdeps/linux/powerpc/bits/e500/mathinline.h b/libc/sysdeps/linux/powerpc/bits/e500/mathinline.h new file mode 100644 index 000000000..ebd8ec4a3 --- /dev/null +++ b/libc/sysdeps/linux/powerpc/bits/e500/mathinline.h @@ -0,0 +1,2 @@ +/* Inline? You've got to be kidding me. We'll take the library functions + any day. */ diff --git a/libc/sysdeps/linux/powerpc/bits/fenv.h b/libc/sysdeps/linux/powerpc/bits/fenv.h deleted file mode 100644 index 8509b4b0c..000000000 --- a/libc/sysdeps/linux/powerpc/bits/fenv.h +++ /dev/null @@ -1,145 +0,0 @@ -/* Copyright (C) 1997, 1998, 1999 Free Software Foundation, Inc. - This file is part of the GNU C Library. - - The GNU C Library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 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 - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with the GNU C Library; if not, write to the Free - Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA - 02111-1307 USA. */ - -#ifndef _FENV_H -# error "Never use directly; include instead." -#endif - - -/* Define bits representing the exception. We use the bit positions of - the appropriate bits in the FPSCR... */ -enum - { - FE_INEXACT = 1 << (31 - 6), -#define FE_INEXACT FE_INEXACT - FE_DIVBYZERO = 1 << (31 - 5), -#define FE_DIVBYZERO FE_DIVBYZERO - FE_UNDERFLOW = 1 << (31 - 4), -#define FE_UNDERFLOW FE_UNDERFLOW - FE_OVERFLOW = 1 << (31 - 3), -#define FE_OVERFLOW FE_OVERFLOW - - /* ... except for FE_INVALID, for which we use bit 31. FE_INVALID - actually corresponds to bits 7 through 12 and 21 through 23 - in the FPSCR, but we can't use that because the current draft - says that it must be a power of 2. Instead we use bit 2 which - is the summary bit for all the FE_INVALID exceptions, which - kind of makes sense. */ - FE_INVALID = 1 << (31 - 2), -#define FE_INVALID FE_INVALID - -#ifdef __USE_GNU - /* Breakdown of the FE_INVALID bits. Setting FE_INVALID on an - input to a routine is equivalent to setting all of these bits; - FE_INVALID will be set on output from a routine iff one of - these bits is set. Note, though, that you can't disable or - enable these exceptions individually. */ - - /* Operation with SNaN. */ - FE_INVALID_SNAN = 1 << (31 - 7), -# define FE_INVALID_SNAN FE_INVALID_SNAN - - /* Inf - Inf */ - FE_INVALID_ISI = 1 << (31 - 8), -# define FE_INVALID_ISI FE_INVALID_ISI - - /* Inf / Inf */ - FE_INVALID_IDI = 1 << (31 - 9), -# define FE_INVALID_IDI FE_INVALID_IDI - - /* 0 / 0 */ - FE_INVALID_ZDZ = 1 << (31 - 10), -# define FE_INVALID_ZDZ FE_INVALID_ZDZ - - /* Inf * 0 */ - FE_INVALID_IMZ = 1 << (31 - 11), -# define FE_INVALID_IMZ FE_INVALID_IMZ - - /* Comparison with NaN or SNaN. */ - FE_INVALID_COMPARE = 1 << (31 - 12), -# define FE_INVALID_COMPARE FE_INVALID_COMPARE - - /* Invalid operation flag for software (not set by hardware). */ - /* Note that some chips don't have this implemented, presumably - because no-one expected anyone to write software for them %-). */ - FE_INVALID_SOFTWARE = 1 << (31 - 21), -# define FE_INVALID_SOFTWARE FE_INVALID_SOFTWARE - - /* Square root of negative number (including -Inf). */ - /* Note that some chips don't have this implemented. */ - FE_INVALID_SQRT = 1 << (31 - 22), -# define FE_INVALID_SQRT FE_INVALID_SQRT - - /* Conversion-to-integer of a NaN or a number too large or too small. */ - FE_INVALID_INTEGER_CONVERSION = 1 << (31 - 23) -# define FE_INVALID_INTEGER_CONVERSION FE_INVALID_INTEGER_CONVERSION - -# define FE_ALL_INVALID \ - (FE_INVALID_SNAN | FE_INVALID_ISI | FE_INVALID_IDI | FE_INVALID_ZDZ \ - | FE_INVALID_IMZ | FE_INVALID_COMPARE | FE_INVALID_SOFTWARE \ - | FE_INVALID_SQRT | FE_INVALID_INTEGER_CONVERSION) -#endif - }; - -#define FE_ALL_EXCEPT \ - (FE_INEXACT | FE_DIVBYZERO | FE_UNDERFLOW | FE_OVERFLOW | FE_INVALID) - -/* PowerPC chips support all of the four defined rounding modes. We - use the bit pattern in the FPSCR as the values for the - appropriate macros. */ -enum - { - FE_TONEAREST = 0, -#define FE_TONEAREST FE_TONEAREST - FE_TOWARDZERO = 1, -#define FE_TOWARDZERO FE_TOWARDZERO - FE_UPWARD = 2, -#define FE_UPWARD FE_UPWARD - FE_DOWNWARD = 3 -#define FE_DOWNWARD FE_DOWNWARD - }; - -/* Type representing exception flags. */ -typedef unsigned int fexcept_t; - -/* Type representing floating-point environment. We leave it as 'double' - for efficiency reasons (rather than writing it to a 32-bit integer). */ -typedef double fenv_t; - -/* If the default argument is used we use this value. */ -extern const fenv_t __fe_dfl_env; -#define FE_DFL_ENV (&__fe_dfl_env) - -#ifdef __USE_GNU -/* Floating-point environment where all exceptions are enabled. Note that - this is not sufficient to give you SIGFPE. */ -extern const fenv_t __fe_enabled_env; -# define FE_ENABLED_ENV (&__fe_enabled_env) - -/* Floating-point environment with (processor-dependent) non-IEEE floating - point. */ -extern const fenv_t __fe_nonieee_env; -# define FE_NONIEEE_ENV (&__fe_nonieee_env) - -/* Floating-point environment with all exceptions enabled. Note that - just evaluating this value will set the processor into 'FPU - exceptions imprecise recoverable' mode, which may cause a significant - performance penalty (but have no other visible effect). */ -extern const fenv_t *__fe_nomask_env (void); -# define FE_NOMASK_ENV (__fe_nomask_env ()) -#endif diff --git a/libc/sysdeps/linux/powerpc/bits/fenvinline.h b/libc/sysdeps/linux/powerpc/bits/fenvinline.h deleted file mode 100644 index f7700a49e..000000000 --- a/libc/sysdeps/linux/powerpc/bits/fenvinline.h +++ /dev/null @@ -1,61 +0,0 @@ -/* Inline floating-point environment handling functions for powerpc. - Copyright (C) 1995, 1996, 1997, 1998, 1999, 2006 - Free Software Foundation, Inc. - This file is part of the GNU C Library. - - The GNU C Library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 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 - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with the GNU C Library; if not, write to the Free - Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA - 02111-1307 USA. */ - -#if defined __GNUC__ && !defined _SOFT_FLOAT && !defined __NO_MATH_INLINES - -/* Inline definition for fegetround. */ -# define fegetround() \ - (__extension__ ({ int __fegetround_result; \ - __asm__ __volatile__ \ - ("mcrfs 7,7 ; mfcr %0" \ - : "=r"(__fegetround_result) : : "cr7"); \ - __fegetround_result & 3; })) - -/* The weird 'i#*X' constraints on the following suppress a gcc - warning when __excepts is not a constant. Otherwise, they mean the - same as just plain 'i'. */ - -/* Inline definition for feraiseexcept. */ -# define feraiseexcept(__excepts) \ - ((__builtin_constant_p (__excepts) \ - && ((__excepts) & ((__excepts)-1)) == 0 \ - && (__excepts) != FE_INVALID) \ - ? ((__excepts) != 0 \ - ? (__extension__ ({ __asm__ __volatile__ \ - ("mtfsb1 %s0" \ - : : "i#*X"(__builtin_ffs (__excepts))); \ - 0; })) \ - : 0) \ - : (feraiseexcept) (__excepts)) - -/* Inline definition for feclearexcept. */ -# define feclearexcept(__excepts) \ - ((__builtin_constant_p (__excepts) \ - && ((__excepts) & ((__excepts)-1)) == 0 \ - && (__excepts) != FE_INVALID) \ - ? ((__excepts) != 0 \ - ? (__extension__ ({ __asm__ __volatile__ \ - ("mtfsb0 %s0" \ - : : "i#*X"(__builtin_ffs (__excepts))); \ - 0; })) \ - : 0) \ - : (feclearexcept) (__excepts)) - -#endif /* __GNUC__ && !_SOFT_FLOAT */ diff --git a/libc/sysdeps/linux/powerpc/bits/mathdef.h b/libc/sysdeps/linux/powerpc/bits/mathdef.h deleted file mode 100644 index a076fb6d7..000000000 --- a/libc/sysdeps/linux/powerpc/bits/mathdef.h +++ /dev/null @@ -1,75 +0,0 @@ -/* Copyright (C) 1997,1998,1999,2000,2003,2004,2006 - Free Software Foundation, Inc. - This file is part of the GNU C Library. - - The GNU C Library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 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 - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with the GNU C Library; if not, write to the Free - Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA - 02111-1307 USA. */ - -#if !defined _MATH_H && !defined _COMPLEX_H -# error "Never use directly; include instead" -#endif - - -/* FIXME! This file describes properties of the compiler, not the machine; - it should not be part of libc! - - FIXME! This file does not deal with the -fshort-double option of - gcc! */ - -#if defined __USE_ISOC99 && defined _MATH_H && !defined _MATH_H_MATHDEF -# define _MATH_H_MATHDEF 1 - -# ifdef __GNUC__ -# if __STDC__ == 1 - -/* In GNU or ANSI mode, gcc leaves `float' expressions as-is. */ -typedef float float_t; /* `float' expressions are evaluated as - `float'. */ -typedef double double_t; /* `double' expressions are evaluated as - `double'. */ - -# else - -/* For `gcc -traditional', `float' expressions are evaluated as `double'. */ -typedef double float_t; /* `float' expressions are evaluated as - `double'. */ -typedef double double_t; /* `double' expressions are evaluated as - `double'. */ - -# endif -# else - -/* Wild guess at types for float_t and double_t. */ -typedef double float_t; -typedef double double_t; - -# endif - -/* The values returned by `ilogb' for 0 and NaN respectively. */ -# define FP_ILOGB0 (-2147483647) -# define FP_ILOGBNAN (2147483647) - -#endif /* ISO C99 */ - -#ifndef __NO_LONG_DOUBLE_MATH -#include -/* Signal that we do not really have a `long double'. The disables the - declaration of all the `long double' function variants. */ -# if __WORDSIZE == 32 -# define __NO_LONG_DOUBLE_MATH 1 -# elif !defined __UCLIBC_HAS_LONG_DOUBLE_MATH__ -# define __NO_LONG_DOUBLE_MATH 1 -# endif -#endif diff --git a/libc/sysdeps/linux/powerpc/bits/mathinline.h b/libc/sysdeps/linux/powerpc/bits/mathinline.h deleted file mode 100644 index 87985a744..000000000 --- a/libc/sysdeps/linux/powerpc/bits/mathinline.h +++ /dev/null @@ -1,182 +0,0 @@ -/* Inline math functions for powerpc. - Copyright (C) 1995, 1996, 1997, 1998, 1999, 2000, 2004, 2006 - Free Software Foundation, Inc. - This file is part of the GNU C Library. - - The GNU C Library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 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 - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with the GNU C Library; if not, write to the Free - Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA - 02111-1307 USA. */ - -#ifndef _MATH_H -# error "Never use directly; include instead." -#endif - -#ifdef __cplusplus -# define __MATH_INLINE __inline -#else -# define __MATH_INLINE extern __inline -#endif /* __cplusplus */ - -#if defined __GNUC__ && !defined _SOFT_FLOAT - -#ifdef __USE_ISOC99 -# if !__GNUC_PREREQ (2,97) -# define __unordered_cmp(x, y) \ - (__extension__ \ - ({ __typeof__(x) __x = (x); __typeof__(y) __y = (y); \ - unsigned __r; \ - __asm__("fcmpu 7,%1,%2 ; mfcr %0" : "=r" (__r) : "f" (__x), "f"(__y) \ - : "cr7"); \ - __r; })) - -# undef isgreater -# undef isgreaterequal -# undef isless -# undef islessequal -# undef islessgreater -# undef isunordered - -# define isgreater(x, y) (__unordered_cmp (x, y) >> 2 & 1) -# define isgreaterequal(x, y) ((__unordered_cmp (x, y) & 6) != 0) -# define isless(x, y) (__unordered_cmp (x, y) >> 3 & 1) -# define islessequal(x, y) ((__unordered_cmp (x, y) & 0xA) != 0) -# define islessgreater(x, y) ((__unordered_cmp (x, y) & 0xC) != 0) -# define isunordered(x, y) (__unordered_cmp (x, y) & 1) - -# endif /* __GNUC_PREREQ (2,97) */ - -/* The gcc, version 2.7 or below, has problems with all this inlining - code. So disable it for this version of the compiler. */ -# if __GNUC_PREREQ (2, 8) -/* Test for negative number. Used in the signbit() macro. */ -__MATH_INLINE int -__NTH (__signbitf (float __x)) -{ - __extension__ union { float __f; int __i; } __u = { __f: __x }; - return __u.__i < 0; -} -__MATH_INLINE int -__NTH (__signbit (double __x)) -{ - __extension__ union { double __d; int __i[2]; } __u = { __d: __x }; - return __u.__i[0] < 0; -} -# endif -#endif /* __USE_ISOC99 */ - -#if !defined __NO_MATH_INLINES && defined __OPTIMIZE__ - -#ifdef __USE_ISOC99 - -# ifndef __powerpc64__ -__MATH_INLINE long int lrint (double __x) __THROW; -__MATH_INLINE long int -__NTH (lrint (double __x)) -{ - union { - double __d; - int __ll[2]; - } __u; - __asm__ ("fctiw %0,%1" : "=f"(__u.__d) : "f"(__x)); - return __u.__ll[1]; -} - -__MATH_INLINE long int lrintf (float __x) __THROW; -__MATH_INLINE long int -__NTH (lrintf (float __x)) -{ - union { - double __d; - int __ll[2]; - } __u; - __asm__ ("fctiw %0,%1" : "=f"(__u.__d) : "f"(__x)); - return __u.__ll[1]; -} -# endif - -__MATH_INLINE double fdim (double __x, double __y) __THROW; -__MATH_INLINE double -__NTH (fdim (double __x, double __y)) -{ - return __x <= __y ? 0 : __x - __y; -} - -__MATH_INLINE float fdimf (float __x, float __y) __THROW; -__MATH_INLINE float -__NTH (fdimf (float __x, float __y)) -{ - return __x <= __y ? 0 : __x - __y; -} - -#endif /* __USE_ISOC99 */ -#endif /* !__NO_MATH_INLINES && __OPTIMIZE__ */ - -/* This code is used internally in the GNU libc. */ -#if 0 /*def __LIBC_INTERNAL_MATH_INLINES*/ - -#include -#include -#include - -# if __WORDSIZE == 64 || defined _ARCH_PWR4 -# define __CPU_HAS_FSQRT 1 -# else -# define __CPU_HAS_FSQRT ((GLRO(dl_hwcap) & PPC_FEATURE_64) != 0) -# endif - -extern double __slow_ieee754_sqrt (double); -__MATH_INLINE double -__NTH (__ieee754_sqrt (double __x)) -{ - double __z; - - /* If the CPU is 64-bit we can use the optional FP instructions. */ - if (__CPU_HAS_FSQRT) - { - /* Volatile is required to prevent the compiler from moving the - fsqrt instruction above the branch. */ - __asm __volatile ( - " fsqrt %0,%1\n" - : "=f" (__z) - : "f" (__x)); - } - else - __z = __slow_ieee754_sqrt(__x); - - return __z; -} - -extern float __slow_ieee754_sqrtf (float); -__MATH_INLINE float -__NTH (__ieee754_sqrtf (float __x)) -{ - float __z; - - /* If the CPU is 64-bit we can use the optional FP instructions. */ - if (__CPU_HAS_FSQRT) - { - /* Volatile is required to prevent the compiler from moving the - fsqrts instruction above the branch. */ - __asm __volatile ( - " fsqrts %0,%1\n" - : "=f" (__z) - : "f" (__x)); - } - else - __z = __slow_ieee754_sqrtf(__x); - - return __z; -} -#endif /* __LIBC_INTERNAL_MATH_INLINES */ -#endif /* __GNUC__ && !_SOFT_FLOAT */ diff --git a/libc/sysdeps/linux/powerpc/classic/__longjmp.S b/libc/sysdeps/linux/powerpc/classic/__longjmp.S new file mode 100644 index 000000000..83f094c15 --- /dev/null +++ b/libc/sysdeps/linux/powerpc/classic/__longjmp.S @@ -0,0 +1,84 @@ +/* longjmp for PowerPC. + Copyright (C) 1995, 1996, 1997, 1999, 2000 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 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 + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, write to the Free + Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA + 02111-1307 USA. */ + +#include +#include "ppc_asm.h" +#define _ASM +#define _SETJMP_H +#include + + +#if defined __UCLIBC_HAS_FLOATS__ && ! defined __UCLIBC_HAS_SOFT_FLOAT__ +#define FP(x...) x +#else +#define FP(x...) +#endif + +.globl __longjmp; +.type __longjmp, @function; +.align 2; + +__longjmp: + lwz r1,(JB_GPR1*4)(r3) + lwz r2,(JB_GPR2*4)(r3) + lwz r0,(JB_LR*4)(r3) + lwz r14,((JB_GPRS+0)*4)(r3) +FP( lfd fp14,((JB_FPRS+0*2)*4)(r3)) + lwz r15,((JB_GPRS+1)*4)(r3) +FP( lfd fp15,((JB_FPRS+1*2)*4)(r3)) + lwz r16,((JB_GPRS+2)*4)(r3) +FP( lfd fp16,((JB_FPRS+2*2)*4)(r3)) + lwz r17,((JB_GPRS+3)*4)(r3) +FP( lfd fp17,((JB_FPRS+3*2)*4)(r3)) + lwz r18,((JB_GPRS+4)*4)(r3) +FP( lfd fp18,((JB_FPRS+4*2)*4)(r3)) + lwz r19,((JB_GPRS+5)*4)(r3) +FP( lfd fp19,((JB_FPRS+5*2)*4)(r3)) + lwz r20,((JB_GPRS+6)*4)(r3) +FP( lfd fp20,((JB_FPRS+6*2)*4)(r3)) + mtlr r0 + lwz r21,((JB_GPRS+7)*4)(r3) +FP( lfd fp21,((JB_FPRS+7*2)*4)(r3)) + lwz r22,((JB_GPRS+8)*4)(r3) +FP( lfd fp22,((JB_FPRS+8*2)*4)(r3)) + lwz r0,(JB_CR*4)(r3) + lwz r23,((JB_GPRS+9)*4)(r3) +FP( lfd fp23,((JB_FPRS+9*2)*4)(r3)) + lwz r24,((JB_GPRS+10)*4)(r3) +FP( lfd fp24,((JB_FPRS+10*2)*4)(r3)) + lwz r25,((JB_GPRS+11)*4)(r3) +FP( lfd fp25,((JB_FPRS+11*2)*4)(r3)) + mtcrf 0xFF,r0 + lwz r26,((JB_GPRS+12)*4)(r3) +FP( lfd fp26,((JB_FPRS+12*2)*4)(r3)) + lwz r27,((JB_GPRS+13)*4)(r3) +FP( lfd fp27,((JB_FPRS+13*2)*4)(r3)) + lwz r28,((JB_GPRS+14)*4)(r3) +FP( lfd fp28,((JB_FPRS+14*2)*4)(r3)) + lwz r29,((JB_GPRS+15)*4)(r3) +FP( lfd fp29,((JB_FPRS+15*2)*4)(r3)) + lwz r30,((JB_GPRS+16)*4)(r3) +FP( lfd fp30,((JB_FPRS+16*2)*4)(r3)) + lwz r31,((JB_GPRS+17)*4)(r3) +FP( lfd fp31,((JB_FPRS+17*2)*4)(r3)) + mr r3,r4 + blr +.size __longjmp,.-__longjmp + +libc_hidden_def(__longjmp) diff --git a/libc/sysdeps/linux/powerpc/classic/fpu_control.h b/libc/sysdeps/linux/powerpc/classic/fpu_control.h new file mode 100644 index 000000000..2df9ba0e7 --- /dev/null +++ b/libc/sysdeps/linux/powerpc/classic/fpu_control.h @@ -0,0 +1,71 @@ +/* FPU control word definitions. PowerPC version. + Copyright (C) 1996, 1997, 1998 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 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 + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, write to the Free + Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA + 02111-1307 USA. */ + +#ifndef _FPU_CONTROL_H +#define _FPU_CONTROL_H + +/* rounding control */ +#define _FPU_RC_NEAREST 0x00 /* RECOMMENDED */ +#define _FPU_RC_DOWN 0x03 +#define _FPU_RC_UP 0x02 +#define _FPU_RC_ZERO 0x01 + +#define _FPU_MASK_NI 0x04 /* non-ieee mode */ + +/* masking of interrupts */ +#define _FPU_MASK_ZM 0x10 /* zero divide */ +#define _FPU_MASK_OM 0x40 /* overflow */ +#define _FPU_MASK_UM 0x20 /* underflow */ +#define _FPU_MASK_XM 0x08 /* inexact */ +#define _FPU_MASK_IM 0x80 /* invalid operation */ + +#define _FPU_RESERVED 0xffffff00 /* These bits are reserved are not changed. */ + +/* The fdlibm code requires no interrupts for exceptions. */ +#define _FPU_DEFAULT 0x00000000 /* Default value. */ + +/* IEEE: same as above, but (some) exceptions; + we leave the 'inexact' exception off. + */ +#define _FPU_IEEE 0x000000f0 + +/* Type of the control word. */ +typedef unsigned int fpu_control_t __attribute__ ((__mode__ (__SI__))); + +/* Macros for accessing the hardware control word. */ +#define _FPU_GETCW(__cw) ( { \ + union { double d; fpu_control_t cw[2]; } \ + tmp __attribute__ ((__aligned__(8))); \ + __asm__ ("mffs 0; stfd%U0 0,%0" : "=m" (tmp.d) : : "fr0"); \ + (__cw)=tmp.cw[1]; \ + tmp.cw[1]; } ) +#define _FPU_SETCW(__cw) { \ + union { double d; fpu_control_t cw[2]; } \ + tmp __attribute__ ((__aligned__(8))); \ + tmp.cw[0] = 0xFFF80000; /* More-or-less arbitrary; this is a QNaN. */ \ + tmp.cw[1] = __cw; \ + __asm__ ("lfd%U0 0,%0; mtfsf 255,0" : : "m" (tmp.d) : "fr0"); \ +} + +#if 0 +/* Default control word set at startup. */ +extern fpu_control_t __fpu_control; +#endif + +#endif /* _FPU_CONTROL_H */ diff --git a/libc/sysdeps/linux/powerpc/classic/setjmp.S b/libc/sysdeps/linux/powerpc/classic/setjmp.S new file mode 100644 index 000000000..3bdf6cbfe --- /dev/null +++ b/libc/sysdeps/linux/powerpc/classic/setjmp.S @@ -0,0 +1,82 @@ +/* setjmp for PowerPC. + Copyright (C) 1995, 1996, 1997, 1999, 2000 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 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 + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, write to the Free + Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA + 02111-1307 USA. */ + +#include +#include "ppc_asm.h" +#define _ASM +#define _SETJMP_H +#include + +#if defined __UCLIBC_HAS_FLOATS__ && ! defined __UCLIBC_HAS_SOFT_FLOAT__ +#define FP(x...) x +#else +#define FP(x...) +#endif + +.globl __sigsetjmp; +.type __sigsetjmp, @function; +.align 2; + +__sigsetjmp: + stw r1,(JB_GPR1*4)(3) + mflr r0 + stw r2,(JB_GPR2*4)(3) + stw r14,((JB_GPRS+0)*4)(3) +FP( stfd fp14,((JB_FPRS+0*2)*4)(3)) + stw r0,(JB_LR*4)(3) + stw r15,((JB_GPRS+1)*4)(3) +FP( stfd fp15,((JB_FPRS+1*2)*4)(3)) + mfcr r0 + stw r16,((JB_GPRS+2)*4)(3) +FP( stfd fp16,((JB_FPRS+2*2)*4)(3)) + stw r0,(JB_CR*4)(3) + stw r17,((JB_GPRS+3)*4)(3) +FP( stfd fp17,((JB_FPRS+3*2)*4)(3)) + stw r18,((JB_GPRS+4)*4)(3) +FP( stfd fp18,((JB_FPRS+4*2)*4)(3)) + stw r19,((JB_GPRS+5)*4)(3) +FP( stfd fp19,((JB_FPRS+5*2)*4)(3)) + stw r20,((JB_GPRS+6)*4)(3) +FP( stfd fp20,((JB_FPRS+6*2)*4)(3)) + stw r21,((JB_GPRS+7)*4)(3) +FP( stfd fp21,((JB_FPRS+7*2)*4)(3)) + stw r22,((JB_GPRS+8)*4)(3) +FP( stfd fp22,((JB_FPRS+8*2)*4)(3)) + stw r23,((JB_GPRS+9)*4)(3) +FP( stfd fp23,((JB_FPRS+9*2)*4)(3)) + stw r24,((JB_GPRS+10)*4)(3) +FP( stfd fp24,((JB_FPRS+10*2)*4)(3)) + stw r25,((JB_GPRS+11)*4)(3) +FP( stfd fp25,((JB_FPRS+11*2)*4)(3)) + stw r26,((JB_GPRS+12)*4)(3) +FP( stfd fp26,((JB_FPRS+12*2)*4)(3)) + stw r27,((JB_GPRS+13)*4)(3) +FP( stfd fp27,((JB_FPRS+13*2)*4)(3)) + stw r28,((JB_GPRS+14)*4)(3) +FP( stfd fp28,((JB_FPRS+14*2)*4)(3)) + stw r29,((JB_GPRS+15)*4)(3) +FP( stfd fp29,((JB_FPRS+15*2)*4)(3)) + stw r30,((JB_GPRS+16)*4)(3) +FP( stfd fp30,((JB_FPRS+16*2)*4)(3)) + stw r31,((JB_GPRS+17)*4)(3) +FP( stfd fp31,((JB_FPRS+17*2)*4)(3)) + + b __sigjmp_save@local + +.size __sigsetjmp,.-__sigsetjmp diff --git a/libc/sysdeps/linux/powerpc/e500/__longjmp.S b/libc/sysdeps/linux/powerpc/e500/__longjmp.S new file mode 100644 index 000000000..8161f869d --- /dev/null +++ b/libc/sysdeps/linux/powerpc/e500/__longjmp.S @@ -0,0 +1,86 @@ +/* longjmp for PowerPC e500 + Copyright (C) 1995, 1996, 1997, 1999, 2000, 2004 + Free Software Foundation, Inc. + Contributed by Aldy Hernandez . + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 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 + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, write to the Free + Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA + 02111-1307 USA. */ + +#include +#include "ppc_asm.h" +#define _ASM +#define _SETJMP_H +#include + + +#if defined __UCLIBC_HAS_FLOATS__ && ! defined __UCLIBC_HAS_SOFT_FLOAT__ +#define FP(x...) x +#else +#define FP(x...) +#endif + +.globl __longjmp; +.type __longjmp, @function; +.align 2; + +__longjmp: + lwz r1,(JB_GPR1*4)(r3) + lwz r2,(JB_GPR2*4)(r3) + lwz r0,(JB_LR*4)(r3) + lwz r14,((JB_GPRS+0)*4)(r3) +FP( evldd r14,((JB_FPRS+0*2)*4)(r3)) + lwz r15,((JB_GPRS+1)*4)(r3) +FP( evldd r15,((JB_FPRS+1*2)*4)(r3)) + lwz r16,((JB_GPRS+2)*4)(r3) +FP( evldd r16,((JB_FPRS+2*2)*4)(r3)) + lwz r17,((JB_GPRS+3)*4)(r3) +FP( evldd r17,((JB_FPRS+3*2)*4)(r3)) + lwz r18,((JB_GPRS+4)*4)(r3) +FP( evldd r18,((JB_FPRS+4*2)*4)(r3)) + lwz r19,((JB_GPRS+5)*4)(r3) +FP( evldd r19,((JB_FPRS+5*2)*4)(r3)) + lwz r20,((JB_GPRS+6)*4)(r3) +FP( evldd r20,((JB_FPRS+6*2)*4)(r3)) + mtlr r0 + lwz r21,((JB_GPRS+7)*4)(r3) +FP( evldd r21,((JB_FPRS+7*2)*4)(r3)) + lwz r22,((JB_GPRS+8)*4)(r3) +FP( evldd r22,((JB_FPRS+8*2)*4)(r3)) + lwz r0,(JB_CR*4)(r3) + lwz r23,((JB_GPRS+9)*4)(r3) +FP( evldd r23,((JB_FPRS+9*2)*4)(r3)) + lwz r24,((JB_GPRS+10)*4)(r3) +FP( evldd r24,((JB_FPRS+10*2)*4)(r3)) + lwz r25,((JB_GPRS+11)*4)(r3) +FP( evldd r25,((JB_FPRS+11*2)*4)(r3)) + mtcrf 0xFF,r0 + lwz r26,((JB_GPRS+12)*4)(r3) +FP( evldd r26,((JB_FPRS+12*2)*4)(r3)) + lwz r27,((JB_GPRS+13)*4)(r3) +FP( evldd r27,((JB_FPRS+13*2)*4)(r3)) + lwz r28,((JB_GPRS+14)*4)(r3) +FP( evldd r28,((JB_FPRS+14*2)*4)(r3)) + lwz r29,((JB_GPRS+15)*4)(r3) +FP( evldd r29,((JB_FPRS+15*2)*4)(r3)) + lwz r30,((JB_GPRS+16)*4)(r3) +FP( evldd r30,((JB_FPRS+16*2)*4)(r3)) + lwz r31,((JB_GPRS+17)*4)(r3) +FP( evldd r31,((JB_FPRS+17*2)*4)(r3)) + mr r3,r4 + blr +.size __longjmp,.-__longjmp + +libc_hidden_def(__longjmp) diff --git a/libc/sysdeps/linux/powerpc/e500/fenv_top.h b/libc/sysdeps/linux/powerpc/e500/fenv_top.h new file mode 100644 index 000000000..8a06f024e --- /dev/null +++ b/libc/sysdeps/linux/powerpc/e500/fenv_top.h @@ -0,0 +1,136 @@ +/* Copyright (C) 1997, 1999, 2000 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 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 + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, write to the Free + Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA + 02111-1307 USA. */ + +/* + * ISO C99 7.6: Floating-point environment + */ + +#ifndef _FENV_H +#define _FENV_H 1 + +#include + +/* Get the architecture dependend definitions. The following definitions + are expected to be done: + + fenv_t type for object representing an entire floating-point + environment + + FE_DFL_ENV macro of type pointer to fenv_t to be used as the argument + to functions taking an argument of type fenv_t; in this + case the default environment will be used + + fexcept_t type for object representing the floating-point exception + flags including status associated with the flags + + The following macros are defined iff the implementation supports this + kind of exception. + FE_INEXACT inexact result + FE_DIVBYZERO division by zero + FE_UNDERFLOW result not representable due to underflow + FE_OVERFLOW result not representable due to overflow + FE_INVALID invalid operation + + FE_ALL_EXCEPT bitwise OR of all supported exceptions + + The next macros are defined iff the appropriate rounding mode is + supported by the implementation. + FE_TONEAREST round to nearest + FE_UPWARD round toward +Inf + FE_DOWNWARD round toward -Inf + FE_TOWARDZERO round toward 0 +*/ +#include + +__BEGIN_DECLS + +/* Floating-point exception handling. */ + +/* Clear the supported exceptions represented by EXCEPTS. */ +extern int feclearexcept (int __excepts) __THROW; + +/* Store implementation-defined representation of the exception flags + indicated by EXCEPTS in the object pointed to by FLAGP. */ +extern int fegetexceptflag (fexcept_t *__flagp, int __excepts) __THROW; + +/* Raise the supported exceptions represented by EXCEPTS. */ +extern int feraiseexcept (int __excepts) __THROW; + +/* Set complete status for exceptions indicated by EXCEPTS according to + the representation in the object pointed to by FLAGP. */ +extern int fesetexceptflag (__const fexcept_t *__flagp, int __excepts) __THROW; + +/* Determine which of subset of the exceptions specified by EXCEPTS are + currently set. */ +extern int fetestexcept (int __excepts) __THROW; + + +/* Rounding control. */ + +/* Get current rounding direction. */ +extern int fegetround (void) __THROW; + +/* Establish the rounding direction represented by ROUND. */ +extern int fesetround (int __rounding_direction) __THROW; + + +/* Floating-point environment. */ + +/* Store the current floating-point environment in the object pointed + to by ENVP. */ +extern int fegetenv (fenv_t *__envp) __THROW; + +/* Save the current environment in the object pointed to by ENVP, clear + exception flags and install a non-stop mode (if available) for all + exceptions. */ +extern int feholdexcept (fenv_t *__envp) __THROW; + +/* Establish the floating-point environment represented by the object + pointed to by ENVP. */ +extern int fesetenv (__const fenv_t *__envp) __THROW; + +/* Save current exceptions in temporary storage, install environment + represented by object pointed to by ENVP and raise exceptions + according to saved exceptions. */ +extern int feupdateenv (__const fenv_t *__envp) __THROW; + + +/* Include optimization. */ +#ifdef __OPTIMIZE__ +# include +#endif + +#ifdef __USE_GNU + +/* Enable individual exceptions. Will not enable more exceptions than + EXCEPTS specifies. Returns the previous enabled exceptions if all + exceptions are successfully set, otherwise returns -1. */ +extern int feenableexcept (int __excepts) __THROW; + +/* Disable individual exceptions. Will not disable more exceptions than + EXCEPTS specifies. Returns the previous enabled exceptions if all + exceptions are successfully disabled, otherwise returns -1. */ +extern int fedisableexcept (int __excepts) __THROW; + +/* Return enabled exceptions. */ +extern int fegetexcept (void) __THROW; +#endif + +__END_DECLS + +#endif /* fenv.h */ diff --git a/libc/sysdeps/linux/powerpc/e500/fpu_control.h b/libc/sysdeps/linux/powerpc/e500/fpu_control.h new file mode 100644 index 000000000..10e8506ad --- /dev/null +++ b/libc/sysdeps/linux/powerpc/e500/fpu_control.h @@ -0,0 +1,66 @@ +/* FPU control word definitions. PowerPC e500 version. + Copyright (C) 1996, 1997, 1998, 2004 Free Software Foundation, Inc. + This file is part of the GNU C Library. + Contributed by Aldy Hernandez , 2004. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 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 + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, write to the Free + Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA + 02111-1307 USA. */ + +#ifndef _FPU_CONTROL_H +#define _FPU_CONTROL_H + +/* rounding control */ +#define _FPU_RC_NEAREST 0x00 /* RECOMMENDED */ +#define _FPU_RC_DOWN 0x03 +#define _FPU_RC_UP 0x02 +#define _FPU_RC_ZERO 0x01 + +#define _FPU_MASK_NI 0x04 /* non-ieee mode */ + +/* masking of interrupts */ +#define _FPU_MASK_ZM 0x10 /* zero divide */ +#define _FPU_MASK_OM 0x40 /* overflow */ +#define _FPU_MASK_UM 0x20 /* underflow */ +#define _FPU_MASK_XM 0x08 /* inexact */ +#define _FPU_MASK_IM 0x80 /* invalid operation */ + +#define _FPU_RESERVED 0xff3fff7f /* These bits are reserved are not changed. */ + +/* The fdlibm code requires no interrupts for exceptions. */ +#define _FPU_DEFAULT 0x00000000 /* Default value. */ + +/* IEEE: same as above, but (some) exceptions; + we leave the 'inexact' exception off. + */ +#define _FPU_IEEE 0x000003c0 + +/* Type of the control word. */ +typedef unsigned int fpu_control_t __attribute__ ((__mode__ (__SI__))); + +/* Macros for accessing the hardware control word. */ +#define _FPU_GETCW(__cw) ({ \ + unsigned int env; \ + asm volatile ("mfspefscr %0" : "=r" (env)); \ + (__cw) = env; }) +#define _FPU_SETCW(__cw) ({ \ + unsigned int env = __cw; \ + asm volatile ("mtspefscr %0" : : "r" (env)); }) + +#if 0 +/* Default control word set at startup. */ +extern fpu_control_t __fpu_control; +#endif + +#endif /* _FPU_CONTROL_H */ diff --git a/libc/sysdeps/linux/powerpc/e500/setjmp.S b/libc/sysdeps/linux/powerpc/e500/setjmp.S new file mode 100644 index 000000000..6b3bbfbd6 --- /dev/null +++ b/libc/sysdeps/linux/powerpc/e500/setjmp.S @@ -0,0 +1,84 @@ +/* setjmp for PowerPC e500. + Copyright (C) 1995, 1996, 1997, 1999, 2000, 2004 + Free Software Foundation, Inc. + Contributed by Aldy Hernandez . + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 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 + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, write to the Free + Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA + 02111-1307 USA. */ + +#include +#include "ppc_asm.h" +#define _ASM +#define _SETJMP_H +#include + +#if defined __UCLIBC_HAS_FLOATS__ && ! defined __UCLIBC_HAS_SOFT_FLOAT__ +#define FP(x...) x +#else +#define FP(x...) +#endif + +.globl __sigsetjmp; +.type __sigsetjmp, @function; +.align 2; + +__sigsetjmp: + stw r1,(JB_GPR1*4)(3) + mflr r0 + stw r2,(JB_GPR2*4)(3) + stw r14,((JB_GPRS+0)*4)(3) +FP( evstdd r14,((JB_FPRS+0*2)*4)(3)) + stw r0,(JB_LR*4)(3) + stw r15,((JB_GPRS+1)*4)(3) +FP( evstdd r15,((JB_FPRS+1*2)*4)(3)) + mfcr r0 + stw r16,((JB_GPRS+2)*4)(3) +FP( evstdd r16,((JB_FPRS+2*2)*4)(3)) + stw r0,(JB_CR*4)(3) + stw r17,((JB_GPRS+3)*4)(3) +FP( evstdd r17,((JB_FPRS+3*2)*4)(3)) + stw r18,((JB_GPRS+4)*4)(3) +FP( evstdd r18,((JB_FPRS+4*2)*4)(3)) + stw r19,((JB_GPRS+5)*4)(3) +FP( evstdd r19,((JB_FPRS+5*2)*4)(3)) + stw r20,((JB_GPRS+6)*4)(3) +FP( evstdd r20,((JB_FPRS+6*2)*4)(3)) + stw r21,((JB_GPRS+7)*4)(3) +FP( evstdd r21,((JB_FPRS+7*2)*4)(3)) + stw r22,((JB_GPRS+8)*4)(3) +FP( evstdd r22,((JB_FPRS+8*2)*4)(3)) + stw r23,((JB_GPRS+9)*4)(3) +FP( evstdd r23,((JB_FPRS+9*2)*4)(3)) + stw r24,((JB_GPRS+10)*4)(3) +FP( evstdd r24,((JB_FPRS+10*2)*4)(3)) + stw r25,((JB_GPRS+11)*4)(3) +FP( evstdd r25,((JB_FPRS+11*2)*4)(3)) + stw r26,((JB_GPRS+12)*4)(3) +FP( evstdd r26,((JB_FPRS+12*2)*4)(3)) + stw r27,((JB_GPRS+13)*4)(3) +FP( evstdd r27,((JB_FPRS+13*2)*4)(3)) + stw r28,((JB_GPRS+14)*4)(3) +FP( evstdd r28,((JB_FPRS+14*2)*4)(3)) + stw r29,((JB_GPRS+15)*4)(3) +FP( evstdd r29,((JB_FPRS+15*2)*4)(3)) + stw r30,((JB_GPRS+16)*4)(3) +FP( evstdd r30,((JB_FPRS+16*2)*4)(3)) + stw r31,((JB_GPRS+17)*4)(3) +FP( evstdd r31,((JB_FPRS+17*2)*4)(3)) + + b __sigjmp_save@local + +.size __sigsetjmp,.-__sigsetjmp diff --git a/libc/sysdeps/linux/powerpc/fpu_control.h b/libc/sysdeps/linux/powerpc/fpu_control.h deleted file mode 100644 index 2df9ba0e7..000000000 --- a/libc/sysdeps/linux/powerpc/fpu_control.h +++ /dev/null @@ -1,71 +0,0 @@ -/* FPU control word definitions. PowerPC version. - Copyright (C) 1996, 1997, 1998 Free Software Foundation, Inc. - This file is part of the GNU C Library. - - The GNU C Library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 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 - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with the GNU C Library; if not, write to the Free - Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA - 02111-1307 USA. */ - -#ifndef _FPU_CONTROL_H -#define _FPU_CONTROL_H - -/* rounding control */ -#define _FPU_RC_NEAREST 0x00 /* RECOMMENDED */ -#define _FPU_RC_DOWN 0x03 -#define _FPU_RC_UP 0x02 -#define _FPU_RC_ZERO 0x01 - -#define _FPU_MASK_NI 0x04 /* non-ieee mode */ - -/* masking of interrupts */ -#define _FPU_MASK_ZM 0x10 /* zero divide */ -#define _FPU_MASK_OM 0x40 /* overflow */ -#define _FPU_MASK_UM 0x20 /* underflow */ -#define _FPU_MASK_XM 0x08 /* inexact */ -#define _FPU_MASK_IM 0x80 /* invalid operation */ - -#define _FPU_RESERVED 0xffffff00 /* These bits are reserved are not changed. */ - -/* The fdlibm code requires no interrupts for exceptions. */ -#define _FPU_DEFAULT 0x00000000 /* Default value. */ - -/* IEEE: same as above, but (some) exceptions; - we leave the 'inexact' exception off. - */ -#define _FPU_IEEE 0x000000f0 - -/* Type of the control word. */ -typedef unsigned int fpu_control_t __attribute__ ((__mode__ (__SI__))); - -/* Macros for accessing the hardware control word. */ -#define _FPU_GETCW(__cw) ( { \ - union { double d; fpu_control_t cw[2]; } \ - tmp __attribute__ ((__aligned__(8))); \ - __asm__ ("mffs 0; stfd%U0 0,%0" : "=m" (tmp.d) : : "fr0"); \ - (__cw)=tmp.cw[1]; \ - tmp.cw[1]; } ) -#define _FPU_SETCW(__cw) { \ - union { double d; fpu_control_t cw[2]; } \ - tmp __attribute__ ((__aligned__(8))); \ - tmp.cw[0] = 0xFFF80000; /* More-or-less arbitrary; this is a QNaN. */ \ - tmp.cw[1] = __cw; \ - __asm__ ("lfd%U0 0,%0; mtfsf 255,0" : : "m" (tmp.d) : "fr0"); \ -} - -#if 0 -/* Default control word set at startup. */ -extern fpu_control_t __fpu_control; -#endif - -#endif /* _FPU_CONTROL_H */ diff --git a/libc/sysdeps/linux/powerpc/setjmp.S b/libc/sysdeps/linux/powerpc/setjmp.S deleted file mode 100644 index 3bdf6cbfe..000000000 --- a/libc/sysdeps/linux/powerpc/setjmp.S +++ /dev/null @@ -1,82 +0,0 @@ -/* setjmp for PowerPC. - Copyright (C) 1995, 1996, 1997, 1999, 2000 Free Software Foundation, Inc. - This file is part of the GNU C Library. - - The GNU C Library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 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 - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with the GNU C Library; if not, write to the Free - Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA - 02111-1307 USA. */ - -#include -#include "ppc_asm.h" -#define _ASM -#define _SETJMP_H -#include - -#if defined __UCLIBC_HAS_FLOATS__ && ! defined __UCLIBC_HAS_SOFT_FLOAT__ -#define FP(x...) x -#else -#define FP(x...) -#endif - -.globl __sigsetjmp; -.type __sigsetjmp, @function; -.align 2; - -__sigsetjmp: - stw r1,(JB_GPR1*4)(3) - mflr r0 - stw r2,(JB_GPR2*4)(3) - stw r14,((JB_GPRS+0)*4)(3) -FP( stfd fp14,((JB_FPRS+0*2)*4)(3)) - stw r0,(JB_LR*4)(3) - stw r15,((JB_GPRS+1)*4)(3) -FP( stfd fp15,((JB_FPRS+1*2)*4)(3)) - mfcr r0 - stw r16,((JB_GPRS+2)*4)(3) -FP( stfd fp16,((JB_FPRS+2*2)*4)(3)) - stw r0,(JB_CR*4)(3) - stw r17,((JB_GPRS+3)*4)(3) -FP( stfd fp17,((JB_FPRS+3*2)*4)(3)) - stw r18,((JB_GPRS+4)*4)(3) -FP( stfd fp18,((JB_FPRS+4*2)*4)(3)) - stw r19,((JB_GPRS+5)*4)(3) -FP( stfd fp19,((JB_FPRS+5*2)*4)(3)) - stw r20,((JB_GPRS+6)*4)(3) -FP( stfd fp20,((JB_FPRS+6*2)*4)(3)) - stw r21,((JB_GPRS+7)*4)(3) -FP( stfd fp21,((JB_FPRS+7*2)*4)(3)) - stw r22,((JB_GPRS+8)*4)(3) -FP( stfd fp22,((JB_FPRS+8*2)*4)(3)) - stw r23,((JB_GPRS+9)*4)(3) -FP( stfd fp23,((JB_FPRS+9*2)*4)(3)) - stw r24,((JB_GPRS+10)*4)(3) -FP( stfd fp24,((JB_FPRS+10*2)*4)(3)) - stw r25,((JB_GPRS+11)*4)(3) -FP( stfd fp25,((JB_FPRS+11*2)*4)(3)) - stw r26,((JB_GPRS+12)*4)(3) -FP( stfd fp26,((JB_FPRS+12*2)*4)(3)) - stw r27,((JB_GPRS+13)*4)(3) -FP( stfd fp27,((JB_FPRS+13*2)*4)(3)) - stw r28,((JB_GPRS+14)*4)(3) -FP( stfd fp28,((JB_FPRS+14*2)*4)(3)) - stw r29,((JB_GPRS+15)*4)(3) -FP( stfd fp29,((JB_FPRS+15*2)*4)(3)) - stw r30,((JB_GPRS+16)*4)(3) -FP( stfd fp30,((JB_FPRS+16*2)*4)(3)) - stw r31,((JB_GPRS+17)*4)(3) -FP( stfd fp31,((JB_FPRS+17*2)*4)(3)) - - b __sigjmp_save@local - -.size __sigsetjmp,.-__sigsetjmp -- cgit v1.2.3