Start of math support from glibc.

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@22701 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
François Revol 2007-10-24 22:54:33 +00:00
parent 20b56fdd92
commit cc9ad8e824
20 changed files with 1249 additions and 0 deletions

View File

@ -0,0 +1,148 @@
SubDir HAIKU_TOP src system libroot posix glibc arch m68k ;
SubDirSysHdrs $(HAIKU_TOP) src system libroot posix glibc include arch
$(TARGET_ARCH) ;
SubDirSysHdrs $(HAIKU_TOP) src system libroot posix glibc include arch generic ;
SubDirSysHdrs $(HAIKU_TOP) src system libroot posix glibc include ;
SubDirSysHdrs $(HAIKU_TOP) src system libroot posix glibc stdlib ;
SubDirSysHdrs $(HAIKU_TOP) src system libroot posix glibc math ;
SubDirSysHdrs $(HAIKU_TOP) src system libroot posix glibc libio ;
SubDirSysHdrs $(HAIKU_TOP) src system libroot posix glibc ;
SubDirHdrs $(HAIKU_TOP) src system libroot posix glibc arch generic ;
if $(OPTIM) = -O0 {
OPTIM = -O ;
}
# don't compile with debugging
DEBUG = 0 ;
SubDirCcFlags -D_GNU_SOURCE -D_IEEE_LIBM ;
# Note: There is no *l() support yet. Our compiler says sizeof(long double) = 8,
# while there are only 96 and 128 bit implementation in glibc.
local genericSources =
branred.c
cmp.c dbl2mpn.c divrem.c
doasin.c dosincos.c
halfulp.c
mpa.c mpatan.c mpatan2.c mpexp.c mplog.c mpn2dbl.c
mpn2flt.c mpn2ldbl.c mpsqrt.c mptan.c
mul.c mul_n.c
sincos32.c
slowexp.c
slowpow.c
e_acos.c e_acosf.c # e_acosl.c
e_acosh.c e_acoshf.c # e_acoshl.c
e_asin.c e_asinf.c # e_asinl.c
e_atan2.c e_atan2f.c # e_atan2l.c
e_atanh.c e_atanhf.c # e_atanhl.c
e_cosh.c e_coshf.c # e_coshl.c
e_exp.c e_expf.c
e_fmod.c e_fmodf.c # e_fmodl.c
e_gamma_r.c e_gammaf_r.c
e_hypot.c e_hypotf.c # e_hypotl.c
e_j0.c e_j0f.c
e_j1.c e_j1f.c
e_jn.c e_jnf.c
e_lgamma_r.c e_lgammaf_r.c
e_log.c e_logf.c
e_log10.c e_log10f.c
e_pow.c e_powf.c # e_powl.c
e_rem_pio2f.c
e_remainder.c e_remainderf.c # e_remainderl.c
e_scalb.c e_scalbf.c # e_scalbl.c
e_sinh.c e_sinhf.c # e_sinhl.c
k_cos.c k_cosf.c
k_sin.c k_sinf.c
k_rem_pio2.c k_rem_pio2f.c # k_rem_pio2l.c
k_tan.c k_tanf.c
s_asinh.c s_asinhf.c # s_asinhl.c
s_atan.c s_atanf.c # s_atanl.c
s_cbrt.c s_cbrtf.c # s_cbrtl.c
s_ceil.c s_ceilf.c # s_ceill.c
s_cos.c s_cosf.c
s_erf.c s_erff.c # s_erfl.c
s_expm1f.c s_expm1.c
s_finite.c s_finitef.c # s_finitel.c
s_floor.c s_floorf.c # s_floorl.c
s_fpclassify.c s_fpclassifyf.c # s_fpclassifyl.c
s_frexp.c s_frexpf.c # s_frexpl.c
s_ilogb.c s_ilogbf.c
s_isinf.c s_isinff.c # s_isinfl.c
s_ldexp.c s_ldexpf.c # s_ldexpl.c
s_log1p.c s_log1pf.c
s_logb.c s_logbf.c # s_logbl.c
s_lround.c s_lroundf.c
s_modf.c s_modff.c # s_modfl.c
s_nan.c s_nanf.c # s_nanl.c
s_round.c s_roundf.c # s_roundl.c
s_scalbn.c s_scalbnf.c # s_scalbnl.c
s_signbit.c s_signbitf.c # s_signbitl.c
s_significand.c s_significandf.c
s_signgam.c
s_sin.c s_sinf.c # s_sinl.c
s_sincos.c s_sincosf.c
s_tan.c s_tanf.c
s_tanh.c s_tanhf.c
s_trunc.c s_truncf.c
t_exp.c
w_acos.c w_acosf.c # w_acosl.c
w_acosh.c w_acoshf.c # w_acoshl.c
w_atan2.c w_atan2f.c # w_atan2l.c
w_asin.c w_asinf.c # w_asinl.c
w_atanh.c w_atanhf.c # w_atanhl.c
w_cosh.c w_coshf.c # w_coshl.c
w_drem.c w_dremf.c # w_dreml.c
w_exp.c w_expf.c # w_expl.c
w_fmod.c w_fmodf.c # w_fmodl.c
w_hypot.c w_hypotf.c # w_hypotl.c
w_j0.c w_j0f.c
w_j1.c w_j1f.c
w_jn.c w_jnf.c
w_lgamma.c w_lgammaf.c
w_lgamma_r.c w_lgammaf_r.c
w_log.c w_logf.c # w_logl.c
w_log10.c w_log10f.c # w_log10l.c
w_pow.c w_powf.c # w_powl.c
w_remainder.c w_remainderf.c # w_remainderl.c
w_scalb.c w_scalbf.c # w_scalbl.c
w_sinh.c w_sinhf.c # w_sinhl.c
;
MergeObject posix_gnu_arch_$(TARGET_ARCH)_generic.o :
$(genericSources)
;
MergeObject posix_gnu_arch_$(TARGET_ARCH)_other.o :
# add_n.S
# addmul_1.S
feholdexcpt.c fraiseexcpt.c fesetenv.c fesetround.c ftestexcept.c
# ldbl2mpn.c
# lshift.S rshift.S
# mul_1.S
# strlen.S
# sub_n.S
# submul_1.S
#
# e_sqrt.c e_sqrtf.c # e_sqrtl.c
# s_copysign.S s_copysignf.S # s_copysignl.S
# s_fdim.c s_fdimf.c # s_fdiml.S
# s_fabs.S s_fabsf.S # s_fabsl.S
# s_isnan.c s_isnanf.S
# s_rint.c s_rintf.c # s_rintl.c
# t_sqrt.c
# w_sqrt.c w_sqrtf.c # w_sqrtl.c
;
MergeObjectFromObjects posix_gnu_arch_$(TARGET_ARCH).o : :
posix_gnu_arch_$(TARGET_ARCH)_generic.o
posix_gnu_arch_$(TARGET_ARCH)_other.o
;
SEARCH on [ FGristFiles $(genericSources) ]
= [ FDirName $(HAIKU_TOP) src system libroot posix glibc arch generic ] ;

