mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
* pack.c (swapd): remove duplicated code.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@30492 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
b85ed255fa
commit
13c4c551d1
2 changed files with 9 additions and 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.
|
||||
|
|
26
pack.c
26
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;
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue