Bug #17646 ยป ruby-__builtin_mul_overflow_long_long.patch
configure.ac | ||
---|---|---|
RUBY_CHECK_BUILTIN_FUNC(__builtin_types_compatible_p, [__builtin_types_compatible_p(int, int)])
|
||
RUBY_CHECK_BUILTIN_FUNC(__builtin_trap, [__builtin_trap()])
|
||
AS_IF([test "$rb_cv_builtin___builtin_mul_overflow" != no], [
|
||
AC_CACHE_CHECK(for __builtin_mul_overflow with long long arguments, rb_cv_use___builtin_mul_overflow_long_long, [
|
||
AC_LINK_IFELSE([AC_LANG_SOURCE([[
|
||
#pragma clang optimize off
|
||
int
|
||
main(void)
|
||
{
|
||
long long x = 0, y;
|
||
__builtin_mul_overflow(x, x, &y);
|
||
return 0;
|
||
}
|
||
]])],
|
||
rb_cv_use___builtin_mul_overflow_long_long=yes,
|
||
rb_cv_use___builtin_mul_overflow_long_long=no)])
|
||
])
|
||
AS_IF([test "$rb_cv_use___builtin_mul_overflow_long_long" = yes], [
|
||
AC_DEFINE(USE___BUILTIN_MUL_OVERFLOW_LONG_LONG, 1)
|
||
])
|
||
AS_IF([test "$ac_cv_func_qsort_r" != no], [
|
||
AC_CACHE_CHECK(whether qsort_r is GNU version, rb_cv_gnu_qsort_r,
|
||
[AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
|
||
-- a/internal/bits.h
|
||
++ b/internal/bits.h
|
||
... | ... | |
MUL_OVERFLOW_SIGNED_INTEGER_P(a, b, FIXNUM_MIN, FIXNUM_MAX)
|
||
#endif
|
||
#ifdef MUL_OVERFLOW_P
|
||
#if defined(MUL_OVERFLOW_P) && defined(USE___BUILTIN_MUL_OVERFLOW_LONG_LONG)
|
||
# define MUL_OVERFLOW_LONG_LONG_P(a, b) MUL_OVERFLOW_P(a, b)
|
||
#else
|
||
# define MUL_OVERFLOW_LONG_LONG_P(a, b) MUL_OVERFLOW_SIGNED_INTEGER_P(a, b, LLONG_MIN, LLONG_MAX)
|
||
#endif
|
||
#ifdef MUL_OVERFLOW_P
|
||
# define MUL_OVERFLOW_LONG_P(a, b) MUL_OVERFLOW_P(a, b)
|
||
# define MUL_OVERFLOW_INT_P(a, b) MUL_OVERFLOW_P(a, b)
|
||
#else
|
||
# define MUL_OVERFLOW_LONG_LONG_P(a, b) MUL_OVERFLOW_SIGNED_INTEGER_P(a, b, LLONG_MIN, LLONG_MAX)
|
||
# define MUL_OVERFLOW_LONG_P(a, b) MUL_OVERFLOW_SIGNED_INTEGER_P(a, b, LONG_MIN, LONG_MAX)
|
||
# define MUL_OVERFLOW_INT_P(a, b) MUL_OVERFLOW_SIGNED_INTEGER_P(a, b, INT_MIN, INT_MAX)
|
||
#endif
|