Re: for big endian machine

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



shige 03/06 2009
----------------

I wrote:
| I compiled ming-0.4.2 on Sun Ultra10 (Solaris 9), but "make check"
| puts errors as followings:
| 
|  Executing './test01 .' in /xxx/xxx/ming-0.4.2/test/Movie/add
|  22c22
|  <      [001]   Integer: 16777216
|  ---
|  >      [001]   Integer: 1
|  test01 failed. problem comparing against ./test01.ref
| 
| Since 16777216 = 0x 01 00 00 00, I think this is a bug about 
| endian. For example, util/read.c seems to be for the little 
| endian machine (But Ultra10 uses big endian).

I solved the problem and others by the following patch:

----- From here -----
diff -uN ming-0.4.2/configure.ORG ming-0.4.2/configure
--- ming-0.4.2/configure.ORG	Thu Sep 18 10:00:06 2008
+++ ming-0.4.2/configure	Fri Mar  6 14:25:07 2009
@@ -21984,7 +21984,8 @@
    { (exit 1); exit 1; }; } ;;
 esac
 
-if test x"$WORDS_BIGENDIAN" != x; then
+#if test x"$WORDS_BIGENDIAN" != x; then
+if test x"$ac_cv_c_bigendian" = x"yes"; then
 	CFLAGS="$CFLAGS -DSWF_BIG_ENDIAN"
 else
 	CFLAGS="$CFLAGS -DSWF_LITTLE_ENDIAN"
diff -uN ming-0.4.2/php_ext/Makefile.in.ORG ming-0.4.2/php_ext/Makefile.in
--- ming-0.4.2/php_ext/Makefile.in.ORG	Thu Sep 18 09:59:59 2008
+++ ming-0.4.2/php_ext/Makefile.in	Fri Mar  6 10:17:34 2009
@@ -358,8 +358,8 @@
 	rm -rf tmp
 
 install: all
-	$(INSTALL) -d "$(DESTDIR)"/`php-config --extension-dir`
-	$(INSTALL) -m 755 tmp/modules/ming.so" "$(DESTDIR)"/`php-config --extension-dir`
+	$(INSTALL) -d `php-config --extension-dir`
+	$(INSTALL) -m 755 tmp/modules/ming.so `php-config --extension-dir`
 # Tell versions [3.59,3.63) of GNU make to not export all variables.
 # Otherwise a system limit (for SysV at least) may be exceeded.
 .NOEXPORT:
diff -uN ming-0.4.2/test/actionscript/ActionScriptTest.c.ORG ming-0.4.2/test/actionscript/ActionScriptTest.c
--- ming-0.4.2/test/actionscript/ActionScriptTest.c.ORG	Tue Jul  1 03:37:39 2008
+++ ming-0.4.2/test/actionscript/ActionScriptTest.c	Wed Mar  4 18:26:35 2009
@@ -41,6 +41,45 @@
 #include <limits.h>
 #include <makeswf.h>
 
