2009-12-31 BVK Chaitanya <bvk.groups@gmail.com>
* include/grub/list.h (grub_assert_fail): Removed. (grub_bad_type_cast_real): New function. (grub_bad_type_cast): New macro. (GRUB_AS_LIST): Use grub_bad_type_cast. (GRUB_AS_LIST_P): Likewise. (GRUB_AS_NAMED_LIST): Likewise. (GRUB_AS_NAMED_LIST_P): Likewise. (GRUB_AS_PRIO_LIST): Likewise. (GRUB_AS_PRIO_LIST_P): Likewise. * include/grub/handler.h (GRUB_AS_HANDLER): Likewise.
This commit is contained in:
parent
f5a513064c
commit
33433555f3
3 changed files with 31 additions and 18 deletions
13
ChangeLog
13
ChangeLog
|
@ -1,3 +1,16 @@
|
||||||
|
2009-12-31 BVK Chaitanya <bvk.groups@gmail.com>
|
||||||
|
|
||||||
|
* include/grub/list.h (grub_assert_fail): Removed.
|
||||||
|
(grub_bad_type_cast_real): New function.
|
||||||
|
(grub_bad_type_cast): New macro.
|
||||||
|
(GRUB_AS_LIST): Use grub_bad_type_cast.
|
||||||
|
(GRUB_AS_LIST_P): Likewise.
|
||||||
|
(GRUB_AS_NAMED_LIST): Likewise,
|
||||||
|
(GRUB_AS_NAMED_LIST_P): Likewise.
|
||||||
|
(GRUB_AS_PRIO_LIST): Likewise,
|
||||||
|
(GRUB_AS_PRIO_LIST_P): Likewise.
|
||||||
|
* include/grub/handler.h (GRUB_AS_HANDLER): Likewise,
|
||||||
|
|
||||||
2009-12-29 Vladimir Serbinenko <phcoder@gmail.com>
|
2009-12-29 Vladimir Serbinenko <phcoder@gmail.com>
|
||||||
|
|
||||||
* loader/sparc64/ieee1275/linux.c (GRUB_MOD_INIT (linux)):
|
* loader/sparc64/ieee1275/linux.c (GRUB_MOD_INIT (linux)):
|
||||||
|
|
|
@ -55,6 +55,6 @@ grub_err_t EXPORT_FUNC(grub_handler_set_current) (grub_handler_class_t class,
|
||||||
GRUB_FIELD_MATCH (ptr, grub_handler_t, name) && \
|
GRUB_FIELD_MATCH (ptr, grub_handler_t, name) && \
|
||||||
GRUB_FIELD_MATCH (ptr, grub_handler_t, init) && \
|
GRUB_FIELD_MATCH (ptr, grub_handler_t, init) && \
|
||||||
GRUB_FIELD_MATCH (ptr, grub_handler_t, fini)) ? \
|
GRUB_FIELD_MATCH (ptr, grub_handler_t, fini)) ? \
|
||||||
(grub_handler_t) ptr : grub_assert_fail ())
|
(grub_handler_t) ptr : grub_bad_type_cast ())
|
||||||
|
|
||||||
#endif /* ! GRUB_HANDLER_HEADER */
|
#endif /* ! GRUB_HANDLER_HEADER */
|
||||||
|
|
|
@ -22,6 +22,7 @@
|
||||||
|
|
||||||
#include <grub/symbol.h>
|
#include <grub/symbol.h>
|
||||||
#include <grub/types.h>
|
#include <grub/types.h>
|
||||||
|
#include <grub/misc.h>
|
||||||
|
|
||||||
struct grub_list
|
struct grub_list
|
||||||
{
|
{
|
||||||
|
@ -39,31 +40,30 @@ int EXPORT_FUNC(grub_list_iterate) (grub_list_t head, grub_list_hook_t hook);
|
||||||
void EXPORT_FUNC(grub_list_insert) (grub_list_t *head, grub_list_t item,
|
void EXPORT_FUNC(grub_list_insert) (grub_list_t *head, grub_list_t item,
|
||||||
grub_list_test_t test);
|
grub_list_test_t test);
|
||||||
|
|
||||||
/* This function doesn't exist, so if assertion is false for some reason, the
|
|
||||||
linker would fail. */
|
|
||||||
#ifdef APPLE_CC
|
|
||||||
/* This approach fails with Apple's gcc. Use grub_abort. */
|
|
||||||
#include <grub/misc.h>
|
|
||||||
static inline void *
|
static inline void *
|
||||||
grub_assert_fail (void)
|
grub_bad_type_cast_real (int line, const char *file)
|
||||||
|
__attribute__ ((error ("bad type cast between incompatible grub types")));
|
||||||
|
|
||||||
|
static inline void *
|
||||||
|
grub_bad_type_cast_real (int line, const char *file)
|
||||||
{
|
{
|
||||||
grub_abort ();
|
grub_fatal ("error:%s:%u: bad type cast between incompatible grub types",
|
||||||
|
file, line);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
#else
|
|
||||||
extern void* grub_assert_fail (void);
|
#define grub_bad_type_cast() grub_bad_type_cast_real(__LINE__, __FILE__)
|
||||||
#endif
|
|
||||||
|
|
||||||
#define GRUB_FIELD_MATCH(ptr, type, field) \
|
#define GRUB_FIELD_MATCH(ptr, type, field) \
|
||||||
((char *) &(ptr)->field == (char *) &((type) (ptr))->field)
|
((char *) &(ptr)->field == (char *) &((type) (ptr))->field)
|
||||||
|
|
||||||
#define GRUB_AS_LIST(ptr) \
|
#define GRUB_AS_LIST(ptr) \
|
||||||
(GRUB_FIELD_MATCH (ptr, grub_list_t, next) ? \
|
(GRUB_FIELD_MATCH (ptr, grub_list_t, next) ? \
|
||||||
(grub_list_t) ptr : grub_assert_fail ())
|
(grub_list_t) ptr : grub_bad_type_cast ())
|
||||||
|
|
||||||
#define GRUB_AS_LIST_P(pptr) \
|
#define GRUB_AS_LIST_P(pptr) \
|
||||||
(GRUB_FIELD_MATCH (*pptr, grub_list_t, next) ? \
|
(GRUB_FIELD_MATCH (*pptr, grub_list_t, next) ? \
|
||||||
(grub_list_t *) (void *) pptr : grub_assert_fail ())
|
(grub_list_t *) (void *) pptr : grub_bad_type_cast ())
|
||||||
|
|
||||||
struct grub_named_list
|
struct grub_named_list
|
||||||
{
|
{
|
||||||
|
@ -78,12 +78,12 @@ void * EXPORT_FUNC(grub_named_list_find) (grub_named_list_t head,
|
||||||
#define GRUB_AS_NAMED_LIST(ptr) \
|
#define GRUB_AS_NAMED_LIST(ptr) \
|
||||||
((GRUB_FIELD_MATCH (ptr, grub_named_list_t, next) && \
|
((GRUB_FIELD_MATCH (ptr, grub_named_list_t, next) && \
|
||||||
GRUB_FIELD_MATCH (ptr, grub_named_list_t, name))? \
|
GRUB_FIELD_MATCH (ptr, grub_named_list_t, name))? \
|
||||||
(grub_named_list_t) ptr : grub_assert_fail ())
|
(grub_named_list_t) ptr : grub_bad_type_cast ())
|
||||||
|
|
||||||
#define GRUB_AS_NAMED_LIST_P(pptr) \
|
#define GRUB_AS_NAMED_LIST_P(pptr) \
|
||||||
((GRUB_FIELD_MATCH (*pptr, grub_named_list_t, next) && \
|
((GRUB_FIELD_MATCH (*pptr, grub_named_list_t, next) && \
|
||||||
GRUB_FIELD_MATCH (*pptr, grub_named_list_t, name))? \
|
GRUB_FIELD_MATCH (*pptr, grub_named_list_t, name))? \
|
||||||
(grub_named_list_t *) (void *) pptr : grub_assert_fail ())
|
(grub_named_list_t *) (void *) pptr : grub_bad_type_cast ())
|
||||||
|
|
||||||
#define GRUB_PRIO_LIST_PRIO_MASK 0xff
|
#define GRUB_PRIO_LIST_PRIO_MASK 0xff
|
||||||
#define GRUB_PRIO_LIST_FLAG_ACTIVE 0x100
|
#define GRUB_PRIO_LIST_FLAG_ACTIVE 0x100
|
||||||
|
@ -111,12 +111,12 @@ grub_prio_list_remove (grub_prio_list_t *head, grub_prio_list_t item)
|
||||||
((GRUB_FIELD_MATCH (ptr, grub_prio_list_t, next) && \
|
((GRUB_FIELD_MATCH (ptr, grub_prio_list_t, next) && \
|
||||||
GRUB_FIELD_MATCH (ptr, grub_prio_list_t, name) && \
|
GRUB_FIELD_MATCH (ptr, grub_prio_list_t, name) && \
|
||||||
GRUB_FIELD_MATCH (ptr, grub_prio_list_t, prio))? \
|
GRUB_FIELD_MATCH (ptr, grub_prio_list_t, prio))? \
|
||||||
(grub_prio_list_t) ptr : grub_assert_fail ())
|
(grub_prio_list_t) ptr : grub_bad_type_cast ())
|
||||||
|
|
||||||
#define GRUB_AS_PRIO_LIST_P(pptr) \
|
#define GRUB_AS_PRIO_LIST_P(pptr) \
|
||||||
((GRUB_FIELD_MATCH (*pptr, grub_prio_list_t, next) && \
|
((GRUB_FIELD_MATCH (*pptr, grub_prio_list_t, next) && \
|
||||||
GRUB_FIELD_MATCH (*pptr, grub_prio_list_t, name) && \
|
GRUB_FIELD_MATCH (*pptr, grub_prio_list_t, name) && \
|
||||||
GRUB_FIELD_MATCH (*pptr, grub_prio_list_t, prio))? \
|
GRUB_FIELD_MATCH (*pptr, grub_prio_list_t, prio))? \
|
||||||
(grub_prio_list_t *) (void *) pptr : grub_assert_fail ())
|
(grub_prio_list_t *) (void *) pptr : grub_bad_type_cast ())
|
||||||
|
|
||||||
#endif /* ! GRUB_LIST_HEADER */
|
#endif /* ! GRUB_LIST_HEADER */
|
||||||
|
|
Loading…
Reference in a new issue