1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

* pack.c (swap64): fix for VC6.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@26766 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
nobu 2010-02-26 07:49:21 +00:00
parent aec58680ec
commit d191b742bd
2 changed files with 16 additions and 16 deletions

View file

@ -1,3 +1,7 @@
Fri Feb 26 16:49:29 2010 Nobuyoshi Nakada <nobu@ruby-lang.org>
* pack.c (swap64): fix for VC6.
Fri Feb 26 14:17:09 2010 Nobuyoshi Nakada <nobu@ruby-lang.org>
* pack.c (pack_pack, pack_unpack): suppressed warnings.

28
pack.c
View file

@ -84,23 +84,19 @@ TOKEN_PASTE(swap,x)(xtype z) \
#ifndef swap64
# if SIZEOF_LONG == 8
# define swap64(x) ((((x)&0x00000000000000FFL)<<56) \
|(((x)>>56)&0xFF) \
|(((x)&0x000000000000FF00L)<<40) \
|(((x)&0x00FF000000000000L)>>40) \
|(((x)&0x0000000000FF0000L)<<24) \
|(((x)&0x0000FF0000000000L)>>24) \
|(((x)&0x00000000FF000000L)<<8) \
|(((x)&0x000000FF00000000L)>>8))
# define byte_in_64bit(n) ((unsigned long)0xff << n)
# elif defined(HAVE_LONG_LONG) && SIZEOF_LONG_LONG == 8
# define swap64(x) ((((x)&0x00000000000000FFLL)<<56) \
|(((x)>>56)&0xFF) \
|(((x)&0x000000000000FF00LL)<<40) \
|(((x)&0x00FF000000000000LL)>>40) \
|(((x)&0x0000000000FF0000LL)<<24) \
|(((x)&0x0000FF0000000000LL)>>24) \
|(((x)&0x00000000FF000000LL)<<8) \
|(((x)&0x000000FF00000000LL)>>8))
# define byte_in_64bit(n) ((LONG_LONG)0xff << n)
# endif
# ifdef byte_in_64bit
# define swap64(x) ((((x)&byte_in_64bit(0))<<56) \
|(((x)>>56)&0xFF) \
|(((x)&byte_in_64bit(8))<<40) \
|(((x)&byte_in_64bit(48))>>40) \
|(((x)&byte_in_64bit(16))<<24) \
|(((x)&byte_in_64bit(40))>>24) \
|(((x)&byte_in_64bit(24))<<8) \
|(((x)&byte_in_64bit(32))>>8))
# endif
#endif