pkgsrc-Changes-HG archive

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

[pkgsrc/trunk]: pkgsrc Fix float reading by using a union instead of a cast. ...



details:   https://anonhg.NetBSD.org/pkgsrc/rev/d2a7ca6f1566
branches:  trunk
changeset: 551593:d2a7ca6f1566
user:      reinoud <reinoud%pkgsrc.org@localhost>
date:      Thu Dec 18 13:15:10 2008 +0000

description:
Fix float reading by using a union instead of a cast. Newer gcc's would
generate incorrect code effectively breaking the package.

I know this solution is still lame but its fix comes from the still uncomitted
lib3ds version 2.0.0. Should one day be fixed/done correctly for non i386.

diffstat:

 doc/CHANGES-2008                 |   4 ++-
 graphics/lib3ds/Makefile         |   4 +-
 graphics/lib3ds/distinfo         |   3 +-
 graphics/lib3ds/patches/patch-af |  56 ++++++++++++++++++++++++++++++++++++++++
 4 files changed, 63 insertions(+), 4 deletions(-)

diffs (103 lines):

diff -r 821696821277 -r d2a7ca6f1566 doc/CHANGES-2008
--- a/doc/CHANGES-2008  Thu Dec 18 12:02:34 2008 +0000
+++ b/doc/CHANGES-2008  Thu Dec 18 13:15:10 2008 +0000
@@ -1,4 +1,4 @@
-$NetBSD: CHANGES-2008,v 1.3431 2008/12/18 09:28:01 rillig Exp $
+$NetBSD: CHANGES-2008,v 1.3432 2008/12/18 13:16:44 reinoud Exp $
 
 Changes to the packages collection and infrastructure in 2008:
 
@@ -5688,3 +5688,5 @@
        Updated databases/p5-DBD-postgresql to 2.11.7 [he 2008-12-18]
        Updated databases/p5-DBD-Oracle to 1.22 [he 2008-12-18]
        Updated games/cgoban-java to 3.3.23 [roland 2008-12-18]
+       Updated graphics/lib3ds to 1.2.0nb6 [reinoud 2008-12-18]
+
diff -r 821696821277 -r d2a7ca6f1566 graphics/lib3ds/Makefile
--- a/graphics/lib3ds/Makefile  Thu Dec 18 12:02:34 2008 +0000
+++ b/graphics/lib3ds/Makefile  Thu Dec 18 13:15:10 2008 +0000
@@ -1,8 +1,8 @@
-# $NetBSD: Makefile,v 1.14 2008/07/14 12:56:05 joerg Exp $
+# $NetBSD: Makefile,v 1.15 2008/12/18 13:15:10 reinoud Exp $
 #
 
 DISTNAME=      lib3ds-1.2.0
-PKGREVISION=   5
+PKGREVISION=   6
 CATEGORIES=    graphics devel
 MASTER_SITES=  ${MASTER_SITE_SOURCEFORGE:=lib3ds/}
 
diff -r 821696821277 -r d2a7ca6f1566 graphics/lib3ds/distinfo
--- a/graphics/lib3ds/distinfo  Thu Dec 18 12:02:34 2008 +0000
+++ b/graphics/lib3ds/distinfo  Thu Dec 18 13:15:10 2008 +0000
@@ -1,4 +1,4 @@
-$NetBSD: distinfo,v 1.5 2006/04/11 14:47:06 jmmv Exp $
+$NetBSD: distinfo,v 1.6 2008/12/18 13:15:10 reinoud Exp $
 
 SHA1 (lib3ds-1.2.0.tar.gz) = 49614218c4c11572887beefaa34d23f72ef70a2c
 RMD160 (lib3ds-1.2.0.tar.gz) = 3e0401e36b545c2a54213ecb2ea3216360450562
@@ -8,3 +8,4 @@
 SHA1 (patch-ac) = d73dd1b2cdabe61f78d4a7307a04917ff5fc379b
 SHA1 (patch-ad) = bbf95ca49e1bf6fa67314f9818af5b1b974eb54a
 SHA1 (patch-ae) = 7760d2311d99f3d5d91f89fceced314648abbeb0
+SHA1 (patch-af) = 016c93ead0e5d6a033d891d03db5f227a3e1df71
diff -r 821696821277 -r d2a7ca6f1566 graphics/lib3ds/patches/patch-af
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/graphics/lib3ds/patches/patch-af  Thu Dec 18 13:15:10 2008 +0000
@@ -0,0 +1,56 @@
+$NetBSD: patch-af,v 1.1 2008/12/18 13:15:10 reinoud Exp $
+
+--- lib3ds/io.c.orig   2001-07-11 15:47:35.000000000 +0200
++++ lib3ds/io.c
+@@ -31,6 +31,11 @@
+  * \author J.E. Hoffmann <je-h%gmx.net@localhost>
+  */
+ 
++typedef union {
++    uint32_t dword_value;
++    float float_value;
++} Lib3dsDwordFloat;
++
+ 
+ struct _Lib3dsIo {
+   void *self;
+@@ -248,15 +253,15 @@ Lib3dsFloat
+ lib3ds_io_read_float(Lib3dsIo *io)
+ {
+   Lib3dsByte b[4];
+-  Lib3dsDword d;
++  Lib3dsDwordFloat d;
+ 
+   ASSERT(io);
+   lib3ds_io_read(io, b, 4);
+-  d=((Lib3dsDword)b[3] << 24) |
++  d.dword_value =((Lib3dsDword)b[3] << 24) |
+     ((Lib3dsDword)b[2] << 16) |
+     ((Lib3dsDword)b[1] << 8) |
+     ((Lib3dsDword)b[0]);
+-  return(*((Lib3dsFloat*)&d));
++  return d.float_value;
+ }
+ 
+ 
+@@ -459,14 +464,14 @@ Lib3dsBool
+ lib3ds_io_write_float(Lib3dsIo *io, Lib3dsFloat l)
+ {
+   Lib3dsByte b[4];
+-  Lib3dsDword d;
++  Lib3dsDwordFloat d;
+ 
+   ASSERT(io);
+-  d=*((Lib3dsDword*)&l);
+-  b[3]=(Lib3dsByte)(((Lib3dsDword)d & 0xFF000000) >> 24);
+-  b[2]=(Lib3dsByte)(((Lib3dsDword)d & 0x00FF0000) >> 16);
+-  b[1]=(Lib3dsByte)(((Lib3dsDword)d & 0x0000FF00) >> 8);
+-  b[0]=(Lib3dsByte)(((Lib3dsDword)d & 0x000000FF));
++  d.float_value = l;
++  b[3]=(Lib3dsByte)(((Lib3dsDword)d.dword_value & 0xFF000000) >> 24);
++  b[2]=(Lib3dsByte)(((Lib3dsDword)d.dword_value & 0x00FF0000) >> 16);
++  b[1]=(Lib3dsByte)(((Lib3dsDword)d.dword_value & 0x0000FF00) >> 8);
++  b[0]=(Lib3dsByte)(((Lib3dsDword)d.dword_value & 0x000000FF));
+   if (lib3ds_io_write(io, b, 4)!=4) {
+     return(LIB3DS_FALSE);
+   }



Home | Main Index | Thread Index | Old Index