View File

@ -0,0 +1,39 @@
/* 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, write to the Free
Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
02111-1307 USA. */
#include <fenv.h>
int
feholdexcept (fenv_t *envp)
{
fexcept_t fpcr, fpsr;
/* Store the environment. */
__asm__ ("fmovem%.l %/fpcr/%/fpsr/%/fpiar,%0" : "=m" (*envp));
/* 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;
}

View File

@ -0,0 +1,59 @@
/* Install given 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, write to the Free
Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
02111-1307 USA. */
#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. */
__asm__ ("fmovem%.l %/fpcr/%/fpsr/%/fpiar,%0" : "=m" (*&temp));
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;
}
__asm__ __volatile__ ("fmovem%.l %0,%/fpcr/%/fpsr/%/fpiar" : : "m" (*&temp));
/* 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
versioned_symbol (libm, __fesetenv, fesetenv, GLIBC_2_2);

View File

@ -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, write to the Free
Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
02111-1307 USA. */
#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;
}

View File

@ -0,0 +1,82 @@
/* Raise given 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, write to the Free
Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
02111-1307 USA. */
#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
versioned_symbol (libm, __feraiseexcept, feraiseexcept, GLIBC_2_2);

View File

@ -0,0 +1,32 @@
/* Test exception in current environment.
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, write to the Free
Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
02111-1307 USA. */
#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;
}

View File

@ -0,0 +1,109 @@
/* Definitions for 68k syntax variations.
Copyright (C) 1992, 1994, 1996, 1997 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, write to the Free
Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
02111-1307 USA. */
#ifdef HAVE_ELF
/* 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. */
#ifdef __STDC__
#define R_(r) %##r
#define R(r) R_(r)
#define L(label) .##label
#else
#define R(r) %/**/r
#define L(label) ./**/label
#endif
#else
#define ALIGNARG(log2) log2
#define PROLOG(name) /* Nothing. */
#define EPILOG(name) /* Nothing. */
#define R(r) r
#define L(label) label
#endif
#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))+
#ifdef __STDC__
#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)
#else
#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)
#endif
#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 eorw eor.w
#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 subql subq.l
#define negl neg.l
#define mulul mulu.l
#endif

