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

Side by Side Diff: runtime/platform/utils_win.h

Issue 14299008: Add utilities for converting from Host endianity to big endian and little endian formats for the va… (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 7 years, 8 months 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 | Annotate | Revision Log
« no previous file with comments | « runtime/platform/utils_macos.h ('k') | runtime/vm/os_android.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 Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 #ifndef PLATFORM_UTILS_WIN_H_ 5 #ifndef PLATFORM_UTILS_WIN_H_
6 #define PLATFORM_UTILS_WIN_H_ 6 #define PLATFORM_UTILS_WIN_H_
7 7
8 #include <intrin.h> 8 #include <intrin.h>
9 #include <stdlib.h>
9 10
10 namespace dart { 11 namespace dart {
11 12
12 inline int Utils::CountTrailingZeros(uword x) { 13 inline int Utils::CountTrailingZeros(uword x) {
13 unsigned long result; // NOLINT 14 unsigned long result; // NOLINT
14 #if defined(ARCH_IS_32_BIT) 15 #if defined(ARCH_IS_32_BIT)
15 _BitScanReverse(&result, x); 16 _BitScanReverse(&result, x);
16 #elif defined(ARCH_IS_64_BIT) 17 #elif defined(ARCH_IS_64_BIT)
17 _BitScanReverse64(&result, x); 18 _BitScanReverse64(&result, x);
18 #else 19 #else
19 #error Architecture is not 32-bit or 64-bit. 20 #error Architecture is not 32-bit or 64-bit.
20 #endif 21 #endif
21 return static_cast<int>(result); 22 return static_cast<int>(result);
22 }; 23 };
23 24
25
26 inline uint16_t Utils::HostToBigEndian16(uint16_t value) {
27 return _byteswap_ushort(value);
28 }
29
30
31 inline uint32_t Utils::HostToBigEndian32(uint32_t value) {
32 return _byteswap_ulong(value);
33 }
34
35
36 inline uint64_t Utils::HostToBigEndian64(uint64_t value) {
37 return _byteswap_uint64(value);
38 }
39
40
41 inline uint16_t Utils::HostToLittleEndian16(uint16_t value) {
42 return value;
43 }
44
45
46 inline uint32_t Utils::HostToLittleEndian32(uint32_t value) {
47 return value;
48 }
49
50
51 inline uint64_t Utils::HostToLittleEndian64(uint64_t value) {
52 return value;
53 }
54
24 } // namespace dart 55 } // namespace dart
25 56
26 #endif // PLATFORM_UTILS_WIN_H_ 57 #endif // PLATFORM_UTILS_WIN_H_
OLDNEW
« no previous file with comments | « runtime/platform/utils_macos.h ('k') | runtime/vm/os_android.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698