aboutsummaryrefslogtreecommitdiff
path: root/lib/string.c
diff options
context:
space:
mode:
authorSimon Glass2017-04-02 09:50:28 -0600
committerSimon Glass2017-04-04 20:01:57 -0600
commitab4458bdb5074ababe09f2538cb9f25901121ebb (patch)
treea995262be8e740ca6964852434e81c599e753be7 /lib/string.c
parent3c00a2c8b5e22e3eff9afb291e555b4bcba17d77 (diff)
string: Provide a slimmed-down memset()
Most of the time the optimised memset() is what we want. For extreme situations such as TPL it may be too large. For example on the 'rock' board, using a simple loop saves a useful 48 bytes. With gcc 4.9 and the rodata bug, this patch is enough to reduce the TPL image below the limit. Signed-off-by: Simon Glass <sjg@chromium.org> Reviewed-by: Heiko Stuebner <heiko@sntech.de>
Diffstat (limited to 'lib/string.c')
-rw-r--r--lib/string.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/lib/string.c b/lib/string.c
index 67d5f6a4213..c1a28c14ced 100644
--- a/lib/string.c
+++ b/lib/string.c
@@ -437,8 +437,10 @@ char *strswab(const char *s)
void * memset(void * s,int c,size_t count)
{
unsigned long *sl = (unsigned long *) s;
- unsigned long cl = 0;
char *s8;
+
+#if !CONFIG_IS_ENABLED(TINY_MEMSET)
+ unsigned long cl = 0;
int i;
/* do it one word at a time (32 bits or 64 bits) while possible */
@@ -452,7 +454,7 @@ void * memset(void * s,int c,size_t count)
count -= sizeof(*sl);
}
}
- /* fill 8 bits at a time */
+#endif /* fill 8 bits at a time */
s8 = (char *)sl;
while (count--)
*s8++ = c;