Commit 32a03aec authored by Michel Lespinasse's avatar Michel Lespinasse
Browse files

adding static branch prediction for gcc 3.1

parent c502bc3a
......@@ -17,6 +17,30 @@ AC_DEFUN([AC_C_RESTRICT],
*) AC_DEFINE_UNQUOTED([restrict],$ac_cv_c_restrict) ;;
esac])
dnl AC_C_BUILTIN_EXPECT
dnl Check whether compiler understands __builtin_expect.
AC_DEFUN([AC_C_BUILTIN_EXPECT],
[AC_CACHE_CHECK([for __builtin_expect],[ac_cv_builtin_expect],
[cat > conftest.c <<EOF
#line __oline__ "configure"
int foo (int a)
{
a = __builtin_expect (a, 10);
return a == 10 ? 0 : 1;
}
EOF
if AC_TRY_COMMAND([${CC-cc} $CFLAGS -nostdlib -nostartfiles
-o conftest conftest.c -lgcc >&AC_FD_CC]); then
ac_cv_builtin_expect=yes
else
ac_cv_builtin_expect=no
fi
rm -f conftest*])
if test x"$ac_cv_builtin_expect" = x"yes"; then
AC_DEFINE(HAVE_BUILTIN_EXPECT,[1],
[Define to 1 if you have the `__builtin_expect' function.])
fi])
dnl AC_C_ALWAYS_INLINE
dnl Define inline to something appropriate, including the new always_inline
dnl attribute from gcc 3.1
......
......@@ -96,6 +96,7 @@ dnl Checks for typedefs, structures, and compiler characteristics.
AC_C_CONST
AC_C_ALWAYS_INLINE
AC_C_RESTRICT
AC_C_BUILTIN_EXPECT
AC_TYPE_SIZE_T
AC_C_BIGENDIAN
......
......@@ -27,3 +27,11 @@
#else
#define ATTR_ALIGN(align)
#endif
#ifdef HAVE_BUILTIN_EXPECT
#define likely(x) __builtin_expect ((x) != 0, 1)
#define unlikely(x) __builtin_expect ((x) != 0, 0)
#else
#define likely(x) (x)
#define unlikely(x) (x)
#endif
......@@ -38,7 +38,7 @@ static inline void bitstream_init (decoder_t * decoder, const uint8_t * start)
/* make sure that there are at least 16 valid bits in bit_buf */
#define NEEDBITS(bit_buf,bits,bit_ptr) \
do { \
if (bits > 0) { \
if (unlikely (bits > 0)) { \
GETWORD (bit_buf, bits, bit_ptr); \
bits -= 16; \
} \
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment