summaryrefslogtreecommitdiff
path: root/pack.c
diff options
context:
space:
mode:
authorakr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2011-01-08 11:52:11 +0000
committerakr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2011-01-08 11:52:11 +0000
commit13c4c551d19c63770e94255a1a3a6709ffc487a6 (patch)
tree223eac2cd5c711bcad76e288c9bf9d5735c6a20c /pack.c
parentb85ed255fafe48e3d435eee31d6403af5558afb9 (diff)
* pack.c (swapd): remove duplicated code.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@30492 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'pack.c')
-rw-r--r--pack.c26
1 files changed, 5 insertions, 21 deletions
diff --git a/pack.c b/pack.c
index 9df3706f44..74c12849c2 100644
--- a/pack.c
+++ b/pack.c
@@ -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;
}