OSDN Git Service

1999-07-07 Andrew Haley <aph@cygnus.com>
[pf3gnuchains/gcc-fork.git] / libjava / quick-threads.cc
1 // quick-threads.cc - interface between libjava and QuickThreads.
2
3 /* Copyright (C) 1998, 1999  Cygnus Solutions
4
5    This file is part of libgcj.
6
7 This software is copyrighted work licensed under the terms of the
8 Libgcj License.  Please consult the file "LIBGCJ_LICENSE" for
9 details.  */
10
11 #include <config.h>
12
13 #include <cni.h>
14 #include <jvm.h>
15
16 #include <java/lang/Thread.h>
17 #include <java/lang/System.h>
18
19
20 // Identifier for our piece of thread-local data.  Visible so that it
21 // can be used in quick-threads.h.
22 int _Jv_ThreadKey;
23
24 void
25 _Jv_ThreadStart (java::lang::Thread *thread, _Jv_Thread_t *data,
26                  _Jv_ThreadStartFunc *meth)
27 {
28   *data = coop_create ((coop_userf_t *) meth, (void *) thread,
29                        thread->isDaemon());
30   coop_setspecific (*data, _Jv_ThreadKey, thread);
31 }
32
33 static void
34 qthrow (void *except)
35 {
36   _Jv_Throw ((java::lang::Throwable *) except);
37 }
38
39 // Function to destroy thread-specific data item.  We just don't care.
40 static void
41 destroy_data (void *)
42 {
43 }
44
45 void
46 _Jv_InitThreads (void)
47 {
48   coop_init ();
49   _Jv_ThreadKey = coop_key_create (destroy_data);
50   coop_set_throw_function (qthrow);
51 }