PALIMPORT int __cdecl abs(int);
PALIMPORT double __cdecl fabs(double);
PALIMPORT LONG __cdecl labs(LONG);
+// clang complains if this is declared with __int64
+PALIMPORT long long __cdecl llabs(long long);
PALIMPORT double __cdecl sqrt(double);
PALIMPORT double __cdecl log(double);
extern "C++" {
inline float fabsf(float _X)
{
- return ((float)fabs((double)_X)); }
+ return ((float)fabs((double)_X));
+}
+
+#ifdef BIT64
+inline __int64 abs(__int64 _X) {
+ return llabs(_X);
+}
+#endif
}
#endif
#define time_t PAL_time_t
#define va_list DUMMY_va_list
#define abs DUMMY_abs
+#define llabs DUMMY_llabs
#define atan DUMMY_atan
#define tan DUMMY_tan
#define cos DUMMY_cos
#undef stderr
#undef abs
#undef labs
+#undef llabs
#undef acos
#undef asin
#undef atan2
add_subdirectory(iswxdigit)
add_subdirectory(isxdigit)
add_subdirectory(labs)
+add_subdirectory(llabs)
add_subdirectory(localtime)
add_subdirectory(log)
add_subdirectory(log10)
--- /dev/null
+cmake_minimum_required(VERSION 2.8.12.2)
+
+add_subdirectory(test1)
+
--- /dev/null
+cmake_minimum_required(VERSION 2.8.12.2)
+
+set(CMAKE_INCLUDE_CURRENT_DIR ON)
+
+set(SOURCES
+ test1.c
+)
+
+add_executable(paltest_llabs_test1
+ ${SOURCES}
+)
+
+add_dependencies(paltest_llabs_test1 CoreClrPal)
+
+target_link_libraries(paltest_llabs_test1
+ pthread
+ m
+ CoreClrPal
+)
--- /dev/null
+//
+// Copyright (c) Microsoft. All rights reserved.
+// Licensed under the MIT license. See LICENSE file in the project root for full license information.
+//
+
+/*=====================================================================
+**
+** Source: test1.c
+**
+** Purpose: Call llabs on a series of values -- negative, positive,
+** zero, and the largest negative value of an __int64. Ensure that
+** they are all changed properly to their absoulte value.
+**
+**
+**===================================================================*/
+
+#include <palsuite.h>
+
+struct testCase
+{
+ __int64 LongLongValue;
+ __int64 AbsoluteLongLongValue;
+};
+
+int __cdecl main(int argc, char **argv)
+{
+
+ __int64 result=0;
+ int i=0;
+
+ struct testCase testCases[] =
+ {
+ {1234, 1234},
+ {-1234, 1234},
+ {0, 0},
+ {-9223372036854775807LL, 9223372036854775807LL}, /* Max value to abs */
+ {9223372036854775807LL, 9223372036854775807LL}
+ };
+
+ if (0 != (PAL_Initialize(argc, argv)))
+ {
+ return FAIL;
+ }
+
+ /* Loop through each case. Call labs on each LONG and ensure that
+ the resulting value is correct.
+ */
+
+ for(i = 0; i < sizeof(testCases) / sizeof(struct testCase); i++)
+ {
+ /* Absolute value on a LONG */
+ result = llabs(testCases[i].LongLongValue);
+
+ if (testCases[i].AbsoluteLongLongValue != result)
+ {
+ Fail("ERROR: labs took the absoulte value of '%d' to be '%d' "
+ "instead of %d.\n",
+ testCases[i].LongLongValue,
+ result,
+ testCases[i].AbsoluteLongLongValue);
+ }
+ }
+
+ PAL_Terminate();
+ return PASS;
+}
--- /dev/null
+#
+# Copyright (c) Microsoft Corporation. All rights reserved.
+#
+
+Version = 1.0
+Section = C Runtime
+Function = labs
+Name = Series of tests for labs: positive, negative, zero, maximum __int64 value.
+TYPE = DEFAULT
+EXE1 = test1
+Description
+= Call llabs on a series of values -- negative, positive, zero,
+= and the largest negative value of an __int64. Ensure that they are all
+= changed properly to their absoulte value.
c_runtime/iswxdigit/test1/paltest_iswxdigit_test1
c_runtime/isxdigit/test1/paltest_isxdigit_test1
c_runtime/labs/test1/paltest_labs_test1
+c_runtime/llabs/test1/paltest_llabs_test1
c_runtime/localtime/test1/paltest_localtime_test1
c_runtime/log/test1/paltest_log_test1
c_runtime/log10/test1/paltest_log10_test1
c_runtime/iswxdigit/test1,1
c_runtime/isxdigit/test1,1
c_runtime/labs/test1,1
+c_runtime/llabs/test1,1
c_runtime/localtime/test1,1
c_runtime/log/test1,1
c_runtime/log10/test1,1