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

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

Issue 2974233002: VM: Re-format to use at most one newline between functions (Closed)
Patch Set: Rebase and merge Created 3 years, 5 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
« no previous file with comments | « runtime/platform/utils_linux.h ('k') | runtime/platform/utils_win.h » ('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 RUNTIME_PLATFORM_UTILS_MACOS_H_ 5 #ifndef RUNTIME_PLATFORM_UTILS_MACOS_H_
6 #define RUNTIME_PLATFORM_UTILS_MACOS_H_ 6 #define RUNTIME_PLATFORM_UTILS_MACOS_H_
7 7
8 #include <libkern/OSByteOrder.h> // NOLINT 8 #include <libkern/OSByteOrder.h> // NOLINT
9 9
10 namespace dart { 10 namespace dart {
11 11
12 inline int Utils::CountLeadingZeros(uword x) { 12 inline int Utils::CountLeadingZeros(uword x) {
13 #if defined(ARCH_IS_32_BIT) 13 #if defined(ARCH_IS_32_BIT)
14 return __builtin_clzl(x); 14 return __builtin_clzl(x);
15 #elif defined(ARCH_IS_64_BIT) 15 #elif defined(ARCH_IS_64_BIT)
16 return __builtin_clzll(x); 16 return __builtin_clzll(x);
17 #else 17 #else
18 #error Architecture is not 32-bit or 64-bit. 18 #error Architecture is not 32-bit or 64-bit.
19 #endif 19 #endif
20 } 20 }
21 21
22
23 inline int Utils::CountTrailingZeros(uword x) { 22 inline int Utils::CountTrailingZeros(uword x) {
24 #if defined(ARCH_IS_32_BIT) 23 #if defined(ARCH_IS_32_BIT)
25 return __builtin_ctzl(x); 24 return __builtin_ctzl(x);
26 #elif defined(ARCH_IS_64_BIT) 25 #elif defined(ARCH_IS_64_BIT)
27 return __builtin_ctzll(x); 26 return __builtin_ctzll(x);
28 #else 27 #else
29 #error Architecture is not 32-bit or 64-bit. 28 #error Architecture is not 32-bit or 64-bit.
30 #endif 29 #endif
31 } 30 }
32 31
33
34 inline uint16_t Utils::HostToBigEndian16(uint16_t value) { 32 inline uint16_t Utils::HostToBigEndian16(uint16_t value) {
35 return OSSwapHostToBigInt16(value); 33 return OSSwapHostToBigInt16(value);
36 } 34 }
37 35
38
39 inline uint32_t Utils::HostToBigEndian32(uint32_t value) { 36 inline uint32_t Utils::HostToBigEndian32(uint32_t value) {
40 return OSSwapHostToBigInt32(value); 37 return OSSwapHostToBigInt32(value);
41 } 38 }
42 39
43
44 inline uint64_t Utils::HostToBigEndian64(uint64_t value) { 40 inline uint64_t Utils::HostToBigEndian64(uint64_t value) {
45 return OSSwapHostToBigInt64(value); 41 return OSSwapHostToBigInt64(value);
46 } 42 }
47 43
48
49 inline uint16_t Utils::HostToLittleEndian16(uint16_t value) { 44 inline uint16_t Utils::HostToLittleEndian16(uint16_t value) {
50 return OSSwapHostToLittleInt16(value); 45 return OSSwapHostToLittleInt16(value);
51 } 46 }
52 47
53
54 inline uint32_t Utils::HostToLittleEndian32(uint32_t value) { 48 inline uint32_t Utils::HostToLittleEndian32(uint32_t value) {
55 return OSSwapHostToLittleInt32(value); 49 return OSSwapHostToLittleInt32(value);
56 } 50 }
57 51
58
59 inline uint64_t Utils::HostToLittleEndian64(uint64_t value) { 52 inline uint64_t Utils::HostToLittleEndian64(uint64_t value) {
60 return OSSwapHostToLittleInt64(value); 53 return OSSwapHostToLittleInt64(value);
61 } 54 }
62 55
63 inline char* Utils::StrError(int err, char* buffer, size_t bufsize) { 56 inline char* Utils::StrError(int err, char* buffer, size_t bufsize) {
64 if (strerror_r(err, buffer, bufsize) != 0) { 57 if (strerror_r(err, buffer, bufsize) != 0) {
65 snprintf(buffer, bufsize, "%s", "strerror_r failed"); 58 snprintf(buffer, bufsize, "%s", "strerror_r failed");
66 } 59 }
67 return buffer; 60 return buffer;
68 } 61 }
69 62
70 } // namespace dart 63 } // namespace dart
71 64
72 #endif // RUNTIME_PLATFORM_UTILS_MACOS_H_ 65 #endif // RUNTIME_PLATFORM_UTILS_MACOS_H_
OLDNEW
« no previous file with comments | « runtime/platform/utils_linux.h ('k') | runtime/platform/utils_win.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698