aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
authorKim Phillips <kim.phillips@freescale.com>2013-02-19 11:24:01 -0800
committerChristopher Li <sparse@chrisli.org>2013-02-19 11:24:01 -0800
commit8e42bac6efcb047a2b3d812e42c00f82e3b8a984 (patch)
tree8eaf392717dbd7c71928a0d129e2e01d7576e9ac
parent1b8e012d10d2a5af2d4935e4a47df9c527399219 (diff)
downloadsparse-dev-8e42bac6efcb047a2b3d812e42c00f82e3b8a984.tar.gz
sparse: add built-in byte swap identifiers
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> Signed-off-by: Christopher Li <sparse@chrisli.org>
-rw-r--r--lib.c5
-rw-r--r--validation/builtin_bswap.c9
2 files changed, 14 insertions, 0 deletions
diff --git a/lib.c b/lib.c
index 6bd10d36..4f69e119 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 00000000..6a4a9072
--- /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
+ */