xref: /freebsd/contrib/llvm-project/compiler-rt/lib/builtins/divmoddi4.c (revision cfd6422a5217410fbd66f7a7a8a64d9d85e61229)
1 //===-- divmoddi4.c - Implement __divmoddi4 -------------------------------===//
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 __divmoddi4 for the compiler_rt library.
10 //
11 //===----------------------------------------------------------------------===//
12 
13 #include "int_lib.h"
14 
15 // Returns: a / b, *rem = a % b
16 
17 COMPILER_RT_ABI di_int __divmoddi4(di_int a, di_int b, di_int *rem) {
18   di_int d = __divdi3(a, b);
19   *rem = a - (d * b);
20   return d;
21 }
22