diff mbox

[v2] sparse: add built-in byte swap identifiers

Message ID 20130219114103.4630a9053ef81cd4e0e1a7b8@freescale.com (mailing list archive)
State Mainlined, archived
Headers show

Commit Message

Kim Phillips Feb. 19, 2013, 5:41 p.m. UTC
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

Comments

Christopher Li Feb. 19, 2013, 7:13 p.m. UTC | #1
On Tue, Feb 19, 2013 at 9:41 AM, Kim Phillips
<kim.phillips@freescale.com> wrote:
> this patch stops sparse from complaining about them not being
> defined:

> v2: add a test for builtin_bswap{16,32,64}

Looks good to me. I will apply that.

Thanks

Chris
--
To unsubscribe from this list: send the line "unsubscribe linux-sparse" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

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
+ */