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

Side by Side Diff: base/sys_byteorder.h

Issue 1446363003: Deleted OS_WIN and all Windows specific files from base. (Closed) Base URL: https://github.com/domokit/mojo.git@base_tests
Patch Set: Created 5 years, 1 month 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 unified diff | Download patch
« no previous file with comments | « base/synchronization/waitable_event_win.cc ('k') | base/sys_info_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 header defines cross-platform ByteSwap() implementations for 16, 32 and 5 // This header defines cross-platform ByteSwap() implementations for 16, 32 and
6 // 64-bit values, and NetToHostXX() / HostToNextXX() functions equivalent to 6 // 64-bit values, and NetToHostXX() / HostToNextXX() functions equivalent to
7 // the traditional ntohX() and htonX() functions. 7 // the traditional ntohX() and htonX() functions.
8 // Use the functions defined here rather than using the platform-specific 8 // Use the functions defined here rather than using the platform-specific
9 // functions directly. 9 // functions directly.
10 10
11 #ifndef BASE_SYS_BYTEORDER_H_ 11 #ifndef BASE_SYS_BYTEORDER_H_
12 #define BASE_SYS_BYTEORDER_H_ 12 #define BASE_SYS_BYTEORDER_H_
13 13
14 #include <arpa/inet.h>
15
14 #include "base/basictypes.h" 16 #include "base/basictypes.h"
15 #include "build/build_config.h" 17 #include "build/build_config.h"
16 18
17 #if defined(OS_WIN)
18 #include <winsock2.h>
19 #else
20 #include <arpa/inet.h>
21 #endif
22
23 namespace base { 19 namespace base {
24 20
25 // Returns a value with all bytes in |x| swapped, i.e. reverses the endianness. 21 // Returns a value with all bytes in |x| swapped, i.e. reverses the endianness.
26 inline uint16 ByteSwap(uint16 x) { 22 inline uint16 ByteSwap(uint16 x) {
27 return ((x & 0x00ff) << 8) | ((x & 0xff00) >> 8); 23 return ((x & 0x00ff) << 8) | ((x & 0xff00) >> 8);
28 } 24 }
29 25
30 inline uint32 ByteSwap(uint32 x) { 26 inline uint32 ByteSwap(uint32 x) {
31 return ((x & 0x000000fful) << 24) | ((x & 0x0000ff00ul) << 8) | 27 return ((x & 0x000000fful) << 24) | ((x & 0x0000ff00ul) << 8) |
32 ((x & 0x00ff0000ul) >> 8) | ((x & 0xff000000ul) >> 24); 28 ((x & 0x00ff0000ul) >> 8) | ((x & 0xff000000ul) >> 24);
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
111 #if defined(ARCH_CPU_LITTLE_ENDIAN) 107 #if defined(ARCH_CPU_LITTLE_ENDIAN)
112 return ByteSwap(x); 108 return ByteSwap(x);
113 #else 109 #else
114 return x; 110 return x;
115 #endif 111 #endif
116 } 112 }
117 113
118 } // namespace base 114 } // namespace base
119 115
120 #endif // BASE_SYS_BYTEORDER_H_ 116 #endif // BASE_SYS_BYTEORDER_H_
OLDNEW
« no previous file with comments | « base/synchronization/waitable_event_win.cc ('k') | base/sys_info_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698