brintos

brintos / llvm-project-archived public Read only

0
0
Text · 1.0 KiB · a405a45 Raw
50 lines · c
1// RUN: %clang_builtins %s %librt -o %t && %run %t2// REQUIRES: librt_has_udivmodsi43 4#include "int_lib.h"5#include <stdio.h>6 7// Returns: a / b8 9extern COMPILER_RT_ABI su_int __udivmodsi4(su_int a, su_int b, su_int* rem);10 11int test__udivmodsi4(su_int a, su_int b, 12						su_int expected_result, su_int expected_rem)13{14	su_int rem;15    su_int result = __udivmodsi4(a, b, &rem);16    if (result != expected_result) {17        printf("error in __udivmodsi4: %u / %u = %u, expected %u\n",18               a, b, result, expected_result);19		return 1;20	}21    if (rem != expected_rem) {22        printf("error in __udivmodsi4: %u mod %u = %u, expected %u\n",23               a, b, rem, expected_rem);24		return 1;25	}26	27    return 0;28}29 30 31int main()32{33    if (test__udivmodsi4(0, 1, 0, 0))34        return 1;35 36    if (test__udivmodsi4(2, 1, 2, 0))37        return 1;38 39	if (test__udivmodsi4(19, 5, 3, 4))40        return 1;41 42	if (test__udivmodsi4(0x80000000, 8, 0x10000000, 0))43        return 1;44  	45 	if (test__udivmodsi4(0x80000003, 8, 0x10000000, 3))46        return 1;47 48	return 0;49}50