* [PATCH] Sparse: fix the setting of __SIZE_TYPE__ in lib.c
@ 2005-12-17 20:40 Mika Kukkonen
2005-12-17 20:56 ` Linus Torvalds
0 siblings, 1 reply; 2+ messages in thread
From: Mika Kukkonen @ 2005-12-17 20:40 UTC (permalink / raw)
To: torvalds; +Cc: linux-sparse
[-- Attachment #1: Type: text/plain, Size: 545 bytes --]
I was doing some janitorial work on kernel lib/string.c (patch to
kernel mailing list coming later), and in particular removed the
"#undef memcmp" line. This caused sparse to barf:
mika@desktop:~/work/repos/git/linux-2.6$ make C=1 lib
CHK include/linux/version.h
CHECK lib/string.c
lib/string.c:519:5: error: symbol '__builtin_memcmp' redeclared with
different type (originally declared at builtin:37) - incompatible
argument 3 (different type sizes)
CC lib/string.o
Does the attached patch make sense?
--MiKu
[-- Attachment #2: fix-size_type-setting.patch --]
[-- Type: application/octet-stream, Size: 984 bytes --]
---
lib.c | 9 ++++++---
1 files changed, 6 insertions(+), 3 deletions(-)
diff --git a/lib.c b/lib.c
index d765d75..d80bc28 100644
--- a/lib.c
+++ b/lib.c
@@ -479,10 +479,13 @@ void create_builtin_stream(void)
// gcc defines __SIZE_TYPE__ to be size_t. For linux/i86 and
// solaris/sparc that is really "unsigned int" and for linux/x86_64
- // it is "long unsigned int". In either case we can probably
- // get away with this. We need the #ifndef as cgcc will define
+ // it is "long unsigned int". We need the #ifndef as cgcc will define
// the right __SIZE_TYPE__.
- add_pre_buffer("#weak_define __SIZE_TYPE__ long unsigned int\n");
+ if (sizeof(size_t) == sizeof(unsigned int))
+ add_pre_buffer("#weak_define __SIZE_TYPE__ unsigned int\n");
+ else
+ add_pre_buffer("#weak_define __SIZE_TYPE__ long unsigned int\n");
+
add_pre_buffer("#weak_define __STDC__ 1\n");
add_pre_buffer("#define __builtin_stdarg_start(a,b) ((a) = (__builtin_va_list)(&(b)))\n");
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] Sparse: fix the setting of __SIZE_TYPE__ in lib.c
2005-12-17 20:40 [PATCH] Sparse: fix the setting of __SIZE_TYPE__ in lib.c Mika Kukkonen
@ 2005-12-17 20:56 ` Linus Torvalds
0 siblings, 0 replies; 2+ messages in thread
From: Linus Torvalds @ 2005-12-17 20:56 UTC (permalink / raw)
To: Mika Kukkonen; +Cc: linux-sparse
On Sat, 17 Dec 2005, Mika Kukkonen wrote:
>
> Does the attached patch make sense?
Please don't use attachments, but most _especially_ not attachements that
aren't even marked "text/plain". It means that you have to save the
attachment to a file, and can't quote it in the reply sanely.
Anyway, I'd much prefer a solution that just involves using a real type,
ie a "__builtin_size_t" type or something, and then we just do
#define __SIZE_T__ __builtin_size_t
We actually already have a builtin [s]size_t pointer: do a
git grep size_t_ctype
to see what I mean (although right now it always ends up pointing to
"unsigned long", regardless of what __SIZE_T__ is, which means that you
can end up with
sizeof(__SIZE_T__) != sizeof(sizeof(int))
which is wrong.
Linus
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2005-12-17 20:56 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2005-12-17 20:40 [PATCH] Sparse: fix the setting of __SIZE_TYPE__ in lib.c Mika Kukkonen
2005-12-17 20:56 ` Linus Torvalds
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox