From 794df3bf254c03b363a5d196456a429b89a71855 Mon Sep 17 00:00:00 2001 From: Marcus Overhagen Date: Sat, 20 Aug 2005 23:57:11 +0000 Subject: [PATCH] This removes the inline assembly code for find_thread from OS.h, sorry for triggering a complete rebuild. To avoid doing a syscall for find_thread(0), the assembly version is now in libroot. For BeOS R5 compatibility, _kfind_thread_ is retained. This will fix some compile problems, and provides a cleaner OS.h for future Haiku versions. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@14014 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- headers/os/kernel/OS.h | 22 ---------------------- src/system/libroot/os/arch/ppc/Jamfile | 1 + src/system/libroot/os/arch/ppc/thread.c | 9 +++++++++ src/system/libroot/os/arch/x86/thread.c | 18 +++++++++++++++++- src/system/libroot/os/thread.c | 7 ------- src/system/runtime_loader/Jamfile | 1 + 6 files changed, 28 insertions(+), 30 deletions(-) create mode 100644 src/system/libroot/os/arch/ppc/thread.c diff --git a/headers/os/kernel/OS.h b/headers/os/kernel/OS.h index b520be78c0..0d7718087e 100644 --- a/headers/os/kernel/OS.h +++ b/headers/os/kernel/OS.h @@ -296,29 +296,7 @@ extern void exit_thread(status_t status); extern status_t wait_for_thread (thread_id thread, status_t *threadReturnValue); extern status_t on_exit_thread(void (*callback)(void *), void *data); -#if __INTEL__ && !_KERNEL_MODE && !_NO_INLINE_ASM -static inline thread_id -find_thread(const char *name) { -# ifndef __HAIKU__ -/* ToDo: this can be removed once we don't need BeOS compatibility of our source files */ -# define _kern_find_thread _kfind_thread_ -# endif - extern thread_id _kern_find_thread(const char *name); - if (!name) { - thread_id thread; - __asm__ __volatile__ ( - "movl %%fs:4, %%eax \n\t" - : "=a" (thread)); - return thread; - } - return _kern_find_thread(name); -# ifndef __HAIKU__ -# undef _kern_find_thread -# endif -} -#else extern thread_id find_thread(const char *name); -#endif extern status_t send_data(thread_id thread, int32 code, const void *buffer, size_t bufferSize); diff --git a/src/system/libroot/os/arch/ppc/Jamfile b/src/system/libroot/os/arch/ppc/Jamfile index 9128822187..917485834e 100644 --- a/src/system/libroot/os/arch/ppc/Jamfile +++ b/src/system/libroot/os/arch/ppc/Jamfile @@ -5,6 +5,7 @@ KernelMergeObject os_arch_$(OBOS_ARCH).o : <$(SOURCE_GRIST)>byteorder.S # <$(SOURCE_GRIST)>systeminfo.c <$(SOURCE_GRIST)>system_time.S + <$(SOURCE_GRIST)>thread.c <$(SOURCE_GRIST)>tls.c : -fPIC -DPIC diff --git a/src/system/libroot/os/arch/ppc/thread.c b/src/system/libroot/os/arch/ppc/thread.c new file mode 100644 index 0000000000..df90b6ad6a --- /dev/null +++ b/src/system/libroot/os/arch/ppc/thread.c @@ -0,0 +1,9 @@ +#include +#include "syscalls.h" + + +thread_id +find_thread(const char *name) +{ + return _kern_find_thread(name); +} diff --git a/src/system/libroot/os/arch/x86/thread.c b/src/system/libroot/os/arch/x86/thread.c index 3b4aed421a..ad6dc4d3f7 100644 --- a/src/system/libroot/os/arch/x86/thread.c +++ b/src/system/libroot/os/arch/x86/thread.c @@ -8,8 +8,24 @@ #include "syscalls.h" +thread_id +find_thread(const char *name) +{ + // BeOS R5 applications also use this trick as find_thread was available + // in BeOS R5 OS.h as inline function. Do not change storage of thread id. + if (!name) { + thread_id thread; + __asm__ __volatile__ ( + "movl %%fs:4, %%eax \n\t" + : "=a" (thread)); + return thread; + } + return _kern_find_thread(name); +} + + // see OS.h from BeOS R5 for the reason why we need this -// (it's referenced there in the same way we reference _kern_find_thread()) +// there find_thread (see above) is provided as inline function extern thread_id _kfind_thread_(const char *name); diff --git a/src/system/libroot/os/thread.c b/src/system/libroot/os/thread.c index 91dbc14ae8..c6e3c8d864 100644 --- a/src/system/libroot/os/thread.c +++ b/src/system/libroot/os/thread.c @@ -70,13 +70,6 @@ suspend_thread(thread_id thread) } -thread_id -find_thread(const char *name) -{ - return _kern_find_thread(name); -} - - status_t rename_thread(thread_id thread, const char *name) { diff --git a/src/system/runtime_loader/Jamfile b/src/system/runtime_loader/Jamfile index 0a4f71e7db..32b8f2167a 100644 --- a/src/system/runtime_loader/Jamfile +++ b/src/system/runtime_loader/Jamfile @@ -15,6 +15,7 @@ KernelStaticLibraryObjects librld.a : syscalls.o sem.o atomic.o + thread.o errno.o