| OLD | NEW |
| 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 <time.h> | 7 #include <time.h> |
| 8 | 8 |
| 9 #include "platform/assert.h" | 9 #include "platform/assert.h" |
| 10 | 10 |
| (...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 136 | 136 |
| 137 int OS::SNPrint(char* str, size_t size, const char* format, ...) { | 137 int OS::SNPrint(char* str, size_t size, const char* format, ...) { |
| 138 va_list args; | 138 va_list args; |
| 139 va_start(args, format); | 139 va_start(args, format); |
| 140 int retval = VSNPrint(str, size, format, args); | 140 int retval = VSNPrint(str, size, format, args); |
| 141 va_end(args); | 141 va_end(args); |
| 142 return retval; | 142 return retval; |
| 143 } | 143 } |
| 144 | 144 |
| 145 | 145 |
| 146 // TODO(asiva): Consider moving this to "globals.h". | |
| 147 #ifndef va_copy | |
| 148 #define va_copy(dst, src) (memmove(&(dst), &(src), sizeof(dst))) | |
| 149 #endif /* va_copy */ | |
| 150 | |
| 151 | |
| 152 int OS::VSNPrint(char* str, size_t size, const char* format, va_list args) { | 146 int OS::VSNPrint(char* str, size_t size, const char* format, va_list args) { |
| 153 if (str == NULL || size == 0) { | 147 if (str == NULL || size == 0) { |
| 154 return _vscprintf(format, args); | 148 return _vscprintf(format, args); |
| 155 } | 149 } |
| 156 va_list args_copy; | 150 va_list args_copy; |
| 157 va_copy(args_copy, args); | 151 va_copy(args_copy, args); |
| 158 int written =_vsnprintf(str, size, format, args_copy); | 152 int written =_vsnprintf(str, size, format, args_copy); |
| 159 va_end(args_copy); | 153 va_end(args_copy); |
| 160 if (written < 0) { | 154 if (written < 0) { |
| 161 // _vsnprintf returns -1 if the number of characters to be written is | 155 // _vsnprintf returns -1 if the number of characters to be written is |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 202 void OS::Abort() { | 196 void OS::Abort() { |
| 203 abort(); | 197 abort(); |
| 204 } | 198 } |
| 205 | 199 |
| 206 | 200 |
| 207 void OS::Exit(int code) { | 201 void OS::Exit(int code) { |
| 208 exit(code); | 202 exit(code); |
| 209 } | 203 } |
| 210 | 204 |
| 211 } // namespace dart | 205 } // namespace dart |
| OLD | NEW |