[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [52401] trunk/blender/source/blender/ blenlib/BLI_endian_switch_inline.h: Fix bug in endian switch functions.

Sergey Sharybin sergey.vfx at gmail.com
Tue Nov 20 11:37:14 CET 2012


Revision: 52401
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=52401
Author:   nazgul
Date:     2012-11-20 10:37:11 +0000 (Tue, 20 Nov 2012)
Log Message:
-----------
Fix bug in endian switch functions.

Seems ti was here since the very first day this functions were added
and issue was happening for switching sign for negative values.

Wrote a brute-force test locally and seems corrected functions indeed
works the same way as old macroses.

This should fix: #33226: File loading issue with svn 52328 (recent BF buildbot compile)

Modified Paths:
--------------
    trunk/blender/source/blender/blenlib/BLI_endian_switch_inline.h

Modified: trunk/blender/source/blender/blenlib/BLI_endian_switch_inline.h
===================================================================
--- trunk/blender/source/blender/blenlib/BLI_endian_switch_inline.h	2012-11-20 10:24:34 UTC (rev 52400)
+++ trunk/blender/source/blender/blenlib/BLI_endian_switch_inline.h	2012-11-20 10:37:11 UTC (rev 52401)
@@ -38,41 +38,43 @@
 /* *** 16 *** */
 BLI_INLINE void BLI_endian_switch_int16(short *val)
 {
-	short tval = *val;
-	*val = (tval >> 8) |
-	       (tval << 8);
-
+	BLI_endian_switch_uint16((unsigned short *)val);
 }
 BLI_INLINE void BLI_endian_switch_uint16(unsigned short *val)
 {
-	BLI_endian_switch_int16((short *)val);
+	unsigned short tval = *val;
+	*val = (tval >> 8) |
+	       (tval << 8);
 }
 
 
 /* *** 32 *** */
 BLI_INLINE void BLI_endian_switch_int32(int *val)
 {
-	int tval = *val;
+	BLI_endian_switch_uint32((unsigned int *)val);
+}
+BLI_INLINE void BLI_endian_switch_uint32(unsigned int *val)
+{
+	unsigned int tval = *val;
 	*val = ((tval >> 24))             |
 	       ((tval << 8) & 0x00ff0000) |
 	       ((tval >> 8) & 0x0000ff00) |
 	       ((tval << 24));
-
 }
-BLI_INLINE void BLI_endian_switch_uint32(unsigned int *val)
-{
-	BLI_endian_switch_int32((int *)val);
-}
 BLI_INLINE void BLI_endian_switch_float(float *val)
 {
-	BLI_endian_switch_int32((int *)val);
+	BLI_endian_switch_uint32((unsigned int *)val);
 }
 
 
 /* *** 64 *** */
 BLI_INLINE void BLI_endian_switch_int64(int64_t *val)
 {
-	int64_t tval = *val;
+	BLI_endian_switch_uint64((uint64_t *)val);
+}
+BLI_INLINE void BLI_endian_switch_uint64(uint64_t *val)
+{
+	uint64_t tval = *val;
 	*val = ((tval >> 56)) |
 	       ((tval << 40) & 0x00ff000000000000ll) |
 	       ((tval << 24) & 0x0000ff0000000000ll) |
@@ -82,13 +84,9 @@
 	       ((tval >> 40) & 0x000000000000ff00ll) |
 	       ((tval << 56));
 }
-BLI_INLINE void BLI_endian_switch_uint64(uint64_t *val)
-{
-	BLI_endian_switch_int64((int64_t *)val);
-}
 BLI_INLINE void BLI_endian_switch_double(double *val)
 {
-	BLI_endian_switch_int64((int64_t *)val);
+	BLI_endian_switch_uint64((uint64_t *)val);
 }
 
 #endif  /* __BLI_ENDIAN_SWITCH_INLINE_H__ */




More information about the Bf-blender-cvs mailing list