xref: /haiku/src/system/libroot/os/arch/x86/thread.c (revision 718d7149b1b3bd7443e4149ab4a43814efbcc684)
15af32e75SAxel Dörfler /*
25af32e75SAxel Dörfler  * Copyright 2003-2005, Axel Dörfler, axeld@pinc-software.de. All rights reserved.
35af32e75SAxel Dörfler  * Distributed under the terms of the MIT License.
45af32e75SAxel Dörfler  */
55af32e75SAxel Dörfler 
65af32e75SAxel Dörfler 
75af32e75SAxel Dörfler #include <OS.h>
85af32e75SAxel Dörfler #include "syscalls.h"
95af32e75SAxel Dörfler 
105af32e75SAxel Dörfler 
11*794df3bfSMarcus Overhagen thread_id
find_thread(const char * name)12*794df3bfSMarcus Overhagen find_thread(const char *name)
13*794df3bfSMarcus Overhagen {
14*794df3bfSMarcus Overhagen 	// BeOS R5 applications also use this trick as find_thread was available
15*794df3bfSMarcus Overhagen 	// in BeOS R5 OS.h as inline function. Do not change storage of thread id.
16*794df3bfSMarcus Overhagen 	if (!name) {
17*794df3bfSMarcus Overhagen 		thread_id thread;
18*794df3bfSMarcus Overhagen 		__asm__ __volatile__ (
19*794df3bfSMarcus Overhagen 			"movl	%%fs:4, %%eax \n\t"
20*794df3bfSMarcus Overhagen 			: "=a" (thread));
21*794df3bfSMarcus Overhagen 		return thread;
22*794df3bfSMarcus Overhagen 	}
23*794df3bfSMarcus Overhagen 	return _kern_find_thread(name);
24*794df3bfSMarcus Overhagen }
25*794df3bfSMarcus Overhagen 
26*794df3bfSMarcus Overhagen 
275af32e75SAxel Dörfler // see OS.h from BeOS R5 for the reason why we need this
28*794df3bfSMarcus Overhagen // there find_thread (see above) is provided as inline function
295af32e75SAxel Dörfler extern thread_id _kfind_thread_(const char *name);
305af32e75SAxel Dörfler 
315af32e75SAxel Dörfler 
325af32e75SAxel Dörfler thread_id
_kfind_thread_(const char * name)335af32e75SAxel Dörfler _kfind_thread_(const char *name)
345af32e75SAxel Dörfler {
355af32e75SAxel Dörfler 	return _kern_find_thread(name);
365af32e75SAxel Dörfler }
375af32e75SAxel Dörfler 
385af32e75SAxel Dörfler 
395af32e75SAxel Dörfler extern thread_id _kget_thread_stacks_(thread_id thread, uint32 *stacks);
405af32e75SAxel Dörfler 
415af32e75SAxel Dörfler status_t
_kget_thread_stacks_(thread_id thread,uint32 * stacks)425af32e75SAxel Dörfler _kget_thread_stacks_(thread_id thread, uint32 *stacks)
435af32e75SAxel Dörfler {
445af32e75SAxel Dörfler 	// This one is obviously called from the R4.5 startup code. I am not
455af32e75SAxel Dörfler 	// exactly sure how it returns its infos, but just returning an
465af32e75SAxel Dörfler 	// error seems to work fine as well
475af32e75SAxel Dörfler 	return B_ERROR;
485af32e75SAxel Dörfler }
495af32e75SAxel Dörfler 
50