[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Xen-devel] [PATCH] x86/string: Use compiler builtins whenever possible



The use of -fno-builtin inhibits this automatic transformation.  Manually
tranform the callsites.  This causes constructs such as strlen("literal") to
be evaluated at compile time, and certain simple operations to be replaced
with repeated string operations.

Signed-off-by: Andrew Cooper <andrew.cooper3@xxxxxxxxxx>
---
CC: Jan Beulich <JBeulich@xxxxxxxx>
---
 xen/include/asm-x86/string.h | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/xen/include/asm-x86/string.h b/xen/include/asm-x86/string.h
index 34c5561..e194cc1 100644
--- a/xen/include/asm-x86/string.h
+++ b/xen/include/asm-x86/string.h
@@ -13,4 +13,12 @@ extern void *memmove(void *dest, const void *src, size_t n);
 #define __HAVE_ARCH_MEMSET
 #define memset(s,c,n) (__builtin_memset((s),(c),(n)))
 
+#define strcmp(s1, s2)     __builtin_strcmp(s1, s2)
+#define strncmp(s1, s2, n) __builtin_strncmp(s1, s2, n)
+#define strcasecmp(s1, s2) __builtin_strcasecmp(s1, s2)
+#define strchr(s1, c)      __builtin_strchr(s1, c)
+#define strrchr(s1, c)     __builtin_strrchr(s1, c)
+#define strstr(s1, s2)     __builtin_strstr(s1, s2)
+#define strlen(s1)         __builtin_strlen(s1)
+
 #endif /* __X86_STRING_H__ */
-- 
2.1.4


_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxx
https://lists.xen.org/xen-devel

 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.