| 1 | // win32-threads.cc - interface between libjava and Win32 threads.
|
|---|
| 2 |
|
|---|
| 3 | /* Copyright (C) 1998, 1999 Free Software Foundation, Inc.
|
|---|
| 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 | // If we're using the Boehm GC, then we need to override some of the
|
|---|
| 14 | // thread primitives. This is fairly gross.
|
|---|
| 15 | #ifdef HAVE_BOEHM_GC
|
|---|
| 16 | extern "C"
|
|---|
| 17 | {
|
|---|
| 18 | #include <gc.h>
|
|---|
| 19 | // <windows.h> #define's STRICT, which conflicts with Modifier.h
|
|---|
| 20 | #undef STRICT
|
|---|
| 21 | };
|
|---|
| 22 | #endif /* HAVE_BOEHM_GC */
|
|---|
| 23 |
|
|---|
| 24 | #include <gcj/cni.h>
|
|---|
| 25 | #include <jvm.h>
|
|---|
| 26 | #include <java/lang/Thread.h>
|
|---|
| 27 | #include <java/lang/System.h>
|
|---|
| 28 |
|
|---|
| 29 | #include <errno.h>
|
|---|
| 30 |
|
|---|
| 31 | #ifndef ETIMEDOUT
|
|---|
| 32 | #define ETIMEDOUT 116
|
|---|
| 33 | #endif
|
|---|
| 34 |
|
|---|
| 35 | // This is used to implement thread startup.
|
|---|
| 36 | struct starter
|
|---|
| 37 | {
|
|---|
| 38 | _Jv_ThreadStartFunc *method;
|
|---|
| 39 | _Jv_Thread_t *data;
|
|---|
| 40 | };
|
|---|
| 41 |
|
|---|
| 42 | // Controls access to the variable below
|
|---|
| 43 | static HANDLE daemon_mutex;
|
|---|
| 44 | static HANDLE daemon_cond;
|
|---|
| 45 | // Number of non-daemon threads - _Jv_ThreadWait returns when this is 0
|
|---|
| 46 | static int non_daemon_count;
|
|---|
| 47 |
|
|---|
| 48 | // TLS key get Java object representing the thread
|
|---|
| 49 | DWORD _Jv_ThreadKey;
|
|---|
| 50 | // TLS key to get _Jv_Thread_t* representing the thread
|
|---|
| 51 | DWORD _Jv_ThreadDataKey;
|
|---|
| 52 |
|
|---|
| 53 | //
|
|---|
| 54 | // These are the flags that can appear in _Jv_Thread_t.
|
|---|
| 55 | //
|
|---|
| 56 |
|
|---|
| 57 | // Thread started.
|
|---|
| 58 | #define FLAG_START 0x01
|
|---|
| 59 | // Thread is daemon.
|
|---|
| 60 | #define FLAG_DAEMON 0x02
|
|---|
|
|---|