added fmin, fma, fmax from glibc (ticket #5114).

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@34652 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Jérôme Duval 2009-12-13 14:22:13 +00:00
parent 63a275889b
commit d0c1951713
25 changed files with 727 additions and 1 deletions

View File

@ -0,0 +1,33 @@
/* Compute x * y + z as ternary operation.
Copyright (C) 1997, 2001 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Ulrich Drepper <drepper@cygnus.com>, 1997.
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 <math.h>
double
__fma (double x, double y, double z)
{
return (x * y) + z;
}
weak_alias (__fma, fma)
#ifdef NO_LONG_DOUBLE
strong_alias (__fma, __fmal)
weak_alias (__fmal, fmal)
#endif

View File

@ -0,0 +1,28 @@
/* Compute x * y + z as ternary operation.
Copyright (C) 1997 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Ulrich Drepper <drepper@cygnus.com>, 1997.
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 <math.h>
float
__fmaf (float x, float y, float z)
{
return (x * y) + z;
}
weak_alias (__fmaf, fmaf)

View File

@ -0,0 +1,28 @@
/* Compute x * y + z as ternary operation.
Copyright (C) 1997 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Ulrich Drepper <drepper@cygnus.com>, 1997.
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 <math.h>
long double
__fmal (long double x, long double y, long double z)
{
return (x * y) + z;
}
weak_alias (__fmal, fmal)

View File

@ -0,0 +1,33 @@
/* Return maximum numeric value of X and Y.
Copyright (C) 1997 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Ulrich Drepper <drepper@cygnus.com>, 1997.
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 <math.h>
double
__fmax (double x, double y)
{
return (isgreaterequal (x, y) || isnan (y)) ? x : y;
}
weak_alias (__fmax, fmax)
#ifdef NO_LONG_DOUBLE
strong_alias (__fmax, __fmaxl)
weak_alias (__fmax, fmaxl)
#endif

View File

@ -0,0 +1,29 @@
/* Return maximum numeric value of X and Y.
Copyright (C) 1997 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Ulrich Drepper <drepper@cygnus.com>, 1997.
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 <math.h>
float
__fmaxf (float x, float y)
{
return (isgreaterequal (x, y) || isnan (y)) ? x : y;
}
weak_alias (__fmaxf, fmaxf)

View File

@ -0,0 +1,29 @@
/* Return maximum numeric value of X and Y.
Copyright (C) 1997 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Ulrich Drepper <drepper@cygnus.com>, 1997.
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 <math.h>
long double
__fmaxl (long double x, long double y)
{
return (isgreaterequal (x, y) || isnan (y)) ? x : y;
}
weak_alias (__fmaxl, fmaxl)

View File

@ -0,0 +1,33 @@
/* Return minimum numeric value of X and Y.
Copyright (C) 1997 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Ulrich Drepper <drepper@cygnus.com>, 1997.
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 <math.h>
double
__fmin (double x, double y)
{
return (islessequal (x, y) || isnan (y)) ? x : y;
}
weak_alias (__fmin, fmin)
#ifdef NO_LONG_DOUBLE
strong_alias (__fmin, __fminl)
weak_alias (__fmin, fminl)
#endif

View File

@ -0,0 +1,29 @@
/* Return minimum numeric value of X and Y.
Copyright (C) 1997 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Ulrich Drepper <drepper@cygnus.com>, 1997.
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 <math.h>
float
__fminf (float x, float y)
{
return (islessequal (x, y) || isnan (y)) ? x : y;
}
weak_alias (__fminf, fminf)

View File

@ -0,0 +1,29 @@
/* Return minimum numeric value of X and Y.
Copyright (C) 1997 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Ulrich Drepper <drepper@cygnus.com>, 1997.
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 <math.h>
long double
__fminl (long double x, long double y)
{
return (islessequal (x, y) || isnan (y)) ? x : y;
}
weak_alias (__fminl, fminl)

View File

@ -72,6 +72,9 @@ local genericSources =
s_fabs.c s_fabsf.c # s_fabsl.S
s_finite.c s_finitef.c # s_finitel.c
s_floor.c s_floorf.c # s_floorl.c
s_fma.c s_fmaf.c # s_fmal.c
s_fmax.c s_fmaxf.c # s_fmaxl.c
s_fmin.c s_fminf.c # s_fminl.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

View File

@ -70,6 +70,7 @@ local genericSources =
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_fma.c s_fmaf.c # s_fmal.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
@ -135,8 +136,10 @@ MergeObject posix_gnu_arch_$(TARGET_ARCH)_other.o :
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_fdim.c s_fdimf.c # s_fdiml.S
s_fmax.S s_fmaxf.S # s_fmaxl.S
s_fmin.S s_fminf.S # s_fminl.S
s_isnan.c s_isnanf.S
s_rint.c s_rintf.c # s_rintl.c
t_sqrt.c

View File

@ -0,0 +1,43 @@
/* Floating-point maximum. PowerPC version.
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, write to the Free
Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
02111-1307 USA. */
#include <sysdep.h>
ENTRY(__fmax)
/* double [f1] fmax (double [f1] x, double [f2] y); */
fcmpu cr0,fp1,fp2
blt cr0,0f /* if x < y, neither x nor y can be NaN... */
bnulr+ cr0
/* x and y are unordered, so one of x or y must be a NaN... */
fcmpu cr1,fp2,fp2
bunlr cr1
0: fmr fp1,fp2
blr
END(__fmax)
weak_alias (__fmax,fmax)
/* It turns out that it's safe to use this code even for single-precision. */
strong_alias(__fmax,__fmaxf)
weak_alias (__fmax,fmaxf)
#ifdef NO_LONG_DOUBLE
weak_alias (__fmax,__fmaxl)
weak_alias (__fmax,fmaxl)
#endif

View File

@ -0,0 +1 @@
/* __fmaxf is in s_fmax.c */

View File

@ -0,0 +1,43 @@
/* Floating-point minimum. PowerPC version.
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, write to the Free
Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
02111-1307 USA. */
#include <sysdep.h>
ENTRY(__fmin)
/* double [f1] fmin (double [f1] x, double [f2] y); */
fcmpu cr0,fp1,fp2
bgt cr0,0f /* if x > y, neither x nor y can be NaN... */
bnulr+ cr0
/* x and y are unordered, so one of x or y must be a NaN... */
fcmpu cr1,fp2,fp2
bunlr cr1
0: fmr fp1,fp2
blr
END(__fmin)
weak_alias (__fmin,fmin)
/* It turns out that it's safe to use this code even for single-precision. */
strong_alias(__fmin,__fminf)
weak_alias (__fmin,fminf)
#ifdef NO_LONG_DOUBLE
weak_alias (__fmin,__fminl)
weak_alias (__fmin,fminl)
#endif

View File

@ -0,0 +1 @@
/* __fminf is in s_fmin.c */

View File

@ -149,6 +149,9 @@ MergeObject posix_gnu_arch_$(TARGET_ARCH)_s.o :
s_fabs.S s_fabsf.S s_fabsl.S
s_finite.S s_finitef.S s_finitel.S
s_floor.S s_floorf.S s_floorl.S
s_fma.S s_fmaf.S s_fmal.S
s_fmax.S s_fmaxf.S s_fmaxl.S
s_fmin.S s_fminf.S s_fminl.S
s_fpclassifyl.c
s_frexp.S s_frexpf.S s_frexpl.S
s_ilogb.S s_ilogbf.S

View File

@ -0,0 +1,31 @@
/* Compute (X * Y) + Z as ternary operation.
Copyright (C) 1997, 1998 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Ulrich Drepper <drepper@cygnus.com>, 1997.
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 <sysdep.h>
.text
ENTRY(__fma)
fldl 4(%esp) // x
fmull 12(%esp) // x * y
fldl 20(%esp) // z : x * y
faddp // (x * y) + z
ret
END(__fma)
weak_alias (__fma, fma)

View File

@ -0,0 +1,31 @@
/* Compute (X * Y) + Z as ternary operation.
Copyright (C) 1997 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Ulrich Drepper <drepper@cygnus.com>, 1997.
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 <sysdep.h>
.text
ENTRY(__fmaf)
flds 4(%esp) // x
fmuls 8(%esp) // x * y
flds 12(%esp) // z : x * y
faddp // (x * y) + z
ret
END(__fmaf)
weak_alias (__fmaf, fmaf)

View File

@ -0,0 +1,32 @@
/* Compute (X * Y) + Z as ternary operation.
Copyright (C) 1997 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Ulrich Drepper <drepper@cygnus.com>, 1997.
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 <sysdep.h>
.text
ENTRY(__fmal)
fldt 4(%esp) // x
fldt 16(%esp) // x : y
fmulp // x * y
fldt 28(%esp) // z : x * y
faddp // (x * y) + z
ret
END(__fmal)
weak_alias (__fmal, fmal)

View File

@ -0,0 +1,44 @@
/* Compute maximum of two numbers, regarding NaN as missing argument.
Copyright (C) 1997 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Ulrich Drepper <drepper@cygnus.com>, 1997.
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 <sysdep.h>
.text
ENTRY(__fmax)
fldl 12(%esp) // y
fxam
fnstsw
fldl 4(%esp) // y : x
andb $0x45, %ah
cmpb $0x01, %ah
je 1f // y == NaN
fucom %st(1)
fnstsw
sahf
jnc 1f
fxch %st(1)
1: fstp %st(1)
ret
END(__fmax)
weak_alias (__fmax, fmax)

View File

@ -0,0 +1,44 @@
/* Compute maximum of two numbers, regarding NaN as missing argument.
Copyright (C) 1997 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Ulrich Drepper <drepper@cygnus.com>, 1997.
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 <sysdep.h>
.text
ENTRY(__fmaxf)
flds 8(%esp) // y
fxam
fnstsw
flds 4(%esp) // y : x
andb $0x45, %ah
cmpb $0x01, %ah
je 1f // y == NaN
fucom %st(1)
fnstsw
sahf
jnc 1f
fxch %st(1)
1: fstp %st(1)
ret
END(__fmaxf)
weak_alias (__fmaxf, fmaxf)

View File

@ -0,0 +1,44 @@
/* Compute maximum of two numbers, regarding NaN as missing argument.
Copyright (C) 1997 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Ulrich Drepper <drepper@cygnus.com>, 1997.
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 <sysdep.h>
.text
ENTRY(__fmaxl)
fldt 16(%esp) // y
fxam
fnstsw
fldt 4(%esp) // y : x
andb $0x45, %ah
cmpb $0x01, %ah
je 1f // y == NaN
fucom %st(1)
fnstsw
sahf
jnc 1f
fxch %st(1)
1: fstp %st(1)
ret
END(__fmaxl)
weak_alias (__fmaxl, fmaxl)

View File

@ -0,0 +1,44 @@
/* Compute minimum of two numbers, regarding NaN as missing argument.
Copyright (C) 1997 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Ulrich Drepper <drepper@cygnus.com>, 1997.
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 <sysdep.h>
.text
ENTRY(__fmin)
fldl 4(%esp) // x
fldl 12(%esp) // x : y
fxam
fnstsw
andb $0x45, %ah
cmpb $0x01, %ah
je 1f // y == NaN
fucom %st(1)
fnstsw
sahf
jc 2f
1: fxch %st(1)
2: fstp %st(1)
ret
END(__fmin)
weak_alias (__fmin, fmin)

View File

@ -0,0 +1,44 @@
/* Compute minimum of two numbers, regarding NaN as missing argument.
Copyright (C) 1997 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Ulrich Drepper <drepper@cygnus.com>, 1997.
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 <sysdep.h>
.text
ENTRY(__fminf)
flds 4(%esp) // x
flds 8(%esp) // x : y
fxam
fnstsw
andb $0x45, %ah
cmpb $0x01, %ah
je 1f // y == NaN
fucom %st(1)
fnstsw
sahf
jc 2f
1: fxch %st(1)
2: fstp %st(1)
ret
END(__fminf)
weak_alias (__fminf, fminf)

View File

@ -0,0 +1,44 @@
/* Compute minimum of two numbers, regarding NaN as missing argument.
Copyright (C) 1997 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Ulrich Drepper <drepper@cygnus.com>, 1997.
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 <sysdep.h>
.text
ENTRY(__fminl)
fldt 4(%esp) // x
fldt 16(%esp) // x : y
fxam
fnstsw
andb $0x45, %ah
cmpb $0x01, %ah
je 1f // y == NaN
fucom %st(1)
fnstsw
sahf
jc 2f
1: fxch %st(1)
2: fstp %st(1)
ret
END(__fminl)
weak_alias (__fminl, fminl)