linux-sparse.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Kim Phillips <kim.phillips@freescale.com>
To: Christopher Li <sparse@chrisli.org>
Cc: linux-sparse@vger.kernel.org
Subject: [PATCH v2] sparse: add built-in byte swap identifiers
Date: Tue, 19 Feb 2013 11:41:03 -0600	[thread overview]
Message-ID: <20130219114103.4630a9053ef81cd4e0e1a7b8@freescale.com> (raw)
In-Reply-To: <CANeU7Q=W8zZEngeweCGDkEpPGJMrADFgnibQVUFvGBwsppVq=A@mail.gmail.com>

this patch stops sparse from complaining about them not being
defined:

include/uapi/linux/swab.h:60:16: error: undefined identifier '__builtin_bswap32'
include/uapi/linux/swab.h:60:33: error: not a function <noident>

Signed-off-by: Kim Phillips <kim.phillips@freescale.com>
---
v2: add a test for builtin_bswap{16,32,64}

 lib.c                      | 5 +++++
 validation/builtin_bswap.c | 9 +++++++++
 2 files changed, 14 insertions(+)
 create mode 100644 validation/builtin_bswap.c

diff --git a/lib.c b/lib.c
index 6bd10d3..4f69e11 100644
--- a/lib.c
+++ b/lib.c
@@ -727,6 +727,11 @@ void declare_builtin_functions(void)
 	add_pre_buffer("extern int __builtin_popcountl(unsigned long);\n");
 	add_pre_buffer("extern int __builtin_popcountll(unsigned long long);\n");
 
+	/* And byte swaps.. */
+	add_pre_buffer("extern unsigned short __builtin_bswap16(unsigned short);\n");
+	add_pre_buffer("extern unsigned int __builtin_bswap32(unsigned int);\n");
+	add_pre_buffer("extern unsigned long long __builtin_bswap64(unsigned long long);\n");
+
 	/* And some random ones.. */
 	add_pre_buffer("extern void *__builtin_return_address(unsigned int);\n");
 	add_pre_buffer("extern void *__builtin_extract_return_addr(void *);\n");
diff --git a/validation/builtin_bswap.c b/validation/builtin_bswap.c
new file mode 100644
index 0000000..6a4a907
--- /dev/null
+++ b/validation/builtin_bswap.c
@@ -0,0 +1,9 @@
+static unsigned short x = __builtin_bswap16(0);
+static unsigned int y = __builtin_bswap32(0);
+static unsigned long long z = __builtin_bswap64(0);
+
+/*
+ * check-name: __builtin_bswap
+ * check-error-start
+ * check-error-end
+ */
-- 
1.8.1.3



  reply	other threads:[~2013-02-19 17:44 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-02-19  0:36 [PATCH] sparse: add built-in byte swap identifiers Kim Phillips
2013-02-19  5:59 ` Christopher Li
2013-02-19 17:41   ` Kim Phillips [this message]
2013-02-19 19:13     ` [PATCH v2] " Christopher Li

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=20130219114103.4630a9053ef81cd4e0e1a7b8@freescale.com \
    --to=kim.phillips@freescale.com \
    --cc=linux-sparse@vger.kernel.org \
    --cc=sparse@chrisli.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).