+#
+# Conditional build:
+%bcond_without tests # perform test build
+#
Summary: C++11 threading classes implementation for MinGW
Summary(pl.UTF-8): Implementacja klas C++11 związanych z wątkami dla MinGW
Name: crossmingw32-std-threads
Version: 0
-%define gitref b7e670d91d33b7ce5836c6255d37e69f17eb3687
-%define snap 20160317
+%define gitref ee67ef384470e998c8e0b7301f7a79b5019251a2
+%define snap 20180912
Release: 0.%{snap}.1
License: BSD
Group: Development/Libraries
Source0: https://github.com/meganz/mingw-std-threads/archive/%{gitref}/mingw-std-threads-%{snap}.tar.gz
-# Source0-md5: e5f0fcdb69d99ab493f45e65767f9346
+# Source0-md5: c55d7a463149d803535b71c6bb1346cb
Patch0: mingw-std-threads-include.patch
+Patch1: mingw-std-threads-errors.patch
URL: https://github.com/meganz/mingw-std-threads
+%if %{with tests}
+BuildRequires: crossmingw32-gcc-c++ >= 1:4.7
+%endif
Requires: crossmingw32-gcc-c++ >= 1:4.7
Requires: crossmingw32-runtime
Requires: crossmingw32-w32api
%define target i386-mingw32
%define target_platform i386-pc-mingw32
+%define __cc %{target}-gcc
+%define __cxx %{target}-g++
+
%define _sysprefix /usr
%define _prefix %{_sysprefix}/%{target}
+%ifnarch %{ix86}
+# arch-specific flags (like alpha's -mieee) are not valid for i386 gcc.
+# now at least i486 is required for atomic operations
+%define optflags -O2
+%endif
+# -z options are invalid for mingw linker, most of -f options are Linux-specific
+%define filterout_ld -Wl,-z,.*
+%define filterout_c -f[-a-z0-9=]*
+%define filterout_cxx -f[-a-z0-9=]*
+
%description
Standard C++11 threading classes (std::condition_variable, std::mutex,
std::thread) implementation, which are currently still missing on
%prep
%setup -q -n mingw-std-threads-%{gitref}
%patch0 -p1
+%patch1 -p1
+
+%build
+%if %{with tests}
+install -d tests/build
+cd tests/build
+CC="%{__cc}" \
+CXX="%{__cxx}" \
+cmake .. \
+ -DCMAKE_BUILD_TYPE=PLD \
+ -DCMAKE_CXX_FLAGS_PLD="%{rpmcxxflags} -DWINVER=0x0501" \
+ -DCMAKE_SYSTEM_NAME=Windows \
+ -DCMAKE_SYSTEM_PROCESSOR=i386 \
+ -DCMAKE_VERBOSE_MAKEFILE=ON
+
+%{__make}
+%endif
%install
rm -rf $RPM_BUILD_ROOT
--- /dev/null
+--- mingw-std-threads-ee67ef384470e998c8e0b7301f7a79b5019251a2/mingw.condition_variable.h.orig 2018-09-11 17:06:14.000000000 +0200
++++ mingw-std-threads-ee67ef384470e998c8e0b7301f7a79b5019251a2/mingw.condition_variable.h 2018-10-03 21:35:48.633130795 +0200
+@@ -105,7 +105,7 @@
+ else\r
+ {\r
+ using namespace std;\r
+- throw system_error(make_error_code(errc::protocol_error));\r
++ throw system_error(make_error_code(errc::invalid_argument));\r
+ }\r
+ }\r
+ public:\r
+--- reads-ee67ef384470e998c8e0b7301f7a79b5019251a2/mingw.mutex.h.orig 2018-09-11 17:06:14.000000000 +0200
++++ reads-ee67ef384470e998c8e0b7301f7a79b5019251a2/mingw.mutex.h 2018-10-03 21:40:38.086460829 +0200
+@@ -300,9 +300,9 @@
+ case WAIT_OBJECT_0:\r
+ return true;\r
+ case WAIT_ABANDONED:\r
+- throw system_error(make_error_code(errc::owner_dead));\r
++ throw system_error(make_error_code(errc::no_such_process));\r
+ default:\r
+- throw system_error(make_error_code(errc::protocol_error));\r
++ throw system_error(make_error_code(errc::invalid_argument));\r
+ }\r
+ }\r
+ protected:\r
---- mingw-std-threads-b7e670d91d33b7ce5836c6255d37e69f17eb3687/mingw.mutex.h.orig 2016-03-16 15:05:58.000000000 +0100
-+++ mingw-std-threads-b7e670d91d33b7ce5836c6255d37e69f17eb3687/mingw.mutex.h 2016-06-25 09:17:48.884289745 +0200
-@@ -41,6 +41,7 @@
- \r
- #include <windows.h>\r
- #include <chrono>\r
-+#include <cstdio>\r
- #include <system_error>\r
- \r
- #ifndef EPROTO\r
-@@ -105,7 +106,7 @@
- DWORD self = GetCurrentThreadId();\r
- if (mOwnerThread == self)\r
- {\r
-- fprintf(stderr, "FATAL: Recursive locking or non-recursive mutex detected. Throwing sysetm exception\n");\r
-+ fprintf(stderr, "FATAL: Recursive locking or non-recursive mutex detected. Throwing system exception\n");\r
- fflush(stderr);\r
- throw system_error(EDEADLK, generic_category());\r
- }\r
+--- mingw-std-threads-ee67ef384470e998c8e0b7301f7a79b5019251a2/mingw.shared_mutex.h.orig 2018-09-11 17:06:14.000000000 +0200
++++ mingw-std-threads-ee67ef384470e998c8e0b7301f7a79b5019251a2/mingw.shared_mutex.h 2018-10-04 20:56:12.195504727 +0200
+@@ -32,6 +32,7 @@
+ #endif
+
+ #include <cassert>
++#include <climits>
+
+ // Use MinGW's shared_lock class template, if it's available. Requires C++14.
+ // If unavailable (eg. because this library is being used in C++11), then an