1// RUN: %clang_builtins %s %librt -o %t && %run %t 2//===-- umoddi3_test.c - Test __umoddi3 -----------------------------------===// 3// 4// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 5// See https://llvm.org/LICENSE.txt for license information. 6// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 7// 8//===----------------------------------------------------------------------===// 9// 10// This file tests __umoddi3 for the compiler_rt library. 11// 12//===----------------------------------------------------------------------===// 13 14#include "int_lib.h" 15#include <stdio.h> 16 17// Returns: a % b 18 19COMPILER_RT_ABI du_int __umoddi3(du_int a, du_int b); 20 21int test__umoddi3(du_int a, du_int b, du_int expected_r) 22{ 23 du_int r = __umoddi3(a, b); 24 if (r != expected_r) 25 printf("error in __umoddi3: %lld %% %lld = %lld, expected %lld\n", 26 a, b, r, expected_r); 27 return r != expected_r; 28} 29 30int main() 31{ 32 if (test__umoddi3(0, 1, 0)) 33 return 1; 34 if (test__umoddi3(2, 1, 0)) 35 return 1; 36 if (test__umoddi3(0x8000000000000000uLL, 1, 0x0uLL)) 37 return 1; 38 if (test__umoddi3(0x8000000000000000uLL, 2, 0x0uLL)) 39 return 1; 40 if (test__umoddi3(0xFFFFFFFFFFFFFFFFuLL, 2, 0x1uLL)) 41 return 1; 42 43 return 0; 44} 45