Search
lxdream.org :: lxdream/acinclude.m4
lxdream 0.9.1
released Jun 29
Download Now
filename acinclude.m4
changeset 1147:e04e4af64626
prev985:52e64faac752
next1198:407659e01ef0
author nkeynes
date Mon Nov 08 22:10:47 2010 +1000 (9 years ago)
permissions -rw-r--r--
last change Suggest to the compiler a little more firmly that it inline the x86op
functions (as these are nearly always called with constants, they can
usually be reduced down pretty dramatically)
file annotate diff log raw
nkeynes@923
     1
# AC_CHECK_FASTCALL([if-ok],[if-notok])
nkeynes@923
     2
# Test if the compiler recognizes __attribute__((regparm(3))) - we don't 
nkeynes@923
     3
# currently check if it actually works correctly, but probably should...
nkeynes@923
     4
# -----------------------
nkeynes@923
     5
AC_DEFUN([AC_CHECK_FASTCALL], [
nkeynes@923
     6
AC_MSG_CHECKING([support for fastcall calling conventions]);
nkeynes@923
     7
AC_RUN_IFELSE([
nkeynes@923
     8
  AC_LANG_SOURCE([[
nkeynes@923
     9
int __attribute__((regparm(3))) foo(int a, int b) { return a+b; }
nkeynes@923
    10
nkeynes@923
    11
int main(int argc, char *argv[])
nkeynes@923
    12
{
nkeynes@923
    13
   return foo( 1, 2 ) == 3 ? 0 : 1;
nkeynes@923
    14
}]])], [ 
nkeynes@923
    15
   AC_MSG_RESULT([yes])
nkeynes@923
    16
   $1 ], [ 
nkeynes@923
    17
   AC_MSG_RESULT([no])
nkeynes@923
    18
   $2 ])
nkeynes@923
    19
])
nkeynes@923
    20
nkeynes@1147
    21
# AC_CHECK_FORCEINLINE([if-ok],[if-notok])
nkeynes@1147
    22
# Test if the compiler recognizes __attribute__((always_inline))
nkeynes@1147
    23
# -----------------------
nkeynes@1147
    24
AC_DEFUN([AC_CHECK_FORCEINLINE], [
nkeynes@1147
    25
AC_MSG_CHECKING([support for force inlining]);
nkeynes@1147
    26
AC_COMPILE_IFELSE([
nkeynes@1147
    27
  AC_LANG_SOURCE([[
nkeynes@1147
    28
static int __attribute__((always_inline)) foo(int a, int b) { return a+b; }
nkeynes@1147
    29
nkeynes@1147
    30
int main(int argc, char *argv[])
nkeynes@1147
    31
{
nkeynes@1147
    32
   return foo( 1, 2 ) == 3 ? 0 : 1;
nkeynes@1147
    33
}]])], [ 
nkeynes@1147
    34
   FORCEINLINE="__attribute__((always_inline))"
nkeynes@1147
    35
   AC_MSG_RESULT([$FORCEINLINE])
nkeynes@1147
    36
   $1 ], [ 
nkeynes@1147
    37
   FORCEINLINE=""
nkeynes@1147
    38
   AC_MSG_RESULT([no])
nkeynes@1147
    39
   $2 ])
nkeynes@1147
    40
])
nkeynes@1147
    41
nkeynes@927
    42
# AC_CHECK_FRAME_ADDRESS([if-ok],[if-notok])
nkeynes@927
    43
# Test if the compiler will let us modify the return address on the stack
nkeynes@927
    44
# via __builtin_frame_address()
nkeynes@927
    45
# -----------------------
nkeynes@927
    46
