Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(429)

Unified Diff: cgpt/endian.h

Issue 2719008: Nearly complete rewrite of cgpt tool. (Closed) Base URL: ssh://git@chromiumos-git//vboot_reference.git
Patch Set: Created 10 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « cgpt/cmd_show.c ('k') | tests/Makefile » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: cgpt/endian.h
diff --git a/cgpt/endian.h b/cgpt/endian.h
new file mode 100644
index 0000000000000000000000000000000000000000..ab62ebc927863dfe94376b05d766dc901c133b98
--- /dev/null
+++ b/cgpt/endian.h
@@ -0,0 +1,44 @@
+#ifndef VBOOT_REFERENCE_UTILITY_CGPT_ENDIAN_H_
+#define VBOOT_REFERENCE_UTILITY_CGPT_ENDIAN_H_
+
+// Newer distros already have this. For those that don't, we add it here.
+#include <endian.h>
+
+#ifndef le16toh
+
+# include <byteswap.h>
+
+# if __BYTE_ORDER == __LITTLE_ENDIAN
+# define htobe16(x) __bswap_16 (x)
+# define htole16(x) (x)
+# define be16toh(x) __bswap_16 (x)
+# define le16toh(x) (x)
+
+# define htobe32(x) __bswap_32 (x)
+# define htole32(x) (x)
+# define be32toh(x) __bswap_32 (x)
+# define le32toh(x) (x)
+
+# define htobe64(x) __bswap_64 (x)
+# define htole64(x) (x)
+# define be64toh(x) __bswap_64 (x)
+# define le64toh(x) (x)
+# else
+# define htobe16(x) (x)
+# define htole16(x) __bswap_16 (x)
+# define be16toh(x) (x)
+# define le16toh(x) __bswap_16 (x)
+
+# define htobe32(x) (x)
+# define htole32(x) __bswap_32 (x)
+# define be32toh(x) (x)
+# define le32toh(x) __bswap_32 (x)
+
+# define htobe64(x) (x)
+# define htole64(x) __bswap_64 (x)
+# define be64toh(x) (x)
+# define le64toh(x) __bswap_64 (x)
+# endif
+
+#endif
+#endif // VBOOT_REFERENCE_UTILITY_CGPT_ENDIAN_H_
« no previous file with comments | « cgpt/cmd_show.c ('k') | tests/Makefile » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698