From 8ff97a3f6efcb8c813a5f13c0bd74cb73ce5fcd0 Mon Sep 17 00:00:00 2001
From: lhmouse <lh_mouse@126.com>
Date: Mon, 18 Apr 2016 11:50:55 +0800
Subject: [PATCH] Added 'mcf' thread model support from mcfgthread.

---
 config/gthr.m4                        | 1 +
 gcc/configure                         | 2 +-
 gcc/configure.ac                      | 2 +-
 libgcc/config.host                    | 6 ++++++
 libgcc/config/i386/gthr-mcf.h         | 1 +
 libgcc/config/i386/t-mingw-mcfgthread | 2 ++
 libgcc/configure                      | 1 +
 libstdc++-v3/configure                | 1 +
 8 files changed, 14 insertions(+), 2 deletions(-)
 create mode 100644 libgcc/config/i386/gthr-mcf.h
 create mode 100644 libgcc/config/i386/t-mingw-mcfgthread

diff --git a/config/gthr.m4 b/config/gthr.m4
index 7b29f1f..82e21fe 100644
--- a/config/gthr.m4
+++ b/config/gthr.m4
@@ -21,6 +21,7 @@ case $1 in
     tpf)	thread_header=config/s390/gthr-tpf.h ;;
     vxworks)	thread_header=config/gthr-vxworks.h ;;
     win32)	thread_header=config/i386/gthr-win32.h ;;
+    mcf)	thread_header=config/i386/gthr-mcf.h ;;
 esac
 AC_SUBST(thread_header)
 ])
diff --git a/gcc/configure b/gcc/configure
index 3c92795..668c7ae 100755
--- a/gcc/configure
+++ b/gcc/configure
@@ -11415,7 +11415,7 @@ case ${enable_threads} in
     target_thread_file='single'
     ;;
   aix | dce | lynx | mipssde | posix | rtems | \
-  single | tpf | vxworks | win32)
+  single | tpf | vxworks | win32 | mcf)
     target_thread_file=${enable_threads}
     ;;
   *)
diff --git a/gcc/configure.ac b/gcc/configure.ac
index d414081..a960a21 100644
--- a/gcc/configure.ac
+++ b/gcc/configure.ac
@@ -1535,7 +1535,7 @@ case ${enable_threads} in
     target_thread_file='single'
     ;;
   aix | dce | lynx | mipssde | posix | rtems | \
-  single | tpf | vxworks | win32)
+  single | tpf | vxworks | win32 | mcf)
     target_thread_file=${enable_threads}
     ;;
   *)
diff --git a/libgcc/config.host b/libgcc/config.host
index 4329891..7b2e49e 100644
--- a/libgcc/config.host
+++ b/libgcc/config.host
@@ -682,6 +682,9 @@ i[34567]86-*-mingw*)
 	  posix)
 	    tmake_file="i386/t-mingw-pthread $tmake_file"
 	    ;;
+	  mcf)
+	    tmake_file="i386/t-mingw-mcf $tmake_file"
+	    ;;
 	esac
 	# This has to match the logic for DWARF2_UNWIND_INFO in gcc/config/i386/cygming.h
 	if test x$enable_sjlj_exceptions = xyes; then
@@ -706,6 +709,9 @@ x86_64-*-mingw*)
 	  posix)
 	    tmake_file="i386/t-mingw-pthread $tmake_file"
 	    ;;
+	  mcf)
+	    tmake_file="i386/t-mingw-mcf $tmake_file"
+	    ;;
 	esac
 	# This has to match the logic for DWARF2_UNWIND_INFO in gcc/config/i386/cygming.h
 	if test x$enable_sjlj_exceptions = xyes; then
diff --git a/libgcc/config/i386/gthr-mcf.h b/libgcc/config/i386/gthr-mcf.h
new file mode 100644
index 0000000..5ea2908
--- /dev/null
+++ b/libgcc/config/i386/gthr-mcf.h
@@ -0,0 +1 @@
+#include <mcfgthread/env/gthread.h>
diff --git a/libgcc/config/i386/t-mingw-mcfgthread b/libgcc/config/i386/t-mingw-mcfgthread
new file mode 100644
index 0000000..041cfc1
--- /dev/null
+++ b/libgcc/config/i386/t-mingw-mcfgthread
@@ -0,0 +1,2 @@
+SHLIB_PTHREAD_CFLAG = -lmcfgthread
+SHLIB_PTHREAD_LDFLAG = -Wl,-lmcfgthread
diff --git a/libgcc/configure b/libgcc/configure
index 203d384..a322158 100644
--- a/libgcc/configure
+++ b/libgcc/configure
@@ -5060,6 +5060,7 @@ case $target_thread_file in
     tpf)	thread_header=config/s390/gthr-tpf.h ;;
     vxworks)	thread_header=config/gthr-vxworks.h ;;
     win32)	thread_header=config/i386/gthr-win32.h ;;
+    mcf)	thread_header=config/i386/gthr-mcf.h ;;
 esac
 
 
diff --git a/libstdc++-v3/configure b/libstdc++-v3/configure
index 8cd4c76..d048d5c 100755
--- a/libstdc++-v3/configure
+++ b/libstdc++-v3/configure
@@ -15265,6 +15265,7 @@ case $target_thread_file in
     tpf)	thread_header=config/s390/gthr-tpf.h ;;
     vxworks)	thread_header=config/gthr-vxworks.h ;;
     win32)	thread_header=config/i386/gthr-win32.h ;;
+    mcf)	thread_header=config/i386/gthr-mcf.h ;;
 esac
 
 
-- 
2.8.1

