repo.or.cz
/
coreboot2.git
/
blob
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
log
|
graphiclog1
|
graphiclog2
|
commit
|
commitdiff
|
tree
|
refs
|
edit
|
fork
blame
|
history
|
raw
|
HEAD
mb/starlabs/{lite_adl,byte_adl}: Don't select MAINBOARD_HAS_TPM2
[coreboot2.git]
/
src
/
commonlib
/
bsd
/
gcd.c
blob
fbc8103a32eecf99d80192b75f2f634dd89ae7ee
1
/* SPDX-License-Identifier: BSD-3-Clause */
2
3
#include <commonlib/bsd/gcd.h>
4
#include <commonlib/bsd/helpers.h>
5
#include <stdint.h>
6
7
uint64_t
gcd
(
uint64_t
a
,
uint64_t
b
)
8
{
9
uint64_t
c
;
10
11
if
(
a
==
0
||
b
==
0
)
12
return
MAX
(
a
,
b
);
13
14
c
=
a
%
b
;
15
16
while
(
c
>
0
) {
17
a
=
b
;
18
b
=
c
;
19
c
=
a
%
b
;
20
}
21
22
return
b
;
23
}