Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSergey Sharybin <sergey.vfx@gmail.com>2012-11-20 14:37:11 +0400
committerSergey Sharybin <sergey.vfx@gmail.com>2012-11-20 14:37:11 +0400
commitfb2543a85f5d9625e35010882445ecee2ddc37e8 (patch)
treec4a1d76cc19e8ae71ce3e2a821165874ca4b8f84 /source/blender/blenlib/BLI_endian_switch_inline.h
parent1d7b36605068d63e304aeeef3112be05b5f900df (diff)
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)
Diffstat (limited to 'source/blender/blenlib/BLI_endian_switch_inline.h')
-rw-r--r--source/blender/blenlib/BLI_endian_switch_inline.h34
1 files changed, 16 insertions, 18 deletions
diff --git a/source/blender/blenlib/BLI_endian_switch_inline.h b/source/blender/blenlib/BLI_endian_switch_inline.h
index 4bc6d3828b9..358206f1177 100644
--- a/source/blender/blenlib/BLI_endian_switch_inline.h
+++ b/source/blender/blenlib/BLI_endian_switch_inline.h
@@ -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 @@ BLI_INLINE void BLI_endian_switch_int64(int64_t *val)
((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__ */