summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorTim Burke <tim.burke@gmail.com>2018-09-11 19:36:10 +0000
committerTim Burke <tim.burke@gmail.com>2018-09-11 21:58:34 -0600
commit7b547e0e46fc0a4172b602ec2a362eb1fa3a6431 (patch)
tree92499af9460e1ecb08a6234227d02f3a792c1fb0 /include
parent72af842b2818f5b43e073cd9196afcc91f6af60a (diff)
downloadliberasurecode-7b547e0e46fc0a4172b602ec2a362eb1fa3a6431.tar.gz
Allow reading of little-endian frags on big-endian
... and vice-versa. We'll fix up frag header values for our output parameter from liberasurecode_get_fragment_metadata but otherwise avoid manipulating the in-memory fragment much. Change-Id: Idd6833bdea60e27c9a0148ee28b4a2c1070be148
Diffstat (limited to 'include')
-rw-r--r--include/erasurecode/erasurecode_helpers.h16
1 files changed, 16 insertions, 0 deletions
diff --git a/include/erasurecode/erasurecode_helpers.h b/include/erasurecode/erasurecode_helpers.h
index f0be41a..0168a55 100644
--- a/include/erasurecode/erasurecode_helpers.h
+++ b/include/erasurecode/erasurecode_helpers.h
@@ -93,5 +93,21 @@ void *get_aligned_buffer16(int size);
/* ==~=*=~==~=*=~==~=*=~==~=*=~==~=*=~==~=*=~==~=*=~==~=*=~==~=*=~==~=*=~== */
+#ifndef bswap_32
+static __inline uint32_t __libec_bswap_32(uint32_t __x)
+{
+ return __x>>24 | (__x>>8&0xff00) | (__x<<8&0xff0000) | __x<<24;
+}
+#define bswap_32(x) __libec_bswap_32(x)
+#endif
+
+#ifndef bswap_64
+static __inline uint64_t __libec_bswap_64(uint64_t __x)
+{
+ return (__libec_bswap_32(__x)+0ULL)<<32 | __libec_bswap_32(__x>>32);
+}
+#define bswap_64(x) __libec_bswap_64(x)
+#endif
+
#endif // _ERASURECODE_HELPERS_H_