diff options
author | Paolo Bonzini <pbonzini@redhat.com> | 2016-09-06 16:17:36 +0200 |
---|---|---|
committer | Paolo Bonzini <pbonzini@redhat.com> | 2016-09-06 16:19:37 +0200 |
commit | 5ea29a8e87a24ac9e2b1ab4f05094102af6a3c9d (patch) | |
tree | d3a23ca084651f2c3d31e720e2c7475598cc5a3d | |
parent | f980302461faad89a3fd1075e5c977c9f6f9d58e (diff) | |
download | qboot-5ea29a8e87a24ac9e2b1ab4f05094102af6a3c9d.zip qboot-5ea29a8e87a24ac9e2b1ab4f05094102af6a3c9d.tar.gz qboot-5ea29a8e87a24ac9e2b1ab4f05094102af6a3c9d.tar.bz2 |
inline string functions to movsb/stosb
-rw-r--r-- | Makefile | 1 | ||||
-rw-r--r-- | include/string.h | 12 | ||||
-rw-r--r-- | string.c | 23 |
3 files changed, 11 insertions, 25 deletions
@@ -13,6 +13,7 @@ BIOS_CFLAGS += -march=i386 BIOS_CFLAGS += -mregparm=3 BIOS_CFLAGS += -fno-stack-protector -fno-delete-null-pointer-checks BIOS_CFLAGS += -ffreestanding +BIOS_CFLAGS += -mstringop-strategy=rep_byte -minline-all-stringops BIOS_CFLAGS += -Iinclude dummy := $(shell mkdir -p .deps) diff --git a/include/string.h b/include/string.h index fb20869..c939cd0 100644 --- a/include/string.h +++ b/include/string.h @@ -9,12 +9,20 @@ char *strcpy(char *dest, const char *src); int strcmp(const char *a, const char *b); char *strchr(const char *s, int c); char *strstr(const char *s1, const char *s2); -void *memset(void *s, int c, size_t n); -void *memcpy(void *dest, const void *src, size_t n); int memcmp(const void *s1, const void *s2, size_t n); void *memmove(void *dest, const void *src, size_t n); void *memchr(const void *s, int c, size_t n); +static inline void *memset(void *s, int c, size_t n) +{ + return __builtin_memset(s, c, n); +} + +static inline void *memcpy(void *dest, const void *src, size_t n) +{ + return __builtin_memcpy(dest, src, n); +} + void *malloc(int n); void *malloc_fseg(int n); @@ -62,29 +62,6 @@ char *strstr(const char *s1, const char *s2) return NULL; } -void *memset(void *s, int c, size_t n) -{ - size_t i; - char *a = s; - - for (i = 0; i < n; ++i) - a[i] = c; - - return s; -} - -void *memcpy(void *dest, const void *src, size_t n) -{ - size_t i; - char *a = dest; - const char *b = src; - - for (i = 0; i < n; ++i) - a[i] = b[i]; - - return dest; -} - int memcmp(const void *s1, const void *s2, size_t n) { const unsigned char *a = s1, *b = s2; |