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

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

Issue 1989513002: strnlen is not always available. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 4 years, 7 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
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 261 matching lines...) Expand 10 before | Expand all | Expand 10 after
272 return NULL; 272 return NULL;
273 } 273 }
274 result[len] = '\0'; 274 result[len] = '\0';
275 return reinterpret_cast<char*>(memmove(result, s, len)); 275 return reinterpret_cast<char*>(memmove(result, s, len));
276 #else // !defined(__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__) || ... 276 #else // !defined(__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__) || ...
277 return strndup(s, n); 277 return strndup(s, n);
278 #endif // !defined(__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__) || ... 278 #endif // !defined(__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__) || ...
279 } 279 }
280 280
281 281
282 intptr_t OS::StrNLen(const char* s, intptr_t n) {
283 // strnlen has only been added to Mac OS X in 10.7. We are supplying
284 // our own copy here if needed.
285 #if !defined(__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__) || \
286 __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ <= 1060
287 intptr_t len = 0;
288 while ((len <= n) && (*s != '\0')) {
289 s++;
290 len++;
291 }
292 return len;
293 #else // !defined(__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__) || ...
294 return strnlen(s, n);
295 #endif // !defined(__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__) || ...
296 }
297
298
282 void OS::Print(const char* format, ...) { 299 void OS::Print(const char* format, ...) {
283 #if TARGET_OS_IOS 300 #if TARGET_OS_IOS
284 va_list args; 301 va_list args;
285 va_start(args, format); 302 va_start(args, format);
286 vsyslog(LOG_INFO, format, args); 303 vsyslog(LOG_INFO, format, args);
287 va_end(args); 304 va_end(args);
288 #else 305 #else
289 va_list args; 306 va_list args;
290 va_start(args, format); 307 va_start(args, format);
291 VFPrint(stdout, format, args); 308 VFPrint(stdout, format, args);
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after
410 } 427 }
411 428
412 429
413 void OS::Exit(int code) { 430 void OS::Exit(int code) {
414 exit(code); 431 exit(code);
415 } 432 }
416 433
417 } // namespace dart 434 } // namespace dart
418 435
419 #endif // defined(TARGET_OS_MACOS) 436 #endif // defined(TARGET_OS_MACOS)
OLDNEW
« no previous file with comments | « runtime/vm/os_linux.cc ('k') | runtime/vm/os_win.cc » ('j') | runtime/vm/os_win.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698