2009-06-04 Vladimir Serbinenko <phcoder@gmail.com>
Avoid aliases when compiling with Apple's CC for PCBIOS machine * kern/misc.c [APPLE_CC] (memcpy): new function [APPLE_CC] (memmove): likewise [APPLE_CC && !GRUB_UTIL] (grub_err_printf): likewise (memcpy): define alias conditionaly on !APPLE_CC (memset): likewise (abort): likewise * include/grub/misc.h (memove): don't define when both GRUB_UTIL and APPLE_CC are defined * include/grub/list.h [APPLE_CC] (grub_assert_fail): new function (grub_assert_fail): make prototype conditional
This commit is contained in:
parent
e37ffc5cf6
commit
6c68847712
4 changed files with 63 additions and 1 deletions
15
ChangeLog
15
ChangeLog
|
@ -1,3 +1,18 @@
|
|||
2009-06-04 Vladimir Serbinenko <phcoder@gmail.com>
|
||||
|
||||
Avoid aliases when compiling with Apple's CC for PCBIOS machine
|
||||
|
||||
* kern/misc.c [APPLE_CC] (memcpy): new function
|
||||
[APPLE_CC] (memmove): likewise
|
||||
[APPLE_CC && !GRUB_UTIL] (grub_err_printf): likewise
|
||||
(memcpy): define alias conditionaly on !APPLE_CC
|
||||
(memset): likewise
|
||||
(abort): likewise
|
||||
* include/grub/misc.h (memove): don't define when both GRUB_UTIL and
|
||||
APPLE_CC are defined
|
||||
* include/grub/list.h [APPLE_CC] (grub_assert_fail): new function
|
||||
(grub_assert_fail): make prototype conditional
|
||||
|
||||
2009-06-04 Vladimir Serbinenko <phcoder@gmail.com>
|
||||
|
||||
Use grub-macho2img when compiling with Apple's CC for PCBIOS machine
|
||||
|
|
|
@ -41,7 +41,18 @@ void EXPORT_FUNC(grub_list_insert) (grub_list_t *head, grub_list_t item,
|
|||
|
||||
/* 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 *
|
||||
grub_assert_fail (void)
|
||||
{
|
||||
grub_abort ();
|
||||
return 0;
|
||||
}
|
||||
#else
|
||||
extern void* grub_assert_fail (void);
|
||||
#endif
|
||||
|
||||
#define GRUB_FIELD_MATCH(ptr, type, field) \
|
||||
((char *) &(ptr)->field == (char *) &((type) (ptr))->field)
|
||||
|
|
|
@ -40,8 +40,10 @@ char *EXPORT_FUNC(grub_strcat) (char *dest, const char *src);
|
|||
char *EXPORT_FUNC(grub_strncat) (char *dest, const char *src, int c);
|
||||
|
||||
/* Prototypes for aliases. */
|
||||
#if !defined (GRUB_UTIL) || !defined (APPLE_CC)
|
||||
void *EXPORT_FUNC(memmove) (void *dest, const void *src, grub_size_t n);
|
||||
void *EXPORT_FUNC(memcpy) (void *dest, const void *src, grub_size_t n);
|
||||
#endif
|
||||
|
||||
int EXPORT_FUNC(grub_memcmp) (const void *s1, const void *s2, grub_size_t n);
|
||||
int EXPORT_FUNC(grub_strcmp) (const char *s1, const char *s2);
|
||||
|
|
36
kern/misc.c
36
kern/misc.c
|
@ -44,11 +44,23 @@ grub_memmove (void *dest, const void *src, grub_size_t n)
|
|||
|
||||
return dest;
|
||||
}
|
||||
|
||||
#ifndef APPLE_CC
|
||||
void *memmove (void *dest, const void *src, grub_size_t n)
|
||||
__attribute__ ((alias ("grub_memmove")));
|
||||
/* GCC emits references to memcpy() for struct copies etc. */
|
||||
void *memcpy (void *dest, const void *src, grub_size_t n)
|
||||
__attribute__ ((alias ("grub_memmove")));
|
||||
#else
|
||||
void *memcpy (void *dest, const void *src, grub_size_t n)
|
||||
{
|
||||
return grub_memmove (dest, src, n);
|
||||
}
|
||||
void *memmove (void *dest, const void *src, grub_size_t n)
|
||||
{
|
||||
return grub_memmove (dest, src, n);
|
||||
}
|
||||
#endif
|
||||
|
||||
char *
|
||||
grub_strcpy (char *dest, const char *src)
|
||||
|
@ -134,7 +146,22 @@ grub_printf (const char *fmt, ...)
|
|||
return ret;
|
||||
}
|
||||
|
||||
#ifndef GRUB_UTIL
|
||||
#if defined (APPLE_CC) && ! defined (GRUB_UTIL)
|
||||
int
|
||||
grub_err_printf (const char *fmt, ...)
|
||||
{
|
||||
va_list ap;
|
||||
int ret;
|
||||
|
||||
va_start (ap, fmt);
|
||||
ret = grub_vprintf (fmt, ap);
|
||||
va_end (ap);
|
||||
|
||||
return ret;
|
||||
}
|
||||
#endif
|
||||
|
||||
#if ! defined (APPLE_CC) && ! defined (GRUB_UTIL)
|
||||
int grub_err_printf (const char *fmt, ...)
|
||||
__attribute__ ((alias("grub_printf")));
|
||||
#endif
|
||||
|
@ -185,8 +212,10 @@ grub_memcmp (const void *s1, const void *s2, grub_size_t n)
|
|||
|
||||
return 0;
|
||||
}
|
||||
#ifndef APPLE_CC
|
||||
int memcmp (const void *s1, const void *s2, grub_size_t n)
|
||||
__attribute__ ((alias ("grub_memcmp")));
|
||||
#endif
|
||||
|
||||
int
|
||||
grub_strcmp (const char *s1, const char *s2)
|
||||
|
@ -534,8 +563,10 @@ grub_memset (void *s, int c, grub_size_t n)
|
|||
|
||||
return s;
|
||||
}
|
||||
#ifndef APPLE_CC
|
||||
void *memset (void *s, int c, grub_size_t n)
|
||||
__attribute__ ((alias ("grub_memset")));
|
||||
#endif
|
||||
|
||||
grub_size_t
|
||||
grub_strlen (const char *s)
|
||||
|
@ -1066,8 +1097,11 @@ grub_abort (void)
|
|||
|
||||
grub_exit ();
|
||||
}
|
||||
|
||||
#ifndef APPLE_CC
|
||||
/* GCC emits references to abort(). */
|
||||
void abort (void) __attribute__ ((alias ("grub_abort")));
|
||||
#endif
|
||||
|
||||
#ifdef NEED_ENABLE_EXECUTE_STACK
|
||||
/* Some gcc versions generate a call to this function
|
||||
|
|
Loading…
Reference in a new issue