Index: third_party/libjingle/overrides/talk/base/byteorder.h |
=================================================================== |
--- third_party/libjingle/overrides/talk/base/byteorder.h (revision 126778) |
+++ third_party/libjingle/overrides/talk/base/byteorder.h (working copy) |
@@ -33,8 +33,8 @@ |
#endif |
#ifdef WIN32 |
+#include <stdlib.h> |
#include <winsock2.h> |
-#include "talk/base/win32.h" |
#endif |
#include "talk/base/basictypes.h" |
@@ -143,11 +143,22 @@ |
} |
inline uint16 HostToNetwork16(uint16 n) { |
+#ifdef WIN32 |
+ // This and below _byteswap_* are to remove the dependency to ws2_32.dll |
+ // especially for chrome, where we don't load the ws2_32.dll in the render |
+ // process. This is correct only on little-endian machines. |
+ return _byteswap_ushort(n); |
+#else |
return htons(n); |
+#endif |
} |
inline uint32 HostToNetwork32(uint32 n) { |
+#ifdef WIN32 |
+ return _byteswap_ulong(n); |
+#else |
return htonl(n); |
+#endif |
} |
inline uint64 HostToNetwork64(uint64 n) { |
@@ -156,11 +167,19 @@ |
} |
inline uint16 NetworkToHost16(uint16 n) { |
+#ifdef WIN32 |
+ return _byteswap_ushort(n); |
+#else |
return ntohs(n); |
+#endif |
} |
inline uint32 NetworkToHost32(uint32 n) { |
+#ifdef WIN32 |
+ return _byteswap_ulong(n); |
+#else |
return ntohl(n); |
+#endif |
} |
inline uint64 NetworkToHost64(uint64 n) { |