Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Build on big-endian systems again.

On big endian, fn_le32() is actually a function, not an empty preprocessor
macro, so we can't take the address of its return value when doing the C
equivalent of reinterpret_cast.

Signed-off-by: Drew Fisher <drew.m.fisher@gmail.com>
  • Loading branch information...
commit bbc109a589a1dd2c229f8bc98536dbc184dd73f9 1 parent ac6721a
@zarvox zarvox authored
Showing with 15 additions and 6 deletions.
  1. +9 −4 src/cameras.c
  2. +6 −2 src/freenect_internal.h
View
13 src/cameras.c
@@ -910,10 +910,15 @@ static int freenect_fetch_zero_plane_info(freenect_device *dev)
}
memcpy(&(dev->registration.zero_plane_info), reply + 94, sizeof(dev->registration.zero_plane_info));
- dev->registration.zero_plane_info.dcmos_emitter_dist = *((float*)(&fn_le32(*((uint32_t*)(&dev->registration.zero_plane_info.dcmos_emitter_dist)))));
- dev->registration.zero_plane_info.dcmos_rcmos_dist = *((float*)(&fn_le32(*((uint32_t*)(&dev->registration.zero_plane_info.dcmos_rcmos_dist)))));
- dev->registration.zero_plane_info.reference_distance = *((float*)(&fn_le32(*((uint32_t*)(&dev->registration.zero_plane_info.reference_distance)))));
- dev->registration.zero_plane_info.reference_pixel_size = *((float*)(&fn_le32(*((uint32_t*)(&dev->registration.zero_plane_info.reference_pixel_size)))));
+ uint32_t temp;
+ temp = fn_le32(*((uint32_t*)(&dev->registration.zero_plane_info.dcmos_emitter_dist)));
+ dev->registration.zero_plane_info.dcmos_emitter_dist = *((float*)(&temp));
+ temp = fn_le32(*((uint32_t*)(&dev->registration.zero_plane_info.dcmos_rcmos_dist)));
+ dev->registration.zero_plane_info.dcmos_rcmos_dist = *((float*)(&temp));
+ temp = fn_le32(*((uint32_t*)(&dev->registration.zero_plane_info.reference_distance)));
+ dev->registration.zero_plane_info.reference_distance = *((float*)(&temp));
+ temp = fn_le32(*((uint32_t*)(&dev->registration.zero_plane_info.reference_pixel_size)));
+ dev->registration.zero_plane_info.reference_pixel_size = *((float*)(&temp));
// WTF is all this data? it's way bigger than sizeof(XnFixedParams)...
FN_SPEW("dcmos_emitter_distance: %f\n", dev->registration.zero_plane_info.dcmos_emitter_dist);
View
8 src/freenect_internal.h
@@ -89,12 +89,16 @@ static inline uint32_t fn_le32(uint32_t d)
static inline int16_t fn_le16s(int16_t s)
{
// reinterpret cast to unsigned, use the normal fn_le16, and then reinterpret cast back
- return *((int16_t*)(&fn_le16(*((uint16_t*)(&s)))));
+ uint16_t temp = (*(uint16_t*)(&s));
+ temp = fn_le16(temp);
+ return *((int16_t*)(&temp));
}
static inline int32_t fn_le32s(int32_t s)
{
// reinterpret cast to unsigned, use the normal fn_le32, and then reinterpret cast back
- return *((int32_t*)(&fn_le32(*((uint32_t*)(&s)))));
+ uint32_t temp = (*(uint32_t*)(&s));
+ temp = fn_le32(temp);
+ return *((int32_t*)(&temp));
}
#else
#define fn_le16(x) (x)
Please sign in to comment.
Something went wrong with that request. Please try again.