[coreboot] New patch to review for coreboot: 58e3417 libpayload: Make the symbols in memory.c weak so they can be overridden.

Stefan Reinauer (stefan.reinauer@coreboot.org) gerrit at coreboot.org
Wed Nov 7 00:21:56 CET 2012


Stefan Reinauer (stefan.reinauer at coreboot.org) just uploaded a new patch set to gerrit, which you can find at http://review.coreboot.org/1725

-gerrit

commit 58e3417706308075a5a027ee54b7a2a62b097167
Author: Gabe Black <gabeblack at google.com>
Date:   Thu Sep 27 17:39:41 2012 -0700

    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 at google.com>
---
 payloads/libpayload/libc/memory.c | 13 +++++++++++++
 1 file changed, 13 insertions(+)

diff --git a/payloads/libpayload/libc/memory.c b/payloads/libpayload/libc/memory.c
index 4757b10..5af8538 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;




More information about the coreboot mailing list