this repo has no description
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Short circuit the most common pthread_canceled() call for singlethreaded programs

+16
+8
src/kernel/emulation/linux/bsdthread/bsdthread_create.c
··· 22 22 23 23 #define STACK_GUARD_SIZE 4096 24 24 25 + static bool _uses_threads = false; 26 + 25 27 // http://www.tldp.org/FAQ/Threads-FAQ/clone.c 26 28 27 29 long sys_bsdthread_create(void* thread_start, void* arg, ··· 30 32 #ifndef VARIANT_DYLD // dyld doesn't create threads 31 33 int ret; 32 34 unsigned long stacksize = 0; 35 + 36 + _uses_threads = true; 33 37 34 38 #ifndef BSDTHREAD_WRAP_LINUX_PTHREAD 35 39 if (!(flags & PTHREAD_START_CUSTOM)) ··· 123 127 } 124 128 #endif 125 129 130 + bool uses_threads(void) 131 + { 132 + return _uses_threads; 133 + } 126 134
+3
src/kernel/emulation/linux/bsdthread/bsdthread_create.h
··· 1 1 #ifndef BSDTHREAD_CREATE_H 2 2 #define BSDTHREAD_CREATE_H 3 3 #include <stdint.h> 4 + #include <stdbool.h> 4 5 5 6 long sys_bsdthread_create(void* thread_start, void* arg, void** stack, 6 7 void* pthread, uint32_t flags); ··· 9 10 uintptr_t arg4, uintptr_t arg5, uintptr_t arg6); 10 11 11 12 void* thread_stack_allocate(unsigned long stacksize); 13 + 14 + bool uses_threads(void); 12 15 13 16 #define LINUX_CLONE_VM 0x00000100 14 17 #define LINUX_CLONE_FS 0x00000200
+5
src/kernel/emulation/linux/bsdthread/pthread_canceled.c
··· 5 5 #include <stddef.h> 6 6 #include "../mach/lkm.h" 7 7 #include "../../../../lkm/api.h" 8 + #include "bsdthread_create.h" 9 + #include <sys/errno.h> 8 10 9 11 long sys_pthread_canceled(int action) 10 12 { 13 + if (action == 0 && !uses_threads()) 14 + return -EINVAL; 15 + 11 16 int ret = lkm_call(NR_pthread_canceled, (void*)(long) action); 12 17 if (ret < 0) 13 18 ret = errno_linux_to_bsd(ret);