From: Andrew Cooper Date: Thu, 4 May 2017 11:29:46 +0000 (+0000) Subject: Fix the declarations of __builtin_*() string functions X-Git-Url: http://xenbits.xensource.com/gitweb?a=commitdiff_plain;h=f43f843409fd098d2a8d975dd4cde7132b4ebe00;p=people%2Fandrewcoop%2Fxen-test-framework.git Fix the declarations of __builtin_*() string functions The underlying function declaration needs to be ahead of the define which alters the default to its __builtin_*() version Signed-off-by: Andrew Cooper --- diff --git a/common/libc/string.c b/common/libc/string.c index 96d0986..5d972dd 100644 --- a/common/libc/string.c +++ b/common/libc/string.c @@ -1,6 +1,6 @@ -#include +#include -size_t strlen(const char *str) +size_t (strlen)(const char *str) { const char *s = str; @@ -20,7 +20,7 @@ size_t strnlen(const char *str, size_t max) return s - str; } -int strcmp(const char *_s1, const char *_s2) +int (strcmp)(const char *_s1, const char *_s2) { char s1, s2; @@ -32,7 +32,7 @@ int strcmp(const char *_s1, const char *_s2) return (s1 < s2) ? -1 : (s1 > s2); } -void *memset(void *s, int c, size_t n) +void *(memset)(void *s, int c, size_t n) { char *p = s; @@ -42,7 +42,7 @@ void *memset(void *s, int c, size_t n) return s; } -void *memcpy(void *_d, const void *_s, size_t n) +void *(memcpy)(void *_d, const void *_s, size_t n) { char *d = _d; const char *s = _s; @@ -53,7 +53,7 @@ void *memcpy(void *_d, const void *_s, size_t n) return _d; } -int memcmp(const void *s1, const void *s2, size_t n) +int (memcmp)(const void *s1, const void *s2, size_t n) { const unsigned char *u1 = s1, *u2 = s2; int res = 0; diff --git a/include/xtf/libc.h b/include/xtf/libc.h index 893f6b8..18ec5f0 100644 --- a/include/xtf/libc.h +++ b/include/xtf/libc.h @@ -14,18 +14,22 @@ * a call to ???(), which needs implementing in common/libc/ */ +size_t strlen(const char *str); #define strlen(s) __builtin_strlen(s) + +int strcmp(const char *s1, const char *s2); #define strcmp(s1, s2) __builtin_strcmp(s1, s2) + +void *memset(void *s, int c, size_t n); #define memset(d, c, n) __builtin_memset(d, c, n) + +void *memcpy(void *dst, const void *src, size_t n); #define memcpy(d, s, n) __builtin_memcpy(d, s, n) + +int memcmp(const void *s1, const void *s2, size_t n); #define memcmp(s1, s2, n) __builtin_memcmp(s1, s2, n) -size_t strlen(const char *str); size_t strnlen(const char *str, size_t max); -int strcmp(const char *s1, const char *s2); -void *memset(void *s, int c, size_t n); -void *memcpy(void *dst, const void *src, size_t n); -int memcmp(const void *s1, const void *s2, size_t n); int __printf(3, 0) vsnprintf(char *buf, size_t size, const char *fmt, va_list args);