From e2d70b5cea62f2b4c57a2fb8e1885d9b7569f741 Mon Sep 17 00:00:00 2001 From: Colin Watson Date: Sun, 3 Jan 2010 21:50:53 +0000 Subject: [PATCH] 2010-01-03 Colin Watson * include/grub/misc.h (GNUC_PREREQ): New macro. (ATTRIBUTE_ERROR): New macro. * include/grub/list.h (grub_bad_type_cast_real): Use ATTRIBUTE_ERROR. --- ChangeLog | 7 +++++++ include/grub/list.h | 2 +- include/grub/misc.h | 18 +++++++++++++++++- 3 files changed, 25 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index 916e2bc1e..e5e4f42ca 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +2010-01-03 Colin Watson + + * include/grub/misc.h (GNUC_PREREQ): New macro. + (ATTRIBUTE_ERROR): New macro. + * include/grub/list.h (grub_bad_type_cast_real): Use + ATTRIBUTE_ERROR. + 2010-01-03 Carles Pina i Estany * normal/menu_text.c (print_message): Change messages. diff --git a/include/grub/list.h b/include/grub/list.h index 86a5381cd..b7703e214 100644 --- a/include/grub/list.h +++ b/include/grub/list.h @@ -42,7 +42,7 @@ void EXPORT_FUNC(grub_list_insert) (grub_list_t *head, grub_list_t item, static inline void * grub_bad_type_cast_real (int line, const char *file) - __attribute__ ((error ("bad type cast between incompatible grub types"))); + ATTRIBUTE_ERROR ("bad type cast between incompatible grub types"); static inline void * grub_bad_type_cast_real (int line, const char *file) diff --git a/include/grub/misc.h b/include/grub/misc.h index 92fb460cf..c5eb953e2 100644 --- a/include/grub/misc.h +++ b/include/grub/misc.h @@ -1,7 +1,7 @@ /* misc.h - prototypes for misc functions */ /* * GRUB -- GRand Unified Bootloader - * Copyright (C) 2002,2003,2005,2006,2007,2008,2009,2008,2009 Free Software Foundation, Inc. + * Copyright (C) 2002,2003,2005,2006,2007,2008,2009,2010 Free Software Foundation, Inc. * * GRUB is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -25,6 +25,22 @@ #include #include +/* GCC version checking borrowed from glibc. */ +#if defined(__GNUC__) && defined(__GNUC_MINOR__) +# define GNUC_PREREQ(maj,min) \ + ((__GNUC__ << 16) + __GNUC_MINOR__ >= ((maj) << 16) + (min)) +#else +# define GNUC_PREREQ(maj,min) 0 +#endif + +/* Does this compiler support compile-time error attributes? */ +#if GNUC_PREREQ(4,3) +# define ATTRIBUTE_ERROR(msg) \ + __attribute__ ((__error__ (msg))) +#else +# define ATTRIBUTE_ERROR(msg) +#endif + #define ALIGN_UP(addr, align) \ ((addr + (typeof (addr)) align - 1) & ~((typeof (addr)) align - 1)) #define ARRAY_SIZE(array) (sizeof (array) / sizeof (array[0]))