diff options
-rw-r--r-- | ChangeLog | 6 | ||||
-rw-r--r-- | configure.in | 1 | ||||
-rw-r--r-- | internal.h | 6 |
3 files changed, 13 insertions, 0 deletions
@@ -1,3 +1,9 @@ +Mon Nov 25 00:50:03 2013 Masaki Matsushita <glass.saga@gmail.com> + + * internal.h: use __builtin_bswap16() if possible. + + * configure.in: check existence of __builtin_bswap16(). + Sun Nov 24 22:24:19 2013 Tanaka Akira <akr@fsij.org> * bignum.c (bigxor_int): Apply BIGLO for long in a BDIGIT expression. diff --git a/configure.in b/configure.in index 5d86e14bd0..1e0550d187 100644 --- a/configure.in +++ b/configure.in @@ -1916,6 +1916,7 @@ AC_CACHE_CHECK([for $1], AS_TR_SH(rb_cv_builtin_$1), 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_bswap16, [__builtin_bswap16(0)]) RUBY_CHECK_BUILTIN_FUNC(__builtin_bswap32, [__builtin_bswap32(0)]) RUBY_CHECK_BUILTIN_FUNC(__builtin_bswap64, [__builtin_bswap64(0)]) RUBY_CHECK_BUILTIN_FUNC(__builtin_clz, [__builtin_clz(0)]) diff --git a/internal.h b/internal.h index 464266ffbb..963192d27b 100644 --- a/internal.h +++ b/internal.h @@ -70,6 +70,12 @@ extern "C" { #define MUL_OVERFLOW_INT_P(a, b) MUL_OVERFLOW_SIGNED_INTEGER_P(a, b, INT_MIN, INT_MAX) #ifndef swap16 +# ifdef HAVE_BUILTIN___BUILTIN_BSWAP16 +# define swap16(x) __builtin_bswap16(x) +# endif +#endif + +#ifndef swap16 # define swap16(x) ((uint16_t)((((x)&0xFF)<<8) | (((x)>>8)&0xFF))) #endif |