View File

@ -0,0 +1,67 @@
/* Macros to swap the order of bytes in integer values. m68k version.
Copyright (C) 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, write to the Free
Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
02111-1307 USA. */
#if !defined _BYTESWAP_H && !defined _NETINET_IN_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_16(x) \
((((x) >> 8) & 0xff) | (((x) & 0xff) << 8))
/* Swap bytes in 32 bit value. */
#define __bswap_constant_32(x) \
((((x) & 0xff000000) >> 24) | (((x) & 0x00ff0000) >> 8) | \
(((x) & 0x0000ff00) << 8) | (((x) & 0x000000ff) << 24))
#if defined __GNUC__ && __GNUC__ >= 2
# define __bswap_32(x) \
__extension__ \
({ unsigned int __bswap_32_v; \
if (__builtin_constant_p (x)) \
__bswap_32_v = __bswap_constant_32 (x); \
else \
__asm__ __volatile__ ("ror%.w %#8, %0;" \
"swap %0;" \
"ror%.w %#8, %0" \
: "=d" (__bswap_32_v) \
: "0" ((unsigned int) (x))); \
__bswap_32_v; })
#else
# define __bswap_32(x) __bswap_constant_32 (x)
#endif
#if defined __GNUC__ && __GNUC__ >= 2
/* Swap bytes in 64 bit value. */
# define __bswap_64(x) \
__extension__ \
({ union { unsigned long long int __ll; \
unsigned long int __l[2]; } __bswap_64_v, __bswap_64_r; \
__bswap_64_v.__ll = (x); \
__bswap_64_r.__l[0] = __bswap_32 (__bswap_64_v.__l[1]); \
__bswap_64_r.__l[1] = __bswap_32 (__bswap_64_v.__l[0]); \
__bswap_64_r.__ll; })
#endif
#endif /* _BITS_BYTESWAP_H */

View File

@ -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

View File

@ -0,0 +1,79 @@
/* Copyright (C) 1997, 1998, 1999, 2000 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
The GNU C Library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with the GNU C Library; if not, write to the Free
Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
02111-1307 USA. */
#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

View File

@ -0,0 +1,8 @@
/* This file provides inline versions of floating-pint environment
handling functions. If there were any. */
#ifndef __NO_MATH_INLINES
/* Here is where the code would go. */
#endif

View File

@ -0,0 +1,92 @@
/* `HUGE_VAL' constants for m68k (where it is infinity).
Used by <stdlib.h> and <math.h> functions for overflow.
Copyright (C) 1992, 1995, 1996, 1997, 1999, 2000 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
The GNU C Library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with the GNU C Library; if not, write to the Free
Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
02111-1307 USA. */
#ifndef _MATH_H
# error "Never use <bits/huge_val.h> directly; include <math.h> instead."
#endif
#include <features.h>
#include <sys/cdefs.h>
/* IEEE positive infinity (-HUGE_VAL is negative infinity). */
#ifdef __GNUC__
# if __GNUC_PREREQ(2,96)
# define HUGE_VAL (__extension__ 0x1.0p2047)
# else
# define HUGE_VAL \
(__extension__ \
((union { unsigned long long __l; double __d; }) \
{ __l: 0x7ff0000000000000ULL }).__d)
# endif
#else /* not GCC */
static union { unsigned char __c[8]; double __d; } __huge_val =
{ { 0x7f, 0xf0, 0, 0, 0, 0, 0, 0 } };
# define HUGE_VAL (__huge_val.__d)
#endif /* GCC. */
/* ISO C 99 extensions: (float) HUGE_VALF and (long double) HUGE_VALL. */
#ifdef __USE_ISOC99
# if __GNUC_PREREQ(2,96)
# define HUGE_VALF (__extension__ 0x1.0p255f)
# define HUGE_VALL (__extension__ 0x1.0p32767L)
# else
# ifdef __GNUC__
# define HUGE_VALF \
(__extension__ \
((union { unsigned long __l; float __f; }) \
{ __l: 0x7f800000UL }).__f)
# 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[4]; float __f; } __huge_valf =
{ { 0x7f, 0x80, 0, 0 } };
# define HUGE_VALF (__huge_valf.__f)
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. */
# endif /* GCC 2.95. */
#endif /* __USE_ISOC99. */

