| OLD | NEW |
| 1 // Copyright (c) 2014, the Dartino project authors. Please see the AUTHORS file | 1 // Copyright (c) 2014, the Dartino project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE.md file. | 3 // BSD-style license that can be found in the LICENSE.md file. |
| 4 | 4 |
| 5 #if defined(FLETCH_TARGET_OS_POSIX) | 5 #if defined(DARTINO_TARGET_OS_POSIX) |
| 6 | 6 |
| 7 // We do not include platform_posix.h on purpose. That file | 7 // We do not include platform_posix.h on purpose. That file |
| 8 // should never be directly inported. platform.h is always | 8 // should never be directly inported. platform.h is always |
| 9 // the platform header to include. | 9 // the platform header to include. |
| 10 #include "src/shared/platform.h" // NOLINT | 10 #include "src/shared/platform.h" // NOLINT |
| 11 | 11 |
| 12 #include <errno.h> | 12 #include <errno.h> |
| 13 #include <pthread.h> | 13 #include <pthread.h> |
| 14 #include <semaphore.h> | 14 #include <semaphore.h> |
| 15 #include <sys/types.h> // mmap & munmap | 15 #include <sys/types.h> // mmap & munmap |
| 16 #include <sys/mman.h> // mmap & munmap | 16 #include <sys/mman.h> // mmap & munmap |
| 17 #include <sys/time.h> | 17 #include <sys/time.h> |
| 18 #include <time.h> | 18 #include <time.h> |
| 19 #include <signal.h> | 19 #include <signal.h> |
| 20 #include <unistd.h> | 20 #include <unistd.h> |
| 21 #include <stdio.h> | 21 #include <stdio.h> |
| 22 #include <fcntl.h> | 22 #include <fcntl.h> |
| 23 #include <stdarg.h> | 23 #include <stdarg.h> |
| 24 | 24 |
| 25 #include "src/shared/utils.h" | 25 #include "src/shared/utils.h" |
| 26 | 26 |
| 27 namespace fletch { | 27 namespace dartino { |
| 28 | 28 |
| 29 static uint64 time_launch; | 29 static uint64 time_launch; |
| 30 | 30 |
| 31 void Platform::Setup() { | 31 void Platform::Setup() { |
| 32 time_launch = GetMicroseconds(); | 32 time_launch = GetMicroseconds(); |
| 33 | 33 |
| 34 // Make functions return EPIPE instead of getting SIGPIPE signal. | 34 // Make functions return EPIPE instead of getting SIGPIPE signal. |
| 35 struct sigaction sa; | 35 struct sigaction sa; |
| 36 sa.sa_flags = 0; | 36 sa.sa_flags = 0; |
| 37 sigemptyset(&sa.sa_mask); | 37 sigemptyset(&sa.sa_mask); |
| (...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 160 void Platform::ScheduleAbort() { | 160 void Platform::ScheduleAbort() { |
| 161 static bool failed = false; | 161 static bool failed = false; |
| 162 if (!failed) atexit(abort); | 162 if (!failed) atexit(abort); |
| 163 failed = true; | 163 failed = true; |
| 164 } | 164 } |
| 165 | 165 |
| 166 void Platform::ImmediateAbort() { abort(); } | 166 void Platform::ImmediateAbort() { abort(); } |
| 167 | 167 |
| 168 #ifdef DEBUG | 168 #ifdef DEBUG |
| 169 void Platform::WaitForDebugger(const char* executable_name) { | 169 void Platform::WaitForDebugger(const char* executable_name) { |
| 170 const char* tty = Platform::GetEnv("FLETCH_VM_TTY"); | 170 const char* tty = Platform::GetEnv("DARTINO_VM_TTY"); |
| 171 if (tty) { | 171 if (tty) { |
| 172 close(2); // Stderr. | 172 close(2); // Stderr. |
| 173 open(tty, O_WRONLY); // Replace stderr with terminal. | 173 open(tty, O_WRONLY); // Replace stderr with terminal. |
| 174 } | 174 } |
| 175 int fd = open("/dev/tty", O_WRONLY); | 175 int fd = open("/dev/tty", O_WRONLY); |
| 176 if (fd >= 0) { | 176 if (fd >= 0) { |
| 177 FILE* terminal = fdopen(fd, "w"); | 177 FILE* terminal = fdopen(fd, "w"); |
| 178 fprintf(terminal, "*** VM paused, debug with:\n"); | 178 fprintf(terminal, "*** VM paused, debug with:\n"); |
| 179 fprintf( | 179 fprintf( |
| 180 terminal, | 180 terminal, |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 234 MAP_PRIVATE | MAP_ANON | MAP_FIXED, kMmapFd, | 234 MAP_PRIVATE | MAP_ANON | MAP_FIXED, kMmapFd, |
| 235 kMmapFdOffset) != MAP_FAILED; | 235 kMmapFdOffset) != MAP_FAILED; |
| 236 } | 236 } |
| 237 | 237 |
| 238 bool VirtualMemory::Uncommit(uword address, int size) { | 238 bool VirtualMemory::Uncommit(uword address, int size) { |
| 239 return mmap(reinterpret_cast<void*>(address), size, PROT_NONE, | 239 return mmap(reinterpret_cast<void*>(address), size, PROT_NONE, |
| 240 MAP_PRIVATE | MAP_ANON | MAP_NORESERVE, kMmapFd, | 240 MAP_PRIVATE | MAP_ANON | MAP_NORESERVE, kMmapFd, |
| 241 kMmapFdOffset) != MAP_FAILED; | 241 kMmapFdOffset) != MAP_FAILED; |
| 242 } | 242 } |
| 243 | 243 |
| 244 } // namespace fletch | 244 } // namespace dartino |
| 245 | 245 |
| 246 #endif // defined(FLETCH_TARGET_OS_POSIX) | 246 #endif // defined(DARTINO_TARGET_OS_POSIX) |
| OLD | NEW |