summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorScott <[email protected]>2016-06-27 12:29:59 +0100
committerGitHub <[email protected]>2016-06-27 12:29:59 +0100
commitb9e7a2ab2056bf09df433c7c52b00e7b1bb103f3 (patch)
treebbed959d4077a1d74ae286ba13f3e2ac97841ac9
parent700b4f8b1de4d73ffe2a9237885f8b6547eb0607 (diff)
parent1a7e20a441f789da4d7fd8b09e6eda10549b5fcb (diff)
Merge pull request #232 from bradleysepos/mingw
Update to mingw-w64 5.0-rc2 and pthreads-win32 2.9.1.
-rw-r--r--contrib/fontconfig/P00-mingw-emmintrin.patch56
-rw-r--r--contrib/harfbuzz/P00-mingw-emmintrin.patch11
-rw-r--r--contrib/libiconv/module.defs12
-rw-r--r--contrib/pthreadw32/P00-mingw-w64.patch1457
-rw-r--r--contrib/pthreadw32/module.defs20
-rw-r--r--libhb/ports.c4
-rw-r--r--make/include/tool.defs1
-rwxr-xr-xscripts/mingw-w64-build440
8 files changed, 527 insertions, 1474 deletions
diff --git a/contrib/fontconfig/P00-mingw-emmintrin.patch b/contrib/fontconfig/P00-mingw-emmintrin.patch
new file mode 100644
index 000000000..758f46b69
--- /dev/null
+++ b/contrib/fontconfig/P00-mingw-emmintrin.patch
@@ -0,0 +1,56 @@
+diff -Naur fontconfig-2.11.94.orig/src/fccache.c fontconfig-2.11.94/src/fccache.c
+--- fontconfig-2.11.94.orig/src/fccache.c 2015-05-27 23:53:27 +0000
++++ fontconfig-2.11.94/src/fccache.c 2016-06-15 12:00:00 +0000
+@@ -34,6 +34,7 @@
+ # include <unistd.h>
+ # include <sys/mman.h>
+ #endif
++#include <emmintrin.h>
+
+ #ifndef O_BINARY
+ #define O_BINARY 0
+diff -Naur fontconfig-2.11.94.orig/src/fccfg.c fontconfig-2.11.94/src/fccfg.c
+--- fontconfig-2.11.94.orig/src/fccfg.c 2015-04-09 00:19:17 +0000
++++ fontconfig-2.11.94/src/fccfg.c 2014-06-15 12:00:00 +0000
+@@ -27,6 +27,7 @@
+ #include "fcint.h"
+ #include <dirent.h>
+ #include <sys/types.h>
++#include <emmintrin.h>
+ #include "../fc-blanks/fcblanks.h"
+
+ #if defined (_WIN32) && !defined (R_OK)
+diff -Naur fontconfig-2.11.94.orig/src/fcxml.c fontconfig-2.11.94/src/fcxml.c
+--- fontconfig-2.11.94.orig/src/fcxml.c 2015-05-28 05:53:27.000000000 +0000
++++ fontconfig-2.11.94/src/fcxml.c 2016-06-15 12:00:00 +0000
+@@ -26,6 +26,7 @@
+ #include <fcntl.h>
+ #include <stdarg.h>
+ #include <dirent.h>
++#include <emmintrin.h>
+
+ #ifdef ENABLE_LIBXML2
+
+diff -Naur fontconfig-2.11.0/src/fcdefault.c fontconfig-2.11.0.new/src/fcdefault.c
+--- fontconfig-2.11.0/src/fcdefault.c 2013-10-11 03:10:18 +0000
++++ fontconfig-2.11.0.new/src/fcdefault.c 2014-02-15 18:44:53 +0000
+@@ -25,6 +25,7 @@
+ #include "fcint.h"
+ #include <limits.h>
+ #include <string.h>
++#include <emmintrin.h>
+
+ /* MT-safe */
+
+diff -Naur fontconfig-2.11.0/src/fcobjs.c fontconfig-2.11.0.new/src/fcobjs.c
+--- fontconfig-2.11.0/src/fcobjs.c 2013-10-11 03:10:18 +0000
++++ fontconfig-2.11.0.new/src/fcobjs.c 2014-02-15 18:45:17 +0000
+@@ -33,6 +33,7 @@
+ #include "fcobjshash.h"
+
+ #include <string.h>
++#include <emmintrin.h>
+
+ /* The 1000 is to leave some room for future added internal objects, such
+ * that caches from newer fontconfig can still be used with older fontconfig
+
diff --git a/contrib/harfbuzz/P00-mingw-emmintrin.patch b/contrib/harfbuzz/P00-mingw-emmintrin.patch
new file mode 100644
index 000000000..60d1e16ad
--- /dev/null
+++ b/contrib/harfbuzz/P00-mingw-emmintrin.patch
@@ -0,0 +1,11 @@
+diff -Naur harfbuzz-1.2.6.orig/src/hb.h harfbuzz-1.2.6/src/hb.h
+--- harfbuzz-1.2.6.orig/src/hb.h 2016-01-06 04:00:36.000000000 -0800
++++ harfbuzz-1.2.6/src/hb.h 2016-06-15 05:30:43.212202580 -0700
+@@ -32,6 +32,7 @@
+ #define HB_EXTERN extern
+ #endif
+
++#include <emmintrin.h>
+ #include "hb-blob.h"
+ #include "hb-buffer.h"
+ #include "hb-common.h"
diff --git a/contrib/libiconv/module.defs b/contrib/libiconv/module.defs
index e7116afac..411b6e0b1 100644
--- a/contrib/libiconv/module.defs
+++ b/contrib/libiconv/module.defs
@@ -1,15 +1,11 @@
$(eval $(call import.MODULE.defs,LIBICONV,libiconv))
$(eval $(call import.CONTRIB.defs,LIBICONV))
-LIBICONV.FETCH.url = http://download.handbrake.fr/handbrake/contrib/libiconv-1.13.tar.gz
-LIBICONV.FETCH.url += http://ftp.gnu.org/gnu/libiconv/libiconv-1.13.tar.gz
-LIBICONV.FETCH.md5 = 048032a3032ebd182150bdee30a5d533
-
-# TODO: libiconv >= 1.14
-#LIBICONV.FETCH.url = http://ftp.gnu.org/gnu/libiconv/libiconv-1.14.tar.gz
-#LIBICONV.FETCH.md5 = e34509b1623cec449dfeb73d7ce9c6c6
+LIBICONV.FETCH.url = http://download.handbrake.fr/handbrake/contrib/libiconv-1.14.tar.gz
+LIBICONV.FETCH.url += https://ftp.gnu.org/gnu/libiconv/libiconv-1.14.tar.gz
+LIBICONV.FETCH.md5 = e34509b1623cec449dfeb73d7ce9c6c6
# this contrib will not build under MinGW with -std=gnu99
ifeq (1-mingw,$(BUILD.cross)-$(BUILD.system))
- LIBICONV.GCC.args.c_std =
+ LIBICONV.GCC.args.c_std = -std=gnu89
endif
diff --git a/contrib/pthreadw32/P00-mingw-w64.patch b/contrib/pthreadw32/P00-mingw-w64.patch
deleted file mode 100644
index 1d4b96884..000000000
--- a/contrib/pthreadw32/P00-mingw-w64.patch
+++ /dev/null
@@ -1,1457 +0,0 @@
-# Bazaar merge directive format 2 (Bazaar 0.90)
-# revision_id: [email protected]\
-# 1vpsymidgi7alpwt
-# target_branch: ../pthreads.bzr/
-# testament_sha1: 521ee14bce6f871b77f9d6797b4460612a673359
-# timestamp: 2010-07-11 02:10:15 +0100
-# source_branch: .
-# base_revision_id: git-v1:fe3f4b4cd92c4d6fc37139dd6cf8214c558676ca
-#
-# Begin patch
-=== modified file 'GNUmakefile'
---- pthreadw32/GNUmakefile 2010-06-20 03:31:18 +0000
-+++ pthreadw32/GNUmakefile 2010-07-10 23:29:46 +0000
-@@ -49,14 +49,27 @@
-
- # For cross compiling use e.g.
- # make CROSS=i386-mingw32msvc- clean GC-inlined
--CROSS =
--
--AR = $(CROSS)ar
--DLLTOOL = $(CROSS)dlltool
--CC = $(CROSS)gcc
--CXX = $(CROSS)g++
--RANLIB = $(CROSS)ranlib
--RC = $(CROSS)windres
-+target =
-+prefix = /usr/local
-+
-+ifeq (,$(findstring x86_64, $(target)))
-+#32bit
-+BITNESS=-m32
-+DLLFLAG=-m i386
-+WINDRESFLAG=pe-i386
-+else
-+#64bit
-+BITNESS=-m64
-+DLLFLAG=-m i386:x86-64
-+WINDRESFLAG=pe-x86-64
-+endif
-+
-+AR = $(target)ar
-+DLLTOOL = $(target)dlltool $(DLLFLAG)
-+CC = $(target)gcc $(BITNESS)
-+CXX = $(target)g++ $(BITNESS)
-+RANLIB = $(target)ranlib
-+RC = $(target)windres -F $(WINDRESFLAG)
-
- OPT = $(CLEANUP) -O3 -finline-functions
- DOPT = $(CLEANUP) -g -O0
-@@ -268,7 +281,7 @@
- version.o
-
- INCL = \
-- config.h \
-+ pthreads_win32_config.h \
- implement.h \
- semaphore.h \
- pthread.h \
-@@ -585,3 +598,11 @@
- sync.o: sync.c $(SYNC_SRCS) $(INCL)
- tsd.o: tsd.c $(TSD_SRCS) $(INCL)
- version.o: version.rc $(INCL)
-+
-+install:
-+ install -d $(prefix)/$(target)/bin
-+ install -d $(prefix)/$(target)/lib
-+ install -d $(prefix)/$(target)/include
-+ install pthreadGC$(DLL_VER).dll $(prefix)/$(target)/bin/pthreadGC$(DLL_VER).dll
-+ install pthreadGC$(DLL_VER).dll $(prefix)/$(target)/lib/libpthread.a
-+ install pthreads_win32_config.h pthread.h sched.h semaphore.h $(prefix)/$(target)/include
-
-=== modified file 'context.h'
---- pthreadw32/context.h 2007-01-06 13:44:39 +0000
-+++ pthreadw32/context.h 2010-07-10 23:05:44 +0000
-@@ -39,7 +39,7 @@
-
- #undef PTW32_PROGCTR
-
--#if defined(_M_IX86) || defined(_X86_)
-+#if defined(_M_IX86) || (defined(_X86_) && !defined(__amd64__))
- #define PTW32_PROGCTR(Context) ((Context).Eip)
- #endif
-
-
-=== modified file 'pthread.h'
---- pthreadw32/pthread.h 2010-06-20 03:31:18 +0000
-+++ pthreadw32/pthread.h 2010-07-10 23:29:46 +0000
-@@ -112,7 +112,7 @@
- #ifdef _UWIN
- # define HAVE_STRUCT_TIMESPEC 1
- # define HAVE_SIGNAL_H 1
--# undef HAVE_CONFIG_H
-+# undef 1
- # pragma comment(lib, "pthread")
- #endif
-
-@@ -210,9 +210,17 @@
- * -----------------
- */
-
--#if HAVE_CONFIG_H
--#include "config.h"
--#endif /* HAVE_CONFIG_H */
-+#if 1
-+#include "pthreads_win32_config.h"
-+#endif /* 1 */
-+
-+#ifdef __MINGW32__
-+# include <_mingw.h>
-+# ifdef __MINGW64_VERSION_MAJOR
-+ /* MinGW-w64 already has it: */
-+# define HAVE_STRUCT_TIMESPEC 1
-+# endif
-+#endif
-
- #ifndef NEED_FTIME
- #include <time.h>
-@@ -236,7 +244,7 @@
- };
-
- /*
-- * This is a duplicate of what is in the autoconf config.h,
-+ * This is a duplicate of what is in the autoconf pthreads_win32_config.h,
- * which is only used when building the pthread-win32 libraries.
- */
-
-
---- pthreadsw32/pthread_win32_attach_detach_np.c 2010-09-11 13:08:31.120188567 -0700
-+++ xxx/pthread_win32_attach_detach_np.c 2010-09-11 13:08:40.209188369 -0700
-@@ -97,6 +97,10 @@
- * InterlockedCompareExchange routine in WIN64 is an intrinsic function.
- * See PTW32_INTERLOCKED_COMPARE_EXCHANGE implement.h
- */
-+ ptw32_interlocked_compare_exchange =
-+ (PTW32_INTERLOCKED_LONG (WINAPI *)
-+ (PTW32_INTERLOCKED_LPLONG, PTW32_INTERLOCKED_LONG,
-+ PTW32_INTERLOCKED_LONG)) InterlockedCompareExchange;
-
- #else
-
-=== modified file 'pthread_cancel.c'
---- pthreadw32/pthread_cancel.c 2010-06-20 03:31:18 +0000
-+++ pthreadw32/pthread_cancel.c 2010-07-10 23:29:46 +0000
-@@ -47,7 +47,7 @@
- }
-
- static void CALLBACK
--ptw32_cancel_callback (DWORD unused)
-+ptw32_cancel_callback (ULONG_PTR unused)
- {
- ptw32_throw (PTW32_EPS_CANCEL);
-
-@@ -157,7 +157,7 @@
- * this will result in a call to ptw32_RegisterCancelation and only
- * the threadH arg will be used.
- */
-- ptw32_register_cancelation (ptw32_cancel_callback, threadH, 0);
-+ ptw32_register_cancelation ((PAPCFUNC)ptw32_cancel_callback, threadH, 0);
- (void) pthread_mutex_unlock (&tp->cancelLock);
- ResumeThread (threadH);
- }
-
-=== modified file 'pthread_exit.c'
---- pthreadw32/pthread_exit.c 2007-05-15 13:46:42 +0000
-+++ pthreadw32/pthread_exit.c 2010-07-10 23:05:44 +0000
-@@ -89,7 +89,7 @@
- */
-
- #if ! defined (__MINGW32__) || defined (__MSVCRT__) || defined (__DMC__)
-- _endthreadex ((unsigned) value_ptr);
-+ _endthreadex ((unsigned) (size_t) value_ptr);
- #else
- _endthread ();
- #endif
-
-=== modified file 'pthread_spin_destroy.c'
---- pthreadw32/pthread_spin_destroy.c 2005-01-01 14:36:17 +0000
-+++ pthreadw32/pthread_spin_destroy.c 2010-07-10 23:05:44 +0000
-@@ -59,9 +59,9 @@
- PTW32_INTERLOCKED_COMPARE_EXCHANGE ((PTW32_INTERLOCKED_LPLONG)
- & (s->interlock),
- (PTW32_INTERLOCKED_LONG)
-- PTW32_OBJECT_INVALID,
-+ (size_t)PTW32_OBJECT_INVALID,
- (PTW32_INTERLOCKED_LONG)
-- PTW32_SPIN_UNLOCKED))
-+ (size_t)PTW32_SPIN_UNLOCKED))
- {
- result = EINVAL;
- }
-
-=== modified file 'pthread_timechange_handler_np.c'
---- pthreadw32/pthread_timechange_handler_np.c 2005-01-01 14:36:17 +0000
-+++ pthreadw32/pthread_timechange_handler_np.c 2010-07-10 23:05:44 +0000
-@@ -103,5 +103,5 @@
-
- LeaveCriticalSection (&ptw32_cond_list_lock);
-
-- return (void *) (result != 0 ? EAGAIN : 0);
-+ return (void *) (size_t) (result != 0 ? EAGAIN : 0);
- }
-
-=== renamed file 'config.h' => 'pthreads_win32_config.h'
-=== modified file 'ptw32_MCS_lock.c'
---- pthreadw32/ptw32_MCS_lock.c 2010-06-20 03:31:18 +0000
-+++ pthreadw32/ptw32_MCS_lock.c 2010-07-10 23:29:46 +0000
-@@ -101,10 +101,10 @@
- INLINE void
- ptw32_mcs_flag_set (LONG * flag)
- {
-- HANDLE e = (HANDLE)PTW32_INTERLOCKED_COMPARE_EXCHANGE(
-+ HANDLE e = (HANDLE)(size_t) PTW32_INTERLOCKED_COMPARE_EXCHANGE(
- (PTW32_INTERLOCKED_LPLONG)flag,
-- (PTW32_INTERLOCKED_LONG)-1,
-- (PTW32_INTERLOCKED_LONG)0);
-+ (PTW32_INTERLOCKED_LONG)(size_t)-1,
-+ (PTW32_INTERLOCKED_LONG)(size_t)0);
- if ((HANDLE)0 != e)
- {
- /* another thread has already stored an event handle in the flag */
-@@ -129,8 +129,8 @@
-
- if (0 == PTW32_INTERLOCKED_COMPARE_EXCHANGE(
- (PTW32_INTERLOCKED_LPLONG)flag,
-- (PTW32_INTERLOCKED_LONG)e,
-- (PTW32_INTERLOCKED_LONG)0))
-+ (PTW32_INTERLOCKED_LONG)(size_t)e,
-+ (PTW32_INTERLOCKED_LONG)(size_t)0))
- {
- /* stored handle in the flag. wait on it now. */
- WaitForSingleObject(e, INFINITE);
-@@ -159,8 +159,8 @@
- node->next = 0; /* initially, no successor */
-
- /* queue for the lock */
-- pred = (ptw32_mcs_local_node_t *)PTW32_INTERLOCKED_EXCHANGE((PTW32_INTERLOCKED_LPLONG)lock,
-- (PTW32_INTERLOCKED_LONG)node);
-+ pred = (ptw32_mcs_local_node_t *)InterlockedExchangePointer((PVOID volatile *)lock,
-+ (void*)node);
-
- if (0 != pred)
- {
-@@ -184,17 +184,19 @@
- {
- ptw32_mcs_lock_t *lock = node->lock;
- ptw32_mcs_local_node_t *next = (ptw32_mcs_local_node_t *)
-- InterlockedExchangeAdd((LPLONG)&node->next,
-- (LONG)0); /* MBR fence */
--
-+#ifndef _WIN64
-+ InterlockedExchangeAdd((LPLONG)&node->next, 0); /* MBR fence */
-+#else
-+ InterlockedExchangeAdd64((LONG64 *)&node->next, 0); /* MBR fence */
-+#endif
- if (0 == next)
- {
- /* no known successor */
-
- if (node == (ptw32_mcs_local_node_t *)
-- PTW32_INTERLOCKED_COMPARE_EXCHANGE((PTW32_INTERLOCKED_LPLONG)lock,
-- (PTW32_INTERLOCKED_LONG)0,
-- (PTW32_INTERLOCKED_LONG)node))
-+ InterlockedCompareExchangePointer((LPVOID volatile *)lock,
-+ (PVOID)0,
-+ (PVOID)node))
- {
- /* no successor, lock is free now */
- return;
-@@ -203,7 +205,11 @@
- /* wait for successor */
- ptw32_mcs_flag_wait(&node->nextFlag);
- next = (ptw32_mcs_local_node_t *)
-+#ifndef _WIN64
- InterlockedExchangeAdd((LPLONG)&node->next, 0); /* MBR fence */
-+#else
-+ InterlockedExchangeAdd64((LONG64 *)&node->next, 0); /* MBR fence */
-+#endif
- }
-
- /* pass the lock */
-
-=== modified file 'ptw32_threadStart.c'
---- pthreadw32/ptw32_threadStart.c 2005-05-15 15:28:24 +0000
-+++ pthreadw32/ptw32_threadStart.c 2010-07-10 23:05:44 +0000
-@@ -344,7 +344,7 @@
- #endif
-
- #if ! defined (__MINGW32__) || defined (__MSVCRT__) || defined (__DMC__)
-- _endthreadex ((unsigned) status);
-+ _endthreadex ((unsigned) (size_t) status);
- #else
- _endthread ();
- #endif
-@@ -354,7 +354,7 @@
- */
-
- #if ! defined (__MINGW32__) || defined (__MSVCRT__) || defined (__DMC__)
-- return (unsigned) status;
-+ return (unsigned) (size_t) status;
- #endif
-
- } /* ptw32_threadStart */
-
-=== modified file 'ptw32_throw.c'
---- pthreadw32/ptw32_throw.c 2008-06-06 00:23:20 +0000
-+++ pthreadw32/ptw32_throw.c 2010-07-10 23:05:44 +0000
-@@ -79,12 +79,12 @@
- switch (exception)
- {
- case PTW32_EPS_CANCEL:
-- exitCode = (unsigned) PTHREAD_CANCELED;
-+ exitCode = (unsigned) (size_t) PTHREAD_CANCELED;
- break;
- case PTW32_EPS_EXIT:
- if (NULL != sp)
- {
-- exitCode = (unsigned) sp->exitStatus;
-+ exitCode = (unsigned) (size_t) sp->exitStatus;
- }
- break;
- }
-@@ -166,7 +166,7 @@
-
- #else
-
-- return (DWORD) NULL;
-+ return (DWORD) (size_t) NULL;
-
- #endif
- }
-
-=== modified file 'tests/GNUmakefile'
---- pthreadw32/tests/GNUmakefile 2010-06-20 04:26:26 +0000
-+++ pthreadw32/tests/GNUmakefile 2010-07-10 23:29:46 +0000
-@@ -33,6 +33,11 @@
-
- DLL_VER = 2
-
-+# For cross compiling use, e.g. CROSS=x86_64-w64-mingw32msvc-
-+# Although testing is supposed to be done on windows, this may still be
-+# needed, because one may as well use an x86-hosted toolchain on an x64.
-+CROSS =
-+
- CP = cp -f
- MV = mv -f
- RM = rm -f
-@@ -167,34 +172,34 @@
- @ $(MAKE) clean GCE
-
- GC:
-- $(MAKE) TEST=GC CC=gcc XXCFLAGS="-fopenmp -D__CLEANUP_C" all-pass
-+ $(MAKE) TEST=GC CC=$(CROSS)gcc XXCFLAGS="-fopenmp -D__CLEANUP_C" all-pass
-
- GCE:
-- $(MAKE) TEST=GCE CC=g++ XXCFLAGS="-fopenmp -mthreads -D__CLEANUP_CXX" all-pass
-+ $(MAKE) TEST=GCE CC=$(CROSS)g++ XXCFLAGS="-fopenmp -mthreads -D__CLEANUP_CXX" all-pass
-
- GCX:
-- $(MAKE) TEST=GC CC=g++ XXCFLAGS="-fopenmp -mthreads -D__CLEANUP_C" all-pass
-+ $(MAKE) TEST=GC CC=$(CROSS)g++ XXCFLAGS="-fopenmp -mthreads -D__CLEANUP_C" all-pass
-
- GC-bench:
-- $(MAKE) TEST=GC CC=gcc XXCFLAGS="-D__CLEANUP_C" XXLIBS="benchlib.o" all-bench
-+ $(MAKE) TEST=GC CC=$(CROSS)gcc XXCFLAGS="-D__CLEANUP_C" XXLIBS="benchlib.o" all-bench
-
- GCE-bench:
-- $(MAKE) TEST=GCE CC=g++ XXCFLAGS="-mthreads -D__CLEANUP_CXX" XXLIBS="benchlib." all-bench
-+ $(MAKE) TEST=GCE CC=$(CROSS)g++ XXCFLAGS="-mthreads -D__CLEANUP_CXX" XXLIBS="benchlib." all-bench
-
- GC-debug:
-- $(MAKE) TEST=GC CC=gcc XXCFLAGS="-fopenmp -D__CLEANUP_C" DLL_VER="$(DLL_VER)d" all-pass
-+ $(MAKE) TEST=GC CC=$(CROSS)gcc XXCFLAGS="-fopenmp -D__CLEANUP_C" DLL_VER="$(DLL_VER)d" all-pass
-
- GC-static:
-- $(MAKE) TEST=GC CC=gcc XXCFLAGS="-D__CLEANUP_C -DPTW32_STATIC_LIB" XXLIBS="-lws2_32" DLL="" all-static
-+ $(MAKE) TEST=GC CC=$(CROSS)gcc XXCFLAGS="-D__CLEANUP_C -DPTW32_STATIC_LIB" XXLIBS="-lws2_32" DLL="" all-static
-
- GC-stress:
- $(ECHO) Stress tests can take a long time since they are trying to
- $(ECHO) expose weaknesses that may be intermittant or statistically rare.
- $(ECHO) A pass does not prove correctness, but may give greater confidence.
-- $(MAKE) TEST=GC CC=gcc XXCFLAGS="-D__CLEANUP_C" XXLIBS="" all-stress
-+ $(MAKE) TEST=GC CC=$(CROSS)gcc XXCFLAGS="-D__CLEANUP_C" XXLIBS="" all-stress
-
- GCE-stress:
-- $(MAKE) TEST=GCE CC=g++ XXCFLAGS="-mthreads -D__CLEANUP_CXX" XXLIBS="" all-stress
-+ $(MAKE) TEST=GCE CC=$(CROSS)g++ XXCFLAGS="-mthreads -D__CLEANUP_CXX" XXLIBS="" all-stress
-
- all-pass: $(PASSES)
- @ $(ECHO) ALL TESTS PASSED! Congratulations!
-
-=== modified file 'tests/barrier3.c'
---- pthreadw32/tests/barrier3.c 2005-01-01 14:36:17 +0000
-+++ pthreadw32/tests/barrier3.c 2010-07-10 23:05:44 +0000
-@@ -41,7 +41,7 @@
- #include "test.h"
-
- pthread_barrier_t barrier = NULL;
--static int result = 1;
-+static DWORD_PTR result = 1;
-
- void * func(void * arg)
- {
-
-=== modified file 'tests/barrier5.c'
---- pthreadw32/tests/barrier5.c 2010-06-20 03:31:18 +0000
-+++ pthreadw32/tests/barrier5.c 2010-07-10 23:29:46 +0000
-@@ -79,7 +79,7 @@
- main()
- {
- int i, j;
-- int result;
-+ DWORD_PTR result;
- int serialThreadsTotal;
- LONG Crossings;
- pthread_t t[NUMTHREADS + 1];
-@@ -104,7 +104,7 @@
- for (i = 1; i <= j; i++)
- {
- assert(pthread_join(t[i], (void **) &result) == 0);
-- serialThreadsTotal += result;
-+ serialThreadsTotal += (int)result;
- }
-
- assert(serialThreadsTotal == BARRIERMULTIPLE);
-
-=== modified file 'tests/cancel2.c'
---- pthreadw32/tests/cancel2.c 2005-01-01 14:36:17 +0000
-+++ pthreadw32/tests/cancel2.c 2010-07-10 23:05:44 +0000
-@@ -217,7 +217,7 @@
- for (i = 1; i <= NUMTHREADS; i++)
- {
- int fail = 0;
-- int result = 0;
-+ DWORD_PTR result = 0;
-
- assert(pthread_join(t[i], (void **) &result) == 0);
- fail = (result != (int) PTHREAD_CANCELED);
-
-=== modified file 'tests/cancel3.c'
---- pthreadw32/tests/cancel3.c 2010-06-22 01:19:08 +0000
-+++ pthreadw32/tests/cancel3.c 2010-07-10 23:29:46 +0000
-@@ -173,7 +173,7 @@
- for (i = 1; i <= NUMTHREADS; i++)
- {
- int fail = 0;
-- int result = 0;
-+ DWORD_PTR result = 0;
-
- /*
- * The thread does not contain any cancelation points, so
-
-=== modified file 'tests/cancel4.c'
---- pthreadw32/tests/cancel4.c 2005-05-06 07:31:28 +0000
-+++ pthreadw32/tests/cancel4.c 2010-07-10 23:05:44 +0000
-@@ -98,7 +98,7 @@
- void *
- mythread(void * arg)
- {
-- int result = ((int)PTHREAD_CANCELED + 1);
-+ int result = ((int)(size_t)PTHREAD_CANCELED + 1);
- bag_t * bag = (bag_t *) arg;
-
- assert(bag == &threadbag[bag->threadnum]);
-@@ -118,7 +118,7 @@
- for (bag->count = 0; bag->count < 20; bag->count++)
- Sleep(100);
-
-- return (void *) result;
-+ return (void *) (size_t)result;
- }
-
- int
-@@ -173,7 +173,7 @@
- for (i = 1; i <= NUMTHREADS; i++)
- {
- int fail = 0;
-- int result = 0;
-+ DWORD_PTR result = 0;
-
- /*
- * The thread does not contain any cancelation points, so
-@@ -182,7 +182,7 @@
- */
- assert(pthread_join(t[i], (void **) &result) == 0);
-
-- fail = (result == (int) PTHREAD_CANCELED);
-+ fail = (result == (int) (size_t) PTHREAD_CANCELED);
-
- if (fail)
- {
-
-=== modified file 'tests/cancel5.c'
---- pthreadw32/tests/cancel5.c 2005-01-01 14:36:17 +0000
-+++ pthreadw32/tests/cancel5.c 2010-07-10 23:05:44 +0000
-@@ -171,7 +171,7 @@
- for (i = 1; i <= NUMTHREADS; i++)
- {
- int fail = 0;
-- int result = 0;
-+ DWORD_PTR result = 0;
-
- /*
- * The thread does not contain any cancelation points, so
-
-=== modified file 'tests/cancel6a.c'
---- pthreadw32/tests/cancel6a.c 2004-11-03 01:08:41 +0000
-+++ pthreadw32/tests/cancel6a.c 2010-07-10 23:05:44 +0000
-@@ -85,7 +85,7 @@
- void *
- mythread(void * arg)
- {
-- int result = ((int)PTHREAD_CANCELED + 1);
-+ int result = ((int)(size_t)PTHREAD_CANCELED + 1);
- bag_t * bag = (bag_t *) arg;
-
- assert(bag == &threadbag[bag->threadnum]);
-@@ -105,7 +105,7 @@
- for (bag->count = 0; bag->count < 100; bag->count++)
- Sleep(100);
-
-- return (void *) result;
-+ return (void *) (size_t)result;
- }
-
- int
-@@ -161,7 +161,7 @@
- for (i = 1; i <= NUMTHREADS; i++)
- {
- int fail = 0;
-- int result = 0;
-+ DWORD_PTR result = 0;
-
- /*
- * The thread does not contain any cancelation points, so
-@@ -170,7 +170,7 @@
- */
- assert(pthread_join(t[i], (void **) &result) == 0);
-
-- fail = (result != (int) PTHREAD_CANCELED);
-+ fail = (result != (int) (size_t) PTHREAD_CANCELED);
-
- if (fail)
- {
-
-=== modified file 'tests/cancel6d.c'
---- pthreadw32/tests/cancel6d.c 2004-11-03 01:08:41 +0000
-+++ pthreadw32/tests/cancel6d.c 2010-07-10 23:05:44 +0000
-@@ -86,7 +86,7 @@
- void *
- mythread(void * arg)
- {
-- int result = ((int)PTHREAD_CANCELED + 1);
-+ int result = ((int) (size_t) PTHREAD_CANCELED + 1);
- bag_t * bag = (bag_t *) arg;
-
- assert(bag == &threadbag[bag->threadnum]);
-@@ -109,7 +109,7 @@
- pthread_testcancel();
- }
-
-- return (void *) result;
-+ return (void *) (size_t) result;
- }
-
- int
-@@ -165,11 +165,11 @@
- for (i = 1; i <= NUMTHREADS; i++)
- {
- int fail = 0;
-- int result = 0;
-+ DWORD_PTR result = 0;
-
- assert(pthread_join(t[i], (void **) &result) == 0);
-
-- fail = (result != (int) PTHREAD_CANCELED);
-+ fail = (result != (int) (size_t) PTHREAD_CANCELED);
-
- if (fail)
- {
-
-=== modified file 'tests/cancel8.c'
---- pthreadw32/tests/cancel8.c 2005-01-01 14:36:17 +0000
-+++ pthreadw32/tests/cancel8.c 2010-07-10 23:05:44 +0000
-@@ -195,7 +195,7 @@
- assert(threadbag[i].self.p != NULL);
- assert(pthread_kill(threadbag[i].self, 0) == ESRCH);
-
-- fail = (result != (int) PTHREAD_CANCELED);
-+ fail = (result != (int) (size_t) PTHREAD_CANCELED);
-
- if (fail)
- {
-
-=== modified file 'tests/cleanup0.c'
---- pthreadw32/tests/cleanup0.c 2005-04-06 02:16:29 +0000
-+++ pthreadw32/tests/cleanup0.c 2010-07-10 23:05:44 +0000
-@@ -189,7 +189,7 @@
- for (i = 1; i <= NUMTHREADS; i++)
- {
- int fail = 0;
-- int result = 0;
-+ DWORD_PTR result = 0;
-
- assert(pthread_join(t[i], (void **) &result) == 0);
-
-
-=== modified file 'tests/cleanup1.c'
---- pthreadw32/tests/cleanup1.c 2005-04-06 02:16:29 +0000
-+++ pthreadw32/tests/cleanup1.c 2010-07-10 23:05:44 +0000
-@@ -203,7 +203,7 @@
- for (i = 1; i <= NUMTHREADS; i++)
- {
- int fail = 0;
-- int result = 0;
-+ DWORD_PTR result = 0;
-
- assert(pthread_join(t[i], (void **) &result) == 0);
-
-
-=== modified file 'tests/cleanup2.c'
---- pthreadw32/tests/cleanup2.c 2005-04-06 02:16:29 +0000
-+++ pthreadw32/tests/cleanup2.c 2010-07-10 23:05:44 +0000
-@@ -178,7 +178,7 @@
- for (i = 1; i <= NUMTHREADS; i++)
- {
- int fail = 0;
-- int result = 0;
-+ DWORD_PTR result = 0;
-
- assert(pthread_join(t[i], (void **) &result) == 0);
-
-
-=== modified file 'tests/cleanup3.c'
---- pthreadw32/tests/cleanup3.c 2005-04-06 02:16:29 +0000
-+++ pthreadw32/tests/cleanup3.c 2010-07-10 23:05:44 +0000
-@@ -183,7 +183,7 @@
- for (i = 1; i <= NUMTHREADS; i++)
- {
- int fail = 0;
-- int result = 0;
-+ DWORD_PTR result = 0;
-
- assert(pthread_join(t[i], (void **) &result) == 0);
-
-
-=== modified file 'tests/condvar1_2.c'
---- pthreadw32/tests/condvar1_2.c 2005-01-01 14:36:17 +0000
-+++ pthreadw32/tests/condvar1_2.c 2010-07-10 23:05:44 +0000
-@@ -89,7 +89,7 @@
- main()
- {
- int i, j, k;
-- int result = -1;
-+ DWORD_PTR result = -1;
- pthread_t t;
-
- for (k = 0; k < NUM_LOOPS; k++)
-
-=== modified file 'tests/condvar2.c'
---- pthreadw32/tests/condvar2.c 2005-05-06 07:31:28 +0000
-+++ pthreadw32/tests/condvar2.c 2010-07-10 23:05:44 +0000
-@@ -99,7 +99,7 @@
- /* get current system time */
- _ftime(&currSysTime);
-
-- abstime.tv_sec = currSysTime.time;
-+ abstime.tv_sec = (long)currSysTime.time;
- abstime.tv_nsec = NANOSEC_PER_MILLISEC * currSysTime.millitm;
-
- abstime.tv_sec += 1;
-@@ -109,7 +109,7 @@
- assert(pthread_mutex_unlock(&mutex) == 0);
-
- {
-- int result = pthread_cond_destroy(&cv);
-+ DWORD_PTR result = pthread_cond_destroy(&cv);
- if (result != 0)
- {
- fprintf(stderr, "Result = %s\n", error_string[result]);
-
-=== modified file 'tests/condvar2_1.c'
---- pthreadw32/tests/condvar2_1.c 2005-01-01 14:36:17 +0000
-+++ pthreadw32/tests/condvar2_1.c 2010-07-10 23:05:44 +0000
-@@ -105,7 +105,7 @@
- {
- int i;
- pthread_t t[NUMTHREADS + 1];
-- int result = 0;
-+ DWORD_PTR result = 0;
- struct _timeb currSysTime;
- const DWORD NANOSEC_PER_MILLISEC = 1000000;
-
-@@ -116,7 +116,7 @@
- /* get current system time */
- _ftime(&currSysTime);
-
-- abstime.tv_sec = currSysTime.time;
-+ abstime.tv_sec = (long)currSysTime.time;
- abstime.tv_nsec = NANOSEC_PER_MILLISEC * currSysTime.millitm;
-
- abstime.tv_sec += 5;
-
-=== modified file 'tests/condvar3.c'
---- pthreadw32/tests/condvar3.c 2005-04-25 14:42:37 +0000
-+++ pthreadw32/tests/condvar3.c 2010-07-10 23:05:44 +0000
-@@ -126,7 +126,7 @@
- /* get current system time */
- _ftime(&currSysTime);
-
-- abstime.tv_sec = currSysTime.time;
-+ abstime.tv_sec = (long)currSysTime.time;
- abstime.tv_nsec = NANOSEC_PER_MILLISEC * currSysTime.millitm;
-
- assert(pthread_create(&t[1], NULL, mythread, (void *) 1) == 0);
-
-=== modified file 'tests/condvar3_1.c'
---- pthreadw32/tests/condvar3_1.c 2005-04-25 14:42:37 +0000
-+++ pthreadw32/tests/condvar3_1.c 2010-07-10 23:05:44 +0000
-@@ -126,7 +126,7 @@
- {
- int i;
- pthread_t t[NUMTHREADS + 1];
-- int result = 0;
-+ DWORD_PTR result = 0;
- struct _timeb currSysTime;
- const DWORD NANOSEC_PER_MILLISEC = 1000000;
-
-@@ -139,7 +139,7 @@
- /* get current system time */
- _ftime(&currSysTime);
-
-- abstime.tv_sec = currSysTime.time;
-+ abstime.tv_sec = (long)currSysTime.time;
- abstime.tv_nsec = NANOSEC_PER_MILLISEC * currSysTime.millitm;
-
- abstime.tv_sec += 5;
-
-=== modified file 'tests/condvar3_2.c'
---- pthreadw32/tests/condvar3_2.c 2005-04-25 14:42:37 +0000
-+++ pthreadw32/tests/condvar3_2.c 2010-07-10 23:05:44 +0000
-@@ -127,7 +127,7 @@
- {
- int i;
- pthread_t t[NUMTHREADS + 1];
-- int result = 0;
-+ DWORD_PTR result = 0;
- struct _timeb currSysTime;
- const DWORD NANOSEC_PER_MILLISEC = 1000000;
-
-@@ -138,7 +138,7 @@
- /* get current system time */
- _ftime(&currSysTime);
-
-- abstime.tv_sec = abstime.tv_sec = currSysTime.time + 5;
-+ abstime.tv_sec = abstime.tv_sec = (long)currSysTime.time + 5;
- abstime.tv_nsec = abstime2.tv_nsec = NANOSEC_PER_MILLISEC * currSysTime.millitm;
-
- assert(pthread_mutex_lock(&mutex) == 0);
-
-=== modified file 'tests/condvar3_3.c'
---- pthreadw32/tests/condvar3_3.c 2005-04-25 14:42:37 +0000
-+++ pthreadw32/tests/condvar3_3.c 2010-07-10 23:05:44 +0000
-@@ -96,7 +96,7 @@
- /* get current system time */
- _ftime(&currSysTime);
-
-- abstime.tv_sec = currSysTime.time;
-+ abstime.tv_sec = (long)currSysTime.time;
- abstime.tv_nsec = NANOSEC_PER_MILLISEC * currSysTime.millitm;
- abstime.tv_sec += 1;
-
-@@ -120,7 +120,7 @@
-
- assert(pthread_mutex_lock(&mtx) == 0);
-
-- abstime.tv_sec = currSysTime.time;
-+ abstime.tv_sec = (long)currSysTime.time;
- abstime.tv_nsec = NANOSEC_PER_MILLISEC * currSysTime.millitm;
- abstime.tv_sec += 1;
-
-
-=== modified file 'tests/condvar4.c'
---- pthreadw32/tests/condvar4.c 2005-04-25 14:42:37 +0000
-+++ pthreadw32/tests/condvar4.c 2010-07-10 23:05:44 +0000
-@@ -130,7 +130,7 @@
- /* get current system time */
- _ftime(&currSysTime);
-
-- abstime.tv_sec = currSysTime.time;
-+ abstime.tv_sec = (long)currSysTime.time;
- abstime.tv_nsec = NANOSEC_PER_MILLISEC * currSysTime.millitm;
-
- abstime.tv_sec += 5;
-@@ -143,7 +143,7 @@
-
- _ftime(&currSysTime);
-
-- abstime.tv_sec = currSysTime.time;
-+ abstime.tv_sec = (long)currSysTime.time;
- abstime.tv_nsec = NANOSEC_PER_MILLISEC * currSysTime.millitm;
-
- abstime.tv_sec += 5;
-
-=== modified file 'tests/condvar5.c'
---- pthreadw32/tests/condvar5.c 2005-04-25 14:42:37 +0000
-+++ pthreadw32/tests/condvar5.c 2010-07-10 23:05:44 +0000
-@@ -129,7 +129,7 @@
- /* get current system time */
- _ftime(&currSysTime);
-
-- abstime.tv_sec = currSysTime.time;
-+ abstime.tv_sec = (long)currSysTime.time;
- abstime.tv_nsec = NANOSEC_PER_MILLISEC * currSysTime.millitm;
-
- abstime.tv_sec += 5;
-@@ -142,7 +142,7 @@
-
- _ftime(&currSysTime);
-
-- abstime.tv_sec = currSysTime.time;
-+ abstime.tv_sec = (long)currSysTime.time;
- abstime.tv_nsec = NANOSEC_PER_MILLISEC * currSysTime.millitm;
-
- abstime.tv_sec += 5;
-
-=== modified file 'tests/condvar6.c'
---- pthreadw32/tests/condvar6.c 2005-04-25 14:42:37 +0000
-+++ pthreadw32/tests/condvar6.c 2010-07-10 23:05:44 +0000
-@@ -159,7 +159,7 @@
-
- _ftime(&currSysTime);
-
-- abstime.tv_sec = currSysTime.time;
-+ abstime.tv_sec = (long)currSysTime.time;
- abstime.tv_nsec = NANOSEC_PER_MILLISEC * currSysTime.millitm;
-
- abstime.tv_sec += 5;
-
-=== modified file 'tests/condvar7.c'
---- pthreadw32/tests/condvar7.c 2005-04-25 14:42:37 +0000
-+++ pthreadw32/tests/condvar7.c 2010-07-10 23:05:44 +0000
-@@ -169,7 +169,7 @@
-
- _ftime(&currSysTime);
-
-- abstime.tv_sec = currSysTime.time;
-+ abstime.tv_sec = (long)currSysTime.time;
- abstime.tv_nsec = NANOSEC_PER_MILLISEC * currSysTime.millitm;
-
- abstime.tv_sec += 10;
-
-=== modified file 'tests/condvar8.c'
---- pthreadw32/tests/condvar8.c 2005-04-25 14:42:37 +0000
-+++ pthreadw32/tests/condvar8.c 2010-07-10 23:05:44 +0000
-@@ -166,7 +166,7 @@
-
- _ftime(&currSysTime);
-
-- abstime.tv_sec = currSysTime.time;
-+ abstime.tv_sec = (long)currSysTime.time;
- abstime.tv_nsec = NANOSEC_PER_MILLISEC * currSysTime.millitm;
-
- abstime.tv_sec += 10;
-
-=== modified file 'tests/condvar9.c'
---- pthreadw32/tests/condvar9.c 2005-04-25 14:42:37 +0000
-+++ pthreadw32/tests/condvar9.c 2010-07-10 23:05:44 +0000
-@@ -174,7 +174,7 @@
-
- _ftime(&currSysTime);
-
-- abstime.tv_sec = currSysTime.time;
-+ abstime.tv_sec = (long)currSysTime.time;
- abstime.tv_nsec = NANOSEC_PER_MILLISEC * currSysTime.millitm;
-
- abstime.tv_sec += 5;
-
-=== modified file 'tests/delay2.c'
---- pthreadw32/tests/delay2.c 2005-01-01 14:36:17 +0000
-+++ pthreadw32/tests/delay2.c 2010-07-10 23:05:44 +0000
-@@ -65,7 +65,7 @@
- main(int argc, char * argv[])
- {
- pthread_t t;
-- int result = 0;
-+ DWORD_PTR result = 0;
-
- assert(pthread_mutex_lock(&mx) == 0);
-
-
-=== modified file 'tests/exception1.c'
---- pthreadw32/tests/exception1.c 2005-01-01 14:36:17 +0000
-+++ pthreadw32/tests/exception1.c 2010-07-10 23:05:44 +0000
-@@ -226,7 +226,7 @@
- for (i = 0; i < NUMTHREADS; i++)
- {
- int fail = 0;
-- int result = 0;
-+ DWORD_PTR result = 0;
-
- /* Canceled thread */
- assert(pthread_join(ct[i], (void **) &result) == 0);
-
-=== modified file 'tests/inherit1.c'
---- pthreadw32/tests/inherit1.c 2005-01-01 14:36:17 +0000
-+++ pthreadw32/tests/inherit1.c 2010-07-10 23:05:44 +0000
-@@ -89,7 +89,7 @@
- struct sched_param param;
-
- assert(pthread_getschedparam(pthread_self(), &policy, &param) == 0);
-- return (void *) param.sched_priority;
-+ return (void *) (size_t) param.sched_priority;
- }
-
-
-@@ -169,7 +169,7 @@
- assert(pthread_attr_setschedparam(&attr, &param) == 0);
- assert(pthread_create(&t, &attr, func, NULL) == 0);
- pthread_join(t, &result);
-- assert((int) result == mainParam.sched_priority);
-+ assert((int) (size_t)result == mainParam.sched_priority);
- }
- }
-
-
-=== modified file 'tests/join0.c'
---- pthreadw32/tests/join0.c 2005-05-15 15:28:24 +0000
-+++ pthreadw32/tests/join0.c 2010-07-10 23:05:44 +0000
-@@ -53,7 +53,7 @@
- main(int argc, char * argv[])
- {
- pthread_t id;
-- int result;
-+ DWORD_PTR result;
-
- /* Create a single thread and wait for it to exit. */
- assert(pthread_create(&id, NULL, func, (void *) 123) == 0);
-
-=== modified file 'tests/join1.c'
---- pthreadw32/tests/join1.c 2005-05-15 15:28:24 +0000
-+++ pthreadw32/tests/join1.c 2010-07-10 23:05:44 +0000
-@@ -56,7 +56,7 @@
- {
- pthread_t id[4];
- int i;
-- int result;
-+ DWORD_PTR result;
-
- /* Create a few threads and then exit. */
- for (i = 0; i < 4; i++)
-
-=== modified file 'tests/join2.c'
---- pthreadw32/tests/join2.c 2005-05-15 15:28:24 +0000
-+++ pthreadw32/tests/join2.c 2010-07-10 23:05:44 +0000
-@@ -50,7 +50,7 @@
- {
- pthread_t id[4];
- int i;
-- int result;
-+ DWORD_PTR result;
-
- /* Create a few threads and then exit. */
- for (i = 0; i < 4; i++)
-
-=== modified file 'tests/join3.c'
---- pthreadw32/tests/join3.c 2005-05-15 15:28:24 +0000
-+++ pthreadw32/tests/join3.c 2010-07-10 23:05:44 +0000
-@@ -50,7 +50,7 @@
- {
- pthread_t id[4];
- int i;
-- int result;
-+ DWORD_PTR result;
-
- /* Create a few threads and then exit. */
- for (i = 0; i < 4; i++)
-
-=== modified file 'tests/mutex6e.c'
---- pthreadw32/tests/mutex6e.c 2005-01-01 14:36:17 +0000
-+++ pthreadw32/tests/mutex6e.c 2010-07-10 23:05:44 +0000
-@@ -74,7 +74,7 @@
- main()
- {
- pthread_t t;
-- int result = 0;
-+ DWORD_PTR result = 0;
- int mxType = -1;
-
- assert(pthread_mutexattr_init(&mxAttr) == 0);
-
-=== modified file 'tests/mutex6es.c'
---- pthreadw32/tests/mutex6es.c 2005-01-01 14:36:17 +0000
-+++ pthreadw32/tests/mutex6es.c 2010-07-10 23:05:44 +0000
-@@ -73,7 +73,7 @@
- main()
- {
- pthread_t t;
-- int result = 0;
-+ DWORD_PTR result = 0;
-
- assert(mutex == PTHREAD_ERRORCHECK_MUTEX_INITIALIZER);
-
-
-=== modified file 'tests/mutex6r.c'
---- pthreadw32/tests/mutex6r.c 2005-01-01 14:36:17 +0000
-+++ pthreadw32/tests/mutex6r.c 2010-07-10 23:05:44 +0000
-@@ -73,7 +73,7 @@
- main()
- {
- pthread_t t;
-- int result = 0;
-+ DWORD_PTR result = 0;
- int mxType = -1;
-
- assert(pthread_mutexattr_init(&mxAttr) == 0);
-
-=== modified file 'tests/mutex6rs.c'
---- pthreadw32/tests/mutex6rs.c 2005-01-01 14:36:17 +0000
-+++ pthreadw32/tests/mutex6rs.c 2010-07-10 23:05:44 +0000
-@@ -72,7 +72,7 @@
- main()
- {
- pthread_t t;
-- int result = 0;
-+ DWORD_PTR result = 0;
-
- assert(mutex == PTHREAD_RECURSIVE_MUTEX_INITIALIZER);
-
-
-=== modified file 'tests/mutex7e.c'
---- pthreadw32/tests/mutex7e.c 2005-01-01 14:36:17 +0000
-+++ pthreadw32/tests/mutex7e.c 2010-07-10 23:05:44 +0000
-@@ -74,7 +74,7 @@
- main()
- {
- pthread_t t;
-- int result = 0;
-+ DWORD_PTR result = 0;
- int mxType = -1;
-
- assert(pthread_mutexattr_init(&mxAttr) == 0);
-
-=== modified file 'tests/mutex7r.c'
---- pthreadw32/tests/mutex7r.c 2005-01-01 14:36:17 +0000
-+++ pthreadw32/tests/mutex7r.c 2010-07-10 23:05:44 +0000
-@@ -73,7 +73,7 @@
- main()
- {
- pthread_t t;
-- int result = 0;
-+ DWORD_PTR result = 0;
- int mxType = -1;
-
- assert(pthread_mutexattr_init(&mxAttr) == 0);
-
-=== modified file 'tests/mutex8.c'
---- pthreadw32/tests/mutex8.c 2002-02-20 04:39:56 +0000
-+++ pthreadw32/tests/mutex8.c 2010-07-10 23:05:44 +0000
-@@ -49,7 +49,7 @@
-
- _ftime(&currSysTime);
-
-- abstime.tv_sec = currSysTime.time;
-+ abstime.tv_sec = (long)currSysTime.time;
- abstime.tv_nsec = NANOSEC_PER_MILLISEC * currSysTime.millitm;
-
- abstime.tv_sec += 1;
-
-=== modified file 'tests/mutex8e.c'
---- pthreadw32/tests/mutex8e.c 2002-02-20 04:39:56 +0000
-+++ pthreadw32/tests/mutex8e.c 2010-07-10 23:05:44 +0000
-@@ -57,7 +57,7 @@
-
- _ftime(&currSysTime);
-
-- abstime.tv_sec = currSysTime.time;
-+ abstime.tv_sec = (long)currSysTime.time;
- abstime.tv_nsec = NANOSEC_PER_MILLISEC * currSysTime.millitm;
-
- abstime.tv_sec += 1;
-
-=== modified file 'tests/mutex8n.c'
---- pthreadw32/tests/mutex8n.c 2002-02-20 04:39:56 +0000
-+++ pthreadw32/tests/mutex8n.c 2010-07-10 23:05:44 +0000
-@@ -57,7 +57,7 @@
-
- _ftime(&currSysTime);
-
-- abstime.tv_sec = currSysTime.time;
-+ abstime.tv_sec = (long)currSysTime.time;
- abstime.tv_nsec = NANOSEC_PER_MILLISEC * currSysTime.millitm;
-
- abstime.tv_sec += 1;
-
-=== modified file 'tests/mutex8r.c'
---- pthreadw32/tests/mutex8r.c 2002-02-20 04:39:56 +0000
-+++ pthreadw32/tests/mutex8r.c 2010-07-10 23:05:44 +0000
-@@ -57,7 +57,7 @@
-
- _ftime(&currSysTime);
-
-- abstime.tv_sec = currSysTime.time;
-+ abstime.tv_sec = (long)currSysTime.time;
- abstime.tv_nsec = NANOSEC_PER_MILLISEC * currSysTime.millitm;
-
- abstime.tv_sec += 1;
-
-=== modified file 'tests/priority1.c'
---- pthreadw32/tests/priority1.c 2005-01-01 14:36:17 +0000
-+++ pthreadw32/tests/priority1.c 2010-07-10 23:05:44 +0000
-@@ -91,7 +91,7 @@
-
- assert(pthread_getschedparam(threadID, &policy, &param) == 0);
- assert(policy == SCHED_OTHER);
-- return (void *) (param.sched_priority);
-+ return (void *) (size_t) (param.sched_priority);
- }
-
- void *
-@@ -164,8 +164,8 @@
-
- assert(pthread_join(t, &result) == 0);
-
-- assert(param.sched_priority == (int) result);
-- printf("%10d %10d %10d\n", param.sched_priority, (int) result, prio);
-+ assert(param.sched_priority == (int) (size_t) result);
-+ printf("%10d %10d %10d\n", param.sched_priority, (int) (size_t) result, prio);
- }
-
- return 0;
-
-=== modified file 'tests/priority2.c'
---- pthreadw32/tests/priority2.c 2005-01-01 14:36:17 +0000
-+++ pthreadw32/tests/priority2.c 2010-07-10 23:05:44 +0000
-@@ -95,7 +95,7 @@
- assert(policy == SCHED_OTHER);
- result = pthread_barrier_wait(&endBarrier);
- assert(result == 0 || result == PTHREAD_BARRIER_SERIAL_THREAD);
-- return (void *) param.sched_priority;
-+ return (void *) (size_t) param.sched_priority;
- }
-
-
-@@ -162,7 +162,7 @@
- assert(GetThreadPriority(pthread_getw32threadhandle_np(t)) ==
- validPriorities[param.sched_priority+(PTW32TEST_MAXPRIORITIES/2)]);
- pthread_join(t, &result);
-- assert(param.sched_priority == (int)result);
-+ assert(param.sched_priority == (int)(size_t)result);
- }
-
- return 0;
-
-=== modified file 'tests/rwlock2_t.c'
---- pthreadw32/tests/rwlock2_t.c 2005-01-01 14:36:17 +0000
-+++ pthreadw32/tests/rwlock2_t.c 2010-07-10 23:05:44 +0000
-@@ -55,7 +55,7 @@
-
- _ftime(&currSysTime);
-
-- abstime.tv_sec = currSysTime.time;
-+ abstime.tv_sec = (long)currSysTime.time;
- abstime.tv_nsec = NANOSEC_PER_MILLISEC * currSysTime.millitm;
-
- abstime.tv_sec += 1;
-
-=== modified file 'tests/rwlock3_t.c'
---- pthreadw32/tests/rwlock3_t.c 2005-01-01 14:36:17 +0000
-+++ pthreadw32/tests/rwlock3_t.c 2010-07-10 23:05:44 +0000
-@@ -68,7 +68,7 @@
-
- _ftime(&currSysTime);
-
-- abstime.tv_sec = currSysTime.time;
-+ abstime.tv_sec = (long)currSysTime.time;
- abstime.tv_nsec = NANOSEC_PER_MILLISEC * currSysTime.millitm;
-
- abstime.tv_sec += 1;
-
-=== modified file 'tests/rwlock4_t.c'
---- pthreadw32/tests/rwlock4_t.c 2005-01-01 14:36:17 +0000
-+++ pthreadw32/tests/rwlock4_t.c 2010-07-10 23:05:44 +0000
-@@ -68,7 +68,7 @@
-
- _ftime(&currSysTime);
-
-- abstime.tv_sec = currSysTime.time;
-+ abstime.tv_sec = (long)currSysTime.time;
- abstime.tv_nsec = NANOSEC_PER_MILLISEC * currSysTime.millitm;
-
- abstime.tv_sec += 1;
-
-=== modified file 'tests/rwlock5_t.c'
---- pthreadw32/tests/rwlock5_t.c 2005-01-01 14:36:17 +0000
-+++ pthreadw32/tests/rwlock5_t.c 2010-07-10 23:05:44 +0000
-@@ -70,7 +70,7 @@
-
- _ftime(&currSysTime);
-
-- abstime.tv_sec = currSysTime.time;
-+ abstime.tv_sec = (long)currSysTime.time;
- abstime.tv_nsec = NANOSEC_PER_MILLISEC * currSysTime.millitm;
-
- abstime.tv_sec += 1;
-
-=== modified file 'tests/rwlock6.c'
---- pthreadw32/tests/rwlock6.c 2005-01-01 14:36:17 +0000
-+++ pthreadw32/tests/rwlock6.c 2010-07-10 23:05:44 +0000
-@@ -77,9 +77,9 @@
- pthread_t wrt1;
- pthread_t wrt2;
- pthread_t rdt;
-- int wr1Result = 0;
-- int wr2Result = 0;
-- int rdResult = 0;
-+ DWORD_PTR wr1Result = 0;
-+ DWORD_PTR wr2Result = 0;
-+ DWORD_PTR rdResult = 0;
-
- bankAccount = 0;
-
-
-=== modified file 'tests/rwlock6_t.c'
---- pthreadw32/tests/rwlock6_t.c 2005-01-01 14:36:17 +0000
-+++ pthreadw32/tests/rwlock6_t.c 2010-07-10 23:05:44 +0000
-@@ -55,7 +55,7 @@
- bankAccount += 10;
- assert(pthread_rwlock_unlock(&rwlock1) == 0);
-
-- return ((void *) bankAccount);
-+ return ((void *) (size_t) bankAccount);
- }
-
- void * rdfunc(void * arg)
-@@ -67,17 +67,17 @@
-
- _ftime(&currSysTime);
-
-- abstime.tv_sec = currSysTime.time;
-+ abstime.tv_sec = (long)currSysTime.time;
- abstime.tv_nsec = NANOSEC_PER_MILLISEC * currSysTime.millitm;
-
-
-- if ((int) arg == 1)
-+ if ((int) ((size_t) arg) == 1)
- {
- abstime.tv_sec += 1;
- assert(pthread_rwlock_timedrdlock(&rwlock1, &abstime) == ETIMEDOUT);
- ba = 0;
- }
-- else if ((int) arg == 2)
-+ else if ((int) ((size_t) arg) == 2)
- {
- abstime.tv_sec += 3;
- assert(pthread_rwlock_timedrdlock(&rwlock1, &abstime) == 0);
-@@ -85,7 +85,7 @@
- assert(pthread_rwlock_unlock(&rwlock1) == 0);
- }
-
-- return ((void *) ba);
-+ return ((void *) (size_t) ba);
- }
-
- int
-@@ -95,10 +95,10 @@
- pthread_t wrt2;
- pthread_t rdt1;
- pthread_t rdt2;
-- int wr1Result = 0;
-- int wr2Result = 0;
-- int rd1Result = 0;
-- int rd2Result = 0;
-+ DWORD_PTR wr1Result = 0;
-+ DWORD_PTR wr2Result = 0;
-+ DWORD_PTR rd1Result = 0;
-+ DWORD_PTR rd2Result = 0;
-
- bankAccount = 0;
-
-
-=== modified file 'tests/rwlock6_t2.c'
---- pthreadw32/tests/rwlock6_t2.c 2005-01-01 14:36:17 +0000
-+++ pthreadw32/tests/rwlock6_t2.c 2010-07-10 23:05:44 +0000
-@@ -54,21 +54,21 @@
- int result;
-
- result = pthread_rwlock_timedwrlock(&rwlock1, &abstime);
-- if ((int) arg == 1)
-+ if ((int) ((size_t)arg) == 1)
- {
- assert(result == 0);
- Sleep(2000);
- bankAccount += 10;
- assert(pthread_rwlock_unlock(&rwlock1) == 0);
-- return ((void *) bankAccount);
-+ return ((void *) (size_t) bankAccount);
- }
-- else if ((int) arg == 2)
-+ else if ((int) ((size_t)arg) == 2)
- {
- assert(result == ETIMEDOUT);
-- return ((void *) 100);
-+ return ((void *) (size_t) 100);
- }
-
-- return ((void *) -1);
-+ return ((void *) (size_t) -1);
- }
-
- void * rdfunc(void * arg)
-@@ -77,7 +77,7 @@
-
- assert(pthread_rwlock_timedrdlock(&rwlock1, &abstime) == ETIMEDOUT);
-
-- return ((void *) ba);
-+ return ((void *) (size_t) ba);
- }
-
- int
-@@ -86,15 +86,15 @@
- pthread_t wrt1;
- pthread_t wrt2;
- pthread_t rdt;
-- int wr1Result = 0;
-- int wr2Result = 0;
-- int rdResult = 0;
-+ DWORD_PTR wr1Result = 0;
-+ DWORD_PTR wr2Result = 0;
-+ DWORD_PTR rdResult = 0;
- struct _timeb currSysTime;
- const DWORD NANOSEC_PER_MILLISEC = 1000000;
-
- _ftime(&currSysTime);
-
-- abstime.tv_sec = currSysTime.time;
-+ abstime.tv_sec = (long)currSysTime.time;
- abstime.tv_nsec = NANOSEC_PER_MILLISEC * currSysTime.millitm;
-
- abstime.tv_sec += 1;
-
-=== modified file 'tests/semaphore1.c'
---- pthreadw32/tests/semaphore1.c 2005-05-08 16:52:50 +0000
-+++ pthreadw32/tests/semaphore1.c 2010-07-10 23:05:44 +0000
-@@ -119,7 +119,7 @@
- {
- pthread_t t;
- sem_t s;
-- int result;
-+ DWORD_PTR result;
-
- assert(pthread_create(&t, NULL, thr, NULL) == 0);
- assert(pthread_join(t, (void **)&result) == 0);
-
-=== modified file 'tests/semaphore4.c'
---- pthreadw32/tests/semaphore4.c 2005-01-01 14:36:17 +0000
-+++ pthreadw32/tests/semaphore4.c 2010-07-10 23:05:44 +0000
-@@ -113,7 +113,7 @@
- //printf("value = %d\n", -value); fflush(stdout);
- assert(pthread_cancel(t[50]) == 0);
- {
-- int result;
-+ DWORD_PTR result;
- assert(pthread_join(t[50], (void **) &result) == 0);
- // printf("result = %d\n", result); fflush(stdout);
- }
-
-=== modified file 'tests/spin3.c'
---- pthreadw32/tests/spin3.c 2005-01-01 14:36:17 +0000
-+++ pthreadw32/tests/spin3.c 2010-07-10 23:05:44 +0000
-@@ -46,7 +46,7 @@
-
- void * unlocker(void * arg)
- {
-- int expectedResult = (int) arg;
-+ int expectedResult = (int) (size_t) arg;
-
- wasHere++;
- assert(pthread_spin_unlock(&spin) == expectedResult);
-
-=== modified file 'tests/spin4.c'
---- pthreadw32/tests/spin4.c 2005-01-01 14:36:17 +0000
-+++ pthreadw32/tests/spin4.c 2010-07-10 23:05:44 +0000
-@@ -63,7 +63,7 @@
- int
- main()
- {
-- long result = 0;
-+ DWORD_PTR result = 0;
- pthread_t t;
- int CPUs;
- struct _timeb sysTime;
-
-=== modified file 'tests/stress1.c'
---- pthreadw32/tests/stress1.c 2010-06-20 03:31:18 +0000
-+++ pthreadw32/tests/stress1.c 2010-07-10 23:29:46 +0000
-@@ -141,9 +141,9 @@
- void *
- masterThread (void * arg)
- {
-- int dither = (int) arg;
-+ int dither = (int) (size_t)arg;
-
-- timeout = (int) arg;
-+ timeout = (int) (size_t)arg;
-
- pthread_barrier_wait(&startBarrier);
-
-@@ -239,7 +239,7 @@
- assert(pthread_barrier_init(&readyBarrier, NULL, 3) == 0);
- assert(pthread_barrier_init(&holdBarrier, NULL, 3) == 0);
-
-- assert(pthread_create(&master, NULL, masterThread, (void *) timeout) == 0);
-+ assert(pthread_create(&master, NULL, masterThread, (void *) (size_t)timeout) == 0);
- assert(pthread_create(&slave, NULL, slaveThread, NULL) == 0);
-
- allExit = FALSE;
-
-=== modified file 'tests/tsd1.c'
---- pthreadw32/tests/tsd1.c 2005-05-08 16:52:50 +0000
-+++ pthreadw32/tests/tsd1.c 2010-07-10 23:05:44 +0000
-@@ -179,7 +179,7 @@
- */
- for (i = 1; i < NUM_THREADS; i++)
- {
-- int result = 0;
-+ DWORD_PTR result = 0;
-
- assert(pthread_join(thread[i], (void **) &result) == 0);
- }
-
-=== modified file 'tests/tsd2.c'
---- pthreadw32/tests/tsd2.c 2005-05-08 16:52:50 +0000
-+++ pthreadw32/tests/tsd2.c 2010-07-10 23:05:44 +0000
-@@ -183,7 +183,7 @@
- */
- for (i = 1; i < NUM_THREADS; i++)
- {
-- int result = 0;
-+ DWORD_PTR result = 0;
-
- assert(pthread_join(thread[i], (void **) &result) == 0);
- }
-
-=== modified file 'version.rc'
---- pthreadw32/version.rc 2005-05-19 04:19:35 +0000
-+++ pthreadw32/version.rc 2010-07-10 23:05:44 +0000
-@@ -102,7 +102,7 @@
- BEGIN
- BLOCK "040904b0"
- BEGIN
-- VALUE "FileDescription", "POSIX Threads for Windows32 Library\0"
-+ VALUE "FileDescription", "POSIX Threads for Windows Library\0"
- VALUE "ProductVersion", PTW32_VERSION_STRING
- VALUE "FileVersion", PTW32_VERSION_STRING
- VALUE "InternalName", PTW32_VERSIONINFO_NAME
-
diff --git a/contrib/pthreadw32/module.defs b/contrib/pthreadw32/module.defs
index 663f8dbec..0e4a06a1d 100644
--- a/contrib/pthreadw32/module.defs
+++ b/contrib/pthreadw32/module.defs
@@ -1,21 +1,27 @@
$(eval $(call import.MODULE.defs,PTHREADW32,pthreadw32))
$(eval $(call import.CONTRIB.defs,PTHREADW32))
-# TODO: Unknown upstream url
-PTHREADW32.FETCH.url = http://download.handbrake.fr/handbrake/contrib/pthreads-w32-cvs20100909.tar.bz2
-PTHREADW32.FETCH.md5 = d1dea735b53176567e9841ca77388633
+PTHREADW32.FETCH.url = http://download.handbrake.fr/handbrake/contrib/pthreads-w32-2-9-1-release.tar.gz
+PTHREADW32.FETCH.url += ftp://sourceware.org/pub/pthreads-win32/pthreads-w32-2-9-1-release.tar.gz
+PTHREADW32.FETCH.md5 = 36ba827d6aa0fa9f9ae740a35626e2e3
+PTHREADW32.CONFIGURE.bootstrap = make realclean;
PTHREADW32.CONFIGURE = $(TOUCH.exe) $@
-PTHREADW32.BUILD.extra = target=$(BUILD.cross.prefix) clean GC-static
-PTHREADW32.BUILD.ntargets = clean GC-static
+PTHREADW32.BUILD.extra = CROSS=$(BUILD.cross.prefix) realclean GC-static
+PTHREADW32.BUILD.ntargets = realclean GC-static
define PTHREADW32.INSTALL
- $(CP.exe) $(PTHREADW32.EXTRACT.dir/)libpthreadGC2.a $(CONTRIB.build/)lib/
$(CP.exe) $(PTHREADW32.EXTRACT.dir/)pthread.h $(CONTRIB.build/)include/
- $(CP.exe) $(PTHREADW32.EXTRACT.dir/)pthreads_win32_config.h $(CONTRIB.build/)include/
+ $(SED.exe) -i.sedbak -e 's/ __declspec (dllexport)//g' -e 's/ __declspec (dllimport)//g' $(CONTRIB.build/)include/pthread.h
+ $(RM.exe) -f $(CONTRIB.build/)include/pthread.h.sedbak
$(CP.exe) $(PTHREADW32.EXTRACT.dir/)sched.h $(CONTRIB.build/)include/
+ $(SED.exe) -i.sedbak -e 's/ __declspec (dllexport)//g' -e 's/ __declspec (dllimport)//g' $(CONTRIB.build/)include/sched.h
+ $(RM.exe) -f $(CONTRIB.build/)include/sched.h.sedbak
$(CP.exe) $(PTHREADW32.EXTRACT.dir/)semaphore.h $(CONTRIB.build/)include/
+ $(SED.exe) -i.sedbak -e 's/ __declspec (dllexport)//g' -e 's/ __declspec (dllimport)//g' $(CONTRIB.build/)include/semaphore.h
+ $(RM.exe) -f $(CONTRIB.build/)include/semaphore.h.sedbak
+ $(CP.exe) $(PTHREADW32.EXTRACT.dir/)libpthreadGC2.a $(CONTRIB.build/)lib/
$(LN.exe) -sf ./libpthreadGC2.a $(CONTRIB.build/)lib/libpthread.a
$(TOUCH.exe) $@
endef
diff --git a/libhb/ports.c b/libhb/ports.c
index ce9e79e76..a6f89b9f5 100644
--- a/libhb/ports.c
+++ b/libhb/ports.c
@@ -471,7 +471,7 @@ int hb_platform_init()
{
int result = 0;
-#if defined(SYS_MINGW) && defined(PTW32_STATIC_LIB)
+#if defined(SYS_MINGW) && defined(PTW32_VERSION)
result = !pthread_win32_process_attach_np();
if (result)
{
@@ -810,7 +810,7 @@ static uint64_t hb_thread_to_integer( const hb_thread_t* t )
#if defined( SYS_CYGWIN )
return (uint64_t)t->thread;
#elif defined( _WIN32 ) || defined( __MINGW32__ )
- #if defined(PTW32_STATIC_LIB)
+ #if defined(PTW32_VERSION)
return (uint64_t)(ptrdiff_t)t->thread.p;
#else
return (uint64_t)t->thread;
diff --git a/make/include/tool.defs b/make/include/tool.defs
index cfd3b3ef4..53fdf89eb 100644
--- a/make/include/tool.defs
+++ b/make/include/tool.defs
@@ -12,3 +12,4 @@ MV.exe = mv
ZIP.exe = zip
LN.exe = ln
GIT.exe = git
+SED.exe = sed
diff --git a/scripts/mingw-w64-build b/scripts/mingw-w64-build
new file mode 100755
index 000000000..5c3999fe0
--- /dev/null
+++ b/scripts/mingw-w64-build
@@ -0,0 +1,440 @@
+#!/bin/bash
+# mingw-w64-build - download and build mingw-w64 toolchain
+#
+# Project: https://github.com/bradleysepos/mingw-w64-build
+# License: MIT
+
+# checks for required external tools
+function check_dependencies { # check_dependencies $DEP1 $DEP2 ...
+ local DEPS ERRORS
+ DEPS=("${@}");
+ ERRORS=()
+ for DEP in ${DEPS[@]}; do
+ if echo "${DEP}" | grep '/' >/dev/null 2>&1 && [[ ! -x "${DEP}" ]]; then
+ ERRORS+=("${DEP}")
+ elif ! hash "${DEP}" >/dev/null 2>&1; then
+ ERRORS+=("${DEP}")
+ fi
+ done
+ if [[ "${#ERRORS[@]}" -ne 0 ]]; then
+ echo "dependencies: ${DEPS[@]}"
+ echo "unable to find command(s): ${ERRORS[*]}" >&2
+ return 1
+ fi
+}
+
+# downloads from a url
+function download_url { # download_file $URL $FILE $VERBOSE
+ local URL FILE VERBOSE
+ URL="${1}"
+ FILE="${2}"
+ VERBOSE="${3}"
+ if [[ "${URL:-}" == "" ]]; then
+ echo "url not specified for download" >&2
+ return 1
+ fi
+ if [[ "${FILE:-}" == "" ]]; then
+ echo "output path not specified for download url: ${FILE}" >&2
+ return 1
+ fi
+ if ! curl --head -L "${URL}" >/dev/null 2>&1; then
+ echo "unable to download from url: ${URL}" >&2
+ return 1
+ fi
+ if ! touch "${FILE}" >/dev/null 2>&1; then
+ echo "unable to create path: ${FILE}" >&2
+ return 1
+ fi
+ if [[ "${VERBOSE:-}" == true ]]; then
+ echo "curl -L \"${URL}\" -o \"${FILE}\""
+ fi
+ if ! curl -L "${URL}" -o "${FILE}"; then
+ echo "unable to download: ${URL} -> ${FILE}" >&2
+ return 1
+ fi
+}
+
+# builds mingw-w64
+function mingw-w64-build { # mingw-w64-build $TARGET_PARAM $TARGET_DIR
+ set -o pipefail
+
+ # dependencies
+ local DEPS
+ DEPS=("bison" "bzip2" "curl" "flex" "g++" "gcc" "gunzip" "m4" "make" "pax" "yasm")
+ check_dependencies "${DEPS[@]}" || return 1
+
+ # package names
+ CONFIG_NAME="config"
+ BINUTILS_NAME="binutils"
+ MINGW_W64_NAME="mingw-w64"
+ GMP_NAME="gmp"
+ MPFR_NAME="mpfr"
+ MPC_NAME="mpc"
+ ISL_NAME="isl"
+ GCC_NAME="gcc"
+ PTW32_NAME="pthreads-win32"
+ NAMES=("${CONFIG_NAME}" "${BINUTILS_NAME}" "${MINGW_W64_NAME}" "${GMP_NAME}" "${MPFR_NAME}" "${MPC_NAME}" "${ISL_NAME}" "${GCC_NAME}" "${PTW32_NAME}")
+
+ # versions
+ local CONFIG_VER BINUTILS_VER MINGW_W64_VER GMP_VER MPFR_VER MPC_VER ISL_VER GCC_VER PTW32_VER
+ CONFIG_VER="ddd7f33"
+ BINUTILS_VER="2.26"
+ #MINGW_W64_VER="4.0.6"
+ MINGW_W64_VER="5.0-rc2"
+ GMP_VER="6.1.0"
+ MPFR_VER="3.1.4"
+ MPC_VER="1.0.3"
+ ISL_VER="0.14"
+ GCC_VER="5.4.0"
+ PTW32_VER="2.9.1"
+ PTW32_VER_URL=$(echo "${PTW32_VER}" | sed 's/\./-/g')
+
+ # urls
+ local CONFIG_URL BINUTILS_URL MINGW_W64_URL GMP_URL MPFR_URL MPC_URL ISL_URL GCC_URL PTW32_URL
+ CONFIG_URL="http://git.savannah.gnu.org/gitweb/?p=config.git;a=snapshot;h=${CONFIG_VER};sf=tgz"
+ BINUTILS_URL="https://ftp.gnu.org/gnu/binutils/binutils-${BINUTILS_VER}.tar.bz2"
+ MINGW_W64_URL="http://downloads.sourceforge.net/project/mingw-w64/mingw-w64/mingw-w64-release/mingw-w64-v${MINGW_W64_VER}.tar.bz2"
+ GMP_URL="https://ftp.gnu.org/gnu/gmp/gmp-${GMP_VER}.tar.bz2"
+ MPFR_URL="https://ftp.gnu.org/gnu/mpfr/mpfr-${MPFR_VER}.tar.gz"
+ MPC_URL="https://ftp.gnu.org/gnu/mpc/mpc-${MPC_VER}.tar.gz"
+ ISL_URL="ftp://gcc.gnu.org/pub/gcc/infrastructure/isl-${ISL_VER}.tar.bz2"
+ GCC_URL="https://ftp.gnu.org/gnu/gcc/gcc-${GCC_VER}/gcc-${GCC_VER}.tar.bz2"
+ PTW32_URL="ftp://sourceware.org/pub/pthreads-win32/pthreads-w32-${PTW32_VER_URL}-release.tar.gz"
+ URLS=("${CONFIG_URL}" "${BINUTILS_URL}" "${MINGW_W64_URL}" "${GMP_URL}" "${MPFR_URL}" "${MPC_URL}" "${ISL_URL}" "${GCC_URL}" "${PTW32_URL}")
+
+ # filenames
+ local CONFIG_PKG BINUTILS_PKG MINGW_W64_PKG GMP_PKG MPFR_PKG MPC_PKG ISL_PKG GCC_PKG PTW32_PKG
+ CONFIG_PKG="config-${CONFIG_VER}.tar.gz"
+ BINUTILS_PKG="binutils-${BINUTILS_VER}.tar.bz2"
+ MINGW_W64_PKG="mingw-w64-v${MINGW_W64_VER}.tar.bz2"
+ GMP_PKG="gmp-${GMP_VER}.tar.bz2"
+ MPFR_PKG="mpfr-${MPFR_VER}.tar.gz"
+ MPC_PKG="mpc-${MPC_VER}.tar.gz"
+ ISL_PKG="isl-${ISL_VER}.tar.bz2"
+ GCC_PKG="gcc-${GCC_VER}.tar.bz2"
+ PTW32_PKG="pthreads-w32-${PTW32_VER_URL}-release.tar.gz"
+ PKGS=("${CONFIG_PKG}" "${BINUTILS_PKG}" "${MINGW_W64_PKG}" "${GMP_PKG}" "${MPFR_PKG}" "${MPC_PKG}" "${ISL_PKG}" "${GCC_PKG}" "${PTW32_PKG}")
+
+ # internal vars
+ local NAME VERSION SELF SELF_NAME HELP
+ NAME="mingw-w64-build"
+ VERSION="1.0.0"
+ SELF="${BASH_SOURCE[0]}"
+ SELF_NAME=$(basename "${SELF}")
+ HELP="\
+usage: ${SELF_NAME} target [install-dir]
+targets:
+ i686
+ i686.clean
+ i686.distclean
+ x86_64
+ x86_64.clean
+ x86_64.distclean
+default install-dir: ${HOME}/toolchains/mingw-w64-${MINGW_W64_VER}"
+
+ # args
+ local TARGET_PARAM TARGET_DIR
+ TARGET_PARAM="${1}"
+ TARGET_DIR="${2}"
+ if [[ "${TARGET_PARAM:-}" == "" ]]; then
+ echo -e "${HELP}"
+ echo "no target specified" >&2
+ return 1
+ fi
+ if [[ "${TARGET_DIR:-}" == "" ]]; then
+ TARGET_DIR="${HOME}/toolchains/mingw-w64-${MINGW_W64_VER}"
+ fi
+
+ # target and prefix
+ local TARGET_i686 TARGET_x86_64 PREFIX_i686 PREFIX_x86_64 TARGET PREFIX
+ TARGET_i686="i686-w64-mingw32"
+ TARGET_x86_64="x86_64-w64-mingw32"
+ PREFIX_i686="mingw-w64-i686"
+ PREFIX_x86_64="mingw-w64-x86_64"
+ case "${TARGET_PARAM}" in
+ i686|i686.clean|i686.distclean|i686.pkgclean)
+ TARGET="${TARGET_i686}"
+ PREFIX="${PREFIX_i686}"
+ ;;
+ x86_64|x86_64.clean|x86_64.distclean|x86_64.pkgclean)
+ TARGET="${TARGET_x86_64}"
+ PREFIX="${PREFIX_x86_64}"
+ ;;
+ esac
+ if [[ "${PREFIX:-}" == "" ]]; then
+ echo -e "${HELP}"
+ echo "target not valid: ${TARGET_PARAM}" >&2
+ return 1
+ fi
+
+ # dirs
+ echo "path: ${TARGET_DIR}"
+ local MINGW_W64_DIR PKG_DIR SOURCE_DIR BUILD_DIR
+ MINGW_W64_DIR="${TARGET_DIR}/${PREFIX}"
+ PKG_DIR="${TARGET_DIR}/pkg"
+ SOURCE_DIR="${TARGET_DIR}/source"
+ BUILD_DIR="${TARGET_DIR}/build-${PREFIX}"
+ case "${TARGET_PARAM}" in
+ i686.clean|x86_64.clean)
+ echo "clean:"
+ echo " rm -rf \"${BUILD_DIR}\""
+ echo " rm -rf \"${SOURCE_DIR}\""
+ rm -rf "${BUILD_DIR}"
+ rm -rf "${SOURCE_DIR}"
+ echo "complete."
+ return 0
+ ;;
+ i686.distclean|x86_64.distclean)
+ echo "distclean:"
+ echo " rm -rf \"${MINGW_W64_DIR}\""
+ rm -rf "${MINGW_W64_DIR}"
+ echo "complete."
+ return 0
+ ;;
+ i686.pkgclean|x86_64.pkgclean)
+ echo "pkgclean:"
+ echo " rm -rf \"${PKG_DIR}\""
+ rm -rf "${PKG_DIR}"
+ echo "complete."
+ return 0
+ ;;
+ esac
+ mkdir -p "${TARGET_DIR}"
+ if [[ ! -d "${TARGET_DIR}" ]]; then
+ echo "unable to create directory: ${TARGET_DIR}" >&2
+ return 1
+ fi
+ if [[ -e "${MINGW_W64_DIR}" ]]; then
+ # prefix dir should not exist
+ echo "directory exists: ${MINGW_W64_DIR}" >&2
+ return 1
+ fi
+ mkdir -p "${MINGW_W64_DIR}"
+ if [[ ! -d "${MINGW_W64_DIR}" ]]; then
+ echo "unable to create directory: ${MINGW_W64_DIR}" >&2
+ return 1
+ fi
+ mkdir -p "${PKG_DIR}"
+ if [[ ! -d "${PKG_DIR}" ]]; then
+ echo "unable to create directory: ${PKG_DIR}" >&2
+ return 1
+ fi
+ mkdir -p "${SOURCE_DIR}"
+ if [[ ! -d "${SOURCE_DIR}" ]]; then
+ echo "unable to create directory: ${SOURCE_DIR}" >&2
+ return 1
+ fi
+ if [[ -e "${BUILD_DIR}" ]]; then
+ # never reuse build dir
+ rm -rf "${BUILD_DIR}"
+ fi
+ mkdir -p "${BUILD_DIR}"
+ if [[ ! -d "${BUILD_DIR}" ]]; then
+ echo "unable to create directory: ${BUILD_DIR}" >&2
+ return 1
+ fi
+
+ # verify/fetch
+ echo "verify:"
+ local DOWNLOAD_VERBOSE
+ DOWNLOAD_VERBOSE=true
+ for I in "${!PKGS[@]}"; do
+ echo " ${PKGS[I]}"
+ if ! tar -tf "${PKG_DIR}/${PKGS[I]}" >/dev/null 2>&1; then
+ download_url "${URLS[I]}" "${PKG_DIR}/${PKGS[I]}" "${DOWNLOAD_VERBOSE}" || return 1
+ fi
+ if ! tar -tf "${PKG_DIR}/${PKGS[I]}" >/dev/null 2>&1; then
+ echo "unable to verify package: ${PKG_DIR}/${PKGS[I]}" >2
+ return 1
+ fi
+ done
+
+ # extract
+ echo "extract:"
+ for I in "${!PKGS[@]}"; do
+ echo " ${PKGS[I]}"
+ if [[ -e "${SOURCE_DIR}/${NAMES[I]}" ]]; then
+ rm -rf "${SOURCE_DIR}/${NAMES[I]}"
+ fi
+ mkdir -p "${SOURCE_DIR}/${NAMES[I]}"
+ if ! tar -xf "${PKG_DIR}/${PKGS[I]}" -C "${SOURCE_DIR}/${NAMES[I]}" >/dev/null 2>&1; then
+ echo "unable to extract package: ${PKG_DIR}/${PKGS[I]}" >2
+ return 1
+ fi
+ done
+
+ # host
+ echo "host:"
+ SYS_NAME=$(uname | awk '{ print tolower($0)}')
+ SYS_ARCH=$(uname -m)
+ SYS_TYPE=$("${SOURCE_DIR}/config/config-${CONFIG_VER}/config.guess")
+ if [[ "${SYS_NAME}" == "darwin" ]]; then
+ CPU_COUNT=$(sysctl -n hw.ncpu 2>/dev/null)
+ elif [[ "${SYS_NAME}" == "linux" ]]; then
+ CPU_COUNT=$(grep -c processor /proc/cpuinfo 2>/dev/null)
+ fi
+ CPU_COUNT="${CPU_COUNT:-1}"
+ echo " name: ${SYS_NAME}"
+ echo " arch: ${SYS_ARCH}"
+ echo " type: ${SYS_TYPE}"
+ echo " vcpu: ${CPU_COUNT}"
+
+ # build
+ echo "target: ${TARGET}"
+ echo "build:"
+
+ # binutils
+ echo " binutils ${BINUTILS_VER}"
+ mkdir -pv "${BUILD_DIR}/binutils" > "${BUILD_DIR}/binutils.log" 2>&1 || return 1
+ cd "${BUILD_DIR}/binutils"
+ CC=gcc CXX=g++ "${SOURCE_DIR}/binutils/binutils-${BINUTILS_VER}/configure" --build="${SYS_TYPE}" --target="${TARGET}" --with-sysroot="${MINGW_W64_DIR}" --prefix="${MINGW_W64_DIR}" --disable-shared --enable-static --disable-multilib --disable-werror >> "${BUILD_DIR}/binutils.log" 2>&1 || return 1
+ make -j "${CPU_COUNT}" >> "${BUILD_DIR}/binutils.log" 2>&1 || return 1
+ make install-strip >> "${BUILD_DIR}/binutils.log" 2>&1 || return 1
+
+ # update PATH
+ export PATH="${MINGW_W64_DIR}/bin:${PATH}"
+
+ # mingw-w64 headers
+ echo " mingw-w64 ${MINGW_W64_VER} headers"
+ mkdir -pv "${BUILD_DIR}/mingw-w64-headers" > "${BUILD_DIR}/mingw-w64-headers.log" 2>&1 || return 1
+ cd "${BUILD_DIR}/mingw-w64-headers"
+ "${SOURCE_DIR}/mingw-w64/mingw-w64-v${MINGW_W64_VER}/mingw-w64-headers/configure" --build="${SYS_TYPE}" --host="${TARGET}" --prefix="${MINGW_W64_DIR}" --enable-sdk=all >> "${BUILD_DIR}/mingw-w64-headers.log" 2>&1 || return 1
+ make install >> "${BUILD_DIR}/mingw-w64-headers.log" 2>&1 || return 1
+
+ # create symlinks
+ cd "${MINGW_W64_DIR}"
+ ln -s "${TARGET}" mingw
+ if [[ ! -d "usr" ]]; then
+ ln -s . usr
+ fi
+ if [[ ! -d "${TARGET}/include" ]]; then
+ cd "${TARGET}"
+ ln -s ../include include
+ cd "${MINGW_W64_DIR}"
+ fi
+ if [[ ! -d "${TARGET}/usr" ]]; then
+ cd "${TARGET}"
+ ln -s . usr
+ cd "${MINGW_W64_DIR}"
+ fi
+
+ # gmp
+ echo " gmp ${GMP_VER}"
+ local GMP_DIR
+ GMP_DIR="${BUILD_DIR}/gmp-${GMP_VER}-${SYS_ARCH}"
+ mkdir -pv "${BUILD_DIR}/gmp" > "${BUILD_DIR}/gmp.log" 2>&1 || return 1
+ cd "${BUILD_DIR}/gmp"
+ CC=gcc CXX=g++ CPPFLAGS=-fexceptions "${SOURCE_DIR}/gmp/gmp-${GMP_VER}/configure" --build="${SYS_TYPE}" --prefix="${GMP_DIR}" --enable-fat --disable-shared --enable-static --enable-cxx >> "${BUILD_DIR}/gmp.log" 2>&1 || return 1
+ make -j "${CPU_COUNT}" >> "${BUILD_DIR}/gmp.log" 2>&1 || return 1
+ make check >> "${BUILD_DIR}/gmp.log" 2>&1 || return 1
+ make install >> "${BUILD_DIR}/gmp.log" 2>&1 || return 1
+
+ # mpfr
+ echo " mpfr ${MPFR_VER}"
+ local MPFR_DIR
+ MPFR_DIR="${BUILD_DIR}/mpfr-${MPFR_VER}-${SYS_ARCH}"
+ mkdir -pv "${BUILD_DIR}/mpfr" > "${BUILD_DIR}/mpfr.log" 2>&1 || return 1
+ cd "${BUILD_DIR}/mpfr"
+ CC=gcc CXX=g++ CFLAGS="-I${GMP_DIR}/include" CPPFLAGS="-I${GMP_DIR}/include" LDFLAGS="-L${GMP_DIR}/lib" "${SOURCE_DIR}/mpfr/mpfr-${MPFR_VER}/configure" --build="${SYS_TYPE}" --prefix="${MPFR_DIR}" --disable-shared --enable-static --with-gmp="${GMP_DIR}" >> "${BUILD_DIR}/mpfr.log" 2>&1 || return 1
+ make -j "${CPU_COUNT}" >> "${BUILD_DIR}/mpfr.log" 2>&1 || return 1
+ make install >> "${BUILD_DIR}/mpfr.log" 2>&1 || return 1
+
+ # mpc
+ echo " mpc ${MPC_VER}"
+ local MPC_DIR
+ MPC_DIR="${BUILD_DIR}/mpc-${MPC_VER}-${SYS_ARCH}"
+ mkdir -pv "${BUILD_DIR}/mpc" > "${BUILD_DIR}/mpc.log" 2>&1 || return 1
+ cd "${BUILD_DIR}/mpc"
+ CC=gcc CXX=g++ CFLAGS="-I${GMP_DIR}/include -I${MPFR_DIR}/include" CPPFLAGS="-I${GMP_DIR}/include -I${MPFR_DIR}/include" LDFLAGS="-L${GMP_DIR}/lib -L${MPFR_DIR}/lib" "${SOURCE_DIR}/mpc/mpc-${MPC_VER}/configure" --build="${SYS_TYPE}" --prefix="${MPC_DIR}" --with-gmp="${GMP_DIR}" --with-mpfr="${MPFR_DIR}" --disable-shared --enable-static >> "${BUILD_DIR}/mpc.log" 2>&1 || return 1
+ make -j "${CPU_COUNT}" >> "${BUILD_DIR}/mpc.log" 2>&1 || return 1
+ make install >> "${BUILD_DIR}/mpc.log" 2>&1 || return 1
+
+ # isl
+ echo " isl ${ISL_VER}"
+ local ISL_DIR
+ ISL_DIR="${BUILD_DIR}/isl-${ISL_VER}-${SYS_ARCH}"
+ mkdir -pv "${BUILD_DIR}/isl" > "${BUILD_DIR}/isl.log" 2>&1 || return 1
+ cd "${BUILD_DIR}/isl"
+ CC=gcc CXX=g++ CFLAGS="-I${GMP_DIR}/include" CPPFLAGS="-I${GMP_DIR}/include" LDFLAGS="-L${GMP_DIR}/lib" "${SOURCE_DIR}/isl/isl-${ISL_VER}/configure" --build="${SYS_TYPE}" --prefix="${ISL_DIR}" --with-gmp="${GMP_DIR}" --disable-shared --enable-static --with-piplib=no --with-clang=no >> "${BUILD_DIR}/isl.log" 2>&1 || return 1
+ make -j "${CPU_COUNT}" >> "${BUILD_DIR}/isl.log" 2>&1 || return 1
+ make install >> "${BUILD_DIR}/isl.log" 2>&1 || return 1
+
+ # gcc core
+ echo " gcc ${GCC_VER} core"
+ GCC_CONFIG_EXTRA=""
+ if [[ "${SYS_NAME}" == "darwin" ]]; then
+ GCC_CONFIG_EXTRA="--with-system-zlib"
+ fi
+ mkdir -pv "${BUILD_DIR}/gcc" > "${BUILD_DIR}/gcc.log" 2>&1 || return 1
+ cd "${BUILD_DIR}/gcc"
+ CFLAGS="-I${GMP_DIR}/include -I${MPFR_DIR}/include -I${MPC_DIR}/include -I${ISL_DIR}/include" CPPFLAGS="-I${GMP_DIR}/include -I${MPFR_DIR}/include -I${MPC_DIR}/include -I${ISL_DIR}/include" LDFLAGS="-L${GMP_DIR}/lib -L${MPFR_DIR}/lib -L${MPC_DIR}/lib -L${ISL_DIR}/lib" "${SOURCE_DIR}/gcc/gcc-${GCC_VER}/configure" --build="${SYS_TYPE}" --host="${SYS_TYPE}" --target="${TARGET}" --prefix="${MINGW_W64_DIR}" --with-sysroot="${MINGW_W64_DIR}" --with-gmp="${GMP_DIR}" --with-mpfr="${MPFR_DIR}" --with-mpc="${MPC_DIR}" --with-isl="${ISL_DIR}" --disable-shared --enable-static --disable-multilib --disable-nls --disable-libstdcxx-pch --disable-win32-registry --enable-checking=release --enable-languages=c,c++ --enable-fully-dynamic-string --enable-version-specific-runtime-libs --enable-lto "${GCC_CONFIG_EXTRA}" >> "${BUILD_DIR}/gcc.log" 2>&1 || return 1
+ make -j "${CPU_COUNT}" all-gcc >> "${BUILD_DIR}/gcc.log" 2>&1 || return 1
+ make install-gcc >> "${BUILD_DIR}/gcc.log" 2>&1 || return 1
+
+ # mingw-w64 runtime
+ echo " mingw-w64 ${MINGW_W64_VER} runtime"
+ local MINGW_W64_CONFIG_EXTRA
+ MINGW_W64_CONFIG_EXTRA=""
+ if [[ "${TARGET}" == "${TARGET_i686}" ]]; then
+ MINGW_W64_CONFIG_EXTRA="--disable-lib64"
+ elif [[ "${TARGET}" == "${TARGET_x86_64}" ]]; then
+ MINGW_W64_CONFIG_EXTRA="--disable-lib32"
+ fi
+ mkdir -pv "${BUILD_DIR}/mingw-w64-crt" > "${BUILD_DIR}/mingw-w64-crt.log" 2>&1 || return 1
+ cd "${BUILD_DIR}/mingw-w64-crt"
+ "${SOURCE_DIR}/mingw-w64/mingw-w64-v${MINGW_W64_VER}/mingw-w64-crt/configure" --build="${SYS_TYPE}" --host="${TARGET}" --prefix="${MINGW_W64_DIR}" --with-sysroot="${MINGW_W64_DIR}" "${MINGW_W64_CONFIG_EXTRA}" >> "${BUILD_DIR}/mingw-w64-crt.log" 2>&1 || return 1
+ if [[ "${SYS_NAME}" == "darwin" ]]; then
+ # parallel build fails on darwin
+ make -j 1 >> "${BUILD_DIR}/mingw-w64-crt.log" 2>&1 || return 1
+ else
+ make -j "${CPU_COUNT}" >> "${BUILD_DIR}/mingw-w64-crt.log" 2>&1 || return 1
+ fi
+ make install-strip >> "${BUILD_DIR}/mingw-w64-crt.log" 2>&1 || return 1
+
+ # relocate and symlink libs
+ cd "${MINGW_W64_DIR}"
+ mv "${TARGET}/lib/"* lib/
+ rm -rf "${TARGET}/lib"
+ cd "${TARGET}"
+ ln -s ../lib lib
+
+ # gcc
+ echo " gcc ${GCC_VER}"
+ cd "${BUILD_DIR}/gcc"
+ make -j "${CPU_COUNT}" all-target-libgcc >> "${BUILD_DIR}/gcc.log" 2>&1 || return 1
+ make -j "${CPU_COUNT}" install-target-libgcc >> "${BUILD_DIR}/gcc.log" 2>&1 || return 1
+ make -j "${CPU_COUNT}" >> "${BUILD_DIR}/gcc.log" 2>&1 || return 1
+ make install-strip >> "${BUILD_DIR}/gcc.log" 2>&1 || return 1
+
+ # pthreads-w32
+ echo " pthreads-win32 ${PTW32_VER}"
+ mkdir -pv "${BUILD_DIR}/pthreads-win32" > "${BUILD_DIR}/pthreads-win32.log" 2>&1 || return 1
+ cp -Rv "${SOURCE_DIR}/pthreads-win32/pthreads-w32-${PTW32_VER_URL}-release/"* "${BUILD_DIR}/pthreads-win32/" >> "${BUILD_DIR}/pthreads-win32.log" 2>&1 || return 1
+ cd "${BUILD_DIR}/pthreads-win32"
+ make realclean >> "${BUILD_DIR}/pthreads-win32.log" 2>&1 || return 1
+ make CROSS="${TARGET}-" realclean GC-static >> "${BUILD_DIR}/pthreads-win32.log" 2>&1 || return 1
+ cp -v libpthreadGC2.a "${MINGW_W64_DIR}/lib/" >> "${BUILD_DIR}/pthreads-win32.log" 2>&1 || return 1
+ cp -v pthread.h sched.h semaphore.h "${MINGW_W64_DIR}/include/" >> "${BUILD_DIR}/pthreads-win32.log" 2>&1 || return 1
+ cd "${MINGW_W64_DIR}/lib"
+ ln -fsv libpthreadGC2.a libpthread.a >> "${BUILD_DIR}/pthreads-win32.log" 2>&1 || return 1
+ cd "${MINGW_W64_DIR}/include"
+ for F in pthread.h sched.h semaphore.h; do
+ sed -i.sedbak -e 's/ __declspec (dllexport)//g' -e 's/ __declspec (dllimport)//g' "${F}"
+ rm -f "${F}.sedbak"
+ done
+
+ # clean up
+ cd "${MINGW_W64_DIR}"
+ find . -name "*.la" -type f -exec rm {} ";" >/dev/null 2>&1
+
+ # done
+ echo "bin: ${MINGW_W64_DIR}/bin"
+ echo " add to your shell startup script (usually .bashrc or .bash_profile):"
+ echo " export PATH=\"${MINGW_W64_DIR}/bin:\${PATH}\""
+ echo "complete."
+ return 0
+
+ set +o pipefail
+}
+
+mingw-w64-build "${@}"