*/
-#ifndef _THREADS_COMMON_H
-#define _THREADS_COMMON_H
+#ifndef _THREAD_H
+#define _THREAD_H
#include "config.h"
+#ifdef __cplusplus
+extern "C" {
+#endif
+
#include "vmcore/system.h"
+#include "threads/mutex.hpp"
+
#if defined(ENABLE_THREADS)
# include "threads/posix/thread-posix.h"
#else
}
+/* cacaothread_get_state *******************************************************
+
+ Returns the current state of the given thread.
+
+ ARGUMENTS:
+ t ... the thread to check
+
+ RETURN:
+ thread state
+
+*******************************************************************************/
+
+inline static int cacaothread_get_state(threadobject *t)
+{
+ return t->state;
+}
+
+
/* thread_is_attached **********************************************************
Returns if the given thread is attached to the VM.
+ ARGUMENTS:
+ t ... the thread to check
+
RETURN:
true .... the thread is attached to the VM
false ... the thread is not
}
+/* thread_is_interrupted *******************************************************
+
+ Check if the given thread has been interrupted.
+
+ ARGUMENTS:
+ t ... the thread to check
+
+ RETURN VALUE:
+ true, if the given thread had been interrupted
+
+*******************************************************************************/
+
+inline static bool thread_is_interrupted(threadobject *t)
+{
+ bool interrupted;
+
+ /* We need the mutex because classpath will call this function when
+ a blocking system call is interrupted. The mutex ensures that it will
+ see the correct value for the interrupted flag. */
+
+ Mutex_lock(t->waitmutex);
+ interrupted = t->interrupted;
+ Mutex_unlock(t->waitmutex);
+
+ return interrupted;
+}
+
+
+/* thread_set_interrupted ******************************************************
+
+ Set the interrupted flag to the given value.
+
+ ARGUMENTS:
+ interrupted ... value to set
+
+*******************************************************************************/
+
+inline static void thread_set_interrupted(threadobject *t, bool interrupted)
+{
+ Mutex_lock(t->waitmutex);
+
+ /* Set interrupted flag. */
+
+ t->interrupted = interrupted;
+
+ Mutex_unlock(t->waitmutex);
+}
+
+
/* thread_is_daemon ************************************************************
Returns if the given thread is a daemon thread.
+ ARGUMENTS:
+ t ... the thread to check
+
RETURN:
true .... the thread is a daemon thread
false ... the thread is not
bool threads_thread_start_internal(utf *name, functionptr f);
void threads_thread_start(java_handle_t *object);
-bool threads_attach_current_thread(JavaVMAttachArgs *vm_aargs, bool isdaemon);
+bool thread_attach_current_thread(JavaVMAttachArgs *vm_aargs, bool isdaemon);
+bool thread_attach_current_external_thread(JavaVMAttachArgs *vm_aargs, bool isdaemon);
+bool thread_detach_current_thread(void);
+
+bool thread_detach_current_external_thread(void);
void thread_fprint_name(threadobject *t, FILE *stream);
void thread_print_info(threadobject *t);
intptr_t threads_get_current_tid(void);
-void threads_thread_state_runnable(threadobject *t);
-void threads_thread_state_waiting(threadobject *t);
-void threads_thread_state_timed_waiting(threadobject *t);
-void threads_thread_state_terminated(threadobject *t);
+void thread_set_state_runnable(threadobject *t);
+void thread_set_state_waiting(threadobject *t);
+void thread_set_state_timed_waiting(threadobject *t);
+void thread_set_state_terminated(threadobject *t);
-utf *threads_thread_get_state(threadobject *t);
threadobject *thread_get_thread(java_handle_t *h);
bool threads_thread_is_alive(threadobject *t);
#endif /* ENABLE_THREADS */
-#endif /* _THREADS_COMMON_H */
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* _THREAD_H */
/*