From e63990ef34f39419d12ab9211d44621dc3768198 Mon Sep 17 00:00:00 2001 From: Vadim Bendebury Date: Thu, 27 Nov 2014 18:50:14 -0800 Subject: libpayload: provide basic 64bit division implementation These functions are usually provided by gcc lib, which is not supposed to be included on embedded platforms. This patch adds a no thrills C implementation. Other than MIPS platforms are happy using the gcc library provided implementation, but in case of Chrome OS MIPS toolchain the libraries are compiled with the small GOT, such that the entire data segment does not fit. With this implementation mips, arm and x86 targets build fine. BRANCH=none BUG=chrome-os-partner:31438 TEST=checked the logic by incorporating this code into a C file and running a loop continuously comparing random inputs' division and left and right shift results. The test ran for extended periods of time without failure. Change-Id: I468acd2fdbcdd493a76758a394e79cad35f9535a Signed-off-by: Patrick Georgi Original-Commit-Id: 2cc5f8668dd2609408af8da5a74c5a3d063fc0d3 Original-Change-Id: Ib46616d7eb0b2b497199270057514f730bb1cb0b Original-Signed-off-by: Vadim Bendebury Original-Reviewed-on: https://chromium-review.googlesource.com/232232 Original-Reviewed-by: Aaron Durbin Reviewed-on: http://review.coreboot.org/8742 Tested-by: build bot (Jenkins) Reviewed-by: Stefan Reinauer Reviewed-by: Paul Menzel --- payloads/libpayload/include/stdlib.h | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'payloads/libpayload/include/stdlib.h') diff --git a/payloads/libpayload/include/stdlib.h b/payloads/libpayload/include/stdlib.h index e571d18f0b..deb5e3dac4 100644 --- a/payloads/libpayload/include/stdlib.h +++ b/payloads/libpayload/include/stdlib.h @@ -225,4 +225,9 @@ void exit(int status) __attribute__ ((noreturn)); void qsort(void *aa, size_t n, size_t es, int (*cmp)(const void *, const void *)); char *getenv(const char*); +uint64_t __umoddi3(uint64_t num, uint64_t den); +uint64_t __udivdi3(uint64_t num, uint64_t den); +uint64_t __ashldi3(uint64_t num, unsigned shift); +uint64_t __lshrdi3(uint64_t num, unsigned shift); + #endif -- cgit v1.2.3