diff --binary -urN pthreads-w32-2-8-0-release_org/GNUmakefile pthreads-w32-2-8-0-release/GNUmakefile
--- pthreads-w32-2-8-0-release_org/GNUmakefile	2006-04-30 19:22:33 +0900
+++ pthreads-w32-2-8-0-release/GNUmakefile	2010-03-14 08:40:41 +0900
@@ -455,6 +455,7 @@
 	@ echo "make clean GC-inlined    (to build the GNU C inlined dll with C cleanup code)"
 	@ echo "make clean GCE-inlined   (to build the GNU C inlined dll with C++ exception handling)"
 	@ echo "make clean GC-static     (to build the GNU C inlined static lib with C cleanup code)"
+	@ echo "make clean GC-fl-static  (to build the GNU C inlined static lib with C cleanup code enhanced)"
 	@ echo "make clean GC-debug      (to build the GNU C debug dll with C cleanup code)"
 	@ echo "make clean GCE-debug     (to build the GNU C debug dll with C++ exception handling)"
 	@ echo "make clean GC-inlined-debug    (to build the GNU C inlined debug dll with C cleanup code)"
@@ -492,6 +493,9 @@
 GC-static:
 		$(MAKE) XOPT="-DPTW32_BUILD_INLINED -DPTW32_STATIC_LIB" CLEANUP=-D__CLEANUP_C XC_FLAGS="$(GC_CFLAGS)" OBJ="$(DLL_INLINED_OBJS)" $(GC_STATIC_STAMP)
 
+GC-fl-static:
+		$(MAKE) XOPT="-DPTW32_BUILD_INLINED -DPTW32_STATIC_LIB -DPTW32_FL_STATIC" CLEANUP=-D__CLEANUP_C XC_FLAGS="$(GC_CFLAGS)" OBJ="$(DLL_INLINED_OBJS)" $(GC_STATIC_STAMP)
+
 GC-static-debug:
 		$(MAKE) XOPT="-DPTW32_BUILD_INLINED -DPTW32_STATIC_LIB" CLEANUP=-D__CLEANUP_C XC_FLAGS="$(GC_CFLAGS)" OBJ="$(DLL_INLINED_OBJS)" DLL_VER=$(DLL_VERD) OPT="$(DOPT)" $(GCD_STATIC_STAMP)
 
