coreboot
coreboot is an Open Source project aimed at replacing the proprietary BIOS found in most computers.
udivmoddi4.c
Go to the documentation of this file.
1
/* SPDX-License-Identifier: GPL-2.0-only */
2
3
#include "
libgcc.h
"
4
5
uint64_t
__udivmoddi4
(
uint64_t
num,
uint64_t
den,
uint64_t
*rem_p)
6
{
7
uint64_t
quot = 0, qbit = 1;
8
if
(den == 0) {
9
return
1 / ((
unsigned
int)den);
/* Intentional divide by zero, without
10
triggering a compiler warning which
11
would abort the build */
12
}
13
14
/* Left-justify denominator and count shift */
15
while
((
int64_t
)den >= 0) {
16
den <<= 1;
17
qbit <<= 1;
18
}
19
20
while
(qbit) {
21
if
(den <= num) {
22
num -= den;
23
quot += qbit;
24
}
25
den >>= 1;
26
qbit >>= 1;
27
}
28
29
if
(rem_p)
30
*rem_p = num;
31
32
return
quot;
33
}
libgcc.h
uint64_t
unsigned long long uint64_t
Definition:
stdint.h:17
int64_t
signed long long int64_t
Definition:
stdint.h:16
__udivmoddi4
uint64_t __udivmoddi4(uint64_t num, uint64_t den, uint64_t *rem_p)
Definition:
udivmoddi4.c:5
src
arch
arm
libgcc
udivmoddi4.c
Generated by
1.9.1