xref: /freebsd/contrib/llvm-project/compiler-rt/lib/builtins/udivmodsi4.c (revision 0b57cec536236d46e3dba9bd041533462f33dbb7)
1 //===-- udivmodsi4.c - Implement __udivmodsi4 -----------------------------===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8 //
9 // This file implements __udivmodsi4 for the compiler_rt library.
10 //
11 //===----------------------------------------------------------------------===//
12 
13 #include "int_lib.h"
14 
15 // Returns: a / b, *rem = a % b
16 
__udivmodsi4(su_int a,su_int b,su_int * rem)17 COMPILER_RT_ABI su_int __udivmodsi4(su_int a, su_int b, su_int *rem) {
18   si_int d = __udivsi3(a, b);
19   *rem = a - (d * b);
20   return d;
21 }
22