From 3ba286f3e1b9239b513381dd4dde54da14e1202d Mon Sep 17 00:00:00 2001 From: Akos Kiss Date: Wed, 6 Apr 2016 18:02:44 +0200 Subject: [PATCH] Turn modified fdlibm into Jerry's own libm * Rename modified fdlibm to jerry-libm * Move third-party/fdlibm to jerry-libm * Rename original fdlibm.h to jerry-libm-internal.h * And remove it from the public headers. * Rename jerry-libm's public header to math.h * This also makes jerry-core sources include ``. Therefore, should anyone want to use a different libm implementation with jerry, it becomes possible. (The same way as we provide a minimal libc with standard headers, but should it be insufficient or conflicting for someone, it can be replaced.) * Drop `s_` prefix from jerry-libm sources * The original fdlibm implementation had various prefixes (e.g., `k_` for sources of kernel routines, and `w_` for wrapper routines), but after the specialization of fdlibm to jerry, only `s_` remained. Since it does not encode anything anymore, it can be dropped. * Stylistic edits to jerry-libm's CMakeLists * Align project name with other CMakeLists in the code base * Move Jerry-LibM under Apache License * Using the same approach as was used by linux-wireless when ath5k driver license needed clarification. Solution was proposed by SFLC. External mail for future reference: http://lwn.net/Articles/247806/ * Tests & checks * Remove FD from the name of libm unit test-related files * Make vera++ and cppcheck check jerry-libm * Targets * Speculative update of targets to use jerry-libm JerryScript-DCO-1.0-Signed-off-by: Akos Kiss akiss@inf.u-szeged.hu --- CMakeLists.txt | 21 +++-- jerry-core/CMakeLists.txt | 2 +- .../ecma-builtin-date-prototype.c | 3 +- .../ecma-builtin-helpers-date.c | 3 +- .../ecma/builtin-objects/ecma-builtin-math.c | 3 +- .../ecma-builtin-number-prototype.c | 3 +- jerry-libm/CMakeLists.txt | 77 +++++++++++++++++++ .../fdlibm/s_acos.c => jerry-libm/acos.c | 39 +++++++--- .../fdlibm/s_asin.c => jerry-libm/asin.c | 39 +++++++--- .../fdlibm/s_atan.c => jerry-libm/atan.c | 39 +++++++--- .../fdlibm/s_atan2.c => jerry-libm/atan2.c | 39 +++++++--- .../fdlibm/s_ceil.c => jerry-libm/ceil.c | 39 +++++++--- jerry-libm/copysign.c | 40 ++++++++++ .../fdlibm/s_exp.c => jerry-libm/exp.c | 37 ++++++--- jerry-libm/fabs.c | 39 ++++++++++ jerry-libm/finite.c | 42 ++++++++++ .../fdlibm/s_floor.c => jerry-libm/floor.c | 39 +++++++--- .../fdlibm/s_fmod.c => jerry-libm/fmod.c | 39 +++++++--- .../include/math.h | 6 +- jerry-libm/isnan.c | 45 +++++++++++ .../jerry-libm-internal.h | 60 +++++++-------- .../fdlibm/s_log.c => jerry-libm/log.c | 39 +++++++--- .../fdlibm/s_pow.c => jerry-libm/pow.c | 37 ++++++--- .../fdlibm/s_scalbn.c => jerry-libm/scalbn.c | 39 +++++++--- .../fdlibm/s_sqrt.c => jerry-libm/sqrt.c | 39 +++++++--- .../fdlibm/s_trig.c => jerry-libm/trig.c | 51 +++++++----- targets/esp8266/Makefile | 6 +- targets/esp8266/Makefile.esp8266 | 5 +- .../esp8266/docs/ESP-PATCHFORJERRYSCRIPT.md | 2 +- targets/mbedk64f/Makefile.mbedk64f | 2 +- targets/mbedk64f/readme.md | 2 +- targets/mbedk64f/source/makejerry.cmake | 4 +- targets/nuttx-stm32f4/Makefile.nuttx | 3 +- targets/nuttx-stm32f4/README.md | 2 +- tests/unit/test-common.h | 4 +- tests/unit/{test-fdlibm.c => test-libm.c} | 4 +- .../{test-fdlibm.inc.h => test-libm.inc.h} | 2 +- third-party/fdlibm/CMakeLists.txt | 76 ------------------ third-party/fdlibm/s_copysign.c | 25 ------ third-party/fdlibm/s_fabs.c | 24 ------ third-party/fdlibm/s_finite.c | 27 ------- third-party/fdlibm/s_isnan.c | 30 -------- tools/check-cppcheck.sh | 5 +- tools/check-vera.sh | 3 +- tools/cppcheck/suppressions-list | 5 +- .../{gen-test-fdlibm.sh => gen-test-libm.sh} | 2 +- tools/unit-tests/Makefile | 4 +- .../{gen-test-fdlibm.c => gen-test-libm.c} | 16 ++-- 48 files changed, 686 insertions(+), 426 deletions(-) create mode 100644 jerry-libm/CMakeLists.txt rename third-party/fdlibm/s_acos.c => jerry-libm/acos.c (74%) rename third-party/fdlibm/s_asin.c => jerry-libm/asin.c (76%) rename third-party/fdlibm/s_atan.c => jerry-libm/atan.c (78%) rename third-party/fdlibm/s_atan2.c => jerry-libm/atan2.c (78%) rename third-party/fdlibm/s_ceil.c => jerry-libm/ceil.c (60%) create mode 100644 jerry-libm/copysign.c rename third-party/fdlibm/s_exp.c => jerry-libm/exp.c (83%) create mode 100644 jerry-libm/fabs.c create mode 100644 jerry-libm/finite.c rename third-party/fdlibm/s_floor.c => jerry-libm/floor.c (60%) rename third-party/fdlibm/s_fmod.c => jerry-libm/fmod.c (76%) rename third-party/fdlibm/include/fdlibm-math.h => jerry-libm/include/math.h (96%) create mode 100644 jerry-libm/isnan.c rename third-party/fdlibm/include/fdlibm.h => jerry-libm/jerry-libm-internal.h (54%) rename third-party/fdlibm/s_log.c => jerry-libm/log.c (80%) rename third-party/fdlibm/s_pow.c => jerry-libm/pow.c (91%) rename third-party/fdlibm/s_scalbn.c => jerry-libm/scalbn.c (55%) rename third-party/fdlibm/s_sqrt.c => jerry-libm/sqrt.c (93%) rename third-party/fdlibm/s_trig.c => jerry-libm/trig.c (95%) rename tests/unit/{test-fdlibm.c => test-libm.c} (97%) rename tests/unit/{test-fdlibm.inc.h => test-libm.inc.h} (99%) delete mode 100644 third-party/fdlibm/CMakeLists.txt delete mode 100644 third-party/fdlibm/s_copysign.c delete mode 100644 third-party/fdlibm/s_fabs.c delete mode 100644 third-party/fdlibm/s_finite.c delete mode 100644 third-party/fdlibm/s_isnan.c rename tools/{gen-test-fdlibm.sh => gen-test-libm.sh} (91%) rename tools/unit-tests/{gen-test-fdlibm.c => gen-test-libm.c} (98%) diff --git a/CMakeLists.txt b/CMakeLists.txt index 12c002dae..78c25f6fd 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -37,9 +37,8 @@ project (Jerry C ASM) endif() -# Imported and third-party targets prefix +# Imported targets prefix set(PREFIX_IMPORTED_LIB imported_) - set(SUFFIX_THIRD_PARTY_LIB .third_party.lib) # Architecture-specific compile/link flags foreach(FLAG ${FLAGS_COMMON_ARCH}) @@ -372,8 +371,8 @@ endif() add_subdirectory(jerry-libc) endif() - # Jerry's fdlibm - add_subdirectory(third-party/fdlibm) + # Jerry's libm + add_subdirectory(jerry-libm) # Jerry's Core add_subdirectory(jerry-core) @@ -394,7 +393,7 @@ endif() set(CORE_TARGET_NAME ${CORE_TARGET_NAME}${MODIFIER_SUFFIX_${MODIFIER}}) endforeach() - set(FDLIBM_TARGET_NAME ${CORE_TARGET_NAME}.jerry-fdlibm${SUFFIX_THIRD_PARTY_LIB}) + set(LIBM_TARGET_NAME ${CORE_TARGET_NAME}.jerry-libm.lib) set(CORE_TARGET_NAME ${CORE_TARGET_NAME}.jerry-core) set(DEFINES_JERRY ) @@ -425,10 +424,10 @@ endif() target_include_directories(${TARGET_NAME} SYSTEM PRIVATE ${INCLUDE_EXTERNAL_LIBS_INTERFACE}) if(("${PLATFORM}" STREQUAL "DARWIN") AND (NOT (CMAKE_COMPILER_IS_GNUCC))) target_link_libraries(${TARGET_NAME} ${CORE_TARGET_NAME} ${LIBC_TARGET_NAME} - ${FDLIBM_TARGET_NAME} ${PREFIX_IMPORTED_LIB}libclang_rt.osx) + ${LIBM_TARGET_NAME} ${PREFIX_IMPORTED_LIB}libclang_rt.osx) else() target_link_libraries(${TARGET_NAME} ${CORE_TARGET_NAME} ${LIBC_TARGET_NAME} - ${FDLIBM_TARGET_NAME} ${PREFIX_IMPORTED_LIB}libgcc) + ${LIBM_TARGET_NAME} ${PREFIX_IMPORTED_LIB}libgcc) endif() if("${PLATFORM}" STREQUAL "MCU") @@ -454,7 +453,7 @@ endif() add_custom_command(TARGET ${TARGET_NAME} POST_BUILD COMMAND mkdir -p ${CMAKE_BINARY_DIR}/${TARGET_NAME} - COMMAND echo $ > ${CMAKE_BINARY_DIR}/${TARGET_NAME}/list + COMMAND echo $ > ${CMAKE_BINARY_DIR}/${TARGET_NAME}/list COMMAND echo $ >> ${CMAKE_BINARY_DIR}/${TARGET_NAME}/list) if(DEFINED EXTERNAL_BUILD_ENTRY_FILE) @@ -499,7 +498,7 @@ endif() if (${USE_JERRY_LIBC}) set(LIBC_TARGET_NAME unittests.jerry-libc.${PLATFORM_L}.lib) endif () - set(FDLIBM_TARGET_NAME unittests.jerry-fdlibm${SUFFIX_THIRD_PARTY_LIB}) + set(LIBM_TARGET_NAME unittests.jerry-libm.lib) add_executable(${TARGET_NAME} ${SOURCE_UNIT_TEST_MAIN}) set_property(TARGET ${TARGET_NAME} @@ -510,10 +509,10 @@ endif() target_include_directories(${TARGET_NAME} SYSTEM PRIVATE ${INCLUDE_LIBC_INTERFACE}) if(("${PLATFORM}" STREQUAL "DARWIN") AND (NOT (CMAKE_COMPILER_IS_GNUCC))) - target_link_libraries(${TARGET_NAME} ${CORE_TARGET_NAME} ${LIBC_TARGET_NAME} ${FDLIBM_TARGET_NAME} + target_link_libraries(${TARGET_NAME} ${CORE_TARGET_NAME} ${LIBC_TARGET_NAME} ${LIBM_TARGET_NAME} ${PREFIX_IMPORTED_LIB}libclang_rt.osx) else() - target_link_libraries(${TARGET_NAME} ${CORE_TARGET_NAME} ${LIBC_TARGET_NAME} ${FDLIBM_TARGET_NAME} + target_link_libraries(${TARGET_NAME} ${CORE_TARGET_NAME} ${LIBC_TARGET_NAME} ${LIBM_TARGET_NAME} ${PREFIX_IMPORTED_LIB}libgcc) endif() diff --git a/jerry-core/CMakeLists.txt b/jerry-core/CMakeLists.txt index 5a89e206b..89cdece55 100644 --- a/jerry-core/CMakeLists.txt +++ b/jerry-core/CMakeLists.txt @@ -225,7 +225,7 @@ project (JerryCore C ASM) PROPERTY COMPILE_FLAGS "${COMPILE_FLAGS_JERRY} ${C_FLAGS_JERRY} ${FLAGS_COMMON_${BUILD_MODE}}") target_compile_definitions(${TARGET_NAME}.jerry-core PRIVATE ${DEFINES_JERRY}) target_include_directories(${TARGET_NAME}.jerry-core PRIVATE ${INCLUDE_CORE}) - target_include_directories(${TARGET_NAME}.jerry-core PRIVATE ${INCLUDE_FDLIBM}) + target_include_directories(${TARGET_NAME}.jerry-core PRIVATE ${INCLUDE_LIBM}) target_include_directories(${TARGET_NAME}.jerry-core SYSTEM PRIVATE ${INCLUDE_LIBC_INTERFACE}) target_include_directories(${TARGET_NAME}.jerry-core SYSTEM PRIVATE ${INCLUDE_EXTERNAL_LIBS_INTERFACE}) diff --git a/jerry-core/ecma/builtin-objects/ecma-builtin-date-prototype.c b/jerry-core/ecma/builtin-objects/ecma-builtin-date-prototype.c index 3075703e4..8e4da2765 100644 --- a/jerry-core/ecma/builtin-objects/ecma-builtin-date-prototype.c +++ b/jerry-core/ecma/builtin-objects/ecma-builtin-date-prototype.c @@ -14,6 +14,8 @@ * limitations under the License. */ +#include + #include "ecma-alloc.h" #include "ecma-builtin-helpers.h" #include "ecma-exceptions.h" @@ -22,7 +24,6 @@ #include "ecma-helpers.h" #include "ecma-objects.h" #include "ecma-try-catch-macro.h" -#include "fdlibm-math.h" #ifndef CONFIG_ECMA_COMPACT_PROFILE_DISABLE_DATE_BUILTIN diff --git a/jerry-core/ecma/builtin-objects/ecma-builtin-helpers-date.c b/jerry-core/ecma/builtin-objects/ecma-builtin-helpers-date.c index 10069afc0..20ef8e272 100644 --- a/jerry-core/ecma/builtin-objects/ecma-builtin-helpers-date.c +++ b/jerry-core/ecma/builtin-objects/ecma-builtin-helpers-date.c @@ -14,6 +14,8 @@ * limitations under the License. */ +#include + #include "ecma-alloc.h" #include "ecma-builtin-helpers.h" #include "ecma-exceptions.h" @@ -21,7 +23,6 @@ #include "ecma-helpers.h" #include "ecma-objects.h" #include "ecma-try-catch-macro.h" -#include "fdlibm-math.h" #include "lit-char-helpers.h" #ifndef CONFIG_ECMA_COMPACT_PROFILE_DISABLE_DATE_BUILTIN diff --git a/jerry-core/ecma/builtin-objects/ecma-builtin-math.c b/jerry-core/ecma/builtin-objects/ecma-builtin-math.c index 2e397e406..c30400ab9 100644 --- a/jerry-core/ecma/builtin-objects/ecma-builtin-math.c +++ b/jerry-core/ecma/builtin-objects/ecma-builtin-math.c @@ -14,6 +14,8 @@ * limitations under the License. */ +#include + #include "ecma-alloc.h" #include "ecma-builtins.h" #include "ecma-conversion.h" @@ -25,7 +27,6 @@ #include "ecma-objects.h" #include "ecma-objects-general.h" #include "ecma-try-catch-macro.h" -#include "fdlibm-math.h" #include "jrt.h" #include "jrt-libc-includes.h" diff --git a/jerry-core/ecma/builtin-objects/ecma-builtin-number-prototype.c b/jerry-core/ecma/builtin-objects/ecma-builtin-number-prototype.c index de8f87079..09fdaee20 100644 --- a/jerry-core/ecma/builtin-objects/ecma-builtin-number-prototype.c +++ b/jerry-core/ecma/builtin-objects/ecma-builtin-number-prototype.c @@ -14,6 +14,8 @@ * limitations under the License. */ +#include + #include "ecma-alloc.h" #include "ecma-builtins.h" #include "ecma-conversion.h" @@ -24,7 +26,6 @@ #include "ecma-objects.h" #include "ecma-string-object.h" #include "ecma-try-catch-macro.h" -#include "fdlibm-math.h" #include "jrt.h" #include "jrt-libc-includes.h" diff --git a/jerry-libm/CMakeLists.txt b/jerry-libm/CMakeLists.txt new file mode 100644 index 000000000..6500e2f9c --- /dev/null +++ b/jerry-libm/CMakeLists.txt @@ -0,0 +1,77 @@ +# Copyright 2015-2016 Samsung Electronics Co., Ltd. +# Copyright 2015-2016 University of Szeged. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +cmake_minimum_required (VERSION 2.8.12) +project (Jerry_LibM C) + +# Compiler / linker flags +# TODO: Reduce the below list of warning/error disablings as much as possible +set(COMPILE_FLAGS_LIBM "${COMPILE_FLAGS_JERRY} ${C_FLAGS_JERRY}") +set(COMPILE_FLAGS_LIBM "${COMPILE_FLAGS_LIBM} -Wno-error=parentheses") +set(COMPILE_FLAGS_LIBM "${COMPILE_FLAGS_LIBM} -Wno-error=sign-compare") +set(COMPILE_FLAGS_LIBM "${COMPILE_FLAGS_LIBM} -Wno-error=sign-conversion") +set(COMPILE_FLAGS_LIBM "${COMPILE_FLAGS_LIBM} -Wno-error=strict-aliasing") +set(COMPILE_FLAGS_LIBM "${COMPILE_FLAGS_LIBM} -Wno-error=unknown-pragmas") +set(COMPILE_FLAGS_LIBM "${COMPILE_FLAGS_LIBM} -Wno-error=missing-declarations") +set(COMPILE_FLAGS_LIBM "${COMPILE_FLAGS_LIBM} -Wno-error=maybe-uninitialized") +set(COMPILE_FLAGS_LIBM "${COMPILE_FLAGS_LIBM} -Wno-error=unused-but-set-variable") +set(COMPILE_FLAGS_LIBM "${COMPILE_FLAGS_LIBM} -Wno-error=unused-variable") +set(COMPILE_FLAGS_LIBM "${COMPILE_FLAGS_LIBM} -Wno-error=conversion") +set(COMPILE_FLAGS_LIBM "${COMPILE_FLAGS_LIBM} -Wno-sign-conversion") +set(COMPILE_FLAGS_LIBM "${COMPILE_FLAGS_LIBM} -Wno-sign-compare") +set(COMPILE_FLAGS_LIBM "${COMPILE_FLAGS_LIBM} -Wno-parentheses") +set(COMPILE_FLAGS_LIBM "${COMPILE_FLAGS_LIBM} -Wno-maybe-uninitialized") +set(COMPILE_FLAGS_LIBM "${COMPILE_FLAGS_LIBM} -Wno-unknown-pragmas") +set(COMPILE_FLAGS_LIBM "${COMPILE_FLAGS_LIBM} -Wno-unused-but-set-variable") +set(COMPILE_FLAGS_LIBM "${COMPILE_FLAGS_LIBM} -Wno-unused-variable") + +# Include directories +set(INCLUDE_LIBM ${CMAKE_SOURCE_DIR}/jerry-libm/include) +set(INCLUDE_LIBM ${INCLUDE_LIBM} PARENT_SCOPE) + +# Source directories +file(GLOB SOURCE_LIBM *.c) + +add_custom_target (jerry-libm-all) + +# Targets declaration + function(declare_targets_for_build_mode BUILD_MODE) + set(TARGET_NAME ${BUILD_MODE_PREFIX_${BUILD_MODE}}) + + function(declare_target_with_modifiers ) # modifiers are passed in ARGN implicit argument + foreach(MODIFIER ${ARGN}) + set(TARGET_NAME ${TARGET_NAME}${MODIFIER_SUFFIX_${MODIFIER}}) + endforeach() + + add_library(${TARGET_NAME}.jerry-libm.lib STATIC ${SOURCE_LIBM}) + set_property(TARGET ${TARGET_NAME}.jerry-libm.lib + PROPERTY COMPILE_FLAGS "${COMPILE_FLAGS_LIBM}") + target_include_directories(${TARGET_NAME}.jerry-libm.lib PRIVATE ${INCLUDE_LIBM}) + + if("${BUILD_MODE}" STREQUAL "UNITTESTS") + target_include_directories(${TARGET_NAME}.jerry-libm.lib INTERFACE ${INCLUDE_LIBM}) + endif() + endfunction() + + foreach(MODIFIERS_LIST ${MODIFIERS_LISTS}) + separate_arguments(MODIFIERS_LIST) + + declare_target_with_modifiers(${MODIFIERS_LIST}) + endforeach() + endfunction() + + declare_targets_for_build_mode(DEBUG) + declare_targets_for_build_mode(RELEASE) + declare_targets_for_build_mode(UNITTESTS) diff --git a/third-party/fdlibm/s_acos.c b/jerry-libm/acos.c similarity index 74% rename from third-party/fdlibm/s_acos.c rename to jerry-libm/acos.c index cf2237f64..b7cd7578c 100644 --- a/third-party/fdlibm/s_acos.c +++ b/jerry-libm/acos.c @@ -1,16 +1,33 @@ - -/* @(#)e_acos.c 1.3 95/01/18 */ -/* - * ==================================================== - * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. +/* Copyright 2016 Samsung Electronics Co., Ltd. + * Copyright 2016 University of Szeged * - * Developed at SunSoft, a Sun Microsystems, Inc. business. - * Permission to use, copy, modify, and distribute this - * software is freely granted, provided that this notice - * is preserved. - * ==================================================== + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * This file is based on work under the following copyright and permission + * notice: + * + * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. + * + * Developed at SunSoft, a Sun Microsystems, Inc. business. + * Permission to use, copy, modify, and distribute this + * software is freely granted, provided that this notice + * is preserved. + * + * @(#)e_acos.c 1.3 95/01/18 */ +#include "jerry-libm-internal.h" + /* acos(x) * * Method: @@ -36,8 +53,6 @@ * Function needed: sqrt */ -#include "fdlibm.h" - #define one 1.00000000000000000000e+00 /* 0x3FF00000, 0x00000000 */ #define pi 3.14159265358979311600e+00 /* 0x400921FB, 0x54442D18 */ #define pio2_hi 1.57079632679489655800e+00 /* 0x3FF921FB, 0x54442D18 */ diff --git a/third-party/fdlibm/s_asin.c b/jerry-libm/asin.c similarity index 76% rename from third-party/fdlibm/s_asin.c rename to jerry-libm/asin.c index 0d29c50d1..e013405db 100644 --- a/third-party/fdlibm/s_asin.c +++ b/jerry-libm/asin.c @@ -1,16 +1,33 @@ - -/* @(#)e_asin.c 1.3 95/01/18 */ -/* - * ==================================================== - * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. +/* Copyright 2016 Samsung Electronics Co., Ltd. + * Copyright 2016 University of Szeged * - * Developed at SunSoft, a Sun Microsystems, Inc. business. - * Permission to use, copy, modify, and distribute this - * software is freely granted, provided that this notice - * is preserved. - * ==================================================== + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * This file is based on work under the following copyright and permission + * notice: + * + * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. + * + * Developed at SunSoft, a Sun Microsystems, Inc. business. + * Permission to use, copy, modify, and distribute this + * software is freely granted, provided that this notice + * is preserved. + * + * @(#)e_asin.c 1.3 95/01/18 */ +#include "jerry-libm-internal.h" + /* asin(x) * * Method: @@ -41,8 +58,6 @@ * if |x|>1, return NaN with invalid signal. */ -#include "fdlibm.h" - #define one 1.00000000000000000000e+00 /* 0x3FF00000, 0x00000000 */ #define huge 1.000e+300 #define pio2_hi 1.57079632679489655800e+00 /* 0x3FF921FB, 0x54442D18 */ diff --git a/third-party/fdlibm/s_atan.c b/jerry-libm/atan.c similarity index 78% rename from third-party/fdlibm/s_atan.c rename to jerry-libm/atan.c index 691303cf1..8dc7104fd 100644 --- a/third-party/fdlibm/s_atan.c +++ b/jerry-libm/atan.c @@ -1,16 +1,33 @@ - -/* @(#)s_atan.c 1.3 95/01/18 */ -/* - * ==================================================== - * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. +/* Copyright 2016 Samsung Electronics Co., Ltd. + * Copyright 2016 University of Szeged * - * Developed at SunSoft, a Sun Microsystems, Inc. business. - * Permission to use, copy, modify, and distribute this - * software is freely granted, provided that this notice - * is preserved. - * ==================================================== + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * This file is based on work under the following copyright and permission + * notice: + * + * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. + * + * Developed at SunSoft, a Sun Microsystems, Inc. business. + * Permission to use, copy, modify, and distribute this + * software is freely granted, provided that this notice + * is preserved. + * + * @(#)s_atan.c 1.3 95/01/18 */ +#include "jerry-libm-internal.h" + /* atan(x) * * Method: @@ -32,8 +49,6 @@ * to produce the hexadecimal values shown. */ -#include "fdlibm.h" - static const double atanhi[] = { 4.63647609000806093515e-01, /* atan(0.5)hi 0x3FDDAC67, 0x0561BB4F */ diff --git a/third-party/fdlibm/s_atan2.c b/jerry-libm/atan2.c similarity index 78% rename from third-party/fdlibm/s_atan2.c rename to jerry-libm/atan2.c index 209b932e7..374e89165 100644 --- a/third-party/fdlibm/s_atan2.c +++ b/jerry-libm/atan2.c @@ -1,16 +1,33 @@ - -/* @(#)e_atan2.c 1.3 95/01/18 */ -/* - * ==================================================== - * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. +/* Copyright 2016 Samsung Electronics Co., Ltd. + * Copyright 2016 University of Szeged * - * Developed at SunSoft, a Sun Microsystems, Inc. business. - * Permission to use, copy, modify, and distribute this - * software is freely granted, provided that this notice - * is preserved. - * ==================================================== + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * This file is based on work under the following copyright and permission + * notice: + * + * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. + * + * Developed at SunSoft, a Sun Microsystems, Inc. business. + * Permission to use, copy, modify, and distribute this + * software is freely granted, provided that this notice + * is preserved. + * + * @(#)e_atan2.c 1.3 95/01/18 */ +#include "jerry-libm-internal.h" + /* atan2(y,x) * * Method: @@ -38,8 +55,6 @@ * to produce the hexadecimal values shown. */ -#include "fdlibm.h" - #define tiny 1.0e-300 #define zero 0.0 #define pi_o_4 7.8539816339744827900E-01 /* 0x3FE921FB, 0x54442D18 */ diff --git a/third-party/fdlibm/s_ceil.c b/jerry-libm/ceil.c similarity index 60% rename from third-party/fdlibm/s_ceil.c rename to jerry-libm/ceil.c index e5b5db08e..34c50900c 100644 --- a/third-party/fdlibm/s_ceil.c +++ b/jerry-libm/ceil.c @@ -1,16 +1,33 @@ - -/* @(#)s_ceil.c 1.3 95/01/18 */ -/* - * ==================================================== - * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. +/* Copyright 2016 Samsung Electronics Co., Ltd. + * Copyright 2016 University of Szeged * - * Developed at SunSoft, a Sun Microsystems, Inc. business. - * Permission to use, copy, modify, and distribute this - * software is freely granted, provided that this notice - * is preserved. - * ==================================================== + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * This file is based on work under the following copyright and permission + * notice: + * + * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. + * + * Developed at SunSoft, a Sun Microsystems, Inc. business. + * Permission to use, copy, modify, and distribute this + * software is freely granted, provided that this notice + * is preserved. + * + * @(#)s_ceil.c 1.3 95/01/18 */ +#include "jerry-libm-internal.h" + /* ceil(x) * Return x rounded toward -inf to integral value * @@ -21,8 +38,6 @@ * Inexact flag raised if x not equal to ceil(x). */ -#include "fdlibm.h" - #define huge 1.0e300 double diff --git a/jerry-libm/copysign.c b/jerry-libm/copysign.c new file mode 100644 index 000000000..877ff2ef0 --- /dev/null +++ b/jerry-libm/copysign.c @@ -0,0 +1,40 @@ +/* Copyright 2016 Samsung Electronics Co., Ltd. + * Copyright 2016 University of Szeged + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * This file is based on work under the following copyright and permission + * notice: + * + * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. + * + * Developed at SunSoft, a Sun Microsystems, Inc. business. + * Permission to use, copy, modify, and distribute this + * software is freely granted, provided that this notice + * is preserved. + * + * @(#)s_copysign.c 1.3 95/01/18 + */ + +#include "jerry-libm-internal.h" + +/* copysign(x,y) returns a value with the magnitude of x and + * with the sign bit of y. + */ + +double +copysign (double x, double y) +{ + __HI (x) = (__HI (x) & 0x7fffffff) | (__HI (y) & 0x80000000); + return x; +} /* copysign */ diff --git a/third-party/fdlibm/s_exp.c b/jerry-libm/exp.c similarity index 83% rename from third-party/fdlibm/s_exp.c rename to jerry-libm/exp.c index b2fe87fa2..68190f4ef 100644 --- a/third-party/fdlibm/s_exp.c +++ b/jerry-libm/exp.c @@ -1,15 +1,32 @@ - -/* @(#)e_exp.c 1.6 04/04/22 */ -/* - * ==================================================== - * Copyright (C) 2004 by Sun Microsystems, Inc. All rights reserved. +/* Copyright 2016 Samsung Electronics Co., Ltd. + * Copyright 2016 University of Szeged * - * Permission to use, copy, modify, and distribute this - * software is freely granted, provided that this notice - * is preserved. - * ==================================================== + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * This file is based on work under the following copyright and permission + * notice: + * + * Copyright (C) 2004 by Sun Microsystems, Inc. All rights reserved. + * + * Permission to use, copy, modify, and distribute this + * software is freely granted, provided that this notice + * is preserved. + * + * @(#)e_exp.c 1.6 04/04/22 */ +#include "jerry-libm-internal.h" + /* exp(x) * Returns the exponential of x. * @@ -73,8 +90,6 @@ * to produce the hexadecimal values shown. */ -#include "fdlibm.h" - static const double halF[2] = { 0.5, diff --git a/jerry-libm/fabs.c b/jerry-libm/fabs.c new file mode 100644 index 000000000..1ebbb12a2 --- /dev/null +++ b/jerry-libm/fabs.c @@ -0,0 +1,39 @@ +/* Copyright 2016 Samsung Electronics Co., Ltd. + * Copyright 2016 University of Szeged + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * This file is based on work under the following copyright and permission + * notice: + * + * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. + * + * Developed at SunSoft, a Sun Microsystems, Inc. business. + * Permission to use, copy, modify, and distribute this + * software is freely granted, provided that this notice + * is preserved. + * + * @(#)s_fabs.c 1.3 95/01/18 + */ + +#include "jerry-libm-internal.h" + +/* fabs(x) returns the absolute value of x. + */ + +double +fabs (double x) +{ + __HI (x) &= 0x7fffffff; + return x; +} /* fabs */ diff --git a/jerry-libm/finite.c b/jerry-libm/finite.c new file mode 100644 index 000000000..f5817f421 --- /dev/null +++ b/jerry-libm/finite.c @@ -0,0 +1,42 @@ +/* Copyright 2016 Samsung Electronics Co., Ltd. + * Copyright 2016 University of Szeged + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * This file is based on work under the following copyright and permission + * notice: + * + * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. + * + * Developed at SunSoft, a Sun Microsystems, Inc. business. + * Permission to use, copy, modify, and distribute this + * software is freely granted, provided that this notice + * is preserved. + * + * @(#)s_finite.c 1.3 95/01/18 + */ + +#include "jerry-libm-internal.h" + +/* finite(x) returns 1 is x is finite, else 0; + * no branching! + */ + +int +finite (double x) +{ + int hx; + + hx = __HI (x); + return (unsigned) ((hx & 0x7fffffff) - 0x7ff00000) >> 31; +} /* finite */ diff --git a/third-party/fdlibm/s_floor.c b/jerry-libm/floor.c similarity index 60% rename from third-party/fdlibm/s_floor.c rename to jerry-libm/floor.c index e4c3db916..5e3afec00 100644 --- a/third-party/fdlibm/s_floor.c +++ b/jerry-libm/floor.c @@ -1,16 +1,33 @@ - -/* @(#)s_floor.c 1.3 95/01/18 */ -/* - * ==================================================== - * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. +/* Copyright 2016 Samsung Electronics Co., Ltd. + * Copyright 2016 University of Szeged * - * Developed at SunSoft, a Sun Microsystems, Inc. business. - * Permission to use, copy, modify, and distribute this - * software is freely granted, provided that this notice - * is preserved. - * ==================================================== + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * This file is based on work under the following copyright and permission + * notice: + * + * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. + * + * Developed at SunSoft, a Sun Microsystems, Inc. business. + * Permission to use, copy, modify, and distribute this + * software is freely granted, provided that this notice + * is preserved. + * + * @(#)s_floor.c 1.3 95/01/18 */ +#include "jerry-libm-internal.h" + /* floor(x) * Return x rounded toward -inf to integral value * @@ -21,8 +38,6 @@ * Inexact flag raised if x not equal to floor(x). */ -#include "fdlibm.h" - #define huge 1.0e300 double diff --git a/third-party/fdlibm/s_fmod.c b/jerry-libm/fmod.c similarity index 76% rename from third-party/fdlibm/s_fmod.c rename to jerry-libm/fmod.c index 7e488c713..2c4ea0ccc 100644 --- a/third-party/fdlibm/s_fmod.c +++ b/jerry-libm/fmod.c @@ -1,24 +1,39 @@ - -/* @(#)e_fmod.c 1.3 95/01/18 */ -/* - * ==================================================== - * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. +/* Copyright 2016 Samsung Electronics Co., Ltd. + * Copyright 2016 University of Szeged * - * Developed at SunSoft, a Sun Microsystems, Inc. business. - * Permission to use, copy, modify, and distribute this - * software is freely granted, provided that this notice - * is preserved. - * ==================================================== + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * This file is based on work under the following copyright and permission + * notice: + * + * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. + * + * Developed at SunSoft, a Sun Microsystems, Inc. business. + * Permission to use, copy, modify, and distribute this + * software is freely granted, provided that this notice + * is preserved. + * + * @(#)e_fmod.c 1.3 95/01/18 */ +#include "jerry-libm-internal.h" + /* fmod(x,y) * Return x mod y in exact arithmetic * * Method: shift and subtract */ -#include "fdlibm.h" - static const double Zero[] = { 0.0, -0.0, }; #define one 1.0 diff --git a/third-party/fdlibm/include/fdlibm-math.h b/jerry-libm/include/math.h similarity index 96% rename from third-party/fdlibm/include/fdlibm-math.h rename to jerry-libm/include/math.h index cd0fb05ba..00f181d0e 100644 --- a/third-party/fdlibm/include/fdlibm-math.h +++ b/jerry-libm/include/math.h @@ -14,8 +14,8 @@ * limitations under the License. */ -#ifndef JERRY_FDLIBM_MATH_H -#define JERRY_FDLIBM_MATH_H +#ifndef JERRY_LIBM_MATH_H +#define JERRY_LIBM_MATH_H #ifdef __cplusplus extern "C" @@ -79,4 +79,4 @@ double fmod (double, double); #ifdef __cplusplus } #endif /* !__cplusplus */ -#endif /* !JERRY_FDLIBM_MATH_H */ +#endif /* !JERRY_LIBM_MATH_H */ diff --git a/jerry-libm/isnan.c b/jerry-libm/isnan.c new file mode 100644 index 000000000..e8c2b9e2a --- /dev/null +++ b/jerry-libm/isnan.c @@ -0,0 +1,45 @@ +/* Copyright 2016 Samsung Electronics Co., Ltd. + * Copyright 2016 University of Szeged + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * This file is based on work under the following copyright and permission + * notice: + * + * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. + * + * Developed at SunSoft, a Sun Microsystems, Inc. business. + * Permission to use, copy, modify, and distribute this + * software is freely granted, provided that this notice + * is preserved. + * + * @(#)s_isnan.c 1.3 95/01/18 + */ + +#include "jerry-libm-internal.h" + +/* isnan(x) returns 1 is x is nan, else 0; + * no branching! + */ + +int +isnan (double x) +{ + int hx, lx; + + hx = (__HI (x) & 0x7fffffff); + lx = __LO (x); + hx |= (unsigned) (lx | (-lx)) >> 31; + hx = 0x7ff00000 - hx; + return ((unsigned) (hx)) >> 31; +} /* isnan */ diff --git a/third-party/fdlibm/include/fdlibm.h b/jerry-libm/jerry-libm-internal.h similarity index 54% rename from third-party/fdlibm/include/fdlibm.h rename to jerry-libm/jerry-libm-internal.h index 5d8d3eb78..f593e9c4e 100644 --- a/third-party/fdlibm/include/fdlibm.h +++ b/jerry-libm/jerry-libm-internal.h @@ -1,15 +1,33 @@ - -/* @(#)fdlibm.h 1.5 04/04/22 */ -/* - * ==================================================== - * Copyright (C) 2004 by Sun Microsystems, Inc. All rights reserved. +/* Copyright 2016 Samsung Electronics Co., Ltd. + * Copyright 2016 University of Szeged * - * Permission to use, copy, modify, and distribute this - * software is freely granted, provided that this notice - * is preserved. - * ==================================================== + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * This file is based on work under the following copyright and permission + * notice: + * + * Copyright (C) 2004 by Sun Microsystems, Inc. All rights reserved. + * + * Permission to use, copy, modify, and distribute this + * software is freely granted, provided that this notice + * is preserved. + * + * @(#)fdlibm.h 1.5 04/04/22 */ +#ifndef JERRY_LIBM_INTERNAL_H +#define JERRY_LIBM_INTERNAL_H + /* Sometimes it's necessary to define __LITTLE_ENDIAN explicitly but these catch some common cases. */ @@ -29,28 +47,6 @@ #define __LO(x) *(1 + (int *) &x) #endif -/* - * ANSI/POSIX - */ - -#define MAXFLOAT ((float) 3.40282346638528860e+38) - -#define HUGE MAXFLOAT - -/* - * set X_TLOSS = pi*2**52, which is possibly defined in - * (one may replace the following line by "#include ") - */ - -#define X_TLOSS 1.41484755040568800000e+16 - -#define DOMAIN 1 -#define SING 2 -#define OVERFLOW 3 -#define UNDERFLOW 4 -#define TLOSS 5 -#define PLOSS 6 - /* * ANSI/POSIX */ @@ -81,3 +77,5 @@ extern int finite (double); */ extern double copysign (double, double); extern double scalbn (double, int); + +#endif /* !JERRY_LIBM_INTERNAL_H */ diff --git a/third-party/fdlibm/s_log.c b/jerry-libm/log.c similarity index 80% rename from third-party/fdlibm/s_log.c rename to jerry-libm/log.c index 1e6d11f25..832d730ac 100644 --- a/third-party/fdlibm/s_log.c +++ b/jerry-libm/log.c @@ -1,16 +1,33 @@ - -/* @(#)e_log.c 1.3 95/01/18 */ -/* - * ==================================================== - * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. +/* Copyright 2016 Samsung Electronics Co., Ltd. + * Copyright 2016 University of Szeged * - * Developed at SunSoft, a Sun Microsystems, Inc. business. - * Permission to use, copy, modify, and distribute this - * software is freely granted, provided that this notice - * is preserved. - * ==================================================== + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * This file is based on work under the following copyright and permission + * notice: + * + * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. + * + * Developed at SunSoft, a Sun Microsystems, Inc. business. + * Permission to use, copy, modify, and distribute this + * software is freely granted, provided that this notice + * is preserved. + * + * @(#)e_log.c 1.3 95/01/18 */ +#include "jerry-libm-internal.h" + /* log(x) * Return the logrithm of x * @@ -62,8 +79,6 @@ * to produce the hexadecimal values shown. */ -#include "fdlibm.h" - #define zero 0.0 #define ln2_hi 6.93147180369123816490e-01 /* 3fe62e42 fee00000 */ #define ln2_lo 1.90821492927058770002e-10 /* 3dea39ef 35793c76 */ diff --git a/third-party/fdlibm/s_pow.c b/jerry-libm/pow.c similarity index 91% rename from third-party/fdlibm/s_pow.c rename to jerry-libm/pow.c index 10fa7eb2d..000dbbefc 100644 --- a/third-party/fdlibm/s_pow.c +++ b/jerry-libm/pow.c @@ -1,15 +1,32 @@ - -/* @(#)e_pow.c 1.5 04/04/22 */ -/* - * ==================================================== - * Copyright (C) 2004 by Sun Microsystems, Inc. All rights reserved. +/* Copyright 2016 Samsung Electronics Co., Ltd. + * Copyright 2016 University of Szeged * - * Permission to use, copy, modify, and distribute this - * software is freely granted, provided that this notice - * is preserved. - * ==================================================== + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * This file is based on work under the following copyright and permission + * notice: + * + * Copyright (C) 2004 by Sun Microsystems, Inc. All rights reserved. + * + * Permission to use, copy, modify, and distribute this + * software is freely granted, provided that this notice + * is preserved. + * + * @(#)e_pow.c 1.5 04/04/22 */ +#include "jerry-libm-internal.h" + /* pow(x,y) return x**y * * n @@ -55,8 +72,6 @@ * to produce the hexadecimal values shown. */ -#include "fdlibm.h" - static const double one = 1.0; static const double bp[] = { diff --git a/third-party/fdlibm/s_scalbn.c b/jerry-libm/scalbn.c similarity index 55% rename from third-party/fdlibm/s_scalbn.c rename to jerry-libm/scalbn.c index d7b437404..4f054cf20 100644 --- a/third-party/fdlibm/s_scalbn.c +++ b/jerry-libm/scalbn.c @@ -1,23 +1,38 @@ - -/* @(#)s_scalbn.c 1.3 95/01/18 */ -/* - * ==================================================== - * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. +/* Copyright 2016 Samsung Electronics Co., Ltd. + * Copyright 2016 University of Szeged * - * Developed at SunSoft, a Sun Microsystems, Inc. business. - * Permission to use, copy, modify, and distribute this - * software is freely granted, provided that this notice - * is preserved. - * ==================================================== + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * This file is based on work under the following copyright and permission + * notice: + * + * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. + * + * Developed at SunSoft, a Sun Microsystems, Inc. business. + * Permission to use, copy, modify, and distribute this + * software is freely granted, provided that this notice + * is preserved. + * + * @(#)s_scalbn.c 1.3 95/01/18 */ +#include "jerry-libm-internal.h" + /* scalbn(x,n) returns x* 2**n computed by exponent * manipulation rather than by actually performing an * exponentiation or a multiplication. */ -#include "fdlibm.h" - #define two54 1.80143985094819840000e+16 /* 0x43500000, 0x00000000 */ #define twom54 5.55111512312578270212e-17 /* 0x3C900000, 0x00000000 */ #define huge 1.0e+300 diff --git a/third-party/fdlibm/s_sqrt.c b/jerry-libm/sqrt.c similarity index 93% rename from third-party/fdlibm/s_sqrt.c rename to jerry-libm/sqrt.c index 82afe2138..71970d061 100644 --- a/third-party/fdlibm/s_sqrt.c +++ b/jerry-libm/sqrt.c @@ -1,16 +1,33 @@ - -/* @(#)e_sqrt.c 1.3 95/01/18 */ -/* - * ==================================================== - * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. +/* Copyright 2016 Samsung Electronics Co., Ltd. + * Copyright 2016 University of Szeged * - * Developed at SunSoft, a Sun Microsystems, Inc. business. - * Permission to use, copy, modify, and distribute this - * software is freely granted, provided that this notice - * is preserved. - * ==================================================== + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * This file is based on work under the following copyright and permission + * notice: + * + * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. + * + * Developed at SunSoft, a Sun Microsystems, Inc. business. + * Permission to use, copy, modify, and distribute this + * software is freely granted, provided that this notice + * is preserved. + * + * @(#)e_sqrt.c 1.3 95/01/18 */ +#include "jerry-libm-internal.h" + /* sqrt(x) * Return correctly rounded sqrt. * @@ -82,8 +99,6 @@ * Other methods: see the appended file at the end of the program below. */ -#include "fdlibm.h" - #define one 1.0 #define tiny 1.0e-300 diff --git a/third-party/fdlibm/s_trig.c b/jerry-libm/trig.c similarity index 95% rename from third-party/fdlibm/s_trig.c rename to jerry-libm/trig.c index 06bfef4f6..b41f50787 100644 --- a/third-party/fdlibm/s_trig.c +++ b/jerry-libm/trig.c @@ -1,24 +1,39 @@ - -/* @(#)k_rem_pio2.c 1.3 95/01/18 */ -/* @(#)e_rem_pio2.c 1.4 95/01/18 */ -/* @(#)k_sin.c 1.3 95/01/18 */ -/* @(#)k_cos.c 1.3 95/01/18 */ -/* @(#)k_tan.c 1.5 04/04/22 */ -/* @(#)s_sin.c 1.3 95/01/18 */ -/* @(#)s_cos.c 1.3 95/01/18 */ -/* @(#)s_tan.c 1.3 95/01/18 */ -/* - * ==================================================== - * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. +/* Copyright 2016 Samsung Electronics Co., Ltd. + * Copyright 2016 University of Szeged * - * Developed at SunSoft, a Sun Microsystems, Inc. business. - * Permission to use, copy, modify, and distribute this - * software is freely granted, provided that this notice - * is preserved. - * ==================================================== + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * This file is based on work under the following copyright and permission + * notice: + * + * Copyright (C) 1993, 2004 by Sun Microsystems, Inc. All rights reserved. + * + * Developed at SunSoft, a Sun Microsystems, Inc. business. + * Permission to use, copy, modify, and distribute this + * software is freely granted, provided that this notice + * is preserved. + * + * @(#)k_rem_pio2.c 1.3 95/01/18 + * @(#)e_rem_pio2.c 1.4 95/01/18 + * @(#)k_sin.c 1.3 95/01/18 + * @(#)k_cos.c 1.3 95/01/18 + * @(#)k_tan.c 1.5 04/04/22 + * @(#)s_sin.c 1.3 95/01/18 + * @(#)s_cos.c 1.3 95/01/18 + * @(#)s_tan.c 1.3 95/01/18 */ -#include "fdlibm.h" +#include "jerry-libm-internal.h" #define zero 0.00000000000000000000e+00 /* 0x00000000, 0x00000000 */ #define half 5.00000000000000000000e-01 /* 0x3FE00000, 0x00000000 */ diff --git a/targets/esp8266/Makefile b/targets/esp8266/Makefile index 70a0e72ea..ab5013071 100644 --- a/targets/esp8266/Makefile +++ b/targets/esp8266/Makefile @@ -1,4 +1,4 @@ -# Copyright 2015 Samsung Electronics Co., Ltd. +# Copyright 2015-2016 Samsung Electronics Co., Ltd. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -86,7 +86,7 @@ LINKFLAGS_eagle.app.v6 = \ -L./libs \ -ljerrycore \ -ljerryentry \ - -lfdlibm \ + -ljerrylibm \ $(DEP_LIBS_eagle.app.v6) \ ./libs/lib_a-setjmp.o \ -Wl,--end-group @@ -96,7 +96,7 @@ DEPENDS_eagle.app.v6 = \ $(LD_FILE) \ $(LDDIR)/eagle.rom.addr.v6.ld \ ./source/jerry_targetjs.h \ - ./libs/libfdlibm.a \ + ./libs/libjerrylibm.a \ ./libs/libjerrycore.a \ ./libs/libjerryentry.a diff --git a/targets/esp8266/Makefile.esp8266 b/targets/esp8266/Makefile.esp8266 index 4edc315d4..e400d4dad 100644 --- a/targets/esp8266/Makefile.esp8266 +++ b/targets/esp8266/Makefile.esp8266 @@ -1,4 +1,4 @@ -# Copyright 2015 Samsung Electronics Co., Ltd. +# Copyright 2015-2016 Samsung Electronics Co., Ltd. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -74,8 +74,7 @@ jerry: make -C $(INTERM) $(TYPE).external cp `cat $(INTERM)/$(TYPE).external/list` $(OUTPUT)/. cp $(OUTPUT)/lib$(TYPE).jerry-core.a $(COPYTARGET)/libjerrycore.a - cp $(OUTPUT)/lib$(TYPE).jerry-fdlibm.third_party.lib.a \ - $(COPYTARGET)/libfdlibm.a + cp $(OUTPUT)/lib$(TYPE).jerry-libm.lib.a $(COPYTARGET)/libjerrylibm.a cp $(INTERM)/lib$(TYPE).external-entry.a $(OUTPUT)/. cp $(OUTPUT)/lib$(TYPE).external-entry.a $(COPYTARGET)/libjerryentry.a diff --git a/targets/esp8266/docs/ESP-PATCHFORJERRYSCRIPT.md b/targets/esp8266/docs/ESP-PATCHFORJERRYSCRIPT.md index 10bde7e43..bc6bb74ab 100644 --- a/targets/esp8266/docs/ESP-PATCHFORJERRYSCRIPT.md +++ b/targets/esp8266/docs/ESP-PATCHFORJERRYSCRIPT.md @@ -23,7 +23,7 @@ index caf8e32..dadaceb 100644 + _jerry_text_start = ABSOLUTE(.); + *\libjerryentry.a:*(.text*) + *\libjerrycore.a:*(.text*) -+ *\libfdlibm.a:*(.text*) ++ *\libjerrylibm.a:*(.text*) + _jerry_text_end = ABSOLUTE(.); + + } >irom0_0_seg :irom0_0_phdr diff --git a/targets/mbedk64f/Makefile.mbedk64f b/targets/mbedk64f/Makefile.mbedk64f index d3ea5ed19..6c3c22ed1 100644 --- a/targets/mbedk64f/Makefile.mbedk64f +++ b/targets/mbedk64f/Makefile.mbedk64f @@ -51,7 +51,7 @@ jerry: make -C $(INTERM) $(TYPE).external cp `cat $(INTERM)/$(TYPE).external/list` $(OUTPUT)/. cp $(OUTPUT)/lib$(TYPE).jerry-core.a $(COPYTARGET)/libjerrycore.a - cp $(OUTPUT)/lib$(TYPE).jerry-fdlibm.third_party.lib.a $(COPYTARGET)/libfdlibm.a + cp $(OUTPUT)/lib$(TYPE).jerry-libm.lib.a $(COPYTARGET)/libjerrylibm.a js2c: diff --git a/targets/mbedk64f/readme.md b/targets/mbedk64f/readme.md index 4f284a5b0..81b85b7fe 100644 --- a/targets/mbedk64f/readme.md +++ b/targets/mbedk64f/readme.md @@ -24,7 +24,7 @@ make -f targets/mbedk64f/Makefile.mbedk64f jerry Two files will be generated at `targets/mbedk64f/libjerry` * libjerrycore.a -* libfdlibm.a +* libjerrylibm.a #### Building mbed binary diff --git a/targets/mbedk64f/source/makejerry.cmake b/targets/mbedk64f/source/makejerry.cmake index c8f20f8f8..356fe434b 100644 --- a/targets/mbedk64f/source/makejerry.cmake +++ b/targets/mbedk64f/source/makejerry.cmake @@ -1,4 +1,4 @@ -# Copyright 2015 Samsung Electronics Co., Ltd. +# Copyright 2015-2016 Samsung Electronics Co., Ltd. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -29,6 +29,6 @@ set(CMAKE_C_FLAGS ${CMAKE_C_FLAGS} # link jerryscript set(LJPATH ${CMAKE_CURRENT_LIST_DIR}/../libjerry) set(LJFILES "") -set(LJFILES ${LJFILES} ${LJPATH}/libfdlibm.a) +set(LJFILES ${LJFILES} ${LJPATH}/libjerrylibm.a) set(LJFILES ${LJFILES} ${LJPATH}/libjerrycore.a) target_link_libraries(${MBEDMODULE} ${LJFILES}) diff --git a/targets/nuttx-stm32f4/Makefile.nuttx b/targets/nuttx-stm32f4/Makefile.nuttx index 966c399bd..972391e4d 100644 --- a/targets/nuttx-stm32f4/Makefile.nuttx +++ b/targets/nuttx-stm32f4/Makefile.nuttx @@ -51,8 +51,7 @@ all: make -C $(INTERM) $(TYPE).external cp `cat $(INTERM)/$(TYPE).external/list` $(OUTPUT)/. cp $(OUTPUT)/lib$(TYPE).jerry-core.a $(COPYTARGET)/libjerrycore.a - cp $(OUTPUT)/lib$(TYPE).jerry-fdlibm.third_party.lib.a \ - $(COPYTARGET)/libfdlibm.a + cp $(OUTPUT)/lib$(TYPE).jerry-libm.lib.a $(COPYTARGET)/libjerrylibm.a cp $(INTERM)/lib$(TYPE).external-entry.a $(OUTPUT)/. cp $(OUTPUT)/lib$(TYPE).external-entry.a $(COPYTARGET)/libjerryentry.a diff --git a/targets/nuttx-stm32f4/README.md b/targets/nuttx-stm32f4/README.md index 4ab782eab..227617410 100644 --- a/targets/nuttx-stm32f4/README.md +++ b/targets/nuttx-stm32f4/README.md @@ -83,7 +83,7 @@ Make will copy three library files to `nuttx/nuttx/lib` folder ``` libjerryentry.a libjerrycore.a -libfdlibm.a +libjerrylibm.a ``` In NuttX, if you run `make clean`, above library files are also removed so you diff --git a/tests/unit/test-common.h b/tests/unit/test-common.h index e5c5c59ff..eaf52e987 100644 --- a/tests/unit/test-common.h +++ b/tests/unit/test-common.h @@ -1,4 +1,4 @@ -/* Copyright 2014-2015 Samsung Electronics Co., Ltd. +/* Copyright 2014-2016 Samsung Electronics Co., Ltd. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -18,7 +18,7 @@ #include "jrt.h" -#include "fdlibm-math.h" +#include #include #include #include diff --git a/tests/unit/test-fdlibm.c b/tests/unit/test-libm.c similarity index 97% rename from tests/unit/test-fdlibm.c rename to tests/unit/test-libm.c index a044b3cd7..4f4069591 100644 --- a/tests/unit/test-fdlibm.c +++ b/tests/unit/test-libm.c @@ -15,7 +15,7 @@ */ /** - * Unit test for fdlibm + * Unit test for jerry-libm */ #include "test-common.h" @@ -77,7 +77,7 @@ main (int __attr_unused___ argc, char __attr_unused___ **argv) { #define INF INFINITY -#include "test-fdlibm.inc.h" +#include "test-libm.inc.h" return passed ? 0 : 1; } /* main */ diff --git a/tests/unit/test-fdlibm.inc.h b/tests/unit/test-libm.inc.h similarity index 99% rename from tests/unit/test-fdlibm.inc.h rename to tests/unit/test-libm.inc.h index 5ed420f42..775d6d03b 100644 --- a/tests/unit/test-fdlibm.inc.h +++ b/tests/unit/test-libm.inc.h @@ -1,5 +1,5 @@ /* - * Generated by tools/gen-test-fdlibm.sh + * Generated by tools/gen-test-libm.sh * DO NOT EDIT!!! */ check_double ("acos (0.0)", acos (0.0), 1.57079632679489655800E+00); diff --git a/third-party/fdlibm/CMakeLists.txt b/third-party/fdlibm/CMakeLists.txt deleted file mode 100644 index 062cb4d62..000000000 --- a/third-party/fdlibm/CMakeLists.txt +++ /dev/null @@ -1,76 +0,0 @@ -# Copyright 2015 Samsung Electronics Co., Ltd. -# Copyright 2015 University of Szeged. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -cmake_minimum_required (VERSION 2.8.12) -project (jerry_fdlibm C) - -# Compiler / linker flags -set(COMPILE_FLAGS_FDLIBM "${COMPILE_FLAGS_JERRY} ${C_FLAGS_JERRY}") -set(COMPILE_FLAGS_FDLIBM "${COMPILE_FLAGS_FDLIBM} -Wno-error=parentheses") -set(COMPILE_FLAGS_FDLIBM "${COMPILE_FLAGS_FDLIBM} -Wno-error=sign-compare") -set(COMPILE_FLAGS_FDLIBM "${COMPILE_FLAGS_FDLIBM} -Wno-error=sign-conversion") -set(COMPILE_FLAGS_FDLIBM "${COMPILE_FLAGS_FDLIBM} -Wno-error=strict-aliasing") -set(COMPILE_FLAGS_FDLIBM "${COMPILE_FLAGS_FDLIBM} -Wno-error=unknown-pragmas") -set(COMPILE_FLAGS_FDLIBM "${COMPILE_FLAGS_FDLIBM} -Wno-error=missing-declarations") -set(COMPILE_FLAGS_FDLIBM "${COMPILE_FLAGS_FDLIBM} -Wno-error=maybe-uninitialized") -set(COMPILE_FLAGS_FDLIBM "${COMPILE_FLAGS_FDLIBM} -Wno-error=unused-but-set-variable") -set(COMPILE_FLAGS_FDLIBM "${COMPILE_FLAGS_FDLIBM} -Wno-error=unused-variable") -set(COMPILE_FLAGS_FDLIBM "${COMPILE_FLAGS_FDLIBM} -Wno-error=conversion") -set(COMPILE_FLAGS_FDLIBM "${COMPILE_FLAGS_FDLIBM} -Wno-sign-conversion") -set(COMPILE_FLAGS_FDLIBM "${COMPILE_FLAGS_FDLIBM} -Wno-sign-compare") -set(COMPILE_FLAGS_FDLIBM "${COMPILE_FLAGS_FDLIBM} -Wno-parentheses") -set(COMPILE_FLAGS_FDLIBM "${COMPILE_FLAGS_FDLIBM} -Wno-maybe-uninitialized") -set(COMPILE_FLAGS_FDLIBM "${COMPILE_FLAGS_FDLIBM} -Wno-unknown-pragmas") -set(COMPILE_FLAGS_FDLIBM "${COMPILE_FLAGS_FDLIBM} -Wno-unused-but-set-variable") -set(COMPILE_FLAGS_FDLIBM "${COMPILE_FLAGS_FDLIBM} -Wno-unused-variable") - -# Include directories -set(INCLUDE_FDLIBM ${CMAKE_SOURCE_DIR}/third-party/fdlibm/include) -set(INCLUDE_FDLIBM ${INCLUDE_FDLIBM} PARENT_SCOPE) - -# Source directories -file(GLOB SOURCE_FDLIBM *.c) - -add_custom_target (jerry-fdlibm-all) - -# Targets declaration - function(declare_targets_for_build_mode BUILD_MODE) - set(TARGET_NAME ${BUILD_MODE_PREFIX_${BUILD_MODE}}) - - function(declare_target_with_modifiers ) # modifiers are passed in ARGN implicit argument - foreach(MODIFIER ${ARGN}) - set(TARGET_NAME ${TARGET_NAME}${MODIFIER_SUFFIX_${MODIFIER}}) - endforeach() - - add_library(${TARGET_NAME}.jerry-fdlibm${SUFFIX_THIRD_PARTY_LIB} STATIC ${SOURCE_FDLIBM}) - set_property(TARGET ${TARGET_NAME}.jerry-fdlibm${SUFFIX_THIRD_PARTY_LIB} - PROPERTY COMPILE_FLAGS "${COMPILE_FLAGS_FDLIBM}") - target_include_directories(${TARGET_NAME}.jerry-fdlibm${SUFFIX_THIRD_PARTY_LIB} PRIVATE ${INCLUDE_FDLIBM}) - - if("${BUILD_MODE}" STREQUAL "UNITTESTS") - target_include_directories(${TARGET_NAME}.jerry-fdlibm${SUFFIX_THIRD_PARTY_LIB} INTERFACE ${INCLUDE_FDLIBM}) - endif() - endfunction() - - foreach(MODIFIERS_LIST ${MODIFIERS_LISTS}) - separate_arguments(MODIFIERS_LIST) - - declare_target_with_modifiers(${MODIFIERS_LIST}) - endforeach() - endfunction() - - declare_targets_for_build_mode(DEBUG) - declare_targets_for_build_mode(RELEASE) - declare_targets_for_build_mode(UNITTESTS) \ No newline at end of file diff --git a/third-party/fdlibm/s_copysign.c b/third-party/fdlibm/s_copysign.c deleted file mode 100644 index 5dd6c0fc1..000000000 --- a/third-party/fdlibm/s_copysign.c +++ /dev/null @@ -1,25 +0,0 @@ - -/* @(#)s_copysign.c 1.3 95/01/18 */ -/* - * ==================================================== - * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. - * - * Developed at SunSoft, a Sun Microsystems, Inc. business. - * Permission to use, copy, modify, and distribute this - * software is freely granted, provided that this notice - * is preserved. - * ==================================================== - */ - -/* copysign(x,y) returns a value with the magnitude of x and - * with the sign bit of y. - */ - -#include "fdlibm.h" - -double -copysign (double x, double y) -{ - __HI (x) = (__HI (x) & 0x7fffffff) | (__HI (y) & 0x80000000); - return x; -} /* copysign */ diff --git a/third-party/fdlibm/s_fabs.c b/third-party/fdlibm/s_fabs.c deleted file mode 100644 index c3864ae92..000000000 --- a/third-party/fdlibm/s_fabs.c +++ /dev/null @@ -1,24 +0,0 @@ - -/* @(#)s_fabs.c 1.3 95/01/18 */ -/* - * ==================================================== - * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. - * - * Developed at SunSoft, a Sun Microsystems, Inc. business. - * Permission to use, copy, modify, and distribute this - * software is freely granted, provided that this notice - * is preserved. - * ==================================================== - */ - -/* fabs(x) returns the absolute value of x. - */ - -#include "fdlibm.h" - -double -fabs (double x) -{ - __HI (x) &= 0x7fffffff; - return x; -} /* fabs */ diff --git a/third-party/fdlibm/s_finite.c b/third-party/fdlibm/s_finite.c deleted file mode 100644 index 7a6ed175c..000000000 --- a/third-party/fdlibm/s_finite.c +++ /dev/null @@ -1,27 +0,0 @@ - -/* @(#)s_finite.c 1.3 95/01/18 */ -/* - * ==================================================== - * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. - * - * Developed at SunSoft, a Sun Microsystems, Inc. business. - * Permission to use, copy, modify, and distribute this - * software is freely granted, provided that this notice - * is preserved. - * ==================================================== - */ - -/* finite(x) returns 1 is x is finite, else 0; - * no branching! - */ - -#include "fdlibm.h" - -int -finite (double x) -{ - int hx; - - hx = __HI (x); - return (unsigned) ((hx & 0x7fffffff) - 0x7ff00000) >> 31; -} /* finite */ diff --git a/third-party/fdlibm/s_isnan.c b/third-party/fdlibm/s_isnan.c deleted file mode 100644 index 30724a315..000000000 --- a/third-party/fdlibm/s_isnan.c +++ /dev/null @@ -1,30 +0,0 @@ - -/* @(#)s_isnan.c 1.3 95/01/18 */ -/* - * ==================================================== - * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. - * - * Developed at SunSoft, a Sun Microsystems, Inc. business. - * Permission to use, copy, modify, and distribute this - * software is freely granted, provided that this notice - * is preserved. - * ==================================================== - */ - -/* isnan(x) returns 1 is x is nan, else 0; - * no branching! - */ - -#include "fdlibm.h" - -int -isnan (double x) -{ - int hx, lx; - - hx = (__HI (x) & 0x7fffffff); - lx = __LO (x); - hx |= (unsigned) (lx | (-lx)) >> 31; - hx = 0x7ff00000 - hx; - return ((unsigned) (hx)) >> 31; -} /* isnan */ diff --git a/tools/check-cppcheck.sh b/tools/check-cppcheck.sh index 422e0c402..408334834 100755 --- a/tools/check-cppcheck.sh +++ b/tools/check-cppcheck.sh @@ -25,9 +25,10 @@ fi JERRY_CORE_DIRS=`find jerry-core -type d` JERRY_LIBC_DIRS=`find jerry-libc -type d` +JERRY_LIBM_DIRS=`find jerry-libm -type d` INCLUDE_DIRS=() -for DIR in $JERRY_CORE_DIRS $JERRY_LIBC_DIRS +for DIR in $JERRY_CORE_DIRS $JERRY_LIBC_DIRS $JERRY_LIBM_DIRS do INCLUDE_DIRS=("${INCLUDE_DIRS[@]}" "-I$DIR") done @@ -38,4 +39,4 @@ cppcheck -j$CPPCHECK_JOBS --force \ --error-exitcode=1 \ --exitcode-suppressions=tools/cppcheck/suppressions-list \ "${INCLUDE_DIRS[@]}" \ - jerry-core jerry-libc *.c *h tests/unit + jerry-core jerry-libc jerry-libm *.c *h tests/unit diff --git a/tools/check-vera.sh b/tools/check-vera.sh index 474077b55..251087a3a 100755 --- a/tools/check-vera.sh +++ b/tools/check-vera.sh @@ -17,9 +17,10 @@ JERRY_CORE_FILES=`find ./jerry-core -name "*.c" -or -name "*.h"` JERRY_LIBC_FILES=`find ./jerry-libc -name "*.c" -or -name "*.h"` +JERRY_LIBM_FILES=`find ./jerry-libm -name "*.c" -or -name "*.h"` JERRY_MAIN_FILES=`find . -maxdepth 1 -name "*.c" -or -name "*.h"` UNIT_TEST_FILES=`find ./tests/unit -name "*.c" -or -name "*.h"` vera++ -r tools/vera++ -p jerry \ -e --no-duplicate \ - $JERRY_CORE_FILES $JERRY_LIBC_FILES $JERRY_MAIN_FILES $UNIT_TEST_FILES + $JERRY_CORE_FILES $JERRY_LIBC_FILES $JERRY_LIBM_FILES $JERRY_MAIN_FILES $UNIT_TEST_FILES diff --git a/tools/cppcheck/suppressions-list b/tools/cppcheck/suppressions-list index 74fab0005..d4c995b1a 100644 --- a/tools/cppcheck/suppressions-list +++ b/tools/cppcheck/suppressions-list @@ -1,7 +1,10 @@ operatorEqVarError noConstructor duplicateExpression -wrongmathcall:tests/unit/test-fdlibm.inc.h +wrongmathcall:tests/unit/test-libm.inc.h +variableScope:jerry-libm/*.c +invalidPointerCast:jerry-libm/*.c +unreadVariable:jerry-libm/*.c // FIXME: false positive in cppcheck 1.61 (will disappear once distro ships with 1.69) variableScope:jerry-core/ecma/builtin-objects/ecma-builtin-helpers.c diff --git a/tools/gen-test-fdlibm.sh b/tools/gen-test-libm.sh similarity index 91% rename from tools/gen-test-fdlibm.sh rename to tools/gen-test-libm.sh index 16cd25eac..9824f69de 100755 --- a/tools/gen-test-fdlibm.sh +++ b/tools/gen-test-libm.sh @@ -16,5 +16,5 @@ # limitations under the License. make -C tools/unit-tests build -tools/unit-tests/gen-test-fdlibm >tests/unit/test-fdlibm.inc.h +tools/unit-tests/gen-test-libm >tests/unit/test-libm.inc.h make -C tools/unit-tests clean diff --git a/tools/unit-tests/Makefile b/tools/unit-tests/Makefile index 379447c27..efdf0a16c 100644 --- a/tools/unit-tests/Makefile +++ b/tools/unit-tests/Makefile @@ -16,7 +16,7 @@ CC=gcc LDFLAGS=-lm -GENS=gen-test-fdlibm +GENS=gen-test-libm .PHONY: build build: $(GENS) @@ -25,5 +25,5 @@ build: $(GENS) clean: rm -f $(GENS) -gen-test-fdlibm: gen-test-fdlibm.c +gen-test-libm: gen-test-libm.c $(CC) $< -o $@ $(LDFLAGS) diff --git a/tools/unit-tests/gen-test-fdlibm.c b/tools/unit-tests/gen-test-libm.c similarity index 98% rename from tools/unit-tests/gen-test-fdlibm.c rename to tools/unit-tests/gen-test-libm.c index 4dddffa22..433b1f04f 100644 --- a/tools/unit-tests/gen-test-fdlibm.c +++ b/tools/unit-tests/gen-test-libm.c @@ -15,13 +15,13 @@ */ /* - * Unit test generator for fdlibm. + * Unit test generator for jerry-libm. * To be compiled separately from the rest of jerry and to be linked to a trusted libm. - * Its output should be redirected to test-fdlibm.inc.h. + * Its output should be redirected to test-libm.inc.h. * * Example: - * gcc gen-test-fdlibm.c -o gen-test-fdlibm -lm - * ./gen-test-fdlibm >test-fdlibm.inc.h + * gcc gen-test-libm.c -o gen-test-libm -lm + * ./gen-test-libm >test-libm.inc.h */ #include @@ -34,7 +34,7 @@ int main (int argc, char **args) { printf ("/*\n" - " * Generated by tools/gen-test-fdlibm.sh\n" + " * Generated by tools/gen-test-libm.sh\n" " * DO NOT EDIT!!!\n" " */\n"); @@ -211,7 +211,7 @@ main (int argc, char **args) GEN_DBL_TEST (ceil (-7.37e+19)); /* copysign tests */ - /* SKIPPED: not declared in fdlibm-math.h + /* SKIPPED: not publicly declared in jerry-libm GEN_DBL_TEST (copysign (0.0, 0.0)); GEN_DBL_TEST (copysign (0.0, -0.0)); GEN_DBL_TEST (copysign (-0.0, 0.0)); @@ -314,7 +314,7 @@ main (int argc, char **args) GEN_DBL_TEST (fabs (-7.37e+19)); /* finite tests */ - /* SKIPPED: not declared in fdlibm-math.h + /* SKIPPED: not publicly declared in jerry-libm GEN_INT_TEST (finite (0.0)); GEN_INT_TEST (finite (-0.0)); GEN_INT_TEST (finite (1.0)); @@ -553,7 +553,7 @@ main (int argc, char **args) GEN_DBL_TEST (pow (0.7, 1.2)); /* scalbn tests */ - /* SKIPPED: not declared in fdlibm-math.h + /* SKIPPED: not publicly declared in jerry-libm GEN_DBL_TEST (scalbn (0.0, 0)); GEN_DBL_TEST (scalbn (-0.0, 0)); GEN_DBL_TEST (scalbn (0.0, 1));