linux-sparse.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] sparse: add built-in byte swap identifiers
@ 2013-02-19  0:36 Kim Phillips
  2013-02-19  5:59 ` Christopher Li
  0 siblings, 1 reply; 4+ messages in thread
From: Kim Phillips @ 2013-02-19  0:36 UTC (permalink / raw)
  To: linux-sparse; +Cc: Christopher Li

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>
---
Based on:

git://git.kernel.org/pub/scm/devel/sparse/chrisl/sparse.git

since it's more up-to-date than:

git://git.kernel.org/pub/scm/devel/sparse/sparse.git

which is what's advertised as the main sparse tree, here:

https://sparse.wiki.kernel.org/index.php/Main_Page

 lib.c |    5 +++++
 1 file changed, 5 insertions(+)

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");
-- 
1.7.9.7


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH] sparse: add built-in byte swap identifiers
  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   ` [PATCH v2] " Kim Phillips
  0 siblings, 1 reply; 4+ messages in thread
From: Christopher Li @ 2013-02-19  5:59 UTC (permalink / raw)
  To: Kim Phillips; +Cc: linux-sparse

On Mon, Feb 18, 2013 at 4:36 PM, Kim Phillips
<kim.phillips@freescale.com> wrote:
>
> which is what's advertised as the main sparse tree, here:
>
> https://sparse.wiki.kernel.org/index.php/Main_Page
>
>  lib.c |    5 +++++
>  1 file changed, 5 insertions(+)
>
> 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.. */

Looks good. Can you please add a test case for __buitin_bswap{16,32,64}?
You can look at "validations/" directory for the test case example.
To run the test case, use "make check".

Thanks

Chris

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [PATCH v2] sparse: add built-in byte swap identifiers
  2013-02-19  5:59 ` Christopher Li
@ 2013-02-19 17:41   ` Kim Phillips
  2013-02-19 19:13     ` Christopher Li
  0 siblings, 1 reply; 4+ messages in thread
From: Kim Phillips @ 2013-02-19 17:41 UTC (permalink / raw)
  To: Christopher Li; +Cc: linux-sparse

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



^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH v2] sparse: add built-in byte swap identifiers
  2013-02-19 17:41   ` [PATCH v2] " Kim Phillips
@ 2013-02-19 19:13     ` Christopher Li
  0 siblings, 0 replies; 4+ messages in thread
From: Christopher Li @ 2013-02-19 19:13 UTC (permalink / raw)
  To: Kim Phillips; +Cc: linux-sparse

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

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2013-02-19 19:13 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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   ` [PATCH v2] " Kim Phillips
2013-02-19 19:13     ` Christopher Li

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).