summaryrefslogtreecommitdiff
path: root/payloads/libpayload
diff options
context:
space:
mode:
authorJulius Werner <jwerner@chromium.org>2024-02-06 22:38:14 -0800
committerFelix Held <felix-coreboot@felixheld.de>2024-02-08 13:13:58 +0000
commitb50602007656962ab6717d63d2f9d83e5c00dacf (patch)
tree16fa6d7f0b2d2f2a9c6d57671928243365673bce /payloads/libpayload
parent3edf840ad15154d38769c0115811906284762b11 (diff)
commonlib: Change GCD function to always use 64 bits
It seems that we have some applications where we need to calculate a GCD in 64 bits. Now, we could instantiate the algorithm multiple times for different bit width combinations to be able to use the most efficient one for each problem... but considering that the function usually only gets called once per callsite per stage, and that software emulation of 64-bit division on 32-bit systems doesn't take *that* long either, we would probably usually be paying more time loading the second instance of the function than we save with faster divisions. So let's just make things easy and always do it in 64-bit and then nobody has to spend time thinking on which version to call. Change-Id: I028361444c4048a0d76ba4f80c7334a9d9983c87 Signed-off-by: Julius Werner <jwerner@chromium.org> Reviewed-on: https://review.coreboot.org/c/coreboot/+/80319 Reviewed-by: Nico Huber <nico.h@gmx.de> Tested-by: build bot (Jenkins) <no-reply@coreboot.org> Reviewed-by: Yidi Lin <yidilin@google.com>
Diffstat (limited to 'payloads/libpayload')
-rw-r--r--payloads/libpayload/libc/getopt_long.c2
-rw-r--r--payloads/libpayload/libc/time.c2
2 files changed, 2 insertions, 2 deletions
diff --git a/payloads/libpayload/libc/getopt_long.c b/payloads/libpayload/libc/getopt_long.c
index 822ce96904..c0303cfea3 100644
--- a/payloads/libpayload/libc/getopt_long.c
+++ b/payloads/libpayload/libc/getopt_long.c
@@ -122,7 +122,7 @@ permute_args(int panonopt_start, int panonopt_end, int opt_end,
*/
nnonopts = panonopt_end - panonopt_start;
nopts = opt_end - panonopt_end;
- ncycle = gcd32(nnonopts, nopts);
+ ncycle = gcd(nnonopts, nopts);
cyclelen = (opt_end - panonopt_start) / ncycle;
for (i = 0; i < ncycle; i++) {
diff --git a/payloads/libpayload/libc/time.c b/payloads/libpayload/libc/time.c
index c38dbfdde8..28f2b3e2a9 100644
--- a/payloads/libpayload/libc/time.c
+++ b/payloads/libpayload/libc/time.c
@@ -182,7 +182,7 @@ u64 timer_us(u64 base)
"must be at least 1MHz.\n", hz);
halt();
}
- div = gcd32(hz, mult);
+ div = gcd(hz, mult);
hz /= div;
mult /= div;
}