Do not mess with libc's prototypes
PATCH 1/1 Do not mess with libc's prototypes
According to POSIX memmove and memcpy can actually be macros or whatever (IIRC). We'd better not play with those in code that uses libc's headers and is to be linked with libc.
2008-08-07 Lubomir Rintel <[email protected]>
* include/grub/misc.h: Surround memmove and memcpy prototypes with
#ifndef GRUB_UTIL
grub/misc.h (working copy) renamed from grub/misc.h (revision 1791) +2 -0
@@ -39,8 +39,10 @@ char *EXPORT_FUNC(grub_strncat) (char *dest, const char *src, int c); /* Prototypes for aliases. */ +#ifndef GRUB_UTIL 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);
Due to some more breakage, here's some more patch:
According to POSIX memmove and memcpy can actually be macros or whatever (IIRC). We'd better not play with those in code that uses libc's headers and is to be linked with libc.
2008-08-08 Lubomir Rintel <[email protected]>
* include/grub/misc.h: Surround memmove and memcpy prototypes with #ifndef GRUB_UTIL
* kern/misc.c: Surround memmove, memcpy and memset prototypes with #ifndef GRUB_UTIL
misc.c (working copy) renamed from misc.c (revision 1797) +6 -0
@@ -44,11 +44,15 @@ return dest; } +#ifdef GRUB_UTIL +#include <string.h> +#else 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"))); +#endif char * grub_strcpy (char *dest, const char *src)
@@ -514,8 +518,10 @@ return s; } +#ifndef GRUB_UTIL void *memset (void *s, int c, grub_size_t n) __attribute__ ((alias ("grub_memset"))); +#endif grub_size_t grub_strlen (const char *s)
grub/misc.h (working copy) renamed from grub/misc.h (revision 1797) +4 -0
@@ -39,8 +39,12 @@ char *EXPORT_FUNC(grub_strncat) (char *dest, const char *src, int c); /* Prototypes for aliases. */ +#ifdef GRUB_UTIL +#include <string.h> +#else 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);
Quoted 6 lines · [email protected] writes:
Due to some more breakage, here's some more patch:
According to POSIX memmove and memcpy can actually be macros or whatever (IIRC). We'd better not play with those in code that uses libc's headers and is to be linked with libc.
Quoted 6 lines
2008-08-08 Lubomir Rintel <[email protected]>
*
include/grub/misc.h: Surround memmove and memcpy prototypes with #ifndefGRUB_UTIL
*kern/misc.c: Surround memmove, memcpy and memset prototypes with #ifndefGRUB_UTIL
This is not for GRUB_UTIL, so please don't do this. Perhaps your problem can be fixed in another way. IIRC, this was added because on the PPC, memcpy was required by libgcc, which is used there...
--
Marco