Added git source kolibri-libc and

Configured autobuild

git-svn-id: svn://kolibrios.org@8687 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
turbocat
2021-04-27 16:33:31 +00:00
parent 1d94455637
commit 728f124678
182 changed files with 9987 additions and 0 deletions
@@ -0,0 +1,23 @@
.text
acos.LC0:
.double 0d1.00000000000000000000e+00
.global acos;
acos:
fldl 4(%esp)
fld1
fsubp %st(0),%st(1)
fsqrt
fldl 4(%esp)
fld1
faddp %st(0),%st(1)
fsqrt
fpatan
fld %st(0)
faddp
ret
@@ -0,0 +1,8 @@
/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */
#include <math.h>
double
acosh(double x)
{
return log(x + sqrt(x*x - 1));
}
@@ -0,0 +1,16 @@
/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */
.global asin;
asin:
fldl 4(%esp)
fld %st(0)
fmulp
fld1
fsubp
fsqrt
fldl 4(%esp)
fxch %st(1)
fpatan
ret
@@ -0,0 +1,9 @@
/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */
#include <math.h>
double
asinh(double x)
{
return x>0 ? log(x + sqrt(x*x + 1)) : -log(sqrt(x*x+1)-x);
}
@@ -0,0 +1,10 @@
/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */
.global atan;
atan:
fldl 4(%esp)
fld1
fpatan
ret
@@ -0,0 +1,37 @@
/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */
.data
.align 2
nan:
.long 0xffffffff
.byte 0xff
.byte 0xff
.byte 0xff
.byte 0x7f
.text
.global atan2;
atan2:
fldl 4(%esp)
fldl 12(%esp)
ftst
fnstsw %ax
sahf
jne doit
fxch %st(1)
ftst
fnstsw %ax
sahf
je isanan
fxch %st(1)
doit:
fpatan
ret
isanan:
movl $1, errno
fstp %st(0)
fstp %st(0)
fldl nan
ret
@@ -0,0 +1,8 @@
/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */
#include <math.h>
double
atanh(double x)
{
return log((1+x)/(1-x)) / 2.0;
}
@@ -0,0 +1,26 @@
/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */
.global ceil;
ceil:
pushl %ebp
movl %esp,%ebp
subl $8,%esp
fstcw -4(%ebp)
fwait
movw -4(%ebp),%ax
andw $0xf3ff,%ax
orw $0x0800,%ax
movw %ax,-2(%ebp)
fldcw -2(%ebp)
fldl 8(%ebp)
frndint
fldcw -4(%ebp)
movl %ebp,%esp
popl %ebp
ret
@@ -0,0 +1,17 @@
cos.L0:
.quad 0xffffffffffffffff
.global cos;
cos:
fldl 4(%esp)
fcos
fstsw
sahf
jnp cos.L1
fstp %st(0)
fldl cos.L0
cos.L1:
ret
@@ -0,0 +1,8 @@
/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */
#include <math.h>
double cosh(double x)
{
const double ebig = exp(fabs(x));
return (ebig + 1.0/ebig) / 2.0;
}
@@ -0,0 +1,33 @@
.data
exp.LCW1:
.word 0
exp.LCW2:
.word 0
exp.LC0:
.double 0d1.0e+00
.text
.global exp;
exp:
fldl 4(%esp)
fldl2e
fmulp
fstcw exp.LCW1
fstcw exp.LCW2
fwait
andw $0xf3ff, exp.LCW2
orw $0x0400, exp.LCW2
fldcw exp.LCW2
fldl %st(0)
frndint
fldcw exp.LCW1
fxch %st(1)
fsub %st(1),%st
f2xm1
faddl exp.LC0
fscale
fstp %st(1)
ret
@@ -0,0 +1,8 @@
/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */
.global fabs;
fabs:
fldl 4(%esp)
fabs
ret
@@ -0,0 +1,26 @@
/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */
.global floor;
floor:
pushl %ebp
movl %esp,%ebp
subl $8,%esp
fstcw -4(%ebp)
fwait
movw -4(%ebp),%ax
andw $0xf3ff,%ax
orw $0x0400,%ax
movw %ax,-2(%ebp)
fldcw -2(%ebp)
fldl 8(%ebp)
frndint
fldcw -4(%ebp)
movl %ebp,%esp
popl %ebp
ret
@@ -0,0 +1,26 @@
/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */
.text
.global fmod;
fmod:
fldl 4(%esp)
fldl 12(%esp)
ftst
fnstsw %ax
fxch %st(1)
sahf
jnz next
fstpl %st(0)
jmp out
next:
fprem
fnstsw %ax
sahf
jpe next
fstpl %st(1)
out:
ret
@@ -0,0 +1,26 @@
/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */
#include <math.h>
double
frexp(double x, int *exptr)
{
union {
double d;
unsigned char c[8];
} u;
u.d = x;
/*
* The format of the number is:
* Sign, 12 exponent bits, 51 mantissa bits
* The exponent is 1023 biased and there is an implicit zero.
* We get the exponent from the upper bits and set the exponent
* to 0x3fe (1022).
*/
*exptr = (int)(((u.c[7] & 0x7f) << 4) | (u.c[6] >> 4)) - 1022;
u.c[7] &= 0x80;
u.c[7] |= 0x3f;
u.c[6] &= 0x0f;
u.c[6] |= 0xe0;
return u.d;
}
@@ -0,0 +1,100 @@
/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */
/*
* hypot() function for DJGPP.
*
* hypot() computes sqrt(x^2 + y^2). The problem with the obvious
* naive implementation is that it might fail for very large or
* very small arguments. For instance, for large x or y the result
* might overflow even if the value of the function should not,
* because squaring a large number might trigger an overflow. For
* very small numbers, their square might underflow and will be
* silently replaced by zero; this won't cause an exception, but might
* have an adverse effect on the accuracy of the result.
*
* This implementation tries to avoid the above pitfals, without
* inflicting too much of a performance hit.
*
*/
/// #include <float.h>
#include <math.h>
#include <errno.h>
/* Approximate square roots of DBL_MAX and DBL_MIN. Numbers
between these two shouldn't neither overflow nor underflow
when squared. */
#define __SQRT_DBL_MAX 1.3e+154
#define __SQRT_DBL_MIN 2.3e-162
double
hypot(double x, double y)
{
double abig = fabs(x), asmall = fabs(y);
double ratio;
/* Make abig = max(|x|, |y|), asmall = min(|x|, |y|). */
if (abig < asmall)
{
double temp = abig;
abig = asmall;
asmall = temp;
}
/* Trivial case. */
if (asmall == 0.)
return abig;
/* Scale the numbers as much as possible by using its ratio.
For example, if both ABIG and ASMALL are VERY small, then
X^2 + Y^2 might be VERY inaccurate due to loss of
significant digits. Dividing ASMALL by ABIG scales them
to a certain degree, so that accuracy is better. */
if ((ratio = asmall / abig) > __SQRT_DBL_MIN && abig < __SQRT_DBL_MAX)
return abig * sqrt(1.0 + ratio*ratio);
else
{
/* Slower but safer algorithm due to Moler and Morrison. Never
produces any intermediate result greater than roughly the
larger of X and Y. Should converge to machine-precision
accuracy in 3 iterations. */
double r = ratio*ratio, t, s, p = abig, q = asmall;
do {
t = 4. + r;
if (t == 4.)
break;
s = r / t;
p += 2. * s * p;
q *= s;
r = (q / p) * (q / p);
} while (1);
return p;
}
}
#ifdef TEST
#include <stdio.h>
int
main(void)
{
printf("hypot(3, 4) =\t\t\t %25.17e\n", hypot(3., 4.));
printf("hypot(3*10^150, 4*10^150) =\t %25.17g\n", hypot(3.e+150, 4.e+150));
printf("hypot(3*10^306, 4*10^306) =\t %25.17g\n", hypot(3.e+306, 4.e+306));
printf("hypot(3*10^-320, 4*10^-320) =\t %25.17g\n",
hypot(3.e-320, 4.e-320));
printf("hypot(0.7*DBL_MAX, 0.7*DBL_MAX) =%25.17g\n",
hypot(0.7*DBL_MAX, 0.7*DBL_MAX));
printf("hypot(DBL_MAX, 1.0) =\t\t %25.17g\n", hypot(DBL_MAX, 1.0));
printf("hypot(1.0, DBL_MAX) =\t\t %25.17g\n", hypot(1.0, DBL_MAX));
printf("hypot(0.0, DBL_MAX) =\t\t %25.17g\n", hypot(0.0, DBL_MAX));
return 0;
}
#endif
@@ -0,0 +1,32 @@
/* Copyright (C) 1996 DJ Delorie, see COPYING.DJ for details */
/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */
#include <math.h>
double
ldexp(double v, int e)
{
double two = 2.0;
if (e < 0)
{
e = -e; /* This just might overflow on two-complement machines. */
if (e < 0) return 0.0;
while (e > 0)
{
if (e & 1) v /= two;
two *= two;
e >>= 1;
}
}
else if (e > 0)
{
while (e > 0)
{
if (e & 1) v *= two;
two *= two;
e >>= 1;
}
}
return v;
}
@@ -0,0 +1,9 @@
/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */
.global log;
log:
fldln2
fldl 4(%esp)
fyl2x
ret
@@ -0,0 +1,35 @@
/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */
.text
.global modf;
modf:
pushl %ebp
movl %esp,%ebp
subl $16,%esp
pushl %ebx
fnstcw -4(%ebp)
fwait
movw -4(%ebp),%ax
orw $0x0c3f,%ax
movw %ax,-8(%ebp)
fldcw -8(%ebp)
fwait
fldl 8(%ebp)
frndint
fstpl -16(%ebp)
fwait
movl -16(%ebp),%edx
movl -12(%ebp),%ecx
movl 16(%ebp),%ebx
movl %edx,(%ebx)
movl %ecx,4(%ebx)
fldl 8(%ebp)
fsubl -16(%ebp)
leal -20(%ebp),%esp
fclex
fldcw -4(%ebp)
fwait
popl %ebx
leave
ret
@@ -0,0 +1,23 @@
/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */
.global modfl;
modfl:
pushl %ebp
movl %esp,%ebp
subl $4,%esp
fldt 8(%ebp)
movl 20(%ebp),%eax
fnstcw -2(%ebp)
movw -2(%ebp),%dx
orb $0x0c,%dh
movw %dx,-4(%ebp)
fldcw -4(%ebp)
fld %st(0)
frndint
fldcw -2(%ebp)
fld %st(0)
fstpt (%eax)
fsubrp %st,%st(1)
leave
ret
@@ -0,0 +1,87 @@
/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */
.data
yint:
.word 0,0
pow.LCW1:
.word 0
pow.LCW2:
.word 0
.text
pow.LC0:
.double 0d1.0e+00
.global pow;
frac:
fstcw pow.LCW1
fstcw pow.LCW2
fwait
andw $0xf3ff,pow.LCW2
orw $0x0400,pow.LCW2
fldcw pow.LCW2
fldl %st(0)
frndint
fldcw pow.LCW1
fxch %st(1)
fsub %st(1),%st
ret
Lpow2:
call frac
f2xm1
faddl pow.LC0
fscale
fstp %st(1)
ret
pow:
fldl 12(%esp)
fldl 4(%esp)
ftst
fnstsw %ax
sahf
jbe xltez
fyl2x
jmp Lpow2
xltez:
jb xltz
fstp %st(0)
ftst
fnstsw %ax
sahf
ja ygtz
jb error
fstp %st(0)
fld1
fchs
error:
fsqrt
ret
ygtz:
fstp %st(0)
fldz
ret
xltz:
fabs
fxch %st(1)
call frac
ftst
fnstsw %ax
fstp %st(0)
sahf
je yisint
fstp %st(0)
fchs
jmp error
yisint:
fistl yint
fxch %st(1)
fyl2x
call Lpow2
andl $1,yint
jz yeven
fchs
yeven:
ret
@@ -0,0 +1,34 @@
/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */
.data
pow10.LCW1:
.word 0
pow10.LCW2:
.word 0
pow10.LC0:
.double 0d1.0e+00
.text
.global pow10;
pow10:
fldl 4(%esp)
fldl2t
fmulp
fstcw pow10.LCW1
fstcw pow10.LCW2
fwait
andw $0xf3ff,pow10.LCW2
orw $0x0400,pow10.LCW2
fldcw pow10.LCW2
fldl %st(0)
frndint
fldcw pow10.LCW1
fxch %st(1)
fsub %st(1),%st
f2xm1
faddl pow10.LC0
fscale
fstp %st(1)
ret
@@ -0,0 +1,32 @@
/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */
.data
pow2.LCW1:
.word 0
pow2.LCW2:
.word 0
pow2.LC0:
.double 0d1.0e+00
.text
.global pow2;
pow2:
fldl 4(%esp)
fstcw pow2.LCW1
fstcw pow2.LCW2
fwait
andw $0xf3ff,pow2.LCW2
orw $0x0400,pow2.LCW2
fldcw pow2.LCW2
fldl %st(0)
frndint
fldcw pow2.LCW1
fxch %st(1)
fsub %st(1),%st
f2xm1
faddl pow2.LC0
fscale
fstp %st(1)
ret
@@ -0,0 +1,18 @@
/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */
.global sin;
sin.L0:
.quad 0xffffffffffffffff
sin:
fldl 4(%esp)
fsin
fstsw
sahf
jnp sin.L1
fstp %st(0)
fldl L0
sin.L1:
ret
@@ -0,0 +1,16 @@
/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */
#include <math.h>
double sinh(double x)
{
if(x >= 0.0)
{
const double epos = exp(x);
return (epos - 1.0/epos) / 2.0;
}
else
{
const double eneg = exp(-x);
return (1.0/eneg - eneg) / 2.0;
}
}
@@ -0,0 +1,8 @@
/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */
.global sqrt;
sqrt:
fldl 4(%esp)
fsqrt
ret
@@ -0,0 +1,16 @@
/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */
tan.L0:
.quad 0xffffffffffffffff
tan:
fldl 4(%esp)
fptan
fstsw
fstp %st(0)
sahf
jnp tan.L1
/* fstp %st(0) - if exception, there is nothing on the stack */
fldl tan.L0
tan.L1:
ret
@@ -0,0 +1,17 @@
/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */
#include <math.h>
double tanh(double x)
{
if (x > 50)
return 1;
else if (x < -50)
return -1;
else
{
const double ebig = exp(x);
const double esmall = 1.0/ebig;
return (ebig - esmall) / (ebig + esmall);
}
}