[前][次][番号順一覧][スレッド一覧]

ruby-changes:18469

From: akr <ko1@a...>
Date: Sat, 8 Jan 2011 20:52:21 +0900 (JST)
Subject: [ruby-changes:18469] Ruby:r30492 (trunk): * pack.c (swapd): remove duplicated code.

akr	2011-01-08 20:52:11 +0900 (Sat, 08 Jan 2011)

  New Revision: 30492

  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=30492

  Log:
    * pack.c (swapd): remove duplicated code.

  Modified files:
    trunk/ChangeLog
    trunk/pack.c

Index: ChangeLog
===================================================================
--- ChangeLog	(revision 30491)
+++ ChangeLog	(revision 30492)
@@ -1,3 +1,7 @@
+Sat Jan  8 20:51:25 2011  Tanaka Akira  <akr@f...>
+
+	* pack.c (swapd): remove duplicated code.
+
 Sat Jan  8 19:28:55 2011  Tanaka Akira  <akr@f...>
 
 	* thread.c: parenthesize macro arguments.
Index: pack.c
===================================================================
--- pack.c	(revision 30491)
+++ pack.c	(revision 30492)
@@ -160,38 +160,22 @@
 #  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);
+	utmp[0] = swap32(utmp[1]);
+	utmp[1] = swap32(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);
-	memcpy(&dtmp,utmp,sizeof(double));
-	return dtmp;
-    }
 #  else	/* SIZEOF_DOUBLE == 8 but undivide by known size of int */
     define_swapx(d, double)
 #  endif

--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]