blob: 2a3ee27f8dcfaae51c23ce6380e0b629b2081f8b [file] [log] [blame]
Nick Kledzik5c080992011-03-17 00:09:13 +00001/*===-- udivmodsi4.c - Implement __udivmodsi4 ------------------------------===
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 __udivmodsi4 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 su_int COMPILER_RT_ABI __udivsi3(su_int n, su_int d);
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 su_int
Nick Kledzik5c080992011-03-17 00:09:13 +000024__udivmodsi4(su_int a, su_int b, su_int* rem)
25{
26 si_int d = __udivsi3(a,b);
27 *rem = a - (d*b);
Anton Korobeynikov1c5f89b2011-04-19 17:52:09 +000028 return d;
Nick Kledzik5c080992011-03-17 00:09:13 +000029}
30
31