AC_DEFUN([AC_CHECK_FRAME_ADDRESS], [
nkeynes@927
    47
AC_MSG_CHECKING([if we have a working __builtin_frame_address()]);
nkeynes@927
    48
AC_RUN_IFELSE([
nkeynes@927
    49
  AC_LANG_SOURCE([[
nkeynes@927
    50
void * __attribute__((noinline)) first_arg( void *x, void *y ) { return x; }
nkeynes@927
    51
int __attribute__((noinline)) foo( int arg, void *exc )
nkeynes@927
    52
{
nkeynes@927
    53
    if( arg < 2 ) {
nkeynes@927
    54
        *(((void **)__builtin_frame_address(0))+1) = exc;
nkeynes@927
    55
    }
nkeynes@927
    56
    return 0;
nkeynes@927
    57
}
nkeynes@927
    58
nkeynes@927
    59
int main(int argc, char *argv[])
nkeynes@927
    60
{
nkeynes@927
    61
   goto *first_arg(&&start, &&except);
nkeynes@927
    62
   
nkeynes@927
    63
start:
nkeynes@927
    64
   return foo( argc, &&except ) + 1;
nkeynes@927
    65
nkeynes@927
    66
except:
nkeynes@927
    67
   return 0;
nkeynes@927
    68
}]])], [ 
nkeynes@927
    69
   AC_MSG_RESULT([yes])
nkeynes@927
    70
   $1 ], [ 
nkeynes@927
    71
   AC_MSG_RESULT([no])
nkeynes@927
    72
   $2 ])
nkeynes@927
    73
])
nkeynes@927
    74
nkeynes@964
    75
# AC_CC_VERSION([if-gcc], [if-icc],[if-other])
nkeynes@964
    76
# Check which C compiler we're using and branch accordingly, eg to set
nkeynes@964
    77
# different optimization flags. Currently recognizes gcc and icc
nkeynes@964
    78
# ---------------
nkeynes@964
    79
AC_DEFUN([AC_CC_VERSION], [
nkeynes@985
    80
_GCC_VERSION=`$CC --version | $SED -ne '/gcc/p'`
nkeynes@964
    81
_ICC_VERSION=`$CC --version | $SED -ne '/(ICC)/p'`
nkeynes@964
    82
AC_MSG_CHECKING([CC version])
nkeynes@985
    83
if test -n "$_ICC_VERSION"; then
nkeynes@985
    84
   AC_MSG_RESULT([ICC])
nkeynes@985
    85
   [ $2 ]
nkeynes@985
    86
elif test -n "$_GCC_VERSION"; then
nkeynes@964
    87
   AC_MSG_RESULT([GCC])
nkeynes@985
    88
   [ $1 ] 
nkeynes@964
    89
else 
nkeynes@964
    90
   AC_MSG_RESULT([Unknown])
nkeynes@964
    91
   [ $3 ]
nkeynes@964
    92
fi
nkeynes@964
    93
]);
nkeynes@927
    94
nkeynes@964
    95
# AC_OBJC_VERSION([if-gcc],[if-other], [if-none])
nkeynes@964
    96
# Check which objective C compiler we're using and branch accordingly.
nkeynes@964
    97
AC_DEFUN([AC_OBJC_VERSION], [
nkeynes@964
    98
AC_MSG_CHECKING([OBJC version])
nkeynes@964
    99
if test -n "$OBJC"; then
nkeynes@964
   100
  _GOBJC_VERSION=`$OBJC --version | $SED -ne '/(GCC)/p'`
nkeynes@964
   101
  if test -n "$_GOBJC_VERSION"; then
nkeynes@964
   102
    AC_MSG_RESULT([GCC])
nkeynes@964
   103
    [ $1 ]
nkeynes@964
   104
  else 
nkeynes@964
   105
    AC_MSG_RESULT([Unknown])
nkeynes@964
   106
    [ $2 ]
nkeynes@964
   107
  fi
nkeynes@964
   108
else
nkeynes@964
   109
  AC_MSG_RESULT([None])
nkeynes@964
   110
  [ $3 ]
nkeynes@964
   111
fi
nkeynes@964
   112
]);
nkeynes@977
   113
nkeynes@977
   114
# AC_HAVE_OBJC([if-present],[if-not-present])
nkeynes@977
   115
# Check if we have a working Objective-C compiler
nkeynes@977
   116
AC_DEFUN([AC_HAVE_OBJC], [
nkeynes@977
   117
AC_PROG_OBJC
nkeynes@977
   118
AC_MSG_CHECKING([for a working Objective-C compiler])
nkeynes@977
   119
AC_LANG_PUSH([Objective C])dnl
nkeynes@977
   120
_AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[@interface Foo @end]], [])],
nkeynes@977
   121
   [AC_MSG_RESULT([yes])
nkeynes@977
   122
    $1 ],
nkeynes@977
   123
   [AC_MSG_RESULT([No])
nkeynes@977
   124
    $2 ]);
nkeynes@977
   125
AC_LANG_POP([Objective C])
nkeynes@977
   126
]);
.