Index: trunk/src/VBox/Runtime/include/internal/thread.h
===================================================================
--- trunk/src/VBox/Runtime/include/internal/thread.h	(revision 392)
+++ trunk/src/VBox/Runtime/include/internal/thread.h	(revision 403)
@@ -25,14 +25,12 @@
 #include <iprt/types.h>
 #include <iprt/thread.h>
+#include <iprt/avl.h>
 #ifdef IN_RING3
 # include <iprt/process.h>
 # include <iprt/critsect.h>
-# include <iprt/avl.h>
 #endif
 
 __BEGIN_DECLS
 
-
-#ifdef IN_RING3
 
 
@@ -89,5 +87,5 @@
     /** The current thread state. */
     RTTHREADSTATE volatile  enmState;
-#ifdef __WIN__
+#if defined(__WIN__) && defined(IN_RING3)
     /** The thread handle.
      * This is not valid until the create function has returned! */
@@ -112,4 +110,5 @@
     /** Actual stack size. */
     size_t                  cbStack;
+#ifdef IN_RING3
     /** What we're blocking on. */
     union RTTHREADINTBLOCKID
@@ -127,4 +126,5 @@
     /** Where we're blocking. */
     RTUINTPTR volatile      uBlockId;
+#endif /* IN_RING3 */
     /** Thread name. */
     char                    szName[RTTHREAD_NAME_LEN];
@@ -154,9 +154,27 @@
  * Initialize the native part of the thread management.
  *
- * Generally a TLS entry will be allocated at this point.
+ * Generally a TLS entry will be allocated at this point (Ring-3).
  *
  * @returns iprt status code.
  */
 int rtThreadNativeInit(void);
+
+/**
+ * Create a native thread.
+ * This creates the thread as described in pThreadInt and stores the thread id in *pThread.
+ *
+ * @returns iprt status code.
+ * @param   pThreadInt      The thread data structure for the thread.
+ * @param   pNativeThread   Where to store the native thread identifier.
+ */
+int rtThreadNativeCreate(PRTTHREADINT pThreadInt, PRTNATIVETHREAD pNativeThread);
+
+/**
+ * Adopts a thread, this is called immediately after allocating the
+ * thread structure.
+ *
+ * @param   pThread     Pointer to the thread structure.
+ */
+int rtThreadNativeAdopt(PRTTHREADINT pThread);
 
 /**
@@ -174,23 +192,6 @@
 int rtThreadNativeSetPriority(PRTTHREADINT pThread, RTTHREADTYPE enmType);
 
-/**
- * Create a native thread.
- * This creates the thread as described in pThreadInt and stores the thread id in *pThread.
- *
- * @returns iprt status code.
- * @param   pThreadInt      The thread data structure for the thread.
- * @param   pNativeThread   Where to store the native thread identifier.
- */
-int rtThreadNativeCreate(PRTTHREADINT pThreadInt, PRTNATIVETHREAD pNativeThread);
-
-/**
- * Adopts a thread, this is called immediately after allocating the
- * thread structure.
- *
- * @param   pThread     Pointer to the thread structure.
- */
-int rtThreadNativeAdopt(PRTTHREADINT pThread);
-
-#ifdef __WIN__
+#ifdef IN_RING3
+# ifdef __WIN__
 /**
  * Callback for when a native thread is detaching.
@@ -200,58 +201,22 @@
  */
 void rtThreadNativeDetach(void);
-#endif
-
-int rtThreadInit(void);
+# endif
+#endif /* !IN_RING0 */
+
+
+/* thread.cpp */
 int rtThreadMain(PRTTHREADINT pThread, RTNATIVETHREAD NativeThread);
-void rtThreadInsert(PRTTHREADINT pThread, RTNATIVETHREAD NativeThread);
-PRTTHREADINT rtThreadGetByNative(RTNATIVETHREAD NativeThread);
-PRTTHREADINT rtThreadGet(RTTHREAD Thread);
-uint32_t rtThreadRelease(PRTTHREADINT pThread);
-int rtThreadDoSetProcPriority(RTPROCPRIORITY enmPriority);
-void rtThreadTerminate(PRTTHREADINT pThread, int rc);
 void rtThreadBlocking(PRTTHREADINT pThread, RTTHREADSTATE enmState, uint64_t u64Block,
                       const char *pszFile, unsigned uLine, RTUINTPTR uId);
 void rtThreadUnblocked(PRTTHREADINT pThread, RTTHREADSTATE enmCurState);
-
-
-#elif defined(IN_RING0)
-
-/**
- * Argument package for a ring-0 thread.
- */
-typedef struct RTR0THREADARGS
-{
-    /** The thread function. */
-    PFNRTTHREAD     pfnThread;
-    /** The thread function argument. */
-    void           *pvUser;
-    /** The thread type. */
-    RTTHREADTYPE    enmType;
-} RTR0THREADARGS, *PRTR0THREADARGS;
-
-
-
-int rtThreadMain(PRTR0THREADARGS pArgs, RTNATIVETHREAD NativeThread);
-
-/**
- * Do the actual thread creation.
- *
- * @returns IPRT status code.
- *          On failure, no thread has been created.
- * @param   pArgs           The argument package.
- * @param   pNativeThread   Where to return the native thread handle.
- */
-int rtThreadNativeCreate(PRTR0THREADARGS pArgs, PRTNATIVETHREAD pNativeThread);
-
-/**
- * Do the actual thread priority change.
- *
- * @returns IPRT status code.
- * @param   Thread      The thread which priority should be changed.
- *                      This is currently restricted to the current thread.
- * @param   enmType     The new thread priority type (valid).
- */
-int rtThreadNativeSetPriority(RTTHREAD Thread, RTTHREADTYPE enmType);
-
+uint32_t rtThreadRelease(PRTTHREADINT pThread);
+void rtThreadTerminate(PRTTHREADINT pThread, int rc);
+PRTTHREADINT rtThreadGetByNative(RTNATIVETHREAD NativeThread);
+PRTTHREADINT rtThreadGet(RTTHREAD Thread);
+int rtThreadInit(void);
+void rtThreadTerm(void);
+void rtThreadInsert(PRTTHREADINT pThread, RTNATIVETHREAD NativeThread);
+#ifdef IN_RING3
+int rtThreadDoSetProcPriority(RTPROCPRIORITY enmPriority);
 #endif /* !IN_RING0 */
 