View File

@ -0,0 +1,41 @@
/* Copyright (C) 1997, 1998, 1999, 2000 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
The GNU C Library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with the GNU C Library; if not, write to the Free
Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
02111-1307 USA. */
#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'. */
/* Define `INFINITY' as value of type `float'. */
# define INFINITY HUGE_VALF
/* The values returned by `ilogb' for 0 and NaN respectively. */
# define FP_ILOGB0 (-2147483647 - 1)
# define FP_ILOGBNAN (2147483647)
#endif /* ISO C99 */

View File

@ -0,0 +1,3 @@
/* We don't want any inlines when we might not have a 68881. */
/* mmu_man: should have them but it gets loads of warnings currently... sort it out */
#warning M68K: replace with glibc-2.2.5/sysdeps/m68k/fpu/bits/mathinline.h someday!

View File

@ -0,0 +1,48 @@
/* `NAN' constant for IEEE 754 machines.
Copyright (C) 1992, 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, write to the Free
Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
02111-1307 USA. */
#ifndef _MATH_H
# error "Never use <bits/nan.h> directly; include <math.h> instead."
#endif
/* IEEE Not A Number. */
#ifdef __GNUC__
# define NAN \
(__extension__ \
((union { unsigned __l __attribute__((__mode__(__SI__))); float __d; }) \
{ __l: 0x7fc00000UL }).__d)
#else
# include <endian.h>
# if __BYTE_ORDER == __BIG_ENDIAN
# define __nan_bytes { 0x7f, 0xc0, 0, 0 }
# endif
# if __BYTE_ORDER == __LITTLE_ENDIAN
# define __nan_bytes { 0, 0, 0xc0, 0x7f }
# endif
static union { unsigned char __c[4]; float __d; } __nan_union = { __nan_bytes };
# define NAN (__nan_union.__d)
#endif /* GCC. */

View File

@ -0,0 +1,19 @@
/* Copyright (C) 1999 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
The GNU C Library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with the GNU C Library; if not, write to the Free
Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
02111-1307 USA. */
#define __WORDSIZE 32

View File

