blob: 4dc1978282a461e90f8fc2450de253bd44c7901b [file] [log] [blame]
Nick Kledzik5c080992011-03-17 00:09:13 +00001/*===-- divmodsi4.c - Implement __divmodsi4 --------------------------------===
2 *
3 * The LLVM Compiler Infrastructure
4 *
5 * This file is dual licensed under the MIT and the University of Illinois Open
6 * Source Licenses. See LICENSE.TXT for details.
7 *
8 * ===----------------------------------------------------------------------===
9 *
10 * This file implements __divmodsi4 for the compiler_rt library.
11 *
12 * ===----------------------------------------------------------------------===
13 */
Anton Korobeynikov1c5f89b2011-04-19 17:52:09 +000014#include "abi.h"
Nick Kledzik5c080992011-03-17 00:09:13 +000015
16#include "int_lib.h"
17
Anton Korobeynikov1c5f89b2011-04-19 17:52:09 +000018extern COMPILER_RT_ABI si_int __divsi3(si_int a, si_int b);
Nick Kledzik5c080992011-03-17 00:09:13 +000019
20
21/* Returns: a / b, *rem = a % b */
22
Anton Korobeynikov1c5f89b2011-04-19 17:52:09 +000023COMPILER_RT_ABI si_int
Nick Kledzik5c080992011-03-17 00:09:13 +000024__divmodsi4(si_int a, si_int b, si_int* rem)
25{
26 si_int d = __divsi3(a,b);
27 *rem = a - (d*b);
28 return d;
29}
30
31