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

Side by Side Diff: vm/os_macos.cc

Issue 10703150: Don't create a Bigint object first for every integer while parsing the sources, instead first check… (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/runtime/
Patch Set: Created 8 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
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/os.h" 5 #include "vm/os.h"
6 6
7 #include <errno.h> 7 #include <errno.h>
8 #include <limits.h> 8 #include <limits.h>
9 #include <mach/mach.h> 9 #include <mach/mach.h>
10 #include <mach/clock.h> 10 #include <mach/clock.h>
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after
129 129
130 int OS::VSNPrint(char* str, size_t size, const char* format, va_list args) { 130 int OS::VSNPrint(char* str, size_t size, const char* format, va_list args) {
131 int retval = vsnprintf(str, size, format, args); 131 int retval = vsnprintf(str, size, format, args);
132 if (retval < 0) { 132 if (retval < 0) {
133 FATAL1("Fatal error in OS::VSNPrint with format '%s'", format); 133 FATAL1("Fatal error in OS::VSNPrint with format '%s'", format);
134 } 134 }
135 return retval; 135 return retval;
136 } 136 }
137 137
138 138
139 bool OS::Strtoll(const char* str, int64_t* value) {
140 ASSERT(str != NULL && strlen(str) > 0 && value != NULL);
141 bool negative_value = false;
142 int32_t base = 10;
143 if (str[0] == '-') {
144 negative_value = true;
145 str += 1;
146 }
147 if ((strlen(str) > 2) && (str[0] == '0') &&
148 (str[1] == 'x' || str[1] == 'X')) {
149 base = 16;
150 }
151 errno = 0;
152 *value = strtoll(str, NULL, base);
153 if (errno == 0) {
154 if (negative_value) {
155 *value = -(*value);
156 }
157 return true;
158 }
159 return false;
160 }
161
162
139 void OS::PrintErr(const char* format, ...) { 163 void OS::PrintErr(const char* format, ...) {
140 va_list args; 164 va_list args;
141 va_start(args, format); 165 va_start(args, format);
142 VFPrint(stderr, format, args); 166 VFPrint(stderr, format, args);
143 va_end(args); 167 va_end(args);
144 } 168 }
145 169
146 170
147 void OS::InitOnce() { 171 void OS::InitOnce() {
148 // TODO(5411554): For now we check that initonce is called only once, 172 // TODO(5411554): For now we check that initonce is called only once,
(...skipping 12 matching lines...) Expand all
161 void OS::Abort() { 185 void OS::Abort() {
162 abort(); 186 abort();
163 } 187 }
164 188
165 189
166 void OS::Exit(int code) { 190 void OS::Exit(int code) {
167 exit(code); 191 exit(code);
168 } 192 }
169 193
170 } // namespace dart 194 } // namespace dart
OLDNEW
« vm/os_linux.cc ('K') | « vm/os_linux.cc ('k') | vm/os_win.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698