* [PATCH] Define __CHAR_BIT__
@ 2013-12-19 5:46 Emilio G. Cota
2013-12-21 17:20 ` Christopher Li
0 siblings, 1 reply; 4+ messages in thread
From: Emilio G. Cota @ 2013-12-19 5:46 UTC (permalink / raw)
To: Christopher Li; +Cc: Emilio G. Cota, Linux-Sparse
From: "Emilio G. Cota" <cota@braap.org>
gcc defines __CHAR_BIT__ as a pre-defined macro.
Define __CHAR_BIT__ in sparse so that code that needs it (e.g. code
using CHAR_BIT from limits.h) does not generate false warnings.
Signed-off-by: Emilio G. Cota <cota@braap.org>
---
lib.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/lib.c b/lib.c
index fe20f93..bbdb9b7 100644
--- a/lib.c
+++ b/lib.c
@@ -911,6 +911,7 @@ void create_builtin_stream(void)
add_pre_buffer("#weak_define __LONG_LONG_MAX__ " STRINGIFY(__LONG_LONG_MAX__) "\n");
add_pre_buffer("#weak_define __WCHAR_MAX__ " STRINGIFY(__WCHAR_MAX__) "\n");
add_pre_buffer("#weak_define __SIZEOF_POINTER__ " STRINGIFY(__SIZEOF_POINTER__) "\n");
+ add_pre_buffer("#weak_define __CHAR_BIT__ " STRINGIFY(__CHAR_BIT__) "\n");
}
static struct symbol_list *sparse_tokenstream(struct token *token)
--
1.8.3
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH] Define __CHAR_BIT__
2013-12-19 5:46 [PATCH] Define __CHAR_BIT__ Emilio G. Cota
@ 2013-12-21 17:20 ` Christopher Li
2014-01-08 21:32 ` [PATCH v2] " Emilio G. Cota
0 siblings, 1 reply; 4+ messages in thread
From: Christopher Li @ 2013-12-21 17:20 UTC (permalink / raw)
To: Emilio G. Cota; +Cc: Linux-Sparse
On Wed, Dec 18, 2013 at 9:46 PM, Emilio G. Cota <cota@braap.org> wrote:
> From: "Emilio G. Cota" <cota@braap.org>
>
> gcc defines __CHAR_BIT__ as a pre-defined macro.
>
> Define __CHAR_BIT__ in sparse so that code that needs it (e.g. code
> using CHAR_BIT from limits.h) does not generate false warnings.
Please provide a test case with this change. The change looks good
otherwise.
Chris
^ permalink raw reply [flat|nested] 4+ messages in thread
* [PATCH v2] Define __CHAR_BIT__
2013-12-21 17:20 ` Christopher Li
@ 2014-01-08 21:32 ` Emilio G. Cota
2014-01-28 21:38 ` Emilio G. Cota
0 siblings, 1 reply; 4+ messages in thread
From: Emilio G. Cota @ 2014-01-08 21:32 UTC (permalink / raw)
To: Christopher Li; +Cc: Emilio G. Cota, Linux-Sparse
From: "Emilio G. Cota" <cota@braap.org>
gcc defines __CHAR_BIT__ as a pre-defined macro.
Define __CHAR_BIT__ in sparse so that code that needs it (e.g. code
using CHAR_BIT from limits.h) does not generate false warnings.
Signed-off-by: Emilio G. Cota <cota@braap.org>
---
lib.c | 1 +
validation/builtin_char_bit.c | 7 +++++++
2 files changed, 8 insertions(+)
create mode 100644 validation/builtin_char_bit.c
diff --git a/lib.c b/lib.c
index fe20f93..bbdb9b7 100644
--- a/lib.c
+++ b/lib.c
@@ -911,6 +911,7 @@ void create_builtin_stream(void)
add_pre_buffer("#weak_define __LONG_LONG_MAX__ " STRINGIFY(__LONG_LONG_MAX__) "\n");
add_pre_buffer("#weak_define __WCHAR_MAX__ " STRINGIFY(__WCHAR_MAX__) "\n");
add_pre_buffer("#weak_define __SIZEOF_POINTER__ " STRINGIFY(__SIZEOF_POINTER__) "\n");
+ add_pre_buffer("#weak_define __CHAR_BIT__ " STRINGIFY(__CHAR_BIT__) "\n");
}
static struct symbol_list *sparse_tokenstream(struct token *token)
diff --git a/validation/builtin_char_bit.c b/validation/builtin_char_bit.c
new file mode 100644
index 0000000..30e6bed
--- /dev/null
+++ b/validation/builtin_char_bit.c
@@ -0,0 +1,7 @@
+#include <limits.h>
+
+static unsigned int word_bits = sizeof(unsigned int) * CHAR_BIT;
+
+/*
+ * check-name: __CHAR_BIT__
+ */
--
1.8.3
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH v2] Define __CHAR_BIT__
2014-01-08 21:32 ` [PATCH v2] " Emilio G. Cota
@ 2014-01-28 21:38 ` Emilio G. Cota
0 siblings, 0 replies; 4+ messages in thread
From: Emilio G. Cota @ 2014-01-28 21:38 UTC (permalink / raw)
To: Christopher Li; +Cc: Linux-Sparse
On Wed, Jan 08, 2014 at 16:32:42 -0500, Emilio G. Cota wrote:
> From: "Emilio G. Cota" <cota@braap.org>
>
> gcc defines __CHAR_BIT__ as a pre-defined macro.
>
> Define __CHAR_BIT__ in sparse so that code that needs it (e.g. code
> using CHAR_BIT from limits.h) does not generate false warnings.
>
> Signed-off-by: Emilio G. Cota <cota@braap.org>
Haven't seen any activity for this v2 since it was sent on
Jan 08--please take a look.
Thanks,
Emilio
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2014-01-28 21:39 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-12-19 5:46 [PATCH] Define __CHAR_BIT__ Emilio G. Cota
2013-12-21 17:20 ` Christopher Li
2014-01-08 21:32 ` [PATCH v2] " Emilio G. Cota
2014-01-28 21:38 ` Emilio G. Cota
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.