Tags: patch
User: [email protected]
Usertags: mips-patch
Hello,
I have attached patch which is obtained from upstream:
https://github.com/zbackup/zbackup/compare/1.2...master
Patch adds support for big endian architectures.
Patched package was successfully built and tested on mips.
Backups made on little endian were successfully restored on little and big
endian.
Backups made on big endian were successfully restored on little and big endian.
Thanks!
Jurica
diff -upNr zbackup-1.2-orig/debian/patches/big-endian-support.patch zbackup-1.2/debian/patches/big-endian-support.patch
--- zbackup-1.2-orig/debian/patches/big-endian-support.patch 1970-01-01 00:00:00.000000000 +0000
+++ zbackup-1.2/debian/patches/big-endian-support.patch 2014-02-03 14:03:14.000000000 +0000
@@ -0,0 +1,38 @@
+--- zbackup-1.2.orig/endian.hh
++++ zbackup-1.2/endian.hh
+@@ -12,9 +12,7 @@
+ #include <endian.h>
+ #endif
+
+-#if __BYTE_ORDER != __LITTLE_ENDIAN
+-#error Please add support for architectures different from little-endian.
+-#endif
++#if __BYTE_ORDER == __LITTLE_ENDIAN
+
+ /// Converts the given host-order value to big-endian value
+ inline uint32_t toBigEndian( uint32_t v ) { return htonl( v ); }
+@@ -25,4 +23,24 @@ inline uint64_t toLittleEndian( uint64_t
+ inline uint32_t fromLittleEndian( uint32_t v ) { return v; }
+ inline uint64_t fromLittleEndian( uint64_t v ) { return v; }
+
++#elif __BYTE_ORDER == __BIG_ENDIAN
++
++// Note: the functions used are non-standard. Add more ifdefs if needed
++
++/// Converts the given host-order value to big-endian value
++inline uint32_t toBigEndian( uint32_t v ) { return v; }
++/// Converts the given host-order value to little-endian value
++inline uint32_t toLittleEndian( uint32_t v ) { return htole32( v ); }
++inline uint64_t toLittleEndian( uint64_t v ) { return htole64( v ); }
++/// Converts the given little-endian value to host-order value
++inline uint32_t fromLittleEndian( uint32_t v ) { return le32toh( v ); }
++inline uint64_t fromLittleEndian( uint64_t v ) { return le64toh( v ); }
++
++#else
++
++#error Please add support for architectures different from little-endian and\
++big-endian.
++
++#endif
++
+ #endif
diff -upNr zbackup-1.2-orig/debian/patches/series zbackup-1.2/debian/patches/series
--- zbackup-1.2-orig/debian/patches/series 1970-01-01 00:00:00.000000000 +0000
+++ zbackup-1.2/debian/patches/series 2014-02-03 14:03:14.000000000 +0000
@@ -0,0 +1 @@
+big-endian-support.patch
--- zbackup-1.2.orig/endian.hh
+++ zbackup-1.2/endian.hh
@@ -12,9 +12,7 @@
#include <endian.h>
#endif
-#if __BYTE_ORDER != __LITTLE_ENDIAN
-#error Please add support for architectures different from little-endian.
-#endif
+#if __BYTE_ORDER == __LITTLE_ENDIAN
/// Converts the given host-order value to big-endian value
inline uint32_t toBigEndian( uint32_t v ) { return htonl( v ); }
@@ -25,4 +23,24 @@ inline uint64_t toLittleEndian( uint64_t
inline uint32_t fromLittleEndian( uint32_t v ) { return v; }
inline uint64_t fromLittleEndian( uint64_t v ) { return v; }
+#elif __BYTE_ORDER == __BIG_ENDIAN
+
+// Note: the functions used are non-standard. Add more ifdefs if needed
+
+/// Converts the given host-order value to big-endian value
+inline uint32_t toBigEndian( uint32_t v ) { return v; }
+/// Converts the given host-order value to little-endian value
+inline uint32_t toLittleEndian( uint32_t v ) { return htole32( v ); }
+inline uint64_t toLittleEndian( uint64_t v ) { return htole64( v ); }
+/// Converts the given little-endian value to host-order value
+inline uint32_t fromLittleEndian( uint32_t v ) { return le32toh( v ); }
+inline uint64_t fromLittleEndian( uint64_t v ) { return le64toh( v ); }
+
+#else
+
+#error Please add support for architectures different from little-endian and\
+big-endian.
+
+#endif
+
#endif