* configure.ac: New switch for disabling -O2 (--disable-optimizations).
[cacao.git] / m4 / acinclude.m4
1 dnl modified AC_C_INLINE from autoconf/c.m4 by TWISTI
2
3 AN_IDENTIFIER([attribute], [AC_C_ATTRIBUTE])
4 AC_DEFUN([AC_C_ATTRIBUTE],
5 [AC_CACHE_CHECK([for __attribute__], ac_cv_c_attribute,
6 [
7 AC_COMPILE_IFELSE([AC_LANG_SOURCE(
8 [void foo(void) __attribute__ ((__noreturn__));]
9 )],
10 [ac_cv_c_attribute=yes],
11 [ac_cv_c_attribute=no]
12 )
13 ])
14 AH_VERBATIM([attribute],
15 [/* Define to `__attribute__' to nothing if it's not supported.  */
16 #ifndef __cplusplus
17 #undef __attribute__
18 #endif])
19 case $ac_cv_c_attribute in
20   yes) ;;
21   no)
22     cat >>confdefs.h <<_ACEOF
23 #ifndef __cplusplus
24 #define __attribute__(x)    /* nothing */
25 #endif
26 _ACEOF
27     ;;
28 esac
29 ])# AC_C_ATTRIBUTE
30
31
32 #check how to do asm(".skip 16")
33
34 AN_IDENTIFIER([skip16], [AC_ASM_SKIP16])
35 AC_DEFUN([AC_ASM_SKIP16],
36 [AC_MSG_CHECKING([if and how we can waste code space])
37 if test -z "$skipcode"; then
38     skipcode=no
39     CFLAGS_1="$CFLAGS"
40     CFLAGS="$CFLAGS $ENGINE_FLAGS"
41     for i in ".skip 16" ".block 16" ".org .+16" ".=.+16" ".space 16"
42     do
43         AC_TRY_RUN(
44 [int foo(int,int,int);
45 main()
46 {
47   exit(foo(0,0,0)!=16);
48 }
49 int foo(int x, int y, int z)
50 {
51   static void *labels[]={&&label1, &&label2};
52   if (x) {
53     y++; /* workaround for http://gcc.gnu.org/bugzilla/show_bug.cgi?id=12108 */
54   label1:
55     __asm__("$i"); /* or ".space 16" or somesuch */
56   label2: ;
57   }
58   {
59   if (y) goto *labels[z]; /* workaround for gcc PR12108 */
60   return labels[1]-labels[0];
61   }
62 }]
63         ,skipcode=$i; break
64         ,,)
65     done
66     CFLAGS=$CFLAGS_1
67 fi
68 AC_MSG_RESULT($skipcode)
69 if test "$skipcode" = no
70 then 
71     if test -z $no_dynamic_default; then
72         no_dynamic_default=1
73         AC_MSG_WARN(Disabling default dynamic native code generation)
74     fi
75     AC_DEFINE_UNQUOTED(SKIP16,((void)0),statement for skipping 16 bytes)
76 else
77     AC_DEFINE_UNQUOTED(SKIP16,__asm__("$skipcode"),statement for skipping 16 bytes)
78 fi
79 ])