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

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

Issue 297303004: Revert 21502 - "Move OS::MemCopy and OS::MemMove out of platform to utils" (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 6 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 | Annotate | Revision Log
« no previous file with comments | « src/platform.h ('k') | src/platform-win32.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 429 matching lines...) Expand 10 before | Expand all | Expand 10 after
440 // If the length is zero, the assignment fails. 440 // If the length is zero, the assignment fails.
441 if (str.length() > 0) 441 if (str.length() > 0)
442 str[str.length() - 1] = '\0'; 442 str[str.length() - 1] = '\0';
443 return -1; 443 return -1;
444 } else { 444 } else {
445 return n; 445 return n;
446 } 446 }
447 } 447 }
448 448
449 449
450 #if V8_TARGET_ARCH_IA32 || V8_TARGET_ARCH_X87
451 static void MemMoveWrapper(void* dest, const void* src, size_t size) {
452 memmove(dest, src, size);
453 }
454
455
456 // Initialize to library version so we can call this at any time during startup.
457 static OS::MemMoveFunction memmove_function = &MemMoveWrapper;
458
459 // Defined in codegen-ia32.cc.
460 OS::MemMoveFunction CreateMemMoveFunction();
461
462 // Copy memory area. No restrictions.
463 void OS::MemMove(void* dest, const void* src, size_t size) {
464 if (size == 0) return;
465 // Note: here we rely on dependent reads being ordered. This is true
466 // on all architectures we currently support.
467 (*memmove_function)(dest, src, size);
468 }
469
470 #elif defined(V8_HOST_ARCH_ARM)
471 void OS::MemCopyUint16Uint8Wrapper(uint16_t* dest,
472 const uint8_t* src,
473 size_t chars) {
474 uint16_t *limit = dest + chars;
475 while (dest < limit) {
476 *dest++ = static_cast<uint16_t>(*src++);
477 }
478 }
479
480
481 OS::MemCopyUint8Function OS::memcopy_uint8_function = &OS::MemCopyUint8Wrapper;
482 OS::MemCopyUint16Uint8Function OS::memcopy_uint16_uint8_function =
483 &OS::MemCopyUint16Uint8Wrapper;
484 // Defined in codegen-arm.cc.
485 OS::MemCopyUint8Function CreateMemCopyUint8Function(
486 OS::MemCopyUint8Function stub);
487 OS::MemCopyUint16Uint8Function CreateMemCopyUint16Uint8Function(
488 OS::MemCopyUint16Uint8Function stub);
489
490 #elif defined(V8_HOST_ARCH_MIPS)
491 OS::MemCopyUint8Function OS::memcopy_uint8_function = &OS::MemCopyUint8Wrapper;
492 // Defined in codegen-mips.cc.
493 OS::MemCopyUint8Function CreateMemCopyUint8Function(
494 OS::MemCopyUint8Function stub);
495 #endif
496
497
498 void OS::PostSetUp() {
499 #if V8_TARGET_ARCH_IA32 || V8_TARGET_ARCH_X87
500 OS::MemMoveFunction generated_memmove = CreateMemMoveFunction();
501 if (generated_memmove != NULL) {
502 memmove_function = generated_memmove;
503 }
504 #elif defined(V8_HOST_ARCH_ARM)
505 OS::memcopy_uint8_function =
506 CreateMemCopyUint8Function(&OS::MemCopyUint8Wrapper);
507 OS::memcopy_uint16_uint8_function =
508 CreateMemCopyUint16Uint8Function(&OS::MemCopyUint16Uint8Wrapper);
509 #elif defined(V8_HOST_ARCH_MIPS)
510 OS::memcopy_uint8_function =
511 CreateMemCopyUint8Function(&OS::MemCopyUint8Wrapper);
512 #endif
513 }
514
515
450 // ---------------------------------------------------------------------------- 516 // ----------------------------------------------------------------------------
451 // POSIX string support. 517 // POSIX string support.
452 // 518 //
453 519
454 char* OS::StrChr(char* str, int c) { 520 char* OS::StrChr(char* str, int c) {
455 return strchr(str, c); 521 return strchr(str, c);
456 } 522 }
457 523
458 524
459 void OS::StrNCpy(Vector<char> dest, const char* src, size_t n) { 525 void OS::StrNCpy(Vector<char> dest, const char* src, size_t n) {
(...skipping 230 matching lines...) Expand 10 before | Expand all | Expand 10 after
690 756
691 void Thread::SetThreadLocal(LocalStorageKey key, void* value) { 757 void Thread::SetThreadLocal(LocalStorageKey key, void* value) {
692 pthread_key_t pthread_key = LocalKeyToPthreadKey(key); 758 pthread_key_t pthread_key = LocalKeyToPthreadKey(key);
693 int result = pthread_setspecific(pthread_key, value); 759 int result = pthread_setspecific(pthread_key, value);
694 ASSERT_EQ(0, result); 760 ASSERT_EQ(0, result);
695 USE(result); 761 USE(result);
696 } 762 }
697 763
698 764
699 } } // namespace v8::internal 765 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/platform.h ('k') | src/platform-win32.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698