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>
|
2009-06-04 Vladimir Serbinenko <phcoder@gmail.com>
|
||||||
|
|
||||||
Use grub-macho2img when compiling with Apple's CC for PCBIOS machine
|
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
|
/* This function doesn't exist, so if assertion is false for some reason, the
|
||||||
linker would fail. */
|
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);
|
extern void* grub_assert_fail (void);
|
||||||
|
#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)
|
||||||
|
|
|
@ -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);
|
char *EXPORT_FUNC(grub_strncat) (char *dest, const char *src, int c);
|
||||||
|
|
||||||
/* Prototypes for aliases. */
|
/* 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(memmove) (void *dest, const void *src, grub_size_t n);
|
||||||
void *EXPORT_FUNC(memcpy) (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_memcmp) (const void *s1, const void *s2, grub_size_t n);
|
||||||
int EXPORT_FUNC(grub_strcmp) (const char *s1, const char *s2);
|
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;
|
return dest;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifndef APPLE_CC
|
||||||
void *memmove (void *dest, const void *src, grub_size_t n)
|
void *memmove (void *dest, const void *src, grub_size_t n)
|
||||||
__attribute__ ((alias ("grub_memmove")));
|
__attribute__ ((alias ("grub_memmove")));
|
||||||
/* GCC emits references to memcpy() for struct copies etc. */
|
/* GCC emits references to memcpy() for struct copies etc. */
|
||||||
void *memcpy (void *dest, const void *src, grub_size_t n)
|
void *memcpy (void *dest, const void *src, grub_size_t n)
|
||||||
__attribute__ ((alias ("grub_memmove")));
|
__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 *
|
char *
|
||||||
grub_strcpy (char *dest, const char *src)
|
grub_strcpy (char *dest, const char *src)
|
||||||
|
@ -134,7 +146,22 @@ grub_printf (const char *fmt, ...)
|
||||||
return ret;
|
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, ...)
|
int grub_err_printf (const char *fmt, ...)
|
||||||
__attribute__ ((alias("grub_printf")));
|
__attribute__ ((alias("grub_printf")));
|
||||||
#endif
|
#endif
|
||||||
|
@ -185,8 +212,10 @@ grub_memcmp (const void *s1, const void *s2, grub_size_t n)
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
#ifndef APPLE_CC
|
||||||
int memcmp (const void *s1, const void *s2, grub_size_t n)
|
int memcmp (const void *s1, const void *s2, grub_size_t n)
|
||||||
__attribute__ ((alias ("grub_memcmp")));
|
__attribute__ ((alias ("grub_memcmp")));
|
||||||
|
#endif
|
||||||
|
|
||||||
int
|
int
|
||||||
grub_strcmp (const char *s1, const char *s2)
|
grub_strcmp (const char *s1, const char *s2)
|
||||||
|
@ -534,8 +563,10 @@ grub_memset (void *s, int c, grub_size_t n)
|
||||||
|
|
||||||
return s;
|
return s;
|
||||||
}
|
}
|
||||||
|
#ifndef APPLE_CC
|
||||||
void *memset (void *s, int c, grub_size_t n)
|
void *memset (void *s, int c, grub_size_t n)
|
||||||
__attribute__ ((alias ("grub_memset")));
|
__attribute__ ((alias ("grub_memset")));
|
||||||
|
#endif
|
||||||
|
|
||||||
grub_size_t
|
grub_size_t
|
||||||
grub_strlen (const char *s)
|
grub_strlen (const char *s)
|
||||||
|
@ -1066,8 +1097,11 @@ grub_abort (void)
|
||||||
|
|
||||||
grub_exit ();
|
grub_exit ();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifndef APPLE_CC
|
||||||
/* GCC emits references to abort(). */
|
/* GCC emits references to abort(). */
|
||||||
void abort (void) __attribute__ ((alias ("grub_abort")));
|
void abort (void) __attribute__ ((alias ("grub_abort")));
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifdef NEED_ENABLE_EXECUTE_STACK
|
#ifdef NEED_ENABLE_EXECUTE_STACK
|
||||||
/* Some gcc versions generate a call to this function
|
/* Some gcc versions generate a call to this function
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue