diff options
author | akr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2011-01-08 11:52:11 +0000 |
---|---|---|
committer | akr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2011-01-08 11:52:11 +0000 |
commit | 13c4c551d19c63770e94255a1a3a6709ffc487a6 (patch) | |
tree | 223eac2cd5c711bcad76e288c9bf9d5735c6a20c | |
parent | b85ed255fafe48e3d435eee31d6403af5558afb9 (diff) | |
download | ruby-13c4c551d19c63770e94255a1a3a6709ffc487a6.tar.gz |
* pack.c (swapd): remove duplicated code.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@30492 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r-- | ChangeLog | 4 | ||||
-rw-r--r-- | pack.c | 26 |
2 files changed, 9 insertions, 21 deletions
@@ -1,3 +1,7 @@ +Sat Jan 8 20:51:25 2011 Tanaka Akira <akr@fsij.org> + + * pack.c (swapd): remove duplicated code. + Sat Jan 8 19:28:55 2011 Tanaka Akira <akr@fsij.org> * thread.c: parenthesize macro arguments. @@ -160,35 +160,19 @@ TOKEN_PASTE(swap,x)(xtype z) \ # define swapd(x) swap64(x) # define DOUBLE_SWAPPER uint64_t # else -# if SIZEOF_LONG == 4 /* SIZEOF_DOUBLE == 8 && 4 == SIZEOF_LONG */ +# if HAVE_INT32_T /* SIZEOF_DOUBLE == 8 && 4 == SIZEOF_INT32 */ static double swapd(const double d) { double dtmp = d; - unsigned long utmp[2]; - unsigned long utmp0; + uint32_t utmp[2]; + uint32_t utmp0; utmp[0] = 0; utmp[1] = 0; memcpy(utmp,&dtmp,sizeof(double)); utmp0 = utmp[0]; - utmp[0] = swapl(utmp[1]); - utmp[1] = swapl(utmp0); - memcpy(&dtmp,utmp,sizeof(double)); - return dtmp; - } -# elif SIZEOF_SHORT == 4 /* SIZEOF_DOUBLE == 8 && 4 == SIZEOF_SHORT */ - static double - swapd(const double d) - { - double dtmp = d; - unsigned short utmp[2]; - unsigned short utmp0; - - utmp[0] = 0; utmp[1] = 0; - memcpy(utmp,&dtmp,sizeof(double)); - utmp0 = utmp[0]; - utmp[0] = swaps(utmp[1]); - utmp[1] = swaps(utmp0); + utmp[0] = swap32(utmp[1]); + utmp[1] = swap32(utmp0); memcpy(&dtmp,utmp,sizeof(double)); return dtmp; } |