Hi, all
I have successfully built mingw64 gcc4.6.2 prerelease with
std::thread using posix thread modal.
I test the code, and this works:
-----------------------------------------------------
#include <iostream>
#include <thread>
void thanks()
{
std::cout << "Thank you for your reading.\n";
};
int main()
{
std::thread t( thanks );
t.join();
return 0;
}
------------------------------------------------------
Here is my patch:
------------------------------------------------------
diff -ruNa old/gcc/config/i386/mingw32.h build/gcc/config/i386/mingw32.h
--- old/gcc/config/i386/mingw32.h 2010-09-30 02:55:44 +0800
+++ build/gcc/config/i386/mingw32.h 2011-08-27 19:14:57 +0800
@@ -114,7 +114,7 @@
#define REAL_LIBGCC_SPEC \
"%{mthreads:-lmingwthrd} -lmingw32 \
"SHARED_LIBGCC_SPEC" \
- -lgcc \
+ -lgcc -lpthread \
-lmoldname -lmingwex -lmsvcrt"
#undef STARTFILE_SPEC
@@ -169,7 +169,8 @@
/* mingw32 uses the -mthreads option to enable thread support. */
#undef GOMP_SELF_SPECS
-#define GOMP_SELF_SPECS "%{fopenmp: -mthreads}"
+#define GOMP_SELF_SPECS "%{fopenmp|ftree-parallelize-loops=*: " \
+ "-mthreads -lpthread}"
/* mingw32 atexit function is safe to use in shared libraries. Use it
to register C++ static destructors. */
diff -ruNa old/gcc/gthr-posix.h build/gcc/gthr-posix.h
--- old/gcc/gthr-posix.h 2011-01-04 04:52:22 +0800
+++ build/gcc/gthr-posix.h 2011-08-27 22:19:16 +0800
@@ -32,6 +32,7 @@
#define __GTHREADS 1
#define __GTHREADS_CXX0X 1
+#define _POSIX_TIMEOUTS 1
/* Some implementations of <pthread.h> require this to be defined. */
#if !defined(_REENTRANT) && defined(__osf__)
diff -ruNa old/gcc/gthr.h build/gcc/gthr.h
--- old/gcc/gthr.h 2009-11-25 18:55:54 +0800
+++ build/gcc/gthr.h 2011-08-27 22:19:41 +0800
@@ -30,6 +30,10 @@
#pragma GCC visibility push(default)
#endif
+#define __GTHREADS 1
+#define __GTHREADS_CXX0X 1
+#define _POSIX_TIMEOUTS 1
+
/* If this file is compiled with threads support, it must
#define __GTHREADS 1
to indicate that threads support is present. Also it has define
diff -ruNa old/libstdc++-v3/config/os/mingw32/error_constants.h
build/libstdc++-v3/config/os/mingw32/error_constants.h
--- old/libstdc++-v3/config/os/mingw32/error_constants.h 2011-01-31
06:39:36 +0800
+++ build/libstdc++-v3/config/os/mingw32/error_constants.h 2011-08-27
23:58:11 +0800
@@ -99,7 +99,7 @@
// not_supported = ENOTSUP,
// operation_canceled = ECANCELED,
// operation_in_progress = EINPROGRESS,
-// operation_not_permitted = EPERM,
+ operation_not_permitted = EPERM,
// operation_not_supported = EOPNOTSUPP,
// operation_would_block = EWOULDBLOCK,
// owner_dead = EOWNERDEAD,
--------------------------------------------------------------------------
You must configure gcc with "--enable-threads=posix", and should
use Kai's winpthreads.
--
Best Regards,
PcX
diff -ruNa old/gcc/config/i386/mingw32.h build/gcc/config/i386/mingw32.h
--- old/gcc/config/i386/mingw32.h 2010-09-30 02:55:44 +0800
+++ build/gcc/config/i386/mingw32.h 2011-08-27 19:14:57 +0800
@@ -114,7 +114,7 @@
#define REAL_LIBGCC_SPEC \
"%{mthreads:-lmingwthrd} -lmingw32 \
"SHARED_LIBGCC_SPEC" \
- -lgcc \
+ -lgcc -lpthread \
-lmoldname -lmingwex -lmsvcrt"
#undef STARTFILE_SPEC
@@ -169,7 +169,8 @@
/* mingw32 uses the -mthreads option to enable thread support. */
#undef GOMP_SELF_SPECS
-#define GOMP_SELF_SPECS "%{fopenmp: -mthreads}"
+#define GOMP_SELF_SPECS "%{fopenmp|ftree-parallelize-loops=*: " \
+ "-mthreads -lpthread}"
/* mingw32 atexit function is safe to use in shared libraries. Use it
to register C++ static destructors. */
diff -ruNa old/gcc/gthr-posix.h build/gcc/gthr-posix.h
--- old/gcc/gthr-posix.h 2011-01-04 04:52:22 +0800
+++ build/gcc/gthr-posix.h 2011-08-27 22:19:16 +0800
@@ -32,6 +32,7 @@
#define __GTHREADS 1
#define __GTHREADS_CXX0X 1
+#define _POSIX_TIMEOUTS 1
/* Some implementations of <pthread.h> require this to be defined. */
#if !defined(_REENTRANT) && defined(__osf__)
diff -ruNa old/gcc/gthr.h build/gcc/gthr.h
--- old/gcc/gthr.h 2009-11-25 18:55:54 +0800
+++ build/gcc/gthr.h 2011-08-27 22:19:41 +0800
@@ -30,6 +30,10 @@
#pragma GCC visibility push(default)
#endif
+#define __GTHREADS 1
+#define __GTHREADS_CXX0X 1
+#define _POSIX_TIMEOUTS 1
+
/* If this file is compiled with threads support, it must
#define __GTHREADS 1
to indicate that threads support is present. Also it has define
diff -ruNa old/libstdc++-v3/config/os/mingw32/error_constants.h build/libstdc++-v3/config/os/mingw32/error_constants.h
--- old/libstdc++-v3/config/os/mingw32/error_constants.h 2011-01-31 06:39:36 +0800
+++ build/libstdc++-v3/config/os/mingw32/error_constants.h 2011-08-27 23:58:11 +0800
@@ -99,7 +99,7 @@
// not_supported = ENOTSUP,
// operation_canceled = ECANCELED,
// operation_in_progress = EINPROGRESS,
-// operation_not_permitted = EPERM,
+ operation_not_permitted = EPERM,
// operation_not_supported = EOPNOTSUPP,
// operation_would_block = EWOULDBLOCK,
// owner_dead = EOWNERDEAD,
------------------------------------------------------------------------------
EMC VNX: the world's simplest storage, starting under $10K
The only unified storage solution that offers unified management
Up to 160% more powerful than alternatives and 25% more efficient.
Guaranteed. http://p.sf.net/sfu/emc-vnx-dev2dev
_______________________________________________
Mingw-w64-public mailing list
Mingw-w64-public@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/mingw-w64-public