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 718 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
729 #endif | 729 #endif |
730 NOINLINE pid_t CloneAndLongjmpInChild(unsigned long flags, | 730 NOINLINE pid_t CloneAndLongjmpInChild(unsigned long flags, |
731 pid_t* ptid, | 731 pid_t* ptid, |
732 pid_t* ctid, | 732 pid_t* ctid, |
733 jmp_buf* env) { | 733 jmp_buf* env) { |
734 // We use the libc clone wrapper instead of making the syscall | 734 // We use the libc clone wrapper instead of making the syscall |
735 // directly because making the syscall may fail to update the libc's | 735 // directly because making the syscall may fail to update the libc's |
736 // internal pid cache. The libc interface unfortunately requires | 736 // internal pid cache. The libc interface unfortunately requires |
737 // specifying a new stack, so we use setjmp/longjmp to emulate | 737 // specifying a new stack, so we use setjmp/longjmp to emulate |
738 // fork-like behavior. | 738 // fork-like behavior. |
739 char stack_buf[PTHREAD_STACK_MIN]; | 739 char stack_buf[PTHREAD_STACK_MIN] ALIGNAS(16); |
740 #if defined(ARCH_CPU_X86_FAMILY) || defined(ARCH_CPU_ARM_FAMILY) || \ | 740 #if defined(ARCH_CPU_X86_FAMILY) || defined(ARCH_CPU_ARM_FAMILY) || \ |
741 defined(ARCH_CPU_MIPS64_FAMILY) || defined(ARCH_CPU_MIPS_FAMILY) | 741 defined(ARCH_CPU_MIPS64_FAMILY) || defined(ARCH_CPU_MIPS_FAMILY) |
742 // The stack grows downward. | 742 // The stack grows downward. |
743 void* stack = stack_buf + sizeof(stack_buf); | 743 void* stack = stack_buf + sizeof(stack_buf); |
744 #else | 744 #else |
745 #error "Unsupported architecture" | 745 #error "Unsupported architecture" |
746 #endif | 746 #endif |
747 return clone(&CloneHelper, stack, flags, env, ptid, nullptr, ctid); | 747 return clone(&CloneHelper, stack, flags, env, ptid, nullptr, ctid); |
748 } | 748 } |
749 | 749 |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
783 jmp_buf env; | 783 jmp_buf env; |
784 if (setjmp(env) == 0) { | 784 if (setjmp(env) == 0) { |
785 return CloneAndLongjmpInChild(flags, ptid, ctid, &env); | 785 return CloneAndLongjmpInChild(flags, ptid, ctid, &env); |
786 } | 786 } |
787 | 787 |
788 return 0; | 788 return 0; |
789 } | 789 } |
790 #endif // defined(OS_LINUX) || defined(OS_NACL_NONSFI) | 790 #endif // defined(OS_LINUX) || defined(OS_NACL_NONSFI) |
791 | 791 |
792 } // namespace base | 792 } // namespace base |
OLD | NEW |