mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
* configure.in: Check __builtin_popcountl, __builtin_bswap32 and
__builtin_bswap64. * internal.h (swap32): Use the configure result for the condition to use __builtin_bswap32. (swap64): Use the configure result for the condition to use __builtin_bswap64. * bignum.c (ones): Use the configure result for the condition to use __builtin_popcountl. (bary_unpack_internal): Use appropriate types for swap argument. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41963 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
b0eacd027a
commit
240f3056aa
4 changed files with 33 additions and 6 deletions
14
ChangeLog
14
ChangeLog
|
@ -1,3 +1,17 @@
|
|||
Sun Jul 14 23:21:47 2013 Tanaka Akira <akr@fsij.org>
|
||||
|
||||
* configure.in: Check __builtin_popcountl, __builtin_bswap32 and
|
||||
__builtin_bswap64.
|
||||
|
||||
* internal.h (swap32): Use the configure result for the condition to
|
||||
use __builtin_bswap32.
|
||||
(swap64): Use the configure result for the condition to use
|
||||
__builtin_bswap64.
|
||||
|
||||
* bignum.c (ones): Use the configure result for the condition to use
|
||||
__builtin_popcountl.
|
||||
(bary_unpack_internal): Use appropriate types for swap argument.
|
||||
|
||||
Sun Jul 14 22:21:11 2013 Tanaka Akira <akr@fsij.org>
|
||||
|
||||
* bignum.c (bary_subb): Support xn < yn.
|
||||
|
|
8
bignum.c
8
bignum.c
|
@ -1137,19 +1137,19 @@ bary_unpack_internal(BDIGIT *bdigits, size_t num_bdigits, const void *words, siz
|
|||
}
|
||||
#if defined(HAVE_UINT16_T) && 2 <= SIZEOF_BDIGITS
|
||||
if (wordsize == 2 && (uintptr_t)words % ALIGNOF(uint16_t) == 0) {
|
||||
BDIGIT u = *(uint16_t *)buf;
|
||||
uint16_t u = *(uint16_t *)buf;
|
||||
return integer_unpack_single_bdigit(need_swap ? swap16(u) : u, sizeof(uint16_t), flags, dp);
|
||||
}
|
||||
#endif
|
||||
#if defined(HAVE_UINT32_T) && 4 <= SIZEOF_BDIGITS
|
||||
if (wordsize == 4 && (uintptr_t)words % ALIGNOF(uint32_t) == 0) {
|
||||
BDIGIT u = *(uint32_t *)buf;
|
||||
uint32_t u = *(uint32_t *)buf;
|
||||
return integer_unpack_single_bdigit(need_swap ? swap32(u) : u, sizeof(uint32_t), flags, dp);
|
||||
}
|
||||
#endif
|
||||
#if defined(HAVE_UINT64_T) && 8 <= SIZEOF_BDIGITS
|
||||
if (wordsize == 8 && (uintptr_t)words % ALIGNOF(uint64_t) == 0) {
|
||||
BDIGIT u = *(uint64_t *)buf;
|
||||
uint64_t u = *(uint64_t *)buf;
|
||||
return integer_unpack_single_bdigit(need_swap ? swap64(u) : u, sizeof(uint64_t), flags, dp);
|
||||
}
|
||||
#endif
|
||||
|
@ -3307,7 +3307,7 @@ big_rshift(VALUE x, unsigned long shift)
|
|||
static inline int
|
||||
ones(register unsigned long x)
|
||||
{
|
||||
#if GCC_VERSION_SINCE(3, 4, 0)
|
||||
#ifdef HAVE_BUILTIN___BUILTIN_POPCOUNTL
|
||||
return __builtin_popcountl(x);
|
||||
#else
|
||||
# if SIZEOF_LONG == 8
|
||||
|
|
13
configure.in
13
configure.in
|
@ -1838,6 +1838,19 @@ AC_CHECK_FUNCS(utimes)
|
|||
AC_CHECK_FUNCS(wait4)
|
||||
AC_CHECK_FUNCS(waitpid)
|
||||
|
||||
AC_DEFUN([RUBY_CHECK_BUILTIN_FUNC], [dnl
|
||||
AC_CACHE_CHECK([for $1], AS_TR_SH(rb_cv_builtin_$1),
|
||||
[AC_LINK_IFELSE(
|
||||
[AC_LANG_PROGRAM([], [$2;])],
|
||||
[AS_TR_SH(rb_cv_builtin_$1)=yes],
|
||||
[AS_TR_SH(rb_cv_builtin_$1)=no])])
|
||||
if test "${AS_TR_SH(rb_cv_builtin_$1)}" != no; then
|
||||
AC_DEFINE(AS_TR_CPP(HAVE_BUILTIN_$1))
|
||||
fi])
|
||||
RUBY_CHECK_BUILTIN_FUNC(__builtin_popcountl, [__builtin_popcountl(0)])
|
||||
RUBY_CHECK_BUILTIN_FUNC(__builtin_bswap32, [__builtin_bswap32(0)])
|
||||
RUBY_CHECK_BUILTIN_FUNC(__builtin_bswap64, [__builtin_bswap64(0)])
|
||||
|
||||
# Some platform neet -lrt for clock_gettime, but the other don't.
|
||||
if test x"$ac_cv_func_clock_gettime" != xyes; then
|
||||
# glibc 2.17 moves clock_* functions from librt to the main C library.
|
||||
|
|
|
@ -82,7 +82,7 @@ extern "C" {
|
|||
#endif
|
||||
|
||||
#ifndef swap32
|
||||
# if GCC_VERSION_SINCE(4,3,0)
|
||||
# ifdef HAVE_BUILTIN___BUILTIN_BSWAP32
|
||||
# define swap32(x) __builtin_bswap32(x)
|
||||
# endif
|
||||
#endif
|
||||
|
@ -95,7 +95,7 @@ extern "C" {
|
|||
#endif
|
||||
|
||||
#ifndef swap64
|
||||
# if GCC_VERSION_SINCE(4,3,0)
|
||||
# ifdef HAVE_BUILTIN___BUILTIN_BSWAP64
|
||||
# define swap64(x) __builtin_bswap64(x)
|
||||
# endif
|
||||
#endif
|
||||
|
|
Loading…
Reference in a new issue