summaryrefslogtreecommitdiffstats
path: root/lib6145/libS6145ImageReProcess.c
diff options
context:
space:
mode:
authorSolomon Peachy <pizza@shaftnet.org>2020-01-25 07:33:52 -0500
committerSolomon Peachy <pizza@shaftnet.org>2020-01-25 07:33:52 -0500
commitc21e10a2ab94ca05710cd41b947e196f75b21133 (patch)
treeb81799c1f449d281e30459a51863886ff37159ba /lib6145/libS6145ImageReProcess.c
parent7030bc952d4c65eae07888fdcbf3bcf429da9f3c (diff)
downloadselphy_print-c21e10a2ab94ca05710cd41b947e196f75b21133.tar.gz
selphy_print-c21e10a2ab94ca05710cd41b947e196f75b21133.tar.bz2
selphy_print-c21e10a2ab94ca05710cd41b947e196f75b21133.zip
misc: Clean up endian macros, eliminate use of ntohs and friends.
Diffstat (limited to 'lib6145/libS6145ImageReProcess.c')
-rw-r--r--lib6145/libS6145ImageReProcess.c57
1 files changed, 38 insertions, 19 deletions
diff --git a/lib6145/libS6145ImageReProcess.c b/lib6145/libS6145ImageReProcess.c
index d58444c..2428ab6 100644
--- a/lib6145/libS6145ImageReProcess.c
+++ b/lib6145/libS6145ImageReProcess.c
@@ -47,7 +47,6 @@
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
-#include <arpa/inet.h>
#include <math.h>
//-------------------------------------------------------------------------
@@ -227,27 +226,45 @@ static void LeadEdgeCorrection(void);
// Endian Manipulation macros
#if (__BYTE_ORDER == __LITTLE_ENDIAN)
+#define le64_to_cpu(__x) __x
#define le32_to_cpu(__x) __x
#define le16_to_cpu(__x) __x
-#define be16_to_cpu(__x) ntohs(__x)
-#define be32_to_cpu(__x) ntohl(__x)
+#define be16_to_cpu(__x) ((uint16_t)( \
+ (((uint16_t)(__x) & (uint16_t)0x00ff) << 8) | \
+ (((uint16_t)(__x) & (uint16_t)0xff00) >> 8) ))
+#define be32_to_cpu(__x) ((uint32_t)( \
+ (((uint32_t)(__x) & (uint32_t)0x000000ffUL) << 24) | \
+ (((uint32_t)(__x) & (uint32_t)0x0000ff00UL) << 8) | \
+ (((uint32_t)(__x) & (uint32_t)0x00ff0000UL) >> 8) | \
+ (((uint32_t)(__x) & (uint32_t)0xff000000UL) >> 24) ))
+#define be64_to_cpu(__x) ((uint64_t)( \
+ (((uint64_t)(__x) & (uint64_t)0x00000000000000ffULL) << 56) | \
+ (((uint64_t)(__x) & (uint64_t)0x000000000000ff00ULL) << 40) | \
+ (((uint64_t)(__x) & (uint64_t)0x0000000000ff0000ULL) << 24) | \
+ (((uint64_t)(__x) & (uint64_t)0x00000000ff000000ULL) << 8) | \
+ (((uint64_t)(__x) & (uint64_t)0x000000ff00000000ULL) >> 8) | \
+ (((uint64_t)(__x) & (uint64_t)0x0000ff0000000000ULL) >> 24) | \
+ (((uint64_t)(__x) & (uint64_t)0x00ff000000000000ULL) >> 40) | \
+ (((uint64_t)(__x) & (uint64_t)0xff00000000000000ULL) >> 56) ))
#else
-#define le32_to_cpu(x) \
- ({ \
- uint32_t __x = (x); \
- ((uint32_t)( \
- (((uint32_t)(__x) & (uint32_t)0x000000ffUL) << 24) | \
- (((uint32_t)(__x) & (uint32_t)0x0000ff00UL) << 8) | \
- (((uint32_t)(__x) & (uint32_t)0x00ff0000UL) >> 8) | \
- (((uint32_t)(__x) & (uint32_t)0xff000000UL) >> 24) )); \
- })
-#define le16_to_cpu(x) \
- ({ \
- uint16_t __x = (x); \
- ((uint16_t)( \
- (((uint16_t)(__x) & (uint16_t)0x00ff) << 8) | \
- (((uint16_t)(__x) & (uint16_t)0xff00) >> 8))); \
- })
+#define le16_to_cpu(__x) ((uint16_t)( \
+ (((uint16_t)(__x) & (uint16_t)0x00ff) << 8) | \
+ (((uint16_t)(__x) & (uint16_t)0xff00) >> 8) ))
+#define le32_to_cpu(__x) ((uint32_t)( \
+ (((uint32_t)(__x) & (uint32_t)0x000000ffUL) << 24) | \
+ (((uint32_t)(__x) & (uint32_t)0x0000ff00UL) << 8) | \
+ (((uint32_t)(__x) & (uint32_t)0x00ff0000UL) >> 8) | \
+ (((uint32_t)(__x) & (uint32_t)0xff000000UL) >> 24) ))
+#define le64_to_cpu(__x) ((uint64_t)( \
+ (((uint64_t)(__x) & (uint64_t)0x00000000000000ffULL) << 56) | \
+ (((uint64_t)(__x) & (uint64_t)0x000000000000ff00ULL) << 40) | \
+ (((uint64_t)(__x) & (uint64_t)0x0000000000ff0000ULL) << 24) | \
+ (((uint64_t)(__x) & (uint64_t)0x00000000ff000000ULL) << 8) | \
+ (((uint64_t)(__x) & (uint64_t)0x000000ff00000000ULL) >> 8) | \
+ (((uint64_t)(__x) & (uint64_t)0x0000ff0000000000ULL) >> 24) | \
+ (((uint64_t)(__x) & (uint64_t)0x00ff000000000000ULL) >> 40) | \
+ (((uint64_t)(__x) & (uint64_t)0xff00000000000000ULL) >> 56)))
+#define be64_to_cpu(__x) __x
#define be32_to_cpu(__x) __x
#define be16_to_cpu(__x) __x
#endif
@@ -256,6 +273,8 @@ static void LeadEdgeCorrection(void);
#define cpu_to_le32 le32_to_cpu
#define cpu_to_be16 be16_to_cpu
#define cpu_to_be32 be32_to_cpu
+#define cpu_to_le64 le64_to_cpu
+#define cpu_to_be64 be64_to_cpu
//-------------------------------------------------------------------------
// Data declarations