diff options
author | Nick Kledzik <kledzik@apple.com> | 2011-03-17 00:09:13 +0000 |
---|---|---|
committer | Nick Kledzik <kledzik@apple.com> | 2011-03-17 00:09:13 +0000 |
commit | 5c0809916b70dbb754cf0c999e2923909e5603c6 (patch) | |
tree | 875c98489b0419eb321390a6093da33c5116f79a /test/Unit/divmodsi4_test.c | |
parent | 1ea7a40c373d811250eb59259140453461e50c30 (diff) | |
download | compiler-rt-5c0809916b70dbb754cf0c999e2923909e5603c6.tar.gz |
<rdar://problem/8914924> implement udivmodsi4 and divmodsi4 for ARM
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@127778 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test/Unit/divmodsi4_test.c')
-rw-r--r-- | test/Unit/divmodsi4_test.c | 73 |
1 files changed, 73 insertions, 0 deletions
diff --git a/test/Unit/divmodsi4_test.c b/test/Unit/divmodsi4_test.c new file mode 100644 index 000000000..bea31ea9a --- /dev/null +++ b/test/Unit/divmodsi4_test.c @@ -0,0 +1,73 @@ +//===-- divmodsi4_test.c - Test __divmodsi4 -------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// +// +// This file tests __divmodsi4 for the compiler_rt library. +// +//===----------------------------------------------------------------------===// + +#include "int_lib.h" +#include <stdio.h> + +// Returns: a / b + +extern si_int __divmodsi4(si_int a, si_int b, si_int* rem); + + +int test__divmodsi4(si_int a, si_int b, + si_int expected_result, si_int expected_rem) +{ + si_int rem; + si_int result = __divmodsi4(a, b, &rem); + if (result != expected_result) { + printf("error in __divmodsi4: %d / %d = %d, expected %d\n", + a, b, result, expected_result); + return 1; + } + if (rem != expected_rem) { + printf("error in __divmodsi4: %d mod %d = %d, expected %d\n", + a, b, rem, expected_rem); + return 1; + } + + return 0; +} + + +int main() +{ + if (test__divmodsi4(0, 1, 0, 0)) + return 1; + if (test__divmodsi4(0, -1, 0, 0)) + return 1; + + if (test__divmodsi4(2, 1, 2, 0)) + return 1; + if (test__divmodsi4(2, -1, -2, 0)) + return 1; + if (test__divmodsi4(-2, 1, -2, 0)) + return 1; + if (test__divmodsi4(-2, -1, 2, 0)) + return 1; + + if (test__divmodsi4(7, 5, 1, 2)) + return 1; + if (test__divmodsi4(-7, 5, -1, -2)) + return 1; + if (test__divmodsi4(19, 5, 3, 4)) + return 1; + if (test__divmodsi4(19, -5, -3, 4)) + return 1; + + if (test__divmodsi4(0x80000000, 8, 0xf0000000, 0)) + return 1; + if (test__divmodsi4(0x80000007, 8, 0xf0000001, -1)) + return 1; + + return 0; +} |