pkgsrc/graphics/lib3ds/patches/patch-af
dsainty 4cc0a75ff7 For Linux, pull in stdint.h to make this patch work. This fixes the
compile for some platforms, and is no change for platforms where this
package previously successfully compiled.

XXX The serious portability issues in the patched file remain, but are
no doubt more widespread than this one file anyway.
2009-01-28 00:37:27 +00:00

64 lines
1.6 KiB
Text

$NetBSD: patch-af,v 1.2 2009/01/28 00:37:27 dsainty Exp $
--- lib3ds/io.c.orig 2001-07-12 01:47:35.000000000 +1200
+++ lib3ds/io.c 2009-01-25 19:59:22.437777313 +1300
@@ -21,6 +21,7 @@
*/
#define LIB3DS_EXPORT
#include <lib3ds/io.h>
+#include <stdint.h>
#include <stdlib.h>
#include <string.h>
@@ -31,6 +32,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 +254,15 @@
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 +465,14 @@
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);
}