diff mbox

Define __CHAR_BIT__

Message ID 1387431987-29219-1-git-send-email-cota@braap.org (mailing list archive)
State Superseded, archived
Headers show

Commit Message

Emilio Cota Dec. 19, 2013, 5:46 a.m. UTC
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(+)

Comments

Christopher Li Dec. 21, 2013, 5:20 p.m. UTC | #1
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
--
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 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)