OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium 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 #include "base/process/launch.h" | 5 #include "base/process/launch.h" |
6 | 6 |
7 #include <dirent.h> | 7 #include <dirent.h> |
8 #include <errno.h> | 8 #include <errno.h> |
9 #include <fcntl.h> | 9 #include <fcntl.h> |
10 #include <sched.h> | 10 #include <sched.h> |
(...skipping 708 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
719 #endif | 719 #endif |
720 NOINLINE pid_t CloneAndLongjmpInChild(unsigned long flags, | 720 NOINLINE pid_t CloneAndLongjmpInChild(unsigned long flags, |
721 pid_t* ptid, | 721 pid_t* ptid, |
722 pid_t* ctid, | 722 pid_t* ctid, |
723 jmp_buf* env) { | 723 jmp_buf* env) { |
724 // We use the libc clone wrapper instead of making the syscall | 724 // We use the libc clone wrapper instead of making the syscall |
725 // directly because making the syscall may fail to update the libc's | 725 // directly because making the syscall may fail to update the libc's |
726 // internal pid cache. The libc interface unfortunately requires | 726 // internal pid cache. The libc interface unfortunately requires |
727 // specifying a new stack, so we use setjmp/longjmp to emulate | 727 // specifying a new stack, so we use setjmp/longjmp to emulate |
728 // fork-like behavior. | 728 // fork-like behavior. |
729 char stack_buf[PTHREAD_STACK_MIN] ALIGNAS(16); | 729 alignas(16) char stack_buf[PTHREAD_STACK_MIN]; |
730 #if defined(ARCH_CPU_X86_FAMILY) || defined(ARCH_CPU_ARM_FAMILY) || \ | 730 #if defined(ARCH_CPU_X86_FAMILY) || defined(ARCH_CPU_ARM_FAMILY) || \ |
731 defined(ARCH_CPU_MIPS_FAMILY) | 731 defined(ARCH_CPU_MIPS_FAMILY) |
732 // The stack grows downward. | 732 // The stack grows downward. |
733 void* stack = stack_buf + sizeof(stack_buf); | 733 void* stack = stack_buf + sizeof(stack_buf); |
734 #else | 734 #else |
735 #error "Unsupported architecture" | 735 #error "Unsupported architecture" |
736 #endif | 736 #endif |
737 return clone(&CloneHelper, stack, flags, env, ptid, nullptr, ctid); | 737 return clone(&CloneHelper, stack, flags, env, ptid, nullptr, ctid); |
738 } | 738 } |
739 | 739 |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
773 jmp_buf env; | 773 jmp_buf env; |
774 if (setjmp(env) == 0) { | 774 if (setjmp(env) == 0) { |
775 return CloneAndLongjmpInChild(flags, ptid, ctid, &env); | 775 return CloneAndLongjmpInChild(flags, ptid, ctid, &env); |
776 } | 776 } |
777 | 777 |
778 return 0; | 778 return 0; |
779 } | 779 } |
780 #endif // defined(OS_LINUX) || defined(OS_NACL_NONSFI) | 780 #endif // defined(OS_LINUX) || defined(OS_NACL_NONSFI) |
781 | 781 |
782 } // namespace base | 782 } // namespace base |
OLD | NEW |