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)
This commit is contained in:
parent
5ab20054d3
commit
c324794cb0
|
@ -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;
|
||||
|
|
Loading…
Reference in New Issue