2 * Written by Josh Dybnis and released to the public domain, as explained at
3 * http://creativecommons.org/licenses/publicdomain
13 DECLARE_THREAD_LOCAL(ThreadId, int);
14 static int ThreadIndex
16 static int MaxThreadId = 0;
18 __attribute__ ((constructor)) void nbd_init (void) {
23 void nbd_thread_init (void) {
24 LOCALIZE_THREAD_LOCAL(ThreadId, int);
27 ++MaxThreadId; // TODO: reuse thread id's of threads that have been destroyed
28 ASSERT(MaxThreadId <= MAX_NUM_THREADS);
29 SET_THREAD_LOCAL(ThreadId, MaxThreadId);