@ -0,0 +1,250 @@
//#if !defined __ASSEMBLER__ && !defined _ISOMAC && !defined __OPTIMIZE__
//# error "glibc cannot be compiled without optimization"
//#endif
/* Another evil option when it comes to compiling the C library is
--ffast-math since it alters the ABI. */
#if defined __FAST_MATH__ && !defined TEST_FAST_MATH
# error "glibc must not be compiled with -ffast-math"
#endif
/* Define if using GNU ld, with support for weak symbols in a.out,
and for symbol set and warning messages extensions in a.out and ELF.
This implies HAVE_WEAK_SYMBOLS; set by --with-gnu-ld. */
#define HAVE_GNU_LD 1
/* Define if using ELF, which supports weak symbols.
This implies HAVE_ASM_WEAK_DIRECTIVE and NO_UNDERSCORES; set by
--with-elf. */
#define HAVE_ELF 1
/* Define if using XCOFF. Set by --with-xcoff. */
#undef HAVE_XCOFF
/* Define if C symbols are asm symbols. Don't define if C symbols
have a `_' prepended to make the asm symbol. */
#define NO_UNDERSCORES 1
/* Define if weak symbols are available via the `.weak' directive. */
#define HAVE_ASM_WEAK_DIRECTIVE 1
/* Define if weak symbols are available via the `.weakext' directive. */
#undef HAVE_ASM_WEAKEXT_DIRECTIVE
/* Define to the assembler line separator character for multiple
assembler instructions per line. Default is `;' */
#undef ASM_LINE_SEP
/* Define if not using ELF, but `.init' and `.fini' sections are available. */
#undef HAVE_INITFINI
/* Define if __attribute__((section("foo"))) puts quotes around foo. */
/*#define HAVE_SECTION_QUOTES 1
[zooey]: defining this causes assembler errors, and I don't think
that any BeOS-gcc actually produces quotes in sections...
*/
#undef HAVE_SECTION_QUOTES
/* Define if using the GNU assembler, gas. */
#define HAVE_GNU_AS 1
/* Define if the assembler supports the `.set' directive. */
#define HAVE_ASM_SET_DIRECTIVE 1
/* Define to the name of the assembler's directive for
declaring a symbol global (default `.globl'). */
#define ASM_GLOBAL_DIRECTIVE .globl
/* Define to the prefix before `object' or `function' in the
assembler's `.type' directive, if it has one. */
#undef ASM_TYPE_DIRECTIVE_PREFIX
/* Define a symbol_name as a global .symbol_name for ld. */
#undef HAVE_ASM_GLOBAL_DOT_NAME
/* Define if the assembler generates debugging information directly. */
#undef HAVE_CPP_ASM_DEBUGINFO
/* Define if _Unwind_Find_FDE should be exported from glibc. */
#undef EXPORT_UNWIND_FIND_FDE
/* Define to use GNU libio instead of GNU stdio.
This is defined by configure under --enable-libio. */
#define USE_IN_LIBIO 1
/* Define if using ELF and the assembler supports the `.previous'
directive. */
#define HAVE_ASM_PREVIOUS_DIRECTIVE 1
/* Define if using ELF and the assembler supports the `.popsection'
directive. */
#undef HAVE_ASM_POPSECTION_DIRECTIVE
/* Define if versioning of the library is wanted. */
#undef DO_VERSIONING
/* Defined to the oldest ABI we support, like 2.1. */
#undef GLIBC_OLDEST_ABI
/* Define if static NSS modules are wanted. */
#undef DO_STATIC_NSS
/* Define if gcc uses DWARF2 unwind information for exception support. */
#define HAVE_DWARF2_UNWIND_INFO 1
/* Define if gcc uses DWARF2 unwind information for exception support
with static variable. */
#define HAVE_DWARF2_UNWIND_INFO_STATIC 1
/* Define if the compiler supports __builtin_expect. */
#undef HAVE_BUILTIN_EXPECT
/* Define if the compiler supports __builtin_memset. */
#undef HAVE_BUILTIN_MEMSET
/* Define if the __thread keyword is supported. */
#undef HAVE___THREAD
/* Define if the compiler supports __attribute__((tls_model(""))). */
#undef HAVE_TLS_MODEL_ATTRIBUTE
/* Define if the regparm attribute shall be used for local functions
(gcc on ix86 only). */
#define USE_REGPARMS 1
/* Defined on PowerPC if the GCC being used has a problem with clobbering
certain registers (CR0, MQ, CTR, LR) in asm statements. */
#undef BROKEN_PPC_ASM_CR0
/* TODO: bonefish: Do we need to define this? */
/* Defined on SPARC if ld doesn't handle R_SPARC_WDISP22 against .hidden
symbol. sysdeps/sparc/sparc32/elf/configure. */
#undef BROKEN_SPARC_WDISP22
/* Define if the linker supports the -z combreloc option. */
#undef HAVE_Z_COMBRELOC
/* Define if the assembler supported .protected. */
#undef HAVE_PROTECTED
/* Define if the assembler supported .hidden. */
#undef HAVE_HIDDEN
/* Define if the compiler supports __attribute__ ((visibility (...))). */
#undef HAVE_VISIBILITY_ATTRIBUTE
/* Define if the compiler doesn't support __attribute__ ((visibility (...)))
together with __asm__ redirection properly. */
#undef HAVE_BROKEN_VISIBILITY_ATTRIBUTE
/* Define if the compiler doesn't support __attribute__ ((alias (...)))
together with __asm__ redirection properly. */
#undef HAVE_BROKEN_ALIAS_ATTRIBUTE
/* Define if _rtld_local structure should be forced into .sdata section. */
#undef HAVE_SDATA_SECTION
/* Define if binutils support TLS handling. */
#undef HAVE_TLS_SUPPORT
/* Define if the linker supports .preinit_array/.init_array/.fini_array
sections. */
#undef HAVE_INITFINI_ARRAY
/* Define if the access to static and hidden variables is position independent
and does not need relocations. */
#undef PI_STATIC_AND_HIDDEN
/* Define this to disable the `hidden_proto' et al macros in
include/libc-symbols.h that avoid PLT slots in the shared objects. */
#undef NO_HIDDEN
/* Defined to some form of __attribute__ ((...)) if the compiler supports
a different, more efficient calling convention. */
#if defined USE_REGPARMS && !defined PROF && !defined __BOUNDED_POINTERS__
# define internal_function __attribute__ ((regparm (3), stdcall))
#endif
/* Linux specific: minimum supported kernel version. */
#undef __LINUX_KERNEL_VERSION
/* Override abi-tags ABI version if necessary. */
#undef __ABI_TAG_VERSION
/* An extension in gcc 2.96 and up allows the subtraction of two
local labels. */
#undef HAVE_SUBTRACT_LOCAL_LABELS
/* bash 2.0 introduced the _XXX_GNU_nonoption_argv_flags_ variable to help
getopt determine whether a parameter is a flag or not. This features
was disabled later since it caused trouble. We are by default therefore
disabling the support as well. */
#undef USE_NONOPTION_FLAGS
/* Mach/Hurd specific: define if mig supports the `retcode' keyword. */
#undef HAVE_MIG_RETCODE
/* Mach specific: define if the `host_page_size' RPC is available. */
#undef HAVE_HOST_PAGE_SIZE
/* Mach/i386 specific: define if the `i386_io_perm_*' RPCs are available. */
#undef HAVE_I386_IO_PERM_MODIFY
/* Mach/i386 specific: define if the `i386_set_gdt' RPC is available. */
#undef HAVE_I386_SET_GDT
/* bonefish: Currently our PPC gcc doesn't support 128 bit long double.
It's 64 bit instead. I tried to change that, but apparently there's no
support for TI mode emulation for PPC. So we define NO_LONG_DOUBLE for
the time being, which creates aliases of the double math functions to
the respective long double functions. */
/* mmu_man: not yet sure for m68k, fpu uses 80bits IIRC, will check later. */
#warning M68K: check sizeof(long double)
#define NO_LONG_DOUBLE 1
#define __NO_LONG_DOUBLE_MATH 1
/*
*/
#ifndef _LIBC
/* These symbols might be defined by some sysdeps configures.
They are used only in miscellaneous generator programs, not
in compiling libc itself. */
/* sysdeps/generic/configure.in */
#undef HAVE_PSIGNAL
/* sysdeps/unix/configure.in */
#define HAVE_STRERROR
/* sysdeps/unix/common/configure.in */
#undef HAVE_SYS_SIGLIST
#undef HAVE__SYS_SIGLIST
#undef HAVE__CTYPE_
#undef HAVE___CTYPE_
#undef HAVE___CTYPE
#undef HAVE__CTYPE__
#undef HAVE__CTYPE
#undef HAVE__LOCP
#endif
/*
*/
#ifdef _LIBC
/* The zic and zdump programs need these definitions. */
#define HAVE_STRERROR 1
/* The locale code needs these definitions. */
#define HAVE_REGEX 1
//#define HAVE_MMAP 1
#undef HAVE_MMAP
#endif

