brintos

brintos / llvm-project-archived public Read only

0
0
Text · 1.4 KiB · b6160d2 Raw
64 lines · c
1// RUN: %clang_builtins %s %librt -o %t && %run %t2// REQUIRES: librt_has_divmodsi43 4#include "int_lib.h"5#include <stdio.h>6 7// Returns: a / b8 9extern COMPILER_RT_ABI si_int __divmodsi4(si_int a, si_int b, si_int* rem);10 11 12int test__divmodsi4(si_int a, si_int b, 13						si_int expected_result, si_int expected_rem)14{15	si_int rem;16    si_int result = __divmodsi4(a, b, &rem);17    if (result != expected_result) {18        printf("error in __divmodsi4: %d / %d = %d, expected %d\n",19               a, b, result, expected_result);20		return 1;21	}22    if (rem != expected_rem) {23        printf("error in __divmodsi4: %d mod %d = %d, expected %d\n",24               a, b, rem, expected_rem);25		return 1;26	}27	28    return 0;29}30 31 32int main()33{34    if (test__divmodsi4(0, 1, 0, 0))35        return 1;36    if (test__divmodsi4(0, -1, 0, 0))37        return 1;38 39    if (test__divmodsi4(2, 1, 2, 0))40        return 1;41    if (test__divmodsi4(2, -1, -2, 0))42        return 1;43    if (test__divmodsi4(-2, 1, -2, 0))44        return 1;45    if (test__divmodsi4(-2, -1, 2, 0))46        return 1;47 48	if (test__divmodsi4(7, 5, 1, 2))49        return 1;50	if (test__divmodsi4(-7, 5, -1, -2))51        return 1;52	if (test__divmodsi4(19, 5, 3, 4))53        return 1;54	if (test__divmodsi4(19, -5, -3, 4))55        return 1;56  	57	if (test__divmodsi4(0x80000000, 8, 0xf0000000, 0))58        return 1;59	if (test__divmodsi4(0x80000007, 8, 0xf0000001, -1))60        return 1;61 62    return 0;63}64