]> xenbits.xensource.com Git - people/andrewcoop/xen-test-framework.git/commitdiff
Fix the declarations of __builtin_*() string functions
authorAndrew Cooper <andrew.cooper3@citrix.com>
Thu, 4 May 2017 11:29:46 +0000 (11:29 +0000)
committerAndrew Cooper <andrew.cooper3@citrix.com>
Mon, 5 Jun 2017 10:47:39 +0000 (11:47 +0100)
The underlying function declaration needs to be ahead of the define which
alters the default to its __builtin_*() version

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
common/libc/string.c
include/xtf/libc.h

index 96d0986aba7e057fb5b5236c1174a1f73e015fda..5d972dd3f0607ca46f183dee70fa1614e32eb7ac 100644 (file)
@@ -1,6 +1,6 @@
-#include <xtf/types.h>
+#include <xtf/libc.h>
 
-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;
index 893f6b87556bdbd4648dff9124bf1470b8eb7dae..18ec5f03b51ca49a3d39054bfc596f9f7fa16f42 100644 (file)
  * 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);