+#ifndef HAVE_VASPRINTF
+/* Workaround for the lack of vasprintf()
+ * As found on: http://unixpapa.com/incnote/stdio.html
+ * Seems to be Public Domain
+ */
+int
+vasprintf(char **ret, const char *format, va_list ap)
+{
+	va_list ap2;
+	int len = 100;        /* First guess at the size */
+	if ((*ret = (char *) malloc(len)) == NULL)
+	{
+		return -1;
+	}
+	while (1)
+	{
+		int nchar;
+		va_copy(ap2, ap);
+		nchar= vsnprintf(*ret, len, format, ap2);
+		if (nchar > -1 && nchar < len)
+		{
+			return nchar;
+		}
+		if (nchar > len)
+		{
+			len= nchar+1;
+		} else
+		{
+			len*= 2;
+		}
+		if ((*ret = (char *) realloc(*ret, len)) == NULL)
+		{
+			free(*ret);
+			return -1;
+		}
+	}
+}
+#endif
+
 static SWFMovie
 compile(const char* filename, const char* ppfile, int version)
 {
diff -uN ming-0.4.2/util/parser.c.ORG ming-0.4.2/util/parser.c
--- ming-0.4.2/util/parser.c.ORG	Sat Sep  6 23:53:53 2008
+++ ming-0.4.2/util/parser.c	Thu Mar  5 20:28:04 2009
@@ -242,7 +242,7 @@
   int i;
 
   gerec->GlyphIndex = malloc((glyphbits+31)/32 * sizeof(UI32) );
-  for( i=0; glyphbits; i++ ) {
+  for( i=0; i <= glyphbits; i++ ) {
 	  if( glyphbits > 32 ) {
 	  	gerec->GlyphIndex[i] = readBits(f, 32);
 	  	glyphbits -= 32;
@@ -253,7 +253,7 @@
   }
 
   gerec->GlyphAdvance = malloc((advancebits+31)/32 * sizeof(UI32) );
-  for( i=0; advancebits; i++ ) {
+  for( i=0; i <= advancebits; i++ ) {
 	  if( advancebits > 32 ) {
 	  	gerec->GlyphAdvance[i] = readBits(f, 32);
 	  	advancebits -= 32;
diff -uN ming-0.4.2/util/read.c.ORG ming-0.4.2/util/read.c
--- ming-0.4.2/util/read.c.ORG	Thu Apr 10 07:29:29 2008
+++ ming-0.4.2/util/read.c	Thu Mar  5 19:20:52 2009
@@ -122,6 +122,7 @@
 {
   char data[8];
 
+#ifdef SWF_LITTLE_ENDIAN
   data[4] = readUInt8(f);
   data[5] = readUInt8(f);
   data[6] = readUInt8(f);
@@ -130,6 +131,16 @@
   data[1] = readUInt8(f);
   data[2] = readUInt8(f);
   data[3] = readUInt8(f);
+#else
+  data[3] = readUInt8(f);
+  data[2] = readUInt8(f);
+  data[1] = readUInt8(f);
+  data[0] = readUInt8(f);
+  data[7] = readUInt8(f);
+  data[6] = readUInt8(f);
+  data[5] = readUInt8(f);
+  data[4] = readUInt8(f);
+#endif
 
   return *((double *)data);
 }
@@ -138,10 +149,17 @@
 {
   char data[4];
 
+#ifdef SWF_LITTLE_ENDIAN
   data[0] = readUInt8(f);
   data[1] = readUInt8(f);
   data[2] = readUInt8(f);
   data[3] = readUInt8(f);
+#else
+  data[3] = readUInt8(f);
+  data[2] = readUInt8(f);
+  data[1] = readUInt8(f);
+  data[0] = readUInt8(f);
+#endif
 
   return *((float *)data);
 }
@@ -374,8 +392,6 @@
 {
 	_dumpBytes(f, length, 1 );
 }
-
-  int j=0, i, k, l=0;
 
 void dumpBuffer(unsigned char *buf, int length)
 {
diff -uN ming-0.4.2/test/Video/test01.php.ORG ming-0.4.2/test/Video/test01.php
--- ming-0.4.2/test/Video/test01.php.ORG	Thu May  1 00:47:38 2008
+++ ming-0.4.2/test/Video/test01.php	Fri Mar  6 14:23:34 2009
@@ -2,6 +2,7 @@
 <?php
 $m = new SWFMovie(7);
 
+set_time_limit(90);
 $video = new SWFVideoStream("../Media/video01.flv");
 $video->setDimension(200, 200);
 $m->add($video);
----- To here -----

+========================================================+
 Shigeharu TAKENO     NIigata Institute of Technology
                       kashiwazaki,Niigata 945-1195 JAPAN
 shige@xxxxxxxxxxxxxx   TEL(&FAX): +81-257-22-8161
+========================================================+

------------------------------------------------------------------------------
Open Source Business Conference (OSBC), March 24-25, 2009, San Francisco, CA
-OSBC tackles the biggest issue in open source: Open Sourcing the Enterprise
-Strategies to boost innovation and cut costs with open source participation
-Receive a $600 discount off the registration fee with the source code: SFAD
http://p.sf.net/sfu/XcvMzF8H
_______________________________________________
Ming-users mailing list
Ming-users@xxxxxxxxxxxxxxxxxxxxx
https://lists.sourceforge.net/lists/listinfo/ming-users

[Index of Archives]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux