[2260] 2009-06-04 Vladimir Serbinenko <[email protected]>

Vladimir Serbinenko <[email protected]>
Newsgroups gmane.comp.boot-loaders.grub.cvs
Message-ID <[email protected]>
Revision: 2260
          http://svn.sv.gnu.org/viewvc/?view=rev&root=grub&revision=2260
Author:   phcoder
Date:     2009-06-04 21:17:05 +0000 (Thu, 04 Jun 2009)
Log Message:
-----------
2009-06-04  Vladimir Serbinenko  <[email protected]>

	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

Modified Paths:
--------------
    trunk/grub2/ChangeLog
    trunk/grub2/include/grub/list.h
    trunk/grub2/include/grub/misc.h
    trunk/grub2/kern/misc.c

Modified: trunk/grub2/ChangeLog
===================================================================
--- trunk/grub2/ChangeLog	2009-06-04 21:01:11 UTC (rev 2259)
+++ trunk/grub2/ChangeLog	2009-06-04 21:17:05 UTC (rev 2260)
@@ -1,5 +1,20 @@
 2009-06-04  Vladimir Serbinenko  <[email protected]>
 
+	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  <[email protected]>
+
 	Use grub-macho2img when compiling with Apple's CC for PCBIOS machine
 
 	* conf/common.rmk (bin_UTILITIES): add (on false on condition) 

Modified: trunk/grub2/include/grub/list.h
===================================================================
--- trunk/grub2/include/grub/list.h	2009-06-04 21:01:11 UTC (rev 2259)
+++ trunk/grub2/include/grub/list.h	2009-06-04 21:17:05 UTC (rev 2260)
@@ -41,7 +41,18 @@
 
 /* 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)

Modified: trunk/grub2/include/grub/misc.h
===================================================================
--- trunk/grub2/include/grub/misc.h	2009-06-04 21:01:11 UTC (rev 2259)
+++ trunk/grub2/include/grub/misc.h	2009-06-04 21:17:05 UTC (rev 2260)
@@ -40,8 +40,10 @@
 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);

Modified: trunk/grub2/kern/misc.c
===================================================================
--- trunk/grub2/kern/misc.c	2009-06-04 21:01:11 UTC (rev 2259)
+++ trunk/grub2/kern/misc.c	2009-06-04 21:17:05 UTC (rev 2260)
@@ -44,11 +44,23 @@
   
   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 @@
   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 @@
 
   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 @@
 
   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_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
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.