Fixed binary search: no more infinite loops when vendor is unknown.
[tangerine.git] / workbench / libs / thread / currentthread.c
blob32abad9eaf85017b540269be1c0739a83c8d3767
1 /*
2 * thread.library - threading and synchronisation primitives
4 * Copyright © 2007 Robert Norris
6 * This program is free software; you can redistribute it and/or modify it
7 * under the same terms as AROS itself.
8 */
10 #include "thread_intern.h"
12 #include <proto/exec.h>
14 /*****************************************************************************
16 NAME */
17 AROS_LH0(uint32_t, CurrentThread,
19 /* SYNOPSIS */
21 /* LOCATION */
22 struct ThreadBase *, ThreadBase, 9, Thread)
24 /* FUNCTION
25 Get the ID of the running thread.
27 INPUTS
28 None.
30 RESULT
31 Numeric thread ID, or 0 if this is not a thread.
33 NOTES
35 EXAMPLE
36 uint32_t id = CurrentThread();
37 printf("this is thread %d\n", id);
39 BUGS
41 SEE ALSO
42 CreateThread(), DetachThread(), WaitThread(), WaitAllThreads()
44 INTERNALS
46 *****************************************************************************/
48 AROS_LIBFUNC_INIT
50 /* find it */
51 struct _Thread *thread = _getthreadbytask(FindTask(NULL), ThreadBase);
52 if (thread == NULL)
53 return 0;
55 return thread->id;
57 AROS_LIBFUNC_EXIT
58 } /* CurrentThread */