Removed global variable pCurrentTeb.

diff --git a/include/winnt.h b/include/winnt.h
index d212e2d..f597056 100644
--- a/include/winnt.h
+++ b/include/winnt.h
@@ -739,15 +739,29 @@
 #define DBG_EXCEPTION_NOT_HANDLED   0x80010001
 
 struct _TEB;
-#if defined(__i386__) && defined(__WINE__)
+
+#ifdef __WINE__
+
+#if defined(__i386__)
 static inline struct _TEB * WINE_UNUSED __get_teb(void)
 {
     struct _TEB *teb;
     __asm__(".byte 0x64\n\tmovl (0x18),%0" : "=r" (teb));
     return teb;
 }
-#define NtCurrentTeb() __get_teb()
+#elif defined(HAVE__LWP_CREATE)
+extern void *_lwp_getprivate(void);
+static inline struct _TEB * WINE_UNUSED __get_teb(void)
+{
+    return (struct _TEB *)_lwp_getprivate();
+}
 #else
+#error NtCurrentTeb() not defined for this architecture!
+#endif
+
+#define NtCurrentTeb() __get_teb()
+
+#else /* __WINE__ */
 extern struct _TEB * WINAPI NtCurrentTeb(void);
 #endif
 
diff --git a/scheduler/sysdeps.c b/scheduler/sysdeps.c
index 17161c0..e69f82a 100644
--- a/scheduler/sysdeps.c
+++ b/scheduler/sysdeps.c
@@ -56,11 +56,6 @@
 
 static int init_done;
 
-#ifndef __i386__
-static TEB *pCurrentTeb;
-#endif
-
-
 #ifndef NO_REENTRANT_LIBC
 
 /***********************************************************************
@@ -112,13 +107,14 @@
  */
 void SYSDEPS_SetCurThread( TEB *teb )
 {
-#ifdef __i386__
+#if defined(__i386__)
     /* On the i386, the current thread is in the %fs register */
     SET_FS( teb->teb_sel );
-#else
-    /* FIXME: only works if there is no preemptive task-switching going on... */
-    pCurrentTeb = teb;
-#endif  /* __i386__ */
+#elif defined(HAVE__LWP_CREATE)
+    /* On non-i386 Solaris, we use the LWP private pointer */
+    _lwp_setprivate( teb );
+#endif
+
     init_done = 1;  /* now we can use threading routines */
 }
 
@@ -216,20 +212,13 @@
  * This will crash and burn if called before threading is initialized
  */
 
-#ifdef NtCurrentTeb
-
 /* if it was defined as a macro, we need to do some magic */
+#ifdef NtCurrentTeb
 #undef NtCurrentTeb
+#endif
+
 struct _TEB * WINAPI NtCurrentTeb(void)
 {
     return __get_teb();
 }
 
-#else  /* NtCurrentTeb */
-
-struct _TEB * WINAPI NtCurrentTeb(void)
-{
-    return pCurrentTeb;
-}
-
-#endif  /* NtCurrentTeb */