d256291
From c38e80269c50494a8357dec19ac8a08dee68d4f2 Mon Sep 17 00:00:00 2001
d256291
From: Kim Phillips <kim.phillips@freescale.com>
d256291
Date: Tue, 19 Feb 2013 11:24:01 -0800
d256291
Subject: [PATCH] sparse: add built-in byte swap identifiers
d256291
d256291
this patch stops sparse from complaining about them not being
d256291
defined:
d256291
d256291
include/uapi/linux/swab.h:60:16: error: undefined identifier '__builtin_bswap32'
d256291
include/uapi/linux/swab.h:60:33: error: not a function <noident>
d256291
d256291
Signed-off-by: Kim Phillips <kim.phillips@freescale.com>
d256291
Signed-off-by: Christopher Li <sparse@chrisli.org>
d256291
---
d256291
 lib.c                      | 5 +++++
d256291
 validation/builtin_bswap.c | 9 +++++++++
d256291
 2 files changed, 14 insertions(+)
d256291
 create mode 100644 validation/builtin_bswap.c
d256291
d256291
diff --git a/lib.c b/lib.c
d256291
index 396e9f1..fa86c2b 100644
d256291
--- a/lib.c
d256291
+++ b/lib.c
d256291
@@ -698,6 +698,11 @@ void declare_builtin_functions(void)
d256291
 	add_pre_buffer("extern int __builtin_popcountl(unsigned long);\n");
d256291
 	add_pre_buffer("extern int __builtin_popcountll(unsigned long long);\n");
d256291
 
d256291
+	/* And byte swaps.. */
d256291
+	add_pre_buffer("extern unsigned short __builtin_bswap16(unsigned short);\n");
d256291
+	add_pre_buffer("extern unsigned int __builtin_bswap32(unsigned int);\n");
d256291
+	add_pre_buffer("extern unsigned long long __builtin_bswap64(unsigned long long);\n");
d256291
+
d256291
 	/* And some random ones.. */
d256291
 	add_pre_buffer("extern void *__builtin_return_address(unsigned int);\n");
d256291
 	add_pre_buffer("extern void *__builtin_extract_return_addr(void *);\n");
d256291
diff --git a/validation/builtin_bswap.c b/validation/builtin_bswap.c
d256291
new file mode 100644
d256291
index 0000000..6a4a907
d256291
--- /dev/null
d256291
+++ b/validation/builtin_bswap.c
d256291
@@ -0,0 +1,9 @@
d256291
+static unsigned short x = __builtin_bswap16(0);
d256291
+static unsigned int y = __builtin_bswap32(0);
d256291
+static unsigned long long z = __builtin_bswap64(0);
d256291
+
d256291
+/*
d256291
+ * check-name: __builtin_bswap
d256291
+ * check-error-start
d256291
+ * check-error-end
d256291
+ */
d256291
-- 
d256291
1.8.1.4
d256291