[前][次][番号順一覧][スレッド一覧]

ruby-changes:29911

From: akr <ko1@a...>
Date: Sun, 14 Jul 2013 23:28:44 +0900 (JST)
Subject: [ruby-changes:29911] akr:r41963 (trunk): * configure.in: Check __builtin_popcountl, __builtin_bswap32 and

akr	2013-07-14 23:28:33 +0900 (Sun, 14 Jul 2013)

  New Revision: 41963

  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=41963

  Log:
    * 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.

  Modified files:
    trunk/ChangeLog
    trunk/bignum.c
    trunk/configure.in
    trunk/internal.h

Index: configure.in
===================================================================
--- configure.in	(revision 41962)
+++ configure.in	(revision 41963)
@@ -1838,6 +1838,19 @@ AC_CHECK_FUNCS(utimes) https://github.com/ruby/ruby/blob/trunk/configure.in#L1838
 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.
Index: ChangeLog
===================================================================
--- ChangeLog	(revision 41962)
+++ ChangeLog	(revision 41963)
@@ -1,3 +1,17 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1
+Sun Jul 14 23:21:47 2013  Tanaka Akira  <akr@f...>
+
+	* 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@f...>
 
 	* bignum.c (bary_subb): Support xn < yn.
Index: internal.h
===================================================================
--- internal.h	(revision 41962)
+++ internal.h	(revision 41963)
@@ -82,7 +82,7 @@ extern "C" { https://github.com/ruby/ruby/blob/trunk/internal.h#L82
 #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" { https://github.com/ruby/ruby/blob/trunk/internal.h#L95
 #endif
 
 #ifndef swap64
-# if GCC_VERSION_SINCE(4,3,0)
+# ifdef HAVE_BUILTIN___BUILTIN_BSWAP64
 #  define swap64(x) __builtin_bswap64(x)
 # endif
 #endif
Index: bignum.c
===================================================================
--- bignum.c	(revision 41962)
+++ bignum.c	(revision 41963)
@@ -1137,19 +1137,19 @@ bary_unpack_internal(BDIGIT *bdigits, si https://github.com/ruby/ruby/blob/trunk/bignum.c#L1137
             }
 #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) https://github.com/ruby/ruby/blob/trunk/bignum.c#L3307
 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

--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]