summaryrefslogtreecommitdiff
path: root/graphics/lib3ds/patches
diff options
context:
space:
mode:
authorreinoud <reinoud>2008-12-18 13:15:10 +0000
committerreinoud <reinoud>2008-12-18 13:15:10 +0000
commitd24d5b3eb0ab4966d440117faf1f89a2deb055ab (patch)
tree6a06145834136bceb799c541d9dee1924d31dbe3 /graphics/lib3ds/patches
parent7ddd7b7032a8837415212eb345299d424d678bf8 (diff)
downloadpkgsrc-d24d5b3eb0ab4966d440117faf1f89a2deb055ab.tar.gz
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 (limited to 'graphics/lib3ds/patches')
-rw-r--r--graphics/lib3ds/patches/patch-af56
1 files changed, 56 insertions, 0 deletions
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 <je-h@gmx.net>
+ */
+
++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);
+ }