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

Side by Side Diff: src/platform-posix.cc

Issue 328343003: Remove dependency on Vector from platform files (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: updates Created 6 years, 6 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 | « src/platform.h ('k') | src/platform-solaris.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 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 // Platform-specific code for POSIX goes here. This is not a platform on its 5 // Platform-specific code for POSIX goes here. This is not a platform on its
6 // own, but contains the parts which are the same across the POSIX platforms 6 // own, but contains the parts which are the same across the POSIX platforms
7 // Linux, MacOS, FreeBSD, OpenBSD, NetBSD and QNX. 7 // Linux, MacOS, FreeBSD, OpenBSD, NetBSD and QNX.
8 8
9 #include <dlfcn.h> 9 #include <dlfcn.h>
10 #include <pthread.h> 10 #include <pthread.h>
(...skipping 404 matching lines...) Expand 10 before | Expand all | Expand 10 after
415 415
416 void OS::VPrintError(const char* format, va_list args) { 416 void OS::VPrintError(const char* format, va_list args) {
417 #if defined(ANDROID) && !defined(V8_ANDROID_LOG_STDOUT) 417 #if defined(ANDROID) && !defined(V8_ANDROID_LOG_STDOUT)
418 __android_log_vprint(ANDROID_LOG_ERROR, LOG_TAG, format, args); 418 __android_log_vprint(ANDROID_LOG_ERROR, LOG_TAG, format, args);
419 #else 419 #else
420 vfprintf(stderr, format, args); 420 vfprintf(stderr, format, args);
421 #endif 421 #endif
422 } 422 }
423 423
424 424
425 int OS::SNPrintF(Vector<char> str, const char* format, ...) { 425 int OS::SNPrintF(char* str, int length, const char* format, ...) {
426 va_list args; 426 va_list args;
427 va_start(args, format); 427 va_start(args, format);
428 int result = VSNPrintF(str, format, args); 428 int result = VSNPrintF(str, length, format, args);
429 va_end(args); 429 va_end(args);
430 return result; 430 return result;
431 } 431 }
432 432
433 433
434 int OS::VSNPrintF(Vector<char> str, 434 int OS::VSNPrintF(char* str,
435 int length,
435 const char* format, 436 const char* format,
436 va_list args) { 437 va_list args) {
437 int n = vsnprintf(str.start(), str.length(), format, args); 438 int n = vsnprintf(str, length, format, args);
438 if (n < 0 || n >= str.length()) { 439 if (n < 0 || n >= length) {
439 // If the length is zero, the assignment fails. 440 // If the length is zero, the assignment fails.
440 if (str.length() > 0) 441 if (length > 0)
441 str[str.length() - 1] = '\0'; 442 str[length - 1] = '\0';
442 return -1; 443 return -1;
443 } else { 444 } else {
444 return n; 445 return n;
445 } 446 }
446 } 447 }
447 448
448 449
449 // ---------------------------------------------------------------------------- 450 // ----------------------------------------------------------------------------
450 // POSIX string support. 451 // POSIX string support.
451 // 452 //
452 453
453 char* OS::StrChr(char* str, int c) { 454 char* OS::StrChr(char* str, int c) {
454 return strchr(str, c); 455 return strchr(str, c);
455 } 456 }
456 457
457 458
458 void OS::StrNCpy(Vector<char> dest, const char* src, size_t n) { 459 void OS::StrNCpy(char* dest, int length, const char* src, size_t n) {
459 strncpy(dest.start(), src, n); 460 strncpy(dest, src, n);
460 } 461 }
461 462
462 463
463 // ---------------------------------------------------------------------------- 464 // ----------------------------------------------------------------------------
464 // POSIX thread support. 465 // POSIX thread support.
465 // 466 //
466 467
467 class Thread::PlatformData : public Malloced { 468 class Thread::PlatformData : public Malloced {
468 public: 469 public:
469 PlatformData() : thread_(kNoThread) {} 470 PlatformData() : thread_(kNoThread) {}
(...skipping 219 matching lines...) Expand 10 before | Expand all | Expand 10 after
689 690
690 void Thread::SetThreadLocal(LocalStorageKey key, void* value) { 691 void Thread::SetThreadLocal(LocalStorageKey key, void* value) {
691 pthread_key_t pthread_key = LocalKeyToPthreadKey(key); 692 pthread_key_t pthread_key = LocalKeyToPthreadKey(key);
692 int result = pthread_setspecific(pthread_key, value); 693 int result = pthread_setspecific(pthread_key, value);
693 ASSERT_EQ(0, result); 694 ASSERT_EQ(0, result);
694 USE(result); 695 USE(result);
695 } 696 }
696 697
697 698
698 } } // namespace v8::internal 699 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/platform.h ('k') | src/platform-solaris.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698