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

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

Issue 20734002: Implement correct OS and CC detection. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Reverted changes to atomicops*.h Created 7 years, 4 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-posix.h » ('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 // Redistribution and use in source and binary forms, with or without 2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are 3 // modification, are permitted provided that the following conditions are
4 // met: 4 // met:
5 // 5 //
6 // * Redistributions of source code must retain the above copyright 6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer. 7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above 8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following 9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided 10 // disclaimer in the documentation and/or other materials provided
(...skipping 10 matching lines...) Expand all
21 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 21 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
22 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 22 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 23 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 27
28 // Platform specific code for Linux goes here. For the POSIX comaptible parts 28 // Platform specific code for Linux goes here. For the POSIX comaptible parts
29 // the implementation is in platform-posix.cc. 29 // the implementation is in platform-posix.cc.
30 30
31 #include "platform.h"
32
31 #include <pthread.h> 33 #include <pthread.h>
32 #include <semaphore.h> 34 #include <semaphore.h>
33 #include <signal.h> 35 #include <signal.h>
34 #include <sys/prctl.h> 36 #include <sys/prctl.h>
35 #include <sys/time.h> 37 #include <sys/time.h>
36 #include <sys/resource.h> 38 #include <sys/resource.h>
37 #include <sys/syscall.h> 39 #include <sys/syscall.h>
38 #include <sys/types.h> 40 #include <sys/types.h>
39 #include <stdlib.h> 41 #include <stdlib.h>
40 42
41 #if defined(__GLIBC__) && !defined(__UCLIBC__) 43 #if defined(__GLIBC__) && !defined(__UCLIBC__)
42 #include <execinfo.h> 44 #include <execinfo.h>
43 #include <cxxabi.h> 45 #include <cxxabi.h>
44 #endif 46 #endif
45 47
46 // Ubuntu Dapper requires memory pages to be marked as 48 // Ubuntu Dapper requires memory pages to be marked as
47 // executable. Otherwise, OS raises an exception when executing code 49 // executable. Otherwise, OS raises an exception when executing code
48 // in that page. 50 // in that page.
49 #include <sys/types.h> // mmap & munmap 51 #include <sys/types.h> // mmap & munmap
50 #include <sys/mman.h> // mmap & munmap 52 #include <sys/mman.h> // mmap & munmap
51 #include <sys/stat.h> // open 53 #include <sys/stat.h> // open
52 #include <fcntl.h> // open 54 #include <fcntl.h> // open
53 #include <unistd.h> // sysconf 55 #include <unistd.h> // sysconf
54 #include <strings.h> // index 56 #include <strings.h> // index
55 #include <errno.h> 57 #include <errno.h>
56 #include <stdarg.h> 58 #include <stdarg.h>
57 59
58 // GLibc on ARM defines mcontext_t has a typedef for 'struct sigcontext'. 60 // GLibc on ARM defines mcontext_t has a typedef for 'struct sigcontext'.
59 // Old versions of the C library <signal.h> didn't define the type. 61 // Old versions of the C library <signal.h> didn't define the type.
60 #if defined(__ANDROID__) && !defined(__BIONIC_HAVE_UCONTEXT_T) && \ 62 #if V8_OS_ANDROID && !defined(__BIONIC_HAVE_UCONTEXT_T) && \
61 defined(__arm__) && !defined(__BIONIC_HAVE_STRUCT_SIGCONTEXT) 63 V8_HOST_ARCH_ARM && !defined(__BIONIC_HAVE_STRUCT_SIGCONTEXT)
62 #include <asm/sigcontext.h> 64 #include <asm/sigcontext.h>
63 #endif 65 #endif
64 66
65 #undef MAP_TYPE 67 #undef MAP_TYPE
66 68
67 #include "v8.h" 69 #include "v8.h"
68 70
69 #include "platform-posix.h" 71 #include "platform-posix.h"
70 #include "platform.h"
71 #include "v8threads.h" 72 #include "v8threads.h"
72 #include "vm-state-inl.h" 73 #include "vm-state-inl.h"
73 74
74 75
75 namespace v8 { 76 namespace v8 {
76 namespace internal { 77 namespace internal {
77 78
78 79
79 static Mutex* limit_mutex = NULL; 80 static Mutex* limit_mutex = NULL;
80 81
81 82
82 #ifdef __arm__ 83 #if V8_HOST_ARCH_ARM
83 static bool CPUInfoContainsString(const char * search_string) { 84 static bool CPUInfoContainsString(const char * search_string) {
84 const char* file_name = "/proc/cpuinfo"; 85 const char* file_name = "/proc/cpuinfo";
85 // This is written as a straight shot one pass parser 86 // This is written as a straight shot one pass parser
86 // and not using STL string and ifstream because, 87 // and not using STL string and ifstream because,
87 // on Linux, it's reading from a (non-mmap-able) 88 // on Linux, it's reading from a (non-mmap-able)
88 // character special device. 89 // character special device.
89 FILE* f = NULL; 90 FILE* f = NULL;
90 const char* what = search_string; 91 const char* what = search_string;
91 92
92 if (NULL == (f = fopen(file_name, "r"))) { 93 if (NULL == (f = fopen(file_name, "r"))) {
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after
215 216
216 217
217 bool OS::ArmUsingHardFloat() { 218 bool OS::ArmUsingHardFloat() {
218 // GCC versions 4.6 and above define __ARM_PCS or __ARM_PCS_VFP to specify 219 // GCC versions 4.6 and above define __ARM_PCS or __ARM_PCS_VFP to specify
219 // the Floating Point ABI used (PCS stands for Procedure Call Standard). 220 // the Floating Point ABI used (PCS stands for Procedure Call Standard).
220 // We use these as well as a couple of other defines to statically determine 221 // We use these as well as a couple of other defines to statically determine
221 // what FP ABI used. 222 // what FP ABI used.
222 // GCC versions 4.4 and below don't support hard-fp. 223 // GCC versions 4.4 and below don't support hard-fp.
223 // GCC versions 4.5 may support hard-fp without defining __ARM_PCS or 224 // GCC versions 4.5 may support hard-fp without defining __ARM_PCS or
224 // __ARM_PCS_VFP. 225 // __ARM_PCS_VFP.
225
226 #define GCC_VERSION (__GNUC__ * 10000 \
227 + __GNUC_MINOR__ * 100 \
228 + __GNUC_PATCHLEVEL__)
229 #if GCC_VERSION >= 40600
230 #if defined(__ARM_PCS_VFP) 226 #if defined(__ARM_PCS_VFP)
231 return true; 227 return true;
232 #else 228 #elif V8_CC_GNU && (V8_GNUC_PREREQ(4, 6) || !V8_GNUC_PREREQ(4, 5))
233 return false; 229 return false;
234 #endif
235
236 #elif GCC_VERSION < 40500
237 return false;
238
239 #else
240 #if defined(__ARM_PCS_VFP)
241 return true;
242 #elif defined(__ARM_PCS) || defined(__SOFTFP) || !defined(__VFP_FP__) 230 #elif defined(__ARM_PCS) || defined(__SOFTFP) || !defined(__VFP_FP__)
243 return false; 231 return false;
244 #else 232 #else
245 #error "Your version of GCC does not report the FP ABI compiled for." \ 233 #error "Your version of GCC does not report the FP ABI compiled for." \
246 "Please report it on this issue" \ 234 "Please report it on this issue" \
247 "http://code.google.com/p/v8/issues/detail?id=2140" 235 "http://code.google.com/p/v8/issues/detail?id=2140"
248
249 #endif 236 #endif
250 #endif
251 #undef GCC_VERSION
252 } 237 }
253 238
254 #endif // def __arm__ 239 #endif // V8_HOST_ARCH_ARM
255 240
256 241
257 #ifdef __mips__ 242 #if V8_HOST_ARCH_MIPS
258 bool OS::MipsCpuHasFeature(CpuFeature feature) { 243 bool OS::MipsCpuHasFeature(CpuFeature feature) {
259 const char* search_string = NULL; 244 const char* search_string = NULL;
260 const char* file_name = "/proc/cpuinfo"; 245 const char* file_name = "/proc/cpuinfo";
261 // Simple detection of FPU at runtime for Linux. 246 // Simple detection of FPU at runtime for Linux.
262 // It is based on /proc/cpuinfo, which reveals hardware configuration 247 // It is based on /proc/cpuinfo, which reveals hardware configuration
263 // to user-space applications. According to MIPS (early 2010), no similar 248 // to user-space applications. According to MIPS (early 2010), no similar
264 // facility is universally available on the MIPS architectures, 249 // facility is universally available on the MIPS architectures,
265 // so it's up to individual OSes to provide such. 250 // so it's up to individual OSes to provide such.
266 // 251 //
267 // This is written as a straight shot one pass parser 252 // This is written as a straight shot one pass parser
(...skipping 30 matching lines...) Expand all
298 } else { 283 } else {
299 what = search_string; 284 what = search_string;
300 } 285 }
301 } 286 }
302 } 287 }
303 fclose(f); 288 fclose(f);
304 289
305 // Did not find string in the proc file. 290 // Did not find string in the proc file.
306 return false; 291 return false;
307 } 292 }
308 #endif // def __mips__ 293 #endif // V8_HOST_ARCH_MIPS
309 294
310 295
311 const char* OS::LocalTimezone(double time) { 296 const char* OS::LocalTimezone(double time) {
312 if (std::isnan(time)) return ""; 297 if (std::isnan(time)) return "";
313 time_t tv = static_cast<time_t>(floor(time/msPerSecond)); 298 time_t tv = static_cast<time_t>(floor(time/msPerSecond));
314 struct tm* t = localtime(&tv); 299 struct tm* t = localtime(&tv);
315 if (NULL == t) return ""; 300 if (NULL == t) return "";
316 return t->tm_zone; 301 return t->tm_zone;
317 } 302 }
318 303
(...skipping 441 matching lines...) Expand 10 before | Expand all | Expand 10 after
760 limit_mutex = CreateMutex(); 745 limit_mutex = CreateMutex();
761 } 746 }
762 747
763 748
764 void OS::TearDown() { 749 void OS::TearDown() {
765 delete limit_mutex; 750 delete limit_mutex;
766 } 751 }
767 752
768 753
769 } } // namespace v8::internal 754 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/platform.h ('k') | src/platform-posix.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698