diff options
author | Joseph Myers <joseph@codesourcery.com> | 2012-07-01 13:06:41 +0000 |
---|---|---|
committer | Joseph Myers <joseph@codesourcery.com> | 2012-07-01 13:06:41 +0000 |
commit | e64ac02c24b43659048622714afdc92fedf561fa (patch) | |
tree | 37162878b72d302de351788bec4c9360c9d55f1d /ports/sysdeps/m68k | |
parent | a20c2b3c87aebc7d4b090c622d36480263b80042 (diff) | |
download | glibc-e64ac02c24b43659048622714afdc92fedf561fa.tar glibc-e64ac02c24b43659048622714afdc92fedf561fa.tar.gz glibc-e64ac02c24b43659048622714afdc92fedf561fa.tar.bz2 glibc-e64ac02c24b43659048622714afdc92fedf561fa.zip |
Move all files into ports/ subdirectory in preparation for merge with glibcglibc-2.16-ports-before-merge
Diffstat (limited to 'ports/sysdeps/m68k')
266 files changed, 11808 insertions, 0 deletions
diff --git a/ports/sysdeps/m68k/Implies b/ports/sysdeps/m68k/Implies new file mode 100644 index 0000000000..beaba937de --- /dev/null +++ b/ports/sysdeps/m68k/Implies @@ -0,0 +1,4 @@ +wordsize-32 +# 68k uses IEEE 754 floating point. +ieee754/dbl-64 +ieee754/flt-32 diff --git a/ports/sysdeps/m68k/Makefile b/ports/sysdeps/m68k/Makefile new file mode 100644 index 0000000000..e2dd372847 --- /dev/null +++ b/ports/sysdeps/m68k/Makefile @@ -0,0 +1,34 @@ +# Copyright (C) 1993, 1994, 1996, 1997, 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, see +# <http://www.gnu.org/licenses/>. + +# The mpn functions need this. All existing 68k ports use MIT syntax. If +# a new port wants to use Motorola or Sony syntax, it can redefine this +# variable. +ifndef m68k-syntax-flag +m68k-syntax-flag = -DMIT_SYNTAX +endif + +asm-CPPFLAGS += $(m68k-syntax-flag) + +pic-ccflag = -fpic + +# Make sure setjmp.c is compiled with a frame pointer +CFLAGS-setjmp.c := -fno-omit-frame-pointer + +ifeq ($(subdir),elf) +CFLAGS-rtld.c += -Wno-uninitialized -Wno-unused +endif diff --git a/ports/sysdeps/m68k/Versions b/ports/sysdeps/m68k/Versions new file mode 100644 index 0000000000..f450291a9b --- /dev/null +++ b/ports/sysdeps/m68k/Versions @@ -0,0 +1,13 @@ +libc { + GLIBC_2.0 { + # Functions from libgcc. + __divdi3; __moddi3; __udivdi3; __umoddi3; + } +} +libm { + GLIBC_2.1 { + # A generic bug got this omitted from other configurations' version + # sets, but we always had it. + exp2l; + } +} diff --git a/ports/sysdeps/m68k/__longjmp.c b/ports/sysdeps/m68k/__longjmp.c new file mode 100644 index 0000000000..290c974bed --- /dev/null +++ b/ports/sysdeps/m68k/__longjmp.c @@ -0,0 +1,62 @@ +/* Copyright (C) 1991, 1992, 1993, 1994, 1995, 1997, 2009 + 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, see + <http://www.gnu.org/licenses/>. */ + +#include <setjmp.h> +#include <stdlib.h> + +/* Jump to the position specified by ENV, causing the + setjmp call there to return VAL, or 1 if VAL is 0. */ +void +__longjmp (__jmp_buf env, int val) +{ + /* This restores the FP and SP that setjmp's caller had, + and puts the return address into A0 and VAL into D0. */ + +#ifdef CHECK_SP + CHECK_SP (env[0].__sp); +#endif + +#if defined(__HAVE_68881__) || defined(__HAVE_FPU__) + /* Restore the floating-point registers. */ + asm volatile("fmovem%.x %0, %/fp0-%/fp7" : + /* No outputs. */ : "g" (env[0].__fpregs[0])); +#elif defined (__mcffpu__) + asm volatile("fmovem %0, %/fp0-%/fp7" : + /* No outputs. */ : "m" (env[0].__fpregs[0])); +#endif + + /* Put VAL in D0. */ + asm volatile("move%.l %0, %/d0" : /* No outputs. */ : + "g" (val == 0 ? 1 : val) : "d0"); + + asm volatile(/* Restore the data and address registers. */ + "movem%.l %0, %/d1-%/d7/%/a0-%/a7\n" + /* Return to setjmp's caller. */ +#ifdef __motorola__ + "jmp (%/a0)" +#else + "jmp %/a0@" +#endif + : /* No outputs. */ : "g" (env[0].__dregs[0]) + /* We don't bother with the clobbers, + because this code always jumps out anyway. */ + ); + + /* Avoid `volatile function does return' warnings. */ + for (;;); +} diff --git a/ports/sysdeps/m68k/abort-instr.h b/ports/sysdeps/m68k/abort-instr.h new file mode 100644 index 0000000000..b43c9efe1d --- /dev/null +++ b/ports/sysdeps/m68k/abort-instr.h @@ -0,0 +1,2 @@ +/* An instruction which should crash any program is `illegal'. */ +#define ABORT_INSTRUCTION asm ("illegal") diff --git a/ports/sysdeps/m68k/asm-syntax.h b/ports/sysdeps/m68k/asm-syntax.h new file mode 100644 index 0000000000..53f5259b0e --- /dev/null +++ b/ports/sysdeps/m68k/asm-syntax.h @@ -0,0 +1,91 @@ +/* Definitions for 68k syntax variations. + Copyright (C) 1992, 1994, 1996, 1997, 2012 Free Software Foundation, Inc. + This file is part of the GNU C Library. Its master source is NOT part of + the C library, however. The master source lives in the GNU MP 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, see + <http://www.gnu.org/licenses/>. */ + +/* ELF uses byte-counts for .align, most others use log2 of count of bytes. */ +#define ALIGNARG(log2) 1<<log2 +/* For ELF we need the `.type' directive to make shared libs work right. */ +#define PROLOG(name) .type name,@function +#define EPILOG(name) .size name,.-name +/* For ELF we need to prefix register names and local labels. */ +#define R_(r) %##r +#define R(r) R_(r) +#define L(label) .##label + +#ifdef MIT_SYNTAX +#define MEM(base)R(base)@ +#define MEM_DISP(base,displacement)R(base)@(displacement) +#define MEM_INDX(base,idx,size_suffix)R(base)@(R(idx):size_suffix) +#define MEM_INDX1(base,idx,size_suffix,scale)R(base)@(R(idx):size_suffix:scale) +#define MEM_PREDEC(memory_base)R(memory_base)@- +#define MEM_POSTINC(memory_base)R(memory_base)@+ +#define TEXT .text +#define ALIGN .even +#define GLOBL .globl +/* Use variable sized opcodes. */ +#define bcc jcc +#define bcs jcs +#define bls jls +#define beq jeq +#define bne jne +#define bra jra +#endif + +#ifdef MOTOROLA_SYNTAX +#define MEM(base)(R(base)) +#define MEM_DISP(base,displacement)(displacement,R(base)) +#define MEM_PREDEC(memory_base)-(R(memory_base)) +#define MEM_POSTINC(memory_base)(R(memory_base))+ +#define MEM_INDX_(base,idx,size_suffix)(R(base),R(idx##.##size_suffix)) +#define MEM_INDX(base,idx,size_suffix)MEM_INDX_(base,idx,size_suffix) +#define MEM_INDX1_(base,idx,size_suffix,scale)(R(base),R(idx##.##size_suffix*scale)) +#define MEM_INDX1(base,idx,size_suffix,scale)MEM_INDX1_(base,idx,size_suffix,scale) +#define TEXT .text +#define ALIGN .align ALIGNARG(2) +#define GLOBL .globl +#define bcc jbcc +#define bcs jbcs +#define bls jbls +#define beq jbeq +#define bne jbne +#define bra jbra +#define movel move.l +#define moveml movem.l +#define moveql moveq.l +#define cmpl cmp.l +#define orl or.l +#define clrl clr.l +#define andw and.w +#define eorw eor.w +#define andl and.l +#define lsrl lsr.l +#define lsll lsl.l +#define roxrl roxr.l +#define roxll roxl.l +#define addl add.l +#define addxl addx.l +#define addql addq.l +#define subl sub.l +#define subxl subx.l +#define subqw subq.w +#define subql subq.l +#define negl neg.l +#define mulul mulu.l +#define tstw tst.w +#define tstl tst.l +#endif diff --git a/ports/sysdeps/m68k/bits/byteswap.h b/ports/sysdeps/m68k/bits/byteswap.h new file mode 100644 index 0000000000..029fb32a5c --- /dev/null +++ b/ports/sysdeps/m68k/bits/byteswap.h @@ -0,0 +1,87 @@ +/* Macros to swap the order of bytes in integer values. m68k version. + Copyright (C) 1997, 2002, 2008, 2011 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, see + <http://www.gnu.org/licenses/>. */ + +#if !defined _BYTESWAP_H && !defined _NETINET_IN_H && !defined _ENDIAN_H +# error "Never use <bits/byteswap.h> directly; include <byteswap.h> instead." +#endif + +#ifndef _BITS_BYTESWAP_H +#define _BITS_BYTESWAP_H 1 + +/* Swap bytes in 16 bit value. We don't provide an assembler version + because GCC is smart enough to generate optimal assembler output, and + this allows for better cse. */ +#define __bswap_constant_16(x) \ + ((((x) >> 8) & 0xffu) | (((x) & 0xffu) << 8)) + +static __inline unsigned short int +__bswap_16 (unsigned short int __bsx) +{ + return __bswap_constant_16 (__bsx); +} + +/* Swap bytes in 32 bit value. */ +#define __bswap_constant_32(x) \ + ((((x) & 0xff000000u) >> 24) | (((x) & 0x00ff0000u) >> 8) | \ + (((x) & 0x0000ff00u) << 8) | (((x) & 0x000000ffu) << 24)) + +#if !defined(__mcoldfire__) +static __inline unsigned int +__bswap_32 (unsigned int __bsx) +{ + if (__builtin_constant_p (__bsx)) + return __bswap_constant_32 (__bsx); + __asm__ __volatile__ ("ror%.w %#8, %0;" + "swap %0;" + "ror%.w %#8, %0" + : "+d" (__bsx)); + return __bsx; +} +#else +static __inline unsigned int +__bswap_32 (unsigned int __bsx) +{ + return __bswap_constant_32 (__bsx); +} +#endif + +#if defined __GNUC__ && __GNUC__ >= 2 +/* Swap bytes in 64 bit value. */ +# define __bswap_constant_64(x) \ + __extension__ \ + ((((x) & 0xff00000000000000ull) >> 56) \ + | (((x) & 0x00ff000000000000ull) >> 40) \ + | (((x) & 0x0000ff0000000000ull) >> 24) \ + | (((x) & 0x000000ff00000000ull) >> 8) \ + | (((x) & 0x00000000ff000000ull) << 8) \ + | (((x) & 0x0000000000ff0000ull) << 24) \ + | (((x) & 0x000000000000ff00ull) << 40) \ + | (((x) & 0x00000000000000ffull) << 56)) + +/* Swap bytes in 64 bit value. */ +static __inline unsigned long long +__bswap_64 (unsigned long long __bsx) +{ + if (__builtin_constant_p (__bsx)) + return __bswap_constant_64 (__bsx); + return (__bswap_32 (__bsx >> 32) + | ((unsigned long long) __bswap_32 (__bsx) << 32)); +} +#endif + +#endif /* _BITS_BYTESWAP_H */ diff --git a/ports/sysdeps/m68k/bits/endian.h b/ports/sysdeps/m68k/bits/endian.h new file mode 100644 index 0000000000..bf4ecb60a4 --- /dev/null +++ b/ports/sysdeps/m68k/bits/endian.h @@ -0,0 +1,7 @@ +/* m68k is big-endian. */ + +#ifndef _ENDIAN_H +# error "Never use <bits/endian.h> directly; include <endian.h> instead." +#endif + +#define __BYTE_ORDER __BIG_ENDIAN diff --git a/ports/sysdeps/m68k/bits/link.h b/ports/sysdeps/m68k/bits/link.h new file mode 100644 index 0000000000..ed7da2c4c0 --- /dev/null +++ b/ports/sysdeps/m68k/bits/link.h @@ -0,0 +1,57 @@ +/* Copyright (C) 2005, 2009 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, see + <http://www.gnu.org/licenses/>. */ + +#ifndef _LINK_H +# error "Never include <bits/link.h> directly; use <link.h> instead." +#endif + + +/* Registers for entry into PLT on M68K. */ +typedef struct La_m68k_regs +{ + uint32_t lr_a0; + uint32_t lr_a1; + uint32_t lr_sp; +} La_m68k_regs; + +/* Return values for calls from PLT on M68K. */ +typedef struct La_m68k_retval +{ + uint32_t lrv_d0; + uint32_t lrv_d1; + uint32_t lrv_a0; + long double lrv_fp0; +} La_m68k_retval; + + +__BEGIN_DECLS + +extern Elf32_Addr la_m68k_gnu_pltenter (Elf32_Sym *__sym, unsigned int __ndx, + uintptr_t *__refcook, + uintptr_t *__defcook, + La_m68k_regs *__regs, + unsigned int *__flags, + const char *__symname, + long int *__framesizep); +extern unsigned int la_m68k_gnu_pltexit (Elf32_Sym *__sym, unsigned int __ndx, + uintptr_t *__refcook, + uintptr_t *__defcook, + const La_m68k_regs *__inregs, + La_m68k_retval *__outregs, + const char *__symname); + +__END_DECLS diff --git a/ports/sysdeps/m68k/bits/setjmp.h b/ports/sysdeps/m68k/bits/setjmp.h new file mode 100644 index 0000000000..bc494c0588 --- /dev/null +++ b/ports/sysdeps/m68k/bits/setjmp.h @@ -0,0 +1,46 @@ +/* Copyright (C) 1997,1998,2005,2006,2008 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, see + <http://www.gnu.org/licenses/>. */ + +/* Define the machine-dependent type `jmp_buf'. m68k version. */ +#ifndef _BITS_SETJMP_H +#define _BITS_SETJMP_H 1 + +#if !defined _SETJMP_H && !defined _PTHREAD_H +# error "Never include <bits/setjmp.h> directly; use <setjmp.h> instead." +#endif + +typedef struct __jmp_buf_internal_tag + { + /* There are eight 4-byte data registers, but D0 is not saved. */ + long int __dregs[7]; + + /* There are six 4-byte address registers, plus the FP and SP. */ + int *__aregs[6]; + int *__fp; + int *__sp; + +#if defined __HAVE_68881__ || defined __HAVE_FPU__ + /* There are eight floating point registers which + are saved in IEEE 96-bit extended format. */ + char __fpregs[8 * (96 / 8)]; +#elif defined __mcffpu__ + char __fpregs[8 * (64 / 8)]; +#endif + + } __jmp_buf[1]; + +#endif /* bits/setjmp.h */ diff --git a/ports/sysdeps/m68k/bsd-_setjmp.c b/ports/sysdeps/m68k/bsd-_setjmp.c new file mode 100644 index 0000000000..0e39dd263c --- /dev/null +++ b/ports/sysdeps/m68k/bsd-_setjmp.c @@ -0,0 +1,21 @@ +/* BSD `_setjmp' entry point to `sigsetjmp (..., 0)'. m68k version. + Copyright (C) 1994, 1997, 2001, 2002 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, see + <http://www.gnu.org/licenses/>. */ + +#define BSD__SETJMP +#include <sysdeps/m68k/setjmp.c> +libc_hidden_def (_setjmp) diff --git a/ports/sysdeps/m68k/bsd-setjmp.c b/ports/sysdeps/m68k/bsd-setjmp.c new file mode 100644 index 0000000000..ce19a052f5 --- /dev/null +++ b/ports/sysdeps/m68k/bsd-setjmp.c @@ -0,0 +1,20 @@ +/* BSD `setjmp' entry point to `sigsetjmp (..., 1)'. m68k version. + Copyright (C) 1994, 1997, 2001 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, see + <http://www.gnu.org/licenses/>. */ + +#define BSD_SETJMP +#include <sysdeps/m68k/setjmp.c> diff --git a/ports/sysdeps/m68k/coldfire/bits/atomic.h b/ports/sysdeps/m68k/coldfire/bits/atomic.h new file mode 100644 index 0000000000..39ede4a9ab --- /dev/null +++ b/ports/sysdeps/m68k/coldfire/bits/atomic.h @@ -0,0 +1,68 @@ +/* Copyright (C) 2003, 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, see + <http://www.gnu.org/licenses/>. */ + +#ifndef _BITS_ATOMIC_H +#define _BITS_ATOMIC_H 1 + +#include <stdint.h> + +/* Coldfire has no atomic compare-and-exchange operation, and the + kernel provides no userspace atomicity operations. Here we just + use generic non-atomic implementations instead. */ + +typedef int8_t atomic8_t; +typedef uint8_t uatomic8_t; +typedef int_fast8_t atomic_fast8_t; +typedef uint_fast8_t uatomic_fast8_t; + +typedef int16_t atomic16_t; +typedef uint16_t uatomic16_t; +typedef int_fast16_t atomic_fast16_t; +typedef uint_fast16_t uatomic_fast16_t; + +typedef int32_t atomic32_t; +typedef uint32_t uatomic32_t; +typedef int_fast32_t atomic_fast32_t; +typedef uint_fast32_t uatomic_fast32_t; + +typedef int64_t atomic64_t; +typedef uint64_t uatomic64_t; +typedef int_fast64_t atomic_fast64_t; +typedef uint_fast64_t uatomic_fast64_t; + +typedef intptr_t atomicptr_t; +typedef uintptr_t uatomicptr_t; +typedef intmax_t atomic_max_t; +typedef uintmax_t uatomic_max_t; + +/* The only basic operation needed is compare and exchange. */ +#define atomic_compare_and_exchange_val_acq(mem, newval, oldval) \ + ({ __typeof (mem) __gmemp = (mem); \ + __typeof (*mem) __gret = *__gmemp; \ + __typeof (*mem) __gnewval = (newval); \ + \ + if (__gret == (oldval)) \ + *__gmemp = __gnewval; \ + __gret; }) + +#define atomic_compare_and_exchange_bool_acq(mem, newval, oldval) \ + ({ __typeof (mem) __gmemp = (mem); \ + __typeof (*mem) __gnewval = (newval); \ + \ + *__gmemp == (oldval) ? (*__gmemp = __gnewval, 0) : 1; }) + +#endif diff --git a/ports/sysdeps/m68k/coldfire/fpu/e_sqrt.c b/ports/sysdeps/m68k/coldfire/fpu/e_sqrt.c new file mode 100644 index 0000000000..46934a9698 --- /dev/null +++ b/ports/sysdeps/m68k/coldfire/fpu/e_sqrt.c @@ -0,0 +1,24 @@ +/* Copyright (C) 2006, 2011 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, see + <http://www.gnu.org/licenses/>. */ + +double +__ieee754_sqrt (double x) +{ + asm ("fdsqrt.d %1,%0" : "=f" (x) : "fm" (x)); + return x; +} +strong_alias (__ieee754_sqrt, __sqrt_finite) diff --git a/ports/sysdeps/m68k/coldfire/fpu/e_sqrtf.c b/ports/sysdeps/m68k/coldfire/fpu/e_sqrtf.c new file mode 100644 index 0000000000..6801b85b0a --- /dev/null +++ b/ports/sysdeps/m68k/coldfire/fpu/e_sqrtf.c @@ -0,0 +1,25 @@ +/* Copyright (C) 2006, 2011 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, see + <http://www.gnu.org/licenses/>. */ + +float +__ieee754_sqrtf (float x) +{ + double result; + asm ("fssqrt.s %1,%0" : "=f" (result) : "dm" (x)); + return result; +} +strong_alias (__ieee754_sqrtf, __sqrtf_finite) diff --git a/ports/sysdeps/m68k/coldfire/fpu/fraiseexcpt.c b/ports/sysdeps/m68k/coldfire/fpu/fraiseexcpt.c new file mode 100644 index 0000000000..8197545d88 --- /dev/null +++ b/ports/sysdeps/m68k/coldfire/fpu/fraiseexcpt.c @@ -0,0 +1,66 @@ +/* Raise given exceptions. + Copyright (C) 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, see + <http://www.gnu.org/licenses/>. */ + +#include <fenv.h> +#include <float.h> +#include <math.h> + +int +feraiseexcept (int excepts) +{ + /* Raise exceptions represented by EXCEPTS. But we must raise only one + signal at a time. It is important that if the overflow/underflow + exception and the divide by zero exception are given at the same + time, the overflow/underflow exception follows the divide by zero + exception. + + The Coldfire FPU allows an exception to be raised by asserting + the associated EXC bit and then executing an arbitrary arithmetic + instruction. fmove.l is classified as an arithmetic instruction + and suffices for this purpose. + + We therefore raise an exception by setting both the EXC and AEXC + bit associated with the exception (the former being 6 bits to the + left of the latter) and then loading the longword at (%sp) into an + FP register. */ + + inline void + raise_one_exception (int mask) + { + if (excepts & mask) + { + int fpsr; + double unused; + + asm volatile ("fmove%.l %/fpsr,%0" : "=d" (fpsr)); + fpsr |= (mask << 6) | mask; + asm volatile ("fmove%.l %0,%/fpsr" :: "d" (fpsr)); + asm volatile ("fmove%.l (%%sp),%0" : "=f" (unused)); + } + } + + raise_one_exception (FE_INVALID); + raise_one_exception (FE_DIVBYZERO); + raise_one_exception (FE_OVERFLOW); + raise_one_exception (FE_UNDERFLOW); + raise_one_exception (FE_INEXACT); + + /* Success. */ + return 0; +} +libm_hidden_def (feraiseexcept) diff --git a/ports/sysdeps/m68k/coldfire/fpu/libm-test-ulps b/ports/sysdeps/m68k/coldfire/fpu/libm-test-ulps new file mode 100644 index 0000000000..8608c0d390 --- /dev/null +++ b/ports/sysdeps/m68k/coldfire/fpu/libm-test-ulps @@ -0,0 +1,820 @@ +# Begin of automatic generation + +# atan2 +Test "atan2 (-0.75, -1.0) == -2.49809154479650885165983415456218025": +float: 1 +ifloat: 1 +Test "atan2 (0.75, -1.0) == 2.49809154479650885165983415456218025": +float: 1 +ifloat: 1 +Test "atan2 (1.390625, 0.9296875) == 0.981498387184244311516296577615519772": +float: 1 +ifloat: 1 + +# atanh +Test "atanh (0.75) == 0.972955074527656652552676371721589865": +float: 1 +ifloat: 1 + +# cacosh +Test "Imaginary part of: cacosh (-2 - 3 i) == 1.9833870299165354323470769028940395 - 2.1414491111159960199416055713254211 i": +float: 1 +ifloat: 1 + +# casin +Test "Real part of: casin (0.75 + 1.25 i) == 0.453276177638793913448921196101971749 + 1.13239363160530819522266333696834467 i": +double: 1 +float: 1 +idouble: 1 +ifloat: 1 + +# casinh +Test "Real part of: casinh (-2 - 3 i) == -1.9686379257930962917886650952454982 - 0.96465850440760279204541105949953237 i": +double: 5 +float: 1 +idouble: 5 +ifloat: 1 +Test "Imaginary part of: casinh (-2 - 3 i) == -1.9686379257930962917886650952454982 - 0.96465850440760279204541105949953237 i": +double: 3 +float: 6 +idouble: 3 +ifloat: 6 +Test "Real part of: casinh (0.75 + 1.25 i) == 1.03171853444778027336364058631006594 + 0.911738290968487636358489564316731207 i": +float: 1 +ifloat: 1 +Test "Imaginary part of: casinh (0.75 + 1.25 i) == 1.03171853444778027336364058631006594 + 0.911738290968487636358489564316731207 i": +double: 1 +float: 1 +idouble: 1 +ifloat: 1 + +# catan +Test "Imaginary part of: catan (-2 - 3 i) == -1.4099210495965755225306193844604208 - 0.22907268296853876629588180294200276 i": +double: 1 +float: 1 +idouble: 1 +ifloat: 1 + +# catanh +Test "Real part of: catanh (-2 - 3 i) == -0.14694666622552975204743278515471595 - 1.3389725222944935611241935759091443 i": +double: 4 +idouble: 4 +Test "Real part of: catanh (0.75 + 1.25 i) == 0.261492138795671927078652057366532140 + 0.996825126463918666098902241310446708 i": +double: 1 +idouble: 1 + +# cbrt +Test "cbrt (-27.0) == -3.0": +double: 1 +idouble: 1 +Test "cbrt (0.75) == 0.908560296416069829445605878163630251": +double: 1 +idouble: 1 +Test "cbrt (0.9921875) == 0.997389022060725270579075195353955217": +double: 1 +idouble: 1 + +# ccos +Test "Imaginary part of: ccos (-2 - 3 i) == -4.18962569096880723013255501961597373 - 9.10922789375533659797919726277886212 i": +float: 1 +ifloat: 1 +Test "Real part of: ccos (0.75 + 1.25 i) == 1.38173873063425888530729933139078645 - 1.09193013555397466170919531722024128 i": +double: 1 +float: 1 +idouble: 1 +ifloat: 1 +Test "Imaginary part of: ccos (0.75 + 1.25 i) == 1.38173873063425888530729933139078645 - 1.09193013555397466170919531722024128 i": +float: 1 +ifloat: 1 + +# ccosh +Test "Real part of: ccosh (-2 - 3 i) == -3.72454550491532256547397070325597253 + 0.511822569987384608834463849801875634 i": +float: 1 +ifloat: 1 +Test "Imaginary part of: ccosh (-2 - 3 i) == -3.72454550491532256547397070325597253 + 0.511822569987384608834463849801875634 i": +float: 1 +ifloat: 1 +Test "Real part of: ccosh (0.75 + 1.25 i) == 0.408242591877968807788852146397499084 + 0.780365930845853240391326216300863152 i": +double: 1 +float: 1 +idouble: 1 +ifloat: 1 +Test "Imaginary part of: ccosh (0.75 + 1.25 i) == 0.408242591877968807788852146397499084 + 0.780365930845853240391326216300863152 i": +float: 1 +ifloat: 1 + +# cexp +Test "Imaginary part of: cexp (-2.0 - 3.0 i) == -0.13398091492954261346140525546115575 - 0.019098516261135196432576240858800925 i": +float: 1 +ifloat: 1 +Test "Real part of: cexp (0.75 + 1.25 i) == 0.667537446429131586942201977015932112 + 2.00900045494094876258347228145863909 i": +float: 1 +ifloat: 1 + +# clog +Test "Real part of: clog (0.75 + 1.25 i) == 0.376885901188190075998919126749298416 + 1.03037682652431246378774332703115153 i": +float: 1 +ifloat: 1 + +# clog10 +Test "Imaginary part of: clog10 (-0 + inf i) == inf + pi/2*log10(e) i": +float: 1 +ifloat: 1 +Test "Imaginary part of: clog10 (-0 - inf i) == inf - pi/2*log10(e) i": +float: 1 +ifloat: 1 +Test "Imaginary part of: clog10 (-2 - 3 i) == 0.556971676153418384603252578971164214 - 0.937554462986374708541507952140189646 i": +double: 1 +idouble: 1 +Test "Imaginary part of: clog10 (-3 + inf i) == inf + pi/2*log10(e) i": +float: 1 +ifloat: 1 +Test "Imaginary part of: clog10 (-3 - inf i) == inf - pi/2*log10(e) i": +float: 1 +ifloat: 1 +Test "Imaginary part of: clog10 (-inf + 0 i) == inf + pi*log10(e) i": +float: 1 +ifloat: 1 +Test "Imaginary part of: clog10 (-inf + 1 i) == inf + pi*log10(e) i": +float: 1 +ifloat: 1 +Test "Imaginary part of: clog10 (-inf - 0 i) == inf - pi*log10(e) i": +float: 1 +ifloat: 1 +Test "Imaginary part of: clog10 (-inf - 1 i) == inf - pi*log10(e) i": +float: 1 +ifloat: 1 +Test "Imaginary part of: clog10 (0 + inf i) == inf + pi/2*log10(e) i": +float: 1 +ifloat: 1 +Test "Imaginary part of: clog10 (0 - inf i) == inf - pi/2*log10(e) i": +float: 1 +ifloat: 1 +Test "Real part of: clog10 (0.75 + 1.25 i) == 0.163679467193165171449476605077428975 + 0.447486970040493067069984724340855636 i": +float: 1 +ifloat: 1 +Test "Imaginary part of: clog10 (3 + inf i) == inf + pi/2*log10(e) i": +float: 1 +ifloat: 1 +Test "Imaginary part of: clog10 (3 - inf i) == inf - pi/2*log10(e) i": +float: 1 +ifloat: 1 +Test "Imaginary part of: clog10 (inf + inf i) == inf + pi/4*log10(e) i": +float: 1 +ifloat: 1 +Test "Imaginary part of: clog10 (inf - inf i) == inf - pi/4*log10(e) i": +float: 1 +ifloat: 1 + +# cos +Test "cos (M_PI_6l * 2.0) == 0.5": +double: 1 +idouble: 1 +Test "cos (M_PI_6l * 4.0) == -0.5": +double: 2 +float: 1 +idouble: 2 +ifloat: 1 + +# cpow +Test "Real part of: cpow (0.75 + 1.25 i, 0.0 + 1.0 i) == 0.331825439177608832276067945276730566 + 0.131338600281188544930936345230903032 i": +float: 1 +ifloat: 1 +Test "Imaginary part of: cpow (0.75 + 1.25 i, 0.0 + 1.0 i) == 0.331825439177608832276067945276730566 + 0.131338600281188544930936345230903032 i": +float: 1 +ifloat: 1 +Test "Real part of: cpow (0.75 + 1.25 i, 0.75 + 1.25 i) == 0.117506293914473555420279832210420483 + 0.346552747708338676483025352060418001 i": +double: 1 +float: 4 +idouble: 1 +ifloat: 4 +Test "Real part of: cpow (0.75 + 1.25 i, 1.0 + 1.0 i) == 0.0846958290317209430433805274189191353 + 0.513285749182902449043287190519090481 i": +double: 2 +float: 3 +idouble: 2 +ifloat: 3 +Test "Real part of: cpow (2 + 3 i, 4 + 0 i) == -119.0 - 120.0 i": +double: 1 +float: 4 +idouble: 1 +ifloat: 4 +Test "Imaginary part of: cpow (2 + 3 i, 4 + 0 i) == -119.0 - 120.0 i": +float: 2 +ifloat: 2 +Test "Imaginary part of: cpow (e + 0 i, 0 + 2 * M_PIl i) == 1.0 + 0.0 i": +double: 2 +float: 2 +idouble: 2 +ifloat: 2 + +# csinh +Test "Imaginary part of: csinh (-2 - 3 i) == 3.59056458998577995201256544779481679 - 0.530921086248519805267040090660676560 i": +double: 1 +idouble: 1 +Test "Real part of: csinh (0.75 + 1.25 i) == 0.259294854551162779153349830618433028 + 1.22863452409509552219214606515777594 i": +float: 1 +ifloat: 1 +Test "Imaginary part of: csinh (0.75 + 1.25 i) == 0.259294854551162779153349830618433028 + 1.22863452409509552219214606515777594 i": +float: 1 +ifloat: 1 + +# csqrt +Test "Real part of: csqrt (-2 + 3 i) == 0.89597747612983812471573375529004348 + 1.6741492280355400404480393008490519 i": +float: 1 +ifloat: 1 +Test "Real part of: csqrt (-2 - 3 i) == 0.89597747612983812471573375529004348 - 1.6741492280355400404480393008490519 i": +float: 1 +ifloat: 1 + +# ctan +Test "Imaginary part of: ctan (0.75 + 1.25 i) == 0.160807785916206426725166058173438663 + 0.975363285031235646193581759755216379 i": +double: 1 +idouble: 1 + +# ctanh +Test "Real part of: ctanh (-2 - 3 i) == -0.965385879022133124278480269394560686 + 0.988437503832249372031403430350121098e-2 i": +double: 1 +float: 2 +idouble: 1 +ifloat: 2 +Test "Imaginary part of: ctanh (0 + pi/4 i) == 0.0 + 1.0 i": +float: 1 +ifloat: 1 +Test "Real part of: ctanh (0.75 + 1.25 i) == 1.37260757053378320258048606571226857 + 0.385795952609750664177596760720790220 i": +double: 1 +idouble: 1 + +# erf +Test "erf (1.25) == 0.922900128256458230136523481197281140": +double: 1 +idouble: 1 + +# erfc +Test "erfc (2.0) == 0.00467773498104726583793074363274707139": +double: 1 +idouble: 1 +Test "erfc (4.125) == 0.542340079956506600531223408575531062e-8": +double: 1 +idouble: 1 + +# exp10 +Test "exp10 (-1) == 0.1": +double: 2 +float: 1 +idouble: 2 +ifloat: 1 +Test "exp10 (0.75) == 5.62341325190349080394951039776481231": +double: 1 +float: 1 +idouble: 1 +ifloat: 1 +Test "exp10 (3) == 1000": +double: 6 +float: 2 +idouble: 6 +ifloat: 2 + +# expm1 +Test "expm1 (0.75) == 1.11700001661267466854536981983709561": +double: 1 +idouble: 1 +Test "expm1 (1) == M_El - 1.0": +float: 1 +ifloat: 1 + +# hypot +Test "hypot (-0.7, -12.4) == 12.419742348374220601176836866763271": +float: 1 +ifloat: 1 +Test "hypot (-0.7, 12.4) == 12.419742348374220601176836866763271": +float: 1 +ifloat: 1 +Test "hypot (-12.4, -0.7) == 12.419742348374220601176836866763271": +float: 1 +ifloat: 1 +Test "hypot (-12.4, 0.7) == 12.419742348374220601176836866763271": +float: 1 +ifloat: 1 +Test "hypot (0.7, -12.4) == 12.419742348374220601176836866763271": +float: 1 +ifloat: 1 +Test "hypot (0.7, 12.4) == 12.419742348374220601176836866763271": +float: 1 +ifloat: 1 +Test "hypot (12.4, -0.7) == 12.419742348374220601176836866763271": +float: 1 +ifloat: 1 +Test "hypot (12.4, 0.7) == 12.419742348374220601176836866763271": +float: 1 +ifloat: 1 + +# j0 +Test "j0 (-4.0) == -3.9714980986384737228659076845169804197562E-1": +double: 1 +float: 1 +idouble: 1 +ifloat: 1 +Test "j0 (0.75) == 0.864242275166648623555731103820923211": +float: 1 +ifloat: 1 +Test "j0 (10.0) == -0.245935764451348335197760862485328754": +double: 2 +float: 1 +idouble: 2 +ifloat: 1 +Test "j0 (2.0) == 0.223890779141235668051827454649948626": +float: 2 +ifloat: 2 +Test "j0 (4.0) == -3.9714980986384737228659076845169804197562E-1": +double: 1 +float: 1 +idouble: 1 +ifloat: 1 +Test "j0 (8.0) == 0.171650807137553906090869407851972001": +float: 1 +ifloat: 1 + +# j1 +Test "j1 (10.0) == 0.0434727461688614366697487680258592883": +float: 2 +ifloat: 2 +Test "j1 (2.0) == 0.576724807756873387202448242269137087": +double: 1 +idouble: 1 +Test "j1 (8.0) == 0.234636346853914624381276651590454612": +double: 1 +idouble: 1 + +# jn +Test "jn (0, -4.0) == -3.9714980986384737228659076845169804197562E-1": +double: 1 +float: 1 +idouble: 1 +ifloat: 1 +Test "jn (0, 0.75) == 0.864242275166648623555731103820923211": +float: 1 +ifloat: 1 +Test "jn (0, 10.0) == -0.245935764451348335197760862485328754": +double: 2 +float: 1 +idouble: 2 +ifloat: 1 +Test "jn (0, 2.0) == 0.223890779141235668051827454649948626": +float: 2 +ifloat: 2 +Test "jn (0, 4.0) == -3.9714980986384737228659076845169804197562E-1": +double: 1 +float: 1 +idouble: 1 +ifloat: 1 +Test "jn (0, 8.0) == 0.171650807137553906090869407851972001": +float: 1 +ifloat: 1 +Test "jn (1, 10.0) == 0.0434727461688614366697487680258592883": +float: 2 +ifloat: 2 +Test "jn (1, 2.0) == 0.576724807756873387202448242269137087": +double: 1 +idouble: 1 +Test "jn (1, 8.0) == 0.234636346853914624381276651590454612": +double: 1 +idouble: 1 +Test "jn (10, 0.125) == 0.250543369809369890173993791865771547e-18": +double: 1 +float: 1 +idouble: 1 +ifloat: 1 +Test "jn (10, 0.75) == 0.149621713117596814698712483621682835e-10": +double: 1 +float: 1 +idouble: 1 +ifloat: 1 +Test "jn (10, 10.0) == 0.207486106633358857697278723518753428": +double: 4 +float: 3 +idouble: 4 +ifloat: 3 +Test "jn (10, 2.0) == 0.251538628271673670963516093751820639e-6": +float: 4 +ifloat: 4 +Test "jn (3, 0.125) == 0.406503832554912875023029337653442868e-4": +double: 1 +float: 1 +idouble: 1 +ifloat: 1 +Test "jn (3, 0.75) == 0.848438342327410884392755236884386804e-2": +double: 1 +float: 1 +idouble: 1 +ifloat: 1 +Test "jn (3, 10.0) == 0.0583793793051868123429354784103409563": +double: 3 +float: 1 +idouble: 3 +ifloat: 1 +Test "jn (3, 2.0) == 0.128943249474402051098793332969239835": +double: 1 +float: 2 +idouble: 1 +ifloat: 2 + +# lgamma +Test "lgamma (0.7) == 0.260867246531666514385732417016759578": +double: 1 +float: 1 +idouble: 1 +ifloat: 1 +Test "lgamma (1.2) == -0.853740900033158497197028392998854470e-1": +double: 1 +float: 2 +idouble: 1 +ifloat: 2 + +# log10 +Test "log10 (0.75) == -0.124938736608299953132449886193870744": +double: 1 +float: 2 +idouble: 1 +ifloat: 2 +Test "log10 (e) == log10(e)": +float: 1 +ifloat: 1 + +# log1p +Test "log1p (-0.25) == -0.287682072451780927439219005993827432": +float: 1 +ifloat: 1 + +# sincos +Test "sincos (M_PI_6l*2.0, &sin_res, &cos_res) puts 0.5 in cos_res": +double: 1 +idouble: 1 +Test "sincos (M_PI_6l*2.0, &sin_res, &cos_res) puts 0.86602540378443864676372317075293616 in sin_res": +double: 1 +float: 1 +idouble: 1 +ifloat: 1 +Test "sincos (pi/6, &sin_res, &cos_res) puts 0.86602540378443864676372317075293616 in cos_res": +float: 1 +ifloat: 1 + +# tgamma +Test "tgamma (-0.5) == -2 sqrt (pi)": +double: 1 +float: 1 +idouble: 1 +ifloat: 1 +Test "tgamma (0.5) == sqrt (pi)": +float: 1 +ifloat: 1 +Test "tgamma (0.7) == 1.29805533264755778568117117915281162": +double: 1 +float: 1 +idouble: 1 +ifloat: 1 + +# y0 +Test "y0 (1.0) == 0.0882569642156769579829267660235151628": +double: 2 +float: 1 +idouble: 2 +ifloat: 1 +Test "y0 (1.5) == 0.382448923797758843955068554978089862": +double: 2 +float: 1 +idouble: 2 +ifloat: 1 +Test "y0 (10.0) == 0.0556711672835993914244598774101900481": +float: 1 +ifloat: 1 +Test "y0 (8.0) == 0.223521489387566220527323400498620359": +double: 1 +float: 1 +idouble: 1 +ifloat: 1 + +# y1 +Test "y1 (0.125) == -5.19993611253477499595928744876579921": +double: 1 +idouble: 1 +Test "y1 (1.5) == -0.412308626973911295952829820633445323": +float: 1 +ifloat: 1 +Test "y1 (10.0) == 0.249015424206953883923283474663222803": +double: 3 +float: 1 +idouble: 3 +ifloat: 1 +Test "y1 (2.0) == -0.107032431540937546888370772277476637": +double: 1 +float: 1 +idouble: 1 +ifloat: 1 +Test "y1 (8.0) == -0.158060461731247494255555266187483550": +double: 1 +float: 2 +idouble: 1 +ifloat: 2 + +# yn +Test "yn (0, 1.0) == 0.0882569642156769579829267660235151628": +double: 2 +float: 1 +idouble: 2 +ifloat: 1 +Test "yn (0, 1.5) == 0.382448923797758843955068554978089862": +double: 2 +float: 1 +idouble: 2 +ifloat: 1 +Test "yn (0, 10.0) == 0.0556711672835993914244598774101900481": +float: 1 +ifloat: 1 +Test "yn (0, 8.0) == 0.223521489387566220527323400498620359": +double: 1 +float: 1 +idouble: 1 +ifloat: 1 +Test "yn (1, 0.125) == -5.19993611253477499595928744876579921": +double: 1 +idouble: 1 +Test "yn (1, 1.5) == -0.412308626973911295952829820633445323": +float: 1 +ifloat: 1 +Test "yn (1, 10.0) == 0.249015424206953883923283474663222803": +double: 3 +float: 1 +idouble: 3 +ifloat: 1 +Test "yn (1, 2.0) == -0.107032431540937546888370772277476637": +double: 1 +float: 1 +idouble: 1 +ifloat: 1 +Test "yn (1, 8.0) == -0.158060461731247494255555266187483550": +double: 1 +float: 2 +idouble: 1 +ifloat: 2 +Test "yn (10, 0.125) == -127057845771019398.252538486899753195": +double: 1 +idouble: 1 +Test "yn (10, 0.75) == -2133501638.90573424452445412893839236": +double: 1 +float: 1 +idouble: 1 +ifloat: 1 +Test "yn (10, 1.0) == -121618014.278689189288130426667971145": +double: 1 +idouble: 1 +Test "yn (10, 10.0) == -0.359814152183402722051986577343560609": +double: 1 +float: 1 +idouble: 1 +ifloat: 1 +Test "yn (10, 2.0) == -129184.542208039282635913145923304214": +double: 2 +idouble: 2 +Test "yn (3, 0.125) == -2612.69757350066712600220955744091741": +double: 1 +idouble: 1 +Test "yn (3, 0.75) == -12.9877176234475433186319774484809207": +double: 1 +float: 1 +idouble: 1 +ifloat: 1 +Test "yn (3, 10.0) == -0.251362657183837329779204747654240998": +double: 1 +float: 1 +idouble: 1 +ifloat: 1 +Test "yn (3, 2.0) == -1.12778377684042778608158395773179238": +double: 1 +idouble: 1 + +# Maximal error of functions: +Function: "atan2": +float: 1 +ifloat: 1 + +Function: "atanh": +float: 1 +ifloat: 1 + +Function: Imaginary part of "cacosh": +float: 1 +ifloat: 1 + +Function: Real part of "casin": +double: 1 +float: 1 +idouble: 1 +ifloat: 1 + +Function: Real part of "casinh": +double: 5 +float: 1 +idouble: 5 +ifloat: 1 + +Function: Imaginary part of "casinh": +double: 3 +float: 6 +idouble: 3 +ifloat: 6 + +Function: Imaginary part of "catan": +double: 1 +float: 1 +idouble: 1 +ifloat: 1 + +Function: Real part of "catanh": +double: 4 +idouble: 4 + +Function: "cbrt": +double: 1 +idouble: 1 + +Function: Real part of "ccos": +double: 1 +float: 1 +idouble: 1 +ifloat: 1 + +Function: Imaginary part of "ccos": +float: 1 +ifloat: 1 + +Function: Real part of "ccosh": +double: 1 +float: 1 +idouble: 1 +ifloat: 1 + +Function: Imaginary part of "ccosh": +float: 1 +ifloat: 1 + +Function: Real part of "cexp": +float: 1 +ifloat: 1 + +Function: Imaginary part of "cexp": +float: 1 +ifloat: 1 + +Function: Real part of "clog": +float: 1 +ifloat: 1 + +Function: Real part of "clog10": +float: 1 +ifloat: 1 + +Function: Imaginary part of "clog10": +double: 1 +float: 1 +idouble: 1 +ifloat: 1 + +Function: "cos": +double: 2 +float: 1 +idouble: 2 +ifloat: 1 + +Function: Real part of "cpow": +double: 2 +float: 4 +idouble: 2 +ifloat: 4 + +Function: Imaginary part of "cpow": +double: 2 +float: 2 +idouble: 2 +ifloat: 2 + +Function: Real part of "csinh": +float: 1 +ifloat: 1 + +Function: Imaginary part of "csinh": +double: 1 +float: 1 +idouble: 1 +ifloat: 1 + +Function: Real part of "csqrt": +float: 1 +ifloat: 1 + +Function: Imaginary part of "ctan": +double: 1 +idouble: 1 + +Function: Real part of "ctanh": +double: 1 +float: 2 +idouble: 1 +ifloat: 2 + +Function: Imaginary part of "ctanh": +float: 1 +ifloat: 1 + +Function: "erf": +double: 1 +idouble: 1 + +Function: "erfc": +double: 1 +idouble: 1 + +Function: "exp10": +double: 6 +float: 2 +idouble: 6 +ifloat: 2 + +Function: "expm1": +double: 1 +float: 1 +idouble: 1 +ifloat: 1 + +Function: "hypot": +float: 1 +ifloat: 1 + +Function: "j0": +double: 2 +float: 2 +idouble: 2 +ifloat: 2 + +Function: "j1": +double: 1 +float: 2 +idouble: 1 +ifloat: 2 + +Function: "jn": +double: 4 +float: 4 +idouble: 4 +ifloat: 4 + +Function: "lgamma": +double: 1 +float: 2 +idouble: 1 +ifloat: 2 + +Function: "log10": +double: 1 +float: 2 +idouble: 1 +ifloat: 2 + +Function: "log1p": +float: 1 +ifloat: 1 + +Function: "sincos": +double: 1 +float: 1 +idouble: 1 +ifloat: 1 + +Function: "tan": +double: 1 +idouble: 1 + +Function: "tgamma": +double: 1 +float: 1 +idouble: 1 +ifloat: 1 + +Function: "y0": +double: 2 +float: 1 +idouble: 2 +ifloat: 1 + +Function: "y1": +double: 3 +float: 2 +idouble: 3 +ifloat: 2 + +Function: "yn": +double: 3 +float: 2 +idouble: 3 +ifloat: 2 + +# end of automatic generation diff --git a/ports/sysdeps/m68k/coldfire/fpu/s_fabs.c b/ports/sysdeps/m68k/coldfire/fpu/s_fabs.c new file mode 100644 index 0000000000..e2f1837777 --- /dev/null +++ b/ports/sysdeps/m68k/coldfire/fpu/s_fabs.c @@ -0,0 +1,28 @@ +/* Copyright (C) 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, see + <http://www.gnu.org/licenses/>. */ + +double +__fabs (double x) +{ + asm ("fdabs.d %1,%0" : "=f" (x) : "fm" (x)); + return x; +} +weak_alias (__fabs, fabs) +#ifdef NO_LONG_DOUBLE +strong_alias (__fabs, __fabsl) +weak_alias (__fabs, fabsl) +#endif diff --git a/ports/sysdeps/m68k/coldfire/fpu/s_fabsf.c b/ports/sysdeps/m68k/coldfire/fpu/s_fabsf.c new file mode 100644 index 0000000000..4a5928afd2 --- /dev/null +++ b/ports/sysdeps/m68k/coldfire/fpu/s_fabsf.c @@ -0,0 +1,24 @@ +/* Copyright (C) 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, see + <http://www.gnu.org/licenses/>. */ + +float +__fabsf (float x) +{ + asm ("fsabs.s %1,%0" : "=f" (x) : "dm" (x)); + return x; +} +weak_alias (__fabsf, fabsf) diff --git a/ports/sysdeps/m68k/coldfire/fpu/s_lrint.c b/ports/sysdeps/m68k/coldfire/fpu/s_lrint.c new file mode 100644 index 0000000000..b0d61e34fe --- /dev/null +++ b/ports/sysdeps/m68k/coldfire/fpu/s_lrint.c @@ -0,0 +1,29 @@ +/* Copyright (C) 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, see + <http://www.gnu.org/licenses/>. */ + +long int +__lrint (double x) +{ + long int result; + asm ("fmove.l %1,%0" : "=dm" (result) : "f" (x)); + return result; +} +weak_alias (__lrint, lrint) +#ifdef NO_LONG_DOUBLE +strong_alias (__lrint, __lrintl) +weak_alias (__lrint, lrintl) +#endif diff --git a/ports/sysdeps/m68k/coldfire/fpu/s_lrintf.c b/ports/sysdeps/m68k/coldfire/fpu/s_lrintf.c new file mode 100644 index 0000000000..37c0e96527 --- /dev/null +++ b/ports/sysdeps/m68k/coldfire/fpu/s_lrintf.c @@ -0,0 +1,25 @@ +/* Copyright (C) 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, see + <http://www.gnu.org/licenses/>. */ + +long int +__lrintf (float x) +{ + long int result; + asm ("fmove.l %1,%0" : "=dm" (result) : "f" (x)); + return result; +} +weak_alias (__lrintf, lrintf) diff --git a/ports/sysdeps/m68k/coldfire/fpu/s_rint.c b/ports/sysdeps/m68k/coldfire/fpu/s_rint.c new file mode 100644 index 0000000000..5435798c18 --- /dev/null +++ b/ports/sysdeps/m68k/coldfire/fpu/s_rint.c @@ -0,0 +1,28 @@ +/* Copyright (C) 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, see + <http://www.gnu.org/licenses/>. */ + +double +__rint (double x) +{ + asm ("fint.d %1,%0" : "=f" (x) : "fm" (x)); + return x; +} +weak_alias (__rint, rint) +#ifdef NO_LONG_DOUBLE +strong_alias (__rint, __rintl) +weak_alias (__rint, rintl) +#endif diff --git a/ports/sysdeps/m68k/coldfire/fpu/s_rintf.c b/ports/sysdeps/m68k/coldfire/fpu/s_rintf.c new file mode 100644 index 0000000000..4eae67857c --- /dev/null +++ b/ports/sysdeps/m68k/coldfire/fpu/s_rintf.c @@ -0,0 +1,25 @@ +/* Copyright (C) 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, see + <http://www.gnu.org/licenses/>. */ + +float +__rintf (float x) +{ + double result; + asm ("fint.s %1,%0" : "=f" (result) : "dm" (x)); + return (float) result; +} +weak_alias (__rintf, rintf) diff --git a/ports/sysdeps/m68k/coldfire/shlib-versions b/ports/sysdeps/m68k/coldfire/shlib-versions new file mode 100644 index 0000000000..f4c68b2a51 --- /dev/null +++ b/ports/sysdeps/m68k/coldfire/shlib-versions @@ -0,0 +1 @@ +m68k-.*-linux.* DEFAULT GLIBC_2.4 diff --git a/ports/sysdeps/m68k/coldfire/sysdep.h b/ports/sysdeps/m68k/coldfire/sysdep.h new file mode 100644 index 0000000000..fc94adea37 --- /dev/null +++ b/ports/sysdeps/m68k/coldfire/sysdep.h @@ -0,0 +1,40 @@ +/* Assembler macros for Coldfire. + Copyright (C) 1998, 2003, 2010, 2012 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, see + <http://www.gnu.org/licenses/>. */ + +#include <sysdeps/m68k/sysdep.h> + +#ifdef __ASSEMBLER__ + +/* Perform operation OP with PC-relative SRC as the first operand and + DST as the second. TMP is available as a temporary if needed. */ +# define PCREL_OP(OP, SRC, DST, TMP) \ + move.l &SRC - ., TMP; OP (-8, %pc, TMP), DST + +/* Load the address of the GOT into register R. */ +# define LOAD_GOT(R) \ + move.l &_GLOBAL_OFFSET_TABLE_@GOTPC, R; \ + lea (-6, %pc, R), R + +#else + +/* As above, but PC is the spelling of the PC register. We need this + so that the macro can be used in both normal and extended asms. */ +# define PCREL_OP(OP, SRC, DST, TMP, PC) \ + "move.l #" SRC " - ., " TMP "\n\t" OP " (-8, " PC ", " TMP "), " DST + +#endif /* __ASSEMBLER__ */ diff --git a/ports/sysdeps/m68k/crti.S b/ports/sysdeps/m68k/crti.S new file mode 100644 index 0000000000..c58e6e5171 --- /dev/null +++ b/ports/sysdeps/m68k/crti.S @@ -0,0 +1,82 @@ +/* Special .init and .fini section support for m68k. + Copyright (C) 2012 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. + + In addition to the permissions in the GNU Lesser General Public + License, the Free Software Foundation gives you unlimited + permission to link the compiled version of this file with other + programs, and to distribute those programs without any restriction + coming from the use of this file. (The GNU Lesser General Public + License restrictions do apply in other respects; for example, they + cover modification of the file, and distribution when not linked + into another program.) + + Note that people who make modified versions of this file are not + obligated to grant this special exception for their modified + versions; it is their choice whether to do so. The GNU Lesser + General Public License gives permission to release a modified + version without this exception; this exception also makes it + possible to release a modified version which carries forward this + exception. + + 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, see + <http://www.gnu.org/licenses/>. */ + +/* crti.S puts a function prologue at the beginning of the .init and + .fini sections and defines global symbols for those addresses, so + they can be called as functions. The symbols _init and _fini are + magic and cause the linker to emit DT_INIT and DT_FINI. */ + +#include <libc-symbols.h> +#include <sysdep.h> + +#ifndef PREINIT_FUNCTION +# define PREINIT_FUNCTION __gmon_start__ +#endif + +#ifndef PREINIT_FUNCTION_WEAK +# define PREINIT_FUNCTION_WEAK 1 +#endif + +#if PREINIT_FUNCTION_WEAK + weak_extern (PREINIT_FUNCTION) +#else + .hidden PREINIT_FUNCTION +#endif + + .section .init,"ax",@progbits + .align 2 + .globl _init + .type _init, @function +_init: + link.w %fp, #0 + move.l %a5, -(%sp) + LOAD_GOT (%a5) +#if PREINIT_FUNCTION_WEAK + tst.l PREINIT_FUNCTION@GOT(%a5) + jeq 1f + jbsr PREINIT_FUNCTION@PLTPC +1: +#else + jbsr PREINIT_FUNCTION +#endif + + .section .fini,"ax",@progbits + .align 2 + .globl _fini + .type _fini, @function +_fini: + link.w %fp, #0 + move.l %a5, -(%sp) + LOAD_GOT (%a5) diff --git a/ports/sysdeps/m68k/crtn.S b/ports/sysdeps/m68k/crtn.S new file mode 100644 index 0000000000..73a213abd2 --- /dev/null +++ b/ports/sysdeps/m68k/crtn.S @@ -0,0 +1,47 @@ +/* Special .init and .fini section support for m68k. + Copyright (C) 2012 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. + + In addition to the permissions in the GNU Lesser General Public + License, the Free Software Foundation gives you unlimited + permission to link the compiled version of this file with other + programs, and to distribute those programs without any restriction + coming from the use of this file. (The GNU Lesser General Public + License restrictions do apply in other respects; for example, they + cover modification of the file, and distribution when not linked + into another program.) + + Note that people who make modified versions of this file are not + obligated to grant this special exception for their modified + versions; it is their choice whether to do so. The GNU Lesser + General Public License gives permission to release a modified + version without this exception; this exception also makes it + possible to release a modified version which carries forward this + exception. + + 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, see + <http://www.gnu.org/licenses/>. */ + +/* crtn.S puts function epilogues in the .init and .fini sections + corresponding to the prologues in crti.S. */ + + .section .init,"ax",@progbits + move.l -4(%fp), %a5 + unlk %fp + rts + + .section .fini,"ax",@progbits + move.l -4(%fp), %a5 + unlk %fp + rts diff --git a/ports/sysdeps/m68k/dl-machine.h b/ports/sysdeps/m68k/dl-machine.h new file mode 100644 index 0000000000..4a1968c4ff --- /dev/null +++ b/ports/sysdeps/m68k/dl-machine.h @@ -0,0 +1,319 @@ +/* Machine-dependent ELF dynamic relocation inline functions. m68k version. + Copyright (C) 1996-2001, 2002, 2003, 2004, 2005, 2010, 2011 + 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, see + <http://www.gnu.org/licenses/>. */ + +#ifndef dl_machine_h +#define dl_machine_h + +#define ELF_MACHINE_NAME "m68k" + +#include <sys/param.h> +#include <sysdep.h> +#include <dl-tls.h> + +/* Return nonzero iff ELF header is compatible with the running host. */ +static inline int +elf_machine_matches_host (const Elf32_Ehdr *ehdr) +{ + return ehdr->e_machine == EM_68K; +} + + +/* Return the link-time address of _DYNAMIC. + This must be inlined in a function which uses global data. */ +static inline Elf32_Addr +elf_machine_dynamic (void) +{ + Elf32_Addr addr; + + asm ("move.l _DYNAMIC@GOT.w(%%a5), %0" + : "=a" (addr)); + return addr; +} + + +/* Return the run-time load address of the shared object. */ +static inline Elf32_Addr +elf_machine_load_address (void) +{ + Elf32_Addr addr; + asm (PCREL_OP ("lea", "_dl_start", "%0", "%0", "%%pc") "\n\t" + "sub.l _dl_start@GOT.w(%%a5), %0" + : "=a" (addr)); + return addr; +} + + +/* Set up the loaded object described by L so its unrelocated PLT + entries will jump to the on-demand fixup code in dl-runtime.c. */ + +static inline int __attribute__ ((always_inline)) +elf_machine_runtime_setup (struct link_map *l, int lazy, int profile) +{ + Elf32_Addr *got; + extern void _dl_runtime_resolve (Elf32_Word); + extern void _dl_runtime_profile (Elf32_Word); + + if (l->l_info[DT_JMPREL] && lazy) + { + /* The GOT entries for functions in the PLT have not yet been + filled in. Their initial contents will arrange when called + to push an offset into the .rela.plt section, push + _GLOBAL_OFFSET_TABLE_[1], and then jump to + _GLOBAL_OFFSET_TABLE_[2]. */ + got = (Elf32_Addr *) D_PTR (l, l_info[DT_PLTGOT]); + got[1] = (Elf32_Addr) l; /* Identify this shared object. */ + + /* The got[2] entry contains the address of a function which gets + called to get the address of a so far unresolved function and + jump to it. The profiling extension of the dynamic linker allows + to intercept the calls to collect information. In this case we + don't store the address in the GOT so that all future calls also + end in this function. */ + if (profile) + { + got[2] = (Elf32_Addr) &_dl_runtime_profile; + + if (GLRO(dl_profile) != NULL + && _dl_name_match_p (GLRO(dl_profile), l)) + { + /* This is the object we are looking for. Say that we really + want profiling and the timers are started. */ + GL(dl_profile_map) = l; + } + } + else + /* This function will get called to fix up the GOT entry indicated by + the offset on the stack, and then jump to the resolved address. */ + got[2] = (Elf32_Addr) &_dl_runtime_resolve; + } + + return lazy; +} + +#define ELF_MACHINE_RUNTIME_FIXUP_ARGS long int save_a0, long int save_a1 + + +/* Mask identifying addresses reserved for the user program, + where the dynamic linker should not map anything. */ +#define ELF_MACHINE_USER_ADDRESS_MASK 0x80000000UL + +/* Initial entry point code for the dynamic linker. + The C function `_dl_start' is the real entry point; + its return value is the user program's entry point. */ + +#define RTLD_START asm ("\ + .text\n\ + .globl _start\n\ + .type _start,@function\n\ +_start:\n\ + sub.l %fp, %fp\n\ + move.l %sp, -(%sp)\n\ + jbsr _dl_start\n\ + addq.l #4, %sp\n\ + /* FALLTHRU */\n\ +\n\ + .globl _dl_start_user\n\ + .type _dl_start_user,@function\n\ +_dl_start_user:\n\ + | Save the user entry point address in %a4.\n\ + move.l %d0, %a4\n\ + | See if we were run as a command with the executable file\n\ + | name as an extra leading argument.\n\ + " PCREL_OP ("move.l", "_dl_skip_args", "%d0", "%d0", "%pc") "\n\ + | Pop the original argument count\n\ + move.l (%sp)+, %d1\n\ + | Subtract _dl_skip_args from it.\n\ + sub.l %d0, %d1\n\ + | Adjust the stack pointer to skip _dl_skip_args words.\n\ + lea (%sp, %d0*4), %sp\n\ + | Push back the modified argument count.\n\ + move.l %d1, -(%sp)\n\ + # Call _dl_init (struct link_map *main_map, int argc, char **argv, char **env)\n\ + pea 8(%sp, %d1*4)\n\ + pea 8(%sp)\n\ + move.l %d1, -(%sp)\n\ + " PCREL_OP ("move.l", "_rtld_local", "-(%sp)", "%d0", "%pc") "\n\ + jbsr _dl_init_internal@PLTPC\n\ + addq.l #8, %sp\n\ + addq.l #8, %sp\n\ + | Pass our finalizer function to the user in %a1.\n\ + " PCREL_OP ("lea", "_dl_fini", "%a1", "%a1", "%pc") "\n\ + | Initialize %fp with the stack pointer.\n\ + move.l %sp, %fp\n\ + | Jump to the user's entry point.\n\ + jmp (%a4)\n\ + .size _dl_start_user, . - _dl_start_user\n\ + .previous"); + +/* ELF_RTYPE_CLASS_PLT iff TYPE describes relocation of a PLT entry or + TLS variable, so undefined references should not be allowed to + define the value. + ELF_RTYPE_CLASS_NOCOPY iff TYPE should not be allowed to resolve to one + of the main executable's symbols, as for a COPY reloc. */ +#define elf_machine_type_class(type) \ + ((((type) == R_68K_JMP_SLOT \ + || (type) == R_68K_TLS_DTPMOD32 \ + || (type) == R_68K_TLS_DTPREL32 \ + || (type) == R_68K_TLS_TPREL32) * ELF_RTYPE_CLASS_PLT) \ + | (((type) == R_68K_COPY) * ELF_RTYPE_CLASS_COPY)) + +/* A reloc type used for ld.so cmdline arg lookups to reject PLT entries. */ +#define ELF_MACHINE_JMP_SLOT R_68K_JMP_SLOT + +/* The m68k never uses Elf32_Rel relocations. */ +#define ELF_MACHINE_NO_REL 1 + +static inline Elf32_Addr +elf_machine_fixup_plt (struct link_map *map, lookup_t t, + const Elf32_Rela *reloc, + Elf32_Addr *reloc_addr, Elf32_Addr value) +{ + return *reloc_addr = value; +} + +/* Return the final value of a plt relocation. On the m68k the JMP_SLOT + relocation ignores the addend. */ +static inline Elf32_Addr +elf_machine_plt_value (struct link_map *map, const Elf32_Rela *reloc, + Elf32_Addr value) +{ + return value; +} + +/* Names of the architecture-specific auditing callback functions. */ +#define ARCH_LA_PLTENTER m68k_gnu_pltenter +#define ARCH_LA_PLTEXIT m68k_gnu_pltexit + +#endif /* !dl_machine_h */ + +#ifdef RESOLVE_MAP + +/* Perform the relocation specified by RELOC and SYM (which is fully resolved). + MAP is the object containing the reloc. */ + +auto inline void __attribute__ ((unused, always_inline)) +elf_machine_rela (struct link_map *map, const Elf32_Rela *reloc, + const Elf32_Sym *sym, const struct r_found_version *version, + void *const reloc_addr_arg, int skip_ifunc) +{ + Elf32_Addr *const reloc_addr = reloc_addr_arg; + const unsigned int r_type = ELF32_R_TYPE (reloc->r_info); + + if (__builtin_expect (r_type == R_68K_RELATIVE, 0)) + *reloc_addr = map->l_addr + reloc->r_addend; + else + { + const Elf32_Sym *const refsym = sym; + struct link_map *sym_map = RESOLVE_MAP (&sym, version, r_type); + Elf32_Addr value = sym == NULL ? 0 : sym_map->l_addr + sym->st_value; + + switch (r_type) + { + case R_68K_COPY: + if (sym == NULL) + /* This can happen in trace mode if an object could not be + found. */ + break; + if (sym->st_size > refsym->st_size + || (sym->st_size < refsym->st_size && GLRO(dl_verbose))) + { + const char *strtab; + + strtab = (const void *) D_PTR (map, l_info[DT_STRTAB]); + _dl_error_printf ("\ +%s: Symbol `%s' has different size in shared object, consider re-linking\n", + rtld_progname ?: "<program name unknown>", + strtab + refsym->st_name); + } + memcpy (reloc_addr_arg, (void *) value, + MIN (sym->st_size, refsym->st_size)); + break; + case R_68K_GLOB_DAT: + case R_68K_JMP_SLOT: + *reloc_addr = value; + break; + case R_68K_8: + *(char *) reloc_addr = value + reloc->r_addend; + break; + case R_68K_16: + *(short *) reloc_addr = value + reloc->r_addend; + break; + case R_68K_32: + *reloc_addr = value + reloc->r_addend; + break; + case R_68K_PC8: + *(char *) reloc_addr + = value + reloc->r_addend - (Elf32_Addr) reloc_addr; + break; + case R_68K_PC16: + *(short *) reloc_addr + = value + reloc->r_addend - (Elf32_Addr) reloc_addr; + break; + case R_68K_PC32: + *reloc_addr = value + reloc->r_addend - (Elf32_Addr) reloc_addr; + break; +#ifndef RTLD_BOOTSTRAP + case R_68K_TLS_DTPMOD32: + /* Get the information from the link map returned by the + resolv function. */ + if (sym_map != NULL) + *reloc_addr = sym_map->l_tls_modid; + break; + case R_68K_TLS_DTPREL32: + if (sym != NULL) + *reloc_addr = TLS_DTPREL_VALUE (sym, reloc); + break; + case R_68K_TLS_TPREL32: + if (sym != NULL) + { + CHECK_STATIC_TLS (map, sym_map); + *reloc_addr = TLS_TPREL_VALUE (sym_map, sym, reloc); + } + break; +#endif /* !RTLD_BOOTSTRAP */ + case R_68K_NONE: /* Alright, Wilbur. */ + break; + default: + _dl_reloc_bad_type (map, r_type, 0); + break; + } + } +} + +auto inline void __attribute__ ((unused, always_inline)) +elf_machine_rela_relative (Elf32_Addr l_addr, const Elf32_Rela *reloc, + void *const reloc_addr_arg) +{ + Elf32_Addr *const reloc_addr = reloc_addr_arg; + *reloc_addr = l_addr + reloc->r_addend; +} + +auto inline void __attribute__ ((unused, always_inline)) +elf_machine_lazy_rel (struct link_map *map, + Elf32_Addr l_addr, const Elf32_Rela *reloc, + int skip_ifunc) +{ + Elf32_Addr *const reloc_addr = (void *) (l_addr + reloc->r_offset); + if (ELF32_R_TYPE (reloc->r_info) == R_68K_JMP_SLOT) + *reloc_addr += l_addr; + else + _dl_reloc_bad_type (map, ELF32_R_TYPE (reloc->r_info), 1); +} + +#endif /* RESOLVE_MAP */ diff --git a/ports/sysdeps/m68k/dl-tls.h b/ports/sysdeps/m68k/dl-tls.h new file mode 100644 index 0000000000..716003587a --- /dev/null +++ b/ports/sysdeps/m68k/dl-tls.h @@ -0,0 +1,50 @@ +/* Thread-local storage handling in the ELF dynamic linker. M68K version. + Copyright (C) 2010, 2011 Free Software Foundation, Inc. + This file is part of the GNU C Library. + Contributed by Maxim Kuvyrkov <maxim@codesourcery.com>, 2010. + + 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, see + <http://www.gnu.org/licenses/>. */ + + +/* Type used for the representation of TLS information in the GOT. */ +typedef struct +{ + unsigned long int ti_module; + unsigned long int ti_offset; +} tls_index; + +/* The thread pointer points 0x7000 past the first static TLS block. */ +#define TLS_TP_OFFSET 0x7000 + +/* Dynamic thread vector pointers point 0x8000 past the start of each + TLS block. */ +#define TLS_DTV_OFFSET 0x8000 + +/* Compute the value for a TPREL reloc. */ +#define TLS_TPREL_VALUE(sym_map, sym, reloc) \ + ((sym_map)->l_tls_offset + (sym)->st_value + (reloc)->r_addend \ + - TLS_TP_OFFSET) + +/* Compute the value for a DTPREL reloc. */ +#define TLS_DTPREL_VALUE(sym, reloc) \ + ((sym)->st_value + (reloc)->r_addend - TLS_DTV_OFFSET) + +extern void *__tls_get_addr (tls_index *ti); + +#define GET_ADDR_OFFSET (ti->ti_offset + TLS_DTV_OFFSET) +#define __TLS_GET_ADDR(__ti) (__tls_get_addr (__ti) - TLS_DTV_OFFSET) + +/* Value used for dtv entries for which the allocation is delayed. */ +#define TLS_DTV_UNALLOCATED ((void *) -1l) diff --git a/ports/sysdeps/m68k/dl-trampoline.S b/ports/sysdeps/m68k/dl-trampoline.S new file mode 100644 index 0000000000..fad1864588 --- /dev/null +++ b/ports/sysdeps/m68k/dl-trampoline.S @@ -0,0 +1,227 @@ +/* PLT trampolines. m68k version. + Copyright (C) 2005, 2011, 2012 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, see + <http://www.gnu.org/licenses/>. */ + +#include <sysdep.h> + + .text + .globl _dl_runtime_resolve + .type _dl_runtime_resolve, @function +_dl_runtime_resolve: + cfi_startproc + cfi_adjust_cfa_offset (8) + | Save %a0 (struct return address) and %a1. + move.l %a0, -(%sp) + cfi_adjust_cfa_offset (4) + move.l %a1, -(%sp) + cfi_adjust_cfa_offset (4) + | Call the real address resolver. + jbsr _dl_fixup + | Restore register %a0 and %a1. + move.l (%sp)+, %a1 + cfi_adjust_cfa_offset (-4) + move.l (%sp)+, %a0 + cfi_adjust_cfa_offset (-4) + | Pop parameters + addq.l #8, %sp + cfi_adjust_cfa_offset (-8) + | Call real function. +#ifdef __mcoldfire__ + move.l %d0,-(%sp) + cfi_adjust_cfa_offset (4) + rts +#else + jmp (%d0) +#endif + cfi_endproc + .size _dl_runtime_resolve, . - _dl_runtime_resolve + + .text + .globl _dl_runtime_profile + .type _dl_runtime_profile, @function +_dl_runtime_profile: + cfi_startproc + cfi_adjust_cfa_offset (8) + pea 8(%sp) + cfi_adjust_cfa_offset (4) + move.l %a1, -(%sp) + cfi_adjust_cfa_offset (4) + move.l %a0, -(%sp) + cfi_adjust_cfa_offset (4) + pea -1.w + cfi_adjust_cfa_offset (4) + | Push parameters for _dl_profile_fixup + pea (%sp) + cfi_adjust_cfa_offset (4) + pea 8(%sp) + cfi_adjust_cfa_offset (4) + move.l 32(%sp), -(%sp) + cfi_adjust_cfa_offset (4) + move.l 32(%sp), -(%sp) + cfi_adjust_cfa_offset (4) + move.l 32(%sp), -(%sp) + cfi_adjust_cfa_offset (4) + subq.l #8, %sp + cfi_adjust_cfa_offset (8) + | Call the real address resolver. + jbsr _dl_profile_fixup + | Pop parameters + lea 28(%sp), %sp + cfi_adjust_cfa_offset (-28) + move.l (%sp), %d1 + jpl 1f + addq.l #4, %sp + cfi_adjust_cfa_offset (-4) + | Restore register %a0 and %a1. + move.l (%sp)+, %a0 + cfi_adjust_cfa_offset (-4) + move.l (%sp)+, %a1 + cfi_adjust_cfa_offset (-4) + lea 12(%sp), %sp + cfi_adjust_cfa_offset (-12) + | Call real function. +#ifdef __mcoldfire__ + move.l %d0,-(%sp) + cfi_adjust_cfa_offset (4) + rts +#else + jmp (%d0) +#endif + + /* + +24 return address + +20 PLT1 + +16 PLT2 + +12 %sp + +8 %a1 + +4 %a0 + %sp free + */ +#ifdef __mcoldfire__ + cfi_adjust_cfa_offset (20) +#else + cfi_adjust_cfa_offset (24) +#endif +1: move.l %a2, (%sp) + cfi_rel_offset (%a2, 0) + move.l %sp, %a2 + move.l %sp, %a0 + lea 28(%sp), %a1 + | Round framesize up to longword alignment + addq.l #3, %d1 + and.l #-3, %d1 + sub.l %d1, %a0 + move.l %a0, %sp + cfi_def_cfa_register (%a2) +#ifdef __mcoldfire__ + tst.l %d1 + beq 2f +1: move.l (%a0)+, (%a1)+ + subq.l #4,%d1 + bne 1b +2: +#else + lsr.l #2,%d1 + jra 2f +1: move.l (%a1)+, (%a0)+ +2: dbra %d1,1b +#endif + /* + %a2+24 return address + %a2+20 PLT1 + %a2+16 PLT2 + %a2+12 %sp + %a2+8 %a1 + %a2+4 %a0 + %a2 %a2 + %sp copied stack frame + */ + + move.l 4(%a2), %a0 + move.l 8(%a2), %a1 +#ifdef __mcoldfire__ + pea 2f(%pc) + move.l %d0,-(%sp) + rts +2: +#else + jsr (%d0) +#endif + move.l %a2, %sp + cfi_def_cfa_register (%sp) + move.l (%sp)+, %a2 + cfi_adjust_cfa_offset (4) + cfi_restore (%a2) + /* + +20 return address + +16 PLT1 + +12 PLT2 + +8 %sp + +4 %a1 + %sp %a0 + */ +#ifdef __mcoldfire__ + fmove.d %fp0, -(%sp) + cfi_adjust_cfa_offset (8) +#else + fmove.x %fp0, -(%sp) + cfi_adjust_cfa_offset (12) +#endif + move.l %a0, -(%sp) + cfi_adjust_cfa_offset (4) + move.l %d1, -(%sp) + cfi_adjust_cfa_offset (4) + move.l %d0, -(%sp) + cfi_adjust_cfa_offset (4) + pea (%sp) + cfi_adjust_cfa_offset (4) +#ifdef __mcoldfire__ + pea 24(%sp) + cfi_adjust_cfa_offset (4) + move.l 40(%sp), -(%sp) + cfi_adjust_cfa_offset (4) + move.l 40(%sp), -(%sp) + cfi_adjust_cfa_offset (4) +#else + pea 28(%sp) + cfi_adjust_cfa_offset (4) + move.l 44(%sp), -(%sp) + cfi_adjust_cfa_offset (4) + move.l 44(%sp), -(%sp) + cfi_adjust_cfa_offset (4) +#endif + jbsr _dl_call_pltexit + lea 16(%sp), %sp + cfi_adjust_cfa_offset (-16) + move.l (%sp)+, %d0 + cfi_adjust_cfa_offset (-4) + move.l (%sp)+, %d1 + cfi_adjust_cfa_offset (-4) + move.l (%sp)+, %a0 + cfi_adjust_cfa_offset (-4) +#ifdef __mcoldfire__ + fmove.d (%sp)+, %fp0 + cfi_adjust_cfa_offset (-8) +#else + fmove.x (%sp)+, %fp0 + cfi_adjust_cfa_offset (-12) +#endif + lea 20(%sp), %sp + cfi_adjust_cfa_offset (-20) + rts + cfi_endproc + .size _dl_runtime_profile, . - _dl_runtime_profile diff --git a/ports/sysdeps/m68k/ffs.c b/ports/sysdeps/m68k/ffs.c new file mode 100644 index 0000000000..3f45a03eaf --- /dev/null +++ b/ports/sysdeps/m68k/ffs.c @@ -0,0 +1,47 @@ +/* ffs -- find first set bit in a word, counted from least significant end. + For mc68020, mc68030, mc68040. + This file is part of the GNU C Library. + Copyright (C) 1991, 1992, 1997, 1998, 2004, 2005 Free Software Foundation, Inc. + Contributed by Torbjorn Granlund (tege@sics.se). + + 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, see + <http://www.gnu.org/licenses/>. */ + +#define ffsl __something_else +#include <string.h> + +#undef ffs + +#if defined (__GNUC__) && defined (__mc68020__) + +int +__ffs (x) + int x; +{ + int cnt; + + asm ("bfffo %1{#0:#0},%0" : "=d" (cnt) : "dm" (x & -x)); + + return 32 - cnt; +} +weak_alias (__ffs, ffs) +libc_hidden_builtin_def (ffs) +#undef ffsl +weak_alias (__ffs, ffsl) + +#else + +#include <string/ffs.c> + +#endif diff --git a/ports/sysdeps/m68k/fpu/bits/fenv.h b/ports/sysdeps/m68k/fpu/bits/fenv.h new file mode 100644 index 0000000000..c98365acdc --- /dev/null +++ b/ports/sysdeps/m68k/fpu/bits/fenv.h @@ -0,0 +1,78 @@ +/* Copyright (C) 1997, 1998, 1999, 2000, 2012 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, see + <http://www.gnu.org/licenses/>. */ + +#ifndef _FENV_H +# error "Never use <bits/fenv.h> directly; include <fenv.h> instead." +#endif + + +/* Define bits representing the exception. We use the bit positions of + the appropriate bits in the FPSR Accrued Exception Byte. */ +enum + { + FE_INEXACT = 1 << 3, +#define FE_INEXACT FE_INEXACT + FE_DIVBYZERO = 1 << 4, +#define FE_DIVBYZERO FE_DIVBYZERO + FE_UNDERFLOW = 1 << 5, +#define FE_UNDERFLOW FE_UNDERFLOW + FE_OVERFLOW = 1 << 6, +#define FE_OVERFLOW FE_OVERFLOW + FE_INVALID = 1 << 7 +#define FE_INVALID FE_INVALID + }; + +#define FE_ALL_EXCEPT \ + (FE_INEXACT | FE_DIVBYZERO | FE_UNDERFLOW | FE_OVERFLOW | FE_INVALID) + +/* The m68k FPU supports all of the four defined rounding modes. We use + the bit positions in the FPCR Mode Control Byte as the values for the + appropriate macros. */ +enum + { + FE_TONEAREST = 0, +#define FE_TONEAREST FE_TONEAREST + FE_TOWARDZERO = 1 << 4, +#define FE_TOWARDZERO FE_TOWARDZERO + FE_DOWNWARD = 2 << 4, +#define FE_DOWNWARD FE_DOWNWARD + FE_UPWARD = 3 << 4 +#define FE_UPWARD FE_UPWARD + }; + + +/* Type representing exception flags. */ +typedef unsigned int fexcept_t; + + +/* Type representing floating-point environment. This structure + corresponds to the layout of the block written by `fmovem'. */ +typedef struct + { + unsigned int __control_register; + unsigned int __status_register; + unsigned int __instruction_address; + } +fenv_t; + +/* If the default argument is used we use this value. */ +#define FE_DFL_ENV ((const fenv_t *) -1) + +#ifdef __USE_GNU +/* Floating-point environment where none of the exceptions are masked. */ +# define FE_NOMASK_ENV ((const fenv_t *) -2) +#endif diff --git a/ports/sysdeps/m68k/fpu/fclrexcpt.c b/ports/sysdeps/m68k/fpu/fclrexcpt.c new file mode 100644 index 0000000000..ceda99cb98 --- /dev/null +++ b/ports/sysdeps/m68k/fpu/fclrexcpt.c @@ -0,0 +1,49 @@ +/* Clear given exceptions in current floating-point environment. + Copyright (C) 1997,99,2000,01 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 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, see + <http://www.gnu.org/licenses/>. */ + +#include <fenv.h> + +int +__feclearexcept (int excepts) +{ + fexcept_t fpsr; + + /* Mask out unsupported bits/exceptions. */ + excepts &= FE_ALL_EXCEPT; + + /* Fetch the fpu status register. */ + __asm__ ("fmove%.l %/fpsr,%0" : "=dm" (fpsr)); + + /* Clear the relevant bits. */ + fpsr &= ~excepts; + + /* Put the new data in effect. */ + __asm__ __volatile__ ("fmove%.l %0,%/fpsr" : : "dm" (fpsr)); + + /* Success. */ + return 0; +} + +#include <shlib-compat.h> +#if SHLIB_COMPAT (libm, GLIBC_2_1, GLIBC_2_2) +strong_alias (__feclearexcept, __old_feclearexcept) +compat_symbol (libm, __old_feclearexcept, feclearexcept, GLIBC_2_1); +#endif + +versioned_symbol (libm, __feclearexcept, feclearexcept, GLIBC_2_2); diff --git a/ports/sysdeps/m68k/fpu/fedisblxcpt.c b/ports/sysdeps/m68k/fpu/fedisblxcpt.c new file mode 100644 index 0000000000..a9a2df6688 --- /dev/null +++ b/ports/sysdeps/m68k/fpu/fedisblxcpt.c @@ -0,0 +1,38 @@ +/* Disable floating-point exceptions. + Copyright (C) 2000 Free Software Foundation, Inc. + This file is part of the GNU C Library. + Contributed by Andreas Schwab <schwab@suse.de>, 2000. + + 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, see + <http://www.gnu.org/licenses/>. */ + +#include <fenv.h> + +int +fedisableexcept (int excepts) +{ + unsigned int old_exc, new_exc; + + /* Get the current control register contents. */ + __asm__ ("fmove%.l %!,%0" : "=dm" (new_exc)); + + old_exc = (new_exc >> 6) & FE_ALL_EXCEPT; + + excepts &= FE_ALL_EXCEPT; + + new_exc &= ~(excepts << 6); + __asm__ ("fmove%.l %0,%!" : : "dm" (new_exc)); + + return old_exc; +} diff --git a/ports/sysdeps/m68k/fpu/feenablxcpt.c b/ports/sysdeps/m68k/fpu/feenablxcpt.c new file mode 100644 index 0000000000..e18c79e74b --- /dev/null +++ b/ports/sysdeps/m68k/fpu/feenablxcpt.c @@ -0,0 +1,38 @@ +/* Enable floating-point exceptions. + Copyright (C) 2000 Free Software Foundation, Inc. + This file is part of the GNU C Library. + Contributed by Andreas Schwab <schwab@suse.de>, 2000. + + 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, see + <http://www.gnu.org/licenses/>. */ + +#include <fenv.h> + +int +feenableexcept (int excepts) +{ + unsigned int new_exc, old_exc; + + /* Get the current control register contents. */ + __asm__ ("fmove%.l %!,%0" : "=dm" (new_exc)); + + old_exc = (new_exc >> 6) & FE_ALL_EXCEPT; + + excepts &= FE_ALL_EXCEPT; + + new_exc |= excepts << 6; + __asm__ ("fmove%.l %0,%!" : : "dm" (new_exc)); + + return old_exc; +} diff --git a/ports/sysdeps/m68k/fpu/fegetenv.c b/ports/sysdeps/m68k/fpu/fegetenv.c new file mode 100644 index 0000000000..84838a2cff --- /dev/null +++ b/ports/sysdeps/m68k/fpu/fegetenv.c @@ -0,0 +1,44 @@ +/* Store current floating-point environment. + Copyright (C) 1997,99,2000,01,10 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 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, see + <http://www.gnu.org/licenses/>. */ + +#include <fenv.h> + +int +__fegetenv (fenv_t *envp) +{ +#ifdef __mcoldfire__ + __asm__ ("fmove%.l %/fpcr,%0" : "=dm" (envp->__control_register)); + __asm__ ("fmove%.l %/fpsr,%0" : "=dm" (envp->__status_register)); + __asm__ ("fmove%.l %/fpiar,%0" : "=dm" (envp->__instruction_address)); +#else + __asm__ ("fmovem%.l %/fpcr/%/fpsr/%/fpiar,%0" : "=m" (*envp)); +#endif + + /* Success. */ + return 0; +} + +#include <shlib-compat.h> +#if SHLIB_COMPAT (libm, GLIBC_2_1, GLIBC_2_2) +strong_alias (__fegetenv, __old_fegetenv) +compat_symbol (libm, __old_fegetenv, fegetenv, GLIBC_2_1); +#endif + +libm_hidden_ver (__fegetenv, fegetenv) +versioned_symbol (libm, __fegetenv, fegetenv, GLIBC_2_2); diff --git a/ports/sysdeps/m68k/fpu/fegetexcept.c b/ports/sysdeps/m68k/fpu/fegetexcept.c new file mode 100644 index 0000000000..d735884e2a --- /dev/null +++ b/ports/sysdeps/m68k/fpu/fegetexcept.c @@ -0,0 +1,31 @@ +/* Get enabled floating-point exceptions. + Copyright (C) 2000 Free Software Foundation, Inc. + This file is part of the GNU C Library. + Contributed by Andreas Schwab <schwab@suse.de>, 2000. + + 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, see + <http://www.gnu.org/licenses/>. */ + +#include <fenv.h> + +int +fegetexcept (void) +{ + unsigned int exc; + + /* Get the current control register contents. */ + __asm__ ("fmove%.l %!,%0" : "=dm" (exc)); + + return (exc >> 6) & FE_ALL_EXCEPT; +} diff --git a/ports/sysdeps/m68k/fpu/fegetround.c b/ports/sysdeps/m68k/fpu/fegetround.c new file mode 100644 index 0000000000..7d09e0fd37 --- /dev/null +++ b/ports/sysdeps/m68k/fpu/fegetround.c @@ -0,0 +1,30 @@ +/* Return current rounding direction. + 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 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, see + <http://www.gnu.org/licenses/>. */ + +#include <fenv.h> + +int +fegetround (void) +{ + int fpcr; + + __asm__ ("fmove%.l %!,%0" : "=dm" (fpcr)); + + return fpcr & FE_UPWARD; +} diff --git a/ports/sysdeps/m68k/fpu/feholdexcpt.c b/ports/sysdeps/m68k/fpu/feholdexcpt.c new file mode 100644 index 0000000000..c58de5b972 --- /dev/null +++ b/ports/sysdeps/m68k/fpu/feholdexcpt.c @@ -0,0 +1,45 @@ +/* Store current floating-point environment and clear exceptions. + Copyright (C) 1997, 1999 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 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, see + <http://www.gnu.org/licenses/>. */ + +#include <fenv.h> + +int +feholdexcept (fenv_t *envp) +{ + fexcept_t fpcr, fpsr; + + /* Store the environment. */ +#ifdef __mcoldfire__ + __asm__ ("fmove%.l %/fpcr,%0" : "=dm" (envp->__control_register)); + __asm__ ("fmove%.l %/fpsr,%0" : "=dm" (envp->__status_register)); + __asm__ ("fmove%.l %/fpiar,%0" : "=dm" (envp->__instruction_address)); +#else + __asm__ ("fmovem%.l %/fpcr/%/fpsr/%/fpiar,%0" : "=m" (*envp)); +#endif + + /* Now clear all exceptions. */ + fpsr = envp->__status_register & ~FE_ALL_EXCEPT; + __asm__ __volatile__ ("fmove%.l %0,%/fpsr" : : "dm" (fpsr)); + /* And set all exceptions to non-stop. */ + fpcr = envp->__control_register & ~(FE_ALL_EXCEPT << 6); + __asm__ __volatile__ ("fmove%.l %0,%!" : : "dm" (fpcr)); + + return 0; +} +libm_hidden_def (feholdexcept); diff --git a/ports/sysdeps/m68k/fpu/fesetenv.c b/ports/sysdeps/m68k/fpu/fesetenv.c new file mode 100644 index 0000000000..1186010adc --- /dev/null +++ b/ports/sysdeps/m68k/fpu/fesetenv.c @@ -0,0 +1,74 @@ +/* Install given floating-point environment. + Copyright (C) 1997,99,2000,01,02 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 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, see + <http://www.gnu.org/licenses/>. */ + +#include <fenv.h> + +int +__fesetenv (const fenv_t *envp) +{ + fenv_t temp; + + /* Install the environment specified by ENVP. But there are a few + values which we do not want to come from the saved environment. + Therefore, we get the current environment and replace the values + we want to use from the environment specified by the parameter. */ +#ifdef __mcoldfire__ + __asm__ ("fmove%.l %/fpcr,%0" : "=dm" (temp.__control_register)); + __asm__ ("fmove%.l %/fpsr,%0" : "=dm" (temp.__status_register)); + __asm__ ("fmove%.l %/fpiar,%0" : "=dm" (temp.__instruction_address)); +#else + __asm__ ("fmovem%.l %/fpcr/%/fpsr/%/fpiar,%0" : "=m" (*&temp)); +#endif + + temp.__status_register &= ~FE_ALL_EXCEPT; + temp.__control_register &= ~((FE_ALL_EXCEPT << 6) | FE_UPWARD); + if (envp == FE_DFL_ENV) + ; + else if (envp == FE_NOMASK_ENV) + temp.__control_register |= FE_ALL_EXCEPT << 6; + else + { + temp.__control_register |= (envp->__control_register + & ((FE_ALL_EXCEPT << 6) | FE_UPWARD)); + temp.__status_register |= envp->__status_register & FE_ALL_EXCEPT; + } + +#ifdef __mcoldfire__ + __asm__ __volatile__ ("fmove%.l %0,%/fpiar" + :: "dm" (temp.__instruction_address)); + __asm__ __volatile__ ("fmove%.l %0,%/fpcr" + :: "dm" (temp.__control_register)); + __asm__ __volatile__ ("fmove%.l %0,%/fpsr" + :: "dm" (temp.__status_register)); +#else + __asm__ __volatile__ ("fmovem%.l %0,%/fpcr/%/fpsr/%/fpiar" : : "m" (*&temp)); +#endif + + /* Success. */ + return 0; +} + +#include <shlib-compat.h> +#if SHLIB_COMPAT (libm, GLIBC_2_1, GLIBC_2_2) +strong_alias (__fesetenv, __old_fesetenv) +compat_symbol (libm, __old_fesetenv, fesetenv, GLIBC_2_1); +#endif + +libm_hidden_ver (__fesetenv, fesetenv) +versioned_symbol (libm, __fesetenv, fesetenv, GLIBC_2_2); diff --git a/ports/sysdeps/m68k/fpu/fesetround.c b/ports/sysdeps/m68k/fpu/fesetround.c new file mode 100644 index 0000000000..bfc463d07a --- /dev/null +++ b/ports/sysdeps/m68k/fpu/fesetround.c @@ -0,0 +1,38 @@ +/* Set current rounding direction. + 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 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, see + <http://www.gnu.org/licenses/>. */ + +#include <fenv.h> + +int +fesetround (int round) +{ + fexcept_t fpcr; + + if (round & ~FE_UPWARD) + /* ROUND is no valid rounding mode. */ + return 1; + + __asm__ ("fmove%.l %!,%0" : "=dm" (fpcr)); + fpcr &= ~FE_UPWARD; + fpcr |= round; + __asm__ __volatile__ ("fmove%.l %0,%!" : : "dm" (fpcr)); + + return 0; +} +libm_hidden_def (fesetround); diff --git a/ports/sysdeps/m68k/fpu/feupdateenv.c b/ports/sysdeps/m68k/fpu/feupdateenv.c new file mode 100644 index 0000000000..dbfa3501f3 --- /dev/null +++ b/ports/sysdeps/m68k/fpu/feupdateenv.c @@ -0,0 +1,50 @@ +/* Install given floating-point environment and raise exceptions. + Copyright (C) 1997,1999-2001,2010 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 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, see + <http://www.gnu.org/licenses/>. */ + +#include <fenv.h> + +int +__feupdateenv (const fenv_t *envp) +{ + fexcept_t fpsr; + + /* Save current exceptions. */ + __asm__ ("fmove%.l %/fpsr,%0" : "=dm" (fpsr)); + fpsr &= FE_ALL_EXCEPT; + + /* Install new environment. */ + fesetenv (envp); + + /* Raise the saved exception. Incidently for us the implementation + defined format of the values in objects of type fexcept_t is the + same as the ones specified using the FE_* constants. */ + feraiseexcept ((int) fpsr); + + /* Success. */ + return 0; +} + +#include <shlib-compat.h> +#if SHLIB_COMPAT (libm, GLIBC_2_1, GLIBC_2_2) +strong_alias (__feupdateenv, __old_feupdateenv) +compat_symbol (libm, __old_feupdateenv, feupdateenv, GLIBC_2_1); +#endif + +libm_hidden_ver (__feupdateenv, feupdateenv) +versioned_symbol (libm, __feupdateenv, feupdateenv, GLIBC_2_2); diff --git a/ports/sysdeps/m68k/fpu/fgetexcptflg.c b/ports/sysdeps/m68k/fpu/fgetexcptflg.c new file mode 100644 index 0000000000..c6f277e490 --- /dev/null +++ b/ports/sysdeps/m68k/fpu/fgetexcptflg.c @@ -0,0 +1,42 @@ +/* Store current representation for exceptions. + Copyright (C) 1997,99,2000,01 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 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, see + <http://www.gnu.org/licenses/>. */ + +#include <fenv.h> + +int +__fegetexceptflag (fexcept_t *flagp, int excepts) +{ + fexcept_t fpsr; + + /* Get the current exceptions. */ + __asm__ ("fmove%.l %/fpsr,%0" : "=dm" (fpsr)); + + *flagp = fpsr & excepts & FE_ALL_EXCEPT; + + /* Success. */ + return 0; +} + +#include <shlib-compat.h> +#if SHLIB_COMPAT (libm, GLIBC_2_1, GLIBC_2_2) +strong_alias (__fegetexceptflag, __old_fegetexceptflag) +compat_symbol (libm, __old_fegetexceptflag, fegetexceptflag, GLIBC_2_1); +#endif + +versioned_symbol (libm, __fegetexceptflag, fegetexceptflag, GLIBC_2_2); diff --git a/ports/sysdeps/m68k/fpu/fsetexcptflg.c b/ports/sysdeps/m68k/fpu/fsetexcptflg.c new file mode 100644 index 0000000000..dca265f0b8 --- /dev/null +++ b/ports/sysdeps/m68k/fpu/fsetexcptflg.c @@ -0,0 +1,48 @@ +/* Set floating-point environment exception handling. + Copyright (C) 1997,99,2000,01 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 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, see + <http://www.gnu.org/licenses/>. */ + +#include <fenv.h> +#include <math.h> + +int +__fesetexceptflag (const fexcept_t *flagp, int excepts) +{ + fexcept_t fpsr; + + /* Get the current status register. */ + __asm__ ("fmove%.l %/fpsr,%0" : "=dm" (fpsr)); + + /* Install the new exception bits in the Accrued Exception Byte. */ + fpsr &= ~(excepts & FE_ALL_EXCEPT); + fpsr |= *flagp & excepts & FE_ALL_EXCEPT; + + /* Store the new status register. */ + __asm__ __volatile__ ("fmove%.l %0,%/fpsr" : : "dm" (fpsr)); + + /* Success. */ + return 0; +} + +#include <shlib-compat.h> +#if SHLIB_COMPAT (libm, GLIBC_2_1, GLIBC_2_2) +strong_alias (__fesetexceptflag, __old_fesetexceptflag) +compat_symbol (libm, __old_fesetexceptflag, fesetexceptflag, GLIBC_2_1); +#endif + +versioned_symbol (libm, __fesetexceptflag, fesetexceptflag, GLIBC_2_2); diff --git a/ports/sysdeps/m68k/fpu/ftestexcept.c b/ports/sysdeps/m68k/fpu/ftestexcept.c new file mode 100644 index 0000000000..535d0eabc7 --- /dev/null +++ b/ports/sysdeps/m68k/fpu/ftestexcept.c @@ -0,0 +1,32 @@ +/* Test exception in current environment. + Copyright (C) 1997, 2010 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 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, see + <http://www.gnu.org/licenses/>. */ + +#include <fenv.h> + +int +fetestexcept (int excepts) +{ + fexcept_t fpsr; + + /* Get current exceptions. */ + __asm__ ("fmove%.l %/fpsr,%0" : "=dm" (fpsr)); + + return fpsr & excepts & FE_ALL_EXCEPT; +} +libm_hidden_def (fetestexcept) diff --git a/ports/sysdeps/m68k/fpu_control.h b/ports/sysdeps/m68k/fpu_control.h new file mode 100644 index 0000000000..98eb80ec49 --- /dev/null +++ b/ports/sysdeps/m68k/fpu_control.h @@ -0,0 +1,108 @@ +/* 68k FPU control word definitions. + 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, see + <http://www.gnu.org/licenses/>. */ + +#ifndef _FPU_CONTROL_H +#define _FPU_CONTROL_H + +/* + * Motorola floating point control register bits. + * + * 31-16 -> reserved (read as 0, ignored on write) + * 15 -> enable trap for BSUN exception + * 14 -> enable trap for SNAN exception + * 13 -> enable trap for OPERR exception + * 12 -> enable trap for OVFL exception + * 11 -> enable trap for UNFL exception + * 10 -> enable trap for DZ exception + * 9 -> enable trap for INEX2 exception (INEX on Coldfire) + * 8 -> enable trap for INEX1 exception (IDE on Coldfire) + * 7-6 -> Precision Control (only bit 6 is used on Coldfire) + * 5-4 -> Rounding Control + * 3-0 -> zero (read as 0, write as 0) + * + * + * Precision Control: + * 00 - round to extended precision + * 01 - round to single precision + * 10 - round to double precision + * 11 - undefined + * + * Rounding Control: + * 00 - rounding to nearest (RN) + * 01 - rounding toward zero (RZ) + * 10 - rounding (down)toward minus infinity (RM) + * 11 - rounding (up) toward plus infinity (RP) + * + * The hardware default is 0x0000. I choose 0x5400. + */ + +#include <features.h> + +/* masking of interrupts */ +#define _FPU_MASK_BSUN 0x8000 +#define _FPU_MASK_SNAN 0x4000 +#define _FPU_MASK_OPERR 0x2000 +#define _FPU_MASK_OVFL 0x1000 +#define _FPU_MASK_UNFL 0x0800 +#define _FPU_MASK_DZ 0x0400 +#define _FPU_MASK_INEX1 0x0200 +#define _FPU_MASK_INEX2 0x0100 + +/* precision control */ +#ifdef __mcoldfire__ +#define _FPU_DOUBLE 0x00 +#else +#define _FPU_EXTENDED 0x00 /* RECOMMENDED */ +#define _FPU_DOUBLE 0x80 +#endif +#define _FPU_SINGLE 0x40 /* DO NOT USE */ + +/* rounding control */ +#define _FPU_RC_NEAREST 0x00 /* RECOMMENDED */ +#define _FPU_RC_ZERO 0x10 +#define _FPU_RC_DOWN 0x20 +#define _FPU_RC_UP 0x30 + +#ifdef __mcoldfire__ +#define _FPU_RESERVED 0xFFFF800F +#else +#define _FPU_RESERVED 0xFFFF000F /* Reserved bits in fpucr */ +#endif + + +/* Now two recommended fpucr */ + +/* The fdlibm code requires no interrupts for exceptions. Don't + change the rounding mode, it would break long double I/O! */ +#define _FPU_DEFAULT 0x00000000 + +/* IEEE: same as above, but exceptions. We must make it non-zero so + that __setfpucw works. This bit will be ignored. */ +#define _FPU_IEEE 0x00000001 + +/* 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) __asm__ ("fmove%.l %!, %0" : "=dm" (cw)) +#define _FPU_SETCW(cw) __asm__ volatile ("fmove%.l %0, %!" : : "dm" (cw)) + +/* Default control word set at startup. */ +extern fpu_control_t __fpu_control; + +#endif /* _M68K_FPU_CONTROL_H */ diff --git a/ports/sysdeps/m68k/gccframe.h b/ports/sysdeps/m68k/gccframe.h new file mode 100644 index 0000000000..539f0bce66 --- /dev/null +++ b/ports/sysdeps/m68k/gccframe.h @@ -0,0 +1,21 @@ +/* Definition of object in frame unwind info. m68k version. + Copyright (C) 2001 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, see + <http://www.gnu.org/licenses/>. */ + +#define FIRST_PSEUDO_REGISTER 24 + +#include <sysdeps/generic/gccframe.h> diff --git a/ports/sysdeps/m68k/jmpbuf-unwind.h b/ports/sysdeps/m68k/jmpbuf-unwind.h new file mode 100644 index 0000000000..534aa90a25 --- /dev/null +++ b/ports/sysdeps/m68k/jmpbuf-unwind.h @@ -0,0 +1,45 @@ +/* Examine __jmp_buf for unwinding frames. m68k version. + Copyright (C) 2006, 2010 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, see + <http://www.gnu.org/licenses/>. */ + +#include <setjmp.h> +#include <stdint.h> +#include <unwind.h> + +/* Test if longjmp to JMPBUF would unwind the frame + containing a local variable at ADDRESS. */ +#define _JMPBUF_UNWINDS(jmpbuf, address, demangle) \ + ((void *) (address) < (void *) demangle ((jmpbuf)->__sp)) + +#define _JMPBUF_CFA_UNWINDS_ADJ(_jmpbuf, _context, _adj) \ + _JMPBUF_UNWINDS_ADJ (_jmpbuf, (void *) _Unwind_GetCFA (_context), _adj) + +static inline uintptr_t __attribute__ ((unused)) +_jmpbuf_sp (__jmp_buf regs) +{ + uintptr_t sp = regs[0].__sp; +#ifdef PTR_DEMANGLE + PTR_DEMANGLE (sp); +#endif + return sp; +} + +#define _JMPBUF_UNWINDS_ADJ(_jmpbuf, _address, _adj) \ + ((uintptr_t) (_address) - (_adj) < _jmpbuf_sp (_jmpbuf) - (_adj)) + +/* We use the normal longjmp for unwinding. */ +#define __libc_unwind_longjmp(buf, val) __libc_longjmp (buf, val) diff --git a/ports/sysdeps/m68k/ldsodefs.h b/ports/sysdeps/m68k/ldsodefs.h new file mode 100644 index 0000000000..bc8d540990 --- /dev/null +++ b/ports/sysdeps/m68k/ldsodefs.h @@ -0,0 +1,42 @@ +/* Run-time dynamic linker data structures for loaded ELF shared objects. + Copyright (C) 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, see + <http://www.gnu.org/licenses/>. */ + +#ifndef __LDSODEFS_H + +#include <elf.h> + +struct La_m68k_regs; +struct La_m68k_retval; + +#define ARCH_PLTENTER_MEMBERS \ + Elf32_Addr (*m68k_gnu_pltenter) (Elf32_Sym *, unsigned int, \ + uintptr_t *, uintptr_t *, \ + const struct La_m68k_regs *, \ + unsigned int *, const char *name, \ + long int *framesizep); + +#define ARCH_PLTEXIT_MEMBERS \ + unsigned int (*m68k_gnu_pltexit) (Elf32_Sym *, unsigned int, \ + uintptr_t *, uintptr_t *, \ + const struct La_m68k_regs *, \ + struct La_m68k_retval *, \ + const char *); + +#include_next <ldsodefs.h> + +#endif diff --git a/ports/sysdeps/m68k/libc-tls.c b/ports/sysdeps/m68k/libc-tls.c new file mode 100644 index 0000000000..6abb64d07c --- /dev/null +++ b/ports/sysdeps/m68k/libc-tls.c @@ -0,0 +1,33 @@ +/* Thread-local storage handling in the ELF dynamic linker. m68k version. + Copyright (C) 2010, 2011 Free Software Foundation, Inc. + This file is part of the GNU C Library. + Contributed by Maxim Kuvyrkov <maxim@codesourcery.com>, 2010. + + 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, see + <http://www.gnu.org/licenses/>. */ + +#include <csu/libc-tls.c> +#include <dl-tls.h> + +/* On M68K, linker optimizations are not required, so __tls_get_addr + can be called even in statically linked binaries. In this case module + must be always 1 and PT_TLS segment exist in the binary, otherwise it + would not link. */ + +void * +__tls_get_addr (tls_index *ti) +{ + dtv_t *dtv = THREAD_DTV (); + return (char *) dtv[1].pointer.val + GET_ADDR_OFFSET; +} diff --git a/ports/sysdeps/m68k/m680x0/Implies b/ports/sysdeps/m68k/m680x0/Implies new file mode 100644 index 0000000000..abf356d9e8 --- /dev/null +++ b/ports/sysdeps/m68k/m680x0/Implies @@ -0,0 +1 @@ +ieee754/ldbl-96 diff --git a/ports/sysdeps/m68k/m680x0/Makefile b/ports/sysdeps/m68k/m680x0/Makefile new file mode 100644 index 0000000000..582fa6f900 --- /dev/null +++ b/ports/sysdeps/m68k/m680x0/Makefile @@ -0,0 +1,2 @@ +# The 68k `long double' is a distinct type we support. +long-double-fcts = yes diff --git a/ports/sysdeps/m68k/m680x0/add_n.S b/ports/sysdeps/m68k/m680x0/add_n.S new file mode 100644 index 0000000000..22f97ecea0 --- /dev/null +++ b/ports/sysdeps/m68k/m680x0/add_n.S @@ -0,0 +1,82 @@ +/* mc68020 __mpn_add_n -- Add two limb vectors of the same length > 0 and store + sum in a third limb vector. + +Copyright (C) 1992, 1994, 1996, 1998, 2012 Free Software Foundation, Inc. + +This file is part of the GNU MP Library. + +The GNU MP 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 MP 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 MP Library. If not, see <http://www.gnu.org/licenses/>. */ + +/* + INPUT PARAMETERS + res_ptr (sp + 4) + s1_ptr (sp + 8) + s2_ptr (sp + 16) + size (sp + 12) +*/ + +#include "sysdep.h" +#include "asm-syntax.h" + + TEXT +ENTRY(__mpn_add_n) +/* Save used registers on the stack. */ + movel R(d2),MEM_PREDEC(sp) + cfi_adjust_cfa_offset (4) + movel R(a2),MEM_PREDEC(sp) + cfi_adjust_cfa_offset (4) + cfi_rel_offset (R(d2), 4) + cfi_rel_offset (R(a2), 0) + +/* Copy the arguments to registers. Better use movem? */ + movel MEM_DISP(sp,12),R(a2) + movel MEM_DISP(sp,16),R(a0) + movel MEM_DISP(sp,20),R(a1) + movel MEM_DISP(sp,24),R(d2) + + eorw #1,R(d2) + lsrl #1,R(d2) + bcc L(L1) + subql #1,R(d2) /* clears cy as side effect */ + +L(Loop:) + movel MEM_POSTINC(a0),R(d0) + movel MEM_POSTINC(a1),R(d1) + addxl R(d1),R(d0) + movel R(d0),MEM_POSTINC(a2) +L(L1:) movel MEM_POSTINC(a0),R(d0) + movel MEM_POSTINC(a1),R(d1) + addxl R(d1),R(d0) + movel R(d0),MEM_POSTINC(a2) + + dbf R(d2),L(Loop) /* loop until 16 lsb of %4 == -1 */ + subxl R(d0),R(d0) /* d0 <= -cy; save cy as 0 or -1 in d0 */ + subl #0x10000,R(d2) + bcs L(L2) + addl R(d0),R(d0) /* restore cy */ + bra L(Loop) + +L(L2:) + negl R(d0) + +/* Restore used registers from stack frame. */ + movel MEM_POSTINC(sp),R(a2) + cfi_adjust_cfa_offset (-4) + cfi_restore (R(a2)) + movel MEM_POSTINC(sp),R(d2) + cfi_adjust_cfa_offset (-4) + cfi_restore (R(d2)) + + rts +END(__mpn_add_n) diff --git a/ports/sysdeps/m68k/m680x0/bits/huge_vall.h b/ports/sysdeps/m68k/m680x0/bits/huge_vall.h new file mode 100644 index 0000000000..fc7371b5db --- /dev/null +++ b/ports/sysdeps/m68k/m680x0/bits/huge_vall.h @@ -0,0 +1,42 @@ +/* `HUGE_VALL' constant for m68k (where it is infinity). + Used by <stdlib.h> and <math.h> functions for overflow. + Copyright (C) 1992, 1995, 1996, 1997, 1999, 2000, 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, see + <http://www.gnu.org/licenses/>. */ + +#ifndef _MATH_H +# error "Never use <bits/huge_val.h> directly; include <math.h> instead." +#endif + +#if __GNUC_PREREQ(3,3) +# define HUGE_VALL (__builtin_huge_vall ()) +#elif __GNUC_PREREQ(2,96) +# define HUGE_VALL (__extension__ 0x1.0p32767L) +#elif defined__GNUC__ + +# define HUGE_VALL \ + (__extension__ \ + ((union { unsigned long __l[3]; long double __ld; }) \ + { __l: { 0x7fff0000UL, 0x80000000UL, 0UL } }).__ld) + +#else /* not GCC */ + +static union { unsigned char __c[12]; long double __ld; } __huge_vall = + { { 0x7f, 0xff, 0, 0, 0x80, 0, 0, 0, 0, 0, 0, 0 } }; +# define HUGE_VALL (__huge_vall.__ld) + +#endif /* GCC 2.95. */ diff --git a/ports/sysdeps/m68k/m680x0/bits/mathdef.h b/ports/sysdeps/m68k/m680x0/bits/mathdef.h new file mode 100644 index 0000000000..a6edcc060e --- /dev/null +++ b/ports/sysdeps/m68k/m680x0/bits/mathdef.h @@ -0,0 +1,37 @@ +/* Copyright (C) 1997, 1998, 1999, 2000, 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, see + <http://www.gnu.org/licenses/>. */ + +#if !defined _MATH_H && !defined _COMPLEX_H +# error "Never use <bits/mathdef.h> directly; include <math.h> instead" +#endif + +#if defined __USE_ISOC99 && defined _MATH_H && !defined _MATH_H_MATHDEF +# define _MATH_H_MATHDEF 1 + +/* The m68k FPUs evaluate all values in the 96 bit floating-point format + which is also available for the user as `long double'. Therefore we + define: */ +typedef long double float_t; /* `float' expressions are evaluated as + `long double'. */ +typedef long double double_t; /* `double' expressions are evaluated as + `long double'. */ + +/* The values returned by `ilogb' for 0 and NaN respectively. */ +# define FP_ILOGB0 (-2147483647 - 1) +# define FP_ILOGBNAN (2147483647) + +#endif /* ISO C99 */ diff --git a/ports/sysdeps/m68k/m680x0/fpu/bits/mathinline.h b/ports/sysdeps/m68k/m680x0/fpu/bits/mathinline.h new file mode 100644 index 0000000000..ffcc39edfd --- /dev/null +++ b/ports/sysdeps/m68k/m680x0/fpu/bits/mathinline.h @@ -0,0 +1,444 @@ +/* Definitions of inline math functions implemented by the m68881/2. + Copyright (C) 1991,92,93,94,96,97,98,99,2000,2002, 2003, 2004, 2008, 2010, 2012 + 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, see + <http://www.gnu.org/licenses/>. */ + +#ifndef _MATH_H +# error "Never use <bits/mathinline.h> directly; include <math.h> instead." +#endif + +#ifndef __extern_inline +# define __MATH_INLINE __inline +#else +# define __MATH_INLINE __extern_inline +#endif + +#ifdef __GNUC__ + +#ifdef __USE_ISOC99 +/* GCC 3.1 and up have builtins that actually can be used. */ +# if !__GNUC_PREREQ (3,1) +/* ISO C99 defines some macros to perform unordered comparisons. The + m68k FPU supports this with special opcodes and we should use them. + These must not be inline functions since we have to be able to handle + all floating-point types. */ +# undef isgreater +# undef isgreaterequal +# undef isless +# undef islessequal +# undef islessgreater +# undef isunordered +# define isgreater(x, y) \ + __extension__ \ + ({ char __result; \ + __asm__ ("fcmp%.x %2,%1; fsogt %0" \ + : "=dm" (__result) : "f" (x), "f" (y)); \ + __result != 0; }) + +# define isgreaterequal(x, y) \ + __extension__ \ + ({ char __result; \ + __asm__ ("fcmp%.x %2,%1; fsoge %0" \ + : "=dm" (__result) : "f" (x), "f" (y)); \ + __result != 0; }) + +# define isless(x, y) \ + __extension__ \ + ({ char __result; \ + __asm__ ("fcmp%.x %2,%1; fsolt %0" \ + : "=dm" (__result) : "f" (x), "f" (y)); \ + __result != 0; }) + +# define islessequal(x, y) \ + __extension__ \ + ({ char __result; \ + __asm__ ("fcmp%.x %2,%1; fsole %0" \ + : "=dm" (__result) : "f" (x), "f" (y)); \ + __result != 0; }) + +# define islessgreater(x, y) \ + __extension__ \ + ({ char __result; \ + __asm__ ("fcmp%.x %2,%1; fsogl %0" \ + : "=dm" (__result) : "f" (x), "f" (y)); \ + __result != 0; }) + +# define isunordered(x, y) \ + __extension__ \ + ({ char __result; \ + __asm__ ("fcmp%.x %2,%1; fsun %0" \ + : "=dm" (__result) : "f" (x), "f" (y)); \ + __result != 0; }) +# endif /* GCC 3.1 */ + +/* 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; +} +__MATH_INLINE int +__NTH (__signbitl (long double __x)) +{ + __extension__ union { long double __d; int __i[3]; } __u = { __d: __x }; + return __u.__i[0] < 0; +} +#endif + + +#if (!defined __NO_MATH_INLINES && defined __OPTIMIZE__) \ + || defined __LIBC_INTERNAL_MATH_INLINES + +#ifdef __LIBC_INTERNAL_MATH_INLINES +/* This is used when defining the functions themselves. Define them with + __ names, and with `static inline' instead of `extern inline' so the + bodies will always be used, never an external function call. */ +# define __m81_u(x) __CONCAT(__,x) +# define __m81_inline static __inline +#else +# define __m81_u(x) x +# define __m81_inline __MATH_INLINE +# define __M81_MATH_INLINES 1 +#endif + +/* Define a const math function. */ +#define __m81_defun(rettype, func, args) \ + __m81_inline rettype __attribute__((__const__)) \ + __NTH (__m81_u(func) args) + +/* Define the three variants of a math function that has a direct + implementation in the m68k fpu. FUNC is the name for C (which will be + suffixed with f and l for the float and long double version, resp). OP + is the name of the fpu operation (without leading f). */ + +#if defined __USE_MISC || defined __USE_ISOC99 +# define __inline_mathop(func, op) \ + __inline_mathop1(double, func, op) \ + __inline_mathop1(float, __CONCAT(func,f), op) \ + __inline_mathop1(long double, __CONCAT(func,l), op) +#else +# define __inline_mathop(func, op) \ + __inline_mathop1(double, func, op) +#endif + +#define __inline_mathop1(float_type,func, op) \ + __m81_defun (float_type, func, (float_type __mathop_x)) \ + { \ + float_type __result; \ + __asm __volatile__ ("f" __STRING(op) "%.x %1, %0" \ + : "=f" (__result) : "f" (__mathop_x)); \ + return __result; \ + } + +__inline_mathop(__atan, atan) +__inline_mathop(__cos, cos) +__inline_mathop(__sin, sin) +__inline_mathop(__tan, tan) +__inline_mathop(__tanh, tanh) +__inline_mathop(__fabs, abs) + +#if defined __USE_MISC || defined __USE_XOPEN_EXTENDED || defined __USE_ISOC99 +__inline_mathop(__rint, int) +__inline_mathop(__expm1, etoxm1) +__inline_mathop(__log1p, lognp1) +#endif + +#ifdef __USE_MISC +__inline_mathop(__significand, getman) +#endif + +#ifdef __USE_ISOC99 +__inline_mathop(__trunc, intrz) +#endif + +#if !defined __NO_MATH_INLINES && defined __OPTIMIZE__ + +__inline_mathop(atan, atan) +__inline_mathop(tanh, tanh) + +# if defined __USE_MISC || defined __USE_XOPEN_EXTENDED || defined __USE_ISOC99 +__inline_mathop(rint, int) +__inline_mathop(log1p, lognp1) +# endif + +# ifdef __USE_MISC +__inline_mathop(significand, getman) +# endif + +# ifdef __USE_ISOC99 +__inline_mathop(trunc, intrz) +# endif + +#endif /* !__NO_MATH_INLINES && __OPTIMIZE__ */ + +/* This macro contains the definition for the rest of the inline + functions, using FLOAT_TYPE as the domain type and S as the suffix + for the function names. */ + +#define __inline_functions(float_type, s) \ +__m81_defun (float_type, __CONCAT(__floor,s), (float_type __x)) \ +{ \ + float_type __result; \ + unsigned long int __ctrl_reg; \ + __asm __volatile__ ("fmove%.l %!, %0" : "=dm" (__ctrl_reg)); \ + /* Set rounding towards negative infinity. */ \ + __asm __volatile__ ("fmove%.l %0, %!" : /* No outputs. */ \ + : "dmi" ((__ctrl_reg & ~0x10) | 0x20)); \ + /* Convert X to an integer, using -Inf rounding. */ \ + __asm __volatile__ ("fint%.x %1, %0" : "=f" (__result) : "f" (__x)); \ + /* Restore the previous rounding mode. */ \ + __asm __volatile__ ("fmove%.l %0, %!" : /* No outputs. */ \ + : "dmi" (__ctrl_reg)); \ + return __result; \ +} \ + \ +__m81_defun (float_type, __CONCAT(__ceil,s), (float_type __x)) \ +{ \ + float_type __result; \ + unsigned long int __ctrl_reg; \ + __asm __volatile__ ("fmove%.l %!, %0" : "=dm" (__ctrl_reg)); \ + /* Set rounding towards positive infinity. */ \ + __asm __volatile__ ("fmove%.l %0, %!" : /* No outputs. */ \ + : "dmi" (__ctrl_reg | 0x30)); \ + /* Convert X to an integer, using +Inf rounding. */ \ + __asm __volatile__ ("fint%.x %1, %0" : "=f" (__result) : "f" (__x)); \ + /* Restore the previous rounding mode. */ \ + __asm __volatile__ ("fmove%.l %0, %!" : /* No outputs. */ \ + : "dmi" (__ctrl_reg)); \ + return __result; \ +} + +__inline_functions(double,) +#if defined __USE_MISC || defined __USE_ISOC99 +__inline_functions(float,f) +__inline_functions(long double,l) +#endif +#undef __inline_functions + +#ifdef __USE_MISC + +# define __inline_functions(float_type, s) \ +__m81_defun (int, __CONCAT(__isinf,s), (float_type __value)) \ +{ \ + /* There is no branch-condition for infinity, \ + so we must extract and examine the condition codes manually. */ \ + unsigned long int __fpsr; \ + __asm ("ftst%.x %1\n" \ + "fmove%.l %/fpsr, %0" : "=dm" (__fpsr) : "f" (__value)); \ + return (__fpsr & (2 << 24)) ? (__fpsr & (8 << 24) ? -1 : 1) : 0; \ +} \ + \ +__m81_defun (int, __CONCAT(__finite,s), (float_type __value)) \ +{ \ + /* There is no branch-condition for infinity, so we must extract and \ + examine the condition codes manually. */ \ + unsigned long int __fpsr; \ + __asm ("ftst%.x %1\n" \ + "fmove%.l %/fpsr, %0" : "=dm" (__fpsr) : "f" (__value)); \ + return (__fpsr & (3 << 24)) == 0; \ +} \ + \ +__m81_defun (float_type, __CONCAT(__scalbn,s), \ + (float_type __x, int __n)) \ +{ \ + float_type __result; \ + __asm __volatile__ ("fscale%.l %1, %0" : "=f" (__result) \ + : "dmi" (__n), "0" (__x)); \ + return __result; \ +} + +__inline_functions(double,) +__inline_functions(float,f) +__inline_functions(long double,l) +# undef __inline_functions + +#endif /* Use misc. */ + +#if defined __USE_MISC || defined __USE_XOPEN + +# define __inline_functions(float_type, s) \ +__m81_defun (int, __CONCAT(__isnan,s), (float_type __value)) \ +{ \ + char __result; \ + __asm ("ftst%.x %1\n" \ + "fsun %0" : "=dm" (__result) : "f" (__value)); \ + return __result; \ +} + +__inline_functions(double,) +# ifdef __USE_MISC +__inline_functions(float,f) +__inline_functions(long double,l) +# endif +# undef __inline_functions + +#endif + +#ifdef __USE_ISOC99 + +# define __inline_functions(float_type, s) \ +__m81_defun (float_type, __CONCAT(__scalbln,s), \ + (float_type __x, long int __n)) \ +{ \ + return __CONCAT(__scalbn,s) (__x, __n); \ +} \ + \ +__m81_defun (float_type, __CONCAT(__nearbyint,s), (float_type __x)) \ +{ \ + float_type __result; \ + unsigned long int __ctrl_reg; \ + __asm __volatile__ ("fmove%.l %!, %0" : "=dm" (__ctrl_reg)); \ + /* Temporarily disable the inexact exception. */ \ + __asm __volatile__ ("fmove%.l %0, %!" : /* No outputs. */ \ + : "dmi" (__ctrl_reg & ~0x200)); \ + __asm __volatile__ ("fint%.x %1, %0" : "=f" (__result) : "f" (__x)); \ + __asm __volatile__ ("fmove%.l %0, %!" : /* No outputs. */ \ + : "dmi" (__ctrl_reg)); \ + return __result; \ +} \ + \ +__m81_defun (long int, __CONCAT(__lrint,s), (float_type __x)) \ +{ \ + long int __result; \ + __asm __volatile__ ("fmove%.l %1, %0" : "=dm" (__result) : "f" (__x)); \ + return __result; \ +} + +__inline_functions (double,) +__inline_functions (float,f) +__inline_functions (long double,l) +# undef __inline_functions + +#endif /* Use ISO C9x */ + +#ifdef __USE_GNU + +# define __inline_functions(float_type, s) \ +__m81_inline void \ +__NTH (__m81_u(__CONCAT(__sincos,s))(float_type __x, float_type *__sinx, \ + float_type *__cosx)) \ +{ \ + __asm __volatile__ ("fsincos%.x %2,%1:%0" \ + : "=f" (*__sinx), "=f" (*__cosx) : "f" (__x)); \ +} + +__inline_functions (double,) +__inline_functions (float,f) +__inline_functions (long double,l) +# undef __inline_functions + +#endif + +#if !defined __NO_MATH_INLINES && defined __OPTIMIZE__ + +/* Define inline versions of the user visible functions. */ + +/* Note that there must be no whitespace before the argument passed for + NAME, to make token pasting work correctly with -traditional. */ +# define __inline_forward_c(rettype, name, args1, args2) \ +__MATH_INLINE rettype __attribute__((__const__)) \ +__NTH (name args1) \ +{ \ + return __CONCAT(__,name) args2; \ +} + +# define __inline_forward(rettype, name, args1, args2) \ +__MATH_INLINE rettype __NTH (name args1) \ +{ \ + return __CONCAT(__,name) args2; \ +} + +__inline_forward_c(double,floor, (double __x), (__x)) +__inline_forward_c(double,ceil, (double __x), (__x)) +# ifdef __USE_MISC +# ifndef __USE_ISOC99 /* Conflict with macro of same name. */ +__inline_forward_c(int,isinf, (double __value), (__value)) +# endif +__inline_forward_c(int,finite, (double __value), (__value)) +__inline_forward_c(double,scalbn, (double __x, int __n), (__x, __n)) +# endif +# if defined __USE_MISC || defined __USE_XOPEN +# ifndef __USE_ISOC99 /* Conflict with macro of same name. */ +__inline_forward_c(int,isnan, (double __value), (__value)) +# endif +# endif +# ifdef __USE_ISOC99 +__inline_forward_c(double,scalbln, (double __x, long int __n), (__x, __n)) +__inline_forward_c(double,nearbyint, (double __value), (__value)) +__inline_forward_c(long int,lrint, (double __value), (__value)) +# endif +# ifdef __USE_GNU +__inline_forward(void,sincos, (double __x, double *__sinx, double *__cosx), + (__x, __sinx, __cosx)) +# endif + +# if defined __USE_MISC || defined __USE_ISOC99 + +__inline_forward_c(float,floorf, (float __x), (__x)) +__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(int,isnanf, (float __value), (__value)) +# endif +# ifdef __USE_ISOC99 +__inline_forward_c(float,scalblnf, (float __x, long int __n), (__x, __n)) +__inline_forward_c(float,nearbyintf, (float __value), (__value)) +__inline_forward_c(long int,lrintf, (float __value), (__value)) +# endif +# ifdef __USE_GNU +__inline_forward(void,sincosf, (float __x, float *__sinx, float *__cosx), + (__x, __sinx, __cosx)) +# endif + +__inline_forward_c(long double,floorl, (long double __x), (__x)) +__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), (__x, __n)) +__inline_forward_c(int,isnanl, (long double __value), (__value)) +# endif +# ifdef __USE_ISOC99 +__inline_forward_c(long double,scalblnl, (long double __x, long int __n), + (__x, __n)) +__inline_forward_c(long double,nearbyintl, (long double __value), (__value)) +__inline_forward_c(long int,lrintl, (long double __value), (__value)) +# endif +# ifdef __USE_GNU +__inline_forward(void,sincosl, + (long double __x, long double *__sinx, long double *__cosx), + (__x, __sinx, __cosx)) +# endif + +#endif /* Use misc or ISO C99 */ + +#undef __inline_forward +#undef __inline_forward_c + +#endif /* !__NO_MATH_INLINES && __OPTIMIZE__ */ + +#endif +#endif /* GCC. */ diff --git a/ports/sysdeps/m68k/m680x0/fpu/branred.c b/ports/sysdeps/m68k/m680x0/fpu/branred.c new file mode 100644 index 0000000000..1cc8931700 --- /dev/null +++ b/ports/sysdeps/m68k/m680x0/fpu/branred.c @@ -0,0 +1 @@ +/* Not needed. */ diff --git a/ports/sysdeps/m68k/m680x0/fpu/doasin.c b/ports/sysdeps/m68k/m680x0/fpu/doasin.c new file mode 100644 index 0000000000..1cc8931700 --- /dev/null +++ b/ports/sysdeps/m68k/m680x0/fpu/doasin.c @@ -0,0 +1 @@ +/* Not needed. */ diff --git a/ports/sysdeps/m68k/m680x0/fpu/dosincos.c b/ports/sysdeps/m68k/m680x0/fpu/dosincos.c new file mode 100644 index 0000000000..1cc8931700 --- /dev/null +++ b/ports/sysdeps/m68k/m680x0/fpu/dosincos.c @@ -0,0 +1 @@ +/* Not needed. */ diff --git a/ports/sysdeps/m68k/m680x0/fpu/e_acos.c b/ports/sysdeps/m68k/m680x0/fpu/e_acos.c new file mode 100644 index 0000000000..f8a0a352a1 --- /dev/null +++ b/ports/sysdeps/m68k/m680x0/fpu/e_acos.c @@ -0,0 +1,38 @@ +/* Copyright (C) 1996, 1997, 1999, 2011 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, see + <http://www.gnu.org/licenses/>. */ + +#include <math.h> +#include <math_private.h> +#include "mathimpl.h" + +#ifndef FUNC +# define FUNC __ieee754_acos +# define FUNC_FINITE __acos_finite +#endif +#ifndef float_type +# define float_type double +#endif + +float_type +FUNC (x) + float_type x; +{ + return __m81_u(FUNC)(x); +} +#ifdef FUNC_FINITE +strong_alias (FUNC, FUNC_FINITE) +#endif diff --git a/ports/sysdeps/m68k/m680x0/fpu/e_acosf.c b/ports/sysdeps/m68k/m680x0/fpu/e_acosf.c new file mode 100644 index 0000000000..300fff601e --- /dev/null +++ b/ports/sysdeps/m68k/m680x0/fpu/e_acosf.c @@ -0,0 +1,6 @@ +#ifndef FUNC +# define FUNC __ieee754_acosf +# define FUNC_FINITE __acosf_finite +#endif +#define float_type float +#include <e_acos.c> diff --git a/ports/sysdeps/m68k/m680x0/fpu/e_acosl.c b/ports/sysdeps/m68k/m680x0/fpu/e_acosl.c new file mode 100644 index 0000000000..35767f4e23 --- /dev/null +++ b/ports/sysdeps/m68k/m680x0/fpu/e_acosl.c @@ -0,0 +1,6 @@ +#ifndef FUNC +# define FUNC __ieee754_acosl +# define FUNC_FINITE __acosl_finite +#endif +#define float_type long double +#include <e_acos.c> diff --git a/ports/sysdeps/m68k/m680x0/fpu/e_asin.c b/ports/sysdeps/m68k/m680x0/fpu/e_asin.c new file mode 100644 index 0000000000..271a1f23d2 --- /dev/null +++ b/ports/sysdeps/m68k/m680x0/fpu/e_asin.c @@ -0,0 +1,3 @@ +#define FUNC __ieee754_asin +#define FUNC_FINITE __asin_finite +#include <e_acos.c> diff --git a/ports/sysdeps/m68k/m680x0/fpu/e_asinf.c b/ports/sysdeps/m68k/m680x0/fpu/e_asinf.c new file mode 100644 index 0000000000..ece691c6fb --- /dev/null +++ b/ports/sysdeps/m68k/m680x0/fpu/e_asinf.c @@ -0,0 +1,3 @@ +#define FUNC __ieee754_asinf +#define FUNC_FINITE __asinf_finite +#include <e_acosf.c> diff --git a/ports/sysdeps/m68k/m680x0/fpu/e_asinl.c b/ports/sysdeps/m68k/m680x0/fpu/e_asinl.c new file mode 100644 index 0000000000..0c136f30eb --- /dev/null +++ b/ports/sysdeps/m68k/m680x0/fpu/e_asinl.c @@ -0,0 +1,3 @@ +#define FUNC __ieee754_asinl +#define FUNC_FINITE __asinl_finite +#include <e_acosl.c> diff --git a/ports/sysdeps/m68k/m680x0/fpu/e_atan2.c b/ports/sysdeps/m68k/m680x0/fpu/e_atan2.c new file mode 100644 index 0000000000..b0742d3da6 --- /dev/null +++ b/ports/sysdeps/m68k/m680x0/fpu/e_atan2.c @@ -0,0 +1,104 @@ +/* Copyright (C) 1997, 1999, 2011 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, see + <http://www.gnu.org/licenses/>. */ + +#include <math.h> +#include <math_private.h> +#include "mathimpl.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_atan2) (float_type y, float_type x) +{ + float_type pi, pi_2, z; + unsigned long y_cond, x_cond; + + __asm ("fmovecr%.x %#0, %0" : "=f" (pi)); + __asm ("fscale%.w %#-1, %0" : "=f" (pi_2) : "0" (pi)); + y_cond = __m81_test (y); + x_cond = __m81_test (x); + + if ((x_cond | y_cond) & __M81_COND_NAN) + z = x + y; + else if (y_cond & __M81_COND_ZERO) + { + if (x_cond & __M81_COND_NEG) + z = y_cond & __M81_COND_NEG ? -pi : pi; + else + z = y; + } + else if (x_cond & __M81_COND_INF) + { + if (y_cond & __M81_COND_INF) + { + float_type pi_4; + __asm ("fscale%.w %#-2, %0" : "=f" (pi_4) : "0" (pi)); + z = x_cond & __M81_COND_NEG ? 3 * pi_4 : pi_4; + } + else + z = x_cond & __M81_COND_NEG ? pi : 0; + if (y_cond & __M81_COND_NEG) + z = -z; + } + else if (y_cond & __M81_COND_INF) + z = y_cond & __M81_COND_NEG ? -pi_2 : pi_2; + else if (x_cond & __M81_COND_NEG) + { + if (y_cond & __M81_COND_NEG) + { + if (-x > -y) + z = -pi + m81(__atan) (y / x); + else + z = -pi_2 - m81(__atan) (x / y); + } + else + { + if (-x > y) + z = pi + m81(__atan) (y / x); + else + z = pi_2 - m81(__atan) (x / y); + } + } + else + { + if (y_cond & __M81_COND_NEG) + { + if (x > -y) + z = m81(__atan) (y / x); + else + z = -pi_2 - m81(__atan) (x / y); + } + else + { + if (x > y) + z = m81(__atan) (y / x); + else + z = pi_2 - m81(__atan) (x / y); + } + } + return z; +} +strong_alias (s(__ieee754_atan2), CONCATX (s (__atan2), _finite)) diff --git a/ports/sysdeps/m68k/m680x0/fpu/e_atan2f.c b/ports/sysdeps/m68k/m680x0/fpu/e_atan2f.c new file mode 100644 index 0000000000..a0c750a759 --- /dev/null +++ b/ports/sysdeps/m68k/m680x0/fpu/e_atan2f.c @@ -0,0 +1,3 @@ +#define SUFF f +#define float_type float +#include <e_atan2.c> diff --git a/ports/sysdeps/m68k/m680x0/fpu/e_atan2l.c b/ports/sysdeps/m68k/m680x0/fpu/e_atan2l.c new file mode 100644 index 0000000000..426ca94baa --- /dev/null +++ b/ports/sysdeps/m68k/m680x0/fpu/e_atan2l.c @@ -0,0 +1,3 @@ +#define SUFF l +#define float_type long double +#include <e_atan2.c> diff --git a/ports/sysdeps/m68k/m680x0/fpu/e_atanh.c b/ports/sysdeps/m68k/m680x0/fpu/e_atanh.c new file mode 100644 index 0000000000..f5f7e7b520 --- /dev/null +++ b/ports/sysdeps/m68k/m680x0/fpu/e_atanh.c @@ -0,0 +1,3 @@ +#define FUNC __ieee754_atanh +#define FUNC_FINITE __atanh_finite +#include <e_acos.c> diff --git a/ports/sysdeps/m68k/m680x0/fpu/e_atanhf.c b/ports/sysdeps/m68k/m680x0/fpu/e_atanhf.c new file mode 100644 index 0000000000..cb464cbb7d --- /dev/null +++ b/ports/sysdeps/m68k/m680x0/fpu/e_atanhf.c @@ -0,0 +1,3 @@ +#define FUNC __ieee754_atanhf +#define FUNC_FINITE __atanhf_finite +#include <e_acosf.c> diff --git a/ports/sysdeps/m68k/m680x0/fpu/e_atanhl.c b/ports/sysdeps/m68k/m680x0/fpu/e_atanhl.c new file mode 100644 index 0000000000..8f276f5fad --- /dev/null +++ b/ports/sysdeps/m68k/m680x0/fpu/e_atanhl.c @@ -0,0 +1,3 @@ +#define FUNC __ieee754_atanhl +#define FUNC_FINITE __atanhl_finite +#include <e_acosl.c> diff --git a/ports/sysdeps/m68k/m680x0/fpu/e_cosh.c b/ports/sysdeps/m68k/m680x0/fpu/e_cosh.c new file mode 100644 index 0000000000..aaba11be3a --- /dev/null +++ b/ports/sysdeps/m68k/m680x0/fpu/e_cosh.c @@ -0,0 +1,3 @@ +#define FUNC __ieee754_cosh +#define FUNC_FINITE __cosh_finite +#include <e_acos.c> diff --git a/ports/sysdeps/m68k/m680x0/fpu/e_coshf.c b/ports/sysdeps/m68k/m680x0/fpu/e_coshf.c new file mode 100644 index 0000000000..0884741c5c --- /dev/null +++ b/ports/sysdeps/m68k/m680x0/fpu/e_coshf.c @@ -0,0 +1,3 @@ +#define FUNC __ieee754_coshf +#define FUNC_FINITE __coshf_finite +#include <e_acosf.c> diff --git a/ports/sysdeps/m68k/m680x0/fpu/e_coshl.c b/ports/sysdeps/m68k/m680x0/fpu/e_coshl.c new file mode 100644 index 0000000000..7fc9b7b91c --- /dev/null +++ b/ports/sysdeps/m68k/m680x0/fpu/e_coshl.c @@ -0,0 +1,3 @@ +#define FUNC __ieee754_coshl +#define FUNC_FINITE __coshl_finite +#include <e_acosl.c> diff --git a/ports/sysdeps/m68k/m680x0/fpu/e_exp.c b/ports/sysdeps/m68k/m680x0/fpu/e_exp.c new file mode 100644 index 0000000000..9f228034a1 --- /dev/null +++ b/ports/sysdeps/m68k/m680x0/fpu/e_exp.c @@ -0,0 +1,3 @@ +#define FUNC __ieee754_exp +#define FUNC_FINITE __exp_finite +#include <e_acos.c> diff --git a/ports/sysdeps/m68k/m680x0/fpu/e_exp10.c b/ports/sysdeps/m68k/m680x0/fpu/e_exp10.c new file mode 100644 index 0000000000..e66a80599c --- /dev/null +++ b/ports/sysdeps/m68k/m680x0/fpu/e_exp10.c @@ -0,0 +1,3 @@ +#define FUNC __ieee754_exp10 +#define FUNC_FINITE __exp10_finite +#include <e_acos.c> diff --git a/ports/sysdeps/m68k/m680x0/fpu/e_exp10f.c b/ports/sysdeps/m68k/m680x0/fpu/e_exp10f.c new file mode 100644 index 0000000000..7a3bdd4186 --- /dev/null +++ b/ports/sysdeps/m68k/m680x0/fpu/e_exp10f.c @@ -0,0 +1,3 @@ +#define FUNC __ieee754_exp10f +#define FUNC_FINITE __exp10f_finite +#include <e_acosf.c> diff --git a/ports/sysdeps/m68k/m680x0/fpu/e_exp10l.c b/ports/sysdeps/m68k/m680x0/fpu/e_exp10l.c new file mode 100644 index 0000000000..e2a6255a76 --- /dev/null +++ b/ports/sysdeps/m68k/m680x0/fpu/e_exp10l.c @@ -0,0 +1,3 @@ +#define FUNC __ieee754_exp10l +#define FUNC_FINITE __exp10l_finite +#include <e_acosl.c> diff --git a/ports/sysdeps/m68k/m680x0/fpu/e_exp2.c b/ports/sysdeps/m68k/m680x0/fpu/e_exp2.c new file mode 100644 index 0000000000..35e29ae653 --- /dev/null +++ b/ports/sysdeps/m68k/m680x0/fpu/e_exp2.c @@ -0,0 +1,3 @@ +#define FUNC __ieee754_exp2 +#define FUNC_FINITE __exp2_finite +#include <e_acos.c> diff --git a/ports/sysdeps/m68k/m680x0/fpu/e_exp2f.c b/ports/sysdeps/m68k/m680x0/fpu/e_exp2f.c new file mode 100644 index 0000000000..e57ddb5365 --- /dev/null +++ b/ports/sysdeps/m68k/m680x0/fpu/e_exp2f.c @@ -0,0 +1,3 @@ +#define FUNC __ieee754_exp2f +#define FUNC_FINITE __exp2f_finite +#include <e_acosf.c> diff --git a/ports/sysdeps/m68k/m680x0/fpu/e_exp2l.c b/ports/sysdeps/m68k/m680x0/fpu/e_exp2l.c new file mode 100644 index 0000000000..c5854ae427 --- /dev/null +++ b/ports/sysdeps/m68k/m680x0/fpu/e_exp2l.c @@ -0,0 +1,3 @@ +#define FUNC __ieee754_exp2l +#define FUNC_FINITE __exp2l_finite +#include <e_acosl.c> diff --git a/ports/sysdeps/m68k/m680x0/fpu/e_expf.c b/ports/sysdeps/m68k/m680x0/fpu/e_expf.c new file mode 100644 index 0000000000..af1e019504 --- /dev/null +++ b/ports/sysdeps/m68k/m680x0/fpu/e_expf.c @@ -0,0 +1,3 @@ +#define FUNC __ieee754_expf +#define FUNC_FINITE __expf_finite +#include <e_acosf.c> diff --git a/ports/sysdeps/m68k/m680x0/fpu/e_expl.c b/ports/sysdeps/m68k/m680x0/fpu/e_expl.c new file mode 100644 index 0000000000..543eb0edf5 --- /dev/null +++ b/ports/sysdeps/m68k/m680x0/fpu/e_expl.c @@ -0,0 +1,3 @@ +#define FUNC __ieee754_expl +#define FUNC_FINITE __expl_finite +#include <e_acosl.c> diff --git a/ports/sysdeps/m68k/m680x0/fpu/e_fmod.c b/ports/sysdeps/m68k/m680x0/fpu/e_fmod.c new file mode 100644 index 0000000000..671e3b83a4 --- /dev/null +++ b/ports/sysdeps/m68k/m680x0/fpu/e_fmod.c @@ -0,0 +1,39 @@ +/* Copyright (C) 1996, 1997, 1999, 2011 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, see + <http://www.gnu.org/licenses/>. */ + +#include <math.h> +#include <math_private.h> +#include "mathimpl.h" + +#ifndef FUNC +# define FUNC __ieee754_fmod +# define FUNC_FINITE __fmod_finite +#endif +#ifndef float_type +# define float_type double +#endif + +float_type +FUNC (x, y) + float_type x; + float_type y; +{ + return __m81_u(FUNC)(x, y); +} +#ifdef FUNC_FINITE +strong_alias (FUNC, FUNC_FINITE) +#endif diff --git a/ports/sysdeps/m68k/m680x0/fpu/e_fmodf.c b/ports/sysdeps/m68k/m680x0/fpu/e_fmodf.c new file mode 100644 index 0000000000..38995c3768 --- /dev/null +++ b/ports/sysdeps/m68k/m680x0/fpu/e_fmodf.c @@ -0,0 +1,6 @@ +#ifndef FUNC +# define FUNC __ieee754_fmodf +# define FUNC_FINITE __fmodf_finite +#endif +#define float_type float +#include <e_fmod.c> diff --git a/ports/sysdeps/m68k/m680x0/fpu/e_fmodl.c b/ports/sysdeps/m68k/m680x0/fpu/e_fmodl.c new file mode 100644 index 0000000000..8d793b2de7 --- /dev/null +++ b/ports/sysdeps/m68k/m680x0/fpu/e_fmodl.c @@ -0,0 +1,6 @@ +#ifndef FUNC +# define FUNC __ieee754_fmodl +# define FUNC_FINITE __fmodl_finite +#endif +#define float_type long double +#include <e_fmod.c> diff --git a/ports/sysdeps/m68k/m680x0/fpu/e_ilogb.c b/ports/sysdeps/m68k/m680x0/fpu/e_ilogb.c new file mode 100644 index 0000000000..41c597a012 --- /dev/null +++ b/ports/sysdeps/m68k/m680x0/fpu/e_ilogb.c @@ -0,0 +1,47 @@ +/* Copyright (C) 1996-2012 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, see + <http://www.gnu.org/licenses/>. */ + +#include <math.h> +#include "mathimpl.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)) + +int +s(__ieee754_ilogb) (float_type 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; +} diff --git a/ports/sysdeps/m68k/m680x0/fpu/e_ilogbf.c b/ports/sysdeps/m68k/m680x0/fpu/e_ilogbf.c new file mode 100644 index 0000000000..34a8cd28e6 --- /dev/null +++ b/ports/sysdeps/m68k/m680x0/fpu/e_ilogbf.c @@ -0,0 +1,3 @@ +#define SUFF f +#define float_type float +#include <e_ilogb.c> diff --git a/ports/sysdeps/m68k/m680x0/fpu/e_ilogbl.c b/ports/sysdeps/m68k/m680x0/fpu/e_ilogbl.c new file mode 100644 index 0000000000..b0e13af6b1 --- /dev/null +++ b/ports/sysdeps/m68k/m680x0/fpu/e_ilogbl.c @@ -0,0 +1,3 @@ +#define SUFF l +#define float_type long double +#include <e_ilogb.c> diff --git a/ports/sysdeps/m68k/m680x0/fpu/e_log.c b/ports/sysdeps/m68k/m680x0/fpu/e_log.c new file mode 100644 index 0000000000..628c62b31a --- /dev/null +++ b/ports/sysdeps/m68k/m680x0/fpu/e_log.c @@ -0,0 +1,3 @@ +#define FUNC __ieee754_log +#define FUNC_FINITE __log_finite +#include <e_acos.c> diff --git a/ports/sysdeps/m68k/m680x0/fpu/e_log10.c b/ports/sysdeps/m68k/m680x0/fpu/e_log10.c new file mode 100644 index 0000000000..78e0693e9d --- /dev/null +++ b/ports/sysdeps/m68k/m680x0/fpu/e_log10.c @@ -0,0 +1,3 @@ +#define FUNC __ieee754_log10 +#define FUNC_FINITE __log10_finite +#include <e_acos.c> diff --git a/ports/sysdeps/m68k/m680x0/fpu/e_log10f.c b/ports/sysdeps/m68k/m680x0/fpu/e_log10f.c new file mode 100644 index 0000000000..452a75ec15 --- /dev/null +++ b/ports/sysdeps/m68k/m680x0/fpu/e_log10f.c @@ -0,0 +1,3 @@ +#define FUNC __ieee754_log10f +#define FUNC_FINITE __log10f_finite +#include <e_acosf.c> diff --git a/ports/sysdeps/m68k/m680x0/fpu/e_log10l.c b/ports/sysdeps/m68k/m680x0/fpu/e_log10l.c new file mode 100644 index 0000000000..7c5dcb8e18 --- /dev/null +++ b/ports/sysdeps/m68k/m680x0/fpu/e_log10l.c @@ -0,0 +1,3 @@ +#define FUNC __ieee754_log10l +#define FUNC_FINITE __log10l_finite +#include <e_acosl.c> diff --git a/ports/sysdeps/m68k/m680x0/fpu/e_log2.c b/ports/sysdeps/m68k/m680x0/fpu/e_log2.c new file mode 100644 index 0000000000..a00ddbdc96 --- /dev/null +++ b/ports/sysdeps/m68k/m680x0/fpu/e_log2.c @@ -0,0 +1,3 @@ +#define FUNC __ieee754_log2 +#define FUNC_FINITE __log2_finite +#include <e_acos.c> diff --git a/ports/sysdeps/m68k/m680x0/fpu/e_log2f.c b/ports/sysdeps/m68k/m680x0/fpu/e_log2f.c new file mode 100644 index 0000000000..670b69c8a9 --- /dev/null +++ b/ports/sysdeps/m68k/m680x0/fpu/e_log2f.c @@ -0,0 +1,3 @@ +#define FUNC __ieee754_log2f +#define FUNC_FINITE __log2f_finite +#include <e_acosf.c> diff --git a/ports/sysdeps/m68k/m680x0/fpu/e_log2l.c b/ports/sysdeps/m68k/m680x0/fpu/e_log2l.c new file mode 100644 index 0000000000..4a97a00235 --- /dev/null +++ b/ports/sysdeps/m68k/m680x0/fpu/e_log2l.c @@ -0,0 +1,3 @@ +#define FUNC __ieee754_log2l +#define FUNC_FINITE __log2l_finite +#include <e_acosl.c> diff --git a/ports/sysdeps/m68k/m680x0/fpu/e_logf.c b/ports/sysdeps/m68k/m680x0/fpu/e_logf.c new file mode 100644 index 0000000000..1989a95431 --- /dev/null +++ b/ports/sysdeps/m68k/m680x0/fpu/e_logf.c @@ -0,0 +1,3 @@ +#define FUNC __ieee754_logf +#define FUNC_FINITE __logf_finite +#include <e_acosf.c> diff --git a/ports/sysdeps/m68k/m680x0/fpu/e_logl.c b/ports/sysdeps/m68k/m680x0/fpu/e_logl.c new file mode 100644 index 0000000000..9ab842c3fc --- /dev/null +++ b/ports/sysdeps/m68k/m680x0/fpu/e_logl.c @@ -0,0 +1,3 @@ +#define FUNC __ieee754_logl +#define FUNC_FINITE __logl_finite +#include <e_acosl.c> diff --git a/ports/sysdeps/m68k/m680x0/fpu/e_pow.c b/ports/sysdeps/m68k/m680x0/fpu/e_pow.c new file mode 100644 index 0000000000..41e28d0559 --- /dev/null +++ b/ports/sysdeps/m68k/m680x0/fpu/e_pow.c @@ -0,0 +1,126 @@ +/* Copyright (C) 1997, 1999, 2011 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, see + <http://www.gnu.org/licenses/>. */ + +#include <math.h> +#include <math_private.h> +#include "mathimpl.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_pow) (float_type x, float_type y) +{ + float_type z; + float_type ax; + unsigned long x_cond, y_cond; + + y_cond = __m81_test (y); + if (y_cond & __M81_COND_ZERO) + return 1.0; + if (y_cond & __M81_COND_NAN) + return x == 1.0 ? x : x + y; + + x_cond = __m81_test (x); + if (x_cond & __M81_COND_NAN) + return x + y; + + if (y_cond & __M81_COND_INF) + { + ax = s(fabs) (x); + if (ax == 1.0) + return ax; + if (ax > 1.0) + return y_cond & __M81_COND_NEG ? 0 : y; + else + return y_cond & __M81_COND_NEG ? -y : 0; + } + + if (s(fabs) (y) == 1.0) + return y_cond & __M81_COND_NEG ? 1 / x : x; + + if (y == 2) + return x * x; + if (y == 0.5 && !(x_cond & __M81_COND_NEG)) + return m81(__ieee754_sqrt) (x); + + if (x == 10.0) + { + __asm ("ftentox%.x %1, %0" : "=f" (z) : "f" (y)); + return z; + } + if (x == 2.0) + { + __asm ("ftwotox%.x %1, %0" : "=f" (z) : "f" (y)); + return z; + } + + ax = s(fabs) (x); + if (x_cond & (__M81_COND_INF | __M81_COND_ZERO) || ax == 1.0) + { + z = ax; + if (y_cond & __M81_COND_NEG) + z = 1 / z; + if (x_cond & __M81_COND_NEG) + { + if (y != m81(__rint) (y)) + { + if (x == -1) + z = (z - z) / (z - z); + } + else + goto maybe_negate; + } + return z; + } + + if (x_cond & __M81_COND_NEG) + { + if (y == m81(__rint) (y)) + { + z = m81(__ieee754_exp) (y * m81(__ieee754_log) (-x)); + maybe_negate: + /* We always use the long double format, since y is already in + this format and rounding won't change the result. */ + { + int32_t exponent; + u_int32_t i0, i1; + GET_LDOUBLE_WORDS (exponent, i0, i1, y); + exponent = (exponent & 0x7fff) - 0x3fff; + if (exponent <= 31 + ? i0 & (1 << (31 - exponent)) + : (exponent <= 63 + && i1 & (1 << (63 - exponent)))) + z = -z; + } + } + else + z = (y - y) / (y - y); + } + else + z = m81(__ieee754_exp) (y * m81(__ieee754_log) (x)); + return z; +} +strong_alias (s(__ieee754_pow), CONCATX (s(__pow), _finite)) diff --git a/ports/sysdeps/m68k/m680x0/fpu/e_powf.c b/ports/sysdeps/m68k/m680x0/fpu/e_powf.c new file mode 100644 index 0000000000..379014355a --- /dev/null +++ b/ports/sysdeps/m68k/m680x0/fpu/e_powf.c @@ -0,0 +1,3 @@ +#define SUFF f +#define float_type float +#include <e_pow.c> diff --git a/ports/sysdeps/m68k/m680x0/fpu/e_powl.c b/ports/sysdeps/m68k/m680x0/fpu/e_powl.c new file mode 100644 index 0000000000..f71fa34a26 --- /dev/null +++ b/ports/sysdeps/m68k/m680x0/fpu/e_powl.c @@ -0,0 +1,3 @@ +#define SUFF l +#define float_type long double +#include <e_pow.c> diff --git a/ports/sysdeps/m68k/m680x0/fpu/e_rem_pio2.c b/ports/sysdeps/m68k/m680x0/fpu/e_rem_pio2.c new file mode 100644 index 0000000000..1347b0468c --- /dev/null +++ b/ports/sysdeps/m68k/m680x0/fpu/e_rem_pio2.c @@ -0,0 +1,3 @@ +/* Empty. This file is only meant to avoid compiling the file with the + same name in the libm-ieee754 directory. The code is not used since + there is an assembler version for all users of this file. */ diff --git a/ports/sysdeps/m68k/m680x0/fpu/e_rem_pio2f.c b/ports/sysdeps/m68k/m680x0/fpu/e_rem_pio2f.c new file mode 100644 index 0000000000..1347b0468c --- /dev/null +++ b/ports/sysdeps/m68k/m680x0/fpu/e_rem_pio2f.c @@ -0,0 +1,3 @@ +/* Empty. This file is only meant to avoid compiling the file with the + same name in the libm-ieee754 directory. The code is not used since + there is an assembler version for all users of this file. */ diff --git a/ports/sysdeps/m68k/m680x0/fpu/e_rem_pio2l.c b/ports/sysdeps/m68k/m680x0/fpu/e_rem_pio2l.c new file mode 100644 index 0000000000..1347b0468c --- /dev/null +++ b/ports/sysdeps/m68k/m680x0/fpu/e_rem_pio2l.c @@ -0,0 +1,3 @@ +/* Empty. This file is only meant to avoid compiling the file with the + same name in the libm-ieee754 directory. The code is not used since + there is an assembler version for all users of this file. */ diff --git a/ports/sysdeps/m68k/m680x0/fpu/e_remainder.c b/ports/sysdeps/m68k/m680x0/fpu/e_remainder.c new file mode 100644 index 0000000000..f7732af8c5 --- /dev/null +++ b/ports/sysdeps/m68k/m680x0/fpu/e_remainder.c @@ -0,0 +1,3 @@ +#define FUNC __ieee754_remainder +#define FUNC_FINITE __remainder_finite +#include <e_fmod.c> diff --git a/ports/sysdeps/m68k/m680x0/fpu/e_remainderf.c b/ports/sysdeps/m68k/m680x0/fpu/e_remainderf.c new file mode 100644 index 0000000000..94b53e7a80 --- /dev/null +++ b/ports/sysdeps/m68k/m680x0/fpu/e_remainderf.c @@ -0,0 +1,3 @@ +#define FUNC __ieee754_remainderf +#define FUNC_FINITE __remainderf_finite +#include <e_fmodf.c> diff --git a/ports/sysdeps/m68k/m680x0/fpu/e_remainderl.c b/ports/sysdeps/m68k/m680x0/fpu/e_remainderl.c new file mode 100644 index 0000000000..d5b59607ab --- /dev/null +++ b/ports/sysdeps/m68k/m680x0/fpu/e_remainderl.c @@ -0,0 +1,3 @@ +#define FUNC __ieee754_remainderl +#define FUNC_FINITE __remainderl_finite +#include <e_fmodl.c> diff --git a/ports/sysdeps/m68k/m680x0/fpu/e_scalb.c b/ports/sysdeps/m68k/m680x0/fpu/e_scalb.c new file mode 100644 index 0000000000..db49fdf097 --- /dev/null +++ b/ports/sysdeps/m68k/m680x0/fpu/e_scalb.c @@ -0,0 +1,60 @@ +/* Copyright (C) 1997, 1999, 2011 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 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, see + <http://www.gnu.org/licenses/>. */ + +#include <math.h> +#include <math_private.h> +#include "mathimpl.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 + return x / -fn; + } + + if (m81(__rint) (fn) != fn) + return (x - x) / (x - x); + + __asm ("fscale%.x %1, %0" : "=f" (retval) : "f" (fn), "0" (x)); + return retval; +} +strong_alias (s(__ieee754_scalb), CONCATX (s(__scalb), _finite)) diff --git a/ports/sysdeps/m68k/m680x0/fpu/e_scalbf.c b/ports/sysdeps/m68k/m680x0/fpu/e_scalbf.c new file mode 100644 index 0000000000..7943571246 --- /dev/null +++ b/ports/sysdeps/m68k/m680x0/fpu/e_scalbf.c @@ -0,0 +1,3 @@ +#define SUFF f +#define float_type float +#include <e_scalb.c> diff --git a/ports/sysdeps/m68k/m680x0/fpu/e_scalbl.c b/ports/sysdeps/m68k/m680x0/fpu/e_scalbl.c new file mode 100644 index 0000000000..35fb2dc0ed --- /dev/null +++ b/ports/sysdeps/m68k/m680x0/fpu/e_scalbl.c @@ -0,0 +1,3 @@ +#define SUFF l +#define float_type long double +#include <e_scalb.c> diff --git a/ports/sysdeps/m68k/m680x0/fpu/e_sinh.c b/ports/sysdeps/m68k/m680x0/fpu/e_sinh.c new file mode 100644 index 0000000000..1e1b1c1180 --- /dev/null +++ b/ports/sysdeps/m68k/m680x0/fpu/e_sinh.c @@ -0,0 +1,3 @@ +#define FUNC __ieee754_sinh +#define FUNC_FINITE __sinh_finite +#include <e_acos.c> diff --git a/ports/sysdeps/m68k/m680x0/fpu/e_sinhf.c b/ports/sysdeps/m68k/m680x0/fpu/e_sinhf.c new file mode 100644 index 0000000000..13c79f9d96 --- /dev/null +++ b/ports/sysdeps/m68k/m680x0/fpu/e_sinhf.c @@ -0,0 +1,3 @@ +#define FUNC __ieee754_sinhf +#define FUNC_FINITE __sinhf_finite +#include <e_acosf.c> diff --git a/ports/sysdeps/m68k/m680x0/fpu/e_sinhl.c b/ports/sysdeps/m68k/m680x0/fpu/e_sinhl.c new file mode 100644 index 0000000000..47f0f24401 --- /dev/null +++ b/ports/sysdeps/m68k/m680x0/fpu/e_sinhl.c @@ -0,0 +1,3 @@ +#define FUNC __ieee754_sinhl +#define FUNC_FINITE __sinhl_finite +#include <e_acosl.c> diff --git a/ports/sysdeps/m68k/m680x0/fpu/e_sqrt.c b/ports/sysdeps/m68k/m680x0/fpu/e_sqrt.c new file mode 100644 index 0000000000..9a250cbc25 --- /dev/null +++ b/ports/sysdeps/m68k/m680x0/fpu/e_sqrt.c @@ -0,0 +1,3 @@ +#define FUNC __ieee754_sqrt +#define FUNC_FINITE __sqrt_finite +#include <e_acos.c> diff --git a/ports/sysdeps/m68k/m680x0/fpu/e_sqrtf.c b/ports/sysdeps/m68k/m680x0/fpu/e_sqrtf.c new file mode 100644 index 0000000000..372c3eb2f4 --- /dev/null +++ b/ports/sysdeps/m68k/m680x0/fpu/e_sqrtf.c @@ -0,0 +1,3 @@ +#define FUNC __ieee754_sqrtf +#define FUNC_FINITE __sqrtf_finite +#include <e_acosf.c> diff --git a/ports/sysdeps/m68k/m680x0/fpu/e_sqrtl.c b/ports/sysdeps/m68k/m680x0/fpu/e_sqrtl.c new file mode 100644 index 0000000000..df5f44e6a7 --- /dev/null +++ b/ports/sysdeps/m68k/m680x0/fpu/e_sqrtl.c @@ -0,0 +1,3 @@ +#define FUNC __ieee754_sqrtl +#define FUNC_FINITE __sqrtl_finite +#include <e_acosl.c> diff --git a/ports/sysdeps/m68k/m680x0/fpu/fraiseexcpt.c b/ports/sysdeps/m68k/m680x0/fpu/fraiseexcpt.c new file mode 100644 index 0000000000..4fe384ebe3 --- /dev/null +++ b/ports/sysdeps/m68k/m680x0/fpu/fraiseexcpt.c @@ -0,0 +1,82 @@ +/* Raise given exceptions. + Copyright (C) 1997,99,2000,01,02 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 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, see + <http://www.gnu.org/licenses/>. */ + +#include <fenv.h> +#include <float.h> +#include <math.h> + +int +__feraiseexcept (int excepts) +{ + /* Raise exceptions represented by EXCEPTS. But we must raise only one + signal at a time. It is important that if the overflow/underflow + exception and the divide by zero exception are given at the same + time, the overflow/underflow exception follows the divide by zero + exception. */ + + /* First: invalid exception. */ + if (excepts & FE_INVALID) + { + /* One example of a invalid operation is 0 * Infinity. */ + double d = HUGE_VAL; + __asm__ __volatile__ ("fmul%.s %#0r0,%0; fnop" : "=f" (d) : "0" (d)); + } + + /* Next: division by zero. */ + if (excepts & FE_DIVBYZERO) + { + double d = 1.0; + __asm__ __volatile__ ("fdiv%.s %#0r0,%0; fnop" : "=f" (d) : "0" (d)); + } + + /* Next: overflow. */ + if (excepts & FE_OVERFLOW) + { + long double d = LDBL_MAX; + + __asm__ __volatile__ ("fmul%.x %0,%0; fnop" : "=f" (d) : "0" (d)); + } + + /* Next: underflow. */ + if (excepts & FE_UNDERFLOW) + { + long double d = -LDBL_MAX; + + __asm__ __volatile__ ("fetox%.x %0; fnop" : "=f" (d) : "0" (d)); + } + + /* Last: inexact. */ + if (excepts & FE_INEXACT) + { + long double d = 1.0; + __asm__ __volatile__ ("fdiv%.s %#0r3,%0; fnop" : "=f" (d) : "0" (d)); + } + + /* Success. */ + return 0; +} + +#include <shlib-compat.h> +#if SHLIB_COMPAT (libm, GLIBC_2_1, GLIBC_2_2) +strong_alias (__feraiseexcept, __old_feraiseexcept) +compat_symbol (libm, __old_feraiseexcept, feraiseexcept, GLIBC_2_1); +#endif + +libm_hidden_ver (__feraiseexcept, feraiseexcept) +versioned_symbol (libm, __feraiseexcept, feraiseexcept, GLIBC_2_2); diff --git a/ports/sysdeps/m68k/m680x0/fpu/halfulp.c b/ports/sysdeps/m68k/m680x0/fpu/halfulp.c new file mode 100644 index 0000000000..1cc8931700 --- /dev/null +++ b/ports/sysdeps/m68k/m680x0/fpu/halfulp.c @@ -0,0 +1 @@ +/* Not needed. */ diff --git a/ports/sysdeps/m68k/m680x0/fpu/k_cosl.c b/ports/sysdeps/m68k/m680x0/fpu/k_cosl.c new file mode 100644 index 0000000000..1cc8931700 --- /dev/null +++ b/ports/sysdeps/m68k/m680x0/fpu/k_cosl.c @@ -0,0 +1 @@ +/* Not needed. */ diff --git a/ports/sysdeps/m68k/m680x0/fpu/k_rem_pio2.c b/ports/sysdeps/m68k/m680x0/fpu/k_rem_pio2.c new file mode 100644 index 0000000000..1347b0468c --- /dev/null +++ b/ports/sysdeps/m68k/m680x0/fpu/k_rem_pio2.c @@ -0,0 +1,3 @@ +/* Empty. This file is only meant to avoid compiling the file with the + same name in the libm-ieee754 directory. The code is not used since + there is an assembler version for all users of this file. */ diff --git a/ports/sysdeps/m68k/m680x0/fpu/k_rem_pio2f.c b/ports/sysdeps/m68k/m680x0/fpu/k_rem_pio2f.c new file mode 100644 index 0000000000..1347b0468c --- /dev/null +++ b/ports/sysdeps/m68k/m680x0/fpu/k_rem_pio2f.c @@ -0,0 +1,3 @@ +/* Empty. This file is only meant to avoid compiling the file with the + same name in the libm-ieee754 directory. The code is not used since + there is an assembler version for all users of this file. */ diff --git a/ports/sysdeps/m68k/m680x0/fpu/k_rem_pio2l.c b/ports/sysdeps/m68k/m680x0/fpu/k_rem_pio2l.c new file mode 100644 index 0000000000..1347b0468c --- /dev/null +++ b/ports/sysdeps/m68k/m680x0/fpu/k_rem_pio2l.c @@ -0,0 +1,3 @@ +/* Empty. This file is only meant to avoid compiling the file with the + same name in the libm-ieee754 directory. The code is not used since + there is an assembler version for all users of this file. */ diff --git a/ports/sysdeps/m68k/m680x0/fpu/k_sinl.c b/ports/sysdeps/m68k/m680x0/fpu/k_sinl.c new file mode 100644 index 0000000000..1cc8931700 --- /dev/null +++ b/ports/sysdeps/m68k/m680x0/fpu/k_sinl.c @@ -0,0 +1 @@ +/* Not needed. */ diff --git a/ports/sysdeps/m68k/m680x0/fpu/k_tanf.c b/ports/sysdeps/m68k/m680x0/fpu/k_tanf.c new file mode 100644 index 0000000000..1cc8931700 --- /dev/null +++ b/ports/sysdeps/m68k/m680x0/fpu/k_tanf.c @@ -0,0 +1 @@ +/* Not needed. */ diff --git a/ports/sysdeps/m68k/m680x0/fpu/k_tanl.c b/ports/sysdeps/m68k/m680x0/fpu/k_tanl.c new file mode 100644 index 0000000000..1cc8931700 --- /dev/null +++ b/ports/sysdeps/m68k/m680x0/fpu/k_tanl.c @@ -0,0 +1 @@ +/* Not needed. */ diff --git a/ports/sysdeps/m68k/m680x0/fpu/libm-test-ulps b/ports/sysdeps/m68k/m680x0/fpu/libm-test-ulps new file mode 100644 index 0000000000..9c011e629c --- /dev/null +++ b/ports/sysdeps/m68k/m680x0/fpu/libm-test-ulps @@ -0,0 +1,2606 @@ +# Begin of automatic generation + +# acos_downward +Test "acos_downward (-0) == pi/2": +float: 1 +ifloat: 1 +ildouble: 1 +ldouble: 1 +Test "acos_downward (-0.5) == M_PI_6l*4.0": +double: 1 +float: 1 +idouble: 1 +ifloat: 1 +Test "acos_downward (-1) == pi": +float: 1 +ifloat: 1 +ildouble: 1 +ldouble: 1 +Test "acos_downward (0) == pi/2": +float: 1 +ifloat: 1 +ildouble: 1 +ldouble: 1 +Test "acos_downward (0.5) == M_PI_6l*2.0": +double: 1 +float: 1 +idouble: 1 +ifloat: 1 + +# acos_towardzero +Test "acos_towardzero (-0) == pi/2": +float: 1 +ifloat: 1 +ildouble: 1 +ldouble: 1 +Test "acos_towardzero (-0.5) == M_PI_6l*4.0": +double: 1 +float: 1 +idouble: 1 +ifloat: 1 +Test "acos_towardzero (-1) == pi": +float: 1 +ifloat: 1 +ildouble: 1 +ldouble: 1 +Test "acos_towardzero (0) == pi/2": +float: 1 +ifloat: 1 +ildouble: 1 +ldouble: 1 +Test "acos_towardzero (0.5) == M_PI_6l*2.0": +double: 1 +float: 1 +idouble: 1 +ifloat: 1 + +# acos_upward +Test "acos_upward (-0) == pi/2": +double: 1 +idouble: 1 +Test "acos_upward (-0.5) == M_PI_6l*4.0": +ildouble: 1 +ldouble: 1 +Test "acos_upward (-1) == pi": +double: 1 +idouble: 1 +Test "acos_upward (0) == pi/2": +double: 1 +idouble: 1 +Test "acos_upward (0.5) == M_PI_6l*2.0": +ildouble: 1 +ldouble: 1 + +# acosh +Test "acosh (7) == 2.63391579384963341725009269461593689": +ildouble: 1 +ldouble: 1 + +# asin_downward +Test "asin_downward (-0.5) == -pi/6": +ildouble: 1 +ldouble: 1 +Test "asin_downward (-1.0) == -pi/2": +double: 1 +idouble: 1 +Test "asin_downward (0.5) == pi/6": +double: 1 +float: 1 +idouble: 1 +ifloat: 1 +Test "asin_downward (1.0) == pi/2": +float: 1 +ifloat: 1 +ildouble: 1 +ldouble: 1 + +# asin_towardzero +Test "asin_towardzero (-0.5) == -pi/6": +double: 1 +float: 1 +idouble: 1 +ifloat: 1 +Test "asin_towardzero (-1.0) == -pi/2": +float: 1 +ifloat: 1 +ildouble: 1 +ldouble: 1 +Test "asin_towardzero (0.5) == pi/6": +double: 1 +float: 1 +idouble: 1 +ifloat: 1 +Test "asin_towardzero (1.0) == pi/2": +float: 1 +ifloat: 1 +ildouble: 1 +ldouble: 1 + +# asin_upward +Test "asin_upward (-0.5) == -pi/6": +double: 1 +float: 1 +idouble: 1 +ifloat: 1 +Test "asin_upward (-1.0) == -pi/2": +float: 1 +ifloat: 1 +ildouble: 1 +ldouble: 1 +Test "asin_upward (0.5) == pi/6": +ildouble: 1 +ldouble: 1 +Test "asin_upward (1.0) == pi/2": +double: 1 +idouble: 1 + +# asinh +Test "asinh (0.75) == 0.693147180559945309417232121458176568": +ildouble: 1 +ldouble: 1 + +# atan2 +Test "atan2 (0.390625, .00029) == 1.57005392693128974780151246612928941": +ildouble: 1 +ldouble: 1 +Test "atan2 (1.390625, 0.9296875) == 0.981498387184244311516296577615519772": +ildouble: 1 +ldouble: 1 + +# atanh +Test "atanh (0.75) == 0.972955074527656652552676371721589865": +ildouble: 1 +ldouble: 1 + +# cacos +Test "Imaginary part of: cacos (+0 + 0.5 i) == pi/2 - 0.4812118250596034474977589134243684231352 i": +double: 2 +idouble: 2 +Test "Imaginary part of: cacos (+0 + 1.0 i) == pi/2 - 0.8813735870195430252326093249797923090282 i": +double: 2 +float: 1 +idouble: 2 +ifloat: 1 +ildouble: 2 +ldouble: 2 +Test "Imaginary part of: cacos (+0 + 1.5 i) == pi/2 - 1.194763217287109304111930828519090523536 i": +double: 2 +float: 1 +idouble: 2 +ifloat: 1 +Test "Imaginary part of: cacos (+0 - 0.5 i) == pi/2 + 0.4812118250596034474977589134243684231352 i": +float: 1 +ifloat: 1 +Test "Imaginary part of: cacos (+0 - 1.0 i) == pi/2 + 0.8813735870195430252326093249797923090282 i": +double: 1 +float: 1 +idouble: 1 +ifloat: 1 +Test "Imaginary part of: cacos (+0 - 1.5 i) == pi/2 + 1.194763217287109304111930828519090523536 i": +double: 1 +idouble: 1 +Test "Imaginary part of: cacos (-0 + 0.5 i) == pi/2 - 0.4812118250596034474977589134243684231352 i": +double: 2 +idouble: 2 +Test "Imaginary part of: cacos (-0 + 1.0 i) == pi/2 - 0.8813735870195430252326093249797923090282 i": +double: 2 +float: 1 +idouble: 2 +ifloat: 1 +ildouble: 2 +ldouble: 2 +Test "Imaginary part of: cacos (-0 + 1.5 i) == pi/2 - 1.194763217287109304111930828519090523536 i": +double: 2 +float: 1 +idouble: 2 +ifloat: 1 +Test "Imaginary part of: cacos (-0 - 0.5 i) == pi/2 + 0.4812118250596034474977589134243684231352 i": +float: 1 +ifloat: 1 +Test "Imaginary part of: cacos (-0 - 1.0 i) == pi/2 + 0.8813735870195430252326093249797923090282 i": +double: 1 +float: 1 +idouble: 1 +ifloat: 1 +Test "Imaginary part of: cacos (-0 - 1.5 i) == pi/2 + 1.194763217287109304111930828519090523536 i": +double: 1 +idouble: 1 +Test "Imaginary part of: cacos (-1.5 + +0 i) == pi - 0.9624236501192068949955178268487368462704 i": +double: 1 +float: 1 +idouble: 1 +ifloat: 1 +Test "Imaginary part of: cacos (-1.5 - 0 i) == pi + 0.9624236501192068949955178268487368462704 i": +ildouble: 1 +ldouble: 1 +Test "Real part of: cacos (0.5 + +0 i) == 1.047197551196597746154214461093167628066 - 0 i": +double: 1 +idouble: 1 +ildouble: 1 +ldouble: 1 +Test "Real part of: cacos (0.5 - 0 i) == 1.047197551196597746154214461093167628066 + +0 i": +double: 1 +idouble: 1 +ildouble: 1 +ldouble: 1 +Test "Real part of: cacos (0.75 + 1.25 i) == 1.11752014915610270578240049553777969 - 1.13239363160530819522266333696834467 i": +float: 2 +ifloat: 2 +ildouble: 1 +ldouble: 1 +Test "Imaginary part of: cacos (0.75 + 1.25 i) == 1.11752014915610270578240049553777969 - 1.13239363160530819522266333696834467 i": +float: 1 +ifloat: 1 +ildouble: 2 +ldouble: 2 +Test "Imaginary part of: cacos (1.5 + +0 i) == +0 - 0.9624236501192068949955178268487368462704 i": +double: 1 +float: 1 +idouble: 1 +ifloat: 1 +Test "Imaginary part of: cacos (1.5 - 0 i) == +0 + 0.9624236501192068949955178268487368462704 i": +ildouble: 1 +ldouble: 1 + +# cacosh +Test "Real part of: cacosh (+0 + 0.5 i) == 0.4812118250596034474977589134243684231352 + pi/2 i": +float: 1 +ifloat: 1 +Test "Real part of: cacosh (+0 + 1.0 i) == 0.8813735870195430252326093249797923090282 + pi/2 i": +double: 1 +float: 1 +idouble: 1 +ifloat: 1 +Test "Real part of: cacosh (+0 + 1.5 i) == 1.194763217287109304111930828519090523536 + pi/2 i": +double: 1 +idouble: 1 +Test "Real part of: cacosh (+0 - 0.5 i) == 0.4812118250596034474977589134243684231352 - pi/2 i": +float: 1 +ifloat: 1 +Test "Real part of: cacosh (+0 - 1.0 i) == 0.8813735870195430252326093249797923090282 - pi/2 i": +double: 1 +float: 1 +idouble: 1 +ifloat: 1 +Test "Real part of: cacosh (+0 - 1.5 i) == 1.194763217287109304111930828519090523536 - pi/2 i": +double: 1 +idouble: 1 +Test "Real part of: cacosh (-0 + 0.5 i) == 0.4812118250596034474977589134243684231352 + pi/2 i": +float: 1 +ifloat: 1 +Test "Real part of: cacosh (-0 + 1.0 i) == 0.8813735870195430252326093249797923090282 + pi/2 i": +double: 1 +float: 1 +idouble: 1 +ifloat: 1 +Test "Real part of: cacosh (-0 + 1.5 i) == 1.194763217287109304111930828519090523536 + pi/2 i": +double: 1 +idouble: 1 +Test "Real part of: cacosh (-0 - 0.5 i) == 0.4812118250596034474977589134243684231352 - pi/2 i": +float: 1 +ifloat: 1 +Test "Real part of: cacosh (-0 - 1.0 i) == 0.8813735870195430252326093249797923090282 - pi/2 i": +double: 1 +float: 1 +idouble: 1 +ifloat: 1 +Test "Real part of: cacosh (-0 - 1.5 i) == 1.194763217287109304111930828519090523536 - pi/2 i": +double: 1 +idouble: 1 +Test "Imaginary part of: cacosh (-0.5 + +0 i) == +0 + 2.094395102393195492308428922186335256131 i": +double: 1 +idouble: 1 +ildouble: 1 +ldouble: 1 +Test "Imaginary part of: cacosh (-0.5 - 0 i) == +0 - 2.094395102393195492308428922186335256131 i": +double: 1 +idouble: 1 +ildouble: 1 +ldouble: 1 +Test "Real part of: cacosh (-1.5 + +0 i) == 0.9624236501192068949955178268487368462704 + pi i": +float: 1 +ifloat: 1 +Test "Real part of: cacosh (-1.5 - 0 i) == 0.9624236501192068949955178268487368462704 - pi i": +float: 1 +ifloat: 1 +Test "Real part of: cacosh (-2 - 3 i) == 1.9833870299165354323470769028940395 - 2.1414491111159960199416055713254211 i": +double: 1 +float: 7 +idouble: 1 +ifloat: 7 +ildouble: 6 +ldouble: 6 +Test "Imaginary part of: cacosh (-2 - 3 i) == 1.9833870299165354323470769028940395 - 2.1414491111159960199416055713254211 i": +double: 1 +idouble: 1 +ildouble: 2 +ldouble: 2 +Test "Real part of: cacosh (0.75 + 1.25 i) == 1.13239363160530819522266333696834467 + 1.11752014915610270578240049553777969 i": +ildouble: 1 +ldouble: 1 +Test "Imaginary part of: cacosh (0.75 + 1.25 i) == 1.13239363160530819522266333696834467 + 1.11752014915610270578240049553777969 i": +float: 1 +ifloat: 1 +Test "Real part of: cacosh (1.5 + +0 i) == 0.9624236501192068949955178268487368462704 + +0 i": +float: 1 +ifloat: 1 +Test "Real part of: cacosh (1.5 - 0 i) == 0.9624236501192068949955178268487368462704 - 0 i": +float: 1 +ifloat: 1 + +# casin +Test "Imaginary part of: casin (+0 + 0.5 i) == +0 + 0.4812118250596034474977589134243684231352 i": +double: 2 +idouble: 2 +Test "Imaginary part of: casin (+0 + 1.0 i) == +0 + 0.8813735870195430252326093249797923090282 i": +double: 2 +float: 1 +idouble: 2 +ifloat: 1 +ildouble: 2 +ldouble: 2 +Test "Imaginary part of: casin (+0 + 1.5 i) == +0 + 1.194763217287109304111930828519090523536 i": +double: 2 +float: 1 +idouble: 2 +ifloat: 1 +Test "Imaginary part of: casin (+0 - 0.5 i) == +0 - 0.4812118250596034474977589134243684231352 i": +float: 1 +ifloat: 1 +Test "Imaginary part of: casin (+0 - 1.0 i) == +0 - 0.8813735870195430252326093249797923090282 i": +double: 1 +float: 1 +idouble: 1 +ifloat: 1 +Test "Imaginary part of: casin (+0 - 1.5 i) == +0 - 1.194763217287109304111930828519090523536 i": +double: 1 +idouble: 1 +Test "Imaginary part of: casin (-0 + 0.5 i) == -0 + 0.4812118250596034474977589134243684231352 i": +double: 2 +idouble: 2 +Test "Imaginary part of: casin (-0 + 1.0 i) == -0 + 0.8813735870195430252326093249797923090282 i": +double: 2 +float: 1 +idouble: 2 +ifloat: 1 +ildouble: 2 +ldouble: 2 +Test "Imaginary part of: casin (-0 + 1.5 i) == -0 + 1.194763217287109304111930828519090523536 i": +double: 2 +float: 1 +idouble: 2 +ifloat: 1 +Test "Imaginary part of: casin (-0 - 0.5 i) == -0 - 0.4812118250596034474977589134243684231352 i": +float: 1 +ifloat: 1 +Test "Imaginary part of: casin (-0 - 1.0 i) == -0 - 0.8813735870195430252326093249797923090282 i": +double: 1 +float: 1 +idouble: 1 +ifloat: 1 +Test "Imaginary part of: casin (-0 - 1.5 i) == -0 - 1.194763217287109304111930828519090523536 i": +double: 1 +idouble: 1 +Test "Imaginary part of: casin (-1.5 + +0 i) == -pi/2 + 0.9624236501192068949955178268487368462704 i": +double: 1 +float: 1 +idouble: 1 +ifloat: 1 +Test "Imaginary part of: casin (-1.5 - 0 i) == -pi/2 - 0.9624236501192068949955178268487368462704 i": +ildouble: 1 +ldouble: 1 +Test "Real part of: casin (0.75 + 1.25 i) == 0.453276177638793913448921196101971749 + 1.13239363160530819522266333696834467 i": +double: 1 +float: 5 +idouble: 1 +ifloat: 5 +ildouble: 3 +ldouble: 3 +Test "Imaginary part of: casin (0.75 + 1.25 i) == 0.453276177638793913448921196101971749 + 1.13239363160530819522266333696834467 i": +float: 1 +ifloat: 1 +ildouble: 2 +ldouble: 2 +Test "Imaginary part of: casin (1.5 + +0 i) == pi/2 + 0.9624236501192068949955178268487368462704 i": +double: 1 +float: 1 +idouble: 1 +ifloat: 1 +Test "Imaginary part of: casin (1.5 - 0 i) == pi/2 - 0.9624236501192068949955178268487368462704 i": +ildouble: 1 +ldouble: 1 + +# casinh +Test "Real part of: casinh (+0 + 1.5 i) == 0.9624236501192068949955178268487368462704 + pi/2 i": +ildouble: 1 +ldouble: 1 +Test "Real part of: casinh (+0 - 1.5 i) == 0.9624236501192068949955178268487368462704 - pi/2 i": +ildouble: 1 +ldouble: 1 +Test "Real part of: casinh (-0 + 1.5 i) == -0.9624236501192068949955178268487368462704 + pi/2 i": +double: 1 +float: 1 +idouble: 1 +ifloat: 1 +Test "Real part of: casinh (-0 - 1.5 i) == -0.9624236501192068949955178268487368462704 - pi/2 i": +double: 1 +float: 1 +idouble: 1 +ifloat: 1 +Test "Real part of: casinh (-0.5 + +0 i) == -0.4812118250596034474977589134243684231352 + +0 i": +double: 2 +idouble: 2 +Test "Real part of: casinh (-0.5 - 0 i) == -0.4812118250596034474977589134243684231352 - 0 i": +double: 2 +idouble: 2 +Test "Real part of: casinh (-1.0 + +0 i) == -0.8813735870195430252326093249797923090282 + +0 i": +double: 2 +float: 1 +idouble: 2 +ifloat: 1 +ildouble: 2 +ldouble: 2 +Test "Real part of: casinh (-1.0 - 0 i) == -0.8813735870195430252326093249797923090282 - 0 i": +double: 2 +float: 1 +idouble: 2 +ifloat: 1 +ildouble: 2 +ldouble: 2 +Test "Real part of: casinh (-1.5 + +0 i) == -1.194763217287109304111930828519090523536 + +0 i": +double: 2 +float: 1 +idouble: 2 +ifloat: 1 +Test "Real part of: casinh (-1.5 - 0 i) == -1.194763217287109304111930828519090523536 - 0 i": +double: 2 +float: 1 +idouble: 2 +ifloat: 1 +Test "Real part of: casinh (-2 - 3 i) == -1.9686379257930962917886650952454982 - 0.96465850440760279204541105949953237 i": +double: 6 +float: 19 +idouble: 6 +ifloat: 19 +ildouble: 5 +ldouble: 5 +Test "Imaginary part of: casinh (-2 - 3 i) == -1.9686379257930962917886650952454982 - 0.96465850440760279204541105949953237 i": +double: 13 +float: 6 +idouble: 13 +ifloat: 6 +ildouble: 6 +ldouble: 6 +Test "Real part of: casinh (0.5 + +0 i) == 0.4812118250596034474977589134243684231352 + +0 i": +float: 1 +ifloat: 1 +Test "Real part of: casinh (0.5 - 0 i) == 0.4812118250596034474977589134243684231352 - 0 i": +float: 1 +ifloat: 1 +Test "Real part of: casinh (0.75 + 1.25 i) == 1.03171853444778027336364058631006594 + 0.911738290968487636358489564316731207 i": +float: 1 +ifloat: 1 +ildouble: 1 +ldouble: 1 +Test "Imaginary part of: casinh (0.75 + 1.25 i) == 1.03171853444778027336364058631006594 + 0.911738290968487636358489564316731207 i": +double: 1 +float: 1 +idouble: 1 +ifloat: 1 +ildouble: 1 +ldouble: 1 +Test "Real part of: casinh (1.0 + +0 i) == 0.8813735870195430252326093249797923090282 + +0 i": +double: 1 +float: 1 +idouble: 1 +ifloat: 1 +Test "Real part of: casinh (1.0 - 0 i) == 0.8813735870195430252326093249797923090282 - 0 i": +double: 1 +float: 1 +idouble: 1 +ifloat: 1 +Test "Real part of: casinh (1.5 + +0 i) == 1.194763217287109304111930828519090523536 + +0 i": +double: 1 +idouble: 1 +Test "Real part of: casinh (1.5 - 0 i) == 1.194763217287109304111930828519090523536 - 0 i": +double: 1 +idouble: 1 + +# catan +Test "Imaginary part of: catan (-2 - 3 i) == -1.4099210495965755225306193844604208 - 0.22907268296853876629588180294200276 i": +double: 1 +float: 1 +idouble: 1 +ifloat: 1 +Test "Real part of: catan (0.75 + 1.25 i) == 1.10714871779409050301706546017853704 + 0.549306144334054845697622618461262852 i": +ildouble: 1 +ldouble: 1 + +# catanh +Test "Real part of: catanh (-2 - 3 i) == -0.14694666622552975204743278515471595 - 1.3389725222944935611241935759091443 i": +float: 1 +ifloat: 1 +ildouble: 1 +ldouble: 1 + +# cbrt +Test "cbrt (-0.001) == -0.1": +ildouble: 1 +ldouble: 1 +Test "cbrt (0.9921875) == 0.997389022060725270579075195353955217": +ildouble: 1 +ldouble: 1 + +# ccos +Test "Real part of: ccos (-2 - 3 i) == -4.18962569096880723013255501961597373 - 9.10922789375533659797919726277886212 i": +float: 1 +ifloat: 1 +Test "Imaginary part of: ccos (-2 - 3 i) == -4.18962569096880723013255501961597373 - 9.10922789375533659797919726277886212 i": +float: 1 +ifloat: 1 +Test "Real part of: ccos (0.75 + 1.25 i) == 1.38173873063425888530729933139078645 - 1.09193013555397466170919531722024128 i": +float: 1 +ifloat: 1 +ildouble: 1 +ldouble: 1 +Test "Imaginary part of: ccos (0.75 + 1.25 i) == 1.38173873063425888530729933139078645 - 1.09193013555397466170919531722024128 i": +float: 1 +ifloat: 1 +ildouble: 1 +ldouble: 1 + +# ccosh +Test "Real part of: ccosh (-2 - 3 i) == -3.72454550491532256547397070325597253 + 0.511822569987384608834463849801875634 i": +float: 1 +ifloat: 1 +Test "Imaginary part of: ccosh (-2 - 3 i) == -3.72454550491532256547397070325597253 + 0.511822569987384608834463849801875634 i": +float: 1 +ifloat: 1 +ildouble: 1 +ldouble: 1 +Test "Real part of: ccosh (0.75 + 1.25 i) == 0.408242591877968807788852146397499084 + 0.780365930845853240391326216300863152 i": +float: 1 +ifloat: 1 +Test "Imaginary part of: ccosh (0.75 + 1.25 i) == 0.408242591877968807788852146397499084 + 0.780365930845853240391326216300863152 i": +float: 1 +ifloat: 1 +ildouble: 1 +ldouble: 1 + +# cexp +Test "Real part of: cexp (-10000 + 0x1p16383 i) == 1.045876464564882298442774542991176546722e-4343 + 4.421154026488516836023811173959413420548e-4344 i": +ildouble: 1 +ldouble: 1 +Test "Real part of: cexp (-2.0 - 3.0 i) == -0.13398091492954261346140525546115575 - 0.019098516261135196432576240858800925 i": +float: 1 +ifloat: 1 +Test "Imaginary part of: cexp (-2.0 - 3.0 i) == -0.13398091492954261346140525546115575 - 0.019098516261135196432576240858800925 i": +float: 1 +ifloat: 1 +Test "Real part of: cexp (-95 + 0.75 i) == 4.039714446238306526889476684000081624047e-42 + 3.763383677300535390271646960780570275931e-42 i": +ildouble: 1 +ldouble: 1 +Test "Real part of: cexp (0.75 + 1.25 i) == 0.667537446429131586942201977015932112 + 2.00900045494094876258347228145863909 i": +float: 2 +ifloat: 2 +Test "Imaginary part of: cexp (0.75 + 1.25 i) == 0.667537446429131586942201977015932112 + 2.00900045494094876258347228145863909 i": +float: 1 +ifloat: 1 +ildouble: 1 +ldouble: 1 +Test "Imaginary part of: cexp (11356.5625 + 0.75 i) == 9.052188470850960144814815984311663764287e4931 + 8.432986734191301036267148978260970230200e4931 i": +ildouble: 1 +ldouble: 1 +Test "Imaginary part of: cexp (50 + 0x1p127 i) == 4.053997150228616856622417636046265337193e21 + 3.232070315463388524466674772633810238819e21 i": +ildouble: 1 +ldouble: 1 +Test "Real part of: cexp (709.8125 + 0.75 i) == 1.355121963080879535248452862759108365762e308 + 1.262426823598609432507811340856186873507e308 i": +ildouble: 1 +ldouble: 1 +Test "Real part of: cexp (88.75 + 0.75 i) == 2.558360358486542817001900410314204322891e38 + 2.383359453227311447654736314679677655100e38 i": +ildouble: 1 +ldouble: 1 +Test "Imaginary part of: cexp (88.75 + 0.75 i) == 2.558360358486542817001900410314204322891e38 + 2.383359453227311447654736314679677655100e38 i": +ildouble: 1 +ldouble: 1 + +# clog +Test "Real part of: clog (0.75 + 1.25 i) == 0.376885901188190075998919126749298416 + 1.03037682652431246378774332703115153 i": +float: 1 +ifloat: 1 +ildouble: 1 +ldouble: 1 +Test "Imaginary part of: clog (0.75 + 1.25 i) == 0.376885901188190075998919126749298416 + 1.03037682652431246378774332703115153 i": +ildouble: 1 +ldouble: 1 +Test "Real part of: clog (0x1.fp+16383 + 0x1p+16383 i) == 11356.60974243783798653123798337822335902 + 0.4764674194737066993385333770295162295856 i": +ildouble: 1 +ldouble: 1 +Test "Imaginary part of: clog (0x1.fp+16383 + 0x1p+16383 i) == 11356.60974243783798653123798337822335902 + 0.4764674194737066993385333770295162295856 i": +ildouble: 1 +ldouble: 1 + +# clog10 +Test "Imaginary part of: clog10 (-0 + inf i) == inf + pi/2*log10(e) i": +float: 1 +ifloat: 1 +Test "Imaginary part of: clog10 (-0 - inf i) == inf - pi/2*log10(e) i": +float: 1 +ifloat: 1 +Test "Real part of: clog10 (-2 - 3 i) == 0.556971676153418384603252578971164214 - 0.937554462986374708541507952140189646 i": +ildouble: 1 +ldouble: 1 +Test "Imaginary part of: clog10 (-3 + inf i) == inf + pi/2*log10(e) i": +float: 1 +ifloat: 1 +Test "Imaginary part of: clog10 (-3 - inf i) == inf - pi/2*log10(e) i": +float: 1 +ifloat: 1 +Test "Imaginary part of: clog10 (-inf + 0 i) == inf + pi*log10(e) i": +float: 1 +ifloat: 1 +Test "Imaginary part of: clog10 (-inf + 1 i) == inf + pi*log10(e) i": +float: 1 +ifloat: 1 +Test "Imaginary part of: clog10 (-inf + inf i) == inf + 3/4 pi*log10(e) i": +double: 1 +idouble: 1 +Test "Imaginary part of: clog10 (-inf - 0 i) == inf - pi*log10(e) i": +float: 1 +ifloat: 1 +Test "Imaginary part of: clog10 (-inf - 1 i) == inf - pi*log10(e) i": +float: 1 +ifloat: 1 +Test "Imaginary part of: clog10 (0 + inf i) == inf + pi/2*log10(e) i": +float: 1 +ifloat: 1 +Test "Imaginary part of: clog10 (0 - inf i) == inf - pi/2*log10(e) i": +float: 1 +ifloat: 1 +Test "Real part of: clog10 (0.75 + 1.25 i) == 0.163679467193165171449476605077428975 + 0.447486970040493067069984724340855636 i": +double: 1 +float: 1 +idouble: 1 +ifloat: 1 +ildouble: 1 +ldouble: 1 +Test "Imaginary part of: clog10 (0.75 + 1.25 i) == 0.163679467193165171449476605077428975 + 0.447486970040493067069984724340855636 i": +double: 1 +idouble: 1 +ildouble: 2 +ldouble: 2 +Test "Imaginary part of: clog10 (0x1p-16440 + 0x1p-16441 i) == -4948.884673709346821106688037612752099609 + 0.2013595981366865710389502301937289472543 i": +ildouble: 1 +ldouble: 1 +Test "Imaginary part of: clog10 (3 + inf i) == inf + pi/2*log10(e) i": +float: 1 +ifloat: 1 +Test "Imaginary part of: clog10 (3 - inf i) == inf - pi/2*log10(e) i": +float: 1 +ifloat: 1 +Test "Imaginary part of: clog10 (inf + inf i) == inf + pi/4*log10(e) i": +float: 1 +ifloat: 1 +Test "Imaginary part of: clog10 (inf - inf i) == inf - pi/4*log10(e) i": +float: 1 +ifloat: 1 + +# cos +Test "cos (M_PI_6l * 2.0) == 0.5": +double: 1 +float: 1 +idouble: 1 +ifloat: 1 +ildouble: 1 +ldouble: 1 +Test "cos (M_PI_6l * 4.0) == -0.5": +double: 2 +float: 1 +idouble: 2 +ifloat: 1 +ildouble: 1 +ldouble: 1 +Test "cos (pi/2) == 0": +double: 1 +float: 1 +idouble: 1 +ifloat: 1 +ildouble: 1 +ldouble: 1 + +# cos_downward +Test "cos_downward (1) == 0.5403023058681397174009366074429766037323": +double: 1 +idouble: 1 +ildouble: 1 +ldouble: 1 +Test "cos_downward (10) == -0.8390715290764524522588639478240648345199": +double: 1 +float: 1 +idouble: 1 +ifloat: 1 +Test "cos_downward (3) == -0.9899924966004454572715727947312613023937": +double: 1 +idouble: 1 +Test "cos_downward (4) == -0.6536436208636119146391681830977503814241": +float: 1 +ifloat: 1 +ildouble: 1 +ldouble: 1 +Test "cos_downward (5) == 0.2836621854632262644666391715135573083344": +float: 1 +ifloat: 1 +Test "cos_downward (7) == 0.7539022543433046381411975217191820122183": +float: 1 +ifloat: 1 +ildouble: 1 +ldouble: 1 +Test "cos_downward (8) == -0.1455000338086135258688413818311946826093": +ildouble: 1 +ldouble: 1 +Test "cos_downward (9) == -0.9111302618846769883682947111811653112463": +double: 1 +float: 1 +idouble: 1 +ifloat: 1 +ildouble: 1 +ldouble: 1 + +# cos_towardzero +Test "cos_towardzero (1) == 0.5403023058681397174009366074429766037323": +double: 1 +idouble: 1 +ildouble: 1 +ldouble: 1 +Test "cos_towardzero (10) == -0.8390715290764524522588639478240648345199": +ildouble: 1 +ldouble: 1 +Test "cos_towardzero (2) == -0.4161468365471423869975682295007621897660": +double: 1 +float: 1 +idouble: 1 +ifloat: 1 +ildouble: 1 +ldouble: 1 +Test "cos_towardzero (3) == -0.9899924966004454572715727947312613023937": +float: 1 +ifloat: 1 +ildouble: 1 +ldouble: 1 +Test "cos_towardzero (4) == -0.6536436208636119146391681830977503814241": +double: 1 +idouble: 1 +Test "cos_towardzero (5) == 0.2836621854632262644666391715135573083344": +float: 1 +ifloat: 1 +Test "cos_towardzero (7) == 0.7539022543433046381411975217191820122183": +float: 1 +ifloat: 1 +ildouble: 1 +ldouble: 1 +Test "cos_towardzero (8) == -0.1455000338086135258688413818311946826093": +double: 1 +float: 1 +idouble: 1 +ifloat: 1 + +# cos_upward +Test "cos_upward (1) == 0.5403023058681397174009366074429766037323": +float: 1 +ifloat: 1 +Test "cos_upward (10) == -0.8390715290764524522588639478240648345199": +ildouble: 1 +ldouble: 1 +Test "cos_upward (2) == -0.4161468365471423869975682295007621897660": +double: 1 +float: 1 +idouble: 1 +ifloat: 1 +ildouble: 1 +ldouble: 1 +Test "cos_upward (3) == -0.9899924966004454572715727947312613023937": +float: 1 +ifloat: 1 +ildouble: 1 +ldouble: 1 +Test "cos_upward (4) == -0.6536436208636119146391681830977503814241": +double: 1 +idouble: 1 +Test "cos_upward (5) == 0.2836621854632262644666391715135573083344": +double: 1 +idouble: 1 +ildouble: 1 +ldouble: 1 +Test "cos_upward (6) == 0.9601702866503660205456522979229244054519": +double: 1 +float: 1 +idouble: 1 +ifloat: 1 +ildouble: 1 +ldouble: 1 +Test "cos_upward (7) == 0.7539022543433046381411975217191820122183": +double: 1 +idouble: 1 +Test "cos_upward (8) == -0.1455000338086135258688413818311946826093": +double: 1 +float: 1 +idouble: 1 +ifloat: 1 + +# cosh_downward +Test "cosh_downward (22) == 1792456423.065795780980053377632656584997": +double: 1 +float: 1 +idouble: 1 +ifloat: 1 +Test "cosh_downward (23) == 4872401723.124451300068625740569997090344": +double: 1 +float: 1 +idouble: 1 +ifloat: 1 +ildouble: 1 +ldouble: 1 +Test "cosh_downward (24) == 13244561064.92173614708845674912733665919": +float: 1 +ifloat: 1 +ildouble: 1 +ldouble: 1 + +# cosh_towardzero +Test "cosh_towardzero (22) == 1792456423.065795780980053377632656584997": +double: 1 +float: 1 +idouble: 1 +ifloat: 1 +Test "cosh_towardzero (23) == 4872401723.124451300068625740569997090344": +double: 1 +float: 1 +idouble: 1 +ifloat: 1 +ildouble: 1 +ldouble: 1 +Test "cosh_towardzero (24) == 13244561064.92173614708845674912733665919": +float: 1 +ifloat: 1 +ildouble: 1 +ldouble: 1 + +# cosh_upward +Test "cosh_upward (22) == 1792456423.065795780980053377632656584997": +ildouble: 1 +ldouble: 1 +Test "cosh_upward (24) == 13244561064.92173614708845674912733665919": +double: 1 +idouble: 1 + +# cpow +Test "Real part of: cpow (0.75 + 1.25 i, 0.0 + 1.0 i) == 0.331825439177608832276067945276730566 + 0.131338600281188544930936345230903032 i": +float: 1 +ifloat: 1 +Test "Imaginary part of: cpow (0.75 + 1.25 i, 0.0 + 1.0 i) == 0.331825439177608832276067945276730566 + 0.131338600281188544930936345230903032 i": +float: 1 +ifloat: 1 +ildouble: 1 +ldouble: 1 +Test "Real part of: cpow (0.75 + 1.25 i, 0.75 + 1.25 i) == 0.117506293914473555420279832210420483 + 0.346552747708338676483025352060418001 i": +float: 3 +ifloat: 3 +ildouble: 9 +ldouble: 9 +Test "Imaginary part of: cpow (0.75 + 1.25 i, 0.75 + 1.25 i) == 0.117506293914473555420279832210420483 + 0.346552747708338676483025352060418001 i": +float: 1 +ifloat: 1 +ildouble: 1 +ldouble: 1 +Test "Real part of: cpow (0.75 + 1.25 i, 1.0 + 0.0 i) == 0.75 + 1.25 i": +float: 2 +ifloat: 2 +ildouble: 2 +ldouble: 2 +Test "Imaginary part of: cpow (0.75 + 1.25 i, 1.0 + 0.0 i) == 0.75 + 1.25 i": +float: 2 +ifloat: 2 +ildouble: 1 +ldouble: 1 +Test "Real part of: cpow (0.75 + 1.25 i, 1.0 + 1.0 i) == 0.0846958290317209430433805274189191353 + 0.513285749182902449043287190519090481 i": +double: 1 +float: 3 +idouble: 1 +ifloat: 3 +ildouble: 15 +ldouble: 15 +Test "Imaginary part of: cpow (0.75 + 1.25 i, 1.0 + 1.0 i) == 0.0846958290317209430433805274189191353 + 0.513285749182902449043287190519090481 i": +float: 1 +ifloat: 1 +ildouble: 1 +ldouble: 1 +Test "Real part of: cpow (2 + 0 i, 10 + 0 i) == 1024.0 + 0.0 i": +ildouble: 5 +ldouble: 5 +Test "Real part of: cpow (2 + 3 i, 4 + 0 i) == -119.0 - 120.0 i": +double: 1 +float: 1 +idouble: 1 +ifloat: 1 +ildouble: 4 +ldouble: 4 +Test "Imaginary part of: cpow (2 + 3 i, 4 + 0 i) == -119.0 - 120.0 i": +float: 6 +ifloat: 6 +ildouble: 2 +ldouble: 2 +Test "Real part of: cpow (e + 0 i, 0 + 2 * M_PIl i) == 1.0 + 0.0 i": +float: 1 +ifloat: 1 +Test "Imaginary part of: cpow (e + 0 i, 0 + 2 * M_PIl i) == 1.0 + 0.0 i": +double: 2 +float: 3 +idouble: 2 +ifloat: 3 +ildouble: 1 +ldouble: 1 + +# csin +Test "Real part of: csin (-2 - 3 i) == -9.15449914691142957346729954460983256 + 4.16890695996656435075481305885375484 i": +float: 1 +ifloat: 1 +Test "Imaginary part of: csin (-2 - 3 i) == -9.15449914691142957346729954460983256 + 4.16890695996656435075481305885375484 i": +float: 1 +ifloat: 1 +Test "Real part of: csin (0.75 + 1.25 i) == 1.28722291002649188575873510790565441 + 1.17210635989270256101081285116138863 i": +float: 1 +ifloat: 1 +ildouble: 1 +ldouble: 1 +Test "Imaginary part of: csin (0.75 + 1.25 i) == 1.28722291002649188575873510790565441 + 1.17210635989270256101081285116138863 i": +float: 1 +ifloat: 1 + +# csinh +Test "Real part of: csinh (-2 - 3 i) == 3.59056458998577995201256544779481679 - 0.530921086248519805267040090660676560 i": +float: 1 +ifloat: 1 +Test "Imaginary part of: csinh (-2 - 3 i) == 3.59056458998577995201256544779481679 - 0.530921086248519805267040090660676560 i": +float: 1 +ifloat: 1 +Test "Real part of: csinh (0.75 + 1.25 i) == 0.259294854551162779153349830618433028 + 1.22863452409509552219214606515777594 i": +float: 1 +ifloat: 1 +ildouble: 1 +ldouble: 1 +Test "Imaginary part of: csinh (0.75 + 1.25 i) == 0.259294854551162779153349830618433028 + 1.22863452409509552219214606515777594 i": +float: 1 +ifloat: 1 + +# csqrt +Test "Real part of: csqrt (0x1.fffffffffffffp+1023 + 0x1.fffffffffffffp+1023 i) == 1.473094556905565378990473658199034571917e+154 + 6.101757441282702188537080005372547713595e+153 i": +double: 1 +idouble: 1 +Test "Imaginary part of: csqrt (0x1.fffffffffffffp+1023 + 0x1.fffffffffffffp+1023 i) == 1.473094556905565378990473658199034571917e+154 + 6.101757441282702188537080005372547713595e+153 i": +double: 1 +idouble: 1 +Test "Imaginary part of: csqrt (0x1.fffffffffffffp+1023 + 0x1p+1023 i) == 1.379778091031440685006200821918878702861e+154 + 3.257214233483129514781233066898042490248e+153 i": +ildouble: 1 +ldouble: 1 +Test "Imaginary part of: csqrt (0x1.fp+16383 + 0x1.fp+16383 i) == 1.179514222452201722651836720466795901016e+2466 + 4.885707879516577666702435054303191575148e+2465 i": +ildouble: 1 +ldouble: 1 +Test "Imaginary part of: csqrt (0x1p-1073 + 0x1p-1073 i) == 3.453664695497464982856905711457966660085e-162 + 1.430554756764195530630723976279903095110e-162 i": +ildouble: 1 +ldouble: 1 +Test "Imaginary part of: csqrt (0x1p-1074 + 0x1p-1074 i) == 2.442109726130830256743814843868934877597e-162 + 1.011554969366634726113090867589031782487e-162 i": +ildouble: 1 +ldouble: 1 +Test "Imaginary part of: csqrt (0x1p-147 + 0x1p-147 i) == 8.225610928685557596194006925540350401606e-23 + 3.407159605465907500737319471202779419102e-23 i": +ildouble: 1 +ldouble: 1 +Test "Imaginary part of: csqrt (0x1p-149 + 0x1p-149 i) == 4.112805464342778798097003462770175200803e-23 + 1.703579802732953750368659735601389709551e-23 i": +ildouble: 1 +ldouble: 1 + +# ctan +Test "Real part of: ctan (-2 - 3 i) == 0.376402564150424829275122113032269084e-2 - 1.00323862735360980144635859782192726 i": +double: 1 +idouble: 1 +ildouble: 2 +ldouble: 2 +Test "Imaginary part of: ctan (-2 - 3 i) == 0.376402564150424829275122113032269084e-2 - 1.00323862735360980144635859782192726 i": +float: 1 +ifloat: 1 +ildouble: 1 +ldouble: 1 +Test "Real part of: ctan (0.75 + 1.25 i) == 0.160807785916206426725166058173438663 + 0.975363285031235646193581759755216379 i": +ildouble: 1 +ldouble: 1 +Test "Imaginary part of: ctan (0.75 + 1.25 i) == 0.160807785916206426725166058173438663 + 0.975363285031235646193581759755216379 i": +float: 1 +ifloat: 1 +ildouble: 2 +ldouble: 2 +Test "Real part of: ctan (0x1p1023 + 1 i) == -0.2254627924997545057926782581695274244229 + 0.8786063118883068695462540226219865087189 i": +ildouble: 1 +ldouble: 1 +Test "Real part of: ctan (0x1p127 + 1 i) == 0.2446359391192790896381501310437708987204 + 0.9101334047676183761532873794426475906201 i": +double: 1 +float: 1 +idouble: 1 +ifloat: 1 +Test "Imaginary part of: ctan (0x1p127 + 1 i) == 0.2446359391192790896381501310437708987204 + 0.9101334047676183761532873794426475906201 i": +ildouble: 1 +ldouble: 1 +Test "Imaginary part of: ctan (0x1p16383 + 1 i) == 0.1608598776370396607204448234354670036772 + 0.8133818522051542536316746743877629761488 i": +ildouble: 1 +ldouble: 1 +Test "Real part of: ctan (0x3.243f6cp-1 + 0 i) == -2.287733242885645987394874673945769518150e7 + 0.0 i": +float: 1 +ifloat: 1 +Test "Real part of: ctan (1 + 45 i) == 1.490158918874345552942703234806348520895e-39 + 1.000000000000000000000000000000000000001 i": +ildouble: 1 +ldouble: 1 +Test "Real part of: ctan (1 + 47 i) == 2.729321264492904590777293425576722354636e-41 + 1.0 i": +ildouble: 2 +ldouble: 2 +Test "Real part of: ctan (1 + 5680 i) == 4.725214596136812019616700920476949798307e-4934 + 1.0 i": +ildouble: 1 +ldouble: 1 + +# ctanh +Test "Real part of: ctanh (-2 - 3 i) == -0.965385879022133124278480269394560686 + 0.988437503832249372031403430350121098e-2 i": +ildouble: 1 +ldouble: 1 +Test "Imaginary part of: ctanh (-2 - 3 i) == -0.965385879022133124278480269394560686 + 0.988437503832249372031403430350121098e-2 i": +float: 1 +ifloat: 1 +ildouble: 1 +ldouble: 1 +Test "Imaginary part of: ctanh (0 + 0x3.243f6cp-1 i) == 0.0 - 2.287733242885645987394874673945769518150e7 i": +float: 1 +ifloat: 1 +Test "Imaginary part of: ctanh (0 + pi/4 i) == 0.0 + 1.0 i": +double: 1 +idouble: 1 +ildouble: 1 +ldouble: 1 +Test "Real part of: ctanh (0.75 + 1.25 i) == 1.37260757053378320258048606571226857 + 0.385795952609750664177596760720790220 i": +float: 1 +ifloat: 1 +Test "Imaginary part of: ctanh (0.75 + 1.25 i) == 1.37260757053378320258048606571226857 + 0.385795952609750664177596760720790220 i": +double: 1 +float: 1 +idouble: 1 +ifloat: 1 +ildouble: 1 +ldouble: 1 +Test "Imaginary part of: ctanh (1 + 0x1p1023 i) == 0.8786063118883068695462540226219865087189 - 0.2254627924997545057926782581695274244229 i": +ildouble: 1 +ldouble: 1 +Test "Real part of: ctanh (1 + 0x1p127 i) == 0.9101334047676183761532873794426475906201 + 0.2446359391192790896381501310437708987204 i": +ildouble: 1 +ldouble: 1 +Test "Imaginary part of: ctanh (1 + 0x1p127 i) == 0.9101334047676183761532873794426475906201 + 0.2446359391192790896381501310437708987204 i": +double: 1 +float: 1 +idouble: 1 +ifloat: 1 +Test "Real part of: ctanh (1 + 0x1p16383 i) == 0.8133818522051542536316746743877629761488 + 0.1608598776370396607204448234354670036772 i": +ildouble: 1 +ldouble: 1 +Test "Imaginary part of: ctanh (45 + 1 i) == 1.000000000000000000000000000000000000001 + 1.490158918874345552942703234806348520895e-39 i": +ildouble: 1 +ldouble: 1 +Test "Imaginary part of: ctanh (47 + 1 i) == 1.0 + 2.729321264492904590777293425576722354636e-41 i": +ildouble: 2 +ldouble: 2 +Test "Imaginary part of: ctanh (5680 + 1 i) == 1.0 + 4.725214596136812019616700920476949798307e-4934 i": +ildouble: 1 +ldouble: 1 + +# erfc +Test "erfc (0.75) == 0.288844366346484868401062165408589223": +float: 1 +ifloat: 1 +Test "erfc (0x1.f7303cp+1) == 2.705500297238986897105236321218861842255e-8": +ildouble: 1 +ldouble: 1 +Test "erfc (0x1.ffa002p+2) == 1.233585992097580296336099501489175967033e-29": +float: 1 +ifloat: 1 +ildouble: 1 +ldouble: 1 +Test "erfc (0x1.ffffc8p+2) == 1.122671365033056305522366683719541099329e-29": +ildouble: 1 +ldouble: 1 +Test "erfc (1.25) == 0.0770998717435417698634765188027188596": +ildouble: 1 +ldouble: 1 +Test "erfc (2.0) == 0.00467773498104726583793074363274707139": +float: 1 +ifloat: 1 +Test "erfc (4.125) == 0.542340079956506600531223408575531062e-8": +float: 1 +ifloat: 1 +ildouble: 1 +ldouble: 1 + +# exp_downward +Test "exp_downward (1) == e": +ildouble: 1 +ldouble: 1 +Test "exp_downward (2) == e^2": +double: 1 +float: 1 +idouble: 1 +ifloat: 1 +ildouble: 1 +ldouble: 1 +Test "exp_downward (3) == e^3": +double: 1 +float: 1 +idouble: 1 +ifloat: 1 +ildouble: 1 +ldouble: 1 + +# exp_towardzero +Test "exp_towardzero (1) == e": +ildouble: 1 +ldouble: 1 +Test "exp_towardzero (2) == e^2": +double: 1 +float: 1 +idouble: 1 +ifloat: 1 +ildouble: 1 +ldouble: 1 +Test "exp_towardzero (3) == e^3": +double: 1 +float: 1 +idouble: 1 +ifloat: 1 +ildouble: 1 +ldouble: 1 + +# exp_upward +Test "exp_upward (1) == e": +double: 1 +float: 1 +idouble: 1 +ifloat: 1 + +# expm1 +Test "expm1 (1) == M_El - 1.0": +ildouble: 1 +ldouble: 1 + +# gamma +Test "gamma (-0.5) == log(2*sqrt(pi))": +ildouble: 1 +ldouble: 1 +Test "gamma (0.5) == log(sqrt(pi))": +ildouble: 1 +ldouble: 1 +Test "gamma (3) == M_LN2l": +ildouble: 1 +ldouble: 1 + +# hypot +Test "hypot (-0.7, -12.4) == 12.419742348374220601176836866763271": +float: 1 +ifloat: 1 +Test "hypot (-0.7, 12.4) == 12.419742348374220601176836866763271": +float: 1 +ifloat: 1 +Test "hypot (-12.4, -0.7) == 12.419742348374220601176836866763271": +float: 1 +ifloat: 1 +Test "hypot (-12.4, 0.7) == 12.419742348374220601176836866763271": +float: 1 +ifloat: 1 +Test "hypot (0.7, -12.4) == 12.419742348374220601176836866763271": +float: 1 +ifloat: 1 +Test "hypot (0.7, 12.4) == 12.419742348374220601176836866763271": +float: 1 +ifloat: 1 +Test "hypot (12.4, -0.7) == 12.419742348374220601176836866763271": +float: 1 +ifloat: 1 +Test "hypot (12.4, 0.7) == 12.419742348374220601176836866763271": +float: 1 +ifloat: 1 + +# j0 +Test "j0 (-0x1.001000001p+593) == -3.927269966354206207832593635798954916263e-90": +ildouble: 2 +ldouble: 2 +Test "j0 (-4.0) == -3.9714980986384737228659076845169804197562E-1": +float: 1 +ifloat: 1 +ildouble: 2 +ldouble: 2 +Test "j0 (0.75) == 0.864242275166648623555731103820923211": +float: 1 +ifloat: 1 +Test "j0 (0x1.d7ce3ap+107) == 2.775523647291230802651040996274861694514e-17": +float: 2 +ifloat: 2 +Test "j0 (1.5) == 0.511827671735918128749051744283411720": +float: 1 +ifloat: 1 +Test "j0 (10.0) == -0.245935764451348335197760862485328754": +double: 1 +idouble: 1 +Test "j0 (4.0) == -3.9714980986384737228659076845169804197562E-1": +float: 1 +ifloat: 1 +ildouble: 2 +ldouble: 2 +Test "j0 (8.0) == 0.171650807137553906090869407851972001": +float: 1 +ifloat: 1 + +# j1 +Test "j1 (-1.0) == -0.440050585744933515959682203718914913": +float: 1 +ifloat: 1 +Test "j1 (0x1.3ffp+74) == 1.818984347516051243459364437186082741567e-12": +float: 1 +ifloat: 1 +ildouble: 1 +ldouble: 1 +Test "j1 (1.0) == 0.440050585744933515959682203718914913": +float: 1 +ifloat: 1 +Test "j1 (1.5) == 0.557936507910099641990121213156089400": +float: 1 +ifloat: 1 +Test "j1 (10.0) == 0.0434727461688614366697487680258592883": +float: 2 +ifloat: 2 +ildouble: 1 +ldouble: 1 +Test "j1 (2.0) == 0.576724807756873387202448242269137087": +float: 1 +ifloat: 1 +Test "j1 (8.0) == 0.234636346853914624381276651590454612": +float: 1 +ifloat: 1 +ildouble: 1 +ldouble: 1 + +# jn +Test "jn (0, -4.0) == -3.9714980986384737228659076845169804197562E-1": +float: 1 +ifloat: 1 +ildouble: 2 +ldouble: 2 +Test "jn (0, 0.75) == 0.864242275166648623555731103820923211": +float: 1 +ifloat: 1 +Test "jn (0, 1.5) == 0.511827671735918128749051744283411720": +float: 1 +ifloat: 1 +Test "jn (0, 10.0) == -0.245935764451348335197760862485328754": +double: 1 +idouble: 1 +Test "jn (0, 4.0) == -3.9714980986384737228659076845169804197562E-1": +float: 1 +ifloat: 1 +ildouble: 2 +ldouble: 2 +Test "jn (0, 8.0) == 0.171650807137553906090869407851972001": +float: 1 +ifloat: 1 +Test "jn (1, -1.0) == -0.440050585744933515959682203718914913": +float: 1 +ifloat: 1 +Test "jn (1, 1.0) == 0.440050585744933515959682203718914913": +float: 1 +ifloat: 1 +Test "jn (1, 1.5) == 0.557936507910099641990121213156089400": +float: 1 +ifloat: 1 +Test "jn (1, 10.0) == 0.0434727461688614366697487680258592883": +float: 2 +ifloat: 2 +ildouble: 1 +ldouble: 1 +Test "jn (1, 2.0) == 0.576724807756873387202448242269137087": +float: 1 +ifloat: 1 +Test "jn (1, 8.0) == 0.234636346853914624381276651590454612": +float: 1 +ifloat: 1 +ildouble: 1 +ldouble: 1 +Test "jn (10, -1.0) == 0.263061512368745320699785368779050294e-9": +float: 2 +ifloat: 2 +ildouble: 1 +ldouble: 1 +Test "jn (10, 0.125) == 0.250543369809369890173993791865771547e-18": +float: 1 +ifloat: 1 +Test "jn (10, 0.75) == 0.149621713117596814698712483621682835e-10": +double: 1 +float: 2 +idouble: 1 +ifloat: 2 +ildouble: 2 +ldouble: 2 +Test "jn (10, 1.0) == 0.263061512368745320699785368779050294e-9": +float: 2 +ifloat: 2 +ildouble: 1 +ldouble: 1 +Test "jn (10, 10.0) == 0.207486106633358857697278723518753428": +double: 1 +float: 5 +idouble: 1 +ifloat: 5 +ildouble: 2 +ldouble: 2 +Test "jn (10, 2.0) == 0.251538628271673670963516093751820639e-6": +float: 3 +ifloat: 3 +ildouble: 1 +ldouble: 1 +Test "jn (2, 0x1.ffff62p+99) == -4.43860668048170034334926693188979974489e-16": +float: 1 +ifloat: 1 +ildouble: 1 +ldouble: 1 +Test "jn (2, 2.4048255576957729) == 0.43175480701968038399746111312430703": +float: 1 +ifloat: 1 +ildouble: 1 +ldouble: 1 +Test "jn (3, -1.0) == -0.0195633539826684059189053216217515083": +float: 1 +ifloat: 1 +ildouble: 1 +ldouble: 1 +Test "jn (3, 1.0) == 0.0195633539826684059189053216217515083": +float: 1 +ifloat: 1 +ildouble: 1 +ldouble: 1 +Test "jn (3, 10.0) == 0.0583793793051868123429354784103409563": +double: 1 +float: 1 +idouble: 1 +ifloat: 1 +ildouble: 1 +ldouble: 1 +Test "jn (3, 2.0) == 0.128943249474402051098793332969239835": +float: 1 +ifloat: 1 +ildouble: 1 +ldouble: 1 +Test "jn (3, 2.4048255576957729) == 0.19899990535769083404042146764530813": +float: 2 +ifloat: 2 +ildouble: 1 +ldouble: 1 +Test "jn (4, 2.4048255576957729) == 0.647466661641779720084932282551219891E-1": +float: 1 +ifloat: 1 +ildouble: 2 +ldouble: 2 +Test "jn (5, 2.4048255576957729) == 0.163892432048058525099230549946147698E-1": +double: 1 +float: 2 +idouble: 1 +ifloat: 2 +ildouble: 3 +ldouble: 3 +Test "jn (6, 2.4048255576957729) == 0.34048184720278336646673682895929161E-2": +float: 4 +ifloat: 4 +ildouble: 1 +ldouble: 1 +Test "jn (7, 2.4048255576957729) == 0.60068836573295394221291569249883076E-3": +float: 5 +ifloat: 5 +Test "jn (8, 2.4048255576957729) == 0.92165786705344923232879022467054148E-4": +float: 4 +ifloat: 4 +ildouble: 2 +ldouble: 2 +Test "jn (9, 2.4048255576957729) == 0.12517270977961513005428966643852564E-4": +float: 3 +ifloat: 3 +ildouble: 2 +ldouble: 2 + +# lgamma +Test "lgamma (-0.5) == log(2*sqrt(pi))": +ildouble: 1 +ldouble: 1 +Test "lgamma (0.5) == log(sqrt(pi))": +ildouble: 1 +ldouble: 1 +Test "lgamma (0.7) == 0.260867246531666514385732417016759578": +float: 1 +ifloat: 1 +ildouble: 1 +ldouble: 1 +Test "lgamma (1.2) == -0.853740900033158497197028392998854470e-1": +double: 1 +float: 2 +idouble: 1 +ifloat: 2 +ildouble: 1 +ldouble: 1 +Test "lgamma (3) == M_LN2l": +ildouble: 1 +ldouble: 1 + +# log +Test "log (0.75) == -0.287682072451780927439219005993827432": +ildouble: 1 +ldouble: 1 +Test "log (2) == M_LN2l": +ildouble: 1 +ldouble: 1 +Test "log (e) == 1": +float: 1 +ifloat: 1 + +# log10 +Test "log10 (0.75) == -0.124938736608299953132449886193870744": +ildouble: 2 +ldouble: 2 +Test "log10 (e) == log10(e)": +float: 1 +ifloat: 1 +ildouble: 1 +ldouble: 1 + +# log1p +Test "log1p (-0.25) == -0.287682072451780927439219005993827432": +ildouble: 1 +ldouble: 1 + +# log2 +Test "log2 (0.75) == -.415037499278843818546261056052183492": +ildouble: 1 +ldouble: 1 + +# pow +Test "pow (0.75, 1.25) == 0.697953644326574699205914060237425566": +ildouble: 1 +ldouble: 1 +Test "pow (0x1p64, 0.125) == 256": +ildouble: 1 +ldouble: 1 +Test "pow (256, 8) == 0x1p64": +float: 1 +ifloat: 1 +ildouble: 7 +ldouble: 7 + +# pow_downward +Test "pow_downward (1.0625, 1.125) == 1.070582293028761362162622578677070098674": +double: 1 +idouble: 1 +ildouble: 1 +ldouble: 1 +Test "pow_downward (1.5, 1.03125) == 1.519127098714743184071644334163037684948": +float: 1 +ifloat: 1 +ildouble: 1 +ldouble: 1 + +# pow_towardzero +Test "pow_towardzero (1.0625, 1.125) == 1.070582293028761362162622578677070098674": +double: 1 +idouble: 1 +ildouble: 1 +ldouble: 1 +Test "pow_towardzero (1.5, 1.03125) == 1.519127098714743184071644334163037684948": +float: 1 +ifloat: 1 +ildouble: 1 +ldouble: 1 + +# pow_upward +Test "pow_upward (1.0625, 1.125) == 1.070582293028761362162622578677070098674": +float: 1 +ifloat: 1 +ildouble: 1 +ldouble: 1 +Test "pow_upward (1.5, 1.03125) == 1.519127098714743184071644334163037684948": +double: 1 +idouble: 1 +ildouble: 1 +ldouble: 1 + +# sin_downward +Test "sin_downward (1) == 0.8414709848078965066525023216302989996226": +ildouble: 1 +ldouble: 1 +Test "sin_downward (10) == -0.5440211108893698134047476618513772816836": +double: 1 +idouble: 1 +ildouble: 1 +ldouble: 1 +Test "sin_downward (2) == 0.9092974268256816953960198659117448427023": +double: 1 +idouble: 1 +Test "sin_downward (3) == 0.1411200080598672221007448028081102798469": +ildouble: 1 +ldouble: 1 +Test "sin_downward (4) == -0.7568024953079282513726390945118290941359": +double: 1 +idouble: 1 +ildouble: 1 +ldouble: 1 +Test "sin_downward (5) == -0.9589242746631384688931544061559939733525": +double: 1 +idouble: 1 +ildouble: 1 +ldouble: 1 +Test "sin_downward (6) == -0.2794154981989258728115554466118947596280": +double: 1 +float: 1 +idouble: 1 +ifloat: 1 +ildouble: 1 +ldouble: 1 +Test "sin_downward (7) == 0.6569865987187890903969990915936351779369": +ildouble: 1 +ldouble: 1 +Test "sin_downward (8) == 0.9893582466233817778081235982452886721164": +double: 1 +idouble: 1 +ildouble: 1 +ldouble: 1 +Test "sin_downward (9) == 0.4121184852417565697562725663524351793439": +double: 1 +float: 1 +idouble: 1 +ifloat: 1 +ildouble: 1 +ldouble: 1 + +# sin_towardzero +Test "sin_towardzero (1) == 0.8414709848078965066525023216302989996226": +ildouble: 1 +ldouble: 1 +Test "sin_towardzero (10) == -0.5440211108893698134047476618513772816836": +float: 1 +ifloat: 1 +Test "sin_towardzero (2) == 0.9092974268256816953960198659117448427023": +double: 1 +idouble: 1 +Test "sin_towardzero (3) == 0.1411200080598672221007448028081102798469": +ildouble: 1 +ldouble: 1 +Test "sin_towardzero (4) == -0.7568024953079282513726390945118290941359": +float: 1 +ifloat: 1 +Test "sin_towardzero (5) == -0.9589242746631384688931544061559939733525": +float: 1 +ifloat: 1 +Test "sin_towardzero (7) == 0.6569865987187890903969990915936351779369": +ildouble: 1 +ldouble: 1 +Test "sin_towardzero (8) == 0.9893582466233817778081235982452886721164": +double: 1 +idouble: 1 +ildouble: 1 +ldouble: 1 +Test "sin_towardzero (9) == 0.4121184852417565697562725663524351793439": +double: 1 +float: 1 +idouble: 1 +ifloat: 1 +ildouble: 1 +ldouble: 1 + +# sin_upward +Test "sin_upward (1) == 0.8414709848078965066525023216302989996226": +double: 1 +float: 1 +idouble: 1 +ifloat: 1 +Test "sin_upward (10) == -0.5440211108893698134047476618513772816836": +float: 1 +ifloat: 1 +Test "sin_upward (2) == 0.9092974268256816953960198659117448427023": +float: 1 +ifloat: 1 +ildouble: 1 +ldouble: 1 +Test "sin_upward (3) == 0.1411200080598672221007448028081102798469": +double: 1 +float: 1 +idouble: 1 +ifloat: 1 +Test "sin_upward (4) == -0.7568024953079282513726390945118290941359": +float: 1 +ifloat: 1 +Test "sin_upward (5) == -0.9589242746631384688931544061559939733525": +float: 1 +ifloat: 1 +Test "sin_upward (7) == 0.6569865987187890903969990915936351779369": +double: 1 +float: 1 +idouble: 1 +ifloat: 1 +Test "sin_upward (8) == 0.9893582466233817778081235982452886721164": +float: 1 +ifloat: 1 + +# sincos +Test "sincos (M_PI_6l*2.0, &sin_res, &cos_res) puts 0.5 in cos_res": +double: 1 +float: 1 +idouble: 1 +ifloat: 1 +ildouble: 1 +ldouble: 1 +Test "sincos (M_PI_6l*2.0, &sin_res, &cos_res) puts 0.86602540378443864676372317075293616 in sin_res": +double: 1 +float: 1 +idouble: 1 +ifloat: 1 +ildouble: 1 +ldouble: 1 +Test "sincos (pi/2, &sin_res, &cos_res) puts 0 in cos_res": +double: 1 +float: 1 +idouble: 1 +ifloat: 1 +ildouble: 1 +ldouble: 1 + +# sinh +Test "sinh (0.75) == 0.822316731935829980703661634446913849": +ildouble: 1 +ldouble: 1 + +# sinh_downward +Test "sinh_downward (22) == 1792456423.065795780701106568345764104225": +double: 1 +float: 1 +idouble: 1 +ifloat: 1 +ildouble: 1 +ldouble: 1 +Test "sinh_downward (23) == 4872401723.124451299966006944252978187305": +double: 1 +float: 1 +idouble: 1 +ifloat: 1 +ildouble: 1 +ldouble: 1 +Test "sinh_downward (24) == 13244561064.92173614705070540368454568168": +float: 1 +ifloat: 1 +ildouble: 1 +ldouble: 1 + +# sinh_towardzero +Test "sinh_towardzero (22) == 1792456423.065795780701106568345764104225": +double: 1 +float: 1 +idouble: 1 +ifloat: 1 +ildouble: 1 +ldouble: 1 +Test "sinh_towardzero (23) == 4872401723.124451299966006944252978187305": +double: 1 +float: 1 +idouble: 1 +ifloat: 1 +ildouble: 1 +ldouble: 1 +Test "sinh_towardzero (24) == 13244561064.92173614705070540368454568168": +float: 1 +ifloat: 1 +ildouble: 1 +ldouble: 1 + +# sinh_upward +Test "sinh_upward (24) == 13244561064.92173614705070540368454568168": +double: 1 +idouble: 1 + +# tan +Test "tan (0.75) == 0.931596459944072461165202756573936428": +ildouble: 1 +ldouble: 1 +Test "tan (pi/4) == 1": +double: 1 +idouble: 1 + +# tan_downward +Test "tan_downward (1) == 1.5574077246549022305069748074583601730873": +double: 1 +float: 1 +idouble: 1 +ifloat: 1 +Test "tan_downward (10) == 0.6483608274590866712591249330098086768169": +float: 1 +ifloat: 1 +ildouble: 1 +ldouble: 1 +Test "tan_downward (2) == -2.1850398632615189916433061023136825434320": +double: 1 +float: 1 +idouble: 1 +ifloat: 1 +Test "tan_downward (3) == -0.1425465430742778052956354105339134932261": +double: 1 +idouble: 1 +ildouble: 1 +ldouble: 1 +Test "tan_downward (4) == 1.1578212823495775831373424182673239231198": +float: 1 +ifloat: 1 +ildouble: 1 +ldouble: 1 +Test "tan_downward (5) == -3.3805150062465856369827058794473439087096": +ildouble: 1 +ldouble: 1 +Test "tan_downward (6) == -0.2910061913847491570536995888681755428312": +double: 1 +float: 1 +idouble: 1 +ifloat: 1 +Test "tan_downward (7) == 0.8714479827243187364564508896003135663222": +double: 1 +idouble: 1 +Test "tan_downward (8) == -6.7997114552203786999252627596086333648814": +float: 1 +ifloat: 1 +Test "tan_downward (9) == -0.4523156594418098405903708757987855343087": +float: 1 +ifloat: 1 + +# tan_towardzero +Test "tan_towardzero (1) == 1.5574077246549022305069748074583601730873": +double: 1 +float: 1 +idouble: 1 +ifloat: 1 +Test "tan_towardzero (10) == 0.6483608274590866712591249330098086768169": +float: 1 +ifloat: 1 +ildouble: 1 +ldouble: 1 +Test "tan_towardzero (2) == -2.1850398632615189916433061023136825434320": +ildouble: 1 +ldouble: 1 +Test "tan_towardzero (3) == -0.1425465430742778052956354105339134932261": +float: 1 +ifloat: 1 +Test "tan_towardzero (4) == 1.1578212823495775831373424182673239231198": +float: 1 +ifloat: 1 +ildouble: 1 +ldouble: 1 +Test "tan_towardzero (5) == -3.3805150062465856369827058794473439087096": +double: 1 +float: 1 +idouble: 1 +ifloat: 1 +Test "tan_towardzero (6) == -0.2910061913847491570536995888681755428312": +ildouble: 1 +ldouble: 1 +Test "tan_towardzero (7) == 0.8714479827243187364564508896003135663222": +double: 1 +idouble: 1 +Test "tan_towardzero (8) == -6.7997114552203786999252627596086333648814": +double: 1 +idouble: 1 +ildouble: 1 +ldouble: 1 +Test "tan_towardzero (9) == -0.4523156594418098405903708757987855343087": +double: 1 +idouble: 1 +ildouble: 1 +ldouble: 1 + +# tan_upward +Test "tan_upward (1) == 1.5574077246549022305069748074583601730873": +ildouble: 1 +ldouble: 1 +Test "tan_upward (10) == 0.6483608274590866712591249330098086768169": +double: 1 +idouble: 1 +Test "tan_upward (2) == -2.1850398632615189916433061023136825434320": +ildouble: 1 +ldouble: 1 +Test "tan_upward (3) == -0.1425465430742778052956354105339134932261": +float: 1 +ifloat: 1 +Test "tan_upward (4) == 1.1578212823495775831373424182673239231198": +double: 1 +idouble: 1 +Test "tan_upward (5) == -3.3805150062465856369827058794473439087096": +double: 1 +float: 1 +idouble: 1 +ifloat: 1 +Test "tan_upward (6) == -0.2910061913847491570536995888681755428312": +ildouble: 1 +ldouble: 1 +Test "tan_upward (7) == 0.8714479827243187364564508896003135663222": +float: 1 +ifloat: 1 +ildouble: 1 +ldouble: 1 +Test "tan_upward (8) == -6.7997114552203786999252627596086333648814": +double: 1 +idouble: 1 +ildouble: 1 +ldouble: 1 +Test "tan_upward (9) == -0.4523156594418098405903708757987855343087": +double: 1 +idouble: 1 +ildouble: 1 +ldouble: 1 + +# tgamma +Test "tgamma (-0.5) == -2 sqrt (pi)": +double: 1 +float: 1 +idouble: 1 +ifloat: 1 +ildouble: 1 +ldouble: 1 +Test "tgamma (0.5) == sqrt (pi)": +float: 1 +ifloat: 1 +ildouble: 1 +ldouble: 1 +Test "tgamma (0.7) == 1.29805533264755778568117117915281162": +double: 1 +float: 1 +idouble: 1 +ifloat: 1 +Test "tgamma (4) == 6": +ildouble: 1 +ldouble: 1 + +# y0 +Test "y0 (0.125) == -1.38968062514384052915582277745018693": +double: 1 +float: 1 +idouble: 1 +ifloat: 1 +ildouble: 1 +ldouble: 1 +Test "y0 (0.75) == -0.137172769385772397522814379396581855": +double: 1 +float: 1 +idouble: 1 +ifloat: 1 +ildouble: 2 +ldouble: 2 +Test "y0 (0x1.3ffp+74) == 1.818984347516051243459467456433028748678e-12": +float: 1 +ifloat: 1 +ildouble: 1 +ldouble: 1 +Test "y0 (1.0) == 0.0882569642156769579829267660235151628": +ildouble: 1 +ldouble: 1 +Test "y0 (1.5) == 0.382448923797758843955068554978089862": +float: 1 +ifloat: 1 +ildouble: 1 +ldouble: 1 +Test "y0 (10.0) == 0.0556711672835993914244598774101900481": +float: 1 +ifloat: 1 +ildouble: 1 +ldouble: 1 +Test "y0 (2.0) == 0.510375672649745119596606592727157873": +float: 1 +ifloat: 1 +Test "y0 (8.0) == 0.223521489387566220527323400498620359": +float: 1 +ifloat: 1 +ildouble: 1 +ldouble: 1 + +# y1 +Test "y1 (0.125) == -5.19993611253477499595928744876579921": +ildouble: 1 +ldouble: 1 +Test "y1 (0x1.001000001p+593) == 3.927269966354206207832593635798954916263e-90": +ildouble: 2 +ldouble: 2 +Test "y1 (0x1.27e204p+99) == -8.881610148467797208469612080785210013461e-16": +double: 1 +float: 2 +idouble: 1 +ifloat: 2 +ildouble: 1 +ldouble: 1 +Test "y1 (1.0) == -0.781212821300288716547150000047964821": +double: 1 +idouble: 1 +Test "y1 (10.0) == 0.249015424206953883923283474663222803": +float: 1 +ifloat: 1 +Test "y1 (2.0) == -0.107032431540937546888370772277476637": +float: 2 +ifloat: 2 +ildouble: 1 +ldouble: 1 +Test "y1 (8.0) == -0.158060461731247494255555266187483550": +float: 1 +ifloat: 1 +ildouble: 1 +ldouble: 1 + +# yn +Test "yn (0, 0.125) == -1.38968062514384052915582277745018693": +double: 1 +float: 1 +idouble: 1 +ifloat: 1 +ildouble: 1 +ldouble: 1 +Test "yn (0, 0.75) == -0.137172769385772397522814379396581855": +double: 1 +float: 1 +idouble: 1 +ifloat: 1 +ildouble: 2 +ldouble: 2 +Test "yn (0, 1.0) == 0.0882569642156769579829267660235151628": +ildouble: 1 +ldouble: 1 +Test "yn (0, 1.5) == 0.382448923797758843955068554978089862": +float: 1 +ifloat: 1 +ildouble: 1 +ldouble: 1 +Test "yn (0, 10.0) == 0.0556711672835993914244598774101900481": +float: 1 +ifloat: 1 +ildouble: 1 +ldouble: 1 +Test "yn (0, 2.0) == 0.510375672649745119596606592727157873": +float: 1 +ifloat: 1 +Test "yn (0, 8.0) == 0.223521489387566220527323400498620359": +float: 1 +ifloat: 1 +ildouble: 1 +ldouble: 1 +Test "yn (1, 0.125) == -5.19993611253477499595928744876579921": +float: 1 +ifloat: 1 +ildouble: 1 +ldouble: 1 +Test "yn (1, 0.75) == -1.03759455076928541973767132140642198": +float: 1 +ifloat: 1 +Test "yn (1, 1.0) == -0.781212821300288716547150000047964821": +double: 1 +idouble: 1 +Test "yn (1, 10.0) == 0.249015424206953883923283474663222803": +float: 1 +ifloat: 1 +Test "yn (1, 2.0) == -0.107032431540937546888370772277476637": +float: 2 +ifloat: 2 +ildouble: 1 +ldouble: 1 +Test "yn (1, 8.0) == -0.158060461731247494255555266187483550": +float: 1 +ifloat: 1 +ildouble: 1 +ldouble: 1 +Test "yn (10, 0.125) == -127057845771019398.252538486899753195": +double: 1 +idouble: 1 +ildouble: 2 +ldouble: 2 +Test "yn (10, 0.75) == -2133501638.90573424452445412893839236": +float: 1 +ifloat: 1 +ildouble: 4 +ldouble: 4 +Test "yn (10, 10.0) == -0.359814152183402722051986577343560609": +double: 1 +float: 1 +idouble: 1 +ifloat: 1 +Test "yn (3, 0.125) == -2612.69757350066712600220955744091741": +ildouble: 1 +ldouble: 1 +Test "yn (3, 0.75) == -12.9877176234475433186319774484809207": +double: 1 +float: 1 +idouble: 1 +ifloat: 1 +ildouble: 2 +ldouble: 2 +Test "yn (3, 2.0) == -1.12778377684042778608158395773179238": +float: 1 +ifloat: 1 + +# Maximal error of functions: +Function: "acos_downward": +double: 1 +float: 1 +idouble: 1 +ifloat: 1 +ildouble: 1 +ldouble: 1 + +Function: "acos_towardzero": +double: 1 +float: 1 +idouble: 1 +ifloat: 1 +ildouble: 1 +ldouble: 1 + +Function: "acos_upward": +double: 1 +idouble: 1 +ildouble: 1 +ldouble: 1 + +Function: "acosh": +double: 1 +idouble: 1 +ildouble: 1 +ldouble: 1 + +Function: "asin_downward": +double: 1 +float: 1 +idouble: 1 +ifloat: 1 +ildouble: 1 +ldouble: 1 + +Function: "asin_towardzero": +double: 1 +float: 1 +idouble: 1 +ifloat: 1 +ildouble: 1 +ldouble: 1 + +Function: "asin_upward": +double: 1 +float: 1 +idouble: 1 +ifloat: 1 +ildouble: 1 +ldouble: 1 + +Function: "asinh": +ildouble: 1 +ldouble: 1 + +Function: "atan2": +ildouble: 1 +ldouble: 1 + +Function: "atanh": +ildouble: 1 +ldouble: 1 + +Function: Real part of "cacos": +double: 1 +float: 2 +idouble: 1 +ifloat: 2 +ildouble: 1 +ldouble: 1 + +Function: Imaginary part of "cacos": +double: 2 +float: 1 +idouble: 2 +ifloat: 1 +ildouble: 2 +ldouble: 2 + +Function: Real part of "cacosh": +double: 1 +float: 7 +idouble: 1 +ifloat: 7 +ildouble: 6 +ldouble: 6 + +Function: Imaginary part of "cacosh": +double: 1 +float: 1 +idouble: 1 +ifloat: 1 +ildouble: 2 +ldouble: 2 + +Function: Real part of "casin": +double: 1 +float: 5 +idouble: 1 +ifloat: 5 +ildouble: 3 +ldouble: 3 + +Function: Imaginary part of "casin": +double: 2 +float: 1 +idouble: 2 +ifloat: 1 +ildouble: 2 +ldouble: 2 + +Function: Real part of "casinh": +double: 6 +float: 1 +idouble: 6 +ifloat: 1 +ildouble: 5 +ldouble: 5 + +Function: Imaginary part of "casinh": +double: 13 +float: 6 +idouble: 13 +ifloat: 6 +ildouble: 6 +ldouble: 6 + +Function: Real part of "catan": +ildouble: 1 +ldouble: 1 + +Function: Imaginary part of "catan": +double: 1 +float: 1 +idouble: 1 +ifloat: 1 + +Function: Real part of "catanh": +float: 1 +ifloat: 1 +ildouble: 1 +ldouble: 1 + +Function: "cbrt": +ildouble: 1 +ldouble: 1 + +Function: Real part of "ccos": +float: 1 +ifloat: 1 +ildouble: 1 +ldouble: 1 + +Function: Imaginary part of "ccos": +float: 1 +ifloat: 1 +ildouble: 1 +ldouble: 1 + +Function: Real part of "ccosh": +float: 1 +ifloat: 1 + +Function: Imaginary part of "ccosh": +float: 1 +ifloat: 1 +ildouble: 1 +ldouble: 1 + +Function: Real part of "cexp": +float: 2 +ifloat: 2 +ildouble: 1 +ldouble: 1 + +Function: Imaginary part of "cexp": +float: 1 +ifloat: 1 +ildouble: 1 +ldouble: 1 + +Function: Real part of "clog": +float: 1 +ifloat: 1 +ildouble: 1 +ldouble: 1 + +Function: Imaginary part of "clog": +ildouble: 1 +ldouble: 1 + +Function: Real part of "clog10": +double: 1 +float: 1 +idouble: 1 +ifloat: 1 +ildouble: 1 +ldouble: 1 + +Function: Imaginary part of "clog10": +double: 1 +float: 1 +idouble: 1 +ifloat: 1 +ildouble: 2 +ldouble: 2 + +Function: "cos": +double: 2 +float: 1 +idouble: 2 +ifloat: 1 +ildouble: 1 +ldouble: 1 + +Function: "cos_downward": +double: 1 +float: 1 +idouble: 1 +ifloat: 1 +ildouble: 1 +ldouble: 1 + +Function: "cos_towardzero": +double: 1 +float: 1 +idouble: 1 +ifloat: 1 +ildouble: 1 +ldouble: 1 + +Function: "cos_upward": +double: 1 +float: 1 +idouble: 1 +ifloat: 1 +ildouble: 1 +ldouble: 1 + +Function: "cosh_downward": +double: 1 +float: 1 +idouble: 1 +ifloat: 1 +ildouble: 1 +ldouble: 1 + +Function: "cosh_towardzero": +double: 1 +float: 1 +idouble: 1 +ifloat: 1 +ildouble: 1 +ldouble: 1 + +Function: "cosh_upward": +double: 1 +idouble: 1 +ildouble: 1 +ldouble: 1 + +Function: Real part of "cpow": +double: 1 +float: 3 +idouble: 1 +ifloat: 3 +ildouble: 15 +ldouble: 15 + +Function: Imaginary part of "cpow": +double: 2 +float: 5 +idouble: 2 +ifloat: 5 +ildouble: 2 +ldouble: 2 + +Function: Real part of "csin": +float: 1 +ifloat: 1 +ildouble: 1 +ldouble: 1 + +Function: Imaginary part of "csin": +float: 1 +ifloat: 1 + +Function: Real part of "csinh": +float: 1 +ifloat: 1 +ildouble: 1 +ldouble: 1 + +Function: Imaginary part of "csinh": +float: 1 +ifloat: 1 + +Function: Real part of "csqrt": +double: 1 +idouble: 1 + +Function: Imaginary part of "csqrt": +double: 1 +idouble: 1 +ildouble: 1 +ldouble: 1 + +Function: Real part of "ctan": +double: 1 +float: 1 +idouble: 1 +ifloat: 1 +ildouble: 2 +ldouble: 2 + +Function: Imaginary part of "ctan": +float: 1 +ifloat: 1 +ildouble: 1 +ldouble: 1 + +Function: Real part of "ctanh": +float: 1 +ifloat: 1 +ildouble: 1 +ldouble: 1 + +Function: Imaginary part of "ctanh": +double: 1 +float: 1 +idouble: 1 +ifloat: 1 +ildouble: 2 +ldouble: 2 + +Function: "erfc": +float: 1 +ifloat: 1 +ildouble: 1 +ldouble: 1 + +Function: "exp_downward": +double: 1 +float: 1 +idouble: 1 +ifloat: 1 +ildouble: 1 +ldouble: 1 + +Function: "exp_towardzero": +double: 1 +float: 1 +idouble: 1 +ifloat: 1 +ildouble: 1 +ldouble: 1 + +Function: "exp_upward": +double: 1 +float: 1 +idouble: 1 +ifloat: 1 + +Function: "expm1": +ildouble: 1 +ldouble: 1 + +Function: "gamma": +ildouble: 1 +ldouble: 1 + +Function: "hypot": +float: 1 +ifloat: 1 + +Function: "j0": +double: 1 +float: 2 +idouble: 1 +ifloat: 2 +ildouble: 2 +ldouble: 2 + +Function: "j1": +float: 2 +ifloat: 2 +ildouble: 1 +ldouble: 1 + +Function: "jn": +double: 1 +float: 5 +idouble: 1 +ifloat: 5 +ildouble: 3 +ldouble: 3 + +Function: "lgamma": +double: 1 +float: 2 +idouble: 1 +ifloat: 2 +ildouble: 1 +ldouble: 1 + +Function: "log": +float: 1 +ifloat: 1 +ildouble: 1 +ldouble: 1 + +Function: "log10": +float: 1 +ifloat: 1 +ildouble: 2 +ldouble: 2 + +Function: "log1p": +ildouble: 1 +ldouble: 1 + +Function: "log2": +ildouble: 1 +ldouble: 1 + +Function: "pow": +float: 1 +ifloat: 1 +ildouble: 7 +ldouble: 7 + +Function: "pow_downward": +double: 1 +float: 1 +idouble: 1 +ifloat: 1 +ildouble: 1 +ldouble: 1 + +Function: "pow_towardzero": +double: 1 +float: 1 +idouble: 1 +ifloat: 1 +ildouble: 1 +ldouble: 1 + +Function: "pow_upward": +double: 1 +float: 1 +idouble: 1 +ifloat: 1 +ildouble: 1 +ldouble: 1 + +Function: "sin_downward": +double: 1 +float: 1 +idouble: 1 +ifloat: 1 +ildouble: 1 +ldouble: 1 + +Function: "sin_towardzero": +double: 1 +float: 1 +idouble: 1 +ifloat: 1 +ildouble: 1 +ldouble: 1 + +Function: "sin_upward": +double: 1 +float: 1 +idouble: 1 +ifloat: 1 +ildouble: 1 +ldouble: 1 + +Function: "sincos": +double: 1 +float: 1 +idouble: 1 +ifloat: 1 +ildouble: 1 +ldouble: 1 + +Function: "sinh": +ildouble: 1 +ldouble: 1 + +Function: "sinh_downward": +double: 1 +float: 1 +idouble: 1 +ifloat: 1 +ildouble: 1 +ldouble: 1 + +Function: "sinh_towardzero": +double: 1 +float: 1 +idouble: 1 +ifloat: 1 +ildouble: 1 +ldouble: 1 + +Function: "sinh_upward": +double: 1 +idouble: 1 + +Function: "tan": +double: 1 +idouble: 1 +ildouble: 1 +ldouble: 1 + +Function: "tan_downward": +double: 1 +float: 1 +idouble: 1 +ifloat: 1 +ildouble: 1 +ldouble: 1 + +Function: "tan_towardzero": +double: 1 +float: 1 +idouble: 1 +ifloat: 1 +ildouble: 1 +ldouble: 1 + +Function: "tan_upward": +double: 1 +float: 1 +idouble: 1 +ifloat: 1 +ildouble: 1 +ldouble: 1 + +Function: "tgamma": +double: 1 +float: 1 +idouble: 1 +ifloat: 1 +ildouble: 1 +ldouble: 1 + +Function: "y0": +double: 1 +float: 1 +idouble: 1 +ifloat: 1 +ildouble: 2 +ldouble: 2 + +Function: "y1": +double: 1 +float: 2 +idouble: 1 +ifloat: 2 +ildouble: 2 +ldouble: 2 + +Function: "yn": +double: 1 +float: 2 +idouble: 1 +ifloat: 2 +ildouble: 4 +ldouble: 4 + +# end of automatic generation diff --git a/ports/sysdeps/m68k/m680x0/fpu/math_private.h b/ports/sysdeps/m68k/m680x0/fpu/math_private.h new file mode 100644 index 0000000000..217de2ecc2 --- /dev/null +++ b/ports/sysdeps/m68k/m680x0/fpu/math_private.h @@ -0,0 +1,19 @@ +#ifndef _MATH_PRIVATE_H + +#define math_opt_barrier(x) \ +({ __typeof (x) __x; \ + __asm ("" : "=f" (__x) : "0" (x)); \ + __x; }) +#define math_force_eval(x) \ +do \ + { \ + __typeof (x) __x = (x); \ + if (sizeof (x) <= sizeof (double)) \ + __asm __volatile ("" : : "m" (__x)); \ + else \ + __asm __volatile ("" : : "f" (__x)); \ + } \ +while (0) + +#include_next <math_private.h> +#endif diff --git a/ports/sysdeps/m68k/m680x0/fpu/mathimpl.h b/ports/sysdeps/m68k/m680x0/fpu/mathimpl.h new file mode 100644 index 0000000000..5acc203aa5 --- /dev/null +++ b/ports/sysdeps/m68k/m680x0/fpu/mathimpl.h @@ -0,0 +1,93 @@ +/* Definitions of libc internal inline math functions implemented + by the m68881/2. + Copyright (C) 1991,92,93,94,96,97,98,99 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, see + <http://www.gnu.org/licenses/>. */ + +/* This file contains the definitions of the inline math functions that + are only used internally inside libm, not visible to the user. */ + +__inline_mathop (__ieee754_acos, acos) +__inline_mathop (__ieee754_asin, asin) +__inline_mathop (__ieee754_cosh, cosh) +__inline_mathop (__ieee754_sinh, sinh) +__inline_mathop (__ieee754_exp, etox) +__inline_mathop (__ieee754_exp2, twotox) +__inline_mathop (__ieee754_exp10, tentox) +__inline_mathop (__ieee754_log10, log10) +__inline_mathop (__ieee754_log2, log2) +__inline_mathop (__ieee754_log, logn) +__inline_mathop (__ieee754_sqrt, sqrt) +__inline_mathop (__ieee754_atanh, atanh) + +__m81_defun (double, __ieee754_remainder, (double __x, double __y)) +{ + double __result; + __asm ("frem%.x %1, %0" : "=f" (__result) : "f" (__y), "0" (__x)); + return __result; +} + +__m81_defun (float, __ieee754_remainderf, (float __x, float __y)) +{ + float __result; + __asm ("frem%.x %1, %0" : "=f" (__result) : "f" (__y), "0" (__x)); + return __result; +} + +__m81_defun (long double, + __ieee754_remainderl, (long double __x, long double __y)) +{ + long double __result; + __asm ("frem%.x %1, %0" : "=f" (__result) : "f" (__y), "0" (__x)); + return __result; +} + +__m81_defun (double, __ieee754_fmod, (double __x, double __y)) +{ + double __result; + __asm ("fmod%.x %1, %0" : "=f" (__result) : "f" (__y), "0" (__x)); + return __result; +} + +__m81_defun (float, __ieee754_fmodf, (float __x, float __y)) +{ + float __result; + __asm ("fmod%.x %1, %0" : "=f" (__result) : "f" (__y), "0" (__x)); + return __result; +} + +__m81_defun (long double, + __ieee754_fmodl, (long double __x, long double __y)) +{ + long double __result; + __asm ("fmod%.x %1, %0" : "=f" (__result) : "f" (__y), "0" (__x)); + return __result; +} + +/* Get the m68881 condition codes, to quickly check multiple conditions. */ +static __inline__ unsigned long +__m81_test (long double __val) +{ + unsigned long __fpsr; + __asm ("ftst%.x %1; fmove%.l %/fpsr,%0" : "=dm" (__fpsr) : "f" (__val)); + return __fpsr; +} + +/* Bit values returned by __m81_test. */ +#define __M81_COND_NAN (1 << 24) +#define __M81_COND_INF (2 << 24) +#define __M81_COND_ZERO (4 << 24) +#define __M81_COND_NEG (8 << 24) diff --git a/ports/sysdeps/m68k/m680x0/fpu/mpa.c b/ports/sysdeps/m68k/m680x0/fpu/mpa.c new file mode 100644 index 0000000000..1cc8931700 --- /dev/null +++ b/ports/sysdeps/m68k/m680x0/fpu/mpa.c @@ -0,0 +1 @@ +/* Not needed. */ diff --git a/ports/sysdeps/m68k/m680x0/fpu/mpatan.c b/ports/sysdeps/m68k/m680x0/fpu/mpatan.c new file mode 100644 index 0000000000..1cc8931700 --- /dev/null +++ b/ports/sysdeps/m68k/m680x0/fpu/mpatan.c @@ -0,0 +1 @@ +/* Not needed. */ diff --git a/ports/sysdeps/m68k/m680x0/fpu/mpatan2.c b/ports/sysdeps/m68k/m680x0/fpu/mpatan2.c new file mode 100644 index 0000000000..1cc8931700 --- /dev/null +++ b/ports/sysdeps/m68k/m680x0/fpu/mpatan2.c @@ -0,0 +1 @@ +/* Not needed. */ diff --git a/ports/sysdeps/m68k/m680x0/fpu/mpexp.c b/ports/sysdeps/m68k/m680x0/fpu/mpexp.c new file mode 100644 index 0000000000..1cc8931700 --- /dev/null +++ b/ports/sysdeps/m68k/m680x0/fpu/mpexp.c @@ -0,0 +1 @@ +/* Not needed. */ diff --git a/ports/sysdeps/m68k/m680x0/fpu/mplog.c b/ports/sysdeps/m68k/m680x0/fpu/mplog.c new file mode 100644 index 0000000000..1cc8931700 --- /dev/null +++ b/ports/sysdeps/m68k/m680x0/fpu/mplog.c @@ -0,0 +1 @@ +/* Not needed. */ diff --git a/ports/sysdeps/m68k/m680x0/fpu/mpsqrt.c b/ports/sysdeps/m68k/m680x0/fpu/mpsqrt.c new file mode 100644 index 0000000000..1cc8931700 --- /dev/null +++ b/ports/sysdeps/m68k/m680x0/fpu/mpsqrt.c @@ -0,0 +1 @@ +/* Not needed. */ diff --git a/ports/sysdeps/m68k/m680x0/fpu/mptan.c b/ports/sysdeps/m68k/m680x0/fpu/mptan.c new file mode 100644 index 0000000000..1cc8931700 --- /dev/null +++ b/ports/sysdeps/m68k/m680x0/fpu/mptan.c @@ -0,0 +1 @@ +/* Not needed. */ diff --git a/ports/sysdeps/m68k/m680x0/fpu/s_atan.c b/ports/sysdeps/m68k/m680x0/fpu/s_atan.c new file mode 100644 index 0000000000..a7d8a296b4 --- /dev/null +++ b/ports/sysdeps/m68k/m680x0/fpu/s_atan.c @@ -0,0 +1,37 @@ +/* Copyright (C) 1996, 1997 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, see + <http://www.gnu.org/licenses/>. */ + +#include <math.h> + +#ifndef FUNC +#define FUNC atan +#endif +#ifndef float_type +#define float_type double +#endif + +#define __CONCATX(a,b) __CONCAT(a,b) + +float_type +__CONCATX(__,FUNC) (x) + float_type x; +{ + return __m81_u(__CONCATX(__,FUNC))(x); +} + +#define weak_aliasx(a,b) weak_alias(a,b) +weak_aliasx (__CONCATX(__,FUNC), FUNC) diff --git a/ports/sysdeps/m68k/m680x0/fpu/s_atanf.c b/ports/sysdeps/m68k/m680x0/fpu/s_atanf.c new file mode 100644 index 0000000000..c98559a8ba --- /dev/null +++ b/ports/sysdeps/m68k/m680x0/fpu/s_atanf.c @@ -0,0 +1,5 @@ +#ifndef FUNC +#define FUNC atanf +#endif +#define float_type float +#include <s_atan.c> diff --git a/ports/sysdeps/m68k/m680x0/fpu/s_atanl.c b/ports/sysdeps/m68k/m680x0/fpu/s_atanl.c new file mode 100644 index 0000000000..b7e608addd --- /dev/null +++ b/ports/sysdeps/m68k/m680x0/fpu/s_atanl.c @@ -0,0 +1,5 @@ +#ifndef FUNC +#define FUNC atanl +#endif +#define float_type long double +#include <s_atan.c> diff --git a/ports/sysdeps/m68k/m680x0/fpu/s_ccosh.c b/ports/sysdeps/m68k/m680x0/fpu/s_ccosh.c new file mode 100644 index 0000000000..b8360853fd --- /dev/null +++ b/ports/sysdeps/m68k/m680x0/fpu/s_ccosh.c @@ -0,0 +1,77 @@ +/* Complex cosine hyperbole function. m68k fpu version + Copyright (C) 1997, 1999, 2010, 2012 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 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, see + <http://www.gnu.org/licenses/>. */ + +#include <complex.h> +#include <math.h> +#include "mathimpl.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)) + +__complex__ float_type +s(__ccosh) (__complex__ float_type x) +{ + __complex__ float_type retval; + unsigned long ix_cond = __m81_test (__imag__ x); + + if ((ix_cond & (__M81_COND_INF|__M81_COND_NAN)) == 0) + { + /* Imaginary part is finite. */ + float_type sin_ix, cos_ix; + + __asm ("fsincos%.x %2,%1:%0" : "=f" (sin_ix), "=f" (cos_ix) + : "f" (__imag__ x)); + __real__ retval = cos_ix * m81(__ieee754_cosh) (__real__ x); + if (ix_cond & __M81_COND_ZERO) + __imag__ retval = (signbit (__real__ x) + ? -__imag__ x : __imag__ x); + else + __imag__ retval = sin_ix * m81(__ieee754_sinh) (__real__ x); + } + else + { + unsigned long rx_cond = __m81_test (__real__ x); + + if (rx_cond & __M81_COND_ZERO) + { + __real__ retval = __imag__ x - __imag__ x; + __imag__ retval = __real__ x; + } + else + { + if (rx_cond & __M81_COND_INF) + __real__ retval = s(fabs) (__real__ x); + else + __real__ retval = s(__nan) (""); + __imag__ retval = __imag__ x - __imag__ x; + } + } + + return retval; +} +#define weak_aliasx(a,b) weak_alias(a,b) +weak_aliasx (s(__ccosh), s(ccosh)) diff --git a/ports/sysdeps/m68k/m680x0/fpu/s_ccoshf.c b/ports/sysdeps/m68k/m680x0/fpu/s_ccoshf.c new file mode 100644 index 0000000000..3c8e7c7bb7 --- /dev/null +++ b/ports/sysdeps/m68k/m680x0/fpu/s_ccoshf.c @@ -0,0 +1,3 @@ +#define SUFF f +#define float_type float +#include <s_ccosh.c> diff --git a/ports/sysdeps/m68k/m680x0/fpu/s_ccoshl.c b/ports/sysdeps/m68k/m680x0/fpu/s_ccoshl.c new file mode 100644 index 0000000000..772d5786cf --- /dev/null +++ b/ports/sysdeps/m68k/m680x0/fpu/s_ccoshl.c @@ -0,0 +1,3 @@ +#define SUFF l +#define float_type long double +#include <s_ccosh.c> diff --git a/ports/sysdeps/m68k/m680x0/fpu/s_ceil.c b/ports/sysdeps/m68k/m680x0/fpu/s_ceil.c new file mode 100644 index 0000000000..93d5ad72e5 --- /dev/null +++ b/ports/sysdeps/m68k/m680x0/fpu/s_ceil.c @@ -0,0 +1,2 @@ +#define FUNC ceil +#include <s_atan.c> diff --git a/ports/sysdeps/m68k/m680x0/fpu/s_ceilf.c b/ports/sysdeps/m68k/m680x0/fpu/s_ceilf.c new file mode 100644 index 0000000000..b3ba6a5700 --- /dev/null +++ b/ports/sysdeps/m68k/m680x0/fpu/s_ceilf.c @@ -0,0 +1,2 @@ +#define FUNC ceilf +#include <s_atanf.c> diff --git a/ports/sysdeps/m68k/m680x0/fpu/s_ceill.c b/ports/sysdeps/m68k/m680x0/fpu/s_ceill.c new file mode 100644 index 0000000000..2bf95b00c6 --- /dev/null +++ b/ports/sysdeps/m68k/m680x0/fpu/s_ceill.c @@ -0,0 +1,2 @@ +#define FUNC ceill +#include <s_atanl.c> diff --git a/ports/sysdeps/m68k/m680x0/fpu/s_cexp.c b/ports/sysdeps/m68k/m680x0/fpu/s_cexp.c new file mode 100644 index 0000000000..c2a9f1d22e --- /dev/null +++ b/ports/sysdeps/m68k/m680x0/fpu/s_cexp.c @@ -0,0 +1,137 @@ +/* Complex exponential function. m68k fpu version + Copyright (C) 1997, 1999 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 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, see + <http://www.gnu.org/licenses/>. */ + +#include <float.h> +#include <complex.h> +#include <math.h> +#include "mathimpl.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)) + +__complex__ float_type +s(__cexp) (__complex__ float_type x) +{ + __complex__ float_type retval; + unsigned long ix_cond; + + ix_cond = __m81_test (__imag__ x); + + if ((ix_cond & (__M81_COND_NAN|__M81_COND_INF)) == 0) + { + /* Imaginary part is finite. */ + unsigned long rx_cond = __m81_test (__real__ x); + + if ((rx_cond & (__M81_COND_NAN|__M81_COND_INF)) == 0) + { + const int t = (int) ((LDBL_MAX_EXP - 1) * M_LN2l); + long double sin_ix, cos_ix, exp_val; + + __m81_u (__sincosl) (__imag__ x, &sin_ix, &cos_ix); + + if (__real__ x > t) + { + long double exp_t = __m81_u(__ieee754_expl) (t); + __real__ x -= t; + sin_ix *= exp_t; + cos_ix *= exp_t; + if (__real__ x > t) + { + __real__ x -= t; + sin_ix *= exp_t; + cos_ix *= exp_t; + } + } + + exp_val = __m81_u(__ieee754_expl) (__real__ x); + __real__ retval = exp_val * cos_ix; + if (ix_cond & __M81_COND_ZERO) + __imag__ retval = __imag__ x; + else + __imag__ retval = exp_val * sin_ix; + } + else + { + /* Compute the sign of the result. */ + long double remainder, pi_2; + int quadrant; + + if ((rx_cond & (__M81_COND_NAN|__M81_COND_NEG)) == __M81_COND_NEG) + __real__ retval = __imag__ retval = 0.0; + else + __real__ retval = __imag__ retval = __real__ x; + __asm ("fmovecr %#0,%0\n\tfscale%.w %#-1,%0" : "=f" (pi_2)); + __asm ("fmod%.x %2,%0\n\tfmove%.l %/fpsr,%1" + : "=f" (remainder), "=dm" (quadrant) + : "f" (pi_2), "0" (__imag__ x)); + quadrant = (quadrant >> 16) & 0x83; + if (quadrant & 0x80) + quadrant ^= 0x83; + switch (quadrant) + { + default: + break; + case 1: + __real__ retval = -__real__ retval; + break; + case 2: + __real__ retval = -__real__ retval; + case 3: + __imag__ retval = -__imag__ retval; + break; + } + if (ix_cond & __M81_COND_ZERO && (rx_cond & __M81_COND_NAN) == 0) + __imag__ retval = __imag__ x; + } + } + else + { + unsigned long rx_cond = __m81_test (__real__ x); + + if (rx_cond & __M81_COND_INF) + { + /* Real part is infinite. */ + if (rx_cond & __M81_COND_NEG) + { + __real__ retval = __imag__ retval = 0.0; + if (ix_cond & __M81_COND_NEG) + __imag__ retval = -__imag__ retval; + } + else + { + __real__ retval = __real__ x; + __imag__ retval = __imag__ x - __imag__ x; + } + } + else + __real__ retval = __imag__ retval = __imag__ x - __imag__ x; + } + + return retval; +} +#define weak_aliasx(a,b) weak_alias(a,b) +weak_aliasx (s(__cexp), s(cexp)) diff --git a/ports/sysdeps/m68k/m680x0/fpu/s_cexpf.c b/ports/sysdeps/m68k/m680x0/fpu/s_cexpf.c new file mode 100644 index 0000000000..177a360f9b --- /dev/null +++ b/ports/sysdeps/m68k/m680x0/fpu/s_cexpf.c @@ -0,0 +1,3 @@ +#define SUFF f +#define float_type float +#include <s_cexp.c> diff --git a/ports/sysdeps/m68k/m680x0/fpu/s_cexpl.c b/ports/sysdeps/m68k/m680x0/fpu/s_cexpl.c new file mode 100644 index 0000000000..bbda4ba990 --- /dev/null +++ b/ports/sysdeps/m68k/m680x0/fpu/s_cexpl.c @@ -0,0 +1,3 @@ +#define SUFF l +#define float_type long double +#include <s_cexp.c> diff --git a/ports/sysdeps/m68k/m680x0/fpu/s_cos.c b/ports/sysdeps/m68k/m680x0/fpu/s_cos.c new file mode 100644 index 0000000000..2f1adf77f5 --- /dev/null +++ b/ports/sysdeps/m68k/m680x0/fpu/s_cos.c @@ -0,0 +1,2 @@ +#define FUNC cos +#include <s_sin.c> diff --git a/ports/sysdeps/m68k/m680x0/fpu/s_cosf.c b/ports/sysdeps/m68k/m680x0/fpu/s_cosf.c new file mode 100644 index 0000000000..b6d6accb4a --- /dev/null +++ b/ports/sysdeps/m68k/m680x0/fpu/s_cosf.c @@ -0,0 +1,2 @@ +#define FUNC cosf +#include <s_sinf.c> diff --git a/ports/sysdeps/m68k/m680x0/fpu/s_cosl.c b/ports/sysdeps/m68k/m680x0/fpu/s_cosl.c new file mode 100644 index 0000000000..eb61521fdd --- /dev/null +++ b/ports/sysdeps/m68k/m680x0/fpu/s_cosl.c @@ -0,0 +1,2 @@ +#define FUNC cosl +#include <s_sinl.c> diff --git a/ports/sysdeps/m68k/m680x0/fpu/s_csin.c b/ports/sysdeps/m68k/m680x0/fpu/s_csin.c new file mode 100644 index 0000000000..dc468d40e0 --- /dev/null +++ b/ports/sysdeps/m68k/m680x0/fpu/s_csin.c @@ -0,0 +1,68 @@ +/* Complex sine function. m68k fpu version + Copyright (C) 1997, 1999 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 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, see + <http://www.gnu.org/licenses/>. */ + +#include <complex.h> +#include <math.h> +#include "mathimpl.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)) + +__complex__ float_type +s(__csin) (__complex__ float_type x) +{ + __complex__ float_type retval; + unsigned long rx_cond = __m81_test (__real__ x); + + if ((rx_cond & (__M81_COND_INF|__M81_COND_NAN)) == 0) + { + /* Real part is finite. */ + float_type sin_rx, cos_rx; + + __asm ("fsincos%.x %2,%1:%0" : "=f" (sin_rx), "=f" (cos_rx) + : "f" (__real__ x)); + if (rx_cond & __M81_COND_ZERO) + __real__ retval = __real__ x; + else + __real__ retval = sin_rx * m81(__ieee754_cosh) (__imag__ x); + __imag__ retval = cos_rx * m81(__ieee754_sinh) (__imag__ x); + } + else + { + unsigned long ix_cond = __m81_test (__imag__ x); + + __real__ retval = __real__ x - __real__ x; + if (ix_cond & (__M81_COND_ZERO|__M81_COND_INF|__M81_COND_NAN)) + __imag__ retval = __imag__ x; + else + __imag__ retval = __real__ retval; + } + + return retval; +} +#define weak_aliasx(a,b) weak_alias(a,b) +weak_aliasx (s(__csin), s(csin)) diff --git a/ports/sysdeps/m68k/m680x0/fpu/s_csinf.c b/ports/sysdeps/m68k/m680x0/fpu/s_csinf.c new file mode 100644 index 0000000000..b760e192c3 --- /dev/null +++ b/ports/sysdeps/m68k/m680x0/fpu/s_csinf.c @@ -0,0 +1,3 @@ +#define SUFF f +#define float_type float +#include <s_csin.c> diff --git a/ports/sysdeps/m68k/m680x0/fpu/s_csinh.c b/ports/sysdeps/m68k/m680x0/fpu/s_csinh.c new file mode 100644 index 0000000000..29156586e6 --- /dev/null +++ b/ports/sysdeps/m68k/m680x0/fpu/s_csinh.c @@ -0,0 +1,70 @@ +/* Complex sine hyperbole function. m68k fpu version + Copyright (C) 1997, 1999 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 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, see + <http://www.gnu.org/licenses/>. */ + +#include <complex.h> +#include <math.h> +#include "mathimpl.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)) + +__complex__ float_type +s(__csinh) (__complex__ float_type x) +{ + __complex__ float_type retval; + unsigned long ix_cond; + + ix_cond = __m81_test (__imag__ x); + + if ((ix_cond & (__M81_COND_INF|__M81_COND_NAN)) == 0) + { + /* Imaginary part is finite. */ + float_type sin_ix, cos_ix; + + __asm ("fsincos%.x %2,%1:%0" : "=f" (sin_ix), "=f" (cos_ix) + : "f" (__imag__ x)); + __real__ retval = cos_ix * m81(__ieee754_sinh) (__real__ x); + if (ix_cond & __M81_COND_ZERO) + __imag__ retval = __imag__ x; + else + __imag__ retval = sin_ix * m81(__ieee754_cosh) (__real__ x); + } + else + { + unsigned long rx_cond = __m81_test (__real__ x); + + __imag__ retval = __imag__ x - __imag__ x; + if (rx_cond & (__M81_COND_ZERO|__M81_COND_INF|__M81_COND_NAN)) + __real__ retval = __real__ x; + else + __real__ retval = __imag__ retval; + } + + return retval; +} +#define weak_aliasx(a,b) weak_alias(a,b) +weak_aliasx (s(__csinh), s(csinh)) diff --git a/ports/sysdeps/m68k/m680x0/fpu/s_csinhf.c b/ports/sysdeps/m68k/m680x0/fpu/s_csinhf.c new file mode 100644 index 0000000000..2f7a43e6a8 --- /dev/null +++ b/ports/sysdeps/m68k/m680x0/fpu/s_csinhf.c @@ -0,0 +1,3 @@ +#define SUFF f +#define float_type float +#include <s_csinh.c> diff --git a/ports/sysdeps/m68k/m680x0/fpu/s_csinhl.c b/ports/sysdeps/m68k/m680x0/fpu/s_csinhl.c new file mode 100644 index 0000000000..026a20e7be --- /dev/null +++ b/ports/sysdeps/m68k/m680x0/fpu/s_csinhl.c @@ -0,0 +1,3 @@ +#define SUFF l +#define float_type long double +#include <s_csinh.c> diff --git a/ports/sysdeps/m68k/m680x0/fpu/s_csinl.c b/ports/sysdeps/m68k/m680x0/fpu/s_csinl.c new file mode 100644 index 0000000000..ea2dad0556 --- /dev/null +++ b/ports/sysdeps/m68k/m680x0/fpu/s_csinl.c @@ -0,0 +1,3 @@ +#define SUFF l +#define float_type long double +#include <s_csin.c> diff --git a/ports/sysdeps/m68k/m680x0/fpu/s_expm1.c b/ports/sysdeps/m68k/m680x0/fpu/s_expm1.c new file mode 100644 index 0000000000..6dac1cc1a7 --- /dev/null +++ b/ports/sysdeps/m68k/m680x0/fpu/s_expm1.c @@ -0,0 +1,43 @@ +/* Copyright (C) 2012 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, see + <http://www.gnu.org/licenses/>. */ + +#include <math.h> +#include <errno.h> +#include "mathimpl.h" + +#ifndef FUNC +# define FUNC expm1 +#endif +#ifndef float_type +# define float_type double +#endif +#ifndef o_threshold +# define o_threshold 7.09782712893383973096e+02 +#endif + +#define CONCATX(a,b) __CONCAT(a,b) + +float_type +CONCATX(__,FUNC) (float_type x) +{ + if ((__m81_test (x) & __M81_COND_INF) == 0 && isgreater (x, o_threshold)) + __set_errno (ERANGE); + return __m81_u(CONCATX(__, FUNC)) (x); +} + +#define weak_aliasx(a, b) weak_alias(a, b) +weak_aliasx (CONCATX(__, FUNC), FUNC) diff --git a/ports/sysdeps/m68k/m680x0/fpu/s_expm1f.c b/ports/sysdeps/m68k/m680x0/fpu/s_expm1f.c new file mode 100644 index 0000000000..2cd8ffcfeb --- /dev/null +++ b/ports/sysdeps/m68k/m680x0/fpu/s_expm1f.c @@ -0,0 +1,4 @@ +#define FUNC expm1f +#define float_type float +#define o_threshold 8.8722831726e+01F +#include <s_expm1.c> diff --git a/ports/sysdeps/m68k/m680x0/fpu/s_expm1l.c b/ports/sysdeps/m68k/m680x0/fpu/s_expm1l.c new file mode 100644 index 0000000000..a2c80860ba --- /dev/null +++ b/ports/sysdeps/m68k/m680x0/fpu/s_expm1l.c @@ -0,0 +1,6 @@ +#define FUNC expm1l +#define float_type long double +/* 400c0000b17217f7d1cf79ab */ +#define o_threshold 1.13565234062941439487914863093465101e+04L +#include <s_expm1.c> +libm_hidden_def (__expm1l) diff --git a/ports/sysdeps/m68k/m680x0/fpu/s_fabs.c b/ports/sysdeps/m68k/m680x0/fpu/s_fabs.c new file mode 100644 index 0000000000..1f0631e2ff --- /dev/null +++ b/ports/sysdeps/m68k/m680x0/fpu/s_fabs.c @@ -0,0 +1,2 @@ +#define FUNC fabs +#include <s_atan.c> diff --git a/ports/sysdeps/m68k/m680x0/fpu/s_fabsf.c b/ports/sysdeps/m68k/m680x0/fpu/s_fabsf.c new file mode 100644 index 0000000000..8f9421998a --- /dev/null +++ b/ports/sysdeps/m68k/m680x0/fpu/s_fabsf.c @@ -0,0 +1,2 @@ +#define FUNC fabsf +#include <s_atanf.c> diff --git a/ports/sysdeps/m68k/m680x0/fpu/s_fabsl.c b/ports/sysdeps/m68k/m680x0/fpu/s_fabsl.c new file mode 100644 index 0000000000..8ac14d5b8c --- /dev/null +++ b/ports/sysdeps/m68k/m680x0/fpu/s_fabsl.c @@ -0,0 +1,2 @@ +#define FUNC fabsl +#include <s_atanl.c> diff --git a/ports/sysdeps/m68k/m680x0/fpu/s_finite.c b/ports/sysdeps/m68k/m680x0/fpu/s_finite.c new file mode 100644 index 0000000000..dafbd5901d --- /dev/null +++ b/ports/sysdeps/m68k/m680x0/fpu/s_finite.c @@ -0,0 +1,2 @@ +#define FUNC finite +#include <s_isinf.c> diff --git a/ports/sysdeps/m68k/m680x0/fpu/s_finitef.c b/ports/sysdeps/m68k/m680x0/fpu/s_finitef.c new file mode 100644 index 0000000000..b81342e5c6 --- /dev/null +++ b/ports/sysdeps/m68k/m680x0/fpu/s_finitef.c @@ -0,0 +1,2 @@ +#define FUNC finitef +#include <s_isinff.c> diff --git a/ports/sysdeps/m68k/m680x0/fpu/s_finitel.c b/ports/sysdeps/m68k/m680x0/fpu/s_finitel.c new file mode 100644 index 0000000000..bd346a220c --- /dev/null +++ b/ports/sysdeps/m68k/m680x0/fpu/s_finitel.c @@ -0,0 +1,2 @@ +#define FUNC finitel +#include <s_isinfl.c> diff --git a/ports/sysdeps/m68k/m680x0/fpu/s_floor.c b/ports/sysdeps/m68k/m680x0/fpu/s_floor.c new file mode 100644 index 0000000000..e1219c602a --- /dev/null +++ b/ports/sysdeps/m68k/m680x0/fpu/s_floor.c @@ -0,0 +1,2 @@ +#define FUNC floor +#include <s_atan.c> diff --git a/ports/sysdeps/m68k/m680x0/fpu/s_floorf.c b/ports/sysdeps/m68k/m680x0/fpu/s_floorf.c new file mode 100644 index 0000000000..f4f9b9a1d8 --- /dev/null +++ b/ports/sysdeps/m68k/m680x0/fpu/s_floorf.c @@ -0,0 +1,2 @@ +#define FUNC floorf +#include <s_atanf.c> diff --git a/ports/sysdeps/m68k/m680x0/fpu/s_floorl.c b/ports/sysdeps/m68k/m680x0/fpu/s_floorl.c new file mode 100644 index 0000000000..2c1ffd7d2c --- /dev/null +++ b/ports/sysdeps/m68k/m680x0/fpu/s_floorl.c @@ -0,0 +1,2 @@ +#define FUNC floorl +#include <s_atanl.c> diff --git a/ports/sysdeps/m68k/m680x0/fpu/s_fpclassifyl.c b/ports/sysdeps/m68k/m680x0/fpu/s_fpclassifyl.c new file mode 100644 index 0000000000..ace6436601 --- /dev/null +++ b/ports/sysdeps/m68k/m680x0/fpu/s_fpclassifyl.c @@ -0,0 +1,43 @@ +/* Return classification value corresponding to argument. m68k version. + Copyright (C) 1997, 2001, 2002 Free Software Foundation, Inc. + This file is part of the GNU C Library. + Contributed by Ulrich Drepper <drepper@cygnus.com>, 1997. + Fixed for m68k by Andreas Schwab <schwab@suse.de>. + + 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, see + <http://www.gnu.org/licenses/>. */ + +#include <math.h> + +#include <math_private.h> + + +int +__fpclassifyl (long double x) +{ + u_int32_t ex, hx, lx; + int retval = FP_NORMAL; + + GET_LDOUBLE_WORDS (ex, hx, lx, x); + ex &= 0x7fff; + if ((ex | hx | lx) == 0) + retval = FP_ZERO; + else if (ex == 0 && (hx & 0x80000000) == 0) + retval = FP_SUBNORMAL; + else if (ex == 0x7fff) + retval = ((hx & 0x7fffffff) | lx) != 0 ? FP_NAN : FP_INFINITE; + + return retval; +} +libm_hidden_def (__fpclassifyl) diff --git a/ports/sysdeps/m68k/m680x0/fpu/s_frexp.c b/ports/sysdeps/m68k/m680x0/fpu/s_frexp.c new file mode 100644 index 0000000000..b4493190fc --- /dev/null +++ b/ports/sysdeps/m68k/m680x0/fpu/s_frexp.c @@ -0,0 +1,55 @@ +/* Copyright (C) 1996, 1997, 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, see + <http://www.gnu.org/licenses/>. */ + +#include <math.h> + +#ifndef FUNC +#define FUNC frexp +#endif +#ifndef float_type +#define float_type double +#endif + +#define __CONCATX(a,b) __CONCAT(a,b) + +float_type +__CONCATX(__,FUNC) (float_type value, int *expptr) +{ + float_type mantissa, exponent; + int iexponent; + unsigned long fpsr; + + __asm ("ftst%.x %1\n" + "fmove%.l %/fpsr, %0" + : "=dm" (fpsr) : "f" (value)); + if (fpsr & (7 << 24)) + { + /* Not finite or zero. */ + *expptr = 0; + return value; + } + __asm ("fgetexp%.x %1, %0" : "=f" (exponent) : "f" (value)); + iexponent = (int) exponent + 1; + *expptr = iexponent; + __asm ("fscale%.l %2, %0" + : "=f" (mantissa) + : "0" (value), "dmi" (-iexponent)); + return mantissa; +} + +#define weak_aliasx(a,b) weak_alias(a,b) +weak_aliasx (__CONCATX(__,FUNC), FUNC) diff --git a/ports/sysdeps/m68k/m680x0/fpu/s_frexpf.c b/ports/sysdeps/m68k/m680x0/fpu/s_frexpf.c new file mode 100644 index 0000000000..893b6ad3cf --- /dev/null +++ b/ports/sysdeps/m68k/m680x0/fpu/s_frexpf.c @@ -0,0 +1,3 @@ +#define FUNC frexpf +#define float_type float +#include <s_frexp.c> diff --git a/ports/sysdeps/m68k/m680x0/fpu/s_frexpl.c b/ports/sysdeps/m68k/m680x0/fpu/s_frexpl.c new file mode 100644 index 0000000000..48e7d287bc --- /dev/null +++ b/ports/sysdeps/m68k/m680x0/fpu/s_frexpl.c @@ -0,0 +1,58 @@ +/* Copyright (C) 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, see + <http://www.gnu.org/licenses/>. */ + +#include <math.h> + +long double +__frexpl (long double value, int *expptr) +{ + long double mantissa, exponent; + int iexponent; + unsigned long fpsr; + + __asm ("ftst%.x %1\n" + "fmove%.l %/fpsr, %0" + : "=dm" (fpsr) : "f" (value)); + if (fpsr & (7 << 24)) + { + /* Not finite or zero. */ + *expptr = 0; + return value; + } + __asm ("fgetexp%.x %1, %0" : "=f" (exponent) : "f" (value)); + iexponent = (int) exponent + 1; + *expptr = iexponent; + /* Unnormalized numbers must be handled specially, otherwise fscale + results in overflow. */ + if (iexponent <= -16384) + { + value *= 0x1p16383L; + iexponent += 16383; + } + else if (iexponent >= 16384) + { + value *= 0x1p-16383L; + iexponent -= 16383; + } + + __asm ("fscale%.l %2, %0" + : "=f" (mantissa) + : "0" (value), "dmi" (-iexponent)); + return mantissa; +} + +weak_alias (__frexpl, frexpl) diff --git a/ports/sysdeps/m68k/m680x0/fpu/s_isinf.c b/ports/sysdeps/m68k/m680x0/fpu/s_isinf.c new file mode 100644 index 0000000000..ff4d3b2b16 --- /dev/null +++ b/ports/sysdeps/m68k/m680x0/fpu/s_isinf.c @@ -0,0 +1,39 @@ +/* Copyright (C) 1996, 1997, 2002 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, see + <http://www.gnu.org/licenses/>. */ + +#include <math.h> + +#ifndef FUNC +#define FUNC isinf +#endif +#ifndef float_type +#define float_type double +#endif + +#define __CONCATX(a,b) __CONCAT(a,b) + +int +__CONCATX(__,FUNC) (x) + float_type x; +{ + return __m81_u(__CONCATX(__,FUNC))(x); +} + +#define hidden_defx(a) hidden_def(a) +hidden_defx(__CONCATX(__,FUNC)) +#define weak_aliasx(a,b) weak_alias(a,b) +weak_aliasx (__CONCATX(__,FUNC), FUNC) diff --git a/ports/sysdeps/m68k/m680x0/fpu/s_isinff.c b/ports/sysdeps/m68k/m680x0/fpu/s_isinff.c new file mode 100644 index 0000000000..ebf4f2ae96 --- /dev/null +++ b/ports/sysdeps/m68k/m680x0/fpu/s_isinff.c @@ -0,0 +1,5 @@ +#ifndef FUNC +#define FUNC isinff +#endif +#define float_type float +#include <s_isinf.c> diff --git a/ports/sysdeps/m68k/m680x0/fpu/s_isinfl.c b/ports/sysdeps/m68k/m680x0/fpu/s_isinfl.c new file mode 100644 index 0000000000..963725ad77 --- /dev/null +++ b/ports/sysdeps/m68k/m680x0/fpu/s_isinfl.c @@ -0,0 +1,5 @@ +#ifndef FUNC +#define FUNC isinfl +#endif +#define float_type long double +#include <s_isinf.c> diff --git a/ports/sysdeps/m68k/m680x0/fpu/s_isnan.c b/ports/sysdeps/m68k/m680x0/fpu/s_isnan.c new file mode 100644 index 0000000000..151d6dc6b4 --- /dev/null +++ b/ports/sysdeps/m68k/m680x0/fpu/s_isnan.c @@ -0,0 +1,2 @@ +#define FUNC isnan +#include <s_isinf.c> diff --git a/ports/sysdeps/m68k/m680x0/fpu/s_isnanf.c b/ports/sysdeps/m68k/m680x0/fpu/s_isnanf.c new file mode 100644 index 0000000000..667bca7235 --- /dev/null +++ b/ports/sysdeps/m68k/m680x0/fpu/s_isnanf.c @@ -0,0 +1,2 @@ +#define FUNC isnanf +#include <s_isinff.c> diff --git a/ports/sysdeps/m68k/m680x0/fpu/s_isnanl.c b/ports/sysdeps/m68k/m680x0/fpu/s_isnanl.c new file mode 100644 index 0000000000..bbacb64f11 --- /dev/null +++ b/ports/sysdeps/m68k/m680x0/fpu/s_isnanl.c @@ -0,0 +1,2 @@ +#define FUNC isnanl +#include <s_isinfl.c> diff --git a/ports/sysdeps/m68k/m680x0/fpu/s_llrint.c b/ports/sysdeps/m68k/m680x0/fpu/s_llrint.c new file mode 100644 index 0000000000..0952ccd1da --- /dev/null +++ b/ports/sysdeps/m68k/m680x0/fpu/s_llrint.c @@ -0,0 +1,75 @@ +/* Round argument to nearest integral value according to current rounding + direction. + Copyright (C) 1997, 1999 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 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, see + <http://www.gnu.org/licenses/>. */ + +#include <math.h> +#include <math_private.h> +#include "mathimpl.h" + +long long int +__llrint (double x) +{ + int32_t e; + u_int32_t h, l, s; + long long int result; + + x = __m81_u(__rint) (x); + + /* We could use __fixxfdi from libgcc, but here we can take advantage of + the known floating point format. */ + EXTRACT_WORDS (h, l, x); + + e = ((h >> 20) & 0x7ff) - 0x3ff; + if (e < 0) + return 0; + s = h; + h &= 0xfffff; + h |= 0x100000; + + if (e < 63) + { + if (e > 52) + { + h <<= e - 52; + h |= l >> (84 - e); + l <<= e - 52; + result = ((long long int) h << 32) | l; + } + else if (e > 20) + { + l >>= 52 - e; + l |= h << (e - 20); + h >>= 52 - e; + result = ((long long int) h << 32) | l; + } + else + result = h >> (20 - e); + if (s & 0x80000000) + result = -result; + } + else + /* The number is too large or not finite. The standard leaves it + undefined what to return when the number is too large to fit in a + `long long int'. */ + result = -1LL; + + return result; +} + +weak_alias (__llrint, llrint) diff --git a/ports/sysdeps/m68k/m680x0/fpu/s_llrintf.c b/ports/sysdeps/m68k/m680x0/fpu/s_llrintf.c new file mode 100644 index 0000000000..dd5b95c730 --- /dev/null +++ b/ports/sysdeps/m68k/m680x0/fpu/s_llrintf.c @@ -0,0 +1,65 @@ +/* Round argument to nearest integral value according to current rounding + direction. + Copyright (C) 1997, 1999 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 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, see + <http://www.gnu.org/licenses/>. */ + +#include <math.h> +#include <math_private.h> +#include "mathimpl.h" + +long long int +__llrintf (float x) +{ + int32_t e; + u_int32_t i, s; + long long int result; + + x = __m81_u(__rintf) (x); + + GET_FLOAT_WORD (i, x); + + e = ((i >> 23) & 0xff) - 0x7f; + if (e < 0) + return 0; + s = i; + i &= 0x7fffff; + i |= 0x800000; + + if (e < 63) + { + if (e > 55) + result = (long long int) (i << (e - 55)) << 32; + else if (e > 31) + result = (((long long int) (i >> (55 - e)) << 32) | (i << (e - 23))); + else if (e > 23) + result = i << (e - 23); + else + result = i >> (23 - e); + if (s & 0x80000000) + result = -result; + } + else + /* The number is too large or not finite. The standard leaves it + undefined what to return when the number is too large to fit in a + `long long int'. */ + result = -1LL; + + return result; +} + +weak_alias (__llrintf, llrintf) diff --git a/ports/sysdeps/m68k/m680x0/fpu/s_llrintl.c b/ports/sysdeps/m68k/m680x0/fpu/s_llrintl.c new file mode 100644 index 0000000000..fbe66ee3dc --- /dev/null +++ b/ports/sysdeps/m68k/m680x0/fpu/s_llrintl.c @@ -0,0 +1,64 @@ +/* Round argument to nearest integral value according to current rounding + direction. + Copyright (C) 1997, 1999 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 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, see + <http://www.gnu.org/licenses/>. */ + +#include <math.h> +#include <math_private.h> +#include "mathimpl.h" + +long long int +__llrintl (long double x) +{ + int32_t e, s; + u_int32_t h, l; + long long int result; + + x = __m81_u(__rintl) (x); + + GET_LDOUBLE_WORDS (e, h, l, x); + + s = e; + e = (e & 0x7fff) - 0x3fff; + if (e < 0) + return 0; + + if (e < 63) + { + if (e > 31) + { + l >>= 63 - e; + l |= h << (e - 31); + h >>= 63 - e; + result = ((long long int) h << 32) | l; + } + else + result = h >> (31 - e); + if (s & 0x8000) + result = -result; + } + else + /* The number is too large or not finite. The standard leaves it + undefined what to return when the number is too large to fit in a + `long long int'. */ + result = -1LL; + + return result; +} + +weak_alias (__llrintl, llrintl) diff --git a/ports/sysdeps/m68k/m680x0/fpu/s_log1p.c b/ports/sysdeps/m68k/m680x0/fpu/s_log1p.c new file mode 100644 index 0000000000..1840ced137 --- /dev/null +++ b/ports/sysdeps/m68k/m680x0/fpu/s_log1p.c @@ -0,0 +1,2 @@ +#define FUNC log1p +#include <s_atan.c> diff --git a/ports/sysdeps/m68k/m680x0/fpu/s_log1pf.c b/ports/sysdeps/m68k/m680x0/fpu/s_log1pf.c new file mode 100644 index 0000000000..cb7235a071 --- /dev/null +++ b/ports/sysdeps/m68k/m680x0/fpu/s_log1pf.c @@ -0,0 +1,2 @@ +#define FUNC log1pf +#include <s_atanf.c> diff --git a/ports/sysdeps/m68k/m680x0/fpu/s_log1pl.c b/ports/sysdeps/m68k/m680x0/fpu/s_log1pl.c new file mode 100644 index 0000000000..8dbef89095 --- /dev/null +++ b/ports/sysdeps/m68k/m680x0/fpu/s_log1pl.c @@ -0,0 +1,2 @@ +#define FUNC log1pl +#include <s_atanl.c> diff --git a/ports/sysdeps/m68k/m680x0/fpu/s_logbl.c b/ports/sysdeps/m68k/m680x0/fpu/s_logbl.c new file mode 100644 index 0000000000..2586622bf7 --- /dev/null +++ b/ports/sysdeps/m68k/m680x0/fpu/s_logbl.c @@ -0,0 +1,49 @@ +/* s_logbl.c -- long double version of s_logb.c. + * Conversion to long double by Ulrich Drepper, + * Cygnus Support, drepper@cygnus.com. + */ + +/* + * ==================================================== + * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. + * + * Developed at SunPro, a Sun Microsystems, Inc. business. + * Permission to use, copy, modify, and distribute this + * software is freely granted, provided that this notice + * is preserved. + * ==================================================== + */ + +/* + * long double logbl(x) + * IEEE 754 logb. Included to pass IEEE test suite. Not recommend. + * Use ilogb instead. + */ + +#include <math.h> +#include <math_private.h> + +long double +__logbl (long double x) +{ + int32_t es, lx, ix; + + GET_LDOUBLE_WORDS (es, ix, lx, x); + es &= 0x7fff; /* exponent */ + if ((es | ix | lx) == 0) + return -1.0 / fabsl (x); + if (es == 0x7fff) + return x * x; + if (es == 0) /* IEEE 754 logb */ + { + /* POSIX specifies that denormal number is treated as + though it were normalized. */ + if (ix == 0) + es = -(__builtin_clz (lx) + 32); + else + es = -__builtin_clz (ix); + } + return (long double) (es - 16383); +} + +weak_alias (__logbl, logbl) diff --git a/ports/sysdeps/m68k/m680x0/fpu/s_lrint.c b/ports/sysdeps/m68k/m680x0/fpu/s_lrint.c new file mode 100644 index 0000000000..da2ea53bba --- /dev/null +++ b/ports/sysdeps/m68k/m680x0/fpu/s_lrint.c @@ -0,0 +1,39 @@ +/* Round argument to nearest integral value according to current rounding + direction. + 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 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, see + <http://www.gnu.org/licenses/>. */ + +#include <math.h> + +#ifndef suffix +#define suffix /*empty*/ +#endif +#ifndef float_type +#define float_type double +#endif + +#define CONCATX(a,b) __CONCAT(a,b) + +long int +CONCATX(__lrint,suffix) (float_type x) +{ + return __m81_u(CONCATX(__lrint,suffix)) (x); +} + +#define weak_aliasx(a,b) weak_alias(a,b) +weak_aliasx (CONCATX(__lrint,suffix), CONCATX(lrint,suffix)) diff --git a/ports/sysdeps/m68k/m680x0/fpu/s_lrintf.c b/ports/sysdeps/m68k/m680x0/fpu/s_lrintf.c new file mode 100644 index 0000000000..44924cb82f --- /dev/null +++ b/ports/sysdeps/m68k/m680x0/fpu/s_lrintf.c @@ -0,0 +1,3 @@ +#define suffix f +#define float_type float +#include <s_lrint.c> diff --git a/ports/sysdeps/m68k/m680x0/fpu/s_lrintl.c b/ports/sysdeps/m68k/m680x0/fpu/s_lrintl.c new file mode 100644 index 0000000000..cd0bd23b8a --- /dev/null +++ b/ports/sysdeps/m68k/m680x0/fpu/s_lrintl.c @@ -0,0 +1,3 @@ +#define suffix l +#define float_type long double +#include <s_lrint.c> diff --git a/ports/sysdeps/m68k/m680x0/fpu/s_modf.c b/ports/sysdeps/m68k/m680x0/fpu/s_modf.c new file mode 100644 index 0000000000..95bc0ef212 --- /dev/null +++ b/ports/sysdeps/m68k/m680x0/fpu/s_modf.c @@ -0,0 +1,55 @@ +/* Copyright (C) 1996, 1997, 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, see + <http://www.gnu.org/licenses/>. */ + +#include <math.h> +#include "mathimpl.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(__modf) (float_type x, float_type *iptr) +{ + float_type x_int, result; + unsigned long x_cond; + + __asm ("fintrz%.x %1, %0" : "=f" (x_int) : "f" (x)); + *iptr = x_int; + x_cond = __m81_test (x); + if (x_cond & __M81_COND_INF) + { + result = 0; + if (x_cond & __M81_COND_NEG) + result = -result; + } + else if (x_cond & __M81_COND_ZERO) + result = x; + else + result = x - x_int; + return result; +} + +#define weak_aliasx(a,b) weak_alias(a,b) +weak_aliasx(s(__modf), s(modf)) diff --git a/ports/sysdeps/m68k/m680x0/fpu/s_modff.c b/ports/sysdeps/m68k/m680x0/fpu/s_modff.c new file mode 100644 index 0000000000..0c44d7c0ab --- /dev/null +++ b/ports/sysdeps/m68k/m680x0/fpu/s_modff.c @@ -0,0 +1,3 @@ +#define SUFF f +#define float_type float +#include <s_modf.c> diff --git a/ports/sysdeps/m68k/m680x0/fpu/s_modfl.c b/ports/sysdeps/m68k/m680x0/fpu/s_modfl.c new file mode 100644 index 0000000000..c7075b3ba9 --- /dev/null +++ b/ports/sysdeps/m68k/m680x0/fpu/s_modfl.c @@ -0,0 +1,3 @@ +#define SUFF l +#define float_type long double +#include <s_modf.c> diff --git a/ports/sysdeps/m68k/m680x0/fpu/s_nearbyint.c b/ports/sysdeps/m68k/m680x0/fpu/s_nearbyint.c new file mode 100644 index 0000000000..b87f5e2160 --- /dev/null +++ b/ports/sysdeps/m68k/m680x0/fpu/s_nearbyint.c @@ -0,0 +1,2 @@ +#define FUNC nearbyint +#include <s_atan.c> diff --git a/ports/sysdeps/m68k/m680x0/fpu/s_nearbyintf.c b/ports/sysdeps/m68k/m680x0/fpu/s_nearbyintf.c new file mode 100644 index 0000000000..70d08ab44c --- /dev/null +++ b/ports/sysdeps/m68k/m680x0/fpu/s_nearbyintf.c @@ -0,0 +1,2 @@ +#define FUNC nearbyintf +#include <s_atanf.c> diff --git a/ports/sysdeps/m68k/m680x0/fpu/s_nearbyintl.c b/ports/sysdeps/m68k/m680x0/fpu/s_nearbyintl.c new file mode 100644 index 0000000000..230cd7784c --- /dev/null +++ b/ports/sysdeps/m68k/m680x0/fpu/s_nearbyintl.c @@ -0,0 +1,2 @@ +#define FUNC nearbyintl +#include <s_atanl.c> diff --git a/ports/sysdeps/m68k/m680x0/fpu/s_nextafterl.c b/ports/sysdeps/m68k/m680x0/fpu/s_nextafterl.c new file mode 100644 index 0000000000..9a03b78631 --- /dev/null +++ b/ports/sysdeps/m68k/m680x0/fpu/s_nextafterl.c @@ -0,0 +1,104 @@ +/* s_nextafterl.c -- long double version of s_nextafter.c. + * Conversion to long double by Ulrich Drepper, + * Cygnus Support, drepper@cygnus.com. + * Fixed for m68k by Andreas Schwab <schwab@suse.de>. + */ + +/* + * ==================================================== + * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. + * + * Developed at SunPro, a Sun Microsystems, Inc. business. + * Permission to use, copy, modify, and distribute this + * software is freely granted, provided that this notice + * is preserved. + * ==================================================== + */ + +#if defined(LIBM_SCCS) && !defined(lint) +static char rcsid[] = "$NetBSD: $"; +#endif + +/* IEEE functions + * nextafterl(x,y) + * return the next machine floating-point number of x in the + * direction toward y. + * Special cases: + */ + +#include <math.h> +#include <math_private.h> + +long double __nextafterl(long double x, long double y) +{ + int32_t ix,iy,esx,esy; + u_int32_t hx,hy,lx,ly; + + GET_LDOUBLE_WORDS(esx,hx,lx,x); + GET_LDOUBLE_WORDS(esy,hy,ly,y); + ix = esx&0x7fff; /* |x| */ + iy = esy&0x7fff; /* |y| */ + + if(((ix==0x7fff)&&((hx&0x7fffffff)|lx)!=0) || /* x is nan */ + ((iy==0x7fff)&&((hy&0x7fffffff)|ly)!=0)) /* y is nan */ + return x+y; + if(x==y) return y; /* x=y, return y */ + if((ix|hx|lx)==0) { /* x == 0 */ + SET_LDOUBLE_WORDS(x,esy&0x8000,0,1);/* return +-minsubnormal */ + y = x*x; + if(y==x) return y; else return x; /* raise underflow flag */ + } + if(esx>=0) { /* x > 0 */ + if(esx>esy||((esx==esy) && (hx>hy||((hx==hy)&&(lx>ly))))) { + /* x > y, x -= ulp */ + if(lx==0) { + if (ix != 0 && hx == 0x80000000) hx = 0; + if (hx==0) esx -= 1; + hx -= 1; + } + lx -= 1; + } else { /* x < y, x += ulp */ + lx += 1; + if(lx==0) { + hx += 1; + if (hx==0) { + hx = 0x80000000; + esx += 1; + } + } + } + } else { /* x < 0 */ + if(esy>=0||esx>esy||((esx==esy) && (hx>hy||((hx==hy)&&(lx>ly))))){ + /* x < y, x -= ulp */ + if(lx==0) { + if (ix != 0 && hx == 0x80000000) hx = 0; + if (hx==0) esx -= 1; + hx -= 1; + } + lx -= 1; + } else { /* x > y, x += ulp */ + lx += 1; + if(lx==0) { + hx += 1; + if (hx==0) { + hx = 0x80000000; + esx += 1; + } + } + } + } + esy = esx&0x7fff; + if(esy==0x7fff) return x+x; /* overflow */ + if(esy==0 && (hx & 0x80000000) == 0) { /* underflow */ + y = x*x; + if(y!=x) { /* raise underflow flag */ + SET_LDOUBLE_WORDS(y,esx,hx,lx); + return y; + } + } + SET_LDOUBLE_WORDS(x,esx,hx,lx); + return x; +} +weak_alias (__nextafterl, nextafterl) +strong_alias (__nextafterl, __nexttowardl) +weak_alias (__nextafterl, nexttowardl) diff --git a/ports/sysdeps/m68k/m680x0/fpu/s_remquo.c b/ports/sysdeps/m68k/m680x0/fpu/s_remquo.c new file mode 100644 index 0000000000..1395f7e013 --- /dev/null +++ b/ports/sysdeps/m68k/m680x0/fpu/s_remquo.c @@ -0,0 +1,47 @@ +/* Compute remainder and a congruent to the quotient. m68k fpu version + 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 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, see + <http://www.gnu.org/licenses/>. */ + +#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) + +float_type +s(__remquo) (float_type x, float_type y, int *quo) +{ + float_type result; + int cquo, fpsr; + + __asm ("frem%.x %2,%0\n\tfmove%.l %/fpsr,%1" + : "=f" (result), "=dm" (fpsr) : "f" (y), "0" (x)); + cquo = (fpsr >> 16) & 0x7f; + if (fpsr & (1 << 23)) + cquo = -cquo; + *quo = cquo; + return result; +} +#define weak_aliasx(a,b) weak_alias(a,b) +weak_aliasx (s(__remquo), s(remquo)) diff --git a/ports/sysdeps/m68k/m680x0/fpu/s_remquof.c b/ports/sysdeps/m68k/m680x0/fpu/s_remquof.c new file mode 100644 index 0000000000..8a292fc26c --- /dev/null +++ b/ports/sysdeps/m68k/m680x0/fpu/s_remquof.c @@ -0,0 +1,3 @@ +#define SUFF f +#define float_type float +#include <s_remquo.c> diff --git a/ports/sysdeps/m68k/m680x0/fpu/s_remquol.c b/ports/sysdeps/m68k/m680x0/fpu/s_remquol.c new file mode 100644 index 0000000000..d236cfd1f9 --- /dev/null +++ b/ports/sysdeps/m68k/m680x0/fpu/s_remquol.c @@ -0,0 +1,3 @@ +#define SUFF l +#define float_type long double +#include <s_remquo.c> diff --git a/ports/sysdeps/m68k/m680x0/fpu/s_rint.c b/ports/sysdeps/m68k/m680x0/fpu/s_rint.c new file mode 100644 index 0000000000..f0f18c7346 --- /dev/null +++ b/ports/sysdeps/m68k/m680x0/fpu/s_rint.c @@ -0,0 +1,2 @@ +#define FUNC rint +#include <s_atan.c> diff --git a/ports/sysdeps/m68k/m680x0/fpu/s_rintf.c b/ports/sysdeps/m68k/m680x0/fpu/s_rintf.c new file mode 100644 index 0000000000..4e00cab0fb --- /dev/null +++ b/ports/sysdeps/m68k/m680x0/fpu/s_rintf.c @@ -0,0 +1,2 @@ +#define FUNC rintf +#include <s_atanf.c> diff --git a/ports/sysdeps/m68k/m680x0/fpu/s_rintl.c b/ports/sysdeps/m68k/m680x0/fpu/s_rintl.c new file mode 100644 index 0000000000..305667b3a1 --- /dev/null +++ b/ports/sysdeps/m68k/m680x0/fpu/s_rintl.c @@ -0,0 +1,2 @@ +#define FUNC rintl +#include <s_atanl.c> diff --git a/ports/sysdeps/m68k/m680x0/fpu/s_scalbln.c b/ports/sysdeps/m68k/m680x0/fpu/s_scalbln.c new file mode 100644 index 0000000000..1009713fbc --- /dev/null +++ b/ports/sysdeps/m68k/m680x0/fpu/s_scalbln.c @@ -0,0 +1,2 @@ +/* Nothing to do. This function is the same as scalbn. So we define an + alias. */ diff --git a/ports/sysdeps/m68k/m680x0/fpu/s_scalblnf.c b/ports/sysdeps/m68k/m680x0/fpu/s_scalblnf.c new file mode 100644 index 0000000000..5e558c3540 --- /dev/null +++ b/ports/sysdeps/m68k/m680x0/fpu/s_scalblnf.c @@ -0,0 +1,2 @@ +/* Nothing to do. This function is the same as scalbnf. So we define an + alias. */ diff --git a/ports/sysdeps/m68k/m680x0/fpu/s_scalblnl.c b/ports/sysdeps/m68k/m680x0/fpu/s_scalblnl.c new file mode 100644 index 0000000000..cda2ec11c8 --- /dev/null +++ b/ports/sysdeps/m68k/m680x0/fpu/s_scalblnl.c @@ -0,0 +1,2 @@ +/* Nothing to do. This function is the same as scalbnl. So we define an + alias. */ diff --git a/ports/sysdeps/m68k/m680x0/fpu/s_scalbn.c b/ports/sysdeps/m68k/m680x0/fpu/s_scalbn.c new file mode 100644 index 0000000000..796aeb2b19 --- /dev/null +++ b/ports/sysdeps/m68k/m680x0/fpu/s_scalbn.c @@ -0,0 +1,53 @@ +/* Copyright (C) 1996, 1997 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, see + <http://www.gnu.org/licenses/>. */ + +#define scalbln __no_scalbln_decl +#define scalblnf __no_scalblnf_decl +#define scalblnl __no_scalblnl_decl +#define __scalbln __no__scalbln_decl +#define __scalblnf __no__scalblnf_decl +#define __scalblnl __no__scalblnl_decl +#include <math.h> +#undef scalbln +#undef scalblnf +#undef scalblnl +#undef __scalbln +#undef __scalblnf +#undef __scalblnl + +#ifndef suffix +#define suffix /*empty*/ +#endif +#ifndef float_type +#define float_type double +#endif + +#define __CONCATX(a,b) __CONCAT(a,b) + +float_type +__CONCATX(__scalbn,suffix) (x, exp) + float_type x; + int exp; +{ + return __m81_u(__CONCATX(__scalbn,suffix))(x, exp); +} + +#define weak_aliasx(a,b) weak_alias(a,b) +#define strong_aliasx(a,b) strong_alias(a,b) +weak_aliasx (__CONCATX(__scalbn,suffix), __CONCATX(scalbn,suffix)) +strong_aliasx (__CONCATX(__scalbn,suffix), __CONCATX(__scalbln,suffix)) +weak_aliasx (__CONCATX(__scalbn,suffix), __CONCATX(scalbln,suffix)) diff --git a/ports/sysdeps/m68k/m680x0/fpu/s_scalbnf.c b/ports/sysdeps/m68k/m680x0/fpu/s_scalbnf.c new file mode 100644 index 0000000000..547971836a --- /dev/null +++ b/ports/sysdeps/m68k/m680x0/fpu/s_scalbnf.c @@ -0,0 +1,3 @@ +#define suffix f +#define float_type float +#include <s_scalbn.c> diff --git a/ports/sysdeps/m68k/m680x0/fpu/s_scalbnl.c b/ports/sysdeps/m68k/m680x0/fpu/s_scalbnl.c new file mode 100644 index 0000000000..874bafb04b --- /dev/null +++ b/ports/sysdeps/m68k/m680x0/fpu/s_scalbnl.c @@ -0,0 +1,3 @@ +#define suffix l +#define float_type long double +#include <s_scalbn.c> diff --git a/ports/sysdeps/m68k/m680x0/fpu/s_significand.c b/ports/sysdeps/m68k/m680x0/fpu/s_significand.c new file mode 100644 index 0000000000..34d4ea3d14 --- /dev/null +++ b/ports/sysdeps/m68k/m680x0/fpu/s_significand.c @@ -0,0 +1,2 @@ +#define FUNC significand +#include <s_atan.c> diff --git a/ports/sysdeps/m68k/m680x0/fpu/s_significandf.c b/ports/sysdeps/m68k/m680x0/fpu/s_significandf.c new file mode 100644 index 0000000000..4e769ca317 --- /dev/null +++ b/ports/sysdeps/m68k/m680x0/fpu/s_significandf.c @@ -0,0 +1,2 @@ +#define FUNC significandf +#include <s_atanf.c> diff --git a/ports/sysdeps/m68k/m680x0/fpu/s_significandl.c b/ports/sysdeps/m68k/m680x0/fpu/s_significandl.c new file mode 100644 index 0000000000..8c6fc7e610 --- /dev/null +++ b/ports/sysdeps/m68k/m680x0/fpu/s_significandl.c @@ -0,0 +1,2 @@ +#define FUNC significandl +#include <s_atanl.c> diff --git a/ports/sysdeps/m68k/m680x0/fpu/s_sin.c b/ports/sysdeps/m68k/m680x0/fpu/s_sin.c new file mode 100644 index 0000000000..4f9b659462 --- /dev/null +++ b/ports/sysdeps/m68k/m680x0/fpu/s_sin.c @@ -0,0 +1,40 @@ +/* Copyright (C) 2012 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, see + <http://www.gnu.org/licenses/>. */ + +#include <math.h> +#include <errno.h> +#include "mathimpl.h" + +#ifndef FUNC +# define FUNC sin +#endif +#ifndef float_type +# define float_type double +#endif + +#define CONCATX(a,b) __CONCAT(a,b) + +float_type +CONCATX(__,FUNC) (float_type x) +{ + if (__m81_test (x) & __M81_COND_INF) + __set_errno (EDOM); + return __m81_u(CONCATX(__, FUNC)) (x); +} + +#define weak_aliasx(a, b) weak_alias(a, b) +weak_aliasx (CONCATX(__, FUNC), FUNC) diff --git a/ports/sysdeps/m68k/m680x0/fpu/s_sincos.c b/ports/sysdeps/m68k/m680x0/fpu/s_sincos.c new file mode 100644 index 0000000000..5e10db231e --- /dev/null +++ b/ports/sysdeps/m68k/m680x0/fpu/s_sincos.c @@ -0,0 +1,37 @@ +/* Copyright (C) 1997 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, see + <http://www.gnu.org/licenses/>. */ + +#include <math.h> + +#ifndef FUNC +#define FUNC sincos +#endif +#ifndef float_type +#define float_type double +#endif + +#define CONCATX(a,b) __CONCAT(a,b) + +void +CONCATX(__,FUNC) (x, sinx, cosx) + float_type x, *sinx, *cosx; +{ + __m81_u(CONCATX(__,FUNC))(x, sinx, cosx); +} + +#define weak_aliasx(a,b) weak_alias(a,b) +weak_aliasx (CONCATX(__,FUNC), FUNC) diff --git a/ports/sysdeps/m68k/m680x0/fpu/s_sincosf.c b/ports/sysdeps/m68k/m680x0/fpu/s_sincosf.c new file mode 100644 index 0000000000..7ee2ec6600 --- /dev/null +++ b/ports/sysdeps/m68k/m680x0/fpu/s_sincosf.c @@ -0,0 +1,3 @@ +#define FUNC sincosf +#define float_type float +#include <s_sincos.c> diff --git a/ports/sysdeps/m68k/m680x0/fpu/s_sincosl.c b/ports/sysdeps/m68k/m680x0/fpu/s_sincosl.c new file mode 100644 index 0000000000..f998cc0977 --- /dev/null +++ b/ports/sysdeps/m68k/m680x0/fpu/s_sincosl.c @@ -0,0 +1,3 @@ +#define FUNC sincosl +#define float_type long double +#include <s_sincos.c> diff --git a/ports/sysdeps/m68k/m680x0/fpu/s_sinf.c b/ports/sysdeps/m68k/m680x0/fpu/s_sinf.c new file mode 100644 index 0000000000..304f4f76f6 --- /dev/null +++ b/ports/sysdeps/m68k/m680x0/fpu/s_sinf.c @@ -0,0 +1,5 @@ +#ifndef FUNC +# define FUNC sinf +#endif +#define float_type float +#include <s_sin.c> diff --git a/ports/sysdeps/m68k/m680x0/fpu/s_sinl.c b/ports/sysdeps/m68k/m680x0/fpu/s_sinl.c new file mode 100644 index 0000000000..31dac0bee7 --- /dev/null +++ b/ports/sysdeps/m68k/m680x0/fpu/s_sinl.c @@ -0,0 +1,5 @@ +#ifndef FUNC +# define FUNC sinl +#endif +#define float_type long double +#include <s_sin.c> diff --git a/ports/sysdeps/m68k/m680x0/fpu/s_tan.c b/ports/sysdeps/m68k/m680x0/fpu/s_tan.c new file mode 100644 index 0000000000..dfbbbb2270 --- /dev/null +++ b/ports/sysdeps/m68k/m680x0/fpu/s_tan.c @@ -0,0 +1,2 @@ +#define FUNC tan +#include <s_sin.c> diff --git a/ports/sysdeps/m68k/m680x0/fpu/s_tanf.c b/ports/sysdeps/m68k/m680x0/fpu/s_tanf.c new file mode 100644 index 0000000000..9ae66ddbf3 --- /dev/null +++ b/ports/sysdeps/m68k/m680x0/fpu/s_tanf.c @@ -0,0 +1,2 @@ +#define FUNC tanf +#include <s_sinf.c> diff --git a/ports/sysdeps/m68k/m680x0/fpu/s_tanh.c b/ports/sysdeps/m68k/m680x0/fpu/s_tanh.c new file mode 100644 index 0000000000..ac2e7dbb79 --- /dev/null +++ b/ports/sysdeps/m68k/m680x0/fpu/s_tanh.c @@ -0,0 +1,2 @@ +#define FUNC tanh +#include <s_atan.c> diff --git a/ports/sysdeps/m68k/m680x0/fpu/s_tanhf.c b/ports/sysdeps/m68k/m680x0/fpu/s_tanhf.c new file mode 100644 index 0000000000..1addaae4ff --- /dev/null +++ b/ports/sysdeps/m68k/m680x0/fpu/s_tanhf.c @@ -0,0 +1,2 @@ +#define FUNC tanhf +#include <s_atanf.c> diff --git a/ports/sysdeps/m68k/m680x0/fpu/s_tanhl.c b/ports/sysdeps/m68k/m680x0/fpu/s_tanhl.c new file mode 100644 index 0000000000..6e997911f2 --- /dev/null +++ b/ports/sysdeps/m68k/m680x0/fpu/s_tanhl.c @@ -0,0 +1,2 @@ +#define FUNC tanhl +#include <s_atanl.c> diff --git a/ports/sysdeps/m68k/m680x0/fpu/s_tanl.c b/ports/sysdeps/m68k/m680x0/fpu/s_tanl.c new file mode 100644 index 0000000000..27daf8f29b --- /dev/null +++ b/ports/sysdeps/m68k/m680x0/fpu/s_tanl.c @@ -0,0 +1,2 @@ +#define FUNC tanl +#include <s_sinl.c> diff --git a/ports/sysdeps/m68k/m680x0/fpu/s_trunc.c b/ports/sysdeps/m68k/m680x0/fpu/s_trunc.c new file mode 100644 index 0000000000..96f29a776c --- /dev/null +++ b/ports/sysdeps/m68k/m680x0/fpu/s_trunc.c @@ -0,0 +1,2 @@ +#define FUNC trunc +#include <s_atan.c> diff --git a/ports/sysdeps/m68k/m680x0/fpu/s_truncf.c b/ports/sysdeps/m68k/m680x0/fpu/s_truncf.c new file mode 100644 index 0000000000..44dca748ca --- /dev/null +++ b/ports/sysdeps/m68k/m680x0/fpu/s_truncf.c @@ -0,0 +1,2 @@ +#define FUNC truncf +#include <s_atanf.c> diff --git a/ports/sysdeps/m68k/m680x0/fpu/s_truncl.c b/ports/sysdeps/m68k/m680x0/fpu/s_truncl.c new file mode 100644 index 0000000000..8d35777aed --- /dev/null +++ b/ports/sysdeps/m68k/m680x0/fpu/s_truncl.c @@ -0,0 +1,2 @@ +#define FUNC truncl +#include <s_atanl.c> diff --git a/ports/sysdeps/m68k/m680x0/fpu/sincos32.c b/ports/sysdeps/m68k/m680x0/fpu/sincos32.c new file mode 100644 index 0000000000..1cc8931700 --- /dev/null +++ b/ports/sysdeps/m68k/m680x0/fpu/sincos32.c @@ -0,0 +1 @@ +/* Not needed. */ diff --git a/ports/sysdeps/m68k/m680x0/fpu/sincostab.c b/ports/sysdeps/m68k/m680x0/fpu/sincostab.c new file mode 100644 index 0000000000..1cc8931700 --- /dev/null +++ b/ports/sysdeps/m68k/m680x0/fpu/sincostab.c @@ -0,0 +1 @@ +/* Not needed. */ diff --git a/ports/sysdeps/m68k/m680x0/fpu/slowexp.c b/ports/sysdeps/m68k/m680x0/fpu/slowexp.c new file mode 100644 index 0000000000..1cc8931700 --- /dev/null +++ b/ports/sysdeps/m68k/m680x0/fpu/slowexp.c @@ -0,0 +1 @@ +/* Not needed. */ diff --git a/ports/sysdeps/m68k/m680x0/fpu/slowpow.c b/ports/sysdeps/m68k/m680x0/fpu/slowpow.c new file mode 100644 index 0000000000..1cc8931700 --- /dev/null +++ b/ports/sysdeps/m68k/m680x0/fpu/slowpow.c @@ -0,0 +1 @@ +/* Not needed. */ diff --git a/ports/sysdeps/m68k/m680x0/fpu/t_exp.c b/ports/sysdeps/m68k/m680x0/fpu/t_exp.c new file mode 100644 index 0000000000..fd37963b05 --- /dev/null +++ b/ports/sysdeps/m68k/m680x0/fpu/t_exp.c @@ -0,0 +1 @@ +/* Empty. Not needed. */ diff --git a/ports/sysdeps/m68k/m680x0/lshift.S b/ports/sysdeps/m68k/m680x0/lshift.S new file mode 100644 index 0000000000..d0d4da7d41 --- /dev/null +++ b/ports/sysdeps/m68k/m680x0/lshift.S @@ -0,0 +1,168 @@ +/* mc68020 __mpn_lshift -- Shift left a low-level natural-number integer. + +Copyright (C) 1996, 1998, 2012 Free Software Foundation, Inc. + +This file is part of the GNU MP Library. + +The GNU MP 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 MP 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 MP Library. If not, see <http://www.gnu.org/licenses/>. */ + +/* + INPUT PARAMETERS + res_ptr (sp + 4) + s_ptr (sp + 8) + s_size (sp + 16) + cnt (sp + 12) +*/ + +#include "sysdep.h" +#include "asm-syntax.h" + +#define res_ptr a1 +#define s_ptr a0 +#define s_size d6 +#define cnt d4 + + TEXT +ENTRY(__mpn_lshift) + +/* Save used registers on the stack. */ + moveml R(d2)-R(d6)/R(a2),MEM_PREDEC(sp) + cfi_adjust_cfa_offset (6*4) + cfi_rel_offset (R(d2), 0) + cfi_rel_offset (R(d3), 4) + cfi_rel_offset (R(d4), 8) + cfi_rel_offset (R(d5), 12) + cfi_rel_offset (R(d6), 16) + cfi_rel_offset (R(a2), 20) + +/* Copy the arguments to registers. */ + movel MEM_DISP(sp,28),R(res_ptr) + movel MEM_DISP(sp,32),R(s_ptr) + movel MEM_DISP(sp,36),R(s_size) + movel MEM_DISP(sp,40),R(cnt) + + moveql #1,R(d5) + cmpl R(d5),R(cnt) + bne L(Lnormal) + cmpl R(s_ptr),R(res_ptr) + bls L(Lspecial) /* jump if s_ptr >= res_ptr */ +#if (defined (__mc68020__) || defined (__NeXT__) || defined(mc68020)) + lea MEM_INDX1(s_ptr,s_size,l,4),R(a2) +#else /* not mc68020 */ + movel R(s_size),R(d0) + asll #2,R(d0) + lea MEM_INDX(s_ptr,d0,l),R(a2) +#endif + cmpl R(res_ptr),R(a2) + bls L(Lspecial) /* jump if res_ptr >= s_ptr + s_size */ + +L(Lnormal:) + moveql #32,R(d5) + subl R(cnt),R(d5) + +#if (defined (__mc68020__) || defined (__NeXT__) || defined(mc68020)) + lea MEM_INDX1(s_ptr,s_size,l,4),R(s_ptr) + lea MEM_INDX1(res_ptr,s_size,l,4),R(res_ptr) +#else /* not mc68000 */ + movel R(s_size),R(d0) + asll #2,R(d0) + addl R(s_size),R(s_ptr) + addl R(s_size),R(res_ptr) +#endif + movel MEM_PREDEC(s_ptr),R(d2) + movel R(d2),R(d0) + lsrl R(d5),R(d0) /* compute carry limb */ + + lsll R(cnt),R(d2) + movel R(d2),R(d1) + subql #1,R(s_size) + beq L(Lend) + lsrl #1,R(s_size) + bcs L(L1) + subql #1,R(s_size) + +L(Loop:) + movel MEM_PREDEC(s_ptr),R(d2) + movel R(d2),R(d3) + lsrl R(d5),R(d3) + orl R(d3),R(d1) + movel R(d1),MEM_PREDEC(res_ptr) + lsll R(cnt),R(d2) +L(L1:) + movel MEM_PREDEC(s_ptr),R(d1) + movel R(d1),R(d3) + lsrl R(d5),R(d3) + orl R(d3),R(d2) + movel R(d2),MEM_PREDEC(res_ptr) + lsll R(cnt),R(d1) + + dbf R(s_size),L(Loop) + subl #0x10000,R(s_size) + bcc L(Loop) + +L(Lend:) + movel R(d1),MEM_PREDEC(res_ptr) /* store least significant limb */ + +/* Restore used registers from stack frame. */ + moveml MEM_POSTINC(sp),R(d2)-R(d6)/R(a2) + cfi_remember_state + cfi_adjust_cfa_offset (-6*4) + cfi_restore (R(d2)) + cfi_restore (R(d3)) + cfi_restore (R(d4)) + cfi_restore (R(d5)) + cfi_restore (R(d6)) + cfi_restore (R(a2)) + rts + +/* We loop from least significant end of the arrays, which is only + permissible if the source and destination don't overlap, since the + function is documented to work for overlapping source and destination. */ + + cfi_restore_state +L(Lspecial:) + clrl R(d0) /* initialize carry */ + eorw #1,R(s_size) + lsrl #1,R(s_size) + bcc L(LL1) + subql #1,R(s_size) + +L(LLoop:) + movel MEM_POSTINC(s_ptr),R(d2) + addxl R(d2),R(d2) + movel R(d2),MEM_POSTINC(res_ptr) +L(LL1:) + movel MEM_POSTINC(s_ptr),R(d2) + addxl R(d2),R(d2) + movel R(d2),MEM_POSTINC(res_ptr) + + dbf R(s_size),L(LLoop) + addxl R(d0),R(d0) /* save cy in lsb */ + subl #0x10000,R(s_size) + bcs L(LLend) + lsrl #1,R(d0) /* restore cy */ + bra L(LLoop) + +L(LLend:) +/* Restore used registers from stack frame. */ + moveml MEM_POSTINC(sp),R(d2)-R(d6)/R(a2) + cfi_adjust_cfa_offset (-6*4) + cfi_restore (R(d2)) + cfi_restore (R(d3)) + cfi_restore (R(d4)) + cfi_restore (R(d5)) + cfi_restore (R(d6)) + cfi_restore (R(a2)) + rts +END(__mpn_lshift) diff --git a/ports/sysdeps/m68k/m680x0/m68020/Makefile b/ports/sysdeps/m68k/m680x0/m68020/Makefile new file mode 100644 index 0000000000..b17635467d --- /dev/null +++ b/ports/sysdeps/m68k/m680x0/m68020/Makefile @@ -0,0 +1,3 @@ +ifeq ($(subdir),db2) +CPPFLAGS += -DHAVE_SPINLOCKS=1 -DHAVE_ASSEM_MC68020_GCC=1 +endif diff --git a/ports/sysdeps/m68k/m680x0/m68020/addmul_1.S b/ports/sysdeps/m68k/m680x0/m68020/addmul_1.S new file mode 100644 index 0000000000..7b6d03db63 --- /dev/null +++ b/ports/sysdeps/m68k/m680x0/m68020/addmul_1.S @@ -0,0 +1,88 @@ +/* mc68020 __mpn_addmul_1 -- Multiply a limb vector with a limb and add + the result to a second limb vector. + +Copyright (C) 1992, 1994, 1996, 1998, 2012 Free Software Foundation, Inc. + +This file is part of the GNU MP Library. + +The GNU MP 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 MP 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 MP Library. If not, see <http://www.gnu.org/licenses/>. */ + +/* + INPUT PARAMETERS + res_ptr (sp + 4) + s1_ptr (sp + 8) + s1_size (sp + 12) + s2_limb (sp + 16) +*/ + +#include "sysdep.h" +#include "asm-syntax.h" + + TEXT +ENTRY(__mpn_addmul_1) + +#define res_ptr a0 +#define s1_ptr a1 +#define s1_size d2 +#define s2_limb d4 + +/* Save used registers on the stack. */ + moveml R(d2)-R(d5),MEM_PREDEC(sp) + cfi_adjust_cfa_offset (4*4) + cfi_rel_offset (R(d2), 0) + cfi_rel_offset (R(d3), 4) + cfi_rel_offset (R(d4), 8) + cfi_rel_offset (R(d5), 12) + +/* Copy the arguments to registers. Better use movem? */ + movel MEM_DISP(sp,20),R(res_ptr) + movel MEM_DISP(sp,24),R(s1_ptr) + movel MEM_DISP(sp,28),R(s1_size) + movel MEM_DISP(sp,32),R(s2_limb) + + eorw #1,R(s1_size) + clrl R(d1) + clrl R(d5) + lsrl #1,R(s1_size) + bcc L(L1) + subql #1,R(s1_size) + subl R(d0),R(d0) /* (d0,cy) <= (0,0) */ + +L(Loop:) + movel MEM_POSTINC(s1_ptr),R(d3) + mulul R(s2_limb),R(d1):R(d3) + addxl R(d0),R(d3) + addxl R(d5),R(d1) + addl R(d3),MEM_POSTINC(res_ptr) +L(L1:) movel MEM_POSTINC(s1_ptr),R(d3) + mulul R(s2_limb),R(d0):R(d3) + addxl R(d1),R(d3) + addxl R(d5),R(d0) + addl R(d3),MEM_POSTINC(res_ptr) + + dbf R(s1_size),L(Loop) + addxl R(d5),R(d0) + subl #0x10000,R(s1_size) + bcc L(Loop) + +/* Restore used registers from stack frame. */ + moveml MEM_POSTINC(sp),R(d2)-R(d5) + cfi_adjust_cfa_offset (-4*4) + cfi_restore (R(d2)) + cfi_restore (R(d3)) + cfi_restore (R(d4)) + cfi_restore (R(d5)) + + rts +END(__mpn_addmul_1) diff --git a/ports/sysdeps/m68k/m680x0/m68020/bits/atomic.h b/ports/sysdeps/m68k/m680x0/m68020/bits/atomic.h new file mode 100644 index 0000000000..7ae5fb96dc --- /dev/null +++ b/ports/sysdeps/m68k/m680x0/m68020/bits/atomic.h @@ -0,0 +1,253 @@ +/* Copyright (C) 2003, 2004 Free Software Foundation, Inc. + This file is part of the GNU C Library. + Contributed by Andreas Schwab <schwab@suse.de>, 2003. + + 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, see + <http://www.gnu.org/licenses/>. */ + +#include <stdint.h> + + +typedef int8_t atomic8_t; +typedef uint8_t uatomic8_t; +typedef int_fast8_t atomic_fast8_t; +typedef uint_fast8_t uatomic_fast8_t; + +typedef int16_t atomic16_t; +typedef uint16_t uatomic16_t; +typedef int_fast16_t atomic_fast16_t; +typedef uint_fast16_t uatomic_fast16_t; + +typedef int32_t atomic32_t; +typedef uint32_t uatomic32_t; +typedef int_fast32_t atomic_fast32_t; +typedef uint_fast32_t uatomic_fast32_t; + +typedef int64_t atomic64_t; +typedef uint64_t uatomic64_t; +typedef int_fast64_t atomic_fast64_t; +typedef uint_fast64_t uatomic_fast64_t; + +typedef intptr_t atomicptr_t; +typedef uintptr_t uatomicptr_t; +typedef intmax_t atomic_max_t; +typedef uintmax_t uatomic_max_t; + +#define __arch_compare_and_exchange_val_8_acq(mem, newval, oldval) \ + ({ __typeof (*(mem)) __ret; \ + __asm __volatile ("cas%.b %0,%2,%1" \ + : "=d" (__ret), "+m" (*(mem)) \ + : "d" (newval), "0" (oldval)); \ + __ret; }) + +#define __arch_compare_and_exchange_val_16_acq(mem, newval, oldval) \ + ({ __typeof (*(mem)) __ret; \ + __asm __volatile ("cas%.w %0,%2,%1" \ + : "=d" (__ret), "+m" (*(mem)) \ + : "d" (newval), "0" (oldval)); \ + __ret; }) + +#define __arch_compare_and_exchange_val_32_acq(mem, newval, oldval) \ + ({ __typeof (*(mem)) __ret; \ + __asm __volatile ("cas%.l %0,%2,%1" \ + : "=d" (__ret), "+m" (*(mem)) \ + : "d" (newval), "0" (oldval)); \ + __ret; }) + +# define __arch_compare_and_exchange_val_64_acq(mem, newval, oldval) \ + ({ __typeof (*(mem)) __ret; \ + __typeof (mem) __memp = (mem); \ + __asm __volatile ("cas2%.l %0:%R0,%1:%R1,(%2):(%3)" \ + : "=d" (__ret) \ + : "d" (newval), "r" (__memp), \ + "r" ((char *) __memp + 4), "0" (oldval) \ + : "memory"); \ + __ret; }) + +#define atomic_exchange_acq(mem, newvalue) \ + ({ __typeof (*(mem)) __result = *(mem); \ + if (sizeof (*(mem)) == 1) \ + __asm __volatile ("1: cas%.b %0,%2,%1;" \ + " jbne 1b" \ + : "=d" (__result), "+m" (*(mem)) \ + : "d" (newvalue), "0" (__result)); \ + else if (sizeof (*(mem)) == 2) \ + __asm __volatile ("1: cas%.w %0,%2,%1;" \ + " jbne 1b" \ + : "=d" (__result), "+m" (*(mem)) \ + : "d" (newvalue), "0" (__result)); \ + else if (sizeof (*(mem)) == 4) \ + __asm __volatile ("1: cas%.l %0,%2,%1;" \ + " jbne 1b" \ + : "=d" (__result), "+m" (*(mem)) \ + : "d" (newvalue), "0" (__result)); \ + else \ + { \ + __typeof (mem) __memp = (mem); \ + __asm __volatile ("1: cas2%.l %0:%R0,%1:%R1,(%2):(%3);" \ + " jbne 1b" \ + : "=d" (__result) \ + : "d" (newvalue), "r" (__memp), \ + "r" ((char *) __memp + 4), "0" (__result) \ + : "memory"); \ + } \ + __result; }) + +#define atomic_exchange_and_add(mem, value) \ + ({ __typeof (*(mem)) __result = *(mem); \ + __typeof (*(mem)) __temp; \ + if (sizeof (*(mem)) == 1) \ + __asm __volatile ("1: move%.b %0,%2;" \ + " add%.b %3,%2;" \ + " cas%.b %0,%2,%1;" \ + " jbne 1b" \ + : "=d" (__result), "+m" (*(mem)), \ + "=&d" (__temp) \ + : "d" (value), "0" (__result)); \ + else if (sizeof (*(mem)) == 2) \ + __asm __volatile ("1: move%.w %0,%2;" \ + " add%.w %3,%2;" \ + " cas%.w %0,%2,%1;" \ + " jbne 1b" \ + : "=d" (__result), "+m" (*(mem)), \ + "=&d" (__temp) \ + : "d" (value), "0" (__result)); \ + else if (sizeof (*(mem)) == 4) \ + __asm __volatile ("1: move%.l %0,%2;" \ + " add%.l %3,%2;" \ + " cas%.l %0,%2,%1;" \ + " jbne 1b" \ + : "=d" (__result), "+m" (*(mem)), \ + "=&d" (__temp) \ + : "d" (value), "0" (__result)); \ + else \ + { \ + __typeof (mem) __memp = (mem); \ + __asm __volatile ("1: move%.l %0,%1;" \ + " move%.l %R0,%R1;" \ + " add%.l %2,%1;" \ + " addx%.l %R2,%R1;" \ + " cas2%.l %0:%R0,%1:%R1,(%3):(%4);" \ + " jbne 1b" \ + : "=d" (__result), "=&d" (__temp) \ + : "d" (value), "r" (__memp), \ + "r" ((char *) __memp + 4), "0" (__result) \ + : "memory"); \ + } \ + __result; }) + +#define atomic_add(mem, value) \ + (void) ({ if (sizeof (*(mem)) == 1) \ + __asm __volatile ("add%.b %1,%0" \ + : "+m" (*(mem)) \ + : "id" (value)); \ + else if (sizeof (*(mem)) == 2) \ + __asm __volatile ("add%.w %1,%0" \ + : "+m" (*(mem)) \ + : "id" (value)); \ + else if (sizeof (*(mem)) == 4) \ + __asm __volatile ("add%.l %1,%0" \ + : "+m" (*(mem)) \ + : "id" (value)); \ + else \ + { \ + __typeof (mem) __memp = (mem); \ + __typeof (*(mem)) __oldval = *__memp; \ + __typeof (*(mem)) __temp; \ + __asm __volatile ("1: move%.l %0,%1;" \ + " move%.l %R0,%R1;" \ + " add%.l %2,%1;" \ + " addx%.l %R2,%R1;" \ + " cas2%.l %0:%R0,%1:%R1,(%3):(%4);" \ + " jbne 1b" \ + : "=d" (__oldval), "=&d" (__temp) \ + : "d" (value), "r" (__memp), \ + "r" ((char *) __memp + 4), "0" (__oldval) \ + : "memory"); \ + } \ + }) + +#define atomic_increment_and_test(mem) \ + ({ char __result; \ + if (sizeof (*(mem)) == 1) \ + __asm __volatile ("addq%.b %#1,%1; seq %0" \ + : "=dm" (__result), "+m" (*(mem))); \ + else if (sizeof (*(mem)) == 2) \ + __asm __volatile ("addq%.w %#1,%1; seq %0" \ + : "=dm" (__result), "+m" (*(mem))); \ + else if (sizeof (*(mem)) == 4) \ + __asm __volatile ("addq%.l %#1,%1; seq %0" \ + : "=dm" (__result), "+m" (*(mem))); \ + else \ + { \ + __typeof (mem) __memp = (mem); \ + __typeof (*(mem)) __oldval = *__memp; \ + __typeof (*(mem)) __temp; \ + __asm __volatile ("1: move%.l %1,%2;" \ + " move%.l %R1,%R2;" \ + " addq%.l %#1,%2;" \ + " addx%.l %5,%R2;" \ + " seq %0;" \ + " cas2%.l %1:%R1,%2:%R2,(%3):(%4);" \ + " jbne 1b" \ + : "=&dm" (__result), "=d" (__oldval), \ + "=&d" (__temp) \ + : "r" (__memp), "r" ((char *) __memp + 4), \ + "d" (0), "1" (__oldval) \ + : "memory"); \ + } \ + __result; }) + +#define atomic_decrement_and_test(mem) \ + ({ char __result; \ + if (sizeof (*(mem)) == 1) \ + __asm __volatile ("subq%.b %#1,%1; seq %0" \ + : "=dm" (__result), "+m" (*(mem))); \ + else if (sizeof (*(mem)) == 2) \ + __asm __volatile ("subq%.w %#1,%1; seq %0" \ + : "=dm" (__result), "+m" (*(mem))); \ + else if (sizeof (*(mem)) == 4) \ + __asm __volatile ("subq%.l %#1,%1; seq %0" \ + : "=dm" (__result), "+m" (*(mem))); \ + else \ + { \ + __typeof (mem) __memp = (mem); \ + __typeof (*(mem)) __oldval = *__memp; \ + __typeof (*(mem)) __temp; \ + __asm __volatile ("1: move%.l %1,%2;" \ + " move%.l %R1,%R2;" \ + " subq%.l %#1,%2;" \ + " subx%.l %5,%R2;" \ + " seq %0;" \ + " cas2%.l %1:%R1,%2:%R2,(%3):(%4);" \ + " jbne 1b" \ + : "=&dm" (__result), "=d" (__oldval), \ + "=&d" (__temp) \ + : "r" (__memp), "r" ((char *) __memp + 4), \ + "d" (0), "1" (__oldval) \ + : "memory"); \ + } \ + __result; }) + +#define atomic_bit_set(mem, bit) \ + __asm __volatile ("bfset %0{%1,#1}" \ + : "+m" (*(mem)) \ + : "di" (sizeof (*(mem)) * 8 - (bit) - 1)) + +#define atomic_bit_test_set(mem, bit) \ + ({ char __result; \ + __asm __volatile ("bfset %1{%2,#1}; sne %0" \ + : "=dm" (__result), "+m" (*(mem)) \ + : "di" (sizeof (*(mem)) * 8 - (bit) - 1)); \ + __result; }) diff --git a/ports/sysdeps/m68k/m680x0/m68020/bits/string.h b/ports/sysdeps/m68k/m680x0/m68020/bits/string.h new file mode 100644 index 0000000000..cb68c78b2e --- /dev/null +++ b/ports/sysdeps/m68k/m680x0/m68020/bits/string.h @@ -0,0 +1,25 @@ +/* Optimized, inlined string functions. m680x0 version, x >= 2. + Copyright (C) 1997 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, see + <http://www.gnu.org/licenses/>. */ + +#ifndef _STRING_H +# error "Never use <bits/string.h> directly; include <string.h> instead." +#endif + +/* Currently the only purpose of this file is to tell the generic inline + macros that unaligned memory access is possible. */ +#define _STRING_ARCH_unaligned 1 diff --git a/ports/sysdeps/m68k/m680x0/m68020/mul_1.S b/ports/sysdeps/m68k/m680x0/m68020/mul_1.S new file mode 100644 index 0000000000..e14ae51d3f --- /dev/null +++ b/ports/sysdeps/m68k/m680x0/m68020/mul_1.S @@ -0,0 +1,83 @@ +/* mc68020 __mpn_mul_1 -- Multiply a limb vector with a limb and store + the result in a second limb vector. + +Copyright (C) 1992, 1994, 1996, 1998, 2012 Free Software Foundation, Inc. + +This file is part of the GNU MP Library. + +The GNU MP 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 MP 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 MP Library. If not, see <http://www.gnu.org/licenses/>. */ + +/* + INPUT PARAMETERS + res_ptr (sp + 4) + s1_ptr (sp + 8) + s1_size (sp + 12) + s2_limb (sp + 16) +*/ + +#include "sysdep.h" +#include "asm-syntax.h" + + TEXT +ENTRY(__mpn_mul_1) + +#define res_ptr a0 +#define s1_ptr a1 +#define s1_size d2 +#define s2_limb d4 + +/* Save used registers on the stack. */ + moveml R(d2)-R(d4),MEM_PREDEC(sp) + cfi_adjust_cfa_offset (3*4) + cfi_rel_offset (R(d2), 0) + cfi_rel_offset (R(d3), 4) + cfi_rel_offset (R(d4), 8) + +/* Copy the arguments to registers. Better use movem? */ + movel MEM_DISP(sp,16),R(res_ptr) + movel MEM_DISP(sp,20),R(s1_ptr) + movel MEM_DISP(sp,24),R(s1_size) + movel MEM_DISP(sp,28),R(s2_limb) + + eorw #1,R(s1_size) + clrl R(d1) + lsrl #1,R(s1_size) + bcc L(L1) + subql #1,R(s1_size) + subl R(d0),R(d0) /* (d0,cy) <= (0,0) */ + +L(Loop:) + movel MEM_POSTINC(s1_ptr),R(d3) + mulul R(s2_limb),R(d1):R(d3) + addxl R(d0),R(d3) + movel R(d3),MEM_POSTINC(res_ptr) +L(L1:) movel MEM_POSTINC(s1_ptr),R(d3) + mulul R(s2_limb),R(d0):R(d3) + addxl R(d1),R(d3) + movel R(d3),MEM_POSTINC(res_ptr) + + dbf R(s1_size),L(Loop) + clrl R(d3) + addxl R(d3),R(d0) + subl #0x10000,R(s1_size) + bcc L(Loop) + +/* Restore used registers from stack frame. */ + moveml MEM_POSTINC(sp),R(d2)-R(d4) + cfi_adjust_cfa_offset (-3*4) + cfi_restore (R(d2)) + cfi_restore (R(d3)) + cfi_restore (R(d4)) + rts +END(__mpn_mul_1) diff --git a/ports/sysdeps/m68k/m680x0/m68020/submul_1.S b/ports/sysdeps/m68k/m680x0/m68020/submul_1.S new file mode 100644 index 0000000000..c42845daa7 --- /dev/null +++ b/ports/sysdeps/m68k/m680x0/m68020/submul_1.S @@ -0,0 +1,88 @@ +/* mc68020 __mpn_submul_1 -- Multiply a limb vector with a limb and subtract + the result from a second limb vector. + +Copyright (C) 1992, 1994, 1996, 1998, 2012 Free Software Foundation, Inc. + +This file is part of the GNU MP Library. + +The GNU MP 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 MP 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 MP Library. If not, see <http://www.gnu.org/licenses/>. */ + +/* + INPUT PARAMETERS + res_ptr (sp + 4) + s1_ptr (sp + 8) + s1_size (sp + 12) + s2_limb (sp + 16) +*/ + +#include "sysdep.h" +#include "asm-syntax.h" + + TEXT +ENTRY(__mpn_submul_1) + +#define res_ptr a0 +#define s1_ptr a1 +#define s1_size d2 +#define s2_limb d4 + +/* Save used registers on the stack. */ + moveml R(d2)-R(d5),MEM_PREDEC(sp) + cfi_adjust_cfa_offset (4*4) + cfi_rel_offset (R(d2), 0) + cfi_rel_offset (R(d3), 4) + cfi_rel_offset (R(d4), 8) + cfi_rel_offset (R(d5), 12) + +/* Copy the arguments to registers. Better use movem? */ + movel MEM_DISP(sp,20),R(res_ptr) + movel MEM_DISP(sp,24),R(s1_ptr) + movel MEM_DISP(sp,28),R(s1_size) + movel MEM_DISP(sp,32),R(s2_limb) + + eorw #1,R(s1_size) + clrl R(d1) + clrl R(d5) + lsrl #1,R(s1_size) + bcc L(L1) + subql #1,R(s1_size) + subl R(d0),R(d0) /* (d0,cy) <= (0,0) */ + +L(Loop:) + movel MEM_POSTINC(s1_ptr),R(d3) + mulul R(s2_limb),R(d1):R(d3) + addxl R(d0),R(d3) + addxl R(d5),R(d1) + subl R(d3),MEM_POSTINC(res_ptr) +L(L1:) movel MEM_POSTINC(s1_ptr),R(d3) + mulul R(s2_limb),R(d0):R(d3) + addxl R(d1),R(d3) + addxl R(d5),R(d0) + subl R(d3),MEM_POSTINC(res_ptr) + + dbf R(s1_size),L(Loop) + addxl R(d5),R(d0) + subl #0x10000,R(s1_size) + bcc L(Loop) + +/* Restore used registers from stack frame. */ + moveml MEM_POSTINC(sp),R(d2)-R(d5) + cfi_adjust_cfa_offset (-4*4) + cfi_restore (R(d2)) + cfi_restore (R(d3)) + cfi_restore (R(d4)) + cfi_restore (R(d5)) + + rts +END(__mpn_submul_1) diff --git a/ports/sysdeps/m68k/m680x0/m68020/wordcopy.S b/ports/sysdeps/m68k/m680x0/m68020/wordcopy.S new file mode 100644 index 0000000000..4fb1a4518f --- /dev/null +++ b/ports/sysdeps/m68k/m680x0/m68020/wordcopy.S @@ -0,0 +1 @@ +/* Empty, not needed. */ diff --git a/ports/sysdeps/m68k/m680x0/printf_fphex.c b/ports/sysdeps/m68k/m680x0/printf_fphex.c new file mode 100644 index 0000000000..d021a090ab --- /dev/null +++ b/ports/sysdeps/m68k/m680x0/printf_fphex.c @@ -0,0 +1,2 @@ +#define LONG_DOUBLE_DENORM_BIAS IEEE854_LONG_DOUBLE_BIAS +#include <sysdeps/ieee754/ldbl-96/printf_fphex.c> diff --git a/ports/sysdeps/m68k/m680x0/rshift.S b/ports/sysdeps/m68k/m680x0/rshift.S new file mode 100644 index 0000000000..f5f2f3d69a --- /dev/null +++ b/ports/sysdeps/m68k/m680x0/rshift.S @@ -0,0 +1,167 @@ +/* mc68020 __mpn_rshift -- Shift right a low-level natural-number integer. + +Copyright (C) 1996, 1998, 2012 Free Software Foundation, Inc. + +This file is part of the GNU MP Library. + +The GNU MP 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 MP 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 MP Library. If not, see <http://www.gnu.org/licenses/>. */ + +/* + INPUT PARAMETERS + res_ptr (sp + 4) + s_ptr (sp + 8) + s_size (sp + 16) + cnt (sp + 12) +*/ + +#include "sysdep.h" +#include "asm-syntax.h" + +#define res_ptr a1 +#define s_ptr a0 +#define s_size d6 +#define cnt d4 + + TEXT +ENTRY(__mpn_rshift) +/* Save used registers on the stack. */ + moveml R(d2)-R(d6)/R(a2),MEM_PREDEC(sp) + cfi_adjust_cfa_offset (6*4) + cfi_rel_offset (R(d2), 0) + cfi_rel_offset (R(d3), 4) + cfi_rel_offset (R(d4), 8) + cfi_rel_offset (R(d5), 12) + cfi_rel_offset (R(d6), 16) + cfi_rel_offset (R(a2), 20) + +/* Copy the arguments to registers. */ + movel MEM_DISP(sp,28),R(res_ptr) + movel MEM_DISP(sp,32),R(s_ptr) + movel MEM_DISP(sp,36),R(s_size) + movel MEM_DISP(sp,40),R(cnt) + + moveql #1,R(d5) + cmpl R(d5),R(cnt) + bne L(Lnormal) + cmpl R(res_ptr),R(s_ptr) + bls L(Lspecial) /* jump if res_ptr >= s_ptr */ +#if (defined (__mc68020__) || defined (__NeXT__) || defined(mc68020)) + lea MEM_INDX1(res_ptr,s_size,l,4),R(a2) +#else /* not mc68020 */ + movel R(s_size),R(d0) + asll #2,R(d0) + lea MEM_INDX(res_ptr,d0,l),R(a2) +#endif + cmpl R(s_ptr),R(a2) + bls L(Lspecial) /* jump if s_ptr >= res_ptr + s_size */ + +L(Lnormal:) + moveql #32,R(d5) + subl R(cnt),R(d5) + movel MEM_POSTINC(s_ptr),R(d2) + movel R(d2),R(d0) + lsll R(d5),R(d0) /* compute carry limb */ + + lsrl R(cnt),R(d2) + movel R(d2),R(d1) + subql #1,R(s_size) + beq L(Lend) + lsrl #1,R(s_size) + bcs L(L1) + subql #1,R(s_size) + +L(Loop:) + movel MEM_POSTINC(s_ptr),R(d2) + movel R(d2),R(d3) + lsll R(d5),R(d3) + orl R(d3),R(d1) + movel R(d1),MEM_POSTINC(res_ptr) + lsrl R(cnt),R(d2) +L(L1:) + movel MEM_POSTINC(s_ptr),R(d1) + movel R(d1),R(d3) + lsll R(d5),R(d3) + orl R(d3),R(d2) + movel R(d2),MEM_POSTINC(res_ptr) + lsrl R(cnt),R(d1) + + dbf R(s_size),L(Loop) + subl #0x10000,R(s_size) + bcc L(Loop) + +L(Lend:) + movel R(d1),MEM(res_ptr) /* store most significant limb */ + +/* Restore used registers from stack frame. */ + moveml MEM_POSTINC(sp),R(d2)-R(d6)/R(a2) + cfi_remember_state + cfi_adjust_cfa_offset (-6*4) + cfi_restore (R(d2)) + cfi_restore (R(d3)) + cfi_restore (R(d4)) + cfi_restore (R(d5)) + cfi_restore (R(d6)) + cfi_restore (R(a2)) + rts + +/* We loop from most significant end of the arrays, which is only + permissible if the source and destination don't overlap, since the + function is documented to work for overlapping source and destination. */ + + cfi_restore_state +L(Lspecial:) +#if (defined (__mc68020__) || defined (__NeXT__) || defined(mc68020)) + lea MEM_INDX1(s_ptr,s_size,l,4),R(s_ptr) + lea MEM_INDX1(res_ptr,s_size,l,4),R(res_ptr) +#else /* not mc68000 */ + movel R(s_size),R(d0) + asll #2,R(d0) + addl R(s_size),R(s_ptr) + addl R(s_size),R(res_ptr) +#endif + + clrl R(d0) /* initialize carry */ + eorw #1,R(s_size) + lsrl #1,R(s_size) + bcc L(LL1) + subql #1,R(s_size) + +L(LLoop:) + movel MEM_PREDEC(s_ptr),R(d2) + roxrl #1,R(d2) + movel R(d2),MEM_PREDEC(res_ptr) +L(LL1:) + movel MEM_PREDEC(s_ptr),R(d2) + roxrl #1,R(d2) + movel R(d2),MEM_PREDEC(res_ptr) + + dbf R(s_size),L(LLoop) + roxrl #1,R(d0) /* save cy in msb */ + subl #0x10000,R(s_size) + bcs L(LLend) + addl R(d0),R(d0) /* restore cy */ + bra L(LLoop) + +L(LLend:) +/* Restore used registers from stack frame. */ + moveml MEM_POSTINC(sp),R(d2)-R(d6)/R(a2) + cfi_adjust_cfa_offset (-6*4) + cfi_restore (R(d2)) + cfi_restore (R(d3)) + cfi_restore (R(d4)) + cfi_restore (R(d5)) + cfi_restore (R(d6)) + cfi_restore (R(a2)) + rts +END(__mpn_rshift) diff --git a/ports/sysdeps/m68k/m680x0/strtold_l.c b/ports/sysdeps/m68k/m680x0/strtold_l.c new file mode 100644 index 0000000000..481d9924c2 --- /dev/null +++ b/ports/sysdeps/m68k/m680x0/strtold_l.c @@ -0,0 +1,2 @@ +#define DENORM_EXP (MIN_EXP - 1) +#include <sysdeps/ieee754/ldbl-96/strtold_l.c> diff --git a/ports/sysdeps/m68k/m680x0/sub_n.S b/ports/sysdeps/m68k/m680x0/sub_n.S new file mode 100644 index 0000000000..69554a3e84 --- /dev/null +++ b/ports/sysdeps/m68k/m680x0/sub_n.S @@ -0,0 +1,82 @@ +/* mc68020 __mpn_sub_n -- Subtract two limb vectors of the same length > 0 and + store difference in a third limb vector. + +Copyright (C) 1992, 1994, 1996, 1998, 2012 Free Software Foundation, Inc. + +This file is part of the GNU MP Library. + +The GNU MP 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 MP 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 MP Library. If not, see <http://www.gnu.org/licenses/>. */ + +/* + INPUT PARAMETERS + res_ptr (sp + 4) + s1_ptr (sp + 8) + s2_ptr (sp + 16) + size (sp + 12) +*/ + +#include "sysdep.h" +#include "asm-syntax.h" + + TEXT +ENTRY(__mpn_sub_n) +/* Save used registers on the stack. */ + movel R(d2),MEM_PREDEC(sp) + cfi_adjust_cfa_offset (4) + movel R(a2),MEM_PREDEC(sp) + cfi_adjust_cfa_offset (4) + cfi_rel_offset (R(d2), 4) + cfi_rel_offset (R(a2), 0) + +/* Copy the arguments to registers. Better use movem? */ + movel MEM_DISP(sp,12),R(a2) + movel MEM_DISP(sp,16),R(a0) + movel MEM_DISP(sp,20),R(a1) + movel MEM_DISP(sp,24),R(d2) + + eorw #1,R(d2) + lsrl #1,R(d2) + bcc L(L1) + subql #1,R(d2) /* clears cy as side effect */ + +L(Loop:) + movel MEM_POSTINC(a0),R(d0) + movel MEM_POSTINC(a1),R(d1) + subxl R(d1),R(d0) + movel R(d0),MEM_POSTINC(a2) +L(L1:) movel MEM_POSTINC(a0),R(d0) + movel MEM_POSTINC(a1),R(d1) + subxl R(d1),R(d0) + movel R(d0),MEM_POSTINC(a2) + + dbf R(d2),L(Loop) /* loop until 16 lsb of %4 == -1 */ + subxl R(d0),R(d0) /* d0 <= -cy; save cy as 0 or -1 in d0 */ + subl #0x10000,R(d2) + bcs L(L2) + addl R(d0),R(d0) /* restore cy */ + bra L(Loop) + +L(L2:) + negl R(d0) + +/* Restore used registers from stack frame. */ + movel MEM_POSTINC(sp),R(a2) + cfi_adjust_cfa_offset (-4) + cfi_restore (R(a2)) + movel MEM_POSTINC(sp),R(d2) + cfi_adjust_cfa_offset (-4) + cfi_restore (R(d2)) + + rts +END(__mpn_sub_n) diff --git a/ports/sysdeps/m68k/m680x0/sysdep.h b/ports/sysdeps/m68k/m680x0/sysdep.h new file mode 100644 index 0000000000..b382264b64 --- /dev/null +++ b/ports/sysdeps/m68k/m680x0/sysdep.h @@ -0,0 +1,39 @@ +/* Assembler macros for m680x0. + Copyright (C) 2010, 2012 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, see + <http://www.gnu.org/licenses/>. */ + +#include <sysdeps/m68k/sysdep.h> + +#ifdef __ASSEMBLER__ + +/* Perform operation OP with PC-relative SRC as the first operand and + DST as the second. TMP is available as a temporary if needed. */ +# define PCREL_OP(OP, SRC, DST, TMP) \ + OP SRC(%pc), DST + +/* Load the address of the GOT into register R. */ +# define LOAD_GOT(R) \ + lea _GLOBAL_OFFSET_TABLE_@GOTPC (%pc), R + +#else + +/* As above, but PC is the spelling of the PC register. We need this + so that the macro can be used in both normal and extended asms. */ +#define PCREL_OP(OP, SRC, DST, TMP, PC) \ + OP " " SRC "(" PC "), " DST + +#endif /* __ASSEMBLER__ */ diff --git a/ports/sysdeps/m68k/memchr.S b/ports/sysdeps/m68k/memchr.S new file mode 100644 index 0000000000..9e7aff816d --- /dev/null +++ b/ports/sysdeps/m68k/memchr.S @@ -0,0 +1,310 @@ +/* memchr (str, ch, n) -- Return pointer to first occurrence of CH in the + first N bytes of STR. + For Motorola 68000. + Copyright (C) 1999, 2000, 2003, 2012 Free Software Foundation, Inc. + This file is part of the GNU C Library. + Contributed by Andreas Schwab <schwab@gnu.org>. + + 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, see + <http://www.gnu.org/licenses/>. */ + +#include <sysdep.h> +#include "asm-syntax.h" + + TEXT +ENTRY(__memchr) + /* Save the callee-saved registers we use. */ +#ifdef __mcoldfire__ + movel R(d2),MEM_PREDEC(sp) + cfi_adjust_cfa_offset (4) + movel R(d3),MEM_PREDEC(sp) + cfi_adjust_cfa_offset (4) + movel R(d4),MEM_PREDEC(sp) + cfi_adjust_cfa_offset (4) + cfi_rel_offset (R(d2), 8) + cfi_rel_offset (R(d3), 4) + cfi_rel_offset (R(d4), 0) +#else + moveml R(d2)-R(d4),MEM_PREDEC(sp) + cfi_adjust_cfa_offset (3*4) + cfi_rel_offset (R(d2), 0) + cfi_rel_offset (R(d3), 4) + cfi_rel_offset (R(d4), 8) +#endif + + /* Get string pointer, character and length. */ + movel MEM_DISP(sp,16),R(a0) + moveb MEM_DISP(sp,23),R(d0) + movel MEM_DISP(sp,24),R(d4) + + /* Check if at least four bytes left to search. */ +#ifdef __mcoldfire__ + subql #4,R(d4) + bcs L(L6) + addql #4,R(d4) +#else + moveql #4,R(d1) + cmpl R(d1),R(d4) + bcs L(L6) +#endif + + /* Distribute the character to all bytes of a longword. */ + movel R(d0),R(d1) + lsll #8,R(d1) + moveb R(d0),R(d1) + movel R(d1),R(d0) + swap R(d0) + movew R(d1),R(d0) + + /* First search for the character one byte at a time until the + pointer is aligned to a longword boundary. */ + movel R(a0),R(d1) +#ifdef __mcoldfire__ + andl #3,R(d1) +#else + andw #3,R(d1) +#endif + beq L(L1) + cmpb MEM(a0),R(d0) + beq L(L9) + addql #1,R(a0) + subql #1,R(d4) + beq L(L7) + +#ifdef __mcoldfire__ + subql #3,R(d1) +#else + subqw #3,R(d1) +#endif + beq L(L1) + cmpb MEM(a0),R(d0) + beq L(L9) + addql #1,R(a0) + subql #1,R(d4) + beq L(L7) + +#ifdef __mcoldfire__ + addql #1,R(d1) +#else + addqw #1,R(d1) +#endif + beq L(L1) + cmpb MEM(a0),R(d0) + beq L(L9) + addql #1,R(a0) + subql #1,R(d4) + beq L(L7) + +L(L1:) + /* Load the magic bits. Unlike the generic implementation we can + use the carry bit as the fourth hole. */ + movel #0xfefefeff,R(d3) + + /* We exit the loop if adding MAGIC_BITS to LONGWORD fails to + change any of the hole bits of LONGWORD. + + 1) Is this safe? Will it catch all the zero bytes? + Suppose there is a byte with all zeros. Any carry bits + propagating from its left will fall into the hole at its + least significant bit and stop. Since there will be no + carry from its most significant bit, the LSB of the + byte to the left will be unchanged, and the zero will be + detected. + + 2) Is this worthwhile? Will it ignore everything except + zero bytes? Suppose every byte of LONGWORD has a bit set + somewhere. There will be a carry into bit 8. If bit 8 + is set, this will carry into bit 16. If bit 8 is clear, + one of bits 9-15 must be set, so there will be a carry + into bit 16. Similarly, there will be a carry into bit + 24. If one of bits 24-31 is set, there will be a carry + into bit 32 (=carry flag), so all of the hole bits will + be changed. + + 3) But wait! Aren't we looking for C, not zero? + Good point. So what we do is XOR LONGWORD with a longword, + each of whose bytes is C. This turns each byte that is C + into a zero. */ + + /* Still at least 4 bytes to search? */ + subql #4,R(d4) + bcs L(L6) + +L(L2:) + /* Get the longword in question. */ + movel MEM_POSTINC(a0),R(d1) + /* XOR with the byte we search for. */ + eorl R(d0),R(d1) + + /* Add the magic value. We get carry bits reported for each byte + which is not C. */ + movel R(d3),R(d2) + addl R(d1),R(d2) + + /* Check the fourth carry bit before it is clobbered by the next + XOR. If it is not set we have a hit. */ + bcc L(L8) + + /* We are only interested in carry bits that change due to the + previous add, so remove original bits. */ + eorl R(d1),R(d2) + + /* Now test for the other three overflow bits. + Set all non-carry bits. */ + orl R(d3),R(d2) + /* Add 1 to get zero if all carry bits were set. */ + addql #1,R(d2) + + /* If we don't get zero then at least one byte of the word equals + C. */ + bne L(L8) + + /* Still at least 4 bytes to search? */ + subql #4,R(d4) + bcs L(L6) + + /* Get the longword in question. */ + movel MEM_POSTINC(a0),R(d1) + /* XOR with the byte we search for. */ + eorl R(d0),R(d1) + + /* Add the magic value. We get carry bits reported for each byte + which is not C. */ + movel R(d3),R(d2) + addl R(d1),R(d2) + + /* Check the fourth carry bit before it is clobbered by the next + XOR. If it is not set we have a hit. */ + bcc L(L8) + + /* We are only interested in carry bits that change due to the + previous add, so remove original bits */ + eorl R(d1),R(d2) + + /* Now test for the other three overflow bits. + Set all non-carry bits. */ + orl R(d3),R(d2) + /* Add 1 to get zero if all carry bits were set. */ + addql #1,R(d2) + + /* If we don't get zero then at least one byte of the word equals + C. */ + bne L(L8) + + /* Still at least 4 bytes to search? */ + subql #4,R(d4) + bcc L(L2) + +L(L6:) + /* Search one byte at a time in the remaining less than 4 bytes. */ +#ifdef __mcoldfire__ + addql #4,R(d4) +#else + andw #3,R(d4) +#endif + beq L(L7) + cmpb MEM(a0),R(d0) + beq L(L9) + addql #1,R(a0) + +#ifdef __mcoldfire__ + subql #1,R(d4) +#else + subqw #1,R(d4) +#endif + beq L(L7) + cmpb MEM(a0),R(d0) + beq L(L9) + addql #1,R(a0) + +#ifdef __mcoldfire__ + subql #1,R(d4) +#else + subqw #1,R(d4) +#endif + beq L(L7) + cmpb MEM(a0),R(d0) + beq L(L9) + +L(L7:) + /* Return NULL. */ + clrl R(d0) + movel R(d0),R(a0) +#ifdef __mcoldfire__ + movel MEM_POSTINC(sp),R(d4) + cfi_remember_state + cfi_adjust_cfa_offset (-4) + cfi_restore (R(d4)) + movel MEM_POSTINC(sp),R(d3) + cfi_adjust_cfa_offset (-4) + cfi_restore (R(d3)) + movel MEM_POSTINC(sp),R(d2) + cfi_adjust_cfa_offset (-4) + cfi_restore (R(d2)) +#else + moveml MEM_POSTINC(sp),R(d2)-R(d4) + cfi_remember_state + cfi_adjust_cfa_offset (-3*4) + cfi_restore (R(d2)) + cfi_restore (R(d3)) + cfi_restore (R(d4)) +#endif + rts + + cfi_restore_state +L(L8:) + /* We have a hit. Check to see which byte it was. First + compensate for the autoincrement in the loop. */ + subql #4,R(a0) + + cmpb MEM(a0),R(d0) + beq L(L9) + addql #1,R(a0) + + cmpb MEM(a0),R(d0) + beq L(L9) + addql #1,R(a0) + + cmpb MEM(a0),R(d0) + beq L(L9) + addql #1,R(a0) + + /* Otherwise the fourth byte must equal C. */ +L(L9:) + movel R(a0),R(d0) +#ifdef __mcoldfire__ + movel MEM_POSTINC(sp),R(d4) + cfi_adjust_cfa_offset (-4) + cfi_restore (R(d4)) + movel MEM_POSTINC(sp),R(d3) + cfi_adjust_cfa_offset (-4) + cfi_restore (R(d3)) + movel MEM_POSTINC(sp),R(d2) + cfi_adjust_cfa_offset (-4) + cfi_restore (R(d2)) +#else + moveml MEM_POSTINC(sp),R(d2)-R(d4) + cfi_adjust_cfa_offset (-3*4) + cfi_restore (R(d2)) + cfi_restore (R(d3)) + cfi_restore (R(d4)) +#endif + rts +END(__memchr) + +weak_alias (__memchr, memchr) +#if !__BOUNDED_POINTERS__ +weak_alias (__memchr, __ubp_memchr) +#endif +libc_hidden_builtin_def (memchr) diff --git a/ports/sysdeps/m68k/memcopy.h b/ports/sysdeps/m68k/memcopy.h new file mode 100644 index 0000000000..7d2604709d --- /dev/null +++ b/ports/sysdeps/m68k/memcopy.h @@ -0,0 +1,99 @@ +/* memcopy.h -- definitions for memory copy functions. Motorola 68020 version. + Copyright (C) 1991, 1997, 2004 Free Software Foundation, Inc. + This file is part of the GNU C Library. + Contributed by Torbjorn Granlund (tege@sics.se). + + 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, see + <http://www.gnu.org/licenses/>. */ + +#include <sysdeps/generic/memcopy.h> + +#if defined(__mc68020__) || defined(mc68020) + +#undef OP_T_THRES +#define OP_T_THRES 16 + +/* WORD_COPY_FWD and WORD_COPY_BWD are not symmetric on the 68020, + because of its weird instruction overlap characteristics. */ + +#undef WORD_COPY_FWD +#define WORD_COPY_FWD(dst_bp, src_bp, nbytes_left, nbytes) \ + do \ + { \ + size_t __nwords = (nbytes) / sizeof (op_t); \ + size_t __nblocks = __nwords / 8 + 1; \ + dst_bp -= (8 - __nwords % 8) * sizeof (op_t); \ + src_bp -= (8 - __nwords % 8) * sizeof (op_t); \ + switch (__nwords % 8) \ + do \ + { \ + ((op_t *) dst_bp)[0] = ((op_t *) src_bp)[0]; \ + case 7: \ + ((op_t *) dst_bp)[1] = ((op_t *) src_bp)[1]; \ + case 6: \ + ((op_t *) dst_bp)[2] = ((op_t *) src_bp)[2]; \ + case 5: \ + ((op_t *) dst_bp)[3] = ((op_t *) src_bp)[3]; \ + case 4: \ + ((op_t *) dst_bp)[4] = ((op_t *) src_bp)[4]; \ + case 3: \ + ((op_t *) dst_bp)[5] = ((op_t *) src_bp)[5]; \ + case 2: \ + ((op_t *) dst_bp)[6] = ((op_t *) src_bp)[6]; \ + case 1: \ + ((op_t *) dst_bp)[7] = ((op_t *) src_bp)[7]; \ + case 0: \ + src_bp += 32; \ + dst_bp += 32; \ + __nblocks--; \ + } \ + while (__nblocks != 0); \ + (nbytes_left) = (nbytes) % sizeof (op_t); \ + } while (0) + +#undef WORD_COPY_BWD +#define WORD_COPY_BWD(dst_ep, src_ep, nbytes_left, nbytes) \ + do \ + { \ + size_t __nblocks = (nbytes) / 32 + 1; \ + op_t *__dst_ep = (op_t *) (dst_ep); \ + op_t *__src_ep = (op_t *) (src_ep); \ + switch ((nbytes) / sizeof (op_t) % 8) \ + do \ + { \ + *--__dst_ep = *--__src_ep; \ + case 7: \ + *--__dst_ep = *--__src_ep; \ + case 6: \ + *--__dst_ep = *--__src_ep; \ + case 5: \ + *--__dst_ep = *--__src_ep; \ + case 4: \ + *--__dst_ep = *--__src_ep; \ + case 3: \ + *--__dst_ep = *--__src_ep; \ + case 2: \ + *--__dst_ep = *--__src_ep; \ + case 1: \ + *--__dst_ep = *--__src_ep; \ + case 0: \ + __nblocks--; \ + } \ + while (__nblocks != 0); \ + (nbytes_left) = (nbytes) % sizeof (op_t); \ + (dst_ep) = (unsigned long) __dst_ep; \ + (src_ep) = (unsigned long) __src_ep; \ + } while (0) + +#endif diff --git a/ports/sysdeps/m68k/memusage.h b/ports/sysdeps/m68k/memusage.h new file mode 100644 index 0000000000..0d00b6e2f1 --- /dev/null +++ b/ports/sysdeps/m68k/memusage.h @@ -0,0 +1,21 @@ +/* Copyright (C) 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, see + <http://www.gnu.org/licenses/>. */ + + +#define GETSP() ({ register uintptr_t stack_ptr asm ("%sp"); stack_ptr; }) + +#include <sysdeps/generic/memusage.h> diff --git a/ports/sysdeps/m68k/nptl/Makefile b/ports/sysdeps/m68k/nptl/Makefile new file mode 100644 index 0000000000..1a476794c2 --- /dev/null +++ b/ports/sysdeps/m68k/nptl/Makefile @@ -0,0 +1,21 @@ +# Copyright (C) 2010 Free Software Foundation, Inc. +# This file is part of the GNU C Library. +# Contributed by Maxim Kuvyrkov <maxim@codesourcery.com>, 2010. +# +# 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, see +# <http://www.gnu.org/licenses/>. + +ifeq ($(subdir),csu) +gen-as-const-headers += tcb-offsets.sym +endif diff --git a/ports/sysdeps/m68k/nptl/pthread_spin_lock.c b/ports/sysdeps/m68k/nptl/pthread_spin_lock.c new file mode 100644 index 0000000000..90a8262b24 --- /dev/null +++ b/ports/sysdeps/m68k/nptl/pthread_spin_lock.c @@ -0,0 +1,30 @@ +/* Copyright (C) 2010 Free Software Foundation, Inc. + This file is part of the GNU C Library. + Contributed by Maxim Kuvyrkov <maxim@codesourcery.com>, 2010. + + 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, see + <http://www.gnu.org/licenses/>. */ + +#include <atomic.h> +#include "pthreadP.h" + +int +pthread_spin_lock (pthread_spinlock_t *lock) +{ + while (atomic_compare_and_exchange_val_acq(lock, 1, 0) != 0) + while (*lock != 0) + ; + + return 0; +} diff --git a/ports/sysdeps/m68k/nptl/pthread_spin_trylock.c b/ports/sysdeps/m68k/nptl/pthread_spin_trylock.c new file mode 100644 index 0000000000..f4b0c0d0a3 --- /dev/null +++ b/ports/sysdeps/m68k/nptl/pthread_spin_trylock.c @@ -0,0 +1,27 @@ +/* Copyright (C) 2010 Free Software Foundation, Inc. + This file is part of the GNU C Library. + Contributed by Maxim Kuvyrkov <maxim@codesourcery.com>, 2010. + + 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, see + <http://www.gnu.org/licenses/>. */ + +#include <errno.h> +#include <atomic.h> +#include "pthreadP.h" + +int +pthread_spin_trylock (pthread_spinlock_t *lock) +{ + return atomic_compare_and_exchange_val_acq(lock, 1, 0) ? EBUSY : 0; +} diff --git a/ports/sysdeps/m68k/nptl/pthreaddef.h b/ports/sysdeps/m68k/nptl/pthreaddef.h new file mode 100644 index 0000000000..dfbc7573a7 --- /dev/null +++ b/ports/sysdeps/m68k/nptl/pthreaddef.h @@ -0,0 +1,38 @@ +/* Copyright (C) 2010 Free Software Foundation, Inc. + This file is part of the GNU C Library. + Contributed by Maxim Kuvyrkov <maxim@codesourcery.com>, 2010. + + 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, see + <http://www.gnu.org/licenses/>. */ + +/* Default stack size. */ +#define ARCH_STACK_DEFAULT_SIZE (2 * 1024 * 1024) + +/* Required stack pointer alignment at beginning. */ +#define STACK_ALIGN 16 + +/* Minimal stack size after allocating thread descriptor and guard size. */ +#define MINIMAL_REST_STACK 2048 + +/* Alignment requirement for TCB. */ +#define TCB_ALIGNMENT 16 + + +/* Location of current stack frame. */ +#define CURRENT_STACK_FRAME __builtin_frame_address (0) + + +/* XXX Until we have a better place keep the definitions here. */ +#define __exit_thread_inline(val) \ + INLINE_SYSCALL (exit, 1, (val)) diff --git a/ports/sysdeps/m68k/nptl/tcb-offsets.sym b/ports/sysdeps/m68k/nptl/tcb-offsets.sym new file mode 100644 index 0000000000..b1bba65868 --- /dev/null +++ b/ports/sysdeps/m68k/nptl/tcb-offsets.sym @@ -0,0 +1,11 @@ +#include <sysdep.h> +#include <tls.h> + +-- + +-- Derive offsets relative to the thread register. +#define thread_offsetof(mem) (long)(offsetof(struct pthread, mem) - TLS_TCB_OFFSET - TLS_PRE_TCB_SIZE) + +MULTIPLE_THREADS_OFFSET thread_offsetof (header.multiple_threads) +PID_OFFSET thread_offsetof (pid) +TID_OFFSET thread_offsetof (tid) diff --git a/ports/sysdeps/m68k/nptl/tls.h b/ports/sysdeps/m68k/nptl/tls.h new file mode 100644 index 0000000000..8b0909237b --- /dev/null +++ b/ports/sysdeps/m68k/nptl/tls.h @@ -0,0 +1,167 @@ +/* Definition for thread-local data handling. NPTL/m68k version. + Copyright (C) 2010 Free Software Foundation, Inc. + This file is part of the GNU C Library. + Contributed by Maxim Kuvyrkov <maxim@codesourcery.com>, 2010. + + 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, see + <http://www.gnu.org/licenses/>. */ + +#ifndef _TLS_H +#define _TLS_H 1 + +#include <dl-sysdep.h> + +#ifndef __ASSEMBLER__ +# include <stdbool.h> +# include <stddef.h> +# include <stdint.h> + +/* Type for the dtv. */ +typedef union dtv +{ + size_t counter; + struct + { + void *val; + bool is_static; + } pointer; +} dtv_t; + +#else /* __ASSEMBLER__ */ +# include <tcb-offsets.h> +#endif /* __ASSEMBLER__ */ + +#ifndef __ASSEMBLER__ + +/* Get system call information. */ +# include <sysdep.h> + +/* The TP points to the start of the thread blocks. */ +# define TLS_DTV_AT_TP 1 + +/* Get the thread descriptor definition. */ +# include <nptl/descr.h> + +typedef struct +{ + dtv_t *dtv; + void *private; +} tcbhead_t; + +/* This is the size of the initial TCB. Because our TCB is before the thread + pointer, we don't need this. */ +# define TLS_INIT_TCB_SIZE 0 + +/* Alignment requirements for the initial TCB. */ +# define TLS_INIT_TCB_ALIGN __alignof__ (struct pthread) + +/* This is the size of the TCB. Because our TCB is before the thread + pointer, we don't need this. */ +# define TLS_TCB_SIZE 0 + +/* Alignment requirements for the TCB. */ +# define TLS_TCB_ALIGN __alignof__ (struct pthread) + +/* This is the size we need before TCB - actually, it includes the TCB. */ +# define TLS_PRE_TCB_SIZE \ + (sizeof (struct pthread) \ + + ((sizeof (tcbhead_t) + TLS_TCB_ALIGN - 1) & ~(TLS_TCB_ALIGN - 1))) + +/* The thread pointer (TP) points to the end of the + TCB + 0x7000, as for PowerPC and MIPS. This implies that TCB address is + TP - 0x7000. As we define TLS_DTV_AT_TP we can + assume that the pthread struct is allocated immediately ahead of the + TCB. This implies that the pthread_descr address is + TP - (TLS_PRE_TCB_SIZE + 0x7000). */ +# define TLS_TCB_OFFSET 0x7000 + +/* Install the dtv pointer. The pointer passed is to the element with + index -1 which contain the length. */ +# define INSTALL_DTV(tcbp, dtvp) \ + ((tcbhead_t *) (tcbp))[-1].dtv = dtvp + 1 + +/* Install new dtv for current thread. */ +# define INSTALL_NEW_DTV(dtv) \ + (THREAD_DTV () = (dtv)) + +/* Return dtv of given thread descriptor. */ +# define GET_DTV(tcbp) \ + (((tcbhead_t *) (tcbp))[-1].dtv) + +/* Code to initially initialize the thread pointer. This might need + special attention since 'errno' is not yet available and if the + operation can cause a failure 'errno' must not be touched. */ +# define TLS_INIT_TP(tcbp, secondcall) \ + ({ \ + INTERNAL_SYSCALL_DECL (err); \ + int _sys_result; \ + \ + _sys_result = INTERNAL_SYSCALL (set_thread_area, err, 1, \ + ((void *) (tcbp)) + TLS_TCB_OFFSET); \ + INTERNAL_SYSCALL_ERROR_P (_sys_result, err) ? "unknown error" : NULL; }) + +extern void * __m68k_read_tp (void); + +/* Return the address of the dtv for the current thread. */ +# define THREAD_DTV() \ + (((tcbhead_t *) (__m68k_read_tp () - TLS_TCB_OFFSET))[-1].dtv) + +/* Return the thread descriptor for the current thread. */ +# define THREAD_SELF \ + ((struct pthread *) (__m68k_read_tp () - TLS_TCB_OFFSET - TLS_PRE_TCB_SIZE)) + +/* Magic for libthread_db to know how to do THREAD_SELF. */ +# define DB_THREAD_SELF \ + CONST_THREAD_AREA (32, TLS_TCB_OFFSET + TLS_PRE_TCB_SIZE) + +/* Access to data in the thread descriptor is easy. */ +# define THREAD_GETMEM(descr, member) \ + descr->member +# define THREAD_GETMEM_NC(descr, member, idx) \ + descr->member[idx] +# define THREAD_SETMEM(descr, member, value) \ + descr->member = (value) +# define THREAD_SETMEM_NC(descr, member, idx, value) \ + descr->member[idx] = (value) + +/* l_tls_offset == 0 is perfectly valid on M68K, so we have to use some + different value to mean unset l_tls_offset. */ +# define NO_TLS_OFFSET -1 + +/* Get and set the global scope generation counter in struct pthread. */ +#define THREAD_GSCOPE_FLAG_UNUSED 0 +#define THREAD_GSCOPE_FLAG_USED 1 +#define THREAD_GSCOPE_FLAG_WAIT 2 +#define THREAD_GSCOPE_RESET_FLAG() \ + do \ + { int __res \ + = atomic_exchange_rel (&THREAD_SELF->header.gscope_flag, \ + THREAD_GSCOPE_FLAG_UNUSED); \ + if (__res == THREAD_GSCOPE_FLAG_WAIT) \ + lll_futex_wake (&THREAD_SELF->header.gscope_flag, 1, LLL_PRIVATE); \ + } \ + while (0) +#define THREAD_GSCOPE_SET_FLAG() \ + do \ + { \ + THREAD_SELF->header.gscope_flag = THREAD_GSCOPE_FLAG_USED; \ + atomic_write_barrier (); \ + } \ + while (0) +#define THREAD_GSCOPE_WAIT() \ + GL(dl_wait_lookup_done) () + +#endif /* __ASSEMBLER__ */ + +#endif /* tls.h */ diff --git a/ports/sysdeps/m68k/preconfigure b/ports/sysdeps/m68k/preconfigure new file mode 100644 index 0000000000..94fc1aabc2 --- /dev/null +++ b/ports/sysdeps/m68k/preconfigure @@ -0,0 +1,17 @@ +# This fragment canonicalizes the machine names for m68k variants. + +case "$machine" in +m680?0) base_machine=m68k machine=m68k/m680x0/$machine ;; +m68k) variant=`(echo "#ifdef __mcoldfire__" + echo "coldfire" + echo "#else" + echo "m680x0/m68020" + echo "#endif") | + $CC $CFLAGS $CPPFLAGS -E - | + grep '^[a-z]'` + if test -z "$variant"; then + echo >&2 "Cannot determine m68k processor variant" + exit 1 + fi + base_machine=m68k machine=m68k/$variant ;; +esac diff --git a/ports/sysdeps/m68k/rawmemchr.S b/ports/sysdeps/m68k/rawmemchr.S new file mode 100644 index 0000000000..ebf1c4b298 --- /dev/null +++ b/ports/sysdeps/m68k/rawmemchr.S @@ -0,0 +1,197 @@ +/* rawmemchr (str, ch) -- Return pointer to first occurrence of CH in STR. + For Motorola 68000. + Copyright (C) 1999, 2002, 2012 Free Software Foundation, Inc. + This file is part of the GNU C Library. + Contributed by Andreas Schwab <schwab@gnu.org>. + + 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, see + <http://www.gnu.org/licenses/>. */ + +#include <sysdep.h> +#include "asm-syntax.h" + + TEXT +ENTRY(__rawmemchr) + /* Save the callee-saved registers we use. */ + movel R(d2),MEM_PREDEC(sp) + cfi_adjust_cfa_offset (4) + movel R(d3),MEM_PREDEC(sp) + cfi_adjust_cfa_offset (4) + cfi_rel_offset (R(d2), 4) + cfi_rel_offset (R(d3), 0) + + /* Get string pointer and character. */ + movel MEM_DISP(sp,12),R(a0) + moveb MEM_DISP(sp,19),R(d0) + + /* Distribute the character to all bytes of a longword. */ + movel R(d0),R(d1) + lsll #8,R(d1) + moveb R(d0),R(d1) + movel R(d1),R(d0) + swap R(d0) + movew R(d1),R(d0) + + /* First search for the character one byte at a time until the + pointer is aligned to a longword boundary. */ + movel R(a0),R(d1) +#ifdef __mcoldfire__ + andl #3,R(d1) +#else + andw #3,R(d1) +#endif + beq L(L1) + cmpb MEM(a0),R(d0) + beq L(L9) + addql #1,R(a0) + +#ifdef __mcoldfire__ + subql #3,R(d1) +#else + subqw #3,R(d1) +#endif + beq L(L1) + cmpb MEM(a0),R(d0) + beq L(L9) + addql #1,R(a0) + +#ifdef __mcoldfire__ + addql #1,R(d1) +#else + addqw #1,R(d1) +#endif + beq L(L1) + cmpb MEM(a0),R(d0) + beq L(L9) + addql #1,R(a0) + +L(L1:) + /* Load the magic bits. Unlike the generic implementation we can + use the carry bit as the fourth hole. */ + movel #0xfefefeff,R(d3) + + /* We exit the loop if adding MAGIC_BITS to LONGWORD fails to + change any of the hole bits of LONGWORD. + + 1) Is this safe? Will it catch all the zero bytes? + Suppose there is a byte with all zeros. Any carry bits + propagating from its left will fall into the hole at its + least significant bit and stop. Since there will be no + carry from its most significant bit, the LSB of the + byte to the left will be unchanged, and the zero will be + detected. + + 2) Is this worthwhile? Will it ignore everything except + zero bytes? Suppose every byte of LONGWORD has a bit set + somewhere. There will be a carry into bit 8. If bit 8 + is set, this will carry into bit 16. If bit 8 is clear, + one of bits 9-15 must be set, so there will be a carry + into bit 16. Similarly, there will be a carry into bit + 24. If one of bits 24-31 is set, there will be a carry + into bit 32 (=carry flag), so all of the hole bits will + be changed. + + 3) But wait! Aren't we looking for C, not zero? + Good point. So what we do is XOR LONGWORD with a longword, + each of whose bytes is C. This turns each byte that is C + into a zero. */ + +L(L2:) + /* Get the longword in question. */ + movel MEM_POSTINC(a0),R(d1) + /* XOR with the byte we search for. */ + eorl R(d0),R(d1) + + /* Add the magic value. We get carry bits reported for each byte + which is not C. */ + movel R(d3),R(d2) + addl R(d1),R(d2) + + /* Check the fourth carry bit before it is clobbered by the next + XOR. If it is not set we have a hit. */ + bcc L(L8) + + /* We are only interested in carry bits that change due to the + previous add, so remove original bits. */ + eorl R(d1),R(d2) + + /* Now test for the other three overflow bits. + Set all non-carry bits. */ + orl R(d3),R(d2) + /* Add 1 to get zero if all carry bits were set. */ + addql #1,R(d2) + + /* If we don't get zero then at least one byte of the word equals + C. */ + bne L(L8) + + /* Get the longword in question. */ + movel MEM_POSTINC(a0),R(d1) + /* XOR with the byte we search for. */ + eorl R(d0),R(d1) + + /* Add the magic value. We get carry bits reported for each byte + which is not C. */ + movel R(d3),R(d2) + addl R(d1),R(d2) + + /* Check the fourth carry bit before it is clobbered by the next + XOR. If it is not set we have a hit. */ + bcc L(L8) + + /* We are only interested in carry bits that change due to the + previous add, so remove original bits */ + eorl R(d1),R(d2) + + /* Now test for the other three overflow bits. + Set all non-carry bits. */ + orl R(d3),R(d2) + /* Add 1 to get zero if all carry bits were set. */ + addql #1,R(d2) + + /* If we don't get zero then at least one byte of the word equals + C. */ + beq L(L2) + +L(L8:) + /* We have a hit. Check to see which byte it was. First + compensate for the autoincrement in the loop. */ + subql #4,R(a0) + + cmpb MEM(a0),R(d0) + beq L(L9) + addql #1,R(a0) + + cmpb MEM(a0),R(d0) + beq L(L9) + addql #1,R(a0) + + cmpb MEM(a0),R(d0) + beq L(L9) + addql #1,R(a0) + + /* Otherwise the fourth byte must equal C. */ +L(L9:) + movel R(a0),R(d0) + movel MEM_POSTINC(sp),R(d3) + cfi_adjust_cfa_offset (-4) + cfi_restore (R(d3)) + movel MEM_POSTINC(sp),R(d2) + cfi_adjust_cfa_offset (-4) + cfi_restore (R(d2)) + rts +END(__rawmemchr) + +libc_hidden_def (__rawmemchr) +weak_alias (__rawmemchr, rawmemchr) diff --git a/ports/sysdeps/m68k/setjmp.c b/ports/sysdeps/m68k/setjmp.c new file mode 100644 index 0000000000..33f21b9bed --- /dev/null +++ b/ports/sysdeps/m68k/setjmp.c @@ -0,0 +1,70 @@ +/* Copyright (C) 1991, 1992, 1994, 1997, 2001, 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, see + <http://www.gnu.org/licenses/>. */ + +#include <setjmp.h> + +/* Save the current program position in ENV and return 0. */ +int +#if defined BSD_SETJMP +# undef setjmp +# define savemask 1 +setjmp (jmp_buf env) +#elif defined BSD__SETJMP +# undef _setjmp +# define savemask 0 +_setjmp (jmp_buf env) +#else +__sigsetjmp (jmp_buf env, int savemask) +#endif +{ + /* Save data registers D1 through D7. */ + asm volatile ("movem%.l %/d1-%/d7, %0" + : : "m" (env[0].__jmpbuf[0].__dregs[0])); + + /* Save return address in place of register A0. */ + env[0].__jmpbuf[0].__aregs[0] = __builtin_return_address (0); + + /* Save address registers A1 through A5. */ + asm volatile ("movem%.l %/a1-%/a5, %0" + : : "m" (env[0].__jmpbuf[0].__aregs[1])); + + /* Save caller's FP, not our own. */ + env[0].__jmpbuf[0].__fp = *(int **) __builtin_frame_address (0); + + /* Save caller's SP, not our own. */ + env[0].__jmpbuf[0].__sp = (int *) __builtin_frame_address (0) + 2; + +#if defined __HAVE_68881__ || defined __HAVE_FPU__ + /* Save floating-point (68881) registers FP0 through FP7. */ + asm volatile ("fmovem%.x %/fp0-%/fp7, %0" + : : "m" (env[0].__jmpbuf[0].__fpregs[0])); +#elif defined (__mcffpu__) + asm volatile ("fmovem %/fp0-%/fp7, %0" + : : "m" (env[0].__jmpbuf[0].__fpregs[0])); +#endif + +#if defined NOT_IN_libc && defined IS_IN_rtld + /* In ld.so we never save the signal mask. */ + return 0; +#else + /* Save the signal mask if requested. */ + return __sigjmp_save (env, savemask); +#endif +} +#if !defined BSD_SETJMP && !defined BSD__SETJMP +libc_hidden_def (__sigsetjmp) +#endif diff --git a/ports/sysdeps/m68k/shlib-versions b/ports/sysdeps/m68k/shlib-versions new file mode 100644 index 0000000000..b65b00b212 --- /dev/null +++ b/ports/sysdeps/m68k/shlib-versions @@ -0,0 +1 @@ +m68k-.*-linux.* libgcc_s=2 diff --git a/ports/sysdeps/m68k/stackinfo.h b/ports/sysdeps/m68k/stackinfo.h new file mode 100644 index 0000000000..657b8a1f35 --- /dev/null +++ b/ports/sysdeps/m68k/stackinfo.h @@ -0,0 +1,41 @@ +/* Copyright (C) 1999, 2010, 2011 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, see + <http://www.gnu.org/licenses/>. */ + +/* This file contains a bit of information about the stack allocation + of the processor. */ + +#ifndef _STACKINFO_H +#define _STACKINFO_H 1 + +#include <elf.h> + +/* On m68k the stack grows down. */ +#define _STACK_GROWS_DOWN 1 + +/* Default to an executable stack. PF_X can be overridden if PT_GNU_STACK + is present, but it is presumed absent. */ +#define DEFAULT_STACK_PERMS (PF_R|PF_W|PF_X) + +/* Access to the stack pointer. */ +#define stackinfo_get_sp() \ + ({ void *p__; asm volatile ("move.l %%sp, %0" : "=r" (p__)); p__; }) +#define stackinfo_sub_sp(ptr) \ + ({ ptrdiff_t d__; \ + asm volatile ("sub.l %%sp, %0" : "=r" (d__) : "0" (ptr)); \ + d__; }) + +#endif /* stackinfo.h */ diff --git a/ports/sysdeps/m68k/start.S b/ports/sysdeps/m68k/start.S new file mode 100644 index 0000000000..7c3e99aa7c --- /dev/null +++ b/ports/sysdeps/m68k/start.S @@ -0,0 +1,99 @@ +/* Startup code compliant to the ELF m68k ABI. + Copyright (C) 1996, 1997, 1998, 2001, 2002 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. + + In addition to the permissions in the GNU Lesser General Public + License, the Free Software Foundation gives you unlimited + permission to link the compiled version of this file with other + programs, and to distribute those programs without any restriction + coming from the use of this file. (The GNU Lesser General Public + License restrictions do apply in other respects; for example, they + cover modification of the file, and distribution when not linked + into another program.) + + Note that people who make modified versions of this file are not + obligated to grant this special exception for their modified + versions; it is their choice whether to do so. The GNU Lesser + General Public License gives permission to release a modified + version without this exception; this exception also makes it + possible to release a modified version which carries forward this + exception. + + 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, see + <http://www.gnu.org/licenses/>. */ + +/* This is the canonical entry point, usually the first thing in the text + segment. The SVR4/m68k ABI says that when the entry point runs, + most registers' values are unspecified, except for: + + %a1 Contains a function pointer to be registered with `atexit'. + This is how the dynamic linker arranges to have DT_FINI + functions called for shared libraries that have been loaded + before this code runs. + + %sp The stack contains the arguments and environment: + 0(%sp) argc + 4(%sp) argv[0] + ... + (4*argc)(%sp) NULL + (4*(argc+1))(%sp) envp[0] + ... + NULL +*/ + + .text + .globl _start + .type _start,@function +_start: + /* Clear the frame pointer. The ABI suggests this be done, to mark + the outermost frame obviously. */ + sub.l %fp, %fp + + /* Extract the arguments as encoded on the stack and set up the + arguments for `main': argc, argv. envp will be determined + later in __libc_start_main. */ + move.l (%sp)+, %d0 /* Pop the argument count. */ + move.l %sp, %a0 /* The argument vector starts just at the + current stack top. */ + + /* Provide the highest stack address to the user code (for stacks + which grow downward). */ + pea (%sp) + + pea (%a1) /* Push address of the shared library + termination function. */ + + /* Push the address of our own entry points to `.fini' and + `.init'. */ + pea __libc_csu_fini + pea __libc_csu_init + + pea (%a0) /* Push second argument: argv. */ + move.l %d0, -(%sp) /* Push first argument: argc. */ + + pea main + + /* Call the user's main function, and exit with its value. But + let the libc call main. */ + jbsr __libc_start_main + + illegal /* Crash if somehow `exit' does return. */ + +/* Define a symbol for the first piece of initialized data. */ + .data + .globl __data_start +__data_start: + .long 0 + .weak data_start + data_start = __data_start diff --git a/ports/sysdeps/m68k/strchr.S b/ports/sysdeps/m68k/strchr.S new file mode 100644 index 0000000000..98e9f24545 --- /dev/null +++ b/ports/sysdeps/m68k/strchr.S @@ -0,0 +1,281 @@ +/* strchr (str, ch) -- Return pointer to first occurrence of CH in STR. + For Motorola 68000. + Copyright (C) 1999, 2003, 2012 Free Software Foundation, Inc. + This file is part of the GNU C Library. + Contributed by Andreas Schwab <schwab@gnu.org>. + + 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, see + <http://www.gnu.org/licenses/>. */ + +#include <sysdep.h> +#include "asm-syntax.h" + + TEXT +ENTRY(strchr) + /* Save the callee-saved registers we use. */ + movel R(d2),MEM_PREDEC(sp) + cfi_adjust_cfa_offset (4) + movel R(d3),MEM_PREDEC(sp) + cfi_adjust_cfa_offset (4) + cfi_rel_offset (R(d2),4) + cfi_rel_offset (R(d3),0) + + /* Get string pointer and character. */ + movel MEM_DISP(sp,12),R(a0) + moveb MEM_DISP(sp,19),R(d0) + + /* Distribute the character to all bytes of a longword. */ + movel R(d0),R(d1) + lsll #8,R(d1) + moveb R(d0),R(d1) + movel R(d1),R(d0) + swap R(d0) + movew R(d1),R(d0) + + /* First search for the character one byte at a time until the + pointer is aligned to a longword boundary. */ + movel R(a0),R(d1) +#ifdef __mcoldfire__ + andl #3,R(d1) +#else + andw #3,R(d1) +#endif + beq L(L1) + moveb MEM(a0),R(d2) + cmpb R(d0),R(d2) + beq L(L9) + tstb R(d2) + beq L(L3) + addql #1,R(a0) + +#ifdef __mcoldfire__ + subql #3,R(d1) +#else + subqw #3,R(d1) +#endif + beq L(L1) + moveb MEM(a0),R(d2) + cmpb R(d0),R(d2) + beq L(L9) + tstb R(d2) + beq L(L3) + addql #1,R(a0) + +#ifdef __mcoldfire__ + addql #1,R(d1) +#else + addqw #1,R(d1) +#endif + beq L(L1) + moveb MEM(a0),R(d2) + cmpb R(d0),R(d2) + beq L(L9) + tstb R(d2) + beq L(L3) + addql #1,R(a0) + +L(L1:) + /* Load the magic bits. Unlike the generic implementation we can + use the carry bit as the fourth hole. */ + movel #0xfefefeff,R(d3) + + /* We exit the loop if adding MAGIC_BITS to LONGWORD fails to + change any of the hole bits of LONGWORD. + + 1) Is this safe? Will it catch all the zero bytes? + Suppose there is a byte with all zeros. Any carry bits + propagating from its left will fall into the hole at its + least significant bit and stop. Since there will be no + carry from its most significant bit, the LSB of the + byte to the left will be unchanged, and the zero will be + detected. + + 2) Is this worthwhile? Will it ignore everything except + zero bytes? Suppose every byte of LONGWORD has a bit set + somewhere. There will be a carry into bit 8. If bit 8 + is set, this will carry into bit 16. If bit 8 is clear, + one of bits 9-15 must be set, so there will be a carry + into bit 16. Similarly, there will be a carry into bit + 24. If one of bits 24-31 is set, there will be a carry + into bit 32 (=carry flag), so all of the hole bits will + be changed. + + 3) But wait! Aren't we looking for C, not zero? + Good point. So what we do is XOR LONGWORD with a longword, + each of whose bytes is C. This turns each byte that is C + into a zero. */ + +L(L2:) + /* Get the longword in question. */ + movel MEM_POSTINC(a0),R(d1) + /* XOR with the byte we search for. */ + eorl R(d0),R(d1) + + /* Add the magic value. We get carry bits reported for each byte + which is not C. */ + movel R(d3),R(d2) + addl R(d1),R(d2) + + /* Check the fourth carry bit before it is clobbered by the next + XOR. If it is not set we have a hit. */ + bcc L(L8) + + /* We are only interested in carry bits that change due to the + previous add, so remove original bits. */ + eorl R(d1),R(d2) + + /* Now test for the other three overflow bits. + Set all non-carry bits. */ + orl R(d3),R(d2) + /* Add 1 to get zero if all carry bits were set. */ + addql #1,R(d2) + + /* If we don't get zero then at least one byte of the word equals + C. */ + bne L(L8) + + /* Next look for a NUL byte. + Restore original longword without reload. */ + eorl R(d0),R(d1) + /* Add the magic value. We get carry bits reported for each byte + which is not NUL. */ + movel R(d3),R(d2) + addl R(d1),R(d2) + + /* Check the fourth carry bit before it is clobbered by the next + XOR. If it is not set we have a hit, and return NULL. */ + bcc L(L3) + + /* We are only interested in carry bits that change due to the + previous add, so remove original bits. */ + eorl R(d1),R(d2) + + /* Now test for the other three overflow bits. + Set all non-carry bits. */ + orl R(d3),R(d2) + /* Add 1 to get zero if all carry bits were set. */ + addql #1,R(d2) + + /* If we don't get zero then at least one byte of the word was NUL + and we return NULL. Otherwise continue with the next longword. */ + bne L(L3) + + /* Get the longword in question. */ + movel MEM_POSTINC(a0),R(d1) + /* XOR with the byte we search for. */ + eorl R(d0),R(d1) + + /* Add the magic value. We get carry bits reported for each byte + which is not C. */ + movel R(d3),R(d2) + addl R(d1),R(d2) + + /* Check the fourth carry bit before it is clobbered by the next + XOR. If it is not set we have a hit. */ + bcc L(L8) + + /* We are only interested in carry bits that change due to the + previous add, so remove original bits */ + eorl R(d1),R(d2) + + /* Now test for the other three overflow bits. + Set all non-carry bits. */ + orl R(d3),R(d2) + /* Add 1 to get zero if all carry bits were set. */ + addql #1,R(d2) + + /* If we don't get zero then at least one byte of the word equals + C. */ + bne L(L8) + + /* Next look for a NUL byte. + Restore original longword without reload. */ + eorl R(d0),R(d1) + /* Add the magic value. We get carry bits reported for each byte + which is not NUL. */ + movel R(d3),R(d2) + addl R(d1),R(d2) + + /* Check the fourth carry bit before it is clobbered by the next + XOR. If it is not set we have a hit, and return NULL. */ + bcc L(L3) + + /* We are only interested in carry bits that change due to the + previous add, so remove original bits */ + eorl R(d1),R(d2) + + /* Now test for the other three overflow bits. + Set all non-carry bits. */ + orl R(d3),R(d2) + /* Add 1 to get zero if all carry bits were set. */ + addql #1,R(d2) + + /* If we don't get zero then at least one byte of the word was NUL + and we return NULL. Otherwise continue with the next longword. */ + beq L(L2) + +L(L3:) + /* Return NULL. */ + clrl R(d0) + movel R(d0),R(a0) + movel MEM_POSTINC(sp),R(d3) + cfi_remember_state + cfi_adjust_cfa_offset (-4) + cfi_restore (R(d3)) + movel MEM_POSTINC(sp),R(d2) + cfi_adjust_cfa_offset (-4) + cfi_restore (R(d2)) + rts + + cfi_restore_state +L(L8:) + /* We have a hit. Check to see which byte it was. First + compensate for the autoincrement in the loop. */ + subql #4,R(a0) + + moveb MEM(a0),R(d1) + cmpb R(d0),R(d1) + beq L(L9) + tstb R(d1) + beq L(L3) + addql #1,R(a0) + + moveb MEM(a0),R(d1) + cmpb R(d0),R(d1) + beq L(L9) + tstb R(d1) + beq L(L3) + addql #1,R(a0) + + moveb MEM(a0),R(d1) + cmpb R(d0),R(d1) + beq L(L9) + tstb R(d1) + beq L(L3) + addql #1,R(a0) + + /* Otherwise the fourth byte must equal C. */ +L(L9:) + movel R(a0),R(d0) + movel MEM_POSTINC(sp),R(d3) + cfi_adjust_cfa_offset (-4) + cfi_restore (R(d3)) + movel MEM_POSTINC(sp),R(d2) + cfi_adjust_cfa_offset (-4) + cfi_restore (R(d2)) + rts +END(strchr) + +weak_alias (strchr, index) +libc_hidden_builtin_def (strchr) diff --git a/ports/sysdeps/m68k/strchrnul.S b/ports/sysdeps/m68k/strchrnul.S new file mode 100644 index 0000000000..085583c3be --- /dev/null +++ b/ports/sysdeps/m68k/strchrnul.S @@ -0,0 +1,267 @@ +/* strchrnul (str, ch) -- Return pointer to first occurrence of CH in STR + or the final NUL byte. + For Motorola 68000. + Copyright (C) 1999 Free Software Foundation, Inc. + This file is part of the GNU C Library. + Contributed by Andreas Schwab <schwab@gnu.org>. + + 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, see + <http://www.gnu.org/licenses/>. */ + +#include <sysdep.h> +#include "asm-syntax.h" + + TEXT +ENTRY(__strchrnul) + /* Save the callee-saved registers we use. */ + movel R(d2),MEM_PREDEC(sp) + cfi_adjust_cfa_offset (4) + movel R(d3),MEM_PREDEC(sp) + cfi_adjust_cfa_offset (4) + cfi_rel_offset (R(d2), 4) + cfi_rel_offset (R(d3), 0) + + /* Get string pointer and character. */ + movel MEM_DISP(sp,12),R(a0) + moveb MEM_DISP(sp,19),R(d0) + + /* Distribute the character to all bytes of a longword. */ + movel R(d0),R(d1) + lsll #8,R(d1) + moveb R(d0),R(d1) + movel R(d1),R(d0) + swap R(d0) + movew R(d1),R(d0) + + /* First search for the character one byte at a time until the + pointer is aligned to a longword boundary. */ + movel R(a0),R(d1) +#ifdef __mcoldfire__ + andl #3,R(d1) +#else + andw #3,R(d1) +#endif + beq L(L1) + moveb MEM(a0),R(d2) + cmpb R(d0),R(d2) + beq L(L9) + tstb R(d2) + beq L(L9) + addql #1,R(a0) + +#ifdef __mcoldfire__ + subql #3,R(d1) +#else + subqw #3,R(d1) +#endif + beq L(L1) + moveb MEM(a0),R(d2) + cmpb R(d0),R(d2) + beq L(L9) + tstb R(d2) + beq L(L9) + addql #1,R(a0) + +#ifdef __mcoldfire__ + addql #1,R(d1) +#else + addqw #1,R(d1) +#endif + beq L(L1) + moveb MEM(a0),R(d2) + cmpb R(d0),R(d2) + beq L(L9) + tstb R(d2) + beq L(L9) + addql #1,R(a0) + +L(L1:) + /* Load the magic bits. Unlike the generic implementation we can + use the carry bit as the fourth hole. */ + movel #0xfefefeff,R(d3) + + /* We exit the loop if adding MAGIC_BITS to LONGWORD fails to + change any of the hole bits of LONGWORD. + + 1) Is this safe? Will it catch all the zero bytes? + Suppose there is a byte with all zeros. Any carry bits + propagating from its left will fall into the hole at its + least significant bit and stop. Since there will be no + carry from its most significant bit, the LSB of the + byte to the left will be unchanged, and the zero will be + detected. + + 2) Is this worthwhile? Will it ignore everything except + zero bytes? Suppose every byte of LONGWORD has a bit set + somewhere. There will be a carry into bit 8. If bit 8 + is set, this will carry into bit 16. If bit 8 is clear, + one of bits 9-15 must be set, so there will be a carry + into bit 16. Similarly, there will be a carry into bit + 24. If one of bits 24-31 is set, there will be a carry + into bit 32 (=carry flag), so all of the hole bits will + be changed. + + 3) But wait! Aren't we looking for C, not zero? + Good point. So what we do is XOR LONGWORD with a longword, + each of whose bytes is C. This turns each byte that is C + into a zero. */ + +L(L2:) + /* Get the longword in question. */ + movel MEM_POSTINC(a0),R(d1) + /* XOR with the byte we search for. */ + eorl R(d0),R(d1) + + /* Add the magic value. We get carry bits reported for each byte + which is not C. */ + movel R(d3),R(d2) + addl R(d1),R(d2) + + /* Check the fourth carry bit before it is clobbered by the next + XOR. If it is not set we have a hit. */ + bcc L(L8) + + /* We are only interested in carry bits that change due to the + previous add, so remove original bits. */ + eorl R(d1),R(d2) + + /* Now test for the other three overflow bits. + Set all non-carry bits. */ + orl R(d3),R(d2) + /* Add 1 to get zero if all carry bits were set. */ + addql #1,R(d2) + + /* If we don't get zero then at least one byte of the word equals + C. */ + bne L(L8) + + /* Next look for a NUL byte. + Restore original longword without reload. */ + eorl R(d0),R(d1) + /* Add the magic value. We get carry bits reported for each byte + which is not NUL. */ + movel R(d3),R(d2) + addl R(d1),R(d2) + + /* Check the fourth carry bit before it is clobbered by the next + XOR. If it is not set we have a hit. */ + bcc L(L8) + + /* We are only interested in carry bits that change due to the + previous add, so remove original bits. */ + eorl R(d1),R(d2) + + /* Now test for the other three overflow bits. + Set all non-carry bits. */ + orl R(d3),R(d2) + /* Add 1 to get zero if all carry bits were set. */ + addql #1,R(d2) + + /* If we don't get zero then at least one byte of the word was + NUL. Otherwise continue with the next longword. */ + bne L(L8) + + /* Get the longword in question. */ + movel MEM_POSTINC(a0),R(d1) + /* XOR with the byte we search for. */ + eorl R(d0),R(d1) + + /* Add the magic value. We get carry bits reported for each byte + which is not C. */ + movel R(d3),R(d2) + addl R(d1),R(d2) + + /* Check the fourth carry bit before it is clobbered by the next + XOR. If it is not set we have a hit. */ + bcc L(L8) + + /* We are only interested in carry bits that change due to the + previous add, so remove original bits */ + eorl R(d1),R(d2) + + /* Now test for the other three overflow bits. + Set all non-carry bits. */ + orl R(d3),R(d2) + /* Add 1 to get zero if all carry bits were set. */ + addql #1,R(d2) + + /* If we don't get zero then at least one byte of the word equals + C. */ + bne L(L8) + + /* Next look for a NUL byte. + Restore original longword without reload. */ + eorl R(d0),R(d1) + /* Add the magic value. We get carry bits reported for each byte + which is not NUL. */ + movel R(d3),R(d2) + addl R(d1),R(d2) + + /* Check the fourth carry bit before it is clobbered by the next + XOR. If it is not set we have a hit. */ + bcc L(L8) + + /* We are only interested in carry bits that change due to the + previous add, so remove original bits */ + eorl R(d1),R(d2) + + /* Now test for the other three overflow bits. + Set all non-carry bits. */ + orl R(d3),R(d2) + /* Add 1 to get zero if all carry bits were set. */ + addql #1,R(d2) + + /* If we don't get zero then at least one byte of the word was + NUL. Otherwise continue with the next longword. */ + beq L(L2) + +L(L8:) + /* We have a hit. Check to see which byte it was. First + compensate for the autoincrement in the loop. */ + subql #4,R(a0) + + moveb MEM(a0),R(d1) + cmpb R(d0),R(d1) + beq L(L9) + tstb R(d1) + beq L(L9) + addql #1,R(a0) + + moveb MEM(a0),R(d1) + cmpb R(d0),R(d1) + beq L(L9) + tstb R(d1) + beq L(L9) + addql #1,R(a0) + + moveb MEM(a0),R(d1) + cmpb R(d0),R(d1) + beq L(L9) + tstb R(d1) + beq L(L9) + addql #1,R(a0) + + /* Otherwise the fourth byte must equal C or be NUL. */ +L(L9:) + movel R(a0),R(d0) + movel MEM_POSTINC(sp),R(d3) + cfi_adjust_cfa_offset (-4) + cfi_restore (R(d3)) + movel MEM_POSTINC(sp),R(d2) + cfi_adjust_cfa_offset (-4) + cfi_restore (R(d2)) + rts +END(__strchrnul) + +weak_alias (__strchrnul, strchrnul) diff --git a/ports/sysdeps/m68k/sys/ucontext.h b/ports/sysdeps/m68k/sys/ucontext.h new file mode 100644 index 0000000000..03f26f6fe9 --- /dev/null +++ b/ports/sysdeps/m68k/sys/ucontext.h @@ -0,0 +1,107 @@ +/* Copyright (C) 1997, 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, see + <http://www.gnu.org/licenses/>. */ + +/* System V/m68k ABI compliant context switching support. */ + +#ifndef _SYS_UCONTEXT_H +#define _SYS_UCONTEXT_H 1 + +#include <features.h> +#include <signal.h> + +/* Type for general register. */ +typedef int greg_t; + +/* Number of general registers. */ +#define NGREG 18 + +/* Container for all general registers. */ +typedef greg_t gregset_t[NGREG]; + +/* Number of each register is the `gregset_t' array. */ +enum +{ + R_D0 = 0, +#define R_D0 R_D0 + R_D1 = 1, +#define R_D1 R_D1 + R_D2 = 2, +#define R_D2 R_D2 + R_D3 = 3, +#define R_D3 R_D3 + R_D4 = 4, +#define R_D4 R_D4 + R_D5 = 5, +#define R_D5 R_D5 + R_D6 = 6, +#define R_D6 R_D6 + R_D7 = 7, +#define R_D7 R_D7 + R_A0 = 8, +#define R_A0 R_A0 + R_A1 = 9, +#define R_A1 R_A1 + R_A2 = 10, +#define R_A2 R_A2 + R_A3 = 11, +#define R_A3 R_A3 + R_A4 = 12, +#define R_A4 R_A4 + R_A5 = 13, +#define R_A5 R_A5 + R_A6 = 14, +#define R_A6 R_A6 + R_A7 = 15, +#define R_A7 R_A7 + R_SP = 15, +#define R_SP R_SP + R_PC = 16, +#define R_PC R_PC + R_PS = 17 +#define R_PS R_PS +}; + +/* Structure to describe FPU registers. */ +typedef struct fpregset +{ + int f_pcr; + int f_psr; + int f_fpiaddr; + int f_fpregs[8][3]; +} fpregset_t; + +/* Context to describe whole processor state. */ +typedef struct +{ + int version; + gregset_t gregs; +} mcontext_t; + +#define MCONTEXT_VERSION 1 + +/* Userlevel context. */ +typedef struct ucontext +{ + unsigned long int uc_flags; + struct ucontext *uc_link; + __sigset_t uc_sigmask; + stack_t uc_stack; + mcontext_t uc_mcontext; + long int uc_filler[201]; +} ucontext_t; + +#endif /* sys/ucontext.h */ diff --git a/ports/sysdeps/m68k/sysdep.h b/ports/sysdeps/m68k/sysdep.h new file mode 100644 index 0000000000..980cae5b84 --- /dev/null +++ b/ports/sysdeps/m68k/sysdep.h @@ -0,0 +1,82 @@ +/* Assembler macros for m68k. + Copyright (C) 1998, 2003, 2010, 2012 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, see + <http://www.gnu.org/licenses/>. */ + +#include <sysdeps/generic/sysdep.h> + +#ifdef __ASSEMBLER__ + +/* Syntactic details of assembler. */ + +/* ELF uses byte-counts for .align, most others use log2 of count of bytes. */ +# define ALIGNARG(log2) 1<<log2 +/* For ELF we need the `.type' directive to make shared libs work right. */ +# define ASM_TYPE_DIRECTIVE(name,typearg) .type name,typearg +# define ASM_SIZE_DIRECTIVE(name) .size name,.-name + +/* Define an entry point visible from C. + + There is currently a bug in gdb which prevents us from specifying + incomplete stabs information. Fake some entries here which specify + the current source file. */ +# define ENTRY(name) \ + .globl C_SYMBOL_NAME(name); \ + ASM_TYPE_DIRECTIVE (C_SYMBOL_NAME(name),@function); \ + .align ALIGNARG(2); \ + C_LABEL(name) \ + cfi_startproc; \ + CALL_MCOUNT + +# undef END +# define END(name) \ + cfi_endproc; \ + ASM_SIZE_DIRECTIVE(name) + + +/* If compiled for profiling, call `_mcount' at the start of each function. */ +# ifdef PROF +/* The mcount code relies on a normal frame pointer being on the stack + to locate our caller, so push one just for its benefit. */ +# define CALL_MCOUNT \ + move.l %fp, -(%sp); \ + cfi_adjust_cfa_offset (4); cfi_rel_offset (%fp, 0); \ + move.l %sp, %fp; \ + jbsr JUMPTARGET (_mcount); \ + move.l (%sp)+, %fp; \ + cfi_adjust_cfa_offset (-4); cfi_restore (%fp); +# else +# define CALL_MCOUNT /* Do nothing. */ +# endif + +# define PSEUDO(name, syscall_name, args) \ + .globl __syscall_error; \ + ENTRY (name) \ + DO_CALL (syscall_name, args); \ + jcc JUMPTARGET(__syscall_error) + +# undef PSEUDO_END +# define PSEUDO_END(name) \ + END (name) + +# undef JUMPTARGET +# ifdef PIC +# define JUMPTARGET(name) name##@PLTPC +# else +# define JUMPTARGET(name) name +# endif + +#endif /* __ASSEMBLER__ */ diff --git a/ports/sysdeps/m68k/tls-macros.h b/ports/sysdeps/m68k/tls-macros.h new file mode 100644 index 0000000000..3ad4af725e --- /dev/null +++ b/ports/sysdeps/m68k/tls-macros.h @@ -0,0 +1,69 @@ +/* Macros for accessing thread-local storage. m68k version. + Copyright (C) 2010 Free Software Foundation, Inc. + This file is part of the GNU C Library. + Contributed by Maxim Kuvyrkov <maxim@codesourcery.com>, 2010. + + 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, see + <http://www.gnu.org/licenses/>. */ + +#define TLS_GD(x) \ + ({ \ + void *__result; \ + extern void *__tls_get_addr (void *); \ + \ + asm ("movel #_GLOBAL_OFFSET_TABLE_@GOTPC, %0\n\t" \ + "lea (-6, %%pc, %0), %0\n\t" \ + "lea " #x "@TLSGD(%0), %0" \ + : "=&a" (__result)); \ + (int *) __tls_get_addr (__result); }) + +#define TLS_LD(x) \ + ({ \ + char *__tp; \ + int __offset; \ + extern void *__tls_get_addr (void *); \ + \ + asm ("movel #_GLOBAL_OFFSET_TABLE_@GOTPC, %0\n\t" \ + "lea (-6, %%pc, %0), %0\n\t" \ + "lea " #x "@TLSLDM(%0), %0" \ + : "=&a" (__tp)); \ + __tp = (char *) __tls_get_addr (__tp); \ + asm ("movel #" #x "@TLSLDO, %0" \ + : "=a" (__offset)); \ + (int *) (__tp + __offset); }) + +#define TLS_IE(x) \ + ({ \ + char *__tp; \ + int __offset; \ + extern void * __m68k_read_tp (void); \ + \ + __tp = (char *) __m68k_read_tp (); \ + asm ("movel #_GLOBAL_OFFSET_TABLE_@GOTPC, %0\n\t" \ + "lea (-6, %%pc, %0), %0\n\t" \ + "movel " #x "@TLSIE(%0), %0" \ + : "=&a" (__offset)); \ + (int *) (__tp + __offset); }) + +#define TLS_LE(x) \ + ({ \ + char *__tp; \ + int __offset; \ + extern void * __m68k_read_tp (void); \ + \ + __tp = (char *) __m68k_read_tp (); \ + asm ("movel #" #x "@TLSLE, %0" \ + : "=a" (__offset)); \ + (int *) (__tp + __offset); }) + diff --git a/ports/sysdeps/m68k/tst-audit.h b/ports/sysdeps/m68k/tst-audit.h new file mode 100644 index 0000000000..dc0a09dd8c --- /dev/null +++ b/ports/sysdeps/m68k/tst-audit.h @@ -0,0 +1,24 @@ +/* Definitions for testing PLT entry/exit auditing. m68k version. + Copyright (C) 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, see + <http://www.gnu.org/licenses/>. */ + +#define pltenter la_m68k_gnu_pltenter +#define pltexit la_m68k_gnu_pltexit +#define La_regs La_m68k_regs +#define La_retval La_m68k_retval +#define int_retval lrv_d0 diff --git a/ports/sysdeps/m68k/wcpcpy.c b/ports/sysdeps/m68k/wcpcpy.c new file mode 100644 index 0000000000..c0e841da2f --- /dev/null +++ b/ports/sysdeps/m68k/wcpcpy.c @@ -0,0 +1,36 @@ +/* Copyright (C) 1996, 1997, 2006 Free Software Foundation, Inc. + This file is part of the GNU C Library. + Contributed by Ulrich Drepper <drepper@gnu.ai.mit.edu>, 1996. + + 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, see + <http://www.gnu.org/licenses/>. */ + +/* The generic version of this file assumes that __alignof__(wchar_t) == + sizeof (wchar_t). We therefore use this port-specific implementation + instead. */ +#include <wchar.h> + +/* Copy SRC to DEST, returning the address of the terminating L'\0' in + DEST. */ +wchar_t * +__wcpcpy (wchar_t *dest, const wchar_t *src) +{ + do + ; + while ((*dest++ = *src++)); + + return dest - 1; +} + +weak_alias (__wcpcpy, wcpcpy) diff --git a/ports/sysdeps/m68k/wcpcpy_chk.c b/ports/sysdeps/m68k/wcpcpy_chk.c new file mode 100644 index 0000000000..b0ddf80bf4 --- /dev/null +++ b/ports/sysdeps/m68k/wcpcpy_chk.c @@ -0,0 +1,35 @@ +/* Copyright (C) 1996, 1997, 2005, 2006 Free Software Foundation, Inc. + This file is part of the GNU C Library. + Contributed by Ulrich Drepper <drepper@gnu.ai.mit.edu>, 1996. + + 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, see + <http://www.gnu.org/licenses/>. */ + +/* The generic version of this file assumes that __alignof__(wchar_t) == + sizeof (wchar_t). We therefore use this port-specific implementation + instead. */ +#include <wchar.h> + +/* Copy SRC to DEST, returning the address of the terminating L'\0' in + DEST. Check for overflows. */ +wchar_t * +__wcpcpy_chk (wchar_t *dest, const wchar_t *src, size_t destlen) +{ + do + if (destlen-- == 0) + __chk_fail (); + while ((*dest++ = *src++)); + + return dest - 1; +} |