300 |
AC_MSG_CHECKING([if GCC has the regparm=3 bug]) |
AC_MSG_CHECKING([if GCC has the regparm=3 bug]) |
301 |
AC_CACHE_VAL(grub_cv_i386_check_nested_functions, |
AC_CACHE_VAL(grub_cv_i386_check_nested_functions, |
302 |
[AC_RUN_IFELSE([AC_LANG_SOURCE( |
[AC_RUN_IFELSE([AC_LANG_SOURCE( |
303 |
[[int *p; |
[[ |
304 |
|
static int |
305 |
|
test (int *n) |
306 |
|
{ |
307 |
|
return *n == -1; |
308 |
|
} |
309 |
|
|
310 |
int |
static int |
311 |
main () |
testfunc (int __attribute__ ((__regparm__ (3))) (*hook) (int a, int b, int *c)) |
312 |
{ |
{ |
313 |
int test; |
int a = 0; |
314 |
|
int b = 0; |
315 |
|
int c = -1; |
316 |
|
return hook (a, b, &c); |
317 |
|
} |
318 |
|
|
319 |
int __attribute__ ((__regparm__ (3))) nestedfunc (int a, int b, int c) |
int |
320 |
|
main (void) |
321 |
|
{ |
322 |
|
int __attribute__ ((__regparm__ (3))) nestedfunc (int a, int b, int *c) |
323 |
{ |
{ |
324 |
return (&test == p); |
return a == b && test (c); |
325 |
} |
} |
326 |
|
return testfunc (nestedfunc) ? 0 : 1; |
|
p = &test; |
|
|
return ! nestedfunc (0, 0, 0); |
|
327 |
} |
} |
328 |
]])], |
]])], |
329 |
[grub_cv_i386_check_nested_functions=yes], |
[grub_cv_i386_check_nested_functions=no], |
330 |
[grub_cv_i386_check_nested_functions=no])]) |
[grub_cv_i386_check_nested_functions=yes])]) |
331 |
|
|
332 |
AC_MSG_RESULT([$grub_cv_i386_check_nested_functions]) |
AC_MSG_RESULT([$grub_cv_i386_check_nested_functions]) |
333 |
|
|
336 |
[__attribute__ ((__regparm__ (2)))], |
[__attribute__ ((__regparm__ (2)))], |
337 |
[Catch gcc bug]) |
[Catch gcc bug]) |
338 |
else |
else |
339 |
AC_DEFINE([NESTED_FUNC_ATTR], [], [Catch gcc bug]) |
dnl Unfortunately, the above test does not detect a bug in gcc-4.0. |
340 |
|
dnl So use regparm 2 until a better test is found. |
341 |
|
AC_DEFINE([NESTED_FUNC_ATTR], |
342 |
|
[__attribute__ ((__regparm__ (2)))], |
343 |
|
[Catch gcc bug]) |
344 |
fi |
fi |
345 |
]) |
]) |