зеркало из https://github.com/github/ruby.git
Check that __builtin_mul_overflow can handle long long
Fixes [Bug #17646] Patch from xtkoba (Tee KOBAYASHI)
This commit is contained in:
Родитель
945e79c996
Коммит
b635388a90
21
configure.ac
21
configure.ac
|
@ -2224,6 +2224,27 @@ RUBY_CHECK_BUILTIN_FUNC(__builtin_types_compatible_p, [__builtin_types_compatibl
|
|||
RUBY_CHECK_BUILTIN_FUNC(__builtin_trap, [__builtin_trap()])
|
||||
RUBY_CHECK_BUILTIN_FUNC(__builtin_expect, [__builtin_expect(0, 0)])
|
||||
|
||||
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([[
|
||||
|
|
|
@ -118,12 +118,16 @@
|
|||
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
|
||||
|
|
Загрузка…
Ссылка в новой задаче