diff --binary -urN pthreads-w32-2-8-0-release_org/clearstatic.c pthreads-w32-2-8-0-release/clearstatic.c
--- pthreads-w32-2-8-0-release_org/clearstatic.c	1970-01-01 09:00:00 +0900
+++ pthreads-w32-2-8-0-release/clearstatic.c	2010-03-15 19:55:42 +0900
@@ -0,0 +1,93 @@
+/* This is an implementation of the threads API of POSIX 1003.1-2001.
+ *
+ * --------------------------------------------------------------------------
+ *
+ *      Pthreads-win32 - POSIX Threads Library for Win32
+ *      Copyright(C) 2010 Pthreads-win32 contributors
+ * 
+ *      This single file is NOT a official port of Pthreads-win32,
+ *      and is made by Takashi Hirata.
+ *
+ *      Contact Email: webmaster at up-cat.net
+ * 
+ *      This library is free software; you can redistribute it and/or
+ *      modify it under the terms of the GNU Lesser General Public
+ *      License as published by the Free Software Foundation; either
+ *      version 2 of the License, or (at your option) any later version.
+ * 
+ *      This library is distributed in the hope that it will be useful,
+ *      but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ *      Lesser General Public License for more details.
+ * 
+ *      You should have received a copy of the GNU Lesser General Public
+ *      License along with this library in the file COPYING.LIB;
+ *      if not, write to the Free Software Foundation, Inc.,
+ *      59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
+ */
+
+#if defined(PTW32_FL_STATIC)
+
+#include <windows.h>
+#include <winnt.h>
+#include "pthread.h"
+#include "implement.h"
+
+static NTAPI void flpthread_tls_callback(PVOID hinstDLL, DWORD fdwReason, PVOID lpvReserved){
+    switch(fdwReason){
+    case DLL_PROCESS_ATTACH:
+        flpthread_win32_process_attach_np();
+        flpthread_win32_thread_attach_np();
+        break;
+    case DLL_PROCESS_DETACH:
+        flpthread_win32_thread_detach_np();
+        flpthread_win32_process_detach_np();
+        break;
+    case DLL_THREAD_ATTACH:
+        flpthread_win32_thread_attach_np();
+        break;
+    case DLL_THREAD_DETACH:
+        flpthread_win32_thread_detach_np();
+        break;
+    default:
+        /* do nothing */
+        break;
+    }
+}
+
+static void*               flpthread_xla __attribute__((section(".CRT$XLA")))       = 0;
+static PIMAGE_TLS_CALLBACK flpthread_xly __attribute__((section(".CRT$XLY"), used)) = flpthread_tls_callback;
+static void*               flpthread_xlz __attribute__((section(".CRT$XLZ"), used)) = 0;
+
+static DWORD  flpthread_tls_data  __attribute__((section(".tls"))) = 0;
+static HANDLE flpthread_tls_index                                  = NULL;
+
+const IMAGE_TLS_DIRECTORY _tls_used __attribute__((section(".rdata$T"))) =
+{
+    (DWORD)&flpthread_tls_data,
+    (DWORD)&flpthread_tls_data,
+    (DWORD)&flpthread_tls_index,
+    (DWORD)(&flpthread_xla+1),
+    (DWORD)0, // unused (not supported)
+    (DWORD)0
+};
+
+// dummy functions
+BOOL pthread_win32_process_attach_np(){ return TRUE; }
+BOOL pthread_win32_process_detach_np(){ return TRUE; }
+BOOL pthread_win32_thread_attach_np(){ return TRUE; }
+BOOL pthread_win32_thread_detach_np(){ return TRUE; }
+
+#elif defined(PTW32_STATIC_LIB) // delegate functions for correctly coded applications for PTW32_STATIC_LIB
+
+BOOL pthread_win32_process_attach_np(){ return flpthread_win32_process_attach_np(); }
+BOOL pthread_win32_process_detach_np(){ return flpthread_win32_process_detach_np(); }
+BOOL pthread_win32_thread_attach_np(){ return flpthread_win32_thread_attach_np(); }
+BOOL pthread_win32_thread_detach_np(){ return flpthread_win32_thread_detach_np(); }
+
+#else
+
+// define nothing.
+// applications assuming "plain pthread" or "pthread-w32 dll" shall not use functions above.
+
+#endif
diff --binary -urN pthreads-w32-2-8-0-release_org/dll.c pthreads-w32-2-8-0-release/dll.c
--- pthreads-w32-2-8-0-release_org/dll.c	2005-04-01 09:55:21 +0900
+++ pthreads-w32-2-8-0-release/dll.c	2010-03-14 08:59:18 +0900
@@ -34,7 +34,7 @@
  *      59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
  */
 
-#ifndef PTW32_STATIC_LIB
+#if !defined(PTW32_STATIC_LIB) && !defined(PTW32_FL_STATIC)
 
 #include "pthread.h"
 #include "implement.h"
@@ -62,26 +62,26 @@
     {
 
     case DLL_PROCESS_ATTACH:
-      result = pthread_win32_process_attach_np ();
+      result = flpthread_win32_process_attach_np ();
       break;
 
     case DLL_THREAD_ATTACH:
       /*
        * A thread is being created
        */
-      result = pthread_win32_thread_attach_np ();
+      result = flpthread_win32_thread_attach_np ();
       break;
 
     case DLL_THREAD_DETACH:
       /*
        * A thread is exiting cleanly
        */
-      result = pthread_win32_thread_detach_np ();
+      result = flpthread_win32_thread_detach_np ();
       break;
 
     case DLL_PROCESS_DETACH:
-      (void) pthread_win32_thread_detach_np ();
-      result = pthread_win32_process_detach_np ();
+      (void) flpthread_win32_thread_detach_np ();
+      result = flpthread_win32_process_detach_np ();
       break;
     }
 
@@ -89,4 +89,4 @@
 
 }				/* DllMain */
 
-#endif /* PTW32_STATIC_LIB */
+#endif /* !defined(PTW32_STATIC_LIB) && !defined(PTW32_FL_STATIC) */
diff --binary -urN pthreads-w32-2-8-0-release_org/nonportable.c pthreads-w32-2-8-0-release/nonportable.c
--- pthreads-w32-2-8-0-release_org/nonportable.c	2005-01-01 23:36:17 +0900
+++ pthreads-w32-2-8-0-release/nonportable.c	2010-03-14 09:02:27 +0900
@@ -43,4 +43,5 @@
 #include "pthread_delay_np.c"
 #include "pthread_num_processors_np.c"
 #include "pthread_win32_attach_detach_np.c"
+#include "clearstatic.c"
 #include "pthread_timechange_handler_np.c"
diff --binary -urN pthreads-w32-2-8-0-release_org/pthread.h pthreads-w32-2-8-0-release/pthread.h
--- pthreads-w32-2-8-0-release_org/pthread.h	2006-01-24 22:59:57 +0900
+++ pthreads-w32-2-8-0-release/pthread.h	2010-03-15 18:41:05 +0900
@@ -104,7 +104,7 @@
 
 #define PTW32_LEVEL_MAX 3
 
-#if !defined(PTW32_LEVEL)
+#if ( defined(_POSIX_C_SOURCE) && _POSIX_C_SOURCE >= 200112 )  || !defined(PTW32_LEVEL)
 #define PTW32_LEVEL PTW32_LEVEL_MAX
 /* Include everything */
 #endif
@@ -537,7 +537,7 @@
 #  ifdef PTW32_BUILD
 #    define PTW32_DLLPORT __declspec (dllexport)
 #  else
-#    define PTW32_DLLPORT __declspec (dllimport)
+#    define PTW32_DLLPORT //__declspec (dllimport) this is not mandatory, and applications using flstatic and dll reaches here
 #  endif
 #else
 #  define PTW32_DLLPORT
@@ -1156,6 +1156,11 @@
 PTW32_DLLPORT int PTW32_CDECL pthread_win32_process_detach_np(void);
 PTW32_DLLPORT int PTW32_CDECL pthread_win32_thread_attach_np(void);
 PTW32_DLLPORT int PTW32_CDECL pthread_win32_thread_detach_np(void);
+/* real functions */
+PTW32_DLLPORT int PTW32_CDECL flpthread_win32_process_attach_np(void);
+PTW32_DLLPORT int PTW32_CDECL flpthread_win32_process_detach_np(void);
+PTW32_DLLPORT int PTW32_CDECL flpthread_win32_thread_attach_np(void);
+PTW32_DLLPORT int PTW32_CDECL flpthread_win32_thread_detach_np(void);
 
 /*
  * Features that are auto-detected at load/run time.
diff --binary -urN pthreads-w32-2-8-0-release_org/pthread_win32_attach_detach_np.c pthreads-w32-2-8-0-release/pthread_win32_attach_detach_np.c
--- pthreads-w32-2-8-0-release_org/pthread_win32_attach_detach_np.c	2006-12-22 11:36:40 +0900
+++ pthreads-w32-2-8-0-release/pthread_win32_attach_detach_np.c	2010-03-14 06:37:35 +0900
@@ -48,7 +48,7 @@
 static HINSTANCE ptw32_h_quserex;
 
 BOOL
-pthread_win32_process_attach_np ()
+flpthread_win32_process_attach_np ()
 {
   BOOL result = TRUE;
   DWORD_PTR vProcessCPUs;
@@ -202,7 +202,7 @@
 
 
 BOOL
-pthread_win32_process_detach_np ()
+flpthread_win32_process_detach_np ()
 {
   if (ptw32_processInitialized)
     {
@@ -256,13 +256,13 @@
 }
 
 BOOL
-pthread_win32_thread_attach_np ()
+flpthread_win32_thread_attach_np ()
 {
   return TRUE;
 }
 
 BOOL
-pthread_win32_thread_detach_np ()
+flpthread_win32_thread_detach_np ()
 {
   if (ptw32_processInitialized)
     {
diff --binary -urN pthreads-w32-2-8-0-release_org/ptw32_threadStart.c pthreads-w32-2-8-0-release/ptw32_threadStart.c
--- pthreads-w32-2-8-0-release_org/ptw32_threadStart.c	2005-05-16 00:28:27 +0900
+++ pthreads-w32-2-8-0-release/ptw32_threadStart.c	2010-03-14 08:32:21 +0900
@@ -110,7 +110,7 @@
 ptw32_terminate ()
 {
   set_terminate (ptw32_oldTerminate);
-  (void) pthread_win32_thread_detach_np ();
+  (void) flpthread_win32_thread_detach_np ();
   terminate ();
 }
 
@@ -306,7 +306,7 @@
     (void) pthread_mutex_lock (&sp->cancelLock);
     sp->state = PThreadStateException;
     (void) pthread_mutex_unlock (&sp->cancelLock);
-    (void) pthread_win32_thread_detach_np ();
+    (void) flpthread_win32_thread_detach_np ();
     (void) set_terminate (ptw32_oldTerminate);
     throw;
 
@@ -325,7 +325,7 @@
 #endif /* __CLEANUP_C */
 #endif /* __CLEANUP_SEH */
 
-#if defined(PTW32_STATIC_LIB)
+#if defined(PTW32_STATIC_LIB) && !defined(PTW32_FL_STATIC)
   /*
    * We need to cleanup the pthread now if we have
    * been statically linked, in which case the cleanup
diff --binary -urN pthreads-w32-2-8-0-release_org/ptw32_throw.c pthreads-w32-2-8-0-release/ptw32_throw.c
--- pthreads-w32-2-8-0-release_org/ptw32_throw.c	2005-05-16 00:28:27 +0900
+++ pthreads-w32-2-8-0-release/ptw32_throw.c	2010-03-14 08:32:51 +0900
@@ -85,9 +85,9 @@
 	  break;
 	}
 
-#if defined(PTW32_STATIC_LIB)
+#if defined(PTW32_STATIC_LIB) && !defined(PTW32_FL_STATIC)
 
-      pthread_win32_thread_detach_np ();
+      flpthread_win32_thread_detach_np ();
 
 #endif
 
diff --binary -urN pthreads-w32-2-8-0-release_org/sched.h pthreads-w32-2-8-0-release/sched.h
--- pthreads-w32-2-8-0-release_org/sched.h	2005-04-01 09:55:21 +0900
+++ pthreads-w32-2-8-0-release/sched.h	2010-03-15 18:40:43 +0900
@@ -60,7 +60,7 @@
 
 #define PTW32_LEVEL_MAX 3
 
-#if !defined(PTW32_LEVEL)
+#if ( defined(_POSIX_C_SOURCE) && _POSIX_C_SOURCE >= 200112 )  || !defined(PTW32_LEVEL)
 #define PTW32_LEVEL PTW32_LEVEL_MAX
 /* Include everything */
 #endif
@@ -80,7 +80,7 @@
 #  ifdef PTW32_BUILD
 #    define PTW32_DLLPORT __declspec (dllexport)
 #  else
-#    define PTW32_DLLPORT __declspec (dllimport)
+#    define PTW32_DLLPORT //__declspec (dllimport) this is not mandatory, and applications using flstatic and dll reaches here
 #  endif
 #else
 #  define PTW32_DLLPORT
@@ -119,6 +119,8 @@
 #  include <sys/types.h>
 /* Required by Unix 98 */
 #  include <time.h>
+#else
+typedef int pid_t;
 #endif /* PTW32_LEVEL >= PTW32_LEVEL_MAX */
 #else
 typedef int pid_t;
diff --binary -urN pthreads-w32-2-8-0-release_org/semaphore.h pthreads-w32-2-8-0-release/semaphore.h
--- pthreads-w32-2-8-0-release_org/semaphore.h	2005-04-01 09:55:21 +0900
+++ pthreads-w32-2-8-0-release/semaphore.h	2010-03-15 18:40:56 +0900
@@ -79,7 +79,7 @@
 #  ifdef PTW32_BUILD
 #    define PTW32_DLLPORT __declspec (dllexport)
 #  else
-#    define PTW32_DLLPORT __declspec (dllimport)
+#    define PTW32_DLLPORT //__declspec (dllimport) this is not mandatory, and applications using flstatic and dll reaches here
 #  endif
 #else
 #  define PTW32_DLLPORT