View File

@ -0,0 +1 @@
#warning M68K: writeme: check sizeof(double float)

View File

@ -0,0 +1,28 @@
/* Copyright (C) 1999 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
The GNU C Library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with the GNU C Library; if not, write to the Free
Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
02111-1307 USA. */
/* This file contains a bit of information about the stack allocation
of the processor. */
#ifndef _STACKINFO_H
#define _STACKINFO_H 1
/* On m68k the stack grows down. */
#define _STACK_GROWS_DOWN 1
#endif /* stackinfo.h */

View File

@ -0,0 +1,99 @@
/* Assembler macros for m68k.
Copyright (C) 1998 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
The GNU C Library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with the GNU C Library; if not, write to the Free
Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
02111-1307 USA. */
#include <sysdeps/generic/sysdep.h>
#ifdef __ASSEMBLER__
/* Syntactic details of assembler. */
#ifdef HAVE_ELF
/* 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
/* In ELF C symbols are asm symbols. */
#undef NO_UNDERSCORES
#define NO_UNDERSCORES
#else
#define ALIGNARG(log2) log2
#define ASM_TYPE_DIRECTIVE(name,type) /* Nothing is specified. */
#define ASM_SIZE_DIRECTIVE(name) /* Nothing is specified. */
#endif
/* 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) \
CALL_MCOUNT
#undef END
#define END(name) 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); move.l %sp, %fp; \
jbsr JUMPTARGET (mcount); \
move.l (%sp)+, %fp;
#else
#define CALL_MCOUNT /* Do nothing. */
#endif
#ifdef NO_UNDERSCORES
/* Since C identifiers are not normally prefixed with an underscore
on this system, the asm identifier `syscall_error' intrudes on the
C name space. Make sure we use an innocuous name. */
#define syscall_error __syscall_error
#define mcount _mcount
#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)
#ifdef PIC
#define JUMPTARGET(name) name##@PLTPC
#else
#define JUMPTARGET(name) name
#endif
#endif /* __ASSEMBLER__ */