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

Side by Side Diff: src/base/platform/platform.h

Issue 358363002: Move platform abstraction to base library (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: updates Created 6 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 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 // This module contains the platform-specific code. This make the rest of the 5 // This module contains the platform-specific code. This make the rest of the
6 // code less dependent on operating system, compilers and runtime libraries. 6 // code less dependent on operating system, compilers and runtime libraries.
7 // This module does specifically not deal with differences between different 7 // This module does specifically not deal with differences between different
8 // processor architecture. 8 // processor architecture.
9 // The platform classes have the same definition for all platforms. The 9 // The platform classes have the same definition for all platforms. The
10 // implementation for a particular platform is put in platform_<os>.cc. 10 // implementation for a particular platform is put in platform_<os>.cc.
11 // The build system then uses the implementation for the target platform. 11 // The build system then uses the implementation for the target platform.
12 // 12 //
13 // This design has been chosen because it is simple and fast. Alternatively, 13 // This design has been chosen because it is simple and fast. Alternatively,
14 // the platform dependent classes could have been implemented using abstract 14 // the platform dependent classes could have been implemented using abstract
15 // superclasses with virtual methods and having specializations for each 15 // superclasses with virtual methods and having specializations for each
16 // platform. This design was rejected because it was more complicated and 16 // platform. This design was rejected because it was more complicated and
17 // slower. It would require factory methods for selecting the right 17 // slower. It would require factory methods for selecting the right
18 // implementation and the overhead of virtual methods for performance 18 // implementation and the overhead of virtual methods for performance
19 // sensitive like mutex locking/unlocking. 19 // sensitive like mutex locking/unlocking.
20 20
21 #ifndef V8_PLATFORM_H_ 21 #ifndef V8_BASE_PLATFORM_PLATFORM_H_
22 #define V8_PLATFORM_H_ 22 #define V8_BASE_PLATFORM_PLATFORM_H_
23 23
24 #include <stdarg.h> 24 #include <stdarg.h>
25 #include <string> 25 #include <string>
26 #include <vector> 26 #include <vector>
27 27
28 #include "src/base/build_config.h" 28 #include "src/base/build_config.h"
29 #include "src/platform/mutex.h" 29 #include "src/base/platform/mutex.h"
30 #include "src/platform/semaphore.h" 30 #include "src/base/platform/semaphore.h"
31 31
32 #ifdef __sun 32 #ifdef __sun
33 # ifndef signbit 33 # ifndef signbit
34 namespace std { 34 namespace std {
35 int signbit(double x); 35 int signbit(double x);
36 } 36 }
37 # endif 37 # endif
38 #endif 38 #endif
39 39
40 #if V8_OS_QNX 40 #if V8_OS_QNX
41 #include "src/qnx-math.h" 41 #include "src/base/qnx-math.h"
42 #endif 42 #endif
43 43
44 // Microsoft Visual C++ specific stuff. 44 // Microsoft Visual C++ specific stuff.
45 #if V8_LIBC_MSVCRT 45 #if V8_LIBC_MSVCRT
46 46
47 #include "src/base/win32-headers.h" 47 #include "src/base/win32-headers.h"
48 #include "src/win32-math.h" 48 #include "src/base/win32-math.h"
49 49
50 int strncasecmp(const char* s1, const char* s2, int n); 50 int strncasecmp(const char* s1, const char* s2, int n);
51 51
52 // Visual C++ 2013 and higher implement this function. 52 // Visual C++ 2013 and higher implement this function.
53 #if (_MSC_VER < 1800) 53 #if (_MSC_VER < 1800)
54 inline int lrint(double flt) { 54 inline int lrint(double flt) {
55 int intgr; 55 int intgr;
56 #if V8_TARGET_ARCH_IA32 || V8_TARGET_ARCH_X87 56 #if V8_TARGET_ARCH_IA32 || V8_TARGET_ARCH_X87
57 __asm { 57 __asm {
58 fld flt 58 fld flt
59 fistp intgr 59 fistp intgr
60 }; 60 };
61 #else 61 #else
62 intgr = static_cast<int>(flt + 0.5); 62 intgr = static_cast<int>(flt + 0.5);
63 if ((intgr & 1) != 0 && intgr - flt == 0.5) { 63 if ((intgr & 1) != 0 && intgr - flt == 0.5) {
64 // If the number is halfway between two integers, round to the even one. 64 // If the number is halfway between two integers, round to the even one.
65 intgr--; 65 intgr--;
66 } 66 }
67 #endif 67 #endif
68 return intgr; 68 return intgr;
69 } 69 }
70 #endif // _MSC_VER < 1800 70 #endif // _MSC_VER < 1800
71 71
72 #endif // V8_LIBC_MSVCRT 72 #endif // V8_LIBC_MSVCRT
73 73
74 namespace v8 { 74 namespace v8 {
75 namespace internal { 75 namespace base {
76 76
77 // ---------------------------------------------------------------------------- 77 // ----------------------------------------------------------------------------
78 // Fast TLS support 78 // Fast TLS support
79 79
80 #ifndef V8_NO_FAST_TLS 80 #ifndef V8_NO_FAST_TLS
81 81
82 #if defined(_MSC_VER) && (V8_HOST_ARCH_IA32) 82 #if defined(_MSC_VER) && (V8_HOST_ARCH_IA32)
83 83
84 #define V8_FAST_TLS_SUPPORTED 1 84 #define V8_FAST_TLS_SUPPORTED 1
85 85
(...skipping 289 matching lines...) Expand 10 before | Expand all | Expand 10 after
375 void* address = address_; 375 void* address = address_;
376 size_t size = size_; 376 size_t size = size_;
377 Reset(); 377 Reset();
378 bool result = ReleaseRegion(address, size); 378 bool result = ReleaseRegion(address, size);
379 USE(result); 379 USE(result);
380 ASSERT(result); 380 ASSERT(result);
381 } 381 }
382 382
383 // Assign control of the reserved region to a different VirtualMemory object. 383 // Assign control of the reserved region to a different VirtualMemory object.
384 // The old object is no longer functional (IsReserved() returns false). 384 // The old object is no longer functional (IsReserved() returns false).
385 void TakeControl(VirtualMemory* from) { 385 void TakeControl(base::VirtualMemory* from) {
386 ASSERT(!IsReserved()); 386 ASSERT(!IsReserved());
387 address_ = from->address_; 387 address_ = from->address_;
388 size_ = from->size_; 388 size_ = from->size_;
389 from->Reset(); 389 from->Reset();
390 } 390 }
391 391
392 static void* ReserveRegion(size_t size); 392 static void* ReserveRegion(size_t size);
393 393
394 static bool CommitRegion(void* base, size_t size, bool is_executable); 394 static bool CommitRegion(void* base, size_t size, bool is_executable);
395 395
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after
512 512
513 PlatformData* data_; 513 PlatformData* data_;
514 514
515 char name_[kMaxThreadNameLength]; 515 char name_[kMaxThreadNameLength];
516 int stack_size_; 516 int stack_size_;
517 Semaphore* start_semaphore_; 517 Semaphore* start_semaphore_;
518 518
519 DISALLOW_COPY_AND_ASSIGN(Thread); 519 DISALLOW_COPY_AND_ASSIGN(Thread);
520 }; 520 };
521 521
522 } } // namespace v8::internal 522 } } // namespace v8::base
523 523
524 #endif // V8_PLATFORM_H_ 524 #endif // V8_BASE_PLATFORM_PLATFORM_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698