Commit 6f20847b authored by Steve Lhomme's avatar Steve Lhomme

contrib: limit the use of pthreads-w32 to winstore builds for now

parent a77bf1c6
......@@ -19,13 +19,15 @@ aom: aom-$(AOM_VERSION).tar.gz .sum-aom
rm -Rf $@-$(AOM_VERSION) $@
mkdir -p $@-$(AOM_VERSION)
tar xvzf "$<" -C $@-$(AOM_VERSION)
ifdef HAVE_WINSTORE
$(APPLY) $(SRC)/aom/aom-pthreads-win32.patch
endif
$(MOVE)
AOM_CFLAGS := $(CFLAGS)
AOM_CXXFLAGS := $(CXXFLAGS)
DEPS_aom =
ifdef HAVE_WIN32
ifdef HAVE_WINSTORE
DEPS_aom += pthreads $(DEPS_pthreads)
AOM_CFLAGS += -DPTW32_STATIC_LIB
AOM_CXXFLAGS += -DPTW32_STATIC_LIB
......
......@@ -16,17 +16,12 @@ new file mode 100644
index 0000000..4c431cf
--- /dev/null
+++ b/Makefile
@@ -0,0 +1,43 @@
@@ -0,0 +1,38 @@
+SRCS := colorspace.c common.c context.c dither.c dispatch.c filters.c ra.c renderer.c shaders.c \
+ shaders/colorspace.c shaders/sampling.c spirv.c bstr/bstr.c bstr/format.c 3rdparty/siphash.c \
+ ta/ta.c ta/ta_utils.c ta/talloc.c
+
+ifdef HAVE_WIN32
+CFLAGS += -DPTW32_STATIC_LIB
+lpthread_libs = -lpthreadGC2 -lws2_32
+else
+lpthread_libs = $(shell $(LD) -lpthread && echo "-lpthread" || echo "")
+endif
+
+OBJS = $(patsubst %.c, $(OBJDIR)src/%.o, $(SRCS))
+
......
......@@ -8,9 +8,6 @@ LIBPLACEBO_CFLAGS := $(CFLAGS)
LIBPLACEBO_CXXFLAGS := $(CXXFLAGS)
ifdef HAVE_WIN32
LIBPLACEBO_WIN32 = HAVE_WIN32=1
DEPS_libplacebo += pthreads $(DEPS_pthreads)
LIBPLACEBO_CFLAGS += -DPTW32_STATIC_LIB
LIBPLACEBO_CXXFLAGS += -DPTW32_STATIC_LIB
endif
PKGS += libplacebo
......
......@@ -12,7 +12,7 @@ endif
MYSOFA_CFLAGS := $(CFLAGS)
MYSOFA_CXXFLAGS := $(CXXFLAGS)
DEPS_mysofa += zlib $(DEPS_zlib)
ifdef HAVE_WIN32
ifdef HAVE_WINSTORE
DEPS_mysofa += pthreads $(DEPS_pthreads)
MYSOFA_CFLAGS += -DPTW32_STATIC_LIB
MYSOFA_CXXFLAGS += -DPTW32_STATIC_LIB
......
......@@ -5,7 +5,7 @@ OPENJPEG_URL := https://github.com/uclouvain/openjpeg/archive/v$(OPENJPEG_VERSIO
OPENJPEG_CFLAGS := $(CFLAGS)
OPENJPEG_CXXFLAGS := $(CXXFLAGS)
ifdef HAVE_WIN32
ifdef HAVE_WINSTORE
DEPS_openjpeg += pthreads $(DEPS_pthreads)
OPENJPEG_CFLAGS += -DPTW32_STATIC_LIB
OPENJPEG_CXXFLAGS += -DPTW32_STATIC_LIB
......
......@@ -30,7 +30,7 @@ $(TARBALLS)/protobuf-$(PROTOBUF_VERSION)-cpp.tar.gz:
PROTOBUF_CFLAGS := $(CFLAGS)
PROTOBUF_CXXFLAGS := $(CXXFLAGS)
DEPS_protobuf = zlib $(DEPS_zlib)
ifdef HAVE_WIN32
ifdef HAVE_WINSTORE
DEPS_protobuf += pthreads $(DEPS_pthreads)
PROTOBUF_CFLAGS += -DPTW32_STATIC_LIB
PROTOBUF_CXXFLAGS += -DPTW32_STATIC_LIB
......
......@@ -14,7 +14,7 @@ endif
SRT_CFLAGS := $(CFLAGS)
SRT_CXXFLAGS := $(CXXFLAGS)
DEPS_srt = gnutls $(DEPS_gnutls)
ifdef HAVE_WIN32
ifdef HAVE_WINSTORE
DEPS_srt += pthreads $(DEPS_pthreads)
SRT_CFLAGS += -DPTW32_STATIC_LIB
SRT_CXXFLAGS += -DPTW32_STATIC_LIB
......@@ -34,9 +34,9 @@ srt: srt-$(SRT_VERSION).tar.gz .sum-srt
$(UNPACK)
$(APPLY) $(SRC)/srt/add-implicit-link-libraries.patch
$(APPLY) $(SRC)/srt/0001-CMakeLists.txt-substitute-link-flags-for-package-nam.patch
$(APPLY) $(SRC)/srt/0002-CMakeLists.txt-let-cmake-find-pthread.patch
$(APPLY) $(SRC)/srt/srt-fix-non-gnu-detection.patch
ifdef HAVE_WIN32
ifdef HAVE_WINSTORE
$(APPLY) $(SRC)/srt/0002-CMakeLists.txt-let-cmake-find-pthread.patch
$(APPLY) $(SRC)/srt/srt-no-implicit-libs.patch
endif
$(call pkg_static,"scripts/haisrt.pc.in")
......
--- libupnp/configure.ac.orig 2011-02-09 00:55:44.000000000 +0100
+++ libupnp/configure.ac 2011-02-10 23:39:44.154929678 +0100
@@ -397,7 +397,6 @@
AC_PROG_MAKE_SET
AC_PROG_EGREP
-#
# Default compilation flags
#
echo "--------------------- Default compilation flags -------------------------------"
@@ -531,39 +530,46 @@
# Checks for POSIX Threads
#
echo "--------------------------- pthread stuff -------------------------------------"
-ACX_PTHREAD(
- [],
- [AC_MSG_ERROR([POSIX threads are required to build this program])])
+#ACX_PTHREAD(
+# [],
+# [AC_MSG_ERROR([POSIX threads are required to build this program])])
#
+PTHREAD_LIBS=" -lpthreadGC2 -lws2_32"
+PTHREAD_CFLAGS=" -DPTW32_STATIC_LIB -DUPNP_STATIC_LIB"
# Update environment variables for pthreads
#
-CC="$PTHREAD_CC"
+#CC="$PTHREAD_CC"
CFLAGS="$PTHREAD_CFLAGS $CFLAGS"
LIBS="$PTHREAD_LIBS $LIBS"
+
+AC_SUBST(PTHREAD_LIBS)
+AC_SUBST(PTHREAD_CFLAGS)
+AC_SUBST(PTHREAD_CC)
+
#
# Determine if pthread_rwlock_t is available
#
-echo "----------------------- pthread_rwlock_t stuff --------------------------------"
-AC_MSG_CHECKING([if pthread_rwlock_t is available])
-AC_LANG([C])
-AC_COMPILE_IFELSE(
- [AC_LANG_PROGRAM(
- [#include <pthread.h>],
- [pthread_rwlock_t *x;])],
- [AC_DEFINE([UPNP_USE_RWLOCK], [1], [Use pthread_rwlock_t])
- AC_MSG_RESULT([yes, supported without any options])],
- [AC_COMPILE_IFELSE(
- [AC_LANG_PROGRAM(
- [#define _GNU_SOURCE
- #include <pthread.h>],
- [pthread_rwlock_t *x;])],
- [AC_DEFINE([UPNP_USE_RWLOCK], [1], [Use pthread_rwlock_t])
- CPPFLAGS="$CPPFLAGS -D_GNU_SOURCE"
- AC_MSG_RESULT([yes, definition of _GNU_SOURCE required])],
- [AC_DEFINE([UPNP_USE_RWLOCK], [0], [Do not use pthread_rwlock_t])
- AC_MSG_RESULT([no, needs to fallback to pthread_mutex])
- AC_MSG_ERROR([pthread_rwlock_t not available])])])
-echo "-------------------------------------------------------------------------------"
+#echo "----------------------- pthread_rwlock_t stuff --------------------------------"
+#AC_MSG_CHECKING([if pthread_rwlock_t is available])
+#AC_LANG([C])
+#AC_COMPILE_IFELSE(
+# [AC_LANG_PROGRAM(
+# [#include <pthread.h>],
+# [pthread_rwlock_t *x;])],
+# [AC_DEFINE([UPNP_USE_RWLOCK], [1], [Use pthread_rwlock_t])
+# AC_MSG_RESULT([yes, supported without any options])],
+# [AC_COMPILE_IFELSE(
+# [AC_LANG_PROGRAM(
+# [#define _GNU_SOURCE
+# #include <pthread.h>],
+# [pthread_rwlock_t *x;])],
+# [AC_DEFINE([UPNP_USE_RWLOCK], [1], [Use pthread_rwlock_t])
+# CPPFLAGS="$CPPFLAGS -D_GNU_SOURCE"
+# AC_MSG_RESULT([yes, definition of _GNU_SOURCE required])],
+# [AC_DEFINE([UPNP_USE_RWLOCK], [0], [Do not use pthread_rwlock_t])
+# AC_MSG_RESULT([no, needs to fallback to pthread_mutex])
+# AC_MSG_ERROR([pthread_rwlock_t not available])])])
+#echo "-------------------------------------------------------------------------------"
AC_CONFIG_FILES([
--- upnp/threadutil/src/ThreadPool.c.pthread-w32 2018-05-17 10:53:48.438587300 +0200
+++ upnp/threadutil/src/ThreadPool.c 2018-05-17 10:54:03.696907300 +0200
@@ -34,7 +34,7 @@
* \file
*/
-#if !defined(WIN32)
+#if !defined(WIN32) || !defined(_MSC_VER)
#include <sys/param.h>
#endif
@@ -263,8 +263,16 @@ static int SetPolicyType(
#elif defined(__OSX__) || defined(__APPLE__) || defined(__NetBSD__)
setpriority(PRIO_PROCESS, 0, 0);
retVal = 0;
-#elif defined(WIN32)
+#elif defined(PTW32_LEVEL)
retVal = sched_setscheduler(0, in);
+#elif defined(WIN32)
+ struct sched_param current;
+ int sched_result;
+
+ memset(&current, 0, sizeof(current));
+ current.sched_priority = sched_get_priority_min(DEFAULT_POLICY);
+ sched_result = sched_setscheduler(0, in, &current);
+ retVal = (sched_result != -1 || errno == EPERM) ? 0 : errno;
#elif defined(_POSIX_PRIORITY_SCHEDULING) && _POSIX_PRIORITY_SCHEDULING > 0
struct sched_param current;
int sched_result;
@@ -415,11 +423,11 @@ static void SetSeed(void)
struct timeval t;
gettimeofday(&t, NULL);
-#if defined(WIN32)
+#if defined(PTW32_LEVEL)
srand((unsigned int)t.tv_usec + (unsigned int)ithread_get_current_thread_id().p);
#elif defined(BSD) || defined(__OSX__) || defined(__APPLE__) || defined(__FreeBSD_kernel__)
srand((unsigned int)t.tv_usec + (unsigned int)ithread_get_current_thread_id());
-#elif defined(__linux__) || defined(__sun) || defined(__CYGWIN__) || defined(__GLIBC__)
+#elif defined(__linux__) || defined(__sun) || defined(__CYGWIN__) || defined(__GLIBC__) || defined(WIN32)
srand((unsigned int)t.tv_usec + (unsigned int)ithread_get_current_thread_id());
#else
{
--- upnp/upnp/src/api/upnpdebug.c.pthread-w32 2018-05-17 10:53:05.030173700 +0200
+++ upnp/upnp/src/api/upnpdebug.c 2018-05-17 10:53:44.686358100 +0200
@@ -183,7 +183,7 @@ void UpnpDisplayFileAndLine(FILE *fd, co
lines[i] = buf[i];
/* Put the debug lines in the buffer */
sprintf(buf[0], "DEBUG - THREAD ID: 0x%lX",
-#ifdef WIN32
+#if defined(PTW32_LEVEL)
(unsigned long int)ithread_self().p
#else
(unsigned long int)ithread_self()
--- upnp/configure.ac.pthread-w32 2018-05-17 11:51:47.115502500 +0200
+++ upnp/configure.ac 2018-05-17 12:49:30.371786100 +0200
@@ -667,6 +667,7 @@ ACX_PTHREAD(
#
# Update environment variables for pthreads
#
+PTHREAD_LIBS="-lpthreadGC2"
CC="$PTHREAD_CC"
CFLAGS="$PTHREAD_CFLAGS $CFLAGS"
LIBS="$PTHREAD_LIBS $LIBS"
@@ -676,7 +677,7 @@ PC_CFLAGS="$PTHREAD_CFLAGS"
# WIN32 specific
if test "$ac_cv_win32" = "yes"; then
WIN32_LIBS="-liphlpapi -lws2_32"
-PC_CFLAGS="$PC_CFLAGS -DUPNP_STATIC_LIB"
+PC_CFLAGS="$PC_CFLAGS -DUPNP_STATIC_LIB -DPTW32_STATIC_LIB"
fi
AC_SUBST(PC_CFLAGS)
AC_SUBST(WIN32_LIBS)
--- upnp/configure.ac.win32 2013-11-15 17:18:45.000000000 +0100
+++ upnp/configure.ac 2018-05-17 11:41:56.647083600 +0200
@@ -670,6 +670,17 @@ ACX_PTHREAD(
CC="$PTHREAD_CC"
CFLAGS="$PTHREAD_CFLAGS $CFLAGS"
LIBS="$PTHREAD_LIBS $LIBS"
+
+PC_CFLAGS="$PTHREAD_CFLAGS"
+
+# WIN32 specific
+if test "$ac_cv_win32" = "yes"; then
+WIN32_LIBS="-liphlpapi -lws2_32"
+PC_CFLAGS="$PC_CFLAGS -DUPNP_STATIC_LIB"
+fi
+AC_SUBST(PC_CFLAGS)
+AC_SUBST(WIN32_LIBS)
+
#
# Determine if pthread_rwlock_t is available
#
--- upnp/libupnp.pc.in.win32 2010-12-23 21:24:05.000000000 +0100
+++ upnp/libupnp.pc.in 2018-05-17 11:43:06.014745400 +0200
@@ -6,6 +6,6 @@ includedir=@includedir@
Name: libupnp
Description: Linux SDK for UPnP Devices
Version: @VERSION@
-Libs: @PTHREAD_CFLAGS@ @PTHREAD_LIBS@ -L${libdir} -lupnp -lthreadutil -lixml
-Cflags: @PTHREAD_CFLAGS@ -I${includedir}/upnp
+Libs: -L${libdir} -lupnp -lthreadutil -lixml @PTHREAD_LIBS@ @WIN32_LIBS@
+Cflags: @PC_CFLAGS@ -I${includedir}/upnp
--- libupnp/configure.ac.orig 2011-02-10 23:53:25.000000000 +0100
+++ libupnp/configure.ac 2011-02-10 23:54:23.574454501 +0100
@@ -546,6 +546,7 @@
AC_SUBST(PTHREAD_CFLAGS)
AC_SUBST(PTHREAD_CC)
+AC_DEFINE([_WIN32_WINNT], 0x0501, [Define to '0x0500' for Windows 2000 APIs.])
#
# Determine if pthread_rwlock_t is available
#
--- libupnp/libupnp.pc.in 2010-12-23 21:24:05.000000000 +0100
+++ libupnp.new/libupnp.pc.in 2011-02-13 11:27:23.000000000 +0100
@@ -6,6 +6,6 @@
Name: libupnp
Description: Linux SDK for UPnP Devices
Version: @VERSION@
-Libs: @PTHREAD_CFLAGS@ @PTHREAD_LIBS@ -L${libdir} -lupnp -lthreadutil -lixml
+Libs: @PTHREAD_CFLAGS@ -L${libdir} -lupnp -lthreadutil -lixml -liphlpapi @PTHREAD_LIBS@
Cflags: @PTHREAD_CFLAGS@ -I${includedir}/upnp
--- libupnp/upnp/src/inc/upnputil.h 2010-12-23 21:24:06.000000000 +0100
+++ libupnp.new/upnp/src/inc/upnputil.h 2011-02-13 08:24:24.000000000 +0100
@@ -125,7 +125,7 @@
......
......@@ -13,7 +13,7 @@ $(TARBALLS)/libupnp-$(UPNP_VERSION).tar.bz2:
UPNP_CFLAGS := $(CFLAGS) -DUPNP_STATIC_LIB
UPNP_CXXFLAGS := $(CXXFLAGS) -DUPNP_STATIC_LIB
ifdef HAVE_WIN32
ifdef HAVE_WINSTORE
DEPS_upnp += pthreads $(DEPS_pthreads)
UPNP_CFLAGS += -DPTW32_STATIC_LIB
UPNP_CXXFLAGS += -DPTW32_STATIC_LIB
......@@ -30,14 +30,15 @@ endif
upnp: libupnp-$(UPNP_VERSION).tar.bz2 .sum-upnp
$(UNPACK)
ifdef HAVE_WIN32
$(APPLY) $(SRC)/upnp/libupnp-configure.patch
$(APPLY) $(SRC)/upnp/libupnp-win32.patch
$(APPLY) $(SRC)/upnp/libupnp-win64.patch
$(APPLY) $(SRC)/upnp/windows-random.patch
$(APPLY) $(SRC)/upnp/windows-version-inet.patch
$(APPLY) $(SRC)/upnp/libupnp-win32-exports.patch
$(APPLY) $(SRC)/upnp/libupnp-pthread-w32-checks.patch
ifdef HAVE_WINSTORE
$(APPLY) $(SRC)/upnp/winrt-dont-force-win32-winnt.patch
$(APPLY) $(SRC)/upnp/no-getifinfo.patch
$(APPLY) $(SRC)/upnp/libupnp-pthread-w32-force.patch
endif
endif
$(APPLY) $(SRC)/upnp/libpthread.patch
......
......@@ -23,7 +23,7 @@ endif
$(APPLY) $(SRC)/vpx/0001-ads2gas-Add-a-noelf-option.patch
$(APPLY) $(SRC)/vpx/0002-configure-Add-an-armv7-win32-gcc-target.patch
$(APPLY) $(SRC)/vpx/0003-configure-Add-an-arm64-win64-gcc-target.patch
ifdef HAVE_WIN32
ifdef HAVE_WINSTORE
$(APPLY) $(SRC)/vpx/libvpx-pthread-w32.patch
endif
$(MOVE)
......@@ -32,7 +32,7 @@ DEPS_vpx =
VPX_CFLAGS := $(CFLAGS)
VPX_CXXFLAGS := $(CXXFLAGS)
ifdef HAVE_WIN32
ifdef HAVE_WINSTORE
DEPS_vpx += pthreads $(DEPS_pthreads)
VPX_CFLAGS += -DPTW32_STATIC_LIB
VPX_CXXFLAGS += -DPTW32_STATIC_LIB
......
......@@ -35,7 +35,11 @@ X264CONF = --prefix="$(PREFIX)" --host="$(HOST)" \
ifndef HAVE_WIN32
X264CONF += --enable-pic
else
ifdef HAVE_WINSTORE
X264CONF += --enable-win32thread
else
X264CONF += --disable-win32thread
endif
ifeq ($(ARCH), arm)
X264_AS = AS="./tools/gas-preprocessor.pl -arch arm -as-type clang -force-thumb -- $(CC) -mimplicit-it=always"
endif
......
......@@ -20,6 +20,9 @@ zvbi: zvbi-$(ZVBI_VERSION).tar.bz2 .sum-zvbi
$(APPLY) $(SRC)/zvbi/zvbi-fix-static-linking.patch
ifdef HAVE_WIN32
$(APPLY) $(SRC)/zvbi/zvbi-win32.patch
ifdef HAVE_WINSTORE
$(APPLY) $(SRC)/zvbi/zvbi-pthread-w32.patch
endif
endif
$(APPLY) $(SRC)/zvbi/zvbi-fix-clang-support.patch
ifdef HAVE_ANDROID
......@@ -30,12 +33,18 @@ endif
DEPS_zvbi = png $(DEPS_png) iconv $(DEPS_iconv)
ZVBI_CFLAGS := $(CFLAGS)
ZVBI_CXXFLAGS := $(CXXFLAGS)
ZVBICONF := \
--disable-dvb --disable-bktr \
--disable-nls --disable-proxy \
--without-doxygen \
$(HOSTCONF)
ifdef HAVE_WINSTORE
DEPS_upnp += pthreads $(DEPS_pthreads)
ZVBI_CFLAGS += -DPTW32_STATIC_LIB
ZVBI_CXXFLAGS += -DPTW32_STATIC_LIB
endif
ifdef HAVE_MACOSX
ZVBI_CFLAGS += -fnested-functions
endif
......@@ -43,7 +52,7 @@ endif
.zvbi: zvbi
$(UPDATE_AUTOCONFIG)
$(RECONF)
cd $< && $(HOSTVARS) CFLAGS="$(ZVBI_CFLAGS)" ./configure $(ZVBICONF)
cd $< && $(HOSTVARS) CFLAGS="$(ZVBI_CFLAGS)" CXXFLAGS="$(ZVBI_CXXFLAGS)" ./configure $(ZVBICONF)
cd $< && $(MAKE) -C src install
cd $< && $(MAKE) SUBDIRS=. install
sed -i.orig -e "s/\/[^ ]*libiconv.a/-liconv/" $(PREFIX)/lib/pkgconfig/zvbi-0.2.pc
......
--- zvbi/configure.in 2018-05-16 14:04:41.881375400 +0200
+++ zvbi/configure.in.pthread-w32 2018-05-16 14:03:52.661096100 +0200
@@ -167,7 +167,7 @@ dnl
dnl Check how to link pthreads functions.
dnl (-lpthread on Linux, -pthread on FreeBSD).
dnl
-AC_CHECK_LIB(pthread, pthread_create,,[
+AC_SEARCH_LIBS(pthread_create,[pthreadGC2 pthread],,[
AC_TRY_LINK(, pthread_create();,,[
LDFLAGS="$LDFLAGS -pthread"
AC_TRY_LINK(, pthread_create();,,[
......@@ -107,17 +107,6 @@ diff -ruN zvbi/src/vbi.c zvbi.new/src/vbi.c
#include <sys/time.h>
#include <pthread.h>
--- zvbi/configure.in 2018-05-16 14:04:41.881375400 +0200
+++ zvbi/configure.in.pthread-w32 2018-05-16 14:03:52.661096100 +0200
@@ -167,7 +167,7 @@ dnl
dnl Check how to link pthreads functions.
dnl (-lpthread on Linux, -pthread on FreeBSD).
dnl
-AC_CHECK_LIB(pthread, pthread_create,,[
+AC_SEARCH_LIBS(pthread_create,[pthreadGC2 pthread],,[
AC_TRY_LINK(, pthread_create();,,[
LDFLAGS="$LDFLAGS -pthread"
AC_TRY_LINK(, pthread_create();,,[
--- zvbi/src/io.c 2008-02-19 01:35:20.000000000 +0100
+++ zvbi2/src/io.c 2008-09-11 21:18:59.000000000 +0200
@@ -28,8 +28,10 @@
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment