Fixes math library compiling on msvc (#4511)
JerryScript-DCO-1.0-Signed-off-by: Yonggang Luo luoyonggang@gmail.com
This commit is contained in:
@@ -18,11 +18,11 @@ project (${JERRY_MATH_NAME} C)
|
|||||||
|
|
||||||
# Compiler / linker flags
|
# Compiler / linker flags
|
||||||
# TODO: Reduce the below list of warning/error disablings as much as possible
|
# TODO: Reduce the below list of warning/error disablings as much as possible
|
||||||
set(COMPILE_FLAGS_MATH "${COMPILE_FLAGS_MATH} -Wno-error=sign-compare")
|
set(COMPILE_FLAGS_MATH_GCC_CLANG "${COMPILE_FLAGS_MATH_GCC_CLANG} -Wno-error=sign-compare")
|
||||||
set(COMPILE_FLAGS_MATH "${COMPILE_FLAGS_MATH} -Wno-error=sign-conversion")
|
set(COMPILE_FLAGS_MATH_GCC_CLANG "${COMPILE_FLAGS_MATH_GCC_CLANG} -Wno-error=sign-conversion")
|
||||||
set(COMPILE_FLAGS_MATH "${COMPILE_FLAGS_MATH} -Wno-sign-conversion")
|
set(COMPILE_FLAGS_MATH_GCC_CLANG "${COMPILE_FLAGS_MATH_GCC_CLANG} -Wno-sign-conversion")
|
||||||
set(COMPILE_FLAGS_MATH "${COMPILE_FLAGS_MATH} -Wno-sign-compare")
|
set(COMPILE_FLAGS_MATH_GCC_CLANG "${COMPILE_FLAGS_MATH_GCC_CLANG} -Wno-sign-compare")
|
||||||
set(COMPILE_FLAGS_MATH "${COMPILE_FLAGS_MATH} -Wno-strict-aliasing")
|
set(COMPILE_FLAGS_MATH_GCC_CLANG "${COMPILE_FLAGS_MATH_GCC_CLANG} -Wno-strict-aliasing")
|
||||||
|
|
||||||
# Include directories
|
# Include directories
|
||||||
set(INCLUDE_MATH "${CMAKE_CURRENT_SOURCE_DIR}/include")
|
set(INCLUDE_MATH "${CMAKE_CURRENT_SOURCE_DIR}/include")
|
||||||
@@ -85,9 +85,10 @@ if(ENABLE_AMALGAM)
|
|||||||
endif()
|
endif()
|
||||||
|
|
||||||
add_library(${JERRY_MATH_NAME} ${SOURCE_MATH})
|
add_library(${JERRY_MATH_NAME} ${SOURCE_MATH})
|
||||||
set_property(TARGET ${JERRY_MATH_NAME}
|
if(USING_GCC OR USING_CLANG)
|
||||||
PROPERTY COMPILE_FLAGS "${COMPILE_FLAGS_MATH}")
|
set_property(TARGET ${JERRY_MATH_NAME}
|
||||||
|
PROPERTY COMPILE_FLAGS "${COMPILE_FLAGS_MATH_GCC_CLANG}")
|
||||||
|
endif()
|
||||||
target_include_directories(${JERRY_MATH_NAME} PUBLIC ${INCLUDE_MATH})
|
target_include_directories(${JERRY_MATH_NAME} PUBLIC ${INCLUDE_MATH})
|
||||||
|
|
||||||
configure_file(libjerry-math.pc.in libjerry-math.pc @ONLY)
|
configure_file(libjerry-math.pc.in libjerry-math.pc @ONLY)
|
||||||
|
|||||||
+6
-1
@@ -265,7 +265,12 @@ expm1 (double x)
|
|||||||
y = one - (e - x);
|
y = one - (e - x);
|
||||||
if (k == 1024)
|
if (k == 1024)
|
||||||
{
|
{
|
||||||
y = y * 2.0 * 0x1p1023;
|
const double twop1023 = ((double_accessor)
|
||||||
|
{
|
||||||
|
.as_int = { .hi = 0x7fe00000, .lo = 0 }
|
||||||
|
}
|
||||||
|
).dbl; /* 0x1p1023 */
|
||||||
|
y = y * 2.0 * twop1023;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -22,9 +22,14 @@ extern "C"
|
|||||||
#endif /* __cplusplus */
|
#endif /* __cplusplus */
|
||||||
|
|
||||||
/* General Constants. */
|
/* General Constants. */
|
||||||
#define INFINITY (1.0/0.0)
|
#ifdef _MSC_VER
|
||||||
#define NAN (0.0/0.0)
|
#define INFINITY ((float) (1e+300 * 1e+300)) /* 1e+300*1e+300 must overflow */
|
||||||
#define HUGE_VAL INFINITY
|
#define NAN ((float) (INFINITY * 0.0f))
|
||||||
|
#else /* !_MSC_VER */
|
||||||
|
#define INFINITY ((float) (1.0 / 0.0))
|
||||||
|
#define NAN ((float) (0.0 / 0.0))
|
||||||
|
#endif /* _MSC_VER */
|
||||||
|
#define HUGE_VAL ((double) INFINITY)
|
||||||
|
|
||||||
#define isnan(x) ((x) != (x))
|
#define isnan(x) ((x) != (x))
|
||||||
#define isinf(x) ((x) == INFINITY ? 1 : (x) == -INFINITY ? -1 : 0)
|
#define isinf(x) ((x) == INFINITY ? 1 : (x) == -INFINITY ? -1 : 0)
|
||||||
|
|||||||
@@ -38,8 +38,10 @@
|
|||||||
#if (defined (i386) || defined (__i386) || defined (__i386__) || \
|
#if (defined (i386) || defined (__i386) || defined (__i386__) || \
|
||||||
defined (i486) || defined (__i486) || defined (__i486__) || \
|
defined (i486) || defined (__i486) || defined (__i486__) || \
|
||||||
defined (intel) || defined (x86) || defined (i86pc) || \
|
defined (intel) || defined (x86) || defined (i86pc) || \
|
||||||
|
defined (_M_IX86) || defined (_M_AMD64) || defined (_M_X64) || \
|
||||||
defined (__alpha) || defined (__osf__) || \
|
defined (__alpha) || defined (__osf__) || \
|
||||||
defined (__x86_64__) || defined (__arm__) || defined (__aarch64__) || \
|
defined (__x86_64__) || defined (__arm__) || defined (__aarch64__) || \
|
||||||
|
defined (_M_ARM) || defined (_M_ARM64) || \
|
||||||
defined (__xtensa__) || defined (__MIPSEL)) || \
|
defined (__xtensa__) || defined (__MIPSEL)) || \
|
||||||
(defined (__BYTE_ORDER__) && (__BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__))
|
(defined (__BYTE_ORDER__) && (__BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__))
|
||||||
#define __LITTLE_ENDIAN
|
#define __LITTLE_ENDIAN
|
||||||
@@ -74,8 +76,14 @@ typedef union
|
|||||||
#endif /* __LITTLE_ENDIAN */
|
#endif /* __LITTLE_ENDIAN */
|
||||||
|
|
||||||
#ifndef NAN
|
#ifndef NAN
|
||||||
#define NAN (0.0/0.0)
|
#ifdef _MSC_VER
|
||||||
#endif
|
#define INFINITY ((float) (1e+300 * 1e+300)) /* 1e+300*1e+300 must overflow */
|
||||||
|
#define NAN ((float) (INFINITY * 0.0f))
|
||||||
|
#else /* !_MSC_VER */
|
||||||
|
#define INFINITY ((float) (1.0 / 0.0))
|
||||||
|
#define NAN ((float) (0.0 / 0.0))
|
||||||
|
#endif /* _MSC_VER */
|
||||||
|
#endif /* !NAN */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* ANSI/POSIX
|
* ANSI/POSIX
|
||||||
|
|||||||
+2
-2
@@ -105,11 +105,11 @@ log (double x)
|
|||||||
{
|
{
|
||||||
if (((hx & 0x7fffffff) | lx) == 0) /* log(+-0) = -inf */
|
if (((hx & 0x7fffffff) | lx) == 0) /* log(+-0) = -inf */
|
||||||
{
|
{
|
||||||
return -two54 / zero;
|
return -INFINITY;
|
||||||
}
|
}
|
||||||
if (hx < 0) /* log(-#) = NaN */
|
if (hx < 0) /* log(-#) = NaN */
|
||||||
{
|
{
|
||||||
return (x - x) / zero;
|
return NAN;
|
||||||
}
|
}
|
||||||
k -= 54;
|
k -= 54;
|
||||||
x *= two54; /* subnormal number, scale up x */
|
x *= two54; /* subnormal number, scale up x */
|
||||||
|
|||||||
+2
-2
@@ -84,12 +84,12 @@ log10 (double x)
|
|||||||
if (((hx & 0x7fffffff) | lx) == 0)
|
if (((hx & 0x7fffffff) | lx) == 0)
|
||||||
{
|
{
|
||||||
/* log(+-0)=-inf */
|
/* log(+-0)=-inf */
|
||||||
return -two54 / zero;
|
return -INFINITY;
|
||||||
}
|
}
|
||||||
if (hx < 0)
|
if (hx < 0)
|
||||||
{
|
{
|
||||||
/* log(-#) = NaN */
|
/* log(-#) = NaN */
|
||||||
return (x - x) / zero;
|
return NAN;
|
||||||
}
|
}
|
||||||
k -= 54;
|
k -= 54;
|
||||||
x *= two54; /* subnormal number, scale up x */
|
x *= two54; /* subnormal number, scale up x */
|
||||||
|
|||||||
+1
-1
@@ -122,7 +122,7 @@ log1p (double x)
|
|||||||
if (x == -1.0)
|
if (x == -1.0)
|
||||||
{
|
{
|
||||||
/* log1p(-1) = -inf */
|
/* log1p(-1) = -inf */
|
||||||
return -two54 / zero;
|
return -INFINITY;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|||||||
+2
-2
@@ -65,11 +65,11 @@ log2 (double x)
|
|||||||
{ /* x < 2**-1022 */
|
{ /* x < 2**-1022 */
|
||||||
if (((hx & 0x7fffffff) | lx) == 0)
|
if (((hx & 0x7fffffff) | lx) == 0)
|
||||||
{
|
{
|
||||||
return -two54 / zero; /* log(+-0)=-inf */
|
return -INFINITY; /* log(+-0)=-inf */
|
||||||
}
|
}
|
||||||
if (hx < 0)
|
if (hx < 0)
|
||||||
{
|
{
|
||||||
return (x - x) / zero; /* log(-#) = NaN */
|
return NAN; /* log(-#) = NaN */
|
||||||
}
|
}
|
||||||
k -= 54;
|
k -= 54;
|
||||||
x *= two54; /* subnormal number, scale up x */
|
x *= two54; /* subnormal number, scale up x */
|
||||||
|
|||||||
Reference in New Issue
Block a user