summaryrefslogtreecommitdiff
path: root/payloads/libpayload
diff options
context:
space:
mode:
authorGabe Black <gabeblack@google.com>2012-09-27 17:39:41 -0700
committerStefan Reinauer <stefan.reinauer@coreboot.org>2012-11-07 18:30:56 +0100
commitc324794cb09d0c6495992c9f6cece6e4c67f8c9f (patch)
tree19bd0320d0e71b3edc095b09278d6dfb5fbbf7b0 /payloads/libpayload
parent5ab20054d3c6e637fbcde46a08d2a3c0891bf658 (diff)
libpayload: Make the symbols in memory.c weak so they can be overridden.
The implementations for various stdlib functions in libc/memory.c are very generic and should work under just about any circumstances. They are unfortunately also very slow. This change makes them weak symbols so that faster versions can be defined on a per architecture basis which will automatically take the place of the slow versions. Change-Id: Ia1ac90d9dcd45962b2a15f61ecc74b0a4676048d Signed-off-by: Gabe Black <gabeblack@google.com> Reviewed-on: http://review.coreboot.org/1725 Reviewed-by: Patrick Georgi <patrick@georgi-clan.de> Tested-by: build bot (Jenkins)
Diffstat (limited to 'payloads/libpayload')
-rw-r--r--payloads/libpayload/libc/memory.c13
1 files changed, 13 insertions, 0 deletions
diff --git a/payloads/libpayload/libc/memory.c b/payloads/libpayload/libc/memory.c
index 4757b10596..5af85389fe 100644
--- a/payloads/libpayload/libc/memory.c
+++ b/payloads/libpayload/libc/memory.c
@@ -34,6 +34,9 @@
#include <libpayload.h>
void *memset(void *s, int c, size_t n)
+ __attribute__((weak, alias("default_memset")));
+
+void *default_memset(void *s, int c, size_t n)
{
char *os = s;
@@ -44,6 +47,9 @@ void *memset(void *s, int c, size_t n)
}
void *memcpy(void *dst, const void *src, size_t n)
+ __attribute__((weak, alias("default_memcpy")));
+
+void *default_memcpy(void *dst, const void *src, size_t n)
{
int i;
void *ret = dst;
@@ -62,6 +68,9 @@ void *memcpy(void *dst, const void *src, size_t n)
}
void *memmove(void *dst, const void *src, size_t n)
+ __attribute__((weak, alias("default_memmove")));
+
+void *default_memmove(void *dst, const void *src, size_t n)
{
int i;
unsigned long offs;
@@ -90,7 +99,11 @@ void *memmove(void *dst, const void *src, size_t n)
* @return If len is 0, return zero. If the areas match, return zero.
* Otherwise return non-zero.
*/
+
int memcmp(const void *s1, const void *s2, size_t len)
+ __attribute__((weak, alias("default_memcmp")));
+
+int default_memcmp(const void *s1, const void *s2, size_t len)
{
for (; len && *(char *)s1++ == *(char *)s2++; len--) ;
return len;