[2233] 2009-05-22 Pavel Roskin <[email protected]>

Pavel Roskin <[email protected]>
Newsgroups gmane.comp.boot-loaders.grub.cvs
Message-ID <[email protected]>
Revision: 2233
          http://svn.sv.gnu.org/viewvc/?view=rev&root=grub&revision=2233
Author:   proski
Date:     2009-05-22 21:15:31 +0000 (Fri, 22 May 2009)
Log Message:
-----------
2009-05-22  Pavel Roskin  <[email protected]>

	* aclocal.m4 (grub_I386_CHECK_REGPARM_BUG): Remove.
	* configure.ac: Don't call grub_I386_CHECK_REGPARM_BUG.  Define
	NESTED_FUNC_ATTR using AH_BOTTOM.  Use regparm(1) only when
	compiling for the i386 targets, but not for the utilities.

Modified Paths:
--------------
    trunk/grub2/ChangeLog
    trunk/grub2/aclocal.m4
    trunk/grub2/configure.ac

Modified: trunk/grub2/ChangeLog
===================================================================
--- trunk/grub2/ChangeLog	2009-05-22 19:52:43 UTC (rev 2232)
+++ trunk/grub2/ChangeLog	2009-05-22 21:15:31 UTC (rev 2233)
@@ -1,5 +1,10 @@
 2009-05-22  Pavel Roskin  <[email protected]>
 
+	* aclocal.m4 (grub_I386_CHECK_REGPARM_BUG): Remove.
+	* configure.ac: Don't call grub_I386_CHECK_REGPARM_BUG.  Define
+	NESTED_FUNC_ATTR using AH_BOTTOM.  Use regparm(1) only when
+	compiling for the i386 targets, but not for the utilities.
+
 	* include/grub/i386/pc/kernel.h (grub_boot_drive): Change type
 	to grub_uint8_t.
 	(grub_root_drive): Likewise.

Modified: trunk/grub2/aclocal.m4
===================================================================
--- trunk/grub2/aclocal.m4	2009-05-22 19:52:43 UTC (rev 2232)
+++ trunk/grub2/aclocal.m4	2009-05-22 21:15:31 UTC (rev 2233)
@@ -301,60 +301,6 @@
 fi
 ])
 
-dnl Check if the C compiler has a bug while using nested functions when
-dnl mregparm is used on the i386.  Some gcc versions do not pass the third
-dnl parameter correctly to the nested function.
-dnl Written by Marco Gerards.
-AC_DEFUN(grub_I386_CHECK_REGPARM_BUG,
-[AC_REQUIRE([AC_PROG_CC])
-AC_MSG_CHECKING([if GCC has the regparm=3 bug])
-AC_CACHE_VAL(grub_cv_i386_check_nested_functions,
-[AC_RUN_IFELSE([AC_LANG_SOURCE(
-[[
-static int
-test (int *n)
-{
-  return *n == -1;
-}
-
-static int
-testfunc (int __attribute__ ((__regparm__ (3))) (*hook) (int a, int b, int *c))
-{
-  int a = 0;
-  int b = 0;
-  int c = -1;
-  return hook (a, b, &c);
-}
-
-int
-main (void)
-{
-  int __attribute__ ((__regparm__ (3))) nestedfunc (int a, int b, int *c)
-    {
-      return a == b && test (c);
-    }
-  return testfunc (nestedfunc) ? 0 : 1;
-}
-]])],
-	[grub_cv_i386_check_nested_functions=no],
-	[grub_cv_i386_check_nested_functions=yes],
-	[grub_cv_i386_check_nested_functions=yes])])
-
-AC_MSG_RESULT([$grub_cv_i386_check_nested_functions])
-
-if test "x$grub_cv_i386_check_nested_functions" = xyes; then
-  AC_DEFINE([NESTED_FUNC_ATTR], 
-	[__attribute__ ((__regparm__ (1)))],
-	[Catch gcc bug])
-else
-dnl Unfortunately, the above test does not detect a bug in gcc-4.0.
-dnl So use regparm 2 until a better test is found.
-  AC_DEFINE([NESTED_FUNC_ATTR], 
-	[__attribute__ ((__regparm__ (1)))],
-	[Catch gcc bug])
-fi
-])
-
 dnl Check if the C compiler generates calls to `__enable_execute_stack()'.
 AC_DEFUN(grub_CHECK_ENABLE_EXECUTE_STACK,[
 AC_MSG_CHECKING([whether `$CC' generates calls to `__enable_execute_stack()'])

Modified: trunk/grub2/configure.ac
===================================================================
--- trunk/grub2/configure.ac	2009-05-22 19:52:43 UTC (rev 2232)
+++ trunk/grub2/configure.ac	2009-05-22 21:15:31 UTC (rev 2233)
@@ -391,11 +391,16 @@
   grub_I386_ASM_PREFIX_REQUIREMENT
   grub_I386_ASM_ADDR32
   grub_I386_ASM_ABSOLUTE_WITHOUT_ASTERISK
-  grub_I386_CHECK_REGPARM_BUG
 else
   AC_DEFINE([NESTED_FUNC_ATTR], [], [Catch gcc bug])
 fi
 
+AH_BOTTOM([#if defined(__i386__) && !defined(GRUB_UTIL)
+#define NESTED_FUNC_ATTR __attribute__ ((__regparm__ (1)))
+#else
+#define NESTED_FUNC_ATTR
+#endif])
+
 # Restore the flags.
 CC="$tmp_CC"
 CFLAGS="$tmp_CFLAGS"
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.