mirror of
https://github.com/UpsilonNumworks/Upsilon.git
synced 2026-01-18 16:27:34 +01:00
[liba] Add fmax in math.h header
This commit is contained in:
@@ -60,6 +60,7 @@ objs += $(addprefix liba/src/external/openbsd/, \
|
||||
s_erf.o \
|
||||
s_expm1f.o\
|
||||
s_fabsf.o \
|
||||
s_fmaxf.o \
|
||||
s_floorf.o \
|
||||
s_frexpf.o \
|
||||
s_frexp.o \
|
||||
@@ -107,6 +108,7 @@ objs += $(addprefix liba/src/external/openbsd/, \
|
||||
s_cos.o \
|
||||
s_expm1.o \
|
||||
s_fabs.o \
|
||||
s_fmax.o \
|
||||
s_floor.o \
|
||||
s_log1p.o \
|
||||
s_round.o \
|
||||
|
||||
@@ -57,6 +57,7 @@ float coshf(float x);
|
||||
float expf(float x);
|
||||
float expm1f(float x);
|
||||
float fabsf(float x);
|
||||
float fmaxf(float x, float y);
|
||||
float floorf(float x);
|
||||
float fmodf(float x, float y);
|
||||
float frexpf(float x, int *eptr);
|
||||
@@ -95,6 +96,7 @@ double erfc(double x);
|
||||
double exp(double x);
|
||||
double expm1(double x);
|
||||
double fabs(double x);
|
||||
double fmax(double x, double y);
|
||||
double floor(double x);
|
||||
double fmod(double x, double y);
|
||||
double frexp(double x, int *eptr);
|
||||
|
||||
55
liba/src/external/openbsd/s_fmax.c
vendored
Normal file
55
liba/src/external/openbsd/s_fmax.c
vendored
Normal file
@@ -0,0 +1,55 @@
|
||||
/* $OpenBSD: s_fmax.c,v 1.4 2008/12/10 01:08:24 martynas Exp $ */
|
||||
/*-
|
||||
* Copyright (c) 2004 David Schultz <das@FreeBSD.ORG>
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
#include <float.h>
|
||||
#include <math.h>
|
||||
|
||||
double
|
||||
fmax(double x, double y)
|
||||
{
|
||||
/* Check for NaNs to avoid raising spurious exceptions. */
|
||||
if (isnan(x))
|
||||
return (y);
|
||||
if (isnan(y))
|
||||
return (x);
|
||||
|
||||
/* Handle comparisons of signed zeroes. */
|
||||
if (signbit(x) != signbit(y))
|
||||
if (signbit(x))
|
||||
return (y);
|
||||
else
|
||||
return (x);
|
||||
|
||||
return (x > y ? x : y);
|
||||
}
|
||||
|
||||
#if LDBL_MANT_DIG == 53
|
||||
#ifdef __weak_alias
|
||||
__weak_alias(fmaxl, fmax);
|
||||
#endif /* __weak_alias */
|
||||
#endif /* LDBL_MANT_DIG == 53 */
|
||||
47
liba/src/external/openbsd/s_fmaxf.c
vendored
Normal file
47
liba/src/external/openbsd/s_fmaxf.c
vendored
Normal file
@@ -0,0 +1,47 @@
|
||||
/* $OpenBSD: s_fmaxf.c,v 1.2 2008/09/11 19:18:12 martynas Exp $ */
|
||||
/*-
|
||||
* Copyright (c) 2004 David Schultz <das@FreeBSD.ORG>
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include <math.h>
|
||||
|
||||
float
|
||||
fmaxf(float x, float y)
|
||||
{
|
||||
/* Check for NaNs to avoid raising spurious exceptions. */
|
||||
if (isnan(x))
|
||||
return (y);
|
||||
if (isnan(y))
|
||||
return (x);
|
||||
|
||||
/* Handle comparisons of signed zeroes. */
|
||||
if (signbit(x) != signbit(y))
|
||||
if (signbit(x))
|
||||
return (y);
|
||||
else
|
||||
return (x);
|
||||
|
||||
return (x > y ? x : y);
|
||||
}
|
||||
@@ -23,6 +23,7 @@
|
||||
#undef expf
|
||||
#undef expm1f
|
||||
#undef fabsf
|
||||
#undef fmaxf
|
||||
#undef floorf
|
||||
#undef fmodf
|
||||
#undef hypotf
|
||||
@@ -57,6 +58,7 @@
|
||||
#undef exp
|
||||
#undef expm1
|
||||
#undef fabs
|
||||
#undef fmax
|
||||
#undef floor
|
||||
#undef hypot
|
||||
#undef lgamma
|
||||
@@ -102,6 +104,8 @@ static inline double exp(double x) { return __builtin_exp(x); }
|
||||
static inline float exp(float x) { return __builtin_expf(x); }
|
||||
static inline double fabs(double x) { return __builtin_fabs(x); }
|
||||
static inline float fabs(float x) { return __builtin_fabsf(x); }
|
||||
static inline double fmax(double x, double y) { return __builtin_fmax(x, y); }
|
||||
static inline float fmax(float x, float y) { return __builtin_fmaxf(x, y); }
|
||||
static inline double floor(double x) { return __builtin_floor(x); }
|
||||
static inline float floor(float x) { return __builtin_floorf(x); }
|
||||
static inline int fpclassify(double x) { return __builtin_fpclassify(FP_NAN, FP_INFINITE, FP_NORMAL, FP_SUBNORMAL, FP_ZERO, x); }
|
||||
|
||||
Reference in New Issue
Block a user