Index: ppapi/tests/test_utils.cc |
diff --git a/ppapi/tests/test_utils.cc b/ppapi/tests/test_utils.cc |
index 4d251d2aa5b1ece2fa011739f0d8c708a380df1c..86a9bc192f0b26f6cb9a606f3a15fb5463a9c3b1 100644 |
--- a/ppapi/tests/test_utils.cc |
+++ b/ppapi/tests/test_utils.cc |
@@ -16,6 +16,19 @@ |
#include "ppapi/cpp/module.h" |
#include "ppapi/cpp/var.h" |
+namespace { |
+ |
+bool IsBigEndian() { |
+ union { |
+ uint32_t integer32; |
+ uint8_t integer8[4]; |
+ } data = { 0x01020304 }; |
+ |
+ return data.integer8[0] == 1; |
+} |
+ |
+} // namespace |
+ |
const int kActionTimeoutMs = 10000; |
const PPB_Testing_Dev* GetTestingInterface() { |
@@ -71,6 +84,20 @@ bool GetLocalHostPort(PP_Instance instance, std::string* host, uint16_t* port) { |
return true; |
} |
+uint16_t ConvertFromNetEndian16(uint16_t x) { |
+ if (IsBigEndian()) |
+ return x; |
+ else |
+ return (x << 8) | (x >> 8); |
+} |
+ |
+uint16_t ConvertToNetEndian16(uint16_t x) { |
+ if (IsBigEndian()) |
+ return x; |
+ else |
+ return (x << 8) | (x >> 8); |
+} |
+ |
void NestedEvent::Wait() { |
PP_DCHECK(pp::Module::Get()->core()->IsMainThread()); |
// Don't allow nesting more than once; it doesn't work with the code as-is, |