#include <math.h>
#include <stdint.h>
#include <unistd.h>
+#include "../../include/arm_features.h"
/////////////////////////////////////////////////////////////////////////////
#endif
-#define GETLEs16(X) ((int16_t)GETLE16((uint16_t *)X))
-#define GETLEs32(X) ((int16_t)GETLE32((uint16_t *)X))
+#define GETLEs16(X) ((int16_t)GETLE16((uint16_t *)(X)))
-#define GETLE16(X) LE2HOST16(*(uint16_t *)X)
-#define GETLE32_(X) LE2HOST32(*(uint32_t *)X)
-#define GETLE16D(X) ({uint32_t val = GETLE32(X); (val<<16 | val >> 16);})
-#define PUTLE16(X, Y) do{*((uint16_t *)X)=HOST2LE16((uint16_t)Y);}while(0)
-#define PUTLE32_(X, Y) do{*((uint32_t *)X)=HOST2LE32((uint32_t)Y);}while(0)
-#ifdef __arm__
-#define GETLE32(X) (*(uint16_t *)(X)|(((uint16_t *)(X))[1]<<16))
+#define GETLE16(X) LE2HOST16(*(uint16_t *)(X))
+#define GETLE32_(X) LE2HOST32(*(uint32_t *)(X))
+#define PUTLE16(X, Y) do{*((uint16_t *)(X))=HOST2LE16((uint16_t)(Y));}while(0)
+#define PUTLE32_(X, Y) do{*((uint32_t *)(X))=HOST2LE32((uint32_t)(Y));}while(0)
+#if defined(__arm__) && !defined(HAVE_ARMV6)
+// for (very) old ARMs with no unaligned loads?
+#define GETLE32(X) (*(uint16_t *)(X)|((uint32_t)((uint16_t *)(X))[1]<<16))
#define PUTLE32(X, Y) do{uint16_t *p_=(uint16_t *)(X);uint32_t y_=Y;p_[0]=y_;p_[1]=y_>>16;}while(0)
#else
#define GETLE32 GETLE32_
#include <stdlib.h>
#include <string.h>
#include "../gpulib/gpu.h"
+#include "../../include/arm_features.h"
#define u32 uint32_t
#endif
-#define GETLEs16(X) ((int16_t)GETLE16((uint16_t *)X))
-#define GETLEs32(X) ((int16_t)GETLE32((uint16_t *)X))
+#define GETLEs16(X) ((int16_t)GETLE16((uint16_t *)(X)))
-#define GETLE16(X) LE2HOST16(*(uint16_t *)X)
-#define GETLE32_(X) LE2HOST32(*(uint32_t *)X)
-#define GETLE16D(X) ({uint32_t val = GETLE32(X); (val<<16 | val >> 16);})
-#define PUTLE16(X, Y) do{*((uint16_t *)X)=HOST2LE16((uint16_t)Y);}while(0)
-#define PUTLE32_(X, Y) do{*((uint32_t *)X)=HOST2LE32((uint32_t)Y);}while(0)
-#ifdef __arm__
-#define GETLE32(X) (*(uint16_t *)(X)|(((uint16_t *)(X))[1]<<16))
+#define GETLE16(X) LE2HOST16(*(uint16_t *)(X))
+#define GETLE32_(X) LE2HOST32(*(uint32_t *)(X))
+#define PUTLE16(X, Y) do{*((uint16_t *)(X))=HOST2LE16((uint16_t)(Y));}while(0)
+#define PUTLE32_(X, Y) do{*((uint32_t *)(X))=HOST2LE32((uint32_t)(Y));}while(0)
+#if defined(__arm__) && !defined(HAVE_ARMV6)
+// for (very) old ARMs with no unaligned loads?
+#define GETLE32(X) (*(uint16_t *)(X)|((uint32_t)((uint16_t *)(X))[1]<<16))
#define PUTLE32(X, Y) do{uint16_t *p_=(uint16_t *)(X);uint32_t y_=Y;p_[0]=y_;p_[1]=y_>>16;}while(0)
#else
#define GETLE32 GETLE32_