From d24d5b3eb0ab4966d440117faf1f89a2deb055ab Mon Sep 17 00:00:00 2001 From: reinoud Date: Thu, 18 Dec 2008 13:15:10 +0000 Subject: 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. --- graphics/lib3ds/Makefile | 4 +-- graphics/lib3ds/distinfo | 3 ++- graphics/lib3ds/patches/patch-af | 56 ++++++++++++++++++++++++++++++++++++++++ 3 files changed, 60 insertions(+), 3 deletions(-) create mode 100644 graphics/lib3ds/patches/patch-af (limited to 'graphics/lib3ds') diff --git a/graphics/lib3ds/Makefile b/graphics/lib3ds/Makefile index 3eef310075a..05f12d04403 100644 --- a/graphics/lib3ds/Makefile +++ b/graphics/lib3ds/Makefile @@ -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 --git a/graphics/lib3ds/distinfo b/graphics/lib3ds/distinfo index d540c6956b2..29d2f96b900 100644 --- a/graphics/lib3ds/distinfo +++ b/graphics/lib3ds/distinfo @@ -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-ab) = b2d6804b71fb37428ebf7fb59168ae8ef2eec362 SHA1 (patch-ac) = d73dd1b2cdabe61f78d4a7307a04917ff5fc379b SHA1 (patch-ad) = bbf95ca49e1bf6fa67314f9818af5b1b974eb54a SHA1 (patch-ae) = 7760d2311d99f3d5d91f89fceced314648abbeb0 +SHA1 (patch-af) = 016c93ead0e5d6a033d891d03db5f227a3e1df71 diff --git a/graphics/lib3ds/patches/patch-af b/graphics/lib3ds/patches/patch-af new file mode 100644 index 00000000000..a108ae585ac --- /dev/null +++ b/graphics/lib3ds/patches/patch-af @@ -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 + */ + ++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); + } -- cgit v1.2.3