All of lore.kernel.org
 help / color / mirror / Atom feed
From: Andrew Cooper <andrew.cooper3@citrix.com>
To: Xen-devel <xen-devel@lists.xen.org>
Cc: Andrew Cooper <andrew.cooper3@citrix.com>,
	Jan Beulich <JBeulich@suse.com>
Subject: [PATCH] x86/string: Use compiler builtins whenever possible
Date: Tue, 9 Aug 2016 13:41:01 +0100	[thread overview]
Message-ID: <1470746461-26827-1-git-send-email-andrew.cooper3@citrix.com> (raw)

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@citrix.com>
---
CC: Jan Beulich <JBeulich@suse.com>
---
 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@lists.xen.org
https://lists.xen.org/xen-devel

             reply	other threads:[~2016-08-09 12:41 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-08-09 12:41 Andrew Cooper [this message]
2016-08-09 14:01 ` [PATCH] x86/string: Use compiler builtins whenever possible Jan Beulich
2016-08-09 14:27   ` Andrew Cooper
2016-08-09 14:39     ` Jan Beulich
2016-08-10 12:12       ` Andrew Cooper

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1470746461-26827-1-git-send-email-andrew.cooper3@citrix.com \
    --to=andrew.cooper3@citrix.com \
    --cc=JBeulich@suse.com \
    --cc=xen-devel@lists.xen.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.