nixpkgs mirror (for testing)
github.com/NixOS/nixpkgs
nix
1From 30534f48c6ede142dad0008d1641392d82b8a137 Mon Sep 17 00:00:00 2001
2From: Liu Hao <lh_mouse@126.com>
3Date: Mon, 18 Apr 2016 11:50:55 +0800
4Subject: [PATCH] Added 'mcf' thread model support from mcfgthread.
5
6Signed-off-by: Liu Hao <lh_mouse@126.com>
7---
8 config/gthr.m4 | 1 +
9 gcc/config.gcc | 3 +++
10 gcc/config/i386/mingw-mcfgthread.h | 1 +
11 gcc/config/i386/mingw-w64.h | 2 +-
12 gcc/config/i386/mingw32.h | 11 ++++++++++-
13 gcc/configure | 2 +-
14 gcc/configure.ac | 2 +-
15 libatomic/configure.tgt | 2 +-
16 libgcc/config.host | 6 ++++++
17 libgcc/config/i386/gthr-mcf.h | 1 +
18 libgcc/config/i386/t-mingw-mcfgthread | 2 ++
19 libgcc/configure | 1 +
20 libstdc++-v3/configure | 1 +
21 libstdc++-v3/libsupc++/atexit_thread.cc | 18 ++++++++++++++++++
22 libstdc++-v3/libsupc++/guard.cc | 23 +++++++++++++++++++++++
23 15 files changed, 71 insertions(+), 5 deletions(-)
24 create mode 100644 gcc/config/i386/mingw-mcfgthread.h
25 create mode 100644 libgcc/config/i386/gthr-mcf.h
26 create mode 100644 libgcc/config/i386/t-mingw-mcfgthread
27
28diff --git a/config/gthr.m4 b/config/gthr.m4
29index 7b29f1f3327..82e21fe1709 100644
30--- a/config/gthr.m4
31+++ b/config/gthr.m4
32@@ -21,6 +21,7 @@ case $1 in
33 tpf) thread_header=config/s390/gthr-tpf.h ;;
34 vxworks) thread_header=config/gthr-vxworks.h ;;
35 win32) thread_header=config/i386/gthr-win32.h ;;
36+ mcf) thread_header=config/i386/gthr-mcf.h ;;
37 esac
38 AC_SUBST(thread_header)
39 ])
40diff --git a/gcc/config.gcc b/gcc/config.gcc
41index 858b878d4b3..6f745790d64 100644
42--- a/gcc/config.gcc
43+++ b/gcc/config.gcc
44@@ -1722,6 +1722,9 @@ i[34567]86-*-mingw* | x86_64-*-mingw*)
45 if test x$enable_threads = xposix ; then
46 tm_file="${tm_file} i386/mingw-pthread.h"
47 fi
48+ if test x$enable_threads = xmcf ; then
49+ tm_file="${tm_file} i386/mingw-mcfgthread.h"
50+ fi
51 tm_file="${tm_file} i386/mingw32.h"
52 # This makes the logic if mingw's or the w64 feature set has to be used
53 case ${target} in
54diff --git a/gcc/config/i386/mingw-mcfgthread.h b/gcc/config/i386/mingw-mcfgthread.h
55new file mode 100644
56index 00000000000..ec381a7798f
57--- /dev/null
58+++ b/gcc/config/i386/mingw-mcfgthread.h
59@@ -0,0 +1 @@
60+#define TARGET_USE_MCFGTHREAD 1
61diff --git a/gcc/config/i386/mingw-w64.h b/gcc/config/i386/mingw-w64.h
62index fe11333a2d1..cac85802f38 100644
63--- a/gcc/config/i386/mingw-w64.h
64+++ b/gcc/config/i386/mingw-w64.h
65@@ -48,7 +48,7 @@ along with GCC; see the file COPYING3. If not see
66 "%{mwindows:-lgdi32 -lcomdlg32} " \
67 "%{fvtable-verify=preinit:-lvtv -lpsapi; \
68 fvtable-verify=std:-lvtv -lpsapi} " \
69- "-ladvapi32 -lshell32 -luser32 -lkernel32"
70+ LIB_MCFGTHREAD "-ladvapi32 -lshell32 -luser32 -lkernel32"
71
72 #undef SPEC_32
73 #undef SPEC_64
74diff --git a/gcc/config/i386/mingw32.h b/gcc/config/i386/mingw32.h
75index e04818966fa..7b75a372506 100644
76--- a/gcc/config/i386/mingw32.h
77+++ b/gcc/config/i386/mingw32.h
78@@ -32,6 +32,14 @@ along with GCC; see the file COPYING3. If not see
79 | MASK_STACK_PROBE | MASK_ALIGN_DOUBLE \
80 | MASK_MS_BITFIELD_LAYOUT)
81
82+#ifndef TARGET_USE_MCFGTHREAD
83+#define CPP_MCFGTHREAD() ((void)0)
84+#define LIB_MCFGTHREAD ""
85+#else
86+#define CPP_MCFGTHREAD() (builtin_define("__USING_MCFGTHREAD__"))
87+#define LIB_MCFGTHREAD " -lmcfgthread "
88+#endif
89+
90 /* See i386/crtdll.h for an alternative definition. _INTEGRAL_MAX_BITS
91 is for compatibility with native compiler. */
92 #define EXTRA_OS_CPP_BUILTINS() \
93@@ -50,6 +58,7 @@ along with GCC; see the file COPYING3. If not see
94 builtin_define_std ("WIN64"); \
95 builtin_define ("_WIN64"); \
96 } \
97+ CPP_MCFGTHREAD(); \
98 } \
99 while (0)
100
101@@ -93,7 +102,7 @@ along with GCC; see the file COPYING3. If not see
102 "%{mwindows:-lgdi32 -lcomdlg32} " \
103 "%{fvtable-verify=preinit:-lvtv -lpsapi; \
104 fvtable-verify=std:-lvtv -lpsapi} " \
105- "-ladvapi32 -lshell32 -luser32 -lkernel32"
106+ LIB_MCFGTHREAD "-ladvapi32 -lshell32 -luser32 -lkernel32"
107
108 /* Weak symbols do not get resolved if using a Windows dll import lib.
109 Make the unwind registration references strong undefs. */
110diff --git a/gcc/configure b/gcc/configure
111index 954673c1c43..6b5667f1c70 100755
112--- a/gcc/configure
113+++ b/gcc/configure
114@@ -11702,7 +11702,7 @@ case ${enable_threads} in
115 target_thread_file='single'
116 ;;
117 aix | dce | lynx | mipssde | posix | rtems | \
118- single | tpf | vxworks | win32)
119+ single | tpf | vxworks | win32 | mcf)
120 target_thread_file=${enable_threads}
121 ;;
122 *)
123diff --git a/gcc/configure.ac b/gcc/configure.ac
124index 4c65d441e72..e6fa04ada4f 100644
125--- a/gcc/configure.ac
126+++ b/gcc/configure.ac
127@@ -1593,7 +1593,7 @@ case ${enable_threads} in
128 target_thread_file='single'
129 ;;
130 aix | dce | lynx | mipssde | posix | rtems | \
131- single | tpf | vxworks | win32)
132+ single | tpf | vxworks | win32 | mcf)
133 target_thread_file=${enable_threads}
134 ;;
135 *)
136diff --git a/libatomic/configure.tgt b/libatomic/configure.tgt
137index eab2765d7fd..f4058b6f4a2 100644
138--- a/libatomic/configure.tgt
139+++ b/libatomic/configure.tgt
140@@ -124,7 +124,7 @@ case "${target}" in
141 *-*-mingw*)
142 # OS support for atomic primitives.
143 case ${target_thread_file} in
144- win32)
145+ win32 | mcf)
146 config_path="${config_path} mingw"
147 ;;
148 posix)
149diff --git a/libgcc/config.host b/libgcc/config.host
150index 2b139b8befc..fb18d2a042e 100644
151--- a/libgcc/config.host
152+++ b/libgcc/config.host
153@@ -712,6 +712,9 @@ i[34567]86-*-mingw*)
154 posix)
155 tmake_file="i386/t-mingw-pthread $tmake_file"
156 ;;
157+ mcf)
158+ tmake_file="i386/t-mingw-mcfgthread $tmake_file"
159+ ;;
160 esac
161 # This has to match the logic for DWARF2_UNWIND_INFO in gcc/config/i386/cygming.h
162 if test x$ac_cv_sjlj_exceptions = xyes; then
163@@ -736,6 +739,9 @@ x86_64-*-mingw*)
164 posix)
165 tmake_file="i386/t-mingw-pthread $tmake_file"
166 ;;
167+ mcf)
168+ tmake_file="i386/t-mingw-mcfgthread $tmake_file"
169+ ;;
170 esac
171 # This has to match the logic for DWARF2_UNWIND_INFO in gcc/config/i386/cygming.h
172 if test x$ac_cv_sjlj_exceptions = xyes; then
173diff --git a/libgcc/config/i386/gthr-mcf.h b/libgcc/config/i386/gthr-mcf.h
174new file mode 100644
175index 00000000000..5ea2908361f
176--- /dev/null
177+++ b/libgcc/config/i386/gthr-mcf.h
178@@ -0,0 +1 @@
179+#include <mcfgthread/gthread.h>
180diff --git a/libgcc/config/i386/t-mingw-mcfgthread b/libgcc/config/i386/t-mingw-mcfgthread
181new file mode 100644
182index 00000000000..4b9b10e32d6
183--- /dev/null
184+++ b/libgcc/config/i386/t-mingw-mcfgthread
185@@ -0,0 +1,2 @@
186+SHLIB_PTHREAD_CFLAG =
187+SHLIB_PTHREAD_LDFLAG = -lmcfgthread
188diff --git a/libgcc/configure b/libgcc/configure
189index e7d6c75a6f7..664d0f852c4 100644
190--- a/libgcc/configure
191+++ b/libgcc/configure
192@@ -5077,6 +5077,7 @@ case $target_thread_file in
193 tpf) thread_header=config/s390/gthr-tpf.h ;;
194 vxworks) thread_header=config/gthr-vxworks.h ;;
195 win32) thread_header=config/i386/gthr-win32.h ;;
196+ mcf) thread_header=config/i386/gthr-mcf.h ;;
197 esac
198
199
200diff --git a/libstdc++-v3/configure b/libstdc++-v3/configure
201index b5ae4213f94..c484d3aee5f 100755
202--- a/libstdc++-v3/configure
203+++ b/libstdc++-v3/configure
204@@ -15177,6 +15177,7 @@ case $target_thread_file in
205 tpf) thread_header=config/s390/gthr-tpf.h ;;
206 vxworks) thread_header=config/gthr-vxworks.h ;;
207 win32) thread_header=config/i386/gthr-win32.h ;;
208+ mcf) thread_header=config/i386/gthr-mcf.h ;;
209 esac
210
211
212diff --git a/libstdc++-v3/libsupc++/atexit_thread.cc b/libstdc++-v3/libsupc++/atexit_thread.cc
213index e6520c1094f..3d6907796dd 100644
214--- a/libstdc++-v3/libsupc++/atexit_thread.cc
215+++ b/libstdc++-v3/libsupc++/atexit_thread.cc
216@@ -25,6 +25,22 @@
217 #include <cstdlib>
218 #include <new>
219 #include "bits/gthr.h"
220+
221+#ifdef __USING_MCFGTHREAD__
222+
223+#include <mcfgthread/gthread.h>
224+
225+extern "C" int
226+__cxxabiv1::__cxa_thread_atexit (void (*dtor)(void *),
227+ void *obj, void *dso_handle)
228+ _GLIBCXX_NOTHROW
229+{
230+ return ::_MCFCRT_AtThreadExit((void (*)(_MCFCRT_STD intptr_t))dtor, (_MCFCRT_STD intptr_t)obj) ? 0 : -1;
231+ (void)dso_handle;
232+}
233+
234+#else // __USING_MCFGTHREAD__
235+
236 #ifdef _GLIBCXX_THREAD_ATEXIT_WIN32
237 #define WIN32_LEAN_AND_MEAN
238 #include <windows.h>
239@@ -163,3 +179,5 @@ __cxxabiv1::__cxa_thread_atexit (void (*dtor)(void *), void *obj, void */*dso_ha
240 }
241
242 #endif /* _GLIBCXX_HAVE___CXA_THREAD_ATEXIT_IMPL */
243+
244+#endif // __USING_MCFGTHREAD__
245diff --git a/libstdc++-v3/libsupc++/guard.cc b/libstdc++-v3/libsupc++/guard.cc
246index 9b617998ffe..a441fdbb616 100644
247--- a/libstdc++-v3/libsupc++/guard.cc
248+++ b/libstdc++-v3/libsupc++/guard.cc
249@@ -28,6 +28,27 @@
250 #include <cxxabi.h>
251 #include <exception>
252 #include <new>
253+
254+#ifdef __USING_MCFGTHREAD__
255+
256+#include <mcfgthread/gthread.h>
257+
258+namespace __cxxabiv1 {
259+
260+extern "C" int __cxa_guard_acquire(__guard *g){
261+ return ::_MCFCRT_WaitForOnceFlagForever((::_MCFCRT_OnceFlag *)g) == ::_MCFCRT_kOnceResultInitial;
262+}
263+extern "C" void __cxa_guard_abort(__guard *g) throw() {
264+ ::_MCFCRT_SignalOnceFlagAsAborted((::_MCFCRT_OnceFlag *)g);
265+}
266+extern "C" void __cxa_guard_release(__guard *g) throw() {
267+ ::_MCFCRT_SignalOnceFlagAsFinished((::_MCFCRT_OnceFlag *)g);
268+}
269+
270+}
271+
272+#else // __USING_MCFGTHREAD__
273+
274 #include <ext/atomicity.h>
275 #include <ext/concurrence.h>
276 #if defined(__GTHREADS) && defined(__GTHREAD_HAS_COND) \
277@@ -424,3 +445,5 @@ namespace __cxxabiv1
278 #endif
279 }
280 }
281+
282+#endif
283--
2842.12.1
285