| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (c) 2014 The Native Client Authors. All rights reserved. | 2 * Copyright (c) 2014 The Native Client Authors. All rights reserved. |
| 3 * Use of this source code is governed by a BSD-style license that can be | 3 * Use of this source code is governed by a BSD-style license that can be |
| 4 * found in the LICENSE file. | 4 * found in the LICENSE file. |
| 5 */ | 5 */ |
| 6 | 6 |
| 7 /* | 7 /* |
| 8 * This file defines various POSIX-like functions directly using Linux | 8 * This file defines various POSIX-like functions directly using Linux |
| 9 * syscalls. This is analogous to src/untrusted/nacl/sys_private.c, which | 9 * syscalls. This is analogous to src/untrusted/nacl/sys_private.c, which |
| 10 * defines functions using NaCl syscalls directly. | 10 * defines functions using NaCl syscalls directly. |
| (...skipping 335 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 346 va_start(ap, cmd); | 346 va_start(ap, cmd); |
| 347 int32_t arg = va_arg(ap, int32_t); | 347 int32_t arg = va_arg(ap, int32_t); |
| 348 va_end(ap); | 348 va_end(ap); |
| 349 return errno_value_call(linux_syscall3(__NR_fcntl64, fd, cmd, arg)); | 349 return errno_value_call(linux_syscall3(__NR_fcntl64, fd, cmd, arg)); |
| 350 } | 350 } |
| 351 /* We only support the fcntl commands above. */ | 351 /* We only support the fcntl commands above. */ |
| 352 errno = EINVAL; | 352 errno = EINVAL; |
| 353 return -1; | 353 return -1; |
| 354 } | 354 } |
| 355 | 355 |
| 356 int getpid(void) { |
| 357 return errno_value_call(linux_syscall0(__NR_getpid)); |
| 358 } |
| 359 |
| 356 int fork(void) { | 360 int fork(void) { |
| 357 /* Set SIGCHLD as flag so we can wait. */ | 361 /* Set SIGCHLD as flag so we can wait. */ |
| 358 return errno_value_call( | 362 return errno_value_call( |
| 359 linux_syscall5(__NR_clone, LINUX_SIGCHLD, | 363 linux_syscall5(__NR_clone, LINUX_SIGCHLD, |
| 360 0 /* stack */, 0 /* ptid */, 0 /* tls */, 0 /* ctid */)); | 364 0 /* stack */, 0 /* ptid */, 0 /* tls */, 0 /* ctid */)); |
| 361 } | 365 } |
| 362 | 366 |
| 363 int isatty(int fd) { | 367 int isatty(int fd) { |
| 364 struct linux_termios term; | 368 struct linux_termios term; |
| 365 return errno_value_call( | 369 return errno_value_call( |
| (...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 515 | 519 |
| 516 void *nacl_tls_get(void) { | 520 void *nacl_tls_get(void) { |
| 517 void *result; | 521 void *result; |
| 518 #if defined(__i386__) | 522 #if defined(__i386__) |
| 519 __asm__("mov %%gs:0, %0" : "=r"(result)); | 523 __asm__("mov %%gs:0, %0" : "=r"(result)); |
| 520 #elif defined(__arm__) | 524 #elif defined(__arm__) |
| 521 __asm__("mrc p15, 0, %0, c13, c0, 3" : "=r"(result)); | 525 __asm__("mrc p15, 0, %0, c13, c0, 3" : "=r"(result)); |
| 522 #endif | 526 #endif |
| 523 return result; | 527 return result; |
| 524 } | 528 } |
| OLD | NEW |