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

Side by Side Diff: runtime/vm/os_macos.cc

Issue 415513002: - Fix a lot of warnings generated by -Wshorten-64-to-32 (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 6 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 | Annotate | Revision Log
« no previous file with comments | « runtime/vm/os_linux.cc ('k') | runtime/vm/os_test.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 #include "vm/globals.h" 5 #include "vm/globals.h"
6 #if defined(TARGET_OS_MACOS) 6 #if defined(TARGET_OS_MACOS)
7 7
8 #include "vm/os.h" 8 #include "vm/os.h"
9 9
10 #include <errno.h> // NOLINT 10 #include <errno.h> // NOLINT
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
92 // TODO(johnmccutchan): Remove hack and switch to posix_memalign. 92 // TODO(johnmccutchan): Remove hack and switch to posix_memalign.
93 return malloc(size); 93 return malloc(size);
94 } 94 }
95 95
96 96
97 void OS::AlignedFree(void* ptr) { 97 void OS::AlignedFree(void* ptr) {
98 free(ptr); 98 free(ptr);
99 } 99 }
100 100
101 101
102 word OS::ActivationFrameAlignment() { 102 intptr_t OS::ActivationFrameAlignment() {
103 // OS X activation frames must be 16 byte-aligned; see "Mac OS X ABI 103 // OS X activation frames must be 16 byte-aligned; see "Mac OS X ABI
104 // Function Call Guide". 104 // Function Call Guide".
105 return 16; 105 return 16;
106 } 106 }
107 107
108 108
109 word OS::PreferredCodeAlignment() { 109 intptr_t OS::PreferredCodeAlignment() {
110 ASSERT(32 <= OS::kMaxPreferredCodeAlignment); 110 ASSERT(32 <= OS::kMaxPreferredCodeAlignment);
111 return 32; 111 return 32;
112 } 112 }
113 113
114 114
115 uword OS::GetStackSizeLimit() {
116 struct rlimit stack_limit;
117 int retval = getrlimit(RLIMIT_STACK, &stack_limit);
118 ASSERT(retval == 0);
119 if (stack_limit.rlim_cur > INT_MAX) {
120 retval = INT_MAX;
121 } else {
122 retval = stack_limit.rlim_cur;
123 }
124 return retval;
125 }
126
127
128 bool OS::AllowStackFrameIteratorFromAnotherThread() { 115 bool OS::AllowStackFrameIteratorFromAnotherThread() {
129 return false; 116 return false;
130 } 117 }
131 118
132 119
133 int OS::NumberOfAvailableProcessors() { 120 int OS::NumberOfAvailableProcessors() {
134 return sysconf(_SC_NPROCESSORS_ONLN); 121 return sysconf(_SC_NPROCESSORS_ONLN);
135 } 122 }
136 123
137 124
138 void OS::Sleep(int64_t millis) { 125 void OS::Sleep(int64_t millis) {
139 int64_t micros = millis * kMicrosecondsPerMillisecond; 126 int64_t micros = millis * kMicrosecondsPerMillisecond;
140 SleepMicros(micros); 127 SleepMicros(micros);
141 } 128 }
142 129
143 130
144 void OS::SleepMicros(int64_t micros) { 131 void OS::SleepMicros(int64_t micros) {
145 struct timespec req; // requested. 132 struct timespec req; // requested.
146 struct timespec rem; // remainder. 133 struct timespec rem; // remainder.
147 int64_t seconds = micros / kMicrosecondsPerSecond; 134 int64_t seconds = micros / kMicrosecondsPerSecond;
135 if (seconds > kMaxInt32) {
136 // Avoid truncation of overly large sleep values.
137 seconds = kMaxInt32;
138 }
148 micros = micros - seconds * kMicrosecondsPerSecond; 139 micros = micros - seconds * kMicrosecondsPerSecond;
149 int64_t nanos = micros * kNanosecondsPerMicrosecond; 140 int64_t nanos = micros * kNanosecondsPerMicrosecond;
150 req.tv_sec = seconds; 141 req.tv_sec = static_cast<int32_t>(seconds);
151 req.tv_nsec = nanos; 142 req.tv_nsec = static_cast<long>(nanos); // NOLINT (long used in timespec).
152 while (true) { 143 while (true) {
153 int r = nanosleep(&req, &rem); 144 int r = nanosleep(&req, &rem);
154 if (r == 0) { 145 if (r == 0) {
155 break; 146 break;
156 } 147 }
157 // We should only ever see an interrupt error. 148 // We should only ever see an interrupt error.
158 ASSERT(errno == EINTR); 149 ASSERT(errno == EINTR);
159 // Copy remainder into requested and repeat. 150 // Copy remainder into requested and repeat.
160 req = rem; 151 req = rem;
161 } 152 }
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after
277 } 268 }
278 269
279 270
280 void OS::Exit(int code) { 271 void OS::Exit(int code) {
281 exit(code); 272 exit(code);
282 } 273 }
283 274
284 } // namespace dart 275 } // namespace dart
285 276
286 #endif // defined(TARGET_OS_MACOS) 277 #endif // defined(TARGET_OS_MACOS)
OLDNEW
« no previous file with comments | « runtime/vm/os_linux.cc ('k') | runtime/vm/os_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698