summaryrefslogtreecommitdiff
path: root/src/pal/tests/palsuite
diff options
context:
space:
mode:
authorJim Ma <mazong1123@gmail.com>2017-09-13 09:33:40 +0800
committerTarek Mahmoud Sayed <tarekms@microsoft.com>2017-09-12 18:33:40 -0700
commit602ebe9b24948465ec157a8a8037ff2855435e04 (patch)
treef1189f28e9a08eaf5933988fa02a184e866d989e /src/pal/tests/palsuite
parent13c7d392fc20492cbef39c923b9d22dd0a57c2a0 (diff)
downloadcoreclr-602ebe9b24948465ec157a8a8037ff2855435e04.tar.gz
coreclr-602ebe9b24948465ec157a8a8037ff2855435e04.tar.bz2
coreclr-602ebe9b24948465ec157a8a8037ff2855435e04.zip
Re-implemented the ecvt function. (#12894)
* Re-implemented the ecvt function. Instead of leveraging snprintf, re-implement the ecvt function according to the paper: https://www.cs.indiana.edu/~dyb/pubs/FP-Printing-PLDI96.pdf Note: 1. This commit won't fix any existing bug. 2. This is a raw implementation of the paper. The performance on Linux only gain 10%. We could tune the performance further. Fix #10651 * Resolve a cross platform header file issue. Fix #10651 * Fixed a minor bug. Improved the performance. Fix #10651 * Modified code according to code review feedback. This commit fixed most of the issue found in code review. However, some of the feedback may not be involved due to either little performance improvement or need a POC. Fix #10651 * Try to fix constexpr compile error on Windows. Fix #10651 * Fixed a potential overflow bug in BigNum::Compare. Fix #10651 * Improved multiply 10 operation. Use shift and add operation to replace actual multiply operation. Fix #10651 * Remove old _ecvt function. Fix #10651 * Documented the reason why we do not need m+ and m-. Fix #10651 * Changed exp > 0 to exp != 0 to remove any confusion. exp should fall in 1 ~ 2046 for normalized value. Denormalized value has exp = 0. Fix #10651 * Disable the _ecvt tests. Fix #10651 * Removed _ecvt tests. Fix #10651 * Re-implemented LogBase2. Fix #10651 * Use DWORD and DWORD64 for _BitScanReverse and _BitScanReverse64 Fix #10651 * Fixed x86 compile issue for _BitScanReverse64 x86 does not support _BitScanReverse64 so we have to add additional shift operations to handle it. Fix #10651 * Implemented BitScanReverse64 and BitScanReverse in pal.h Fix #10651 * Remove the confusion comment which is unrelated to BitScanReverse. Fix #10651 * Introduced wmemset to enhance the perf for 0.0 Fix #10651 * Improved the performance of converting 0.0. Fix #10651 * Renamed ecvt to DoubleToNumberWorker. Fix #10651 * Updated code according to the code review feedback. Fix #10651
Diffstat (limited to 'src/pal/tests/palsuite')
-rw-r--r--src/pal/tests/palsuite/c_runtime/CMakeLists.txt1
-rw-r--r--src/pal/tests/palsuite/c_runtime/_ecvt/CMakeLists.txt4
-rw-r--r--src/pal/tests/palsuite/c_runtime/_ecvt/test1/CMakeLists.txt17
-rw-r--r--src/pal/tests/palsuite/c_runtime/_ecvt/test1/test1.cpp135
-rw-r--r--src/pal/tests/palsuite/c_runtime/_ecvt/test1/testinfo.dat14
-rw-r--r--src/pal/tests/palsuite/paltestlist_to_be_reviewed.txt1
-rw-r--r--src/pal/tests/palsuite/palverify.dat1
7 files changed, 0 insertions, 173 deletions
diff --git a/src/pal/tests/palsuite/c_runtime/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/CMakeLists.txt
index 7a6b2cd919..64ac174a97 100644
--- a/src/pal/tests/palsuite/c_runtime/CMakeLists.txt
+++ b/src/pal/tests/palsuite/c_runtime/CMakeLists.txt
@@ -139,7 +139,6 @@ add_subdirectory(wcstol)
add_subdirectory(wcstoul)
add_subdirectory(wprintf)
add_subdirectory(_alloca)
-add_subdirectory(_ecvt)
add_subdirectory(_fdopen)
add_subdirectory(_finite)
add_subdirectory(_finitef)
diff --git a/src/pal/tests/palsuite/c_runtime/_ecvt/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/_ecvt/CMakeLists.txt
deleted file mode 100644
index f6aa0cb2d9..0000000000
--- a/src/pal/tests/palsuite/c_runtime/_ecvt/CMakeLists.txt
+++ /dev/null
@@ -1,4 +0,0 @@
-cmake_minimum_required(VERSION 2.8.12.2)
-
-add_subdirectory(test1)
-
diff --git a/src/pal/tests/palsuite/c_runtime/_ecvt/test1/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/_ecvt/test1/CMakeLists.txt
deleted file mode 100644
index 152271cf59..0000000000
--- a/src/pal/tests/palsuite/c_runtime/_ecvt/test1/CMakeLists.txt
+++ /dev/null
@@ -1,17 +0,0 @@
-cmake_minimum_required(VERSION 2.8.12.2)
-
-set(CMAKE_INCLUDE_CURRENT_DIR ON)
-
-set(SOURCES
- test1.cpp
-)
-
-add_executable(paltest_ecvt_test1
- ${SOURCES}
-)
-
-add_dependencies(paltest_ecvt_test1 coreclrpal)
-
-target_link_libraries(paltest_ecvt_test1
- ${COMMON_TEST_LIBRARIES}
-)
diff --git a/src/pal/tests/palsuite/c_runtime/_ecvt/test1/test1.cpp b/src/pal/tests/palsuite/c_runtime/_ecvt/test1/test1.cpp
deleted file mode 100644
index fbcf11ecfc..0000000000
--- a/src/pal/tests/palsuite/c_runtime/_ecvt/test1/test1.cpp
+++ /dev/null
@@ -1,135 +0,0 @@
-// Licensed to the .NET Foundation under one or more agreements.
-// The .NET Foundation licenses this file to you under the MIT license.
-// See the LICENSE file in the project root for more information.
-
-/*=====================================================================
-**
-** Source: c_runtime/_ecvt/test1/test1.c
-**
-** Purpose: Call the _ecvt function on a number of cases. Check that it
-** handles negatives, positives and double bounds correctly. Also check that
-** the 'digit' specification works.
-**
-**
-**===================================================================*/
-
-#include <palsuite.h>
-
-#define INT64_TO_DOUBLE(a) (*(double*)&a)
-
-INT64 NaN = 0x7ff8000000000000;
-INT64 NegativeInfinity = 0xfff0000000000000;
-INT64 NegativeSmall = 0x8000000000000001;
-INT64 PositiveInfinity = 0x7ff0000000000000;
-INT64 PositiveSmall = 0x0000000000000001;
-
-struct testCase
-{
- double value; /* number to be converted */
- int precision; /* number of digits to be stored */
- int decimal; /* (expected) decimal point position for stored
- * number */
- int sign; /* (expected) return value */
- char expResult[256]; /* (expected) character array to be returned
- * NOTE: this necessarily limits precision
- * to a value between 0 and 255 */
- char bsdExpResult[256]; /* (expected) character array to be returned
- * NOTE: this necessarily limits precision
- * to a value between 0 and 255 */
-};
-
-int __cdecl main(int argc, char **argv)
-{
- char *result;
- int testDecimal;
- int testSign;
- int i=0;
-
- struct testCase testCases[] =
- {
- /* odd ball values */
- {INT64_TO_DOUBLE(NaN), 7, 1, 0, "1#QNAN0" },
- /* positive values */
- {0, 0, 0, 0, ""},
- {INT64_TO_DOUBLE(PositiveSmall), 17, -323, 0,
- "49406564584124654"},
- {.00123, 3, -2, 0, "123"},
- {.123, 3, 0, 0, "123"},
- {123, 3, 3, 0, "123"},
- {3.1415926535, 9, 1, 0, "314159265"},
- {3.1415926535, 10, 1, 0, "3141592654"},
- {3.1415926535, 11, 1, 0, "31415926535"},
- {3.1415926535, 12, 1, 0, "314159265350"},
- {184467444073709570000.0, 21, 21, 0, "184467444073709570000",
- "184467444073709568000" },
- {184467444073709570000.0, 22, 21, 0, "1844674440737095700000",
- "1844674440737095680000" },
- {INT64_TO_DOUBLE(PositiveInfinity), 7, 1, 0, "1#INF00" },
- /* negative values */
- {-0, 0, 0, 0, ""},
- {INT64_TO_DOUBLE(NegativeSmall), 17, -323, 1,
- "49406564584124654"},
- {-.00123, 3, -2, 1, "123"},
- {-.123, 3, 0, 1, "123"},
- {-123, 3, 3, 1, "123"},
- {-3.1415926535, 9, 1, 1, "314159265"},
- {-3.1415926535, 10, 1, 1, "3141592654"},
- {-3.1415926535, 11, 1, 1, "31415926535"},
- {-3.1415926535, 12, 1, 1, "314159265350"},
- {-184467444073709570000.0, 21, 21, 1, "184467444073709570000",
- "184467444073709568000" },
- {-184467444073709570000.0, 22, 21, 1, "1844674440737095700000",
- "1844674440737095680000" },
- {INT64_TO_DOUBLE(NegativeInfinity), 7, 1, 1, "1#INF00"}
-
- };
-
- if (0 != (PAL_Initialize(argc, argv)))
- {
- return FAIL;
- }
-
- /* Loop through each case. Call _ecvt on each test case and check the
- result.
- */
-
- for(i = 0; i < sizeof(testCases) / sizeof(struct testCase); i++)
- {
- result = _ecvt(testCases[i].value,
- testCases[i].precision,
- &testDecimal,
- &testSign);
-
- if (( strcmp(testCases[i].expResult, result) != 0 &&
- strcmp(testCases[i].bsdExpResult, result) != 0 ) ||
-
- ( testCases[i].sign != testSign ) ||
- ( testCases[i].decimal != testDecimal ))
-
- {
- Fail("PALSUITE ERROR: Test %d\n"
- "-----------------------\n"
- "testCases[i].value = '%f'\n"
- "testCases[i].precision = '%d'\n"
- "testCases[i].decimal = '%d'\n"
- "testCases[i].sign = '%d'\n"
- "testCases[i].expResult = '%s'\n"
- "result = '%s'\n"
- "testDecimal = '%d'\n"
- "testSign = '%d'\n\n",
- i,
- testCases[i].value,
- testCases[i].precision,
- testCases[i].decimal,
- testCases[i].sign,
- testCases[i].expResult,
- result,
- testDecimal,
- testSign);
- }
-
- }
-
- PAL_Terminate();
- return PASS;
-}
diff --git a/src/pal/tests/palsuite/c_runtime/_ecvt/test1/testinfo.dat b/src/pal/tests/palsuite/c_runtime/_ecvt/test1/testinfo.dat
deleted file mode 100644
index 12e7292ec7..0000000000
--- a/src/pal/tests/palsuite/c_runtime/_ecvt/test1/testinfo.dat
+++ /dev/null
@@ -1,14 +0,0 @@
-# Licensed to the .NET Foundation under one or more agreements.
-# The .NET Foundation licenses this file to you under the MIT license.
-# See the LICENSE file in the project root for more information.
-
-Version = 1.0
-Section = C Runtime
-Function = _ecvt
-Name = Call _ecvt on normal values, negatives, exponents and hex digits.
-TYPE = DEFAULT
-EXE1 = test1
-Description
-= Call the _ecvt function on a number of cases. Check that it
-= handles negatives, positives and double bounds correctly. Also check that
-= the 'digit' specification works.
diff --git a/src/pal/tests/palsuite/paltestlist_to_be_reviewed.txt b/src/pal/tests/palsuite/paltestlist_to_be_reviewed.txt
index 0199ad12f1..16be5e6762 100644
--- a/src/pal/tests/palsuite/paltestlist_to_be_reviewed.txt
+++ b/src/pal/tests/palsuite/paltestlist_to_be_reviewed.txt
@@ -22,7 +22,6 @@ c_runtime/vprintf/test1/paltest_vprintf_test1
c_runtime/vswprintf/test2/paltest_vswprintf_test2
c_runtime/vswprintf/test7/paltest_vswprintf_test7
c_runtime/wprintf/test2/paltest_wprintf_test2
-c_runtime/_ecvt/test1/paltest_ecvt_test1
c_runtime/_gcvt/test1/paltest_gcvt_test1
c_runtime/_gcvt/test2/paltest_gcvt_test2
c_runtime/_getw/test1/paltest_getw_test1
diff --git a/src/pal/tests/palsuite/palverify.dat b/src/pal/tests/palsuite/palverify.dat
index cdcb4cb4e3..3d711c1895 100644
--- a/src/pal/tests/palsuite/palverify.dat
+++ b/src/pal/tests/palsuite/palverify.dat
@@ -4,7 +4,6 @@
c_runtime/__iscsym/test1,1
c_runtime/_alloca/test1,1
-c_runtime/_ecvt/test1,1
c_runtime/_fdopen/test1,1
c_runtime/_finite/test1,1
c_runtime/_finitef/test1,1