forked from dotnet/runtime
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add abs(__int64) overload for 64-bit targets. Fixes dotnet/coreclr#143
Commit migrated from dotnet/coreclr@f7925fd
- Loading branch information
Showing
9 changed files
with
118 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 4 additions & 0 deletions
4
src/coreclr/src/pal/tests/palsuite/c_runtime/llabs/CMakeLists.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
cmake_minimum_required(VERSION 2.8.12.2) | ||
|
||
add_subdirectory(test1) | ||
|
19 changes: 19 additions & 0 deletions
19
src/coreclr/src/pal/tests/palsuite/c_runtime/llabs/test1/CMakeLists.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
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 | ||
) |
66 changes: 66 additions & 0 deletions
66
src/coreclr/src/pal/tests/palsuite/c_runtime/llabs/test1/test1.c
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
// | ||
// 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; | ||
} |
14 changes: 14 additions & 0 deletions
14
src/coreclr/src/pal/tests/palsuite/c_runtime/llabs/test1/testinfo.dat
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
# | ||
# 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. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters