| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 // This is a convenience header to pull in the platform-specific | 5 // This header defines cross-platform ByteSwap() implementations for 16, 32 and |
| 6 // headers that define functions for byte-order conversion, | 6 // 64-bit values, and NetToHostXX() / HostToNextXX() functions equivalent to |
| 7 // particularly: ntohs(), htons(), ntohl(), htonl(). Prefer including | 7 // the traditional ntohX() and htonX() functions. |
| 8 // this file instead of directly writing the #if / #else, since it | 8 // Use the functions defined here rather than using the platform-specific |
| 9 // avoids duplicating the platform-specific selections. | 9 // functions directly. |
| 10 // This header also provides ntohll() and htonll() for byte-order conversion | |
| 11 // for 64-bit integers. | |
| 12 | 10 |
| 13 #ifndef BASE_SYS_BYTEORDER_H_ | 11 #ifndef BASE_SYS_BYTEORDER_H_ |
| 14 #define BASE_SYS_BYTEORDER_H_ | 12 #define BASE_SYS_BYTEORDER_H_ |
| 15 | 13 |
| 16 #include "base/basictypes.h" | 14 #include "base/basictypes.h" |
| 17 #include "build/build_config.h" | 15 #include "build/build_config.h" |
| 18 | 16 |
| 19 #if defined(OS_WIN) | 17 #if defined(OS_WIN) |
| 20 #include <winsock2.h> | 18 #include <winsock2.h> |
| 21 #else | 19 #else |
| (...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 116 return ByteSwap(x); | 114 return ByteSwap(x); |
| 117 #else | 115 #else |
| 118 return x; | 116 return x; |
| 119 #endif | 117 #endif |
| 120 } | 118 } |
| 121 | 119 |
| 122 } // namespace base | 120 } // namespace base |
| 123 | 121 |
| 124 | 122 |
| 125 #endif // BASE_SYS_BYTEORDER_H_ | 123 #endif // BASE_SYS_BYTEORDER_H_ |
| OLD | NEW |