Message ID | 1250420733.9535.1.camel@penberg-laptop (mailing list archive) |
---|---|
State | Mainlined, archived |
Headers | show |
On Sun, Aug 16, 2009 at 02:05:33PM +0300, Pekka Enberg wrote: > Of course. Here's the final patch. *fingers crossed* Looks good to me. Acked-by: Josh Triplett <josh@joshtriplett.org> > From: Pekka Enberg <penberg@cs.helsinki.fi> > Date: Sat, 15 Aug 2009 23:22:24 +0300 > Subject: [PATCH] Define GCC builtin defines for limits.h > > Sparse produces a bunch of warnings like this when compiling against > glibc: > > /usr/lib/gcc/i486-linux-gnu/4.3.2//include-fixed/limits.h:33:22: warning: undefined preprocessor identifier '__INT_MAX__' > /usr/lib/gcc/i486-linux-gnu/4.3.2//include-fixed/limits.h:64:5: warning: undefined preprocessor identifier '__SHRT_MAX__' > /usr/lib/gcc/i486-linux-gnu/4.3.2//include-fixed/limits.h:64:21: warning: undefined preprocessor identifier '__INT_MAX__' > /usr/include/bits/xopen_lim.h:95:6: warning: undefined preprocessor identifier '__INT_MAX__' > /usr/include/bits/xopen_lim.h:98:7: warning: undefined preprocessor identifier '__INT_MAX__' > > Fix that up by adding some add_pre_buffer() calls to > create_builtin_define(). For future reference, GCC defines the builtins > in the c_cpp_builtins() function in gcc/c-cppbuiltin.c. > > Signed-off-by: Pekka Enberg <penberg@cs.helsinki.fi> > --- > lib.c | 8 ++++++++ > lib.h | 3 +++ > 2 files changed, 11 insertions(+), 0 deletions(-) > > diff --git a/lib.c b/lib.c > index 42affcd..fb7e9bc 100644 > --- a/lib.c > +++ b/lib.c > @@ -788,6 +788,14 @@ void create_builtin_stream(void) > add_pre_buffer("#define __OPTIMIZE__ 1\n"); > if (optimize_size) > add_pre_buffer("#define __OPTIMIZE_SIZE__ 1\n"); > + > + /* GCC defines these for limits.h */ > + add_pre_buffer("#weak_define __SHRT_MAX__ " STRINGIFY(__SHRT_MAX__) "\n"); > + add_pre_buffer("#weak_define __SCHAR_MAX__ " STRINGIFY(__SCHAR_MAX__) "\n"); > + add_pre_buffer("#weak_define __INT_MAX__ " STRINGIFY(__INT_MAX__) "\n"); > + add_pre_buffer("#weak_define __LONG_MAX__ " STRINGIFY(__LONG_MAX__) "\n"); > + add_pre_buffer("#weak_define __LONG_LONG_MAX__ " STRINGIFY(__LONG_LONG_MAX__) "\n"); > + add_pre_buffer("#weak_define __WCHAR_MAX__ " STRINGIFY(__WCHAR_MAX__) "\n"); > } > > static struct symbol_list *sparse_tokenstream(struct token *token) > diff --git a/lib.h b/lib.h > index b22fa93..25abb80 100644 > --- a/lib.h > +++ b/lib.h > @@ -17,6 +17,9 @@ > #include "compat.h" > #include "ptrlist.h" > > +#define DO_STRINGIFY(x) #x > +#define STRINGIFY(x) DO_STRINGIFY(x) > + > extern int verbose, optimize, optimize_size, preprocessing; > extern int die_if_error; > extern int repeat_phase, merge_phi_sources; -- 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
On Sun, Aug 16, 2009 at 5:41 AM, Josh Triplett<josh@joshtriplett.org> wrote: > On Sun, Aug 16, 2009 at 02:05:33PM +0300, Pekka Enberg wrote: >> Of course. Here's the final patch. *fingers crossed* > > Looks good to me. > > Acked-by: Josh Triplett <josh@joshtriplett.org> > Looks good to me too. I will apply. The linux kernel has a STRING macro. I will rename to match that if nobody objects. 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
On Sun, Aug 16, 2009 at 10:50:46AM -0700, Christopher Li wrote: > On Sun, Aug 16, 2009 at 5:41 AM, Josh Triplett<josh@joshtriplett.org> wrote: > > On Sun, Aug 16, 2009 at 02:05:33PM +0300, Pekka Enberg wrote: > >> Of course. Here's the final patch. *fingers crossed* > > > > Looks good to me. > > > > Acked-by: Josh Triplett <josh@joshtriplett.org> > > > > Looks good to me too. I will apply. > > The linux kernel has a STRING macro. I will rename to match > that if nobody objects. Matching Linux seems sensible, but I don't see that macro in any general code, just a bunch of local defines with various names. A few quick greps on current git master turned up at least: Documentation/trace/ftrace.txt:#define _STR(x) #x Documentation/trace/ftrace.txt-#define STR(x) _STR(x) arch/cris/boot/tools/build.c:#define STRINGIFY(x) #x arch/cris/include/arch-v10/arch/irq.h:#define __STR(x) #x arch/cris/include/arch-v10/arch/irq.h-#define STR(x) __STR(x) arch/cris/include/arch-v32/arch/hwregs/supp_reg.h-#ifndef STRINGIFYFY arch/cris/include/arch-v32/arch/hwregs/supp_reg.h:#define STRINGIFYFY(i) #i arch/cris/include/arch-v32/arch/irq.h:#define STR2(x) #x arch/cris/include/arch-v32/arch/irq.h-#define STR(x) STR2(x) arch/m68k/include/asm/entry_mm.h-#define STR(X) STR1(X) arch/m68k/include/asm/entry_mm.h:#define STR1(X) #X arch/m68k/lib/checksum.c-#define STR(X) STR1(X) arch/m68k/lib/checksum.c:#define STR1(X) #X arch/mips/include/asm/mipsregs.h-#ifndef __STR arch/mips/include/asm/mipsregs.h:#define __STR(x) #x arch/mips/include/asm/sim.h:#define __str2(x) #x arch/mips/include/asm/sim.h-#define __str(x) __str2(x) arch/mips/kernel/unaligned.c-#define STR(x) __STR(x) arch/mips/kernel/unaligned.c:#define __STR(x) #x arch/powerpc/boot/reg.h:#define __stringify_1(x) #x arch/powerpc/boot/reg.h-#define __stringify(x) __stringify_1(x) arch/sh/include/cpu-sh5/cpu/registers.h:#define __str(x) #x arch/um/drivers/mconsole_user.c:#define STRINGX(x) #x arch/um/drivers/mconsole_user.c-#define STRING(x) STRINGX(x) arch/um/sys-i386/shared/sysdep/kernel-offsets.h:#define STR(x) #x arch/um/sys-x86_64/shared/sysdep/kernel-offsets.h:#define DEFINE_STR1(x) #x arch/x86/kernel/machine_kexec_32.c:#define __STR(X) #X arch/x86/kernel/machine_kexec_32.c-#define STR(X) __STR(X) And probably more. (Also, the above didn't necessarily capture both macros from each pair.) So, I don't see any particular consistency here that we can follow, other than that the macro should probably have "str" in it somewhere. :) And if we have to choose, I think STRINGIFY seems more descriptive than just STRING. - Josh Triplett -- 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
On Sun, 2009-08-16 at 11:56 -0700, Josh Triplett wrote: > > The linux kernel has a STRING macro. I will rename to match > > that if nobody objects. > > Matching Linux seems sensible, but I don't see that macro in any general > code, just a bunch of local defines with various names. A few quick > greps on current git master turned up at least: > So, I don't see any particular consistency here that we can follow, other than > that the macro should probably have "str" in it somewhere. :) And if we have > to choose, I think STRINGIFY seems more descriptive than just STRING. There's include/linux/stringify.h that all those instances you found could use. johannes
On Sun, Aug 16, 2009 at 09:34:31PM +0200, Johannes Berg wrote: > On Sun, 2009-08-16 at 11:56 -0700, Josh Triplett wrote: > > > > The linux kernel has a STRING macro. I will rename to match > > > that if nobody objects. > > > > Matching Linux seems sensible, but I don't see that macro in any general > > code, just a bunch of local defines with various names. A few quick > > greps on current git master turned up at least: > > > So, I don't see any particular consistency here that we can follow, other than > > that the macro should probably have "str" in it somewhere. :) And if we have > > to choose, I think STRINGIFY seems more descriptive than just STRING. > > There's include/linux/stringify.h that all those instances you found > could use. Interesting. I don't know why my search missed that one. Unfortunate that it settled on __stringify, though. Thanks fo the pointer. - Josh Triplett -- 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 --git a/lib.c b/lib.c index 42affcd..fb7e9bc 100644 --- a/lib.c +++ b/lib.c @@ -788,6 +788,14 @@ void create_builtin_stream(void) add_pre_buffer("#define __OPTIMIZE__ 1\n"); if (optimize_size) add_pre_buffer("#define __OPTIMIZE_SIZE__ 1\n"); + + /* GCC defines these for limits.h */ + add_pre_buffer("#weak_define __SHRT_MAX__ " STRINGIFY(__SHRT_MAX__) "\n"); + add_pre_buffer("#weak_define __SCHAR_MAX__ " STRINGIFY(__SCHAR_MAX__) "\n"); + add_pre_buffer("#weak_define __INT_MAX__ " STRINGIFY(__INT_MAX__) "\n"); + add_pre_buffer("#weak_define __LONG_MAX__ " STRINGIFY(__LONG_MAX__) "\n"); + add_pre_buffer("#weak_define __LONG_LONG_MAX__ " STRINGIFY(__LONG_LONG_MAX__) "\n"); + add_pre_buffer("#weak_define __WCHAR_MAX__ " STRINGIFY(__WCHAR_MAX__) "\n"); } static struct symbol_list *sparse_tokenstream(struct token *token) diff --git a/lib.h b/lib.h index b22fa93..25abb80 100644 --- a/lib.h +++ b/lib.h @@ -17,6 +17,9 @@ #include "compat.h" #include "ptrlist.h" +#define DO_STRINGIFY(x) #x +#define STRINGIFY(x) DO_STRINGIFY(x) + extern int verbose, optimize, optimize_size, preprocessing; extern int die_if_error; extern int repeat_phase, merge_phi_sources;