Index: native_client_sdk/src/libraries/nacl_io/syscalls/htonl.c |
diff --git a/native_client_sdk/src/libraries/nacl_io/syscalls/htonl.c b/native_client_sdk/src/libraries/nacl_io/syscalls/htonl.c |
new file mode 100644 |
index 0000000000000000000000000000000000000000..f198c62afbd18a40af21d59997e9dc761ba3387e |
--- /dev/null |
+++ b/native_client_sdk/src/libraries/nacl_io/syscalls/htonl.c |
@@ -0,0 +1,18 @@ |
+/* Copyright (c) 2013 The Chromium Authors. All rights reserved. |
+ * Use of this source code is governed by a BSD-style license that can be |
+ * found in the LICENSE file. */ |
+ |
+#include "nacl_io/ossocket.h" |
+#if defined(PROVIDES_SOCKET_API) && !defined(__GLIBC__) |
+ |
+inline uint32_t htonl(uint32_t hostlong) { |
+ uint8_t result_bytes[4]; |
+ result_bytes[0] = (uint8_t) ((hostlong >> 24) & 0xFF); |
+ result_bytes[1] = (uint8_t) ((hostlong >> 16) & 0xFF); |
+ result_bytes[2] = (uint8_t) ((hostlong >> 8) & 0xFF); |
+ result_bytes[3] = (uint8_t) (hostlong & 0xFF); |
+ uint32_t* result = (uint32_t*) result_bytes; |
binji
2013/08/08 16:07:21
This breaks strict aliasing rules. Probably will w
torinmr
2013/08/08 17:10:07
Done.
|
+ return *result; |
+} |
+ |
+#endif // defined(PROVIDES_SOCKET_API) && !defined(__GLIBC__) |
Sam Clegg
2013/08/08 01:47:25
Use C++ comment
binji
2013/08/08 16:07:21
You mean C89 comment.
torinmr
2013/08/08 17:01:22
Done.
|