From 8506a64149933c80d464c5a9f3aecba86e739fbe Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Mon, 11 Nov 2013 22:53:30 +0100 Subject: [PATCH] * include/grub/misc.h [__APPLE__]: Do not add regparm(0) on x86_64. * grub-core/kern/misc.c (__bzero) [__APPLE__]: New function. --- ChangeLog | 5 +++++ grub-core/kern/misc.c | 15 +++++++++++---- include/grub/misc.h | 22 +++++++++++++--------- 3 files changed, 29 insertions(+), 13 deletions(-) diff --git a/ChangeLog b/ChangeLog index f7a7c442c..f387a60f3 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2013-11-11 Vladimir Serbinenko + + * include/grub/misc.h [__APPLE__]: Do not add regparm(0) on x86_64. + * grub-core/kern/misc.c (__bzero) [__APPLE__]: New function. + 2013-11-11 Vladimir Serbinenko * util/getroot.c (grub_util_biosdisk_get_grub_dev) [__APPLE__]: diff --git a/grub-core/kern/misc.c b/grub-core/kern/misc.c index f883fb911..af259d4f6 100644 --- a/grub-core/kern/misc.c +++ b/grub-core/kern/misc.c @@ -71,12 +71,12 @@ void *memmove (void *dest, const void *src, grub_size_t n) void *memcpy (void *dest, const void *src, grub_size_t n) __attribute__ ((alias ("grub_memmove"))); #else -void * __attribute__ ((regparm(0))) +void * GRUB_BUILTIN_ATTR memcpy (void *dest, const void *src, grub_size_t n) { return grub_memmove (dest, src, n); } -void * __attribute__ ((regparm(0))) +void * GRUB_BUILTIN_ATTR memmove (void *dest, const void *src, grub_size_t n) { return grub_memmove (dest, src, n); @@ -225,7 +225,7 @@ grub_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"))); #else -int __attribute__ ((regparm(0))) +int GRUB_BUILTIN_ATTR memcmp (const void *s1, const void *s2, grub_size_t n) { return grub_memcmp (s1, s2, n); @@ -504,11 +504,18 @@ grub_memset (void *s, int c, grub_size_t len) void *memset (void *s, int c, grub_size_t n) __attribute__ ((alias ("grub_memset"))); #else -void * __attribute__ ((regparm(0))) +void * GRUB_BUILTIN_ATTR memset (void *s, int c, grub_size_t n) { return grub_memset (s, c, n); } + +void GRUB_BUILTIN_ATTR +__bzero (void *s, grub_size_t n) +{ + grub_memset (s, 0, n); +} + #endif grub_size_t diff --git a/include/grub/misc.h b/include/grub/misc.h index 958372469..20331f1c1 100644 --- a/include/grub/misc.h +++ b/include/grub/misc.h @@ -98,19 +98,23 @@ grub_memcpy (void *dest, const void *src, grub_size_t n) return grub_memmove (dest, src, n); } +#if defined (__APPLE__) && defined(__i386__) && !defined (GRUB_UTIL) +#define GRUB_BUILTIN_ATTR __attribute__ ((regparm(0))) +#else +#define GRUB_BUILTIN_ATTR +#endif + /* Prototypes for aliases. */ #ifndef GRUB_UTIL +int GRUB_BUILTIN_ATTR EXPORT_FUNC(memcmp) (const void *s1, const void *s2, grub_size_t n); +void *GRUB_BUILTIN_ATTR EXPORT_FUNC(memmove) (void *dest, const void *src, grub_size_t n); +void *GRUB_BUILTIN_ATTR EXPORT_FUNC(memcpy) (void *dest, const void *src, grub_size_t n); +void *GRUB_BUILTIN_ATTR EXPORT_FUNC(memset) (void *s, int c, grub_size_t n); + #ifdef __APPLE__ -int __attribute__ ((regparm(0))) EXPORT_FUNC(memcmp) (const void *s1, const void *s2, grub_size_t n); -void *__attribute__ ((regparm(0))) EXPORT_FUNC(memmove) (void *dest, const void *src, grub_size_t n); -void *__attribute__ ((regparm(0))) EXPORT_FUNC(memcpy) (void *dest, const void *src, grub_size_t n); -void *__attribute__ ((regparm(0))) EXPORT_FUNC(memset) (void *s, int c, grub_size_t n); -#else -int EXPORT_FUNC(memcmp) (const void *s1, const void *s2, 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(memset) (void *s, int c, grub_size_t n); +void GRUB_BUILTIN_ATTR EXPORT_FUNC (__bzero) (void *s, grub_size_t n); #endif + #endif int EXPORT_FUNC(grub_memcmp) (const void *s1, const void *s2, grub_size_t n);