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-freebsd.cc

Issue 11421013: v8: fix dragonflybsd build (Closed)
Patch Set: Created 8 years 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
« no previous file with comments | « src/d8.gyp ('k') | tools/gyp/v8.gyp » ('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 25 matching lines...) Expand all
36 #include <sys/types.h> 36 #include <sys/types.h>
37 #include <sys/ucontext.h> 37 #include <sys/ucontext.h>
38 #include <stdlib.h> 38 #include <stdlib.h>
39 39
40 #include <sys/types.h> // mmap & munmap 40 #include <sys/types.h> // mmap & munmap
41 #include <sys/mman.h> // mmap & munmap 41 #include <sys/mman.h> // mmap & munmap
42 #include <sys/stat.h> // open 42 #include <sys/stat.h> // open
43 #include <sys/fcntl.h> // open 43 #include <sys/fcntl.h> // open
44 #include <unistd.h> // getpagesize 44 #include <unistd.h> // getpagesize
45 // If you don't have execinfo.h then you need devel/libexecinfo from ports. 45 // If you don't have execinfo.h then you need devel/libexecinfo from ports.
46 #include <execinfo.h> // backtrace, backtrace_symbols
47 #include <strings.h> // index 46 #include <strings.h> // index
48 #include <errno.h> 47 #include <errno.h>
49 #include <stdarg.h> 48 #include <stdarg.h>
50 #include <limits.h> 49 #include <limits.h>
51 50
51 #if !defined(__DragonFly__)
Sven Panne 2013/01/02 08:06:46 One general comment about such #ifs: Instead of sc
52 #include <execinfo.h> // backtrace, backtrace_symbols
53 #endif
54
52 #undef MAP_TYPE 55 #undef MAP_TYPE
53 56
54 #include "v8.h" 57 #include "v8.h"
55 #include "v8threads.h" 58 #include "v8threads.h"
56 59
57 #include "platform-posix.h" 60 #include "platform-posix.h"
58 #include "platform.h" 61 #include "platform.h"
59 #include "vm-state-inl.h" 62 #include "vm-state-inl.h"
60 63
61 64
(...skipping 227 matching lines...) Expand 10 before | Expand all | Expand 10 after
289 } 292 }
290 close(fd); 293 close(fd);
291 } 294 }
292 295
293 296
294 void OS::SignalCodeMovingGC() { 297 void OS::SignalCodeMovingGC() {
295 } 298 }
296 299
297 300
298 int OS::StackWalk(Vector<OS::StackFrame> frames) { 301 int OS::StackWalk(Vector<OS::StackFrame> frames) {
302 #if defined(__DragonFly__)
303 return 0;
304 #else
299 int frames_size = frames.length(); 305 int frames_size = frames.length();
300 ScopedVector<void*> addresses(frames_size); 306 ScopedVector<void*> addresses(frames_size);
301 307
302 int frames_count = backtrace(addresses.start(), frames_size); 308 int frames_count = backtrace(addresses.start(), frames_size);
303 309
304 char** symbols = backtrace_symbols(addresses.start(), frames_count); 310 char** symbols = backtrace_symbols(addresses.start(), frames_count);
305 if (symbols == NULL) { 311 if (symbols == NULL) {
306 return kStackWalkError; 312 return kStackWalkError;
307 } 313 }
308 314
309 for (int i = 0; i < frames_count; i++) { 315 for (int i = 0; i < frames_count; i++) {
310 frames[i].address = addresses[i]; 316 frames[i].address = addresses[i];
311 // Format a text representation of the frame based on the information 317 // Format a text representation of the frame based on the information
312 // available. 318 // available.
313 SNPrintF(MutableCStrVector(frames[i].text, kStackWalkMaxTextLen), 319 SNPrintF(MutableCStrVector(frames[i].text, kStackWalkMaxTextLen),
314 "%s", 320 "%s",
315 symbols[i]); 321 symbols[i]);
316 // Make sure line termination is in place. 322 // Make sure line termination is in place.
317 frames[i].text[kStackWalkMaxTextLen - 1] = '\0'; 323 frames[i].text[kStackWalkMaxTextLen - 1] = '\0';
318 } 324 }
319 325
320 free(symbols); 326 free(symbols);
321 327
322 return frames_count; 328 return frames_count;
329 #endif
323 } 330 }
324 331
325 332
326 // Constants used for mmap. 333 // Constants used for mmap.
327 static const int kMmapFd = -1; 334 static const int kMmapFd = -1;
328 static const int kMmapFdOffset = 0; 335 static const int kMmapFdOffset = 0;
329 336
330 VirtualMemory::VirtualMemory() : address_(NULL), size_(0) { } 337 VirtualMemory::VirtualMemory() : address_(NULL), size_(0) { }
331 338
332 VirtualMemory::VirtualMemory(size_t size) { 339 VirtualMemory::VirtualMemory(size_t size) {
(...skipping 278 matching lines...) Expand 10 before | Expand all | Expand 10 after
611 void FreeBSDSemaphore::Wait() { 618 void FreeBSDSemaphore::Wait() {
612 while (true) { 619 while (true) {
613 int result = sem_wait(&sem_); 620 int result = sem_wait(&sem_);
614 if (result == 0) return; // Successfully got semaphore. 621 if (result == 0) return; // Successfully got semaphore.
615 CHECK(result == -1 && errno == EINTR); // Signal caused spurious wakeup. 622 CHECK(result == -1 && errno == EINTR); // Signal caused spurious wakeup.
616 } 623 }
617 } 624 }
618 625
619 626
620 bool FreeBSDSemaphore::Wait(int timeout) { 627 bool FreeBSDSemaphore::Wait(int timeout) {
628 #if defined(__DragonFly__)
629 /* DragonFlyBSD lacks sem_timedwait() and there is no good way to emulate it.
630 */
631 if (sem_wait(&sem_)) abort();
632 USE(timeout);
633 return true;
634 #else
621 const long kOneSecondMicros = 1000000; // NOLINT 635 const long kOneSecondMicros = 1000000; // NOLINT
622 636
623 // Split timeout into second and nanosecond parts. 637 // Split timeout into second and nanosecond parts.
624 struct timeval delta; 638 struct timeval delta;
625 delta.tv_usec = timeout % kOneSecondMicros; 639 delta.tv_usec = timeout % kOneSecondMicros;
626 delta.tv_sec = timeout / kOneSecondMicros; 640 delta.tv_sec = timeout / kOneSecondMicros;
627 641
628 struct timeval current_time; 642 struct timeval current_time;
629 // Get the current time. 643 // Get the current time.
630 if (gettimeofday(&current_time, NULL) == -1) { 644 if (gettimeofday(&current_time, NULL) == -1) {
631 return false; 645 return false;
632 } 646 }
633 647
634 // Calculate time for end of timeout. 648 // Calculate time for end of timeout.
635 struct timeval end_time; 649 struct timeval end_time;
636 timeradd(&current_time, &delta, &end_time); 650 timeradd(&current_time, &delta, &end_time);
637 651
638 struct timespec ts; 652 struct timespec ts;
639 TIMEVAL_TO_TIMESPEC(&end_time, &ts); 653 TIMEVAL_TO_TIMESPEC(&end_time, &ts);
640 while (true) { 654 while (true) {
641 int result = sem_timedwait(&sem_, &ts); 655 int result = sem_timedwait(&sem_, &ts);
642 if (result == 0) return true; // Successfully got semaphore. 656 if (result == 0) return true; // Successfully got semaphore.
643 if (result == -1 && errno == ETIMEDOUT) return false; // Timeout. 657 if (result == -1 && errno == ETIMEDOUT) return false; // Timeout.
644 CHECK(result == -1 && errno == EINTR); // Signal caused spurious wakeup. 658 CHECK(result == -1 && errno == EINTR); // Signal caused spurious wakeup.
645 } 659 }
660 #endif
646 } 661 }
647 662
648 663
649 Semaphore* OS::CreateSemaphore(int count) { 664 Semaphore* OS::CreateSemaphore(int count) {
650 return new FreeBSDSemaphore(count); 665 return new FreeBSDSemaphore(count);
651 } 666 }
652 667
653 668
654 static pthread_t GetThreadID() { 669 static pthread_t GetThreadID() {
655 pthread_t thread_id = pthread_self(); 670 pthread_t thread_id = pthread_self();
(...skipping 256 matching lines...) Expand 10 before | Expand all | Expand 10 after
912 927
913 void Sampler::StartSampling() { 928 void Sampler::StartSampling() {
914 } 929 }
915 930
916 931
917 void Sampler::StopSampling() { 932 void Sampler::StopSampling() {
918 } 933 }
919 934
920 935
921 } } // namespace v8::internal 936 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/d8.gyp ('k') | tools/gyp/v8.gyp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698