summaryrefslogtreecommitdiff
path: root/libs
diff options
context:
space:
mode:
authorGeorge Hazan <ghazan@miranda.im>2021-06-06 22:01:10 +0300
committerGeorge Hazan <ghazan@miranda.im>2021-06-06 22:01:10 +0300
commitb18dd79bc6b6ee3658ef4513665cb84c24030368 (patch)
tree52dcfedbf246865021e0cb0e13f9ff22b08d9504 /libs
parentfedcdca7ed8f402550227c5c6e9c1d28417b896c (diff)
fixes #2909 (pthreads updated to 2.11.0)
Diffstat (limited to 'libs')
-rw-r--r--libs/pthreads/src/GNUmakefile.in408
-rw-r--r--libs/pthreads/src/TODO26
-rw-r--r--libs/pthreads/src/WinCE-PORT222
-rw-r--r--libs/pthreads/src/_ptw32.h218
-rw-r--r--libs/pthreads/src/attr.c53
-rw-r--r--libs/pthreads/src/autostatic.c69
-rw-r--r--libs/pthreads/src/barrier.c47
-rw-r--r--libs/pthreads/src/cancel.c44
-rw-r--r--libs/pthreads/src/cleanup.c46
-rw-r--r--libs/pthreads/src/condvar.c50
-rw-r--r--libs/pthreads/src/config.h52
-rw-r--r--libs/pthreads/src/context.h44
-rw-r--r--libs/pthreads/src/create.c263
-rw-r--r--libs/pthreads/src/dll.c127
-rw-r--r--libs/pthreads/src/errno.c55
-rw-r--r--libs/pthreads/src/exit.c44
-rw-r--r--libs/pthreads/src/fork.c39
-rw-r--r--libs/pthreads/src/global.c50
-rw-r--r--libs/pthreads/src/implement.h278
-rw-r--r--libs/pthreads/src/misc.c50
-rw-r--r--libs/pthreads/src/mutex.c62
-rw-r--r--libs/pthreads/src/need_errno.h57
-rw-r--r--libs/pthreads/src/nonportable.c47
-rw-r--r--libs/pthreads/src/private.c54
-rw-r--r--libs/pthreads/src/pthread.c206
-rw-r--r--libs/pthreads/src/pthread.h632
-rw-r--r--libs/pthreads/src/pthread_attr_destroy.c46
-rw-r--r--libs/pthreads/src/pthread_attr_getaffinity_np.c56
-rw-r--r--libs/pthreads/src/pthread_attr_getdetachstate.c46
-rw-r--r--libs/pthreads/src/pthread_attr_getinheritsched.c46
-rw-r--r--libs/pthreads/src/pthread_attr_getname_np.c53
-rw-r--r--libs/pthreads/src/pthread_attr_getschedparam.c46
-rw-r--r--libs/pthreads/src/pthread_attr_getschedpolicy.c55
-rw-r--r--libs/pthreads/src/pthread_attr_getscope.c46
-rw-r--r--libs/pthreads/src/pthread_attr_getstackaddr.c50
-rw-r--r--libs/pthreads/src/pthread_attr_getstacksize.c48
-rw-r--r--libs/pthreads/src/pthread_attr_init.c50
-rw-r--r--libs/pthreads/src/pthread_attr_setaffinity_np.c56
-rw-r--r--libs/pthreads/src/pthread_attr_setdetachstate.c46
-rw-r--r--libs/pthreads/src/pthread_attr_setinheritsched.c46
-rw-r--r--libs/pthreads/src/pthread_attr_setname_np.c98
-rw-r--r--libs/pthreads/src/pthread_attr_setschedparam.c46
-rw-r--r--libs/pthreads/src/pthread_attr_setschedpolicy.c46
-rw-r--r--libs/pthreads/src/pthread_attr_setscope.c46
-rw-r--r--libs/pthreads/src/pthread_attr_setstackaddr.c48
-rw-r--r--libs/pthreads/src/pthread_attr_setstacksize.c48
-rw-r--r--libs/pthreads/src/pthread_barrier_destroy.c46
-rw-r--r--libs/pthreads/src/pthread_barrier_init.c46
-rw-r--r--libs/pthreads/src/pthread_barrier_wait.c46
-rw-r--r--libs/pthreads/src/pthread_barrierattr_destroy.c46
-rw-r--r--libs/pthreads/src/pthread_barrierattr_getpshared.c46
-rw-r--r--libs/pthreads/src/pthread_barrierattr_init.c46
-rw-r--r--libs/pthreads/src/pthread_barrierattr_setpshared.c46
-rw-r--r--libs/pthreads/src/pthread_cancel.c60
-rw-r--r--libs/pthreads/src/pthread_cond_destroy.c54
-rw-r--r--libs/pthreads/src/pthread_cond_init.c50
-rw-r--r--libs/pthreads/src/pthread_cond_signal.c50
-rw-r--r--libs/pthreads/src/pthread_cond_wait.c63
-rw-r--r--libs/pthreads/src/pthread_condattr_destroy.c46
-rw-r--r--libs/pthreads/src/pthread_condattr_getpshared.c46
-rw-r--r--libs/pthreads/src/pthread_condattr_init.c46
-rw-r--r--libs/pthreads/src/pthread_condattr_setpshared.c46
-rw-r--r--libs/pthreads/src/pthread_delay_np.c52
-rw-r--r--libs/pthreads/src/pthread_detach.c58
-rw-r--r--libs/pthreads/src/pthread_equal.c46
-rw-r--r--libs/pthreads/src/pthread_exit.c50
-rw-r--r--libs/pthreads/src/pthread_getconcurrency.c46
-rw-r--r--libs/pthreads/src/pthread_getname_np.c71
-rw-r--r--libs/pthreads/src/pthread_getschedparam.c60
-rw-r--r--libs/pthreads/src/pthread_getspecific.c46
-rw-r--r--libs/pthreads/src/pthread_getunique_np.c46
-rw-r--r--libs/pthreads/src/pthread_getw32threadhandle_np.c46
-rw-r--r--libs/pthreads/src/pthread_join.c50
-rw-r--r--libs/pthreads/src/pthread_key_create.c46
-rw-r--r--libs/pthreads/src/pthread_key_delete.c168
-rw-r--r--libs/pthreads/src/pthread_kill.c46
-rw-r--r--libs/pthreads/src/pthread_mutex_consistent.c66
-rw-r--r--libs/pthreads/src/pthread_mutex_destroy.c46
-rw-r--r--libs/pthreads/src/pthread_mutex_init.c92
-rw-r--r--libs/pthreads/src/pthread_mutex_lock.c46
-rw-r--r--libs/pthreads/src/pthread_mutex_timedlock.c71
-rw-r--r--libs/pthreads/src/pthread_mutex_trylock.c50
-rw-r--r--libs/pthreads/src/pthread_mutex_unlock.c49
-rw-r--r--libs/pthreads/src/pthread_mutexattr_destroy.c46
-rw-r--r--libs/pthreads/src/pthread_mutexattr_getkind_np.c46
-rw-r--r--libs/pthreads/src/pthread_mutexattr_getpshared.c46
-rw-r--r--libs/pthreads/src/pthread_mutexattr_getrobust.c46
-rw-r--r--libs/pthreads/src/pthread_mutexattr_gettype.c46
-rw-r--r--libs/pthreads/src/pthread_mutexattr_init.c47
-rw-r--r--libs/pthreads/src/pthread_mutexattr_setkind_np.c46
-rw-r--r--libs/pthreads/src/pthread_mutexattr_setpshared.c46
-rw-r--r--libs/pthreads/src/pthread_mutexattr_setrobust.c46
-rw-r--r--libs/pthreads/src/pthread_mutexattr_settype.c46
-rw-r--r--libs/pthreads/src/pthread_num_processors_np.c46
-rw-r--r--libs/pthreads/src/pthread_once.c52
-rw-r--r--libs/pthreads/src/pthread_rwlock_destroy.c46
-rw-r--r--libs/pthreads/src/pthread_rwlock_init.c46
-rw-r--r--libs/pthreads/src/pthread_rwlock_rdlock.c46
-rw-r--r--libs/pthreads/src/pthread_rwlock_timedrdlock.c46
-rw-r--r--libs/pthreads/src/pthread_rwlock_timedwrlock.c52
-rw-r--r--libs/pthreads/src/pthread_rwlock_tryrdlock.c46
-rw-r--r--libs/pthreads/src/pthread_rwlock_trywrlock.c46
-rw-r--r--libs/pthreads/src/pthread_rwlock_unlock.c46
-rw-r--r--libs/pthreads/src/pthread_rwlock_wrlock.c52
-rw-r--r--libs/pthreads/src/pthread_rwlockattr_destroy.c46
-rw-r--r--libs/pthreads/src/pthread_rwlockattr_getpshared.c46
-rw-r--r--libs/pthreads/src/pthread_rwlockattr_init.c46
-rw-r--r--libs/pthreads/src/pthread_rwlockattr_setpshared.c46
-rw-r--r--libs/pthreads/src/pthread_self.c165
-rw-r--r--libs/pthreads/src/pthread_setaffinity.c242
-rw-r--r--libs/pthreads/src/pthread_setcancelstate.c46
-rw-r--r--libs/pthreads/src/pthread_setcanceltype.c48
-rw-r--r--libs/pthreads/src/pthread_setconcurrency.c46
-rw-r--r--libs/pthreads/src/pthread_setname_np.c192
-rw-r--r--libs/pthreads/src/pthread_setschedparam.c54
-rw-r--r--libs/pthreads/src/pthread_setspecific.c46
-rw-r--r--libs/pthreads/src/pthread_spin_destroy.c46
-rw-r--r--libs/pthreads/src/pthread_spin_init.c46
-rw-r--r--libs/pthreads/src/pthread_spin_lock.c46
-rw-r--r--libs/pthreads/src/pthread_spin_trylock.c46
-rw-r--r--libs/pthreads/src/pthread_spin_unlock.c46
-rw-r--r--libs/pthreads/src/pthread_testcancel.c46
-rw-r--r--libs/pthreads/src/pthread_timechange_handler_np.c48
-rw-r--r--libs/pthreads/src/pthread_timedjoin_np.c187
-rw-r--r--libs/pthreads/src/pthread_tryjoin_np.c172
-rw-r--r--libs/pthreads/src/pthread_win32_attach_detach_np.c87
-rw-r--r--libs/pthreads/src/ptw32_MCS_lock.c125
-rw-r--r--libs/pthreads/src/ptw32_OLL_lock.c734
-rw-r--r--libs/pthreads/src/ptw32_callUserDestroyRoutines.c46
-rw-r--r--libs/pthreads/src/ptw32_calloc.c46
-rw-r--r--libs/pthreads/src/ptw32_cond_check_need_init.c46
-rw-r--r--libs/pthreads/src/ptw32_getprocessors.c46
-rw-r--r--libs/pthreads/src/ptw32_is_attr.c46
-rw-r--r--libs/pthreads/src/ptw32_mutex_check_need_init.c50
-rw-r--r--libs/pthreads/src/ptw32_new.c50
-rw-r--r--libs/pthreads/src/ptw32_processInitialize.c122
-rw-r--r--libs/pthreads/src/ptw32_processTerminate.c46
-rw-r--r--libs/pthreads/src/ptw32_relmillisecs.c184
-rw-r--r--libs/pthreads/src/ptw32_reuse.c64
-rw-r--r--libs/pthreads/src/ptw32_rwlock_cancelwrwait.c46
-rw-r--r--libs/pthreads/src/ptw32_rwlock_check_need_init.c46
-rw-r--r--libs/pthreads/src/ptw32_semwait.c161
-rw-r--r--libs/pthreads/src/ptw32_spinlock_check_need_init.c46
-rw-r--r--libs/pthreads/src/ptw32_threadDestroy.c48
-rw-r--r--libs/pthreads/src/ptw32_threadStart.c212
-rw-r--r--libs/pthreads/src/ptw32_throw.c87
-rw-r--r--libs/pthreads/src/ptw32_timespec.c61
-rw-r--r--libs/pthreads/src/ptw32_tkAssocCreate.c46
-rw-r--r--libs/pthreads/src/ptw32_tkAssocDestroy.c46
-rw-r--r--libs/pthreads/src/rwlock.c51
-rw-r--r--libs/pthreads/src/sched.c53
-rw-r--r--libs/pthreads/src/sched.h302
-rw-r--r--libs/pthreads/src/sched_get_priority_max.c48
-rw-r--r--libs/pthreads/src/sched_get_priority_min.c48
-rw-r--r--libs/pthreads/src/sched_getscheduler.c50
-rw-r--r--libs/pthreads/src/sched_setaffinity.c351
-rw-r--r--libs/pthreads/src/sched_setscheduler.c52
-rw-r--r--libs/pthreads/src/sched_yield.c46
-rw-r--r--libs/pthreads/src/sem_close.c48
-rw-r--r--libs/pthreads/src/sem_destroy.c139
-rw-r--r--libs/pthreads/src/sem_getvalue.c138
-rw-r--r--libs/pthreads/src/sem_init.c192
-rw-r--r--libs/pthreads/src/sem_open.c59
-rw-r--r--libs/pthreads/src/sem_post.c151
-rw-r--r--libs/pthreads/src/sem_post_multiple.c180
-rw-r--r--libs/pthreads/src/sem_timedwait.c279
-rw-r--r--libs/pthreads/src/sem_trywait.c133
-rw-r--r--libs/pthreads/src/sem_unlink.c48
-rw-r--r--libs/pthreads/src/sem_wait.c224
-rw-r--r--libs/pthreads/src/semaphore.c69
-rw-r--r--libs/pthreads/src/semaphore.h203
-rw-r--r--libs/pthreads/src/signal.c48
-rw-r--r--libs/pthreads/src/spin.c46
-rw-r--r--libs/pthreads/src/sync.c43
-rw-r--r--libs/pthreads/src/tsd.c44
-rw-r--r--libs/pthreads/src/w32_CancelableWait.c54
176 files changed, 7991 insertions, 6589 deletions
diff --git a/libs/pthreads/src/GNUmakefile.in b/libs/pthreads/src/GNUmakefile.in
new file mode 100644
index 0000000000..61172db7b6
--- /dev/null
+++ b/libs/pthreads/src/GNUmakefile.in
@@ -0,0 +1,408 @@
+# @configure_input@
+# --------------------------------------------------------------------------
+#
+# Pthreads4w - POSIX Threads Library for Win32
+# Copyright(C) 1998 John E. Bossom
+# Copyright(C) 1999-2018, Pthreads4w contributors
+#
+# Homepage: https://sourceforge.net/projects/pthreads4w/
+#
+# The current list of contributors is contained
+# in the file CONTRIBUTORS included with the source
+# code distribution. The list can also be seen at the
+# following World Wide Web location:
+# https://sourceforge.net/p/pthreads4w/wiki/Contributors/
+#
+# This file is part of Pthreads4w.
+#
+# Pthreads4w is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# Pthreads4w is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with Pthreads4w. If not, see <http://www.gnu.org/licenses/>. *
+#
+PACKAGE = @PACKAGE_TARNAME@
+VERSION = @PACKAGE_VERSION@
+
+PTW32_VER = 2$(EXTRAVERSION)
+
+# See pthread.h and README for the description of version numbering.
+PTW32_VERD = $(PTW32_VER)d
+
+srcdir = @srcdir@
+builddir = @builddir@
+VPATH = @srcdir@
+
+# FIXME: Replace these path name references with autoconf standards.
+DESTROOT = ../PTHREADS-BUILT
+DLLDEST = $(DESTROOT)/bin
+LIBDEST = $(DESTROOT)/lib
+HDRDEST = $(DESTROOT)/include
+# i.e.
+#
+prefix = @prefix@
+exec_prefix = @exec_prefix@
+bindir = ${DESTDIR}@bindir@
+includedir = ${DESTDIR}@includedir@
+libdir = ${DESTDIR}@libdir@
+
+# FIXME: This is correct for a static library; a DLL import library
+# should be called libpthread.dll.a, or some such.
+DEST_LIB_NAME = libpthread
+
+# If Running MsysDTK
+RM = rm -f
+MV = mv -f
+CP = cp -f
+GREP = grep
+MKDIR = mkdir -p
+ECHO = echo
+TESTNDIR = test ! -d
+TESTFILE = test -f
+AND = &&
+COUNT_UNIQ = uniq -c
+
+# If not.
+#RM = erase
+#MV = rename
+#CP = copy
+#MKDIR = mkdir
+#ECHO = echo
+#TESTNDIR = if exist
+#TESTFILE = if exist
+# AND =
+
+# For cross compiling use e.g.
+# make CROSS=x86_64-w64-mingw32- clean GC-inlined
+# FIXME: To be removed; autoconf handles this transparently;
+# DO NOT use this non-standard feature.
+#CROSS =
+
+CC = @CC@
+CXX = @CXX@
+
+AR = @AR@
+DLLTOOL = @DLLTOOL@
+RANLIB = @RANLIB@
+RC = @RC@
+OD_PRIVATE = @OBJDUMP@ -p
+
+# Build for non-native architecture. E.g. "-m64" "-m32" etc.
+# Not tested fully, needs gcc built with "--enable-multilib"
+# Check your "gcc -v" output for the options used to build your gcc.
+# You can set this as a shell variable or on the make comand line.
+# You don't need to uncomment it here unless you want to hardwire
+# a value.
+#ARCH =
+
+#
+# Look for targets that $(RC) (usually windres) supports then look at any object
+# file just built to see which target the compiler used and set the $(RC) target
+# to match it.
+#
+KNOWN_TARGETS := pe-% pei-% elf32-% elf64-% srec symbolsrec verilog tekhex binary ihex
+SUPPORTED_TARGETS := $(filter $(KNOWN_TARGETS),$(shell $(RC) --help))
+RC_TARGET = --target $(firstword $(filter $(SUPPORTED_TARGETS),$(shell $(OD_PRIVATE) *.$(OBJEXT))))
+
+OPT = $(CLEANUP) -O3 # -finline-functions -findirect-inlining
+XOPT =
+
+RCFLAGS = --include-dir=${srcdir}
+LFLAGS = $(ARCH)
+# Uncomment this if config.h defines RETAIN_WSALASTERROR
+# FIXME: autoconf (or GNU make) convention dictates that this should be
+# LIBS (or LDLIBS); ideally, it should be set by configure.
+#LFLAGS += -lws2_32
+#
+# Uncomment this next to link the GCC/C++ runtime libraries statically
+# (Be sure to read about these options and their associated caveats
+# at http://gcc.gnu.org/onlinedocs/gcc/Link-Options.html)
+#
+# NOTE 1: Doing this appears to break GCE:pthread_cleanup_*(), which
+# relies on C++ class destructors being called when leaving scope.
+#
+# NOTE 2: If you do this DO NOT distribute your pthreads DLLs with
+# the official filenaming, i.e. pthreadVC2.dll, etc. Instead, change PTW32_VER
+# above to "2slgcc" for example, to build "pthreadGC2slgcc.dll", etc.
+#
+# FIXME: in this case, convention would have us use LDFLAGS; once again, if
+# we really want this, we should support it via a configure script option.
+#LFLAGS += -static-libgcc -static-libstdc++
+
+# ----------------------------------------------------------------------
+# The library can be built with some alternative behaviour to
+# facilitate development of applications on Win32 that will be ported
+# to other POSIX systems. Nothing definable here will make the library
+# non-compliant, but applications that make assumptions that POSIX
+# does not garrantee may fail or misbehave under some settings.
+#
+# __PTW32_THREAD_ID_REUSE_INCREMENT
+# Purpose:
+# POSIX says that applications should assume that thread IDs can be
+# recycled. However, Solaris and some other systems use a [very large]
+# sequence number as the thread ID, which provides virtual uniqueness.
+# Pthreads4w provides pseudo-unique IDs when the default increment
+# (1) is used, but pthread_t is not a scalar type like Solaris's.
+#
+# Usage:
+# Set to any value in the range: 0 <= value <= 2^wordsize
+#
+# Examples:
+# Set to 0 to emulate non recycle-unique behaviour like Linux or *BSD.
+# Set to 1 for recycle-unique thread IDs (this is the default).
+# Set to some other +ve value to emulate smaller word size types
+# (i.e. will wrap sooner).
+#
+#PTW32_FLAGS = "-DPTW32_THREAD_ID_REUSE_INCREMENT=0"
+#
+# ----------------------------------------------------------------------
+
+GC_CFLAGS = $(PTW32_FLAGS)
+GCE_CFLAGS = $(PTW32_FLAGS) -mthreads
+
+## Mingw
+#MAKE ?= make
+DEFS = @DEFS@ -DPTW32_BUILD
+CFLAGS = $(OPT) $(XOPT) $(ARCH) -I. -I${srcdir} $(DEFS) -Wall
+
+OBJEXT = @OBJEXT@
+OEXT = @OBJEXT@
+RESEXT = @OBJEXT@
+
+include ${srcdir}/common.mk
+
+DLL_OBJS += $(RESOURCE_OBJS)
+STATIC_OBJS += $(RESOURCE_OBJS)
+STATIC_OBJS_SMALL += $(RESOURCE_OBJS)
+
+GCE_DLL = pthreadGCE$(PTW32_VER).dll
+GCED_DLL= pthreadGCE$(PTW32_VERD).dll
+GCE_LIB = libpthreadGCE$(PTW32_VER).a
+GCED_LIB= libpthreadGCE$(PTW32_VERD).a
+
+GC_DLL = pthreadGC$(PTW32_VER).dll
+GCD_DLL = pthreadGC$(PTW32_VERD).dll
+GC_LIB = libpthreadGC$(PTW32_VER).a
+GCD_LIB = libpthreadGC$(PTW32_VERD).a
+GC_INLINED_STATIC_STAMP = libpthreadGC$(PTW32_VER).inlined_static_stamp
+GCD_INLINED_STATIC_STAMP = libpthreadGC$(PTW32_VERD).inlined_static_stamp
+GCE_INLINED_STATIC_STAMP = libpthreadGCE$(PTW32_VER).inlined_static_stamp
+GCED_INLINED_STATIC_STAMP = libpthreadGCE$(PTW32_VERD).inlined_static_stamp
+GC_SMALL_STATIC_STAMP = libpthreadGC$(PTW32_VER).small_static_stamp
+GCD_SMALL_STATIC_STAMP = libpthreadGC$(PTW32_VERD).small_static_stamp
+GCE_SMALL_STATIC_STAMP = libpthreadGCE$(PTW32_VER).small_static_stamp
+GCED_SMALL_STATIC_STAMP = libpthreadGCE$(PTW32_VERD).small_static_stamp
+
+PTHREAD_DEF = pthread.def
+
+help:
+ @ echo "Run one of the following command lines:"
+ @ echo "$(MAKE) clean all (build targets GC, GCE, GC-static, GCE-static)"
+ @ echo "$(MAKE) clean all-tests (build and test all non-debug targets below)"
+ @ echo "$(MAKE) clean GC (to build the GNU C dll with C cleanup code)"
+ @ echo "$(MAKE) clean GC-debug (to build the GNU C debug dll with C cleanup code)"
+ @ echo "$(MAKE) clean GCE (to build the GNU C dll with C++ exception handling)"
+ @ echo "$(MAKE) clean GCE-debug (to build the GNU C debug dll with C++ exception handling)"
+ @ echo "$(MAKE) clean GC-static (to build the GNU C static lib with C cleanup code)"
+ @ echo "$(MAKE) clean GC-static-debug (to build the GNU C static debug lib with C cleanup code)"
+ @ echo "$(MAKE) clean GCE-static (to build the GNU C++ static lib with C++ cleanup code)"
+ @ echo "$(MAKE) clean GCE-static-debug (to build the GNU C++ static debug lib with C++ cleanup code)"
+ @ echo "$(MAKE) clean GC-small-static (to build the GNU C static lib with C cleanup code)"
+ @ echo "$(MAKE) clean GC-small-static-debug (to build the GNU C static debug lib with C cleanup code)"
+ @ echo "$(MAKE) clean GCE-small-static (to build the GNU C++ static lib with C++ cleanup code)"
+ @ echo "$(MAKE) clean GCE-small-static-debug (to build the GNU C++ static debug lib with C++ cleanup code)"
+
+all:
+ @ $(MAKE) clean GC
+ @ $(MAKE) clean GCE
+ @ $(MAKE) clean GC-static
+ @ $(MAKE) clean GCE-static
+
+TEST_ENV = __PTW32_FLAGS="$(PTW32_FLAGS) -DNO_ERROR_DIALOGS" PTW32_VER=$(PTW32_VER) ARCH="$(ARCH)"
+
+all-tests:
+ $(MAKE) realclean GC
+ cd tests && $(MAKE) clean GC $(TEST_ENV) && $(MAKE) clean GCX $(TEST_ENV)
+ $(MAKE) realclean GCE
+ cd tests && $(MAKE) clean GCE $(TEST_ENV)
+ $(MAKE) realclean GC-static
+ cd tests && $(MAKE) clean GC-static $(TEST_ENV) && $(MAKE) clean GCX-static $(TEST_ENV)
+ $(MAKE) realclean GCE-static
+ cd tests && $(MAKE) clean GCE-static $(TEST_ENV)
+ $(MAKE) realclean GC-small-static
+ cd tests && $(MAKE) clean GC-small-static $(TEST_ENV) && $(MAKE) clean GCX-small-static $(TEST_ENV)
+ $(MAKE) realclean GCE-small-static
+ cd tests && $(MAKE) clean GCE-small-static $(TEST_ENV)
+ $(MAKE) realclean
+ @ - $(GREP) Passed *.log | $(COUNT_UNIQ)
+ @ - $(GREP) FAILED *.log
+
+all-tests-cflags:
+ $(MAKE) all-tests __PTW32_FLAGS="-Wall -Wextra"
+ @ $(ECHO) "$@ completed."
+
+GC:
+ $(MAKE) XOPT="-DPTW32_BUILD_INLINED" CLEANUP=-D__CLEANUP_C XC_FLAGS="$(GC_CFLAGS)" OBJ="$(DLL_OBJS)" $(GC_DLL)
+
+GC-debug:
+ $(MAKE) XOPT="-DPTW32_BUILD_INLINED" CLEANUP=-D__CLEANUP_C XC_FLAGS="$(GC_CFLAGS)" OBJ="$(DLL_OBJS)" PTW32_VER=$(PTW32_VERD) OPT="-D__CLEANUP_C -g -O0" $(GCD_DLL)
+
+GCE:
+ $(MAKE) XOPT="-DPTW32_BUILD_INLINED" CC=$(CXX) CLEANUP=-D__CLEANUP_CXX XC_FLAGS="$(GCE_CFLAGS)" OBJ="$(DLL_OBJS)" $(GCE_DLL)
+
+GCE-debug:
+ $(MAKE) XOPT="-DPTW32_BUILD_INLINED" CC=$(CXX) CLEANUP=-D__CLEANUP_CXX XC_FLAGS="$(GCE_CFLAGS)" OBJ="$(DLL_OBJS)" PTW32_VER=$(PTW32_VERD) OPT="-D__CLEANUP_CXX -g -O0" $(GCED_DLL)
+
+GC-static:
+ $(MAKE) XOPT="-DPTW32_BUILD_INLINED -DPTW32_STATIC_LIB" CLEANUP=-D__CLEANUP_C XC_FLAGS="$(GC_CFLAGS)" OBJ="$(STATIC_OBJS)" $(GC_INLINED_STATIC_STAMP)
+
+GC-static-debug:
+ $(MAKE) XOPT="-DPTW32_BUILD_INLINED -DPTW32_STATIC_LIB" CLEANUP=-D__CLEANUP_C XC_FLAGS="$(GC_CFLAGS)" OBJ="$(STATIC_OBJS)" PTW32_VER=$(PTW32_VERD) OPT="-D__CLEANUP_C -g -O0" $(GCD_INLINED_STATIC_STAMP)
+
+GC-small-static:
+ $(MAKE) XOPT="-DPTW32_STATIC_LIB" CLEANUP=-D__CLEANUP_C XC_FLAGS="$(GC_CFLAGS)" OBJ="$(STATIC_OBJS_SMALL)" $(GC_SMALL_STATIC_STAMP)
+
+GC-small-static-debug:
+ $(MAKE) XOPT="-DPTW32_STATIC_LIB" CLEANUP=-D__CLEANUP_C XC_FLAGS="$(GC_CFLAGS)" OBJ="$(STATIC_OBJS_SMALL)" PTW32_VER=$(PTW32_VERD) OPT="-D__CLEANUP_C -g -O0" $(GCD_SMALL_STATIC_STAMP)
+
+GCE-static:
+ $(MAKE) XOPT="-DPTW32_BUILD_INLINED -DPTW32_STATIC_LIB" CC=$(CXX) CLEANUP=-D__CLEANUP_CXX XC_FLAGS="$(GCE_CFLAGS)" OBJ="$(STATIC_OBJS)" $(GCE_INLINED_STATIC_STAMP)
+
+GCE-static-debug:
+ $(MAKE) XOPT="-DPTW32_BUILD_INLINED -DPTW32_STATIC_LIB" CC=$(CXX) CLEANUP=-D__CLEANUP_CXX XC_FLAGS="$(GCE_CFLAGS)" OBJ="$(STATIC_OBJS)" PTW32_VER=$(PTW32_VERD) OPT="-D__CLEANUP_C -g -O0" $(GCED_INLINED_STATIC_STAMP)
+
+GCE-small-static:
+ $(MAKE) XOPT="-DPTW32_STATIC_LIB" CC=$(CXX) CLEANUP=-D__CLEANUP_CXX XC_FLAGS="$(GCE_CFLAGS)" OBJ="$(STATIC_OBJS_SMALL)" $(GCE_SMALL_STATIC_STAMP)
+
+GCE-small-static-debug:
+ $(MAKE) XOPT="-DPTW32_STATIC_LIB" CC=$(CXX) CLEANUP=-D__CLEANUP_CXX XC_FLAGS="$(GCE_CFLAGS)" OBJ="$(STATIC_OBJS_SMALL)" PTW32_VER=$(PTW32_VERD) OPT="-D__CLEANUP_C -g -O0" $(GCED_SMALL_STATIC_STAMP)
+
+tests:
+ @ cd tests
+ @ $(MAKE) auto
+
+# Very basic install. It assumes "realclean" was done just prior to build target if
+# you want the installed $(DEVDEST_LIB_NAME) to match that build.
+
+INSTALL = @INSTALL@
+INSTALL_DATA = @INSTALL_DATA@
+mkinstalldirs = @MKDIR_P@ $1
+
+.PHONY: install installdirs install-headers
+.PHONY: install-dlls install-lib-default install-libs-specific
+
+install: installdirs install-headers install-libs install-dlls
+
+installdirs: ${bindir} ${includedir} ${libdir}
+${bindir} ${includedir} ${libdir}:; $(call mkinstalldirs,$@)
+
+install-dlls: $(wildcard ${builddir}/pthreadGC*.dll)
+ $(INSTALL_DATA) $^ ${bindir}
+
+install-libs: install-libs-specific
+install-libs-specific: $(wildcard ${builddir}/libpthreadGC*.a)
+ $(INSTALL_DATA) $^ ${libdir}
+
+default_libs = $(wildcard $(addprefix $1,$(PTW32_VER)$2 $(PTW32_VERD)$2))
+
+# FIXME: this is a ghastly, utterly non-deterministic hack; who knows
+# what it's going to install as the default libpthread.a? Better to
+# just explicitly make it a copy of libpthreadGC$(PTW32_VER).a
+install-libs: install-lib-default
+install-lib-default: $(call default_libs,libpthreadGC,.a)
+install-lib-default: $(call default_libs,libpthreadGCE,.a)
+ $(INSTALL_DATA) $(lastword $^) ${libdir}/$(DEST_LIB_NAME).a
+
+# FIXME: similarly, who knows what this will install? Once again, it
+# would be better to explicitly install libpthread.dll.a as a copy of
+# libpthreadGC$(PTW32_VER).dll.a
+install-libs: install-implib-default
+install-implib-default: $(call default_libs,libpthreadGC,.dll.a)
+install-implib-default: $(call default_libs,libpthreadGCE,.dll.a)
+ $(INSTALL_DATA) $(lastword $^) ${libdir}/$(DEST_LIB_NAME).dll.a
+
+install-headers: pthread.h sched.h semaphore.h _ptw32.h
+ $(INSTALL_DATA) $^ ${includedir}
+
+%.pre: %.c
+ $(CC) -E -o $@ $(CFLAGS) $^
+
+%.s: %.c
+ $(CC) -c $(CFLAGS) -DPTW32_BUILD_INLINED -Wa,-ahl $^ > $@
+
+%.o: %.rc
+ $(RC) $(RC_TARGET) $(RCFLAGS) $(CLEANUP) -o $@ -i $<
+
+.SUFFIXES: .dll .rc .c .o
+
+.c.o:; $(CC) -c -o $@ $(CFLAGS) $(XC_FLAGS) $<
+
+
+$(GC_DLL) $(GCD_DLL): $(DLL_OBJS)
+ $(CC) $(OPT) -shared -o $@ $^ $(LFLAGS)
+ $(DLLTOOL) -z pthread.def $^
+ $(DLLTOOL) -k --dllname $@ --output-lib lib$@.a --def $(PTHREAD_DEF)
+
+$(GCE_DLL) $(GCED_DLL): $(DLL_OBJS)
+ $(CC) $(OPT) -mthreads -shared -o $@ $^ $(LFLAGS)
+ $(DLLTOOL) -z pthread.def $^
+ $(DLLTOOL) -k --dllname $@ --output-lib lib$@.a --def $(PTHREAD_DEF)
+
+$(GC_INLINED_STATIC_STAMP) $(GCE_INLINED_STATIC_STAMP) $(GCD_INLINED_STATIC_STAMP) $(GCED_INLINED_STATIC_STAMP): $(STATIC_OBJS)
+ $(RM) $(basename $@).a
+ $(AR) -rsv $(basename $@).a $^
+ $(ECHO) touched > $@
+
+$(GC_SMALL_STATIC_STAMP) $(GCE_SMALL_STATIC_STAMP) $(GCD_SMALL_STATIC_STAMP) $(GCED_SMALL_STATIC_STAMP): $(STATIC_OBJS_SMALL)
+ $(RM) $(basename $@).a
+ $(AR) -rsv $(basename $@).a $^
+ $(ECHO) touched > $@
+
+clean:
+ -$(RM) *~
+ -$(RM) *.i
+ -$(RM) *.s
+ -$(RM) *.o
+ -$(RM) *.obj
+ -$(RM) *.exe
+ -$(RM) *.manifest
+ -$(RM) $(PTHREAD_DEF)
+ -cd tests && $(MAKE) clean
+
+realclean: clean
+ -$(RM) lib*.a
+ -$(RM) *.lib
+ -$(RM) pthread*.dll
+ -$(RM) *_stamp
+ -$(RM) make.log.txt
+ -cd tests && $(MAKE) realclean
+
+var_check_list =
+
+define var_check_target
+var-check-$(1):
+ @for src in $($(1)); do \
+ fgrep -q "\"$$$$src\"" $(2) && continue; \
+ echo "$$$$src is in \$$$$($(1)), but not in $(2)"; \
+ exit 1; \
+ done
+ @grep '^# *include *".*\.c"' $(2) | cut -d'"' -f2 | while read src; do \
+ echo " $($(1)) " | fgrep -q " $$$$src " && continue; \
+ echo "$$$$src is in $(2), but not in \$$$$($(1))"; \
+ exit 1; \
+ done
+ @echo "$(1) <-> $(2): OK"
+
+var_check_list += var-check-$(1)
+endef
+
+$(eval $(call var_check_target,PTHREAD_SRCS,pthread.c))
+
+srcs-vars-check: $(var_check_list)
diff --git a/libs/pthreads/src/TODO b/libs/pthreads/src/TODO
new file mode 100644
index 0000000000..360be64530
--- /dev/null
+++ b/libs/pthreads/src/TODO
@@ -0,0 +1,26 @@
+ Things that aren't done yet
+ ---------------------------
+
+1. Implement PTHREAD_PROCESS_SHARED for semaphores, mutexes,
+ condition variables, read/write locks, barriers.
+
+ IMO, to do this in a source code compatible way requires implementation of
+ POSIX shared memory functions, etc.
+
+2. For version 3 onwards: the following types need to change, resulting in an ABI
+ change. These have been written conditional on PTW32_VERSION_MAJOR > 2
+
+ a) ptw32_handle_t (a.k.a. pthread_t)
+ Change the reuse counter from unsigned int to size_t. Type "int" on 32 bit
+ and 64 bit Windows is 32 bits wide.
+
+ To give an indication of relative effectiveness of the current "unsigned int",
+ consider an application that creates and detaches a single thread every
+ millisecond. At this rate the reuse counter will max out after 49 days.
+
+ After changing to "size_t" an application compiled for x64 and creating and
+ detaching a single thread every nanosecond would max out after 584 years.
+
+ b) pthread_once_t
+ Remove elements no longer required after switching to use of MCS lock.
+ \ No newline at end of file
diff --git a/libs/pthreads/src/WinCE-PORT b/libs/pthreads/src/WinCE-PORT
new file mode 100644
index 0000000000..7bcfdea6cc
--- /dev/null
+++ b/libs/pthreads/src/WinCE-PORT
@@ -0,0 +1,222 @@
+NOTE: The comments in this file relate to the original WinCE port
+done by Tristan Savatier. The semaphore routines have been
+completely rewritten since (2005-04-25), having been progressively
+broken more and more by changes to the library. All of the semaphore
+routines implemented for W9x/WNT/2000 and up should now also work for
+WinCE. Also, pthread_mutex_timedlock should now work.
+
+Additional WinCE updates have been applied since this as well. Check the
+ChangeLog file and search for WINCE for example. (2007-01-07)
+
+[RPJ]
+
+----
+
+Some interesting news:
+
+I have been able to port pthread-win32 to Windows-CE,
+which uses a subset of the WIN32 API.
+
+Since we intend to keep using pthread-win32 for our
+Commercial WinCE developments, I would be very interested
+if WinCE support could be added to the main source tree
+of pthread-win32. Also, I would like to be credited
+for this port :-)
+
+Now, here is the story...
+
+The port was performed and tested on a Casio "Cassiopeia"
+PalmSize PC, which runs a MIP processor. The OS in the
+Casio is WinCE version 2.11, but I used VC++ 6.0 with
+the WinCE SDK for version 2.01.
+
+I used pthread-win32 to port a heavily multithreaded
+commercial application (real-time MPEG video player)
+from Linux to WinCE. I consider the changes that
+I have done to be quite well tested.
+
+Overall the modifications that we had to do are minor.
+
+The WinCE port were based on pthread-win32-snap-1999-05-30,
+but I am certain that they can be integrated very easiely
+to more recent versions of the source.
+
+I have attached the modified source code:
+pthread-win32-snap-1999-05-30-WinCE.
+
+All the changes do not affect the code compiled on non-WinCE
+environment, provided that the macros used for WinCE compilation
+are not used, of course!
+
+Overall description of the WinCE port:
+-------------------------------------
+
+Most of the changes had to be made in areas where
+pthread-win32 was relying on some standard-C librairies
+(e.g. _ftime, calloc, errno), which are not available
+on WinCE. We have changed the code to use native Win32
+API instead (or in some cases we made wrappers).
+
+The Win32 Semaphores are not available,
+so we had to re-implement Semaphores using mutexes
+and events.
+
+Limitations / known problems of the WinCE port:
+----------------------------------------------
+
+Not all the semaphore routines have been ported
+(semaphores are defined by Posix but are not part
+pf pthread). I have just done enough to make
+pthread routines (that rely internally on semaphores)
+work, like signal conditions.
+
+I noticed that the Win32 threads work slightly
+differently on WinCE. This may have some impact
+on some tricky parts of pthread-win32, but I have
+not really investigated. For example, on WinCE,
+the process is killed if the main thread falls off
+the bottom (or calls pthread_exit), regardless
+of the existence of any other detached thread.
+Microsoft manual indicates that this behavior is
+deffirent from that of Windows Threads for other
+Win32 platforms.
+
+
+Detailed descriptions of the changes and rationals:
+
+------------------------------------
+- use a new macro NEED_ERRNO.
+
+If defined, the code in errno.c that defines a reentrant errno
+is compiled, regardless of _MT and _REENTRANT.
+
+Rational: On WinCE, there is no support for <stdio.h>, <errno.h> or
+any other standard C library, i.e. even if _MT or _REENTRANT
+is defined, errno is not provided by any library. NEED_ERRNO
+must be set to compile for WinCE.
+
+------------------------------------
+- In implement.h, change #include <semaphore.h> to #include "semaphore.h".
+
+Rational: semaphore.h is provided in pthread-win32 and should not
+be searched in the systems standard include. would not compile.
+This change does not seem to create problems on "classic" win32
+(e.g. win95).
+
+------------------------------------
+- use a new macro NEED_CALLOC.
+
+If defined, some code in misc.c will provide a replacement
+for calloc, which is not available on Win32.
+
+
+------------------------------------
+- use a new macro NEED_CREATETHREAD.
+
+If defined, implement.h defines the macro _beginthreadex
+and _endthreadex.
+
+Rational: On WinCE, the wrappers _beginthreadex and _endthreadex
+do not exist. The native Win32 routines must be used.
+
+------------------------------------
+- in misc.c:
+
+#ifdef NEED_DUPLICATEHANDLE
+ /* DuplicateHandle does not exist on WinCE */
+ self->threadH = GetCurrentThread();
+#else
+ if( !DuplicateHandle(
+ GetCurrentProcess(),
+ GetCurrentThread(),
+ GetCurrentProcess(),
+ &self->threadH,
+ 0,
+ FALSE,
+ DUPLICATE_SAME_ACCESS ) )
+ {
+ free( self );
+ return (NULL);
+ }
+#endif
+
+Rational: On WinCE, DuplicateHandle does not exist. I could not understand
+why DuplicateHandle must be used. It seems to me that getting the current
+thread handle with GetCurrentThread() is sufficient, and it seems to work
+perfectly fine, so maybe DuplicateHandle was just plain useless to begin with ?
+
+------------------------------------
+- In private.c, added some code at the beginning of ptw32_processInitialize
+to detect the case of multiple calls to ptw32_processInitialize.
+
+Rational: In order to debug pthread-win32, it is easier to compile
+it as a regular library (it is not possible to debug DLL's on winCE).
+In that case, the application must call ptw32_rocessInitialize()
+explicitely, to initialize pthread-win32. It is safer in this circumstance
+to handle the case where ptw32_processInitialize() is called on
+an already initialized library:
+
+int
+ptw32_processInitialize (void)
+{
+ if (ptw32_processInitialized) {
+ /*
+ * ignore if already initialized. this is useful for
+ * programs that uses a non-dll pthread
+ * library. such programs must call ptw32_processInitialize() explicitely,
+ * since this initialization routine is automatically called only when
+ * the dll is loaded.
+ */
+ return TRUE;
+ }
+ ptw32_processInitialized = TRUE;
+ [...]
+}
+
+------------------------------------
+- in private.c, if macro NEED_FTIME is defined, add routines to
+convert timespec_to_filetime and filetime_to_timespec, and modified
+code that was using _ftime() to use Win32 API instead.
+
+Rational: _ftime is not available on WinCE. It is necessary to use
+the native Win32 time API instead.
+
+Note: the routine timespec_to_filetime is provided as a convenience and a mean
+to test that filetime_to_timespec works, but it is not used by the library.
+
+------------------------------------
+- in semaphore.c, if macro NEED_SEM is defined, add code for the routines
+_increase_semaphore and _decrease_semaphore, and modify significantly
+the implementation of the semaphores so that it does not use CreateSemaphore.
+
+Rational: CreateSemaphore is not available on WinCE. I had to re-implement
+semaphores using mutexes and Events.
+
+Note: Only the semaphore routines that are used by pthread are implemented
+(i.e. signal conditions rely on a subset of the semaphores routines, and
+this subset works). Some other semaphore routines (e.g. sem_trywait) are
+not yet supported on my WinCE port (and since I don't need them, I am not
+planning to do anything about them).
+
+------------------------------------
+- in tsd.c, changed the code that defines TLS_OUT_OF_INDEXES
+
+/* TLS_OUT_OF_INDEXES not defined on WinCE */
+#ifndef TLS_OUT_OF_INDEXES
+#define TLS_OUT_OF_INDEXES 0xffffffff
+#endif
+
+Rational: TLS_OUT_OF_INDEXES is not defined in any standard include file
+on WinCE.
+
+------------------------------------
+- added file need_errno.h
+
+Rational: On WinCE, there is no errno.h file. need_errno.h is just a
+copy of windows version of errno.h, with minor modifications due to the fact
+that some of the error codes are defined by the WinCE socket library.
+In pthread.h, if NEED_ERRNO is defined, the file need_errno.h is
+included (instead of <errno.h>).
+
+
+-- eof
diff --git a/libs/pthreads/src/_ptw32.h b/libs/pthreads/src/_ptw32.h
new file mode 100644
index 0000000000..71a74b6746
--- /dev/null
+++ b/libs/pthreads/src/_ptw32.h
@@ -0,0 +1,218 @@
+/*
+ * Module: _ptw32.h
+ *
+ * Purpose:
+ * Pthreads4w internal macros, to be shared by other headers
+ * comprising the Pthreads4w package.
+ *
+ * --------------------------------------------------------------------------
+ *
+ * Pthreads4w - POSIX Threads Library for Win32
+ * Copyright(C) 1998 John E. Bossom
+ * Copyright(C) 1999-2018, Pthreads4w contributors
+ *
+ * Homepage: https://sourceforge.net/projects/pthreads4w/
+ *
+ * The current list of contributors is contained
+ * in the file CONTRIBUTORS included with the source
+ * code distribution. The list can also be seen at the
+ * following World Wide Web location:
+ * https://sourceforge.net/p/pthreads4w/wiki/Contributors/
+ *
+ * This file is part of Pthreads4w.
+ *
+ * Pthreads4w is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * Pthreads4w is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Pthreads4w. If not, see <http://www.gnu.org/licenses/>. *
+ */
+#ifndef __PTW32_H
+#define __PTW32_H
+
+/* See the README file for an explanation of the Pthreads4w
+ * version numbering scheme and how the DLL is named etc.
+ *
+ * FIXME: consider moving this to <_ptw32.h>; maybe also add a
+ * leading underscore to the macro names.
+ */
+#define PTW32_VERSION_MAJOR 2
+#define PTW32_VERSION_MINOR 11
+#define PTW32_VERSION_MICRO 0
+#define PTW32_VERION_BUILD 0
+#define PTW32_VERSION 2,11,0,0
+#define PTW32_VERSION_STRING "2, 11, 0, 0\0"
+
+#if defined(__GNUC__)
+# pragma GCC system_header
+# if ! defined __declspec
+# error "Please upgrade your GNU compiler to one that supports __declspec."
+# endif
+#endif
+
+#if defined (__cplusplus)
+# define __PTW32_BEGIN_C_DECLS extern "C" {
+# define __PTW32_END_C_DECLS }
+#else
+# define __PTW32_BEGIN_C_DECLS
+# define __PTW32_END_C_DECLS
+#endif
+
+#if defined PTW32_STATIC_LIB
+# define PTW32_DLLPORT
+
+#elif defined PTW32_BUILD
+# define PTW32_DLLPORT __declspec (dllexport)
+#else
+# define PTW32_DLLPORT /*__declspec (dllimport)*/
+#endif
+
+#ifndef PTW32_CDECL
+/* FIXME: another internal macro; should have two initial underscores;
+ * Nominally, we prefer to use __cdecl calling convention for all our
+ * functions, but we map it through this macro alias to facilitate the
+ * possible choice of alternatives; for example:
+ */
+# ifdef _OPEN_WATCOM_SOURCE
+ /* The Open Watcom C/C++ compiler uses a non-standard default calling
+ * convention, (similar to __fastcall), which passes function arguments
+ * in registers, unless the __cdecl convention is explicitly specified
+ * in exposed function prototypes.
+ *
+ * Our preference is to specify the __cdecl convention for all calls,
+ * even though this could slow Watcom code down slightly. If you know
+ * that the Watcom compiler will be used to build both the DLL and your
+ * application, then you may #define _OPEN_WATCOM_SOURCE, so disabling
+ * the forced specification of __cdecl for all function declarations;
+ * remember that this must be defined consistently, for both the DLL
+ * build, and the application build.
+ */
+# define PTW32_CDECL
+# else
+# define PTW32_CDECL __cdecl
+# endif
+#endif
+
+/*
+ * This is more or less a duplicate of what is in the autoconf config.h,
+ * which is only used when building the pthread-win32 libraries. They
+ */
+
+#if !defined(PTW32_CONFIG_H) && !defined(__PTW32_PSEUDO_CONFIG_H_SOURCED)
+# define __PTW32_PSEUDO_CONFIG_H_SOURCED
+# if defined(WINCE)
+# undef HAVE_CPU_AFFINITY
+# define NEED_DUPLICATEHANDLE
+# define NEED_CREATETHREAD
+# define NEED_ERRNO
+# define NEED_CALLOC
+# define NEED_UNICODE_CONSTS
+# define NEED_PROCESS_AFFINITY_MASK
+/* This may not be needed */
+# define RETAIN_WSALASTERROR
+# elif defined(_MSC_VER)
+# if _MSC_VER >= 1900
+# define HAVE_STRUCT_TIMESPEC
+# elif _MSC_VER < 1300
+# define PTW32_CONFIG_MSVC6
+# elif _MSC_VER < 1400
+# define PTW32_CONFIG_MSVC7
+# endif
+# elif defined(_UWIN)
+# define HAVE_MODE_T
+# define HAVE_STRUCT_TIMESPEC
+# define HAVE_SIGNAL_H
+# endif
+#endif
+
+/*
+ * If HAVE_ERRNO_H is defined then assume that autoconf has been used
+ * to overwrite config.h, otherwise the original config.h is in use
+ * at build-time or the above block of defines is in use otherwise
+ * and NEED_ERRNO is either defined or not defined.
+ */
+#if defined(HAVE_ERRNO_H) || !defined(NEED_ERRNO)
+# include <errno.h>
+#else
+# include "need_errno.h"
+#endif
+
+#if defined(__BORLANDC__)
+# define int64_t LONGLONG
+# define uint64_t ULONGLONG
+#elif !defined(__MINGW32__)
+ typedef _int64 int64_t;
+ typedef unsigned _int64 uint64_t;
+# if defined(PTW32_CONFIG_MSVC6)
+ typedef long intptr_t;
+# endif
+#elif defined(HAVE_STDINT_H) && HAVE_STDINT_H == 1
+# include <stdint.h>
+#endif
+
+/*
+ * In case ETIMEDOUT hasn't been defined above somehow.
+ */
+#if !defined(ETIMEDOUT)
+ /*
+ * note: ETIMEDOUT is no longer defined in winsock.h
+ * WSAETIMEDOUT is so use its value.
+ */
+# include <winsock.h>
+# if defined(WSAETIMEDOUT)
+# define ETIMEDOUT WSAETIMEDOUT
+# else
+# define ETIMEDOUT 10060 /* This is the value of WSAETIMEDOUT in winsock.h. */
+# endif
+#endif
+
+/*
+ * Several systems may not define some error numbers;
+ * defining those which are likely to be missing here will let
+ * us complete the library builds.
+ */
+#if !defined(ENOTSUP)
+# define ENOTSUP 48 /* This is the value in Solaris. */
+#endif
+
+#if !defined(ENOSYS)
+# define ENOSYS 140 /* Semi-arbitrary value */
+#endif
+
+#if !defined(EDEADLK)
+# if defined(EDEADLOCK)
+# define EDEADLK EDEADLOCK
+# else
+# define EDEADLK 36 /* This is the value in MSVC. */
+# endif
+#endif
+
+/* POSIX 2008 - related to robust mutexes */
+/*
+ * FIXME: These should be changed for version 3.0.0 onward.
+ * 42 clashes with EILSEQ.
+ */
+#if PTW32_VERSION_MAJOR > 2
+# if !defined(EOWNERDEAD)
+# define EOWNERDEAD 1000
+# endif
+# if !defined(ENOTRECOVERABLE)
+# define ENOTRECOVERABLE 1001
+# endif
+#else
+# if !defined(EOWNERDEAD)
+# define EOWNERDEAD 42
+# endif
+# if !defined(ENOTRECOVERABLE)
+# define ENOTRECOVERABLE 43
+# endif
+#endif
+
+#endif /* !__PTW32_H */
diff --git a/libs/pthreads/src/attr.c b/libs/pthreads/src/attr.c
deleted file mode 100644
index a9d55f4a4b..0000000000
--- a/libs/pthreads/src/attr.c
+++ /dev/null
@@ -1,53 +0,0 @@
-/*
- * attr.c
- *
- * Description:
- * This translation unit agregates operations on thread attribute objects.
- * It is used for inline optimisation.
- *
- * The included modules are used separately when static executable sizes
- * must be minimised.
- *
- * --------------------------------------------------------------------------
- *
- * Pthreads-win32 - POSIX Threads Library for Win32
- * Copyright(C) 1998 John E. Bossom
- * Copyright(C) 1999,2005 Pthreads-win32 contributors
- *
- * Contact Email: rpj@callisto.canberra.edu.au
- *
- * The current list of contributors is contained
- * in the file CONTRIBUTORS included with the source
- * code distribution. The list can also be seen at the
- * following World Wide Web location:
- * http://sources.redhat.com/pthreads-win32/contributors.html
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library in the file COPYING.LIB;
- * if not, write to the Free Software Foundation, Inc.,
- * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
- */
-
-#include "pthread.h"
-#include "implement.h"
-
-#include "pthread_attr_init.c"
-#include "pthread_attr_destroy.c"
-#include "pthread_attr_getdetachstate.c"
-#include "pthread_attr_setdetachstate.c"
-#include "pthread_attr_getstackaddr.c"
-#include "pthread_attr_setstackaddr.c"
-#include "pthread_attr_getstacksize.c"
-#include "pthread_attr_setstacksize.c"
-#include "pthread_attr_getscope.c"
-#include "pthread_attr_setscope.c"
diff --git a/libs/pthreads/src/autostatic.c b/libs/pthreads/src/autostatic.c
deleted file mode 100644
index 092aff2aee..0000000000
--- a/libs/pthreads/src/autostatic.c
+++ /dev/null
@@ -1,69 +0,0 @@
-/*
- * autostatic.c
- *
- * Description:
- * This translation unit implements static auto-init and auto-exit logic.
- *
- * --------------------------------------------------------------------------
- *
- * Pthreads-win32 - POSIX Threads Library for Win32
- * Copyright(C) 1998 John E. Bossom
- * Copyright(C) 1999,2005 Pthreads-win32 contributors
- *
- * Contact Email: rpj@callisto.canberra.edu.au
- *
- * The current list of contributors is contained
- * in the file CONTRIBUTORS included with the source
- * code distribution. The list can also be seen at the
- * following World Wide Web location:
- * http://sources.redhat.com/pthreads-win32/contributors.html
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library in the file COPYING.LIB;
- * if not, write to the Free Software Foundation, Inc.,
- * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
- */
-
-#if defined(PTW32_STATIC_LIB)
-
-#if defined(__MINGW64__) || defined(__MINGW32__) || defined(_MSC_VER)
-
-#include "pthread.h"
-#include "implement.h"
-
-static void on_process_init(void)
-{
- pthread_win32_process_attach_np ();
-}
-
-static void on_process_exit(void)
-{
- pthread_win32_thread_detach_np ();
- pthread_win32_process_detach_np ();
-}
-
-#if defined(__MINGW64__) || defined(__MINGW32__)
-# define attribute_section(a) __attribute__((section(a)))
-#elif defined(_MSC_VER)
-# define attribute_section(a) __pragma(section(a,long,read)); __declspec(allocate(a))
-#endif
-
-attribute_section(".ctors") void *gcc_ctor = on_process_init;
-attribute_section(".dtors") void *gcc_dtor = on_process_exit;
-
-attribute_section(".CRT$XCU") void *msc_ctor = on_process_init;
-attribute_section(".CRT$XPU") void *msc_dtor = on_process_exit;
-
-#endif /* defined(__MINGW64__) || defined(__MINGW32__) || defined(_MSC_VER) */
-
-#endif /* PTW32_STATIC_LIB */
diff --git a/libs/pthreads/src/barrier.c b/libs/pthreads/src/barrier.c
deleted file mode 100644
index 41b950cd12..0000000000
--- a/libs/pthreads/src/barrier.c
+++ /dev/null
@@ -1,47 +0,0 @@
-/*
- * barrier.c
- *
- * Description:
- * This translation unit implements barrier primitives.
- *
- * --------------------------------------------------------------------------
- *
- * Pthreads-win32 - POSIX Threads Library for Win32
- * Copyright(C) 1998 John E. Bossom
- * Copyright(C) 1999,2005 Pthreads-win32 contributors
- *
- * Contact Email: rpj@callisto.canberra.edu.au
- *
- * The current list of contributors is contained
- * in the file CONTRIBUTORS included with the source
- * code distribution. The list can also be seen at the
- * following World Wide Web location:
- * http://sources.redhat.com/pthreads-win32/contributors.html
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library in the file COPYING.LIB;
- * if not, write to the Free Software Foundation, Inc.,
- * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
- */
-
-#include "pthread.h"
-#include "implement.h"
-
-
-#include "pthread_barrier_init.c"
-#include "pthread_barrier_destroy.c"
-#include "pthread_barrier_wait.c"
-#include "pthread_barrierattr_init.c"
-#include "pthread_barrierattr_destroy.c"
-#include "pthread_barrierattr_getpshared.c"
-#include "pthread_barrierattr_setpshared.c"
diff --git a/libs/pthreads/src/cancel.c b/libs/pthreads/src/cancel.c
deleted file mode 100644
index 1bd14ebe65..0000000000
--- a/libs/pthreads/src/cancel.c
+++ /dev/null
@@ -1,44 +0,0 @@
-/*
- * cancel.c
- *
- * Description:
- * POSIX thread functions related to thread cancellation.
- *
- * --------------------------------------------------------------------------
- *
- * Pthreads-win32 - POSIX Threads Library for Win32
- * Copyright(C) 1998 John E. Bossom
- * Copyright(C) 1999,2005 Pthreads-win32 contributors
- *
- * Contact Email: rpj@callisto.canberra.edu.au
- *
- * The current list of contributors is contained
- * in the file CONTRIBUTORS included with the source
- * code distribution. The list can also be seen at the
- * following World Wide Web location:
- * http://sources.redhat.com/pthreads-win32/contributors.html
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library in the file COPYING.LIB;
- * if not, write to the Free Software Foundation, Inc.,
- * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
- */
-
-#include "pthread.h"
-#include "implement.h"
-
-
-#include "pthread_setcancelstate.c"
-#include "pthread_setcanceltype.c"
-#include "pthread_testcancel.c"
-#include "pthread_cancel.c"
diff --git a/libs/pthreads/src/cleanup.c b/libs/pthreads/src/cleanup.c
index 381d1e87c8..90f81554e0 100644
--- a/libs/pthreads/src/cleanup.c
+++ b/libs/pthreads/src/cleanup.c
@@ -8,34 +8,38 @@
*
* --------------------------------------------------------------------------
*
- * Pthreads-win32 - POSIX Threads Library for Win32
+ * Pthreads4w - POSIX Threads Library for Win32
* Copyright(C) 1998 John E. Bossom
- * Copyright(C) 1999,2005 Pthreads-win32 contributors
- *
- * Contact Email: rpj@callisto.canberra.edu.au
- *
+ * Copyright(C) 1999-2018, Pthreads4w contributors
+ *
+ * Homepage: https://sourceforge.net/projects/pthreads4w/
+ *
* The current list of contributors is contained
* in the file CONTRIBUTORS included with the source
* code distribution. The list can also be seen at the
* following World Wide Web location:
- * http://sources.redhat.com/pthreads-win32/contributors.html
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library in the file COPYING.LIB;
- * if not, write to the Free Software Foundation, Inc.,
- * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
+ * https://sourceforge.net/p/pthreads4w/wiki/Contributors/
+ *
+ * This file is part of Pthreads4w.
+ *
+ * Pthreads4w is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * Pthreads4w is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Pthreads4w. If not, see <http://www.gnu.org/licenses/>. *
*/
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
#include "pthread.h"
#include "implement.h"
diff --git a/libs/pthreads/src/condvar.c b/libs/pthreads/src/condvar.c
deleted file mode 100644
index 704f4d7931..0000000000
--- a/libs/pthreads/src/condvar.c
+++ /dev/null
@@ -1,50 +0,0 @@
-/*
- * condvar.c
- *
- * Description:
- * This translation unit implements condition variables and their primitives.
- *
- *
- * --------------------------------------------------------------------------
- *
- * Pthreads-win32 - POSIX Threads Library for Win32
- * Copyright(C) 1998 John E. Bossom
- * Copyright(C) 1999,2005 Pthreads-win32 contributors
- *
- * Contact Email: rpj@callisto.canberra.edu.au
- *
- * The current list of contributors is contained
- * in the file CONTRIBUTORS included with the source
- * code distribution. The list can also be seen at the
- * following World Wide Web location:
- * http://sources.redhat.com/pthreads-win32/contributors.html
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library in the file COPYING.LIB;
- * if not, write to the Free Software Foundation, Inc.,
- * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
- *
- */
-
-#include "pthread.h"
-#include "implement.h"
-
-#include "ptw32_cond_check_need_init.c"
-#include "pthread_condattr_init.c"
-#include "pthread_condattr_destroy.c"
-#include "pthread_condattr_getpshared.c"
-#include "pthread_condattr_setpshared.c"
-#include "pthread_cond_init.c"
-#include "pthread_cond_destroy.c"
-#include "pthread_cond_wait.c"
-#include "pthread_cond_signal.c"
diff --git a/libs/pthreads/src/config.h b/libs/pthreads/src/config.h
index e63ce2da46..2edf4f4152 100644
--- a/libs/pthreads/src/config.h
+++ b/libs/pthreads/src/config.h
@@ -7,9 +7,12 @@
* Defaults: see target specific redefinitions below.
*********************************************************************/
-/* We're building the pthreads-win32 library */
+/* We're building the Pthreads4w library */
#define PTW32_BUILD
+/* CPU affinity */
+#define HAVE_CPU_AFFINITY
+
/* Do we know about the C type sigset_t? */
#undef HAVE_SIGSET_T
@@ -31,9 +34,6 @@
/* Define if you don't have Win32 calloc. (eg. WinCE) */
#undef NEED_CALLOC
-/* Define if you don't have Win32 ftime. (eg. WinCE) */
-#undef NEED_FTIME
-
/* Define if you don't have Win32 semaphores. (eg. WinCE 2.1 or earlier) */
#undef NEED_SEM
@@ -46,7 +46,7 @@
/* Do we know about type mode_t? */
#undef HAVE_MODE_T
-/*
+/*
* Define if GCC has atomic builtins, i.e. __sync_* intrinsics
* __sync_lock_* is implemented in mingw32 gcc 4.5.2 at least
* so this define does not turn those on or off. If you get an
@@ -55,7 +55,7 @@
#undef HAVE_GCC_ATOMIC_BUILTINS
/* Define if you have the timespec struct */
-#define HAVE_STRUCT_TIMESPEC 1
+#undef HAVE_STRUCT_TIMESPEC
/* Define if you don't have the GetProcessAffinityMask() */
#undef NEED_PROCESS_AFFINITY_MASK
@@ -106,35 +106,29 @@
* Target specific groups
*
* If you find that these are incorrect or incomplete please report it
- * to the pthreads-win32 maintainer. Thanks.
+ * to the Pthreads4w maintainer. Thanks.
*********************************************************************/
#if defined(WINCE)
-#define NEED_DUPLICATEHANDLE
-#define NEED_CREATETHREAD
-#define NEED_ERRNO
-#define NEED_CALLOC
-#define NEED_FTIME
-/* #define NEED_SEM */
-#define NEED_UNICODE_CONSTS
-#define NEED_PROCESS_AFFINITY_MASK
+# undef HAVE_CPU_AFFINITY
+# define NEED_DUPLICATEHANDLE
+# define NEED_CREATETHREAD
+# define NEED_ERRNO
+# define NEED_CALLOC
+/* # define NEED_SEM */
+# define NEED_UNICODE_CONSTS
+# define NEED_PROCESS_AFFINITY_MASK
/* This may not be needed */
-#define RETAIN_WSALASTERROR
+# define RETAIN_WSALASTERROR
#endif
#if defined(_UWIN)
-#define HAVE_MODE_T
-#define HAVE_STRUCT_TIMESPEC
+# define HAVE_MODE_T
+# define HAVE_STRUCT_TIMESPEC
+# define HAVE_SIGNAL_H
#endif
#if defined(__GNUC__)
-#define HAVE_C_INLINE
-#endif
-
-#if defined(__MINGW64__)
-#define HAVE_MODE_T
-#define HAVE_STRUCT_TIMESPEC
-#elif defined(__MINGW32__)
-#define HAVE_MODE_T
+# define HAVE_C_INLINE
#endif
#if defined(__BORLANDC__)
@@ -148,6 +142,8 @@
#define HAVE_C_INLINE
#endif
-
-
+#if defined(_MSC_VER) && _MSC_VER >= 1900
+#define HAVE_STRUCT_TIMESPEC
#endif
+
+#endif /* PTW32_CONFIG_H */
diff --git a/libs/pthreads/src/context.h b/libs/pthreads/src/context.h
index 3d4511f5b3..016066ab3d 100644
--- a/libs/pthreads/src/context.h
+++ b/libs/pthreads/src/context.h
@@ -6,32 +6,32 @@
*
* --------------------------------------------------------------------------
*
- * Pthreads-win32 - POSIX Threads Library for Win32
+ * Pthreads4w - POSIX Threads Library for Win32
* Copyright(C) 1998 John E. Bossom
- * Copyright(C) 1999,2005 Pthreads-win32 contributors
- *
- * Contact Email: rpj@callisto.canberra.edu.au
- *
+ * Copyright(C) 1999-2018, Pthreads4w contributors
+ *
+ * Homepage: https://sourceforge.net/projects/pthreads4w/
+ *
* The current list of contributors is contained
* in the file CONTRIBUTORS included with the source
* code distribution. The list can also be seen at the
* following World Wide Web location:
- * http://sources.redhat.com/pthreads-win32/contributors.html
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library in the file COPYING.LIB;
- * if not, write to the Free Software Foundation, Inc.,
- * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
+ * https://sourceforge.net/p/pthreads4w/wiki/Contributors/
+ *
+ * This file is part of Pthreads4w.
+ *
+ * Pthreads4w is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * Pthreads4w is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Pthreads4w. If not, see <http://www.gnu.org/licenses/>. *
*/
#ifndef PTW32_CONTEXT_H
@@ -63,7 +63,7 @@
#define PTW32_PROGCTR(Context) ((Context).Rip)
#endif
-#if defined(_ARM_) || defined(ARM)
+#if defined(_ARM_) || defined(ARM) || defined(_M_ARM) || defined(_M_ARM64)
#define PTW32_PROGCTR(Context) ((Context).Pc)
#endif
diff --git a/libs/pthreads/src/create.c b/libs/pthreads/src/create.c
index 8b036cc2e9..cc59419bc1 100644
--- a/libs/pthreads/src/create.c
+++ b/libs/pthreads/src/create.c
@@ -7,34 +7,38 @@
*
* --------------------------------------------------------------------------
*
- * Pthreads-win32 - POSIX Threads Library for Win32
+ * Pthreads4w - POSIX Threads Library for Win32
* Copyright(C) 1998 John E. Bossom
- * Copyright(C) 1999,2005 Pthreads-win32 contributors
- *
- * Contact Email: rpj@callisto.canberra.edu.au
- *
+ * Copyright(C) 1999-2018, Pthreads4w contributors
+ *
+ * Homepage: https://sourceforge.net/projects/pthreads4w/
+ *
* The current list of contributors is contained
* in the file CONTRIBUTORS included with the source
* code distribution. The list can also be seen at the
* following World Wide Web location:
- * http://sources.redhat.com/pthreads-win32/contributors.html
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library in the file COPYING.LIB;
- * if not, write to the Free Software Foundation, Inc.,
- * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
+ * https://sourceforge.net/p/pthreads4w/wiki/Contributors/
+ *
+ * This file is part of Pthreads4w.
+ *
+ * Pthreads4w is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * Pthreads4w is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Pthreads4w. If not, see <http://www.gnu.org/licenses/>. *
*/
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
#include "pthread.h"
#include "implement.h"
#if ! defined(_UWIN) && ! defined(WINCE)
@@ -43,48 +47,49 @@
int
pthread_create (pthread_t * tid,
- const pthread_attr_t * attr,
- void *(PTW32_CDECL *start) (void *), void *arg)
- /*
- * ------------------------------------------------------
- * DOCPUBLIC
- * This function creates a thread running the start function,
- * passing it the parameter value, 'arg'. The 'attr'
- * argument specifies optional creation attributes.
- * The identity of the new thread is returned
- * via 'tid', which should not be NULL.
- *
- * PARAMETERS
- * tid
- * pointer to an instance of pthread_t
- *
- * attr
- * optional pointer to an instance of pthread_attr_t
- *
- * start
- * pointer to the starting routine for the new thread
- *
- * arg
- * optional parameter passed to 'start'
- *
- *
- * DESCRIPTION
- * This function creates a thread running the start function,
- * passing it the parameter value, 'arg'. The 'attr'
- * argument specifies optional creation attributes.
- * The identity of the new thread is returned
- * via 'tid', which should not be the NULL pointer.
- *
- * RESULTS
- * 0 successfully created thread,
- * EINVAL attr invalid,
- * EAGAIN insufficient resources.
- *
- * ------------------------------------------------------
- */
+ const pthread_attr_t * attr,
+ void *(PTW32_CDECL *start) (void *), void *arg)
+/*
+ * ------------------------------------------------------
+ * DOCPUBLIC
+ * This function creates a thread running the start function,
+ * passing it the parameter value, 'arg'. The 'attr'
+ * argument specifies optional creation attributes.
+ * The identity of the new thread is returned
+ * via 'tid', which should not be NULL.
+ *
+ * PARAMETERS
+ * tid
+ * pointer to an instance of pthread_t
+ *
+ * attr
+ * optional pointer to an instance of pthread_attr_t
+ *
+ * start
+ * pointer to the starting routine for the new thread
+ *
+ * arg
+ * optional parameter passed to 'start'
+ *
+ *
+ * DESCRIPTION
+ * This function creates a thread running the start function,
+ * passing it the parameter value, 'arg'. The 'attr'
+ * argument specifies optional creation attributes.
+ * The identity of the new thread is returned
+ * via 'tid', which should not be the NULL pointer.
+ *
+ * RESULTS
+ * 0 successfully created thread,
+ * EINVAL attr invalid,
+ * EAGAIN insufficient resources.
+ *
+ * ------------------------------------------------------
+ */
{
pthread_t thread;
ptw32_thread_t * tp;
+ ptw32_thread_t * sp;
register pthread_attr_t a;
HANDLE threadH = 0;
int result = EAGAIN;
@@ -92,7 +97,6 @@ pthread_create (pthread_t * tid,
ThreadParms *parms = NULL;
unsigned int stackSize;
int priority;
- pthread_t self;
/*
* Before doing anything, check that tid can be stored through
@@ -102,6 +106,11 @@ pthread_create (pthread_t * tid,
*/
tid->x = 0;
+ if (NULL == (sp = (ptw32_thread_t *)pthread_self().p))
+ {
+ goto FAIL0;
+ }
+
if (attr != NULL)
{
a = *attr;
@@ -111,7 +120,8 @@ pthread_create (pthread_t * tid,
a = NULL;
}
- if ((thread = ptw32_new ()).p == NULL)
+ thread = ptw32_new();
+ if (thread.p == NULL)
{
goto FAIL0;
}
@@ -129,22 +139,34 @@ pthread_create (pthread_t * tid,
parms->start = start;
parms->arg = arg;
-#if defined(HAVE_SIGSET_T)
-
/*
- * Threads inherit their initial sigmask from their creator thread.
+ * Threads inherit their initial sigmask and CPU affinity from their creator thread.
*/
- self = pthread_self();
- tp->sigmask = ((ptw32_thread_t *)self.p)->sigmask;
-
-#endif /* HAVE_SIGSET_T */
-
+#if defined(HAVE_SIGSET_T)
+ tp->sigmask = sp->sigmask;
+#endif
+#if defined(HAVE_CPU_AFFINITY)
+ tp->cpuset = sp->cpuset;
+#endif
if (a != NULL)
{
+#if defined(HAVE_CPU_AFFINITY)
+ cpu_set_t none;
+ cpu_set_t attr_cpuset;
+ ((_sched_cpu_set_vector_*)&attr_cpuset)->_cpuset = a->cpuset;
+
+ CPU_ZERO(&none);
+ if (! CPU_EQUAL(&attr_cpuset, &none))
+ {
+ tp->cpuset = a->cpuset;
+ }
+#endif
stackSize = (unsigned int)a->stacksize;
tp->detachState = a->detachstate;
priority = a->param.sched_priority;
+ if (a->thrname != NULL)
+ tp->name = _strdup(a->thrname);
#if (THREAD_PRIORITY_LOWEST > THREAD_PRIORITY_NORMAL)
/* WinCE */
@@ -164,17 +186,14 @@ pthread_create (pthread_t * tid,
* PTHREAD_EXPLICIT_SCHED and priority THREAD_PRIORITY_NORMAL.
*/
if (PTHREAD_INHERIT_SCHED == a->inheritsched)
- {
- /*
- * If the thread that called pthread_create() is a Win32 thread
- * then the inherited priority could be the result of a temporary
- * system adjustment. This is not the case for POSIX threads.
- */
-#if ! defined(HAVE_SIGSET_T)
- self = pthread_self ();
-#endif
- priority = ((ptw32_thread_t *) self.p)->sched_priority;
- }
+ {
+ /*
+ * If the thread that called pthread_create() is a Win32 thread
+ * then the inherited priority could be the result of a temporary
+ * system adjustment. This is not the case for POSIX threads.
+ */
+ priority = sp->sched_priority;
+ }
#endif
@@ -200,29 +219,35 @@ pthread_create (pthread_t * tid,
* finished with it here.
*/
-#if ! (defined (__MINGW64__) || defined(__MINGW32__)) || defined (__MSVCRT__) || defined (__DMC__)
+#if ! defined (__MINGW32__) || defined (__MSVCRT__) || defined (__DMC__)
tp->threadH =
- threadH =
- (HANDLE) _beginthreadex ((void *) NULL, /* No security info */
- stackSize, /* default stack size */
- ptw32_threadStart,
- parms,
- (unsigned)
- CREATE_SUSPENDED,
- (unsigned *) &(tp->thread));
+ threadH =
+ (HANDLE) _beginthreadex ((void *) NULL, /* No security info */
+ stackSize, /* default stack size */
+ ptw32_threadStart,
+ parms,
+ (unsigned)
+ CREATE_SUSPENDED,
+ (unsigned *) &(tp->thread));
if (threadH != 0)
{
if (a != NULL)
- {
- (void) ptw32_setthreadpriority (thread, SCHED_OTHER, priority);
- }
+ {
+ (void) ptw32_setthreadpriority (thread, SCHED_OTHER, priority);
+ }
+
+#if defined(HAVE_CPU_AFFINITY)
+
+ SetThreadAffinityMask(tp->threadH, tp->cpuset);
+
+#endif
if (run)
- {
- ResumeThread (threadH);
- }
+ {
+ ResumeThread (threadH);
+ }
}
#else
@@ -237,9 +262,9 @@ pthread_create (pthread_t * tid,
ptw32_mcs_lock_acquire(&tp->stateLock, &stateLock);
tp->threadH =
- threadH =
- (HANDLE) _beginthread (ptw32_threadStart, stackSize, /* default stack size */
- parms);
+ threadH =
+ (HANDLE) _beginthread (ptw32_threadStart, stackSize, /* default stack size */
+ parms);
/*
* Make the return code match _beginthreadex's.
@@ -251,19 +276,26 @@ pthread_create (pthread_t * tid,
else
{
if (!run)
- {
- /*
- * beginthread does not allow for create flags, so we do it now.
- * Note that beginthread itself creates the thread in SUSPENDED
- * mode, and then calls ResumeThread to start it.
- */
- SuspendThread (threadH);
- }
-
+ {
+ /*
+ * beginthread does not allow for create flags, so we do it now.
+ * Note that beginthread itself creates the thread in SUSPENDED
+ * mode, and then calls ResumeThread to start it.
+ */
+ SuspendThread (threadH);
+ }
+
if (a != NULL)
- {
- (void) ptw32_setthreadpriority (thread, SCHED_OTHER, priority);
- }
+ {
+ (void) ptw32_setthreadpriority (thread, SCHED_OTHER, priority);
+ }
+
+#if defined(HAVE_CPU_AFFINITY)
+
+ SetThreadAffinityMask(tp->threadH, tp->cpuset);
+
+#endif
+
}
ptw32_mcs_lock_release (&stateLock);
@@ -282,7 +314,7 @@ pthread_create (pthread_t * tid,
* ------------
*/
-FAIL0:
+ FAIL0:
if (result != 0)
{
@@ -290,9 +322,9 @@ FAIL0:
tp = NULL;
if (parms != NULL)
- {
- free (parms);
- }
+ {
+ free (parms);
+ }
}
else
{
@@ -304,5 +336,4 @@ FAIL0:
pthread_count++;
#endif
return (result);
-
} /* pthread_create */
diff --git a/libs/pthreads/src/dll.c b/libs/pthreads/src/dll.c
index 05e01bee76..bd3bbaeae9 100644
--- a/libs/pthreads/src/dll.c
+++ b/libs/pthreads/src/dll.c
@@ -6,41 +6,45 @@
*
* --------------------------------------------------------------------------
*
- * Pthreads-win32 - POSIX Threads Library for Win32
+ * Pthreads4w - POSIX Threads Library for Win32
* Copyright(C) 1998 John E. Bossom
- * Copyright(C) 1999,2005 Pthreads-win32 contributors
- *
- * Contact Email: rpj@callisto.canberra.edu.au
- *
+ * Copyright(C) 1999-2018, Pthreads4w contributors
+ *
+ * Homepage: https://sourceforge.net/projects/pthreads4w/
+ *
* The current list of contributors is contained
* in the file CONTRIBUTORS included with the source
* code distribution. The list can also be seen at the
* following World Wide Web location:
- * http://sources.redhat.com/pthreads-win32/contributors.html
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library in the file COPYING.LIB;
- * if not, write to the Free Software Foundation, Inc.,
- * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
+ * https://sourceforge.net/p/pthreads4w/wiki/Contributors/
+ *
+ * This file is part of Pthreads4w.
+ *
+ * Pthreads4w is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * Pthreads4w is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Pthreads4w. If not, see <http://www.gnu.org/licenses/>. *
*/
-#if !defined(PTW32_STATIC_LIB)
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
#include "pthread.h"
#include "implement.h"
+#if !defined(PTW32_STATIC_LIB)
+
#if defined(_MSC_VER)
-/*
+/*
* lpvReserved yields an unreferenced formal parameter;
* ignore it
*/
@@ -53,8 +57,7 @@
*/
extern "C"
#endif /* __cplusplus */
- BOOL WINAPI
-DllMain (HINSTANCE hinstDll, DWORD fdwReason, LPVOID lpvReserved)
+ BOOL WINAPI DllMain (HINSTANCE hinstDll, DWORD fdwReason, LPVOID lpvReserved)
{
BOOL result = PTW32_TRUE;
@@ -89,4 +92,78 @@ DllMain (HINSTANCE hinstDll, DWORD fdwReason, LPVOID lpvReserved)
} /* DllMain */
+#endif /* !PTW32_STATIC_LIB */
+
+#if ! defined(PTW32_BUILD_INLINED)
+/*
+ * Avoid "translation unit is empty" warnings
+ */
+typedef int foo;
+#endif
+
+#if defined(PTW32_STATIC_LIB)
+
+/*
+ * Note: MSVC 8 and higher use code in dll.c, which enables TLS cleanup
+ * on thread exit. Code here can only do process init and exit functions.
+ */
+
+#if defined(__MINGW32__) || defined(_MSC_VER)
+
+/* For an explanation of this code (at least the MSVC parts), refer to
+ *
+ * http://www.codeguru.com/cpp/misc/misc/threadsprocesses/article.php/c6945/
+ * ("Running Code Before and After Main")
+ *
+ * Compatibility with MSVC8 was cribbed from Boost:
+ *
+ * http://svn.boost.org/svn/boost/trunk/libs/thread/src/win32/tss_pe.cpp
+ *
+ * In addition to that, because we are in a static library, and the linker
+ * can't tell that the constructor/destructor functions are actually
+ * needed, we need a way to prevent the linker from optimizing away this
+ * module. The pthread_win32_autostatic_anchor() hack below (and in
+ * implement.h) does the job in a portable manner.
+ */
+
+static int on_process_init(void)
+{
+ pthread_win32_process_attach_np ();
+ return 0;
+}
+
+static int on_process_exit(void)
+{
+ pthread_win32_thread_detach_np ();
+ pthread_win32_process_detach_np ();
+ return 0;
+}
+
+#if defined(__GNUC__)
+__attribute__((section(".ctors"), used)) static int (*gcc_ctor)(void) = on_process_init;
+__attribute__((section(".dtors"), used)) static int (*gcc_dtor)(void) = on_process_exit;
+#elif defined(_MSC_VER)
+# if _MSC_VER >= 1400 /* MSVC8+ */
+# pragma section(".CRT$XCU", long, read)
+# pragma section(".CRT$XPU", long, read)
+__declspec(allocate(".CRT$XCU")) static int (*msc_ctor)(void) = on_process_init;
+__declspec(allocate(".CRT$XPU")) static int (*msc_dtor)(void) = on_process_exit;
+# else
+# pragma data_seg(".CRT$XCU")
+static int (*msc_ctor)(void) = on_process_init;
+# pragma data_seg(".CRT$XPU")
+static int (*msc_dtor)(void) = on_process_exit;
+# pragma data_seg() /* reset data segment */
+# endif
+#endif
+
+#endif /* defined(__MINGW32__) || defined(_MSC_VER) */
+
+/* This dummy function exists solely to be referenced by other modules
+ * (specifically, in implement.h), so that the linker can't optimize away
+ * this module. Don't call it.
+ */
+void ptw32_autostatic_anchor(void) { abort(); }
+
#endif /* PTW32_STATIC_LIB */
+
diff --git a/libs/pthreads/src/errno.c b/libs/pthreads/src/errno.c
index 78aa920a5b..9b99d83877 100644
--- a/libs/pthreads/src/errno.c
+++ b/libs/pthreads/src/errno.c
@@ -7,34 +7,38 @@
*
* --------------------------------------------------------------------------
*
- * Pthreads-win32 - POSIX Threads Library for Win32
+ * Pthreads4w - POSIX Threads Library for Win32
* Copyright(C) 1998 John E. Bossom
- * Copyright(C) 1999,2005 Pthreads-win32 contributors
- *
- * Contact Email: rpj@callisto.canberra.edu.au
- *
+ * Copyright(C) 1999-2018, Pthreads4w contributors
+ *
+ * Homepage: https://sourceforge.net/projects/pthreads4w/
+ *
* The current list of contributors is contained
* in the file CONTRIBUTORS included with the source
* code distribution. The list can also be seen at the
* following World Wide Web location:
- * http://sources.redhat.com/pthreads-win32/contributors.html
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library in the file COPYING.LIB;
- * if not, write to the Free Software Foundation, Inc.,
- * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
+ * https://sourceforge.net/p/pthreads4w/wiki/Contributors/
+ *
+ * This file is part of Pthreads4w.
+ *
+ * Pthreads4w is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * Pthreads4w is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Pthreads4w. If not, see <http://www.gnu.org/licenses/>. *
*/
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
#if defined(NEED_ERRNO)
#include "pthread.h"
@@ -84,7 +88,7 @@ _errno (void)
}
else
{
- result = (int *)(&self.p->exitStatus);
+ result = (int *)(&((ptw32_thread_t *)self.p)->exitStatus);
}
return (result);
@@ -92,3 +96,10 @@ _errno (void)
} /* _errno */
#endif /* (NEED_ERRNO) */
+
+#if ! defined(PTW32_BUILD_INLINED)
+/*
+ * Avoid "translation unit is empty" warnings
+ */
+typedef int foo;
+#endif
diff --git a/libs/pthreads/src/exit.c b/libs/pthreads/src/exit.c
deleted file mode 100644
index 94369d007c..0000000000
--- a/libs/pthreads/src/exit.c
+++ /dev/null
@@ -1,44 +0,0 @@
-/*
- * exit.c
- *
- * Description:
- * This translation unit implements routines associated with exiting from
- * a thread.
- *
- * --------------------------------------------------------------------------
- *
- * Pthreads-win32 - POSIX Threads Library for Win32
- * Copyright(C) 1998 John E. Bossom
- * Copyright(C) 1999,2005 Pthreads-win32 contributors
- *
- * Contact Email: rpj@callisto.canberra.edu.au
- *
- * The current list of contributors is contained
- * in the file CONTRIBUTORS included with the source
- * code distribution. The list can also be seen at the
- * following World Wide Web location:
- * http://sources.redhat.com/pthreads-win32/contributors.html
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library in the file COPYING.LIB;
- * if not, write to the Free Software Foundation, Inc.,
- * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
- */
-
-#include "pthread.h"
-#include "implement.h"
-#if ! defined(_UWIN) && ! defined(WINCE)
-# include <process.h>
-#endif
-
-#include "pthread_exit.c"
diff --git a/libs/pthreads/src/fork.c b/libs/pthreads/src/fork.c
deleted file mode 100644
index 8a29550caf..0000000000
--- a/libs/pthreads/src/fork.c
+++ /dev/null
@@ -1,39 +0,0 @@
-/*
- * fork.c
- *
- * Description:
- * Implementation of fork() for POSIX threads.
- *
- * --------------------------------------------------------------------------
- *
- * Pthreads-win32 - POSIX Threads Library for Win32
- * Copyright(C) 1998 John E. Bossom
- * Copyright(C) 1999,2005 Pthreads-win32 contributors
- *
- * Contact Email: rpj@callisto.canberra.edu.au
- *
- * The current list of contributors is contained
- * in the file CONTRIBUTORS included with the source
- * code distribution. The list can also be seen at the
- * following World Wide Web location:
- * http://sources.redhat.com/pthreads-win32/contributors.html
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library in the file COPYING.LIB;
- * if not, write to the Free Software Foundation, Inc.,
- * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
- */
-
-
-#include "pthread.h"
-#include "implement.h"
diff --git a/libs/pthreads/src/global.c b/libs/pthreads/src/global.c
index f1e9b3f669..92a0c86d81 100644
--- a/libs/pthreads/src/global.c
+++ b/libs/pthreads/src/global.c
@@ -7,34 +7,38 @@
*
* --------------------------------------------------------------------------
*
- * Pthreads-win32 - POSIX Threads Library for Win32
+ * Pthreads4w - POSIX Threads Library for Win32
* Copyright(C) 1998 John E. Bossom
- * Copyright(C) 1999,2005 Pthreads-win32 contributors
- *
- * Contact Email: rpj@callisto.canberra.edu.au
- *
+ * Copyright(C) 1999-2018, Pthreads4w contributors
+ *
+ * Homepage: https://sourceforge.net/projects/pthreads4w/
+ *
* The current list of contributors is contained
* in the file CONTRIBUTORS included with the source
* code distribution. The list can also be seen at the
* following World Wide Web location:
- * http://sources.redhat.com/pthreads-win32/contributors.html
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library in the file COPYING.LIB;
- * if not, write to the Free Software Foundation, Inc.,
- * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
+ * https://sourceforge.net/p/pthreads4w/wiki/Contributors/
+ *
+ * This file is part of Pthreads4w.
+ *
+ * Pthreads4w is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * Pthreads4w is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Pthreads4w. If not, see <http://www.gnu.org/licenses/>. *
*/
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
#include "pthread.h"
#include "implement.h"
@@ -57,12 +61,12 @@ int ptw32_features = 0;
*/
unsigned __int64 ptw32_threadSeqNumber = 0;
-/*
+/*
* Function pointer to QueueUserAPCEx if it exists, otherwise
* it will be set at runtime to a substitute routine which cannot unblock
* blocked threads.
*/
-DWORD (*ptw32_register_cancelation) (PAPCFUNC, HANDLE, DWORD) = NULL;
+DWORD (*ptw32_register_cancellation) (PAPCFUNC, HANDLE, DWORD) = NULL;
/*
* Global lock for managing pthread_t struct reuse.
diff --git a/libs/pthreads/src/implement.h b/libs/pthreads/src/implement.h
index 693be26a24..a0fd235d18 100644
--- a/libs/pthreads/src/implement.h
+++ b/libs/pthreads/src/implement.h
@@ -7,43 +7,51 @@
*
* --------------------------------------------------------------------------
*
- * Pthreads-win32 - POSIX Threads Library for Win32
+ * Pthreads4w - POSIX Threads Library for Win32
* Copyright(C) 1998 John E. Bossom
- * Copyright(C) 1999,2005 Pthreads-win32 contributors
- *
- * Contact Email: Ross.Johnson@homemail.com.au
- *
+ * Copyright(C) 1999-2018, Pthreads4w contributors
+ *
+ * Homepage: https://sourceforge.net/projects/pthreads4w/
+ *
* The current list of contributors is contained
* in the file CONTRIBUTORS included with the source
* code distribution. The list can also be seen at the
* following World Wide Web location:
- * http://sources.redhat.com/pthreads-win32/contributors.html
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library in the file COPYING.LIB;
- * if not, write to the Free Software Foundation, Inc.,
- * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
+ * https://sourceforge.net/p/pthreads4w/wiki/Contributors/
+ *
+ * This file is part of Pthreads4w.
+ *
+ * Pthreads4w is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * Pthreads4w is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Pthreads4w. If not, see <http://www.gnu.org/licenses/>. *
*/
#if !defined(_IMPLEMENT_H)
#define _IMPLEMENT_H
+#if !defined(PTW32_CONFIG_H)
+# error "config.h was not #included"
+#endif
+
+#include <_ptw32.h>
+
#if !defined(_WIN32_WINNT)
-#define _WIN32_WINNT 0x0400
+# define _WIN32_WINNT 0x0400
#endif
-#include <windows.h>
+#define WIN32_LEAN_AND_MEAN
+#include <windows.h>
+#include <sys/types.h>
/*
* In case windows.h doesn't define it (e.g. WinCE perhaps)
*/
@@ -52,19 +60,33 @@ typedef VOID (APIENTRY *PAPCFUNC)(DWORD dwParam);
#endif
/*
- * note: ETIMEDOUT is correctly defined in winsock.h
+ * Designed to allow error values to be set and retrieved in builds where
+ * MSCRT libraries are statically linked to DLLs.
*/
-#include <winsock.h>
-
-/*
- * In case ETIMEDOUT hasn't been defined above somehow.
- */
-#if !defined(ETIMEDOUT)
-# define ETIMEDOUT 10060 /* This is the value in winsock.h. */
+#if ! defined(WINCE) && \
+ (( defined(__MINGW32__) && __MSVCRT_VERSION__ >= 0x0800 ) || \
+ ( defined(_MSC_VER) && _MSC_VER >= 1400 )) /* MSVC8+ */
+# if defined(__MINGW32__)
+__attribute__((unused))
+# endif
+static int ptw32_get_errno(void) { int err = 0; _get_errno(&err); return err; }
+# define PTW32_GET_ERRNO() ptw32_get_errno()
+# if defined(__MINGW32__)
+__attribute__((unused))
+# endif
+static void ptw32_set_errno(int err) { _set_errno(err); SetLastError(err); }
+# define PTW32_SET_ERRNO(err) ptw32_set_errno(err)
+#else
+# define PTW32_GET_ERRNO() (errno)
+# if defined(__MINGW32__)
+__attribute__((unused))
+# endif
+static void ptw32_set_errno(int err) { errno = err; SetLastError(err); }
+# define PTW32_SET_ERRNO(err) ptw32_set_errno(err)
#endif
#if !defined(malloc)
-#include <malloc.h>
+# include <malloc.h>
#endif
#if defined(__CLEANUP_C)
@@ -72,43 +94,49 @@ typedef VOID (APIENTRY *PAPCFUNC)(DWORD dwParam);
#endif
#if !defined(INT_MAX)
-#include <limits.h>
+# include <limits.h>
#endif
/* use local include files during development */
#include "semaphore.h"
#include "sched.h"
-#if defined(HAVE_C_INLINE) || defined(__cplusplus)
-#define INLINE inline
-#else
+/* MSVC 7.1 doesn't like complex #if expressions */
#define INLINE
+#if defined(PTW32_BUILD_INLINED)
+# if defined(HAVE_C_INLINE) || defined(__cplusplus)
+# undef INLINE
+# define INLINE inline
+# endif
#endif
-#if defined(_MSC_VER) && _MSC_VER < 1300
-/*
- * MSVC 6 does not use the "volatile" qualifier
- */
-#define PTW32_INTERLOCKED_VOLATILE
+#if defined(PTW32_CONFIG_MSVC6)
+# define PTW32_INTERLOCKED_VOLATILE
#else
-#define PTW32_INTERLOCKED_VOLATILE volatile
+# define PTW32_INTERLOCKED_VOLATILE volatile
#endif
+
#define PTW32_INTERLOCKED_LONG long
-#define PTW32_INTERLOCKED_SIZE size_t
#define PTW32_INTERLOCKED_PVOID PVOID
#define PTW32_INTERLOCKED_LONGPTR PTW32_INTERLOCKED_VOLATILE long*
-#define PTW32_INTERLOCKED_SIZEPTR PTW32_INTERLOCKED_VOLATILE size_t*
#define PTW32_INTERLOCKED_PVOID_PTR PTW32_INTERLOCKED_VOLATILE PVOID*
-
-#if defined(__MINGW64__) || defined(__MINGW32__)
-# include <stdint.h>
-#elif defined(__BORLANDC__)
-# define int64_t ULONGLONG
+#if defined(_WIN64)
+# define PTW32_INTERLOCKED_SIZE LONGLONG
+# define PTW32_INTERLOCKED_SIZEPTR PTW32_INTERLOCKED_VOLATILE LONGLONG*
#else
-# define int64_t _int64
-# if defined(_MSC_VER) && _MSC_VER < 1300
- typedef long intptr_t;
-# endif
+# define PTW32_INTERLOCKED_SIZE long
+# define PTW32_INTERLOCKED_SIZEPTR PTW32_INTERLOCKED_VOLATILE long*
+#endif
+
+/*
+ * Don't allow the linker to optimize away dll.obj (dll.o) in static builds.
+ */
+#if defined(PTW32_STATIC_LIB) && defined(PTW32_BUILD) && !defined(PTW32_TEST_SNEAK_PEEK)
+ void ptw32_autostatic_anchor(void);
+# if defined(__GNUC__)
+ __attribute__((unused, used))
+# endif
+ static void (*local_autostatic_anchor)(void) = ptw32_autostatic_anchor;
#endif
typedef enum
@@ -122,7 +150,7 @@ typedef enum
PThreadStateRunning, /* Thread alive & kicking */
PThreadStateSuspended, /* Thread alive but suspended */
PThreadStateCancelPending, /* Thread alive but */
- /* has cancelation pending. */
+ /* has cancellation pending. */
PThreadStateCanceling, /* Thread alive but is */
/* in the process of terminating */
/* due to a cancellation request */
@@ -139,7 +167,6 @@ typedef struct ptw32_mcs_node_t_* ptw32_mcs_lock_t;
typedef struct ptw32_robust_node_t_ ptw32_robust_node_t;
typedef struct ptw32_thread_t_ ptw32_thread_t;
-
struct ptw32_thread_t_
{
unsigned __int64 seqNumber; /* Process-unique thread sequence number */
@@ -170,7 +197,11 @@ struct ptw32_thread_t_
int cancelState;
int cancelType;
int implicit:1;
- DWORD thread; /* Win32 thread ID */
+ DWORD thread; /* Windows thread ID */
+#if defined(HAVE_CPU_AFFINITY)
+ size_t cpuset; /* Thread CPU affinity set */
+#endif
+ char * name; /* Thread name */
#if defined(_UWIN)
DWORD dummy[5];
#endif
@@ -178,7 +209,7 @@ struct ptw32_thread_t_
};
-/*
+/*
* Special value to mark attribute objects as valid.
*/
#define PTW32_ATTR_VALID ((unsigned long) 0xC4C0FFEE)
@@ -192,6 +223,8 @@ struct pthread_attr_t_
struct sched_param param;
int inheritsched;
int contentionscope;
+ size_t cpuset;
+ char * thrname;
#if defined(HAVE_SIGSET_T)
sigset_t sigmask;
#endif /* HAVE_SIGSET_T */
@@ -209,7 +242,7 @@ struct pthread_attr_t_
struct sem_t_
{
int value;
- pthread_mutex_t lock;
+ ptw32_mcs_lock_t lock;
HANDLE sem;
#if defined(NEED_SEM)
int leftToUnblock;
@@ -386,6 +419,12 @@ struct pthread_rwlockattr_t_
int pshared;
};
+typedef union
+{
+ char cpuset[CPU_SETSIZE/8];
+ size_t _cpuset;
+} _sched_cpu_set_vector_;
+
typedef struct ThreadKeyAssoc ThreadKeyAssoc;
struct ThreadKeyAssoc
@@ -469,7 +508,7 @@ struct ThreadKeyAssoc
* The pthread_key_t->threads attribute is the head of
* a chain of associations that runs through the
* nextThreads link. This chain provides the 1 to many
- * relationship between a pthread_key_t and all the
+ * relationship between a pthread_key_t and all the
* PThreads that have called pthread_setspecific for
* this pthread_key_t.
*
@@ -557,7 +596,7 @@ struct ThreadKeyAssoc
/* Declared in pthread_cancel.c */
-extern DWORD (*ptw32_register_cancelation) (PAPCFUNC, HANDLE, DWORD);
+extern DWORD (*ptw32_register_cancellation) (PAPCFUNC, HANDLE, DWORD);
/* Thread Reuse stack bottom marker. Must not be NULL or any valid pointer to memory. */
#define PTW32_THREAD_REUSE_EMPTY ((ptw32_thread_t *)(size_t) 1)
@@ -589,10 +628,7 @@ extern ptw32_mcs_lock_t ptw32_spinlock_test_init_lock;
extern int pthread_count;
#endif
-#if defined(__cplusplus)
-extern "C"
-{
-#endif /* __cplusplus */
+__PTW32_BEGIN_C_DECLS
/*
* =====================
@@ -607,13 +643,14 @@ extern "C"
int ptw32_cond_check_need_init (pthread_cond_t * cond);
int ptw32_mutex_check_need_init (pthread_mutex_t * mutex);
int ptw32_rwlock_check_need_init (pthread_rwlock_t * rwlock);
+ int ptw32_spinlock_check_need_init (pthread_spinlock_t * lock);
int ptw32_robust_mutex_inherit(pthread_mutex_t * mutex);
void ptw32_robust_mutex_add(pthread_mutex_t* mutex, pthread_t self);
void ptw32_robust_mutex_remove(pthread_mutex_t* mutex, ptw32_thread_t* otp);
DWORD
- ptw32_RegisterCancelation (PAPCFUNC callback,
+ ptw32_Registercancellation (PAPCFUNC callback,
HANDLE threadH, DWORD callback_arg);
int ptw32_processInitialize (void);
@@ -636,7 +673,7 @@ extern "C"
void ptw32_rwlock_cancelwrwait (void *arg);
-#if ! (defined (__MINGW64__) || defined(__MINGW32__)) || (defined(__MSVCRT__) && ! defined(__DMC__))
+#if ! defined (__MINGW32__) || (defined (__MSVCRT__) && ! defined (__DMC__))
unsigned __stdcall
#else
void
@@ -661,43 +698,26 @@ extern "C"
void ptw32_mcs_node_transfer (ptw32_mcs_local_node_t * new_node, ptw32_mcs_local_node_t * old_node);
-#if defined(NEED_FTIME)
void ptw32_timespec_to_filetime (const struct timespec *ts, FILETIME * ft);
+
void ptw32_filetime_to_timespec (const FILETIME * ft, struct timespec *ts);
-#endif
-/* Declared in misc.c */
+/* Declared in pthw32_calloc.c */
#if defined(NEED_CALLOC)
#define calloc(n, s) ptw32_calloc(n, s)
void *ptw32_calloc (size_t n, size_t s);
#endif
-/* Declared in private.c */
-#if defined(_MSC_VER)
-/*
- * Ignore the warning:
- * "C++ exception specification ignored except to indicate that
- * the function is not __declspec(nothrow)."
- */
-#pragma warning(disable:4290)
-#endif
- void ptw32_throw (DWORD exception)
-#if defined(__CLEANUP_CXX)
- throw(ptw32_exception_cancel,ptw32_exception_exit)
-#endif
-;
-
-#if defined(__cplusplus)
-}
-#endif /* __cplusplus */
+/* Declared in ptw32_throw.c */
+void ptw32_throw (DWORD exception);
+__PTW32_END_C_DECLS
#if defined(_UWIN_)
# if defined(_MT)
-# if defined(__cplusplus)
-extern "C"
-{
-# endif
+
+__PTW32_BEGIN_C_DECLS
+
_CRTIMP unsigned long __cdecl _beginthread (void (__cdecl *) (void *),
unsigned, void *);
_CRTIMP void __cdecl _endthread (void);
@@ -705,13 +725,15 @@ extern "C"
unsigned (__stdcall *) (void *),
void *, unsigned, unsigned *);
_CRTIMP void __cdecl _endthreadex (unsigned);
-# if defined(__cplusplus)
-}
-# endif
+
+__PTW32_END_C_DECLS
+
# endif
#else
-# include <process.h>
+# if ! defined(WINCE)
+# include <process.h>
# endif
+#endif
/*
@@ -746,9 +768,15 @@ extern "C"
*
* The above aren't available in Mingw32 as of gcc 4.5.2 so define our own.
*/
+#if defined(__cplusplus)
+# define PTW32_TO_VLONG64PTR(ptr) reinterpret_cast<volatile LONG64 *>(ptr)
+#else
+# define PTW32_TO_VLONG64PTR(ptr) (ptr)
+#endif
+
#if defined(__GNUC__)
# if defined(_WIN64)
-# define PTW32_INTERLOCKED_COMPARE_EXCHANGE_64(location, value, comparand) \
+# define PTW32_INTERLOCKED_COMPARE_EXCHANGE_64(location, value, comparand) \
({ \
__typeof (value) _result; \
__asm__ __volatile__ \
@@ -785,7 +813,7 @@ extern "C"
})
# define PTW32_INTERLOCKED_INCREMENT_64(location) \
({ \
- PTW32_INTERLOCKED_LONG _temp = 1; \
+ PTW32_INTERLOCKED_LONG _temp = 1; \
__asm__ __volatile__ \
( \
"lock\n\t" \
@@ -797,7 +825,7 @@ extern "C"
})
# define PTW32_INTERLOCKED_DECREMENT_64(location) \
({ \
- PTW32_INTERLOCKED_LONG _temp = -1; \
+ PTW32_INTERLOCKED_LONG _temp = -1; \
__asm__ __volatile__ \
( \
"lock\n\t" \
@@ -808,7 +836,7 @@ extern "C"
--_temp; \
})
#endif
-# define PTW32_INTERLOCKED_COMPARE_EXCHANGE_LONG(location, value, comparand) \
+# define PTW32_INTERLOCKED_COMPARE_EXCHANGE_LONG(location, value, comparand) \
({ \
__typeof (value) _result; \
__asm__ __volatile__ \
@@ -845,7 +873,7 @@ extern "C"
})
# define PTW32_INTERLOCKED_INCREMENT_LONG(location) \
({ \
- PTW32_INTERLOCKED_LONG _temp = 1; \
+ PTW32_INTERLOCKED_LONG _temp = 1; \
__asm__ __volatile__ \
( \
"lock\n\t" \
@@ -857,7 +885,7 @@ extern "C"
})
# define PTW32_INTERLOCKED_DECREMENT_LONG(location) \
({ \
- PTW32_INTERLOCKED_LONG _temp = -1; \
+ PTW32_INTERLOCKED_LONG _temp = -1; \
__asm__ __volatile__ \
( \
"lock\n\t" \
@@ -876,48 +904,48 @@ extern "C"
(PTW32_INTERLOCKED_SIZE)value)
#else
# if defined(_WIN64)
-# define PTW32_INTERLOCKED_COMPARE_EXCHANGE_64 InterlockedCompareExchange64
-# define PTW32_INTERLOCKED_EXCHANGE_64 InterlockedExchange64
-# define PTW32_INTERLOCKED_EXCHANGE_ADD_64 InterlockedExchangeAdd64
-# define PTW32_INTERLOCKED_INCREMENT_64 InterlockedIncrement64
-# define PTW32_INTERLOCKED_DECREMENT_64 InterlockedDecrement64
+# define PTW32_INTERLOCKED_COMPARE_EXCHANGE_64(p,v,c) InterlockedCompareExchange64(PTW32_TO_VLONG64PTR(p),(v),(c))
+# define PTW32_INTERLOCKED_EXCHANGE_64(p,v) InterlockedExchange64(PTW32_TO_VLONG64PTR(p),(v))
+# define PTW32_INTERLOCKED_EXCHANGE_ADD_64(p,v) InterlockedExchangeAdd64(PTW32_TO_VLONG64PTR(p),(v))
+# define PTW32_INTERLOCKED_INCREMENT_64(p) InterlockedIncrement64(PTW32_TO_VLONG64PTR(p))
+# define PTW32_INTERLOCKED_DECREMENT_64(p) InterlockedDecrement64(PTW32_TO_VLONG64PTR(p))
# endif
-# if defined(_MSC_VER) && _MSC_VER < 1300 && !defined(_WIN64) /* MSVC 6 */
+# if defined(PTW32_CONFIG_MSVC6) && !defined(_WIN64)
# define PTW32_INTERLOCKED_COMPARE_EXCHANGE_LONG(location, value, comparand) \
((LONG)InterlockedCompareExchange((PVOID *)(location), (PVOID)(value), (PVOID)(comparand)))
# else
# define PTW32_INTERLOCKED_COMPARE_EXCHANGE_LONG InterlockedCompareExchange
# endif
-# define PTW32_INTERLOCKED_EXCHANGE_LONG InterlockedExchange
-# define PTW32_INTERLOCKED_EXCHANGE_ADD_LONG InterlockedExchangeAdd
-# define PTW32_INTERLOCKED_INCREMENT_LONG InterlockedIncrement
-# define PTW32_INTERLOCKED_DECREMENT_LONG InterlockedDecrement
-# if defined(_MSC_VER) && _MSC_VER < 1300 && !defined(_WIN64) /* MSVC 6 */
+# define PTW32_INTERLOCKED_EXCHANGE_LONG(p,v) InterlockedExchange((p),(v))
+# define PTW32_INTERLOCKED_EXCHANGE_ADD_LONG(p,v) InterlockedExchangeAdd((p),(v))
+# define PTW32_INTERLOCKED_INCREMENT_LONG(p) InterlockedIncrement((p))
+# define PTW32_INTERLOCKED_DECREMENT_LONG(p) InterlockedDecrement((p))
+# if defined(PTW32_CONFIG_MSVC6) && !defined(_WIN64)
# define PTW32_INTERLOCKED_COMPARE_EXCHANGE_PTR InterlockedCompareExchange
# define PTW32_INTERLOCKED_EXCHANGE_PTR(location, value) \
((PVOID)InterlockedExchange((LPLONG)(location), (LONG)(value)))
# else
-# define PTW32_INTERLOCKED_COMPARE_EXCHANGE_PTR InterlockedCompareExchangePointer
-# define PTW32_INTERLOCKED_EXCHANGE_PTR InterlockedExchangePointer
+# define PTW32_INTERLOCKED_COMPARE_EXCHANGE_PTR(p,v,c) InterlockedCompareExchangePointer((p),(v),(c))
+# define PTW32_INTERLOCKED_EXCHANGE_PTR(p,v) InterlockedExchangePointer((p),(v))
# endif
#endif
#if defined(_WIN64)
-# define PTW32_INTERLOCKED_COMPARE_EXCHANGE_SIZE PTW32_INTERLOCKED_COMPARE_EXCHANGE_64
-# define PTW32_INTERLOCKED_EXCHANGE_SIZE PTW32_INTERLOCKED_EXCHANGE_64
-# define PTW32_INTERLOCKED_EXCHANGE_ADD_SIZE PTW32_INTERLOCKED_EXCHANGE_ADD_64
-# define PTW32_INTERLOCKED_INCREMENT_SIZE PTW32_INTERLOCKED_INCREMENT_64
-# define PTW32_INTERLOCKED_DECREMENT_SIZE PTW32_INTERLOCKED_DECREMENT_64
+# define PTW32_INTERLOCKED_COMPARE_EXCHANGE_SIZE(p,v,c) PTW32_INTERLOCKED_COMPARE_EXCHANGE_64(PTW32_TO_VLONG64PTR(p),(v),(c))
+# define PTW32_INTERLOCKED_EXCHANGE_SIZE(p,v) PTW32_INTERLOCKED_EXCHANGE_64(PTW32_TO_VLONG64PTR(p),(v))
+# define PTW32_INTERLOCKED_EXCHANGE_ADD_SIZE(p,v) PTW32_INTERLOCKED_EXCHANGE_ADD_64(PTW32_TO_VLONG64PTR(p),(v))
+# define PTW32_INTERLOCKED_INCREMENT_SIZE(p) PTW32_INTERLOCKED_INCREMENT_64(PTW32_TO_VLONG64PTR(p))
+# define PTW32_INTERLOCKED_DECREMENT_SIZE(p) PTW32_INTERLOCKED_DECREMENT_64(PTW32_TO_VLONG64PTR(p))
#else
-# define PTW32_INTERLOCKED_COMPARE_EXCHANGE_SIZE PTW32_INTERLOCKED_COMPARE_EXCHANGE_LONG
-# define PTW32_INTERLOCKED_EXCHANGE_SIZE PTW32_INTERLOCKED_EXCHANGE_LONG
-# define PTW32_INTERLOCKED_EXCHANGE_ADD_SIZE PTW32_INTERLOCKED_EXCHANGE_ADD_LONG
-# define PTW32_INTERLOCKED_INCREMENT_SIZE PTW32_INTERLOCKED_INCREMENT_LONG
-# define PTW32_INTERLOCKED_DECREMENT_SIZE PTW32_INTERLOCKED_DECREMENT_LONG
+# define PTW32_INTERLOCKED_COMPARE_EXCHANGE_SIZE(p,v,c) PTW32_INTERLOCKED_COMPARE_EXCHANGE_LONG((p),(v),(c))
+# define PTW32_INTERLOCKED_EXCHANGE_SIZE(p,v) PTW32_INTERLOCKED_EXCHANGE_LONG((p),(v))
+# define PTW32_INTERLOCKED_EXCHANGE_ADD_SIZE(p,v) PTW32_INTERLOCKED_EXCHANGE_ADD_LONG((p),(v))
+# define PTW32_INTERLOCKED_INCREMENT_SIZE(p) PTW32_INTERLOCKED_INCREMENT_LONG((p))
+# define PTW32_INTERLOCKED_DECREMENT_SIZE(p) PTW32_INTERLOCKED_DECREMENT_LONG((p))
#endif
#if defined(NEED_CREATETHREAD)
-/*
+/*
* Macro uses args so we can cast start_proc to LPTHREAD_START_ROUTINE
* in order to avoid warnings because of return type
*/
diff --git a/libs/pthreads/src/misc.c b/libs/pthreads/src/misc.c
deleted file mode 100644
index 06d1d21374..0000000000
--- a/libs/pthreads/src/misc.c
+++ /dev/null
@@ -1,50 +0,0 @@
-/*
- * misc.c
- *
- * Description:
- * This translation unit implements miscellaneous thread functions.
- *
- * --------------------------------------------------------------------------
- *
- * Pthreads-win32 - POSIX Threads Library for Win32
- * Copyright(C) 1998 John E. Bossom
- * Copyright(C) 1999,2005 Pthreads-win32 contributors
- *
- * Contact Email: rpj@callisto.canberra.edu.au
- *
- * The current list of contributors is contained
- * in the file CONTRIBUTORS included with the source
- * code distribution. The list can also be seen at the
- * following World Wide Web location:
- * http://sources.redhat.com/pthreads-win32/contributors.html
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library in the file COPYING.LIB;
- * if not, write to the Free Software Foundation, Inc.,
- * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
- */
-
-#include "pthread.h"
-#include "implement.h"
-
-
-#include "pthread_kill.c"
-#include "pthread_once.c"
-#include "pthread_self.c"
-#include "pthread_equal.c"
-#include "pthread_setconcurrency.c"
-#include "pthread_getconcurrency.c"
-#include "ptw32_new.c"
-#include "ptw32_calloc.c"
-#include "ptw32_reuse.c"
-#include "w32_CancelableWait.c"
diff --git a/libs/pthreads/src/mutex.c b/libs/pthreads/src/mutex.c
deleted file mode 100644
index c2b3607ca2..0000000000
--- a/libs/pthreads/src/mutex.c
+++ /dev/null
@@ -1,62 +0,0 @@
-/*
- * mutex.c
- *
- * Description:
- * This translation unit implements mutual exclusion (mutex) primitives.
- *
- * --------------------------------------------------------------------------
- *
- * Pthreads-win32 - POSIX Threads Library for Win32
- * Copyright(C) 1998 John E. Bossom
- * Copyright(C) 1999,2005 Pthreads-win32 contributors
- *
- * Contact Email: rpj@callisto.canberra.edu.au
- *
- * The current list of contributors is contained
- * in the file CONTRIBUTORS included with the source
- * code distribution. The list can also be seen at the
- * following World Wide Web location:
- * http://sources.redhat.com/pthreads-win32/contributors.html
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library in the file COPYING.LIB;
- * if not, write to the Free Software Foundation, Inc.,
- * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
- */
-
-#if ! defined(_UWIN) && ! defined(WINCE)
-# include <process.h>
-#endif
-#if !defined(NEED_FTIME)
-#include <sys/timeb.h>
-#endif
-#include "pthread.h"
-#include "implement.h"
-
-
-#include "ptw32_mutex_check_need_init.c"
-#include "pthread_mutex_init.c"
-#include "pthread_mutex_destroy.c"
-#include "pthread_mutexattr_init.c"
-#include "pthread_mutexattr_destroy.c"
-#include "pthread_mutexattr_getpshared.c"
-#include "pthread_mutexattr_setpshared.c"
-#include "pthread_mutexattr_settype.c"
-#include "pthread_mutexattr_gettype.c"
-#include "pthread_mutexattr_setrobust.c"
-#include "pthread_mutexattr_getrobust.c"
-#include "pthread_mutex_lock.c"
-#include "pthread_mutex_timedlock.c"
-#include "pthread_mutex_unlock.c"
-#include "pthread_mutex_trylock.c"
-#include "pthread_mutex_consistent.c"
diff --git a/libs/pthreads/src/need_errno.h b/libs/pthreads/src/need_errno.h
index abf1c95574..7bef061438 100644
--- a/libs/pthreads/src/need_errno.h
+++ b/libs/pthreads/src/need_errno.h
@@ -24,7 +24,7 @@
#error ERROR: Only Win32 targets supported!
#endif
-#include <winsock.h>
+//#include <winsock.h>
#if defined(__cplusplus)
extern "C" {
@@ -59,15 +59,17 @@ extern "C" {
#endif
#endif
-#if !defined(PTW32_STATIC_LIB)
-# if defined(PTW32_BUILD)
+#if defined(PTW32_STATIC_LIB) && defined(_MSC_VER) && _MSC_VER >= 1400
+# define PTW32_STATIC_TLSLIB
+#endif
+
+#if defined(PTW32_STATIC_LIB) || defined(PTW32_STATIC_TLSLIB)
+# define PTW32_DLLPORT
+#elif defined(PTW32_BUILD)
# define PTW32_DLLPORT __declspec (dllexport)
# else
# define PTW32_DLLPORT __declspec (dllimport)
# endif
-#else
-# define PTW32_DLLPORT
-#endif
/* declare reference to errno */
@@ -114,27 +116,46 @@ _CRTIMP extern int errno;
#define ERANGE 34
#define EDEADLK 36
-/* defined differently in winsock.h on WinCE */
-#if !defined(ENAMETOOLONG)
-#define ENAMETOOLONG 38
-#endif
+/* defined differently in winsock.h on WinCE
+ * We don't use this value.
+ */
+//#if !defined(ENAMETOOLONG)
+//#define ENAMETOOLONG 38
+//#endif
#define ENOLCK 39
#define ENOSYS 40
-/* defined differently in winsock.h on WinCE */
-#if !defined(ENOTEMPTY)
-#define ENOTEMPTY 41
-#endif
+/* defined differently in winsock.h on WinCE
+ * We don't use this value.
+ */
+//#if !defined(ENOTEMPTY)
+//#define ENOTEMPTY 41
+//#endif
#define EILSEQ 42
-/* POSIX 2008 - robust mutexes */
-#define EOWNERDEAD 43
-#define ENOTRECOVERABLE 44
+/*
+ * POSIX 2008 - robust mutexes.
+ */
+#if PTW32_VERSION_MAJOR > 2
+# if !defined(EOWNERDEAD)
+# define EOWNERDEAD 1000
+# endif
+# if !defined(ENOTRECOVERABLE)
+# define ENOTRECOVERABLE 1001
+# endif
+#else
+# if !defined(EOWNERDEAD)
+# define EOWNERDEAD 42
+# endif
+# if !defined(ENOTRECOVERABLE)
+# define ENOTRECOVERABLE 43
+# endif
+#endif
/*
- * Support EDEADLOCK for compatibiity with older MS-C versions.
+ * Support EDEADLOCK for compatibility with older MS-C versions.
*/
#define EDEADLOCK EDEADLK
diff --git a/libs/pthreads/src/nonportable.c b/libs/pthreads/src/nonportable.c
deleted file mode 100644
index 742cb969b4..0000000000
--- a/libs/pthreads/src/nonportable.c
+++ /dev/null
@@ -1,47 +0,0 @@
-/*
- * nonportable.c
- *
- * Description:
- * This translation unit implements non-portable thread functions.
- *
- * --------------------------------------------------------------------------
- *
- * Pthreads-win32 - POSIX Threads Library for Win32
- * Copyright(C) 1998 John E. Bossom
- * Copyright(C) 1999,2005 Pthreads-win32 contributors
- *
- * Contact Email: rpj@callisto.canberra.edu.au
- *
- * The current list of contributors is contained
- * in the file CONTRIBUTORS included with the source
- * code distribution. The list can also be seen at the
- * following World Wide Web location:
- * http://sources.redhat.com/pthreads-win32/contributors.html
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library in the file COPYING.LIB;
- * if not, write to the Free Software Foundation, Inc.,
- * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
- */
-
-#include "pthread.h"
-#include "implement.h"
-
-#include "pthread_mutexattr_setkind_np.c"
-#include "pthread_mutexattr_getkind_np.c"
-#include "pthread_getw32threadhandle_np.c"
-#include "pthread_getunique_np.c"
-#include "pthread_delay_np.c"
-#include "pthread_num_processors_np.c"
-#include "pthread_win32_attach_detach_np.c"
-#include "pthread_timechange_handler_np.c"
diff --git a/libs/pthreads/src/private.c b/libs/pthreads/src/private.c
deleted file mode 100644
index 1b1ccb7c52..0000000000
--- a/libs/pthreads/src/private.c
+++ /dev/null
@@ -1,54 +0,0 @@
-/*
- * private.c
- *
- * Description:
- * This translation unit implements routines which are private to
- * the implementation and may be used throughout it.
- *
- * --------------------------------------------------------------------------
- *
- * Pthreads-win32 - POSIX Threads Library for Win32
- * Copyright(C) 1998 John E. Bossom
- * Copyright(C) 1999,2005 Pthreads-win32 contributors
- *
- * Contact Email: rpj@callisto.canberra.edu.au
- *
- * The current list of contributors is contained
- * in the file CONTRIBUTORS included with the source
- * code distribution. The list can also be seen at the
- * following World Wide Web location:
- * http://sources.redhat.com/pthreads-win32/contributors.html
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library in the file COPYING.LIB;
- * if not, write to the Free Software Foundation, Inc.,
- * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
- */
-
-#include "pthread.h"
-#include "implement.h"
-
-#include "ptw32_MCS_lock.c"
-#include "ptw32_is_attr.c"
-#include "ptw32_processInitialize.c"
-#include "ptw32_processTerminate.c"
-#include "ptw32_threadStart.c"
-#include "ptw32_threadDestroy.c"
-#include "ptw32_tkAssocCreate.c"
-#include "ptw32_tkAssocDestroy.c"
-#include "ptw32_callUserDestroyRoutines.c"
-#include "ptw32_semwait.c"
-#include "ptw32_timespec.c"
-#include "ptw32_relmillisecs.c"
-#include "ptw32_throw.c"
-#include "ptw32_getprocessors.c"
diff --git a/libs/pthreads/src/pthread.c b/libs/pthreads/src/pthread.c
index 60b53412be..de1770dfaf 100644
--- a/libs/pthreads/src/pthread.c
+++ b/libs/pthreads/src/pthread.c
@@ -2,65 +2,189 @@
* pthread.c
*
* Description:
- * This translation unit agregates pthreads-win32 translation units.
+ * This translation unit agregates Pthreads4w translation units.
* It is used for inline optimisation of the library,
* maximising for speed at the expense of size.
*
* --------------------------------------------------------------------------
*
- * Pthreads-win32 - POSIX Threads Library for Win32
+ * Pthreads4w - POSIX Threads Library for Win32
* Copyright(C) 1998 John E. Bossom
- * Copyright(C) 1999,2005 Pthreads-win32 contributors
- *
- * Contact Email: rpj@callisto.canberra.edu.au
- *
+ * Copyright(C) 1999-2018, Pthreads4w contributors
+ *
+ * Homepage: https://sourceforge.net/projects/pthreads4w/
+ *
* The current list of contributors is contained
* in the file CONTRIBUTORS included with the source
* code distribution. The list can also be seen at the
* following World Wide Web location:
- * http://sources.redhat.com/pthreads-win32/contributors.html
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library in the file COPYING.LIB;
- * if not, write to the Free Software Foundation, Inc.,
- * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
+ * https://sourceforge.net/p/pthreads4w/wiki/Contributors/
+ *
+ * This file is part of Pthreads4w.
+ *
+ * Pthreads4w is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * Pthreads4w is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Pthreads4w. If not, see <http://www.gnu.org/licenses/>. *
*/
+#include "config.h"
+
#include "pthread.h"
#include "implement.h"
/* The following are ordered for inlining */
-#include "private.c"
-#include "attr.c"
-#include "barrier.c"
-#include "cancel.c"
-#include "cleanup.c"
-#include "condvar.c"
+#include "ptw32_MCS_lock.c"
+#include "ptw32_is_attr.c"
+#include "ptw32_processInitialize.c"
+#include "ptw32_processTerminate.c"
+#include "ptw32_threadStart.c"
+#include "ptw32_threadDestroy.c"
+#include "ptw32_tkAssocCreate.c"
+#include "ptw32_tkAssocDestroy.c"
+#include "ptw32_callUserDestroyRoutines.c"
+#include "ptw32_semwait.c"
+#include "ptw32_timespec.c"
+#include "ptw32_throw.c"
+#include "ptw32_getprocessors.c"
+#include "ptw32_calloc.c"
+#include "ptw32_new.c"
+#include "ptw32_reuse.c"
+#include "ptw32_relmillisecs.c"
+#include "ptw32_cond_check_need_init.c"
+#include "ptw32_mutex_check_need_init.c"
+#include "ptw32_rwlock_check_need_init.c"
+#include "ptw32_rwlock_cancelwrwait.c"
+#include "ptw32_spinlock_check_need_init.c"
+#include "pthread_attr_init.c"
+#include "pthread_attr_destroy.c"
+#include "pthread_attr_getaffinity_np.c"
+#include "pthread_attr_setaffinity_np.c"
+#include "pthread_attr_getdetachstate.c"
+#include "pthread_attr_setdetachstate.c"
+#include "pthread_attr_getname_np.c"
+#include "pthread_attr_setname_np.c"
+#include "pthread_attr_getscope.c"
+#include "pthread_attr_setscope.c"
+#include "pthread_attr_getstackaddr.c"
+#include "pthread_attr_setstackaddr.c"
+#include "pthread_attr_getstacksize.c"
+#include "pthread_attr_setstacksize.c"
+#include "pthread_barrier_init.c"
+#include "pthread_barrier_destroy.c"
+#include "pthread_barrier_wait.c"
+#include "pthread_barrierattr_init.c"
+#include "pthread_barrierattr_destroy.c"
+#include "pthread_barrierattr_setpshared.c"
+#include "pthread_barrierattr_getpshared.c"
+#include "pthread_setcancelstate.c"
+#include "pthread_setcanceltype.c"
+#include "pthread_testcancel.c"
+#include "pthread_cancel.c"
+#include "pthread_condattr_destroy.c"
+#include "pthread_condattr_getpshared.c"
+#include "pthread_condattr_init.c"
+#include "pthread_condattr_setpshared.c"
+#include "pthread_cond_destroy.c"
+#include "pthread_cond_init.c"
+#include "pthread_cond_signal.c"
+#include "pthread_cond_wait.c"
#include "create.c"
+#include "cleanup.c"
#include "dll.c"
-#include "autostatic.c"
#include "errno.c"
-#include "exit.c"
-#include "fork.c"
+#include "pthread_exit.c"
#include "global.c"
-#include "misc.c"
-#include "mutex.c"
-#include "nonportable.c"
-#include "rwlock.c"
-#include "sched.c"
-#include "semaphore.c"
-#include "signal.c"
-#include "spin.c"
-#include "sync.c"
-#include "tsd.c"
+#include "pthread_equal.c"
+#include "pthread_getconcurrency.c"
+#include "pthread_kill.c"
+#include "pthread_once.c"
+#include "pthread_self.c"
+#include "pthread_setconcurrency.c"
+#include "w32_CancelableWait.c"
+#include "pthread_mutex_init.c"
+#include "pthread_mutex_destroy.c"
+#include "pthread_mutexattr_init.c"
+#include "pthread_mutexattr_destroy.c"
+#include "pthread_mutexattr_getpshared.c"
+#include "pthread_mutexattr_setpshared.c"
+#include "pthread_mutexattr_settype.c"
+#include "pthread_mutexattr_gettype.c"
+#include "pthread_mutexattr_setrobust.c"
+#include "pthread_mutexattr_getrobust.c"
+#include "pthread_mutex_lock.c"
+#include "pthread_mutex_timedlock.c"
+#include "pthread_mutex_unlock.c"
+#include "pthread_mutex_trylock.c"
+#include "pthread_mutex_consistent.c"
+#include "pthread_mutexattr_setkind_np.c"
+#include "pthread_mutexattr_getkind_np.c"
+#include "pthread_getw32threadhandle_np.c"
+#include "pthread_getunique_np.c"
+#include "pthread_timedjoin_np.c"
+#include "pthread_tryjoin_np.c"
+#include "pthread_setaffinity.c"
+#include "pthread_delay_np.c"
+#include "pthread_num_processors_np.c"
+#include "pthread_win32_attach_detach_np.c"
+#include "pthread_timechange_handler_np.c"
+#include "pthread_rwlock_init.c"
+#include "pthread_rwlock_destroy.c"
+#include "pthread_rwlockattr_init.c"
+#include "pthread_rwlockattr_destroy.c"
+#include "pthread_rwlockattr_getpshared.c"
+#include "pthread_rwlockattr_setpshared.c"
+#include "pthread_rwlock_rdlock.c"
+#include "pthread_rwlock_timedrdlock.c"
+#include "pthread_rwlock_wrlock.c"
+#include "pthread_rwlock_timedwrlock.c"
+#include "pthread_rwlock_unlock.c"
+#include "pthread_rwlock_tryrdlock.c"
+#include "pthread_rwlock_trywrlock.c"
+#include "pthread_attr_setschedpolicy.c"
+#include "pthread_attr_getschedpolicy.c"
+#include "pthread_attr_setschedparam.c"
+#include "pthread_attr_getschedparam.c"
+#include "pthread_attr_setinheritsched.c"
+#include "pthread_attr_getinheritsched.c"
+#include "pthread_setschedparam.c"
+#include "pthread_getschedparam.c"
+#include "sched_get_priority_max.c"
+#include "sched_get_priority_min.c"
+#include "sched_setscheduler.c"
+#include "sched_getscheduler.c"
+#include "sched_yield.c"
+#include "sched_setaffinity.c"
+#include "sem_init.c"
+#include "sem_destroy.c"
+#include "sem_trywait.c"
+#include "sem_timedwait.c"
+#include "sem_wait.c"
+#include "sem_post.c"
+#include "sem_post_multiple.c"
+#include "sem_getvalue.c"
+#include "sem_open.c"
+#include "sem_close.c"
+#include "sem_unlink.c"
+#include "pthread_spin_init.c"
+#include "pthread_spin_destroy.c"
+#include "pthread_spin_lock.c"
+#include "pthread_spin_unlock.c"
+#include "pthread_spin_trylock.c"
+#include "pthread_detach.c"
+#include "pthread_join.c"
+#include "pthread_key_create.c"
+#include "pthread_key_delete.c"
+#include "pthread_getname_np.c"
+#include "pthread_setname_np.c"
+#include "pthread_setspecific.c"
+#include "pthread_getspecific.c"
diff --git a/libs/pthreads/src/pthread.h b/libs/pthreads/src/pthread.h
index 32ff72bb54..2d96d90177 100644
--- a/libs/pthreads/src/pthread.h
+++ b/libs/pthreads/src/pthread.h
@@ -1,45 +1,38 @@
-/* This is an implementation of the threads API of POSIX 1003.1-2001.
+/* This is an implementation of the threads API of the Single Unix Specification.
*
* --------------------------------------------------------------------------
*
- * Pthreads-win32 - POSIX Threads Library for Win32
+ * Pthreads4w - POSIX Threads Library for Win32
* Copyright(C) 1998 John E. Bossom
- * Copyright(C) 1999,2005 Pthreads-win32 contributors
- *
- * Contact Email: rpj@callisto.canberra.edu.au
- *
+ * Copyright(C) 1999-2018, Pthreads4w contributors
+ *
+ * Homepage: https://sourceforge.net/projects/pthreads4w/
+ *
* The current list of contributors is contained
* in the file CONTRIBUTORS included with the source
* code distribution. The list can also be seen at the
* following World Wide Web location:
- * http://sources.redhat.com/pthreads-win32/contributors.html
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library in the file COPYING.LIB;
- * if not, write to the Free Software Foundation, Inc.,
- * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
+ * https://sourceforge.net/p/pthreads4w/wiki/Contributors/
+ *
+ * This file is part of Pthreads4w.
+ *
+ * Pthreads4w is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * Pthreads4w is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Pthreads4w. If not, see <http://www.gnu.org/licenses/>. *
*/
#if !defined( PTHREAD_H )
#define PTHREAD_H
-/*
- * See the README file for an explanation of the pthreads-win32 version
- * numbering scheme and how the DLL is named etc.
- */
-#define PTW32_VERSION 2,9,1,0
-#define PTW32_VERSION_STRING "2, 9, 1, 0\0"
-
/* There are three implementations of cancel cleanup.
* Note that pthread.h is included in both application
* compilation units and also internally for the library.
@@ -65,7 +58,7 @@
* Define defaults for cleanup code.
* Note: Unless the build explicitly defines one of the following, then
* we default to standard C style cleanup. This style uses setjmp/longjmp
- * in the cancelation and thread exit implementations and therefore won't
+ * in the cancellation and thread exit implementations and therefore won't
* do stack unwinding if linked to applications that have it (e.g.
* C++ apps). This is currently consistent with most/all commercial Unix
* POSIX threads implementations.
@@ -78,42 +71,31 @@
#error ERROR [__FILE__, line __LINE__]: SEH is not supported for this compiler.
#endif
+#include <_ptw32.h>
+
/*
* Stop here if we are being included by the resource compiler.
*/
#if !defined(RC_INVOKED)
-#undef PTW32_LEVEL
+#undef __PTW32_LEVEL
+#undef __PTW32_LEVEL_MAX
+#define __PTW32_LEVEL_MAX 3
-#if defined(_POSIX_SOURCE)
-#define PTW32_LEVEL 0
-/* Early POSIX */
-#endif
+#if _POSIX_C_SOURCE >= 200112L /* POSIX.1-2001 and later */
+# define __PTW32_LEVEL __PTW32_LEVEL_MAX /* include everything */
-#if defined(_POSIX_C_SOURCE) && _POSIX_C_SOURCE >= 199309
-#undef PTW32_LEVEL
-#define PTW32_LEVEL 1
-/* Include 1b, 1c and 1d */
-#endif
+#elif defined INCLUDE_NP /* earlier than POSIX.1-2001, but... */
+# define __PTW32_LEVEL 2 /* include non-portable extensions */
-#if defined(INCLUDE_NP)
-#undef PTW32_LEVEL
-#define PTW32_LEVEL 2
-/* Include Non-Portable extensions */
-#endif
+#elif _POSIX_C_SOURCE >= 199309L /* POSIX.1-1993 */
+# define __PTW32_LEVEL 1 /* include 1b, 1c, and 1d */
-#define PTW32_LEVEL_MAX 3
-
-#if ( defined(_POSIX_C_SOURCE) && _POSIX_C_SOURCE >= 200112 ) || !defined(PTW32_LEVEL)
-#define PTW32_LEVEL PTW32_LEVEL_MAX
-/* Include everything */
-#endif
+#elif defined _POSIX_SOURCE /* early POSIX */
+# define __PTW32_LEVEL 0 /* minimal support */
-#if defined(_UWIN)
-# define HAVE_STRUCT_TIMESPEC 1
-# define HAVE_SIGNAL_H 1
-# undef HAVE_PTW32_CONFIG_H
-# pragma comment(lib, "pthread")
+#else /* unspecified support level */
+# define __PTW32_LEVEL __PTW32_LEVEL_MAX /* include everything anyway */
#endif
/*
@@ -184,191 +166,47 @@
* The source code and other information about this library
* are available from
*
- * http://sources.redhat.com/pthreads-win32/
+ * https://sourceforge.net/projects/pthreads4w//
*
* -------------------------------------------------------------
*/
-
-/* Try to avoid including windows.h */
-#if (defined(__MINGW64__) || defined(__MINGW32__)) && defined(__cplusplus)
-#define PTW32_INCLUDE_WINDOWS_H
-#endif
-
-#if defined(PTW32_INCLUDE_WINDOWS_H)
-#include <windows.h>
-#endif
-
-#if defined(_MSC_VER) && _MSC_VER < 1300 || defined(__DMC__)
-/*
- * VC++6.0 or early compiler's header has no DWORD_PTR type.
- */
-typedef unsigned long DWORD_PTR;
-typedef unsigned long ULONG_PTR;
-#endif
-/*
- * -----------------
- * autoconf switches
- * -----------------
- */
-
-#if defined(HAVE_PTW32_CONFIG_H)
-#include "config.h"
-#endif /* HAVE_PTW32_CONFIG_H */
-
-#if !defined(NEED_FTIME)
-#include <time.h>
-#else /* NEED_FTIME */
-/* use native WIN32 time API */
-#endif /* NEED_FTIME */
-
-#if defined(HAVE_SIGNAL_H)
-#include <signal.h>
-#endif /* HAVE_SIGNAL_H */
-
-#include <limits.h>
-
-/*
- * Boolean values to make us independent of system includes.
- */
-enum {
+enum
+{ /* Boolean values to make us independent of system includes. */
PTW32_FALSE = 0,
PTW32_TRUE = (! PTW32_FALSE)
};
-/*
- * This is a duplicate of what is in the autoconf config.h,
- * which is only used when building the pthread-win32 libraries.
- */
-
-#if !defined(PTW32_CONFIG_H)
-# if defined(WINCE)
-# define NEED_ERRNO
-# define NEED_SEM
-# endif
-# if defined(_MSC_VER) || defined(__MINGW64__)
-# define HAVE_STRUCT_TIMESPEC
-# define HAVE_MODE_T
-# elif defined(_UWIN) || defined(__MINGW32__)
-# define HAVE_MODE_T
-# endif
-#endif
-
-/*
- *
- */
-
-#if PTW32_LEVEL >= PTW32_LEVEL_MAX
-#if defined(NEED_ERRNO)
-#include "need_errno.h"
-#else
-#include <errno.h>
-#endif
-#endif /* PTW32_LEVEL >= PTW32_LEVEL_MAX */
-
-/*
- * Several systems don't define some error numbers.
- */
-#if !defined(ENOTSUP)
-# define ENOTSUP 48 /* This is the value in Solaris. */
-#endif
-
-#if !defined(ETIMEDOUT)
-# define ETIMEDOUT 10060 /* Same as WSAETIMEDOUT */
-#endif
-
-#if !defined(ENOSYS)
-# define ENOSYS 140 /* Semi-arbitrary value */
-#endif
-
-#if !defined(EDEADLK)
-# if defined(EDEADLOCK)
-# define EDEADLK EDEADLOCK
-# else
-# define EDEADLK 36 /* This is the value in MSVC. */
-# endif
-#endif
-
-/* POSIX 2008 - related to robust mutexes */
-#if !defined(EOWNERDEAD)
-# define EOWNERDEAD 43
-#endif
-#if !defined(ENOTRECOVERABLE)
-# define ENOTRECOVERABLE 44
-#endif
-
+#include <time.h>
#include <sched.h>
/*
- * To avoid including windows.h we define only those things that we
- * actually need from it.
- */
-#if !defined(PTW32_INCLUDE_WINDOWS_H)
-#if !defined(HANDLE)
-# define PTW32__HANDLE_DEF
-# define HANDLE void *
-#endif
-#if !defined(DWORD)
-# define PTW32__DWORD_DEF
-# define DWORD unsigned long
-#endif
-#endif
-
-#if !defined(HAVE_STRUCT_TIMESPEC)
-#define HAVE_STRUCT_TIMESPEC
-#if !defined(_TIMESPEC_DEFINED)
-#define _TIMESPEC_DEFINED
-struct timespec {
- time_t tv_sec;
- long tv_nsec;
-};
-#endif /* _TIMESPEC_DEFINED */
-#endif /* HAVE_STRUCT_TIMESPEC */
-
-#if !defined(SIG_BLOCK)
-#define SIG_BLOCK 0
-#endif /* SIG_BLOCK */
-
-#if !defined(SIG_UNBLOCK)
-#define SIG_UNBLOCK 1
-#endif /* SIG_UNBLOCK */
-
-#if !defined(SIG_SETMASK)
-#define SIG_SETMASK 2
-#endif /* SIG_SETMASK */
-
-#if defined(__cplusplus)
-extern "C"
-{
-#endif /* __cplusplus */
-
-/*
* -------------------------------------------------------------
*
* POSIX 1003.1-2001 Options
* =========================
*
* Options are normally set in <unistd.h>, which is not provided
- * with pthreads-win32.
+ * with Pthreads4w.
*
* For conformance with the Single Unix Specification (version 3), all of the
* options below are defined, and have a value of either -1 (not supported)
- * or 200112L (supported).
+ * or yyyymm[dd]L (supported).
*
* These options can neither be left undefined nor have a value of 0, because
* either indicates that sysconf(), which is not implemented, may be used at
* runtime to check the status of the option.
*
- * _POSIX_THREADS (== 200112L)
- * If == 200112L, you can use threads
+ * _POSIX_THREADS (== 20080912L)
+ * If == 20080912L, you can use threads
*
- * _POSIX_THREAD_ATTR_STACKSIZE (== 200112L)
- * If == 200112L, you can control the size of a thread's
+ * _POSIX_THREAD_ATTR_STACKSIZE (== 200809L)
+ * If == 200809L, you can control the size of a thread's
* stack
* pthread_attr_getstacksize
* pthread_attr_setstacksize
*
* _POSIX_THREAD_ATTR_STACKADDR (== -1)
- * If == 200112L, you can allocate and control a thread's
+ * If == 200809L, you can allocate and control a thread's
* stack. If not supported, the following functions
* will return ENOSYS, indicating they are not
* supported:
@@ -383,13 +221,13 @@ extern "C"
* writers over readers when threads have equal priority.
*
* _POSIX_THREAD_PRIO_INHERIT (== -1)
- * If == 200112L, you can create priority inheritance
+ * If == 200809L, you can create priority inheritance
* mutexes.
* pthread_mutexattr_getprotocol +
* pthread_mutexattr_setprotocol +
*
* _POSIX_THREAD_PRIO_PROTECT (== -1)
- * If == 200112L, you can create priority ceiling mutexes
+ * If == 200809L, you can create priority ceiling mutexes
* Indicates the availability of:
* pthread_mutex_getprioceiling
* pthread_mutex_setprioceiling
@@ -408,22 +246,24 @@ extern "C"
* pthread_condattr_getpshared
* pthread_condattr_setpshared
*
- * _POSIX_THREAD_SAFE_FUNCTIONS (== 200112L)
- * If == 200112L you can use the special *_r library
+ * _POSIX_THREAD_SAFE_FUNCTIONS (== 200809L)
+ * If == 200809L you can use the special *_r library
* functions that provide thread-safe behaviour
*
- * _POSIX_READER_WRITER_LOCKS (== 200112L)
- * If == 200112L, you can use read/write locks
+ * _POSIX_READER_WRITER_LOCKS (== 200809L)
+ * If == 200809L, you can use read/write locks
*
- * _POSIX_SPIN_LOCKS (== 200112L)
- * If == 200112L, you can use spin locks
+ * _POSIX_SPIN_LOCKS (== 200809L)
+ * If == 200809L, you can use spin locks
*
- * _POSIX_BARRIERS (== 200112L)
- * If == 200112L, you can use barriers
+ * _POSIX_BARRIERS (== 200809L)
+ * If == 200809L, you can use barriers
*
- * + These functions provide both 'inherit' and/or
- * 'protect' protocol, based upon these macro
- * settings.
+ * _POSIX_ROBUST_MUTEXES (== 200809L)
+ * If == 200809L, you can use robust mutexes
+ * Officially this should also imply
+ * _POSIX_THREAD_PROCESS_SHARED != -1 however
+ * not here yet.
*
* -------------------------------------------------------------
*/
@@ -431,42 +271,45 @@ extern "C"
/*
* POSIX Options
*/
-#undef _POSIX_THREADS
-#define _POSIX_THREADS 200809L
+#undef _POSIX_THREADS
+#define _POSIX_THREADS 200809L
+
+#undef _POSIX_READER_WRITER_LOCKS
+#define _POSIX_READER_WRITER_LOCKS 200809L
-#undef _POSIX_READER_WRITER_LOCKS
-#define _POSIX_READER_WRITER_LOCKS 200809L
+#undef _POSIX_SPIN_LOCKS
+#define _POSIX_SPIN_LOCKS 200809L
-#undef _POSIX_SPIN_LOCKS
-#define _POSIX_SPIN_LOCKS 200809L
+#undef _POSIX_BARRIERS
+#define _POSIX_BARRIERS 200809L
-#undef _POSIX_BARRIERS
-#define _POSIX_BARRIERS 200809L
+#undef _POSIX_THREAD_SAFE_FUNCTIONS
+#define _POSIX_THREAD_SAFE_FUNCTIONS 200809L
-#undef _POSIX_THREAD_SAFE_FUNCTIONS
-#define _POSIX_THREAD_SAFE_FUNCTIONS 200809L
+#undef _POSIX_THREAD_ATTR_STACKSIZE
+#define _POSIX_THREAD_ATTR_STACKSIZE 200809L
-#undef _POSIX_THREAD_ATTR_STACKSIZE
-#define _POSIX_THREAD_ATTR_STACKSIZE 200809L
+#undef _POSIX_ROBUST_MUTEXES
+#define _POSIX_ROBUST_MUTEXES 200809L
/*
* The following options are not supported
*/
-#undef _POSIX_THREAD_ATTR_STACKADDR
-#define _POSIX_THREAD_ATTR_STACKADDR -1
+#undef _POSIX_THREAD_ATTR_STACKADDR
+#define _POSIX_THREAD_ATTR_STACKADDR -1
-#undef _POSIX_THREAD_PRIO_INHERIT
-#define _POSIX_THREAD_PRIO_INHERIT -1
+#undef _POSIX_THREAD_PRIO_INHERIT
+#define _POSIX_THREAD_PRIO_INHERIT -1
-#undef _POSIX_THREAD_PRIO_PROTECT
-#define _POSIX_THREAD_PRIO_PROTECT -1
+#undef _POSIX_THREAD_PRIO_PROTECT
+#define _POSIX_THREAD_PRIO_PROTECT -1
/* TPS is not fully supported. */
-#undef _POSIX_THREAD_PRIORITY_SCHEDULING
-#define _POSIX_THREAD_PRIORITY_SCHEDULING -1
+#undef _POSIX_THREAD_PRIORITY_SCHEDULING
+#define _POSIX_THREAD_PRIORITY_SCHEDULING -1
-#undef _POSIX_THREAD_PROCESS_SHARED
-#define _POSIX_THREAD_PROCESS_SHARED -1
+#undef _POSIX_THREAD_PROCESS_SHARED
+#define _POSIX_THREAD_PROCESS_SHARED -1
/*
@@ -474,7 +317,7 @@ extern "C"
* ===========================
*
* These limits are normally set in <limits.h>, which is not provided with
- * pthreads-win32.
+ * Pthreads4w.
*
* PTHREAD_DESTRUCTOR_ITERATIONS
* Maximum number of attempts to destroy
@@ -501,85 +344,64 @@ extern "C"
* (must be at least 32767)
*
*/
-#undef _POSIX_THREAD_DESTRUCTOR_ITERATIONS
+#undef _POSIX_THREAD_DESTRUCTOR_ITERATIONS
#define _POSIX_THREAD_DESTRUCTOR_ITERATIONS 4
-#undef PTHREAD_DESTRUCTOR_ITERATIONS
+#undef PTHREAD_DESTRUCTOR_ITERATIONS
#define PTHREAD_DESTRUCTOR_ITERATIONS _POSIX_THREAD_DESTRUCTOR_ITERATIONS
-#undef _POSIX_THREAD_KEYS_MAX
+#undef _POSIX_THREAD_KEYS_MAX
#define _POSIX_THREAD_KEYS_MAX 128
-#undef PTHREAD_KEYS_MAX
+#undef PTHREAD_KEYS_MAX
#define PTHREAD_KEYS_MAX _POSIX_THREAD_KEYS_MAX
-#undef PTHREAD_STACK_MIN
+#undef PTHREAD_STACK_MIN
#define PTHREAD_STACK_MIN 0
-#undef _POSIX_THREAD_THREADS_MAX
+#undef _POSIX_THREAD_THREADS_MAX
#define _POSIX_THREAD_THREADS_MAX 64
- /* Arbitrary value */
-#undef PTHREAD_THREADS_MAX
+/* Arbitrary value */
+#undef PTHREAD_THREADS_MAX
#define PTHREAD_THREADS_MAX 2019
-#undef _POSIX_SEM_NSEMS_MAX
+#undef _POSIX_SEM_NSEMS_MAX
#define _POSIX_SEM_NSEMS_MAX 256
- /* Arbitrary value */
-#undef SEM_NSEMS_MAX
+/* Arbitrary value */
+#undef SEM_NSEMS_MAX
#define SEM_NSEMS_MAX 1024
-#undef _POSIX_SEM_VALUE_MAX
+#undef _POSIX_SEM_VALUE_MAX
#define _POSIX_SEM_VALUE_MAX 32767
-#undef SEM_VALUE_MAX
+#undef SEM_VALUE_MAX
#define SEM_VALUE_MAX INT_MAX
-#if defined(__GNUC__) && !defined(__declspec)
-# error Please upgrade your GNU compiler to one that supports __declspec.
-#endif
-
-/*
- * When building the library, you should define PTW32_BUILD so that
- * the variables/functions are exported correctly. When using the library,
- * do NOT define PTW32_BUILD, and then the variables/functions will
- * be imported correctly.
- */
-#if !defined(PTW32_STATIC_LIB)
-# if defined(PTW32_BUILD)
-# define PTW32_DLLPORT __declspec (dllexport)
-# else
-# define PTW32_DLLPORT __declspec (dllimport)
-# endif
+#if defined(_UWIN) && __PTW32_LEVEL >= __PTW32_LEVEL_MAX
+# include <sys/types.h>
#else
-# define PTW32_DLLPORT
-#endif
-
-/*
- * The Open Watcom C/C++ compiler uses a non-standard calling convention
- * that passes function args in registers unless __cdecl is explicitly specified
- * in exposed function prototypes.
+/* Generic handle type - intended to provide the lifetime-uniqueness that
+ * a simple pointer can't. It should scale for either
+ * 32 or 64 bit systems.
+ *
+ * The constraint with this approach is that applications must
+ * strictly comply with POSIX, e.g. not assume scalar type, only
+ * compare pthread_t using the API function pthread_equal(), etc.
*
- * We force all calls to cdecl even though this could slow Watcom code down
- * slightly. If you know that the Watcom compiler will be used to build both
- * the DLL and application, then you can probably define this as a null string.
- * Remember that pthread.h (this file) is used for both the DLL and application builds.
+ * Applications can use the element 'p' to compare, e.g. for sorting,
+ * but it will be up to the application to determine if handles are
+ * live or dead, or resurrected for an entirely new/different thread.
*/
-#define PTW32_CDECL __cdecl
-
-#if defined(_UWIN) && PTW32_LEVEL >= PTW32_LEVEL_MAX
-# include <sys/types.h>
+typedef struct
+{ void * p; /* Pointer to actual object */
+#if PTW32_VERSION_MAJOR > 2
+ size_t x; /* Extra information - reuse count etc */
#else
-/*
- * Generic handle type - intended to extend uniqueness beyond
- * that available with a simple pointer. It should scale for either
- * IA-32 or IA-64.
- */
-typedef struct {
- void * p; /* Pointer to actual object */
- unsigned int x; /* Extra information - reuse count etc */
+ unsigned int x; /* Extra information - reuse count etc */
+#endif
} ptw32_handle_t;
typedef ptw32_handle_t pthread_t;
@@ -591,6 +413,7 @@ typedef struct pthread_mutexattr_t_ * pthread_mutexattr_t;
typedef struct pthread_cond_t_ * pthread_cond_t;
typedef struct pthread_condattr_t_ * pthread_condattr_t;
#endif
+
typedef struct pthread_rwlock_t_ * pthread_rwlock_t;
typedef struct pthread_rwlockattr_t_ * pthread_rwlockattr_t;
typedef struct pthread_spinlock_t_ * pthread_spinlock_t;
@@ -605,60 +428,52 @@ typedef struct pthread_barrierattr_t_ * pthread_barrierattr_t;
* ====================
*/
-enum {
-/*
- * pthread_attr_{get,set}detachstate
- */
+enum
+{ /* pthread_attr_{get,set}detachstate
+ */
PTHREAD_CREATE_JOINABLE = 0, /* Default */
PTHREAD_CREATE_DETACHED = 1,
-
-/*
- * pthread_attr_{get,set}inheritsched
- */
+ /*
+ * pthread_attr_{get,set}inheritsched
+ */
PTHREAD_INHERIT_SCHED = 0,
PTHREAD_EXPLICIT_SCHED = 1, /* Default */
-
-/*
- * pthread_{get,set}scope
- */
+ /*
+ * pthread_{get,set}scope
+ */
PTHREAD_SCOPE_PROCESS = 0,
PTHREAD_SCOPE_SYSTEM = 1, /* Default */
-
-/*
- * pthread_setcancelstate paramters
- */
+ /*
+ * pthread_setcancelstate paramters
+ */
PTHREAD_CANCEL_ENABLE = 0, /* Default */
PTHREAD_CANCEL_DISABLE = 1,
-
-/*
- * pthread_setcanceltype parameters
- */
+ /*
+ * pthread_setcanceltype parameters
+ */
PTHREAD_CANCEL_ASYNCHRONOUS = 0,
PTHREAD_CANCEL_DEFERRED = 1, /* Default */
-
-/*
- * pthread_mutexattr_{get,set}pshared
- * pthread_condattr_{get,set}pshared
- */
+ /*
+ * pthread_mutexattr_{get,set}pshared
+ * pthread_condattr_{get,set}pshared
+ */
PTHREAD_PROCESS_PRIVATE = 0,
PTHREAD_PROCESS_SHARED = 1,
-
-/*
- * pthread_mutexattr_{get,set}robust
- */
+ /*
+ * pthread_mutexattr_{get,set}robust
+ */
PTHREAD_MUTEX_STALLED = 0, /* Default */
PTHREAD_MUTEX_ROBUST = 1,
-
-/*
- * pthread_barrier_wait
- */
+ /*
+ * pthread_barrier_wait
+ */
PTHREAD_BARRIER_SERIAL_THREAD = -1
};
/*
* ====================
* ====================
- * Cancelation
+ * cancellation
* ====================
* ====================
*/
@@ -672,16 +487,30 @@ enum {
* ====================
* ====================
*/
-#define PTHREAD_ONCE_INIT { PTW32_FALSE, 0, 0, 0}
+#if PTW32_VERSION_MAJOR > 2
+
+#define PTHREAD_ONCE_INIT { 0, PTW32_FALSE }
struct pthread_once_t_
{
- int done; /* indicates if user function has been executed */
- void * lock;
+ void * lock; /* MCS lock */
+ int done; /* indicates if user function has been executed */
+};
+
+#else
+
+#define PTHREAD_ONCE_INIT { PTW32_FALSE, 0, 0, 0 }
+
+struct pthread_once_t_
+{
+ int done; /* indicates if user function has been executed */
+ void * lock; /* MCS lock */
int reserved1;
int reserved2;
};
+#endif
+
/*
* ====================
@@ -877,6 +706,7 @@ struct ptw32_cleanup_t
#endif /* __CLEANUP_SEH */
+
/*
* ===============
* ===============
@@ -885,6 +715,8 @@ struct ptw32_cleanup_t
* ===============
*/
+__PTW32_BEGIN_C_DECLS
+
/*
* PThread Attribute Functions
*/
@@ -892,6 +724,10 @@ PTW32_DLLPORT int PTW32_CDECL pthread_attr_init (pthread_attr_t * attr);
PTW32_DLLPORT int PTW32_CDECL pthread_attr_destroy (pthread_attr_t * attr);
+PTW32_DLLPORT int PTW32_CDECL pthread_attr_getaffinity_np (const pthread_attr_t * attr,
+ size_t cpusetsize,
+ cpu_set_t * cpuset);
+
PTW32_DLLPORT int PTW32_CDECL pthread_attr_getdetachstate (const pthread_attr_t * attr,
int *detachstate);
@@ -901,6 +737,10 @@ PTW32_DLLPORT int PTW32_CDECL pthread_attr_getstackaddr (const pthread_attr_t *
PTW32_DLLPORT int PTW32_CDECL pthread_attr_getstacksize (const pthread_attr_t * attr,
size_t * stacksize);
+PTW32_DLLPORT int PTW32_CDECL pthread_attr_setaffinity_np (pthread_attr_t * attr,
+ size_t cpusetsize,
+ const cpu_set_t * cpuset);
+
PTW32_DLLPORT int PTW32_CDECL pthread_attr_setdetachstate (pthread_attr_t * attr,
int detachstate);
@@ -967,13 +807,13 @@ PTW32_DLLPORT void PTW32_CDECL pthread_testcancel (void);
PTW32_DLLPORT int PTW32_CDECL pthread_once (pthread_once_t * once_control,
void (PTW32_CDECL *init_routine) (void));
-#if PTW32_LEVEL >= PTW32_LEVEL_MAX
+#if __PTW32_LEVEL >= __PTW32_LEVEL_MAX
PTW32_DLLPORT ptw32_cleanup_t * PTW32_CDECL ptw32_pop_cleanup (int execute);
PTW32_DLLPORT void PTW32_CDECL ptw32_push_cleanup (ptw32_cleanup_t * cleanup,
ptw32_cleanup_callback_t routine,
void *arg);
-#endif /* PTW32_LEVEL >= PTW32_LEVEL_MAX */
+#endif /* __PTW32_LEVEL >= __PTW32_LEVEL_MAX */
/*
* Thread Specific Data Functions
@@ -1114,7 +954,7 @@ PTW32_DLLPORT int PTW32_CDECL pthread_getschedparam (pthread_t thread,
struct sched_param *param);
PTW32_DLLPORT int PTW32_CDECL pthread_setconcurrency (int);
-
+
PTW32_DLLPORT int PTW32_CDECL pthread_getconcurrency (void);
/*
@@ -1151,7 +991,7 @@ PTW32_DLLPORT int PTW32_CDECL pthread_rwlockattr_getpshared (const pthread_rwloc
PTW32_DLLPORT int PTW32_CDECL pthread_rwlockattr_setpshared (pthread_rwlockattr_t * attr,
int pshared);
-#if PTW32_LEVEL >= PTW32_LEVEL_MAX - 1
+#if __PTW32_LEVEL >= __PTW32_LEVEL_MAX - 1
/*
* Signal Functions. Should be defined in <signal.h> but MSVC and MinGW32
@@ -1170,6 +1010,17 @@ PTW32_DLLPORT int PTW32_CDECL pthread_mutexattr_setkind_np(pthread_mutexattr_t *
int kind);
PTW32_DLLPORT int PTW32_CDECL pthread_mutexattr_getkind_np(pthread_mutexattr_t * attr,
int *kind);
+PTW32_DLLPORT int PTW32_CDECL pthread_timedjoin_np(pthread_t thread,
+ void **value_ptr,
+ const struct timespec *abstime);
+PTW32_DLLPORT int PTW32_CDECL pthread_tryjoin_np(pthread_t thread,
+ void **value_ptr);
+PTW32_DLLPORT int PTW32_CDECL pthread_setaffinity_np(pthread_t thread,
+ size_t cpusetsize,
+ const cpu_set_t *cpuset);
+PTW32_DLLPORT int PTW32_CDECL pthread_getaffinity_np(pthread_t thread,
+ size_t cpusetsize,
+ cpu_set_t *cpuset);
/*
* Possibly supported by other POSIX threads implementations
@@ -1188,12 +1039,22 @@ PTW32_DLLPORT int PTW32_CDECL pthread_win32_thread_attach_np(void);
PTW32_DLLPORT int PTW32_CDECL pthread_win32_thread_detach_np(void);
/*
+ * Returns the first parameter "abstime" modified to represent the current system time.
+ * If "relative" is not NULL it represents an interval to add to "abstime".
+ */
+
+PTW32_DLLPORT struct timespec * PTW32_CDECL pthread_win32_getabstime_np(
+ struct timespec * abstime,
+ const struct timespec * relative);
+
+/*
* Features that are auto-detected at load/run time.
*/
PTW32_DLLPORT int PTW32_CDECL pthread_win32_test_features_np(int);
-enum ptw32_features {
- PTW32_SYSTEM_INTERLOCKED_COMPARE_EXCHANGE = 0x0001, /* System provides it. */
- PTW32_ALERTABLE_ASYNC_CANCEL = 0x0002 /* Can cancel blocked threads. */
+enum ptw32_features
+{
+ PTW32_SYSTEM_INTERLOCKED_COMPARE_EXCHANGE = 0x0001, /* System provides it. */
+ PTW32_ALERTABLE_ASYNC_CANCEL = 0x0002 /* Can cancel blocked threads. */
};
/*
@@ -1206,25 +1067,41 @@ enum ptw32_features {
*/
PTW32_DLLPORT void * PTW32_CDECL pthread_timechange_handler_np(void *);
-#endif /*PTW32_LEVEL >= PTW32_LEVEL_MAX - 1 */
+#endif /* __PTW32_LEVEL >= __PTW32_LEVEL_MAX - 1 */
-#if PTW32_LEVEL >= PTW32_LEVEL_MAX
+#if __PTW32_LEVEL >= __PTW32_LEVEL_MAX
/*
* Returns the Win32 HANDLE for the POSIX thread.
*/
-PTW32_DLLPORT HANDLE PTW32_CDECL pthread_getw32threadhandle_np(pthread_t thread);
+PTW32_DLLPORT void * PTW32_CDECL pthread_getw32threadhandle_np(pthread_t thread);
/*
* Returns the win32 thread ID for POSIX thread.
*/
-PTW32_DLLPORT DWORD PTW32_CDECL pthread_getw32threadid_np (pthread_t thread);
+PTW32_DLLPORT unsigned long PTW32_CDECL pthread_getw32threadid_np (pthread_t thread);
+
+/*
+ * Sets the POSIX thread name. If _MSC_VER is defined the name should be displayed by
+ * the MSVS debugger.
+ */
+#if defined(PTW32_COMPATIBILITY_BSD) || defined(PTW32_COMPATIBILITY_TRU64)
+#define PTHREAD_MAX_NAMELEN_NP 16
+PTW32_DLLPORT int PTW32_CDECL pthread_setname_np (pthread_t thr, const char * name, void * arg);
+PTW32_DLLPORT int PTW32_CDECL pthread_attr_setname_np (pthread_attr_t * attr, const char * name, void * arg);
+#else
+PTW32_DLLPORT int PTW32_CDECL pthread_setname_np (pthread_t thr, const char * name);
+PTW32_DLLPORT int PTW32_CDECL pthread_attr_setname_np (pthread_attr_t * attr, const char * name);
+#endif
+
+PTW32_DLLPORT int PTW32_CDECL pthread_getname_np (pthread_t thr, char * name, int len);
+PTW32_DLLPORT int PTW32_CDECL pthread_attr_getname_np (pthread_attr_t * attr, char * name, int len);
/*
* Protected Methods
*
* This function blocks until the given WIN32 handle
- * is signaled or pthread_cancel had been called.
+ * is signalled or pthread_cancel had been called.
* This function allows the caller to hook into the
* PThreads cancel mechanism. It is implemented using
*
@@ -1235,34 +1112,26 @@ PTW32_DLLPORT DWORD PTW32_CDECL pthread_getw32threadid_np (pthread_t thread);
* argument to TimedWait is simply passed to
* WaitForMultipleObjects.
*/
-PTW32_DLLPORT int PTW32_CDECL pthreadCancelableWait (HANDLE waitHandle);
-PTW32_DLLPORT int PTW32_CDECL pthreadCancelableTimedWait (HANDLE waitHandle,
- DWORD timeout);
+PTW32_DLLPORT int PTW32_CDECL pthreadCancelableWait (void *waitHandle);
+PTW32_DLLPORT int PTW32_CDECL pthreadCancelableTimedWait (void *waitHandle,
+ unsigned long timeout);
-#endif /* PTW32_LEVEL >= PTW32_LEVEL_MAX */
+#endif /* __PTW32_LEVEL >= __PTW32_LEVEL_MAX */
/*
- * Thread-Safe C Runtime Library Mappings.
+ * Declare a thread-safe errno for Open Watcom
+ * (note: this has not been tested in a long time)
*/
-#if !defined(_UWIN)
-# if defined(NEED_ERRNO)
- PTW32_DLLPORT int * PTW32_CDECL _errno( void );
-# else
-# if !defined(errno)
-# if (defined(_MT) || defined(_DLL))
- __declspec(dllimport) extern int * __cdecl _errno(void);
-# define errno (*_errno())
-# endif
-# endif
+#if defined(__WATCOMC__) && !defined(errno)
+# if defined(_MT) || defined(_DLL)
+ __declspec(dllimport) extern int * __cdecl _errno(void);
+# define errno (*_errno())
# endif
#endif
-/*
- * Some compiler environments don't define some things.
- */
-#if defined(__BORLANDC__)
-# define _ftime ftime
-# define _timeb timeb
+#if defined(PTW32_USES_SEPARATE_CRT) && (defined(__CLEANUP_CXX) || defined(__CLEANUP_SEH))
+typedef void (*ptw32_terminate_handler)();
+PTW32_DLLPORT ptw32_terminate_handler PTW32_CDECL pthread_win32_set_terminate_np(ptw32_terminate_handler termFunction);
#endif
#if defined(__cplusplus)
@@ -1276,15 +1145,15 @@ class ptw32_exception_exit : public ptw32_exception {};
#endif
-#if PTW32_LEVEL >= PTW32_LEVEL_MAX
+#if __PTW32_LEVEL >= __PTW32_LEVEL_MAX
/* FIXME: This is only required if the library was built using SEH */
/*
* Get internal SEH tag
*/
-PTW32_DLLPORT DWORD PTW32_CDECL ptw32_get_exception_services_code(void);
+PTW32_DLLPORT unsigned long PTW32_CDECL ptw32_get_exception_services_code(void);
-#endif /* PTW32_LEVEL >= PTW32_LEVEL_MAX */
+#endif /* __PTW32_LEVEL >= __PTW32_LEVEL_MAX */
#if !defined(PTW32_BUILD)
@@ -1309,7 +1178,7 @@ PTW32_DLLPORT DWORD PTW32_CDECL ptw32_get_exception_services_code(void);
#if defined(_MSC_VER)
/*
* WARNING: Replace any 'catch( ... )' with 'PtW32CatchAll'
- * if you want Pthread-Win32 cancelation and pthread_exit to work.
+ * if you want Pthread-Win32 cancellation and pthread_exit to work.
*/
#if !defined(PtW32NoCatchWarn)
@@ -1319,7 +1188,7 @@ PTW32_DLLPORT DWORD PTW32_CDECL ptw32_get_exception_services_code(void);
#pragma message("When compiling applications with MSVC++ and C++ exception handling:")
#pragma message(" Replace any 'catch( ... )' in routines called from POSIX threads")
#pragma message(" with 'PtW32CatchAll' or 'CATCHALL' if you want POSIX thread")
-#pragma message(" cancelation and pthread_exit to work. For example:")
+#pragma message(" cancellation and pthread_exit to work. For example:")
#pragma message("")
#pragma message(" #if defined(PtW32CatchAll)")
#pragma message(" PtW32CatchAll")
@@ -1349,19 +1218,10 @@ PTW32_DLLPORT DWORD PTW32_CDECL ptw32_get_exception_services_code(void);
#endif /* ! PTW32_BUILD */
-#if defined(__cplusplus)
-} /* End of extern "C" */
-#endif /* __cplusplus */
-
-#if defined(PTW32__HANDLE_DEF)
-# undef HANDLE
-#endif
-#if defined(PTW32__DWORD_DEF)
-# undef DWORD
-#endif
+__PTW32_END_C_DECLS
-#undef PTW32_LEVEL
-#undef PTW32_LEVEL_MAX
+#undef __PTW32_LEVEL
+#undef __PTW32_LEVEL_MAX
#endif /* ! RC_INVOKED */
diff --git a/libs/pthreads/src/pthread_attr_destroy.c b/libs/pthreads/src/pthread_attr_destroy.c
index 8b3e04c536..b2c9a2d799 100644
--- a/libs/pthreads/src/pthread_attr_destroy.c
+++ b/libs/pthreads/src/pthread_attr_destroy.c
@@ -6,34 +6,38 @@
*
* --------------------------------------------------------------------------
*
- * Pthreads-win32 - POSIX Threads Library for Win32
+ * Pthreads4w - POSIX Threads Library for Win32
* Copyright(C) 1998 John E. Bossom
- * Copyright(C) 1999,2005 Pthreads-win32 contributors
- *
- * Contact Email: rpj@callisto.canberra.edu.au
- *
+ * Copyright(C) 1999-2018, Pthreads4w contributors
+ *
+ * Homepage: https://sourceforge.net/projects/pthreads4w/
+ *
* The current list of contributors is contained
* in the file CONTRIBUTORS included with the source
* code distribution. The list can also be seen at the
* following World Wide Web location:
- * http://sources.redhat.com/pthreads-win32/contributors.html
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library in the file COPYING.LIB;
- * if not, write to the Free Software Foundation, Inc.,
- * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
+ * https://sourceforge.net/p/pthreads4w/wiki/Contributors/
+ *
+ * This file is part of Pthreads4w.
+ *
+ * Pthreads4w is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * Pthreads4w is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Pthreads4w. If not, see <http://www.gnu.org/licenses/>. *
*/
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
#include "pthread.h"
#include "implement.h"
diff --git a/libs/pthreads/src/pthread_attr_getaffinity_np.c b/libs/pthreads/src/pthread_attr_getaffinity_np.c
new file mode 100644
index 0000000000..2bf5b064b9
--- /dev/null
+++ b/libs/pthreads/src/pthread_attr_getaffinity_np.c
@@ -0,0 +1,56 @@
+/*
+ * pthread_attr_getaffinity_np.c
+ *
+ * Description:
+ * POSIX thread functions that deal with thread CPU affinity.
+ *
+ * --------------------------------------------------------------------------
+ *
+ * Pthreads4w - POSIX Threads Library for Win32
+ * Copyright(C) 1998 John E. Bossom
+ * Copyright(C) 1999-2018, Pthreads4w contributors
+ *
+ * Homepage: https://sourceforge.net/projects/pthreads4w/
+ *
+ * The current list of contributors is contained
+ * in the file CONTRIBUTORS included with the source
+ * code distribution. The list can also be seen at the
+ * following World Wide Web location:
+ * https://sourceforge.net/p/pthreads4w/wiki/Contributors/
+ *
+ * This file is part of Pthreads4w.
+ *
+ * Pthreads4w is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * Pthreads4w is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Pthreads4w. If not, see <http://www.gnu.org/licenses/>. *
+ */
+
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
+#include "pthread.h"
+#include "implement.h"
+#include "sched.h"
+
+int
+pthread_attr_getaffinity_np (const pthread_attr_t * attr, size_t cpusetsize, cpu_set_t * cpuset)
+{
+ if (ptw32_is_attr (attr) != 0 || cpuset == NULL)
+ {
+ return EINVAL;
+ }
+
+ ((_sched_cpu_set_vector_*)cpuset)->_cpuset = (*attr)->cpuset;
+
+ return 0;
+}
diff --git a/libs/pthreads/src/pthread_attr_getdetachstate.c b/libs/pthreads/src/pthread_attr_getdetachstate.c
index 188533b13c..91aeb4959f 100644
--- a/libs/pthreads/src/pthread_attr_getdetachstate.c
+++ b/libs/pthreads/src/pthread_attr_getdetachstate.c
@@ -6,34 +6,38 @@
*
* --------------------------------------------------------------------------
*
- * Pthreads-win32 - POSIX Threads Library for Win32
+ * Pthreads4w - POSIX Threads Library for Win32
* Copyright(C) 1998 John E. Bossom
- * Copyright(C) 1999,2005 Pthreads-win32 contributors
- *
- * Contact Email: rpj@callisto.canberra.edu.au
- *
+ * Copyright(C) 1999-2018, Pthreads4w contributors
+ *
+ * Homepage: https://sourceforge.net/projects/pthreads4w/
+ *
* The current list of contributors is contained
* in the file CONTRIBUTORS included with the source
* code distribution. The list can also be seen at the
* following World Wide Web location:
- * http://sources.redhat.com/pthreads-win32/contributors.html
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library in the file COPYING.LIB;
- * if not, write to the Free Software Foundation, Inc.,
- * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
+ * https://sourceforge.net/p/pthreads4w/wiki/Contributors/
+ *
+ * This file is part of Pthreads4w.
+ *
+ * Pthreads4w is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * Pthreads4w is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Pthreads4w. If not, see <http://www.gnu.org/licenses/>. *
*/
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
#include "pthread.h"
#include "implement.h"
diff --git a/libs/pthreads/src/pthread_attr_getinheritsched.c b/libs/pthreads/src/pthread_attr_getinheritsched.c
index 9c6885ed92..aa3f9851a1 100644
--- a/libs/pthreads/src/pthread_attr_getinheritsched.c
+++ b/libs/pthreads/src/pthread_attr_getinheritsched.c
@@ -6,34 +6,38 @@
*
* --------------------------------------------------------------------------
*
- * Pthreads-win32 - POSIX Threads Library for Win32
+ * Pthreads4w - POSIX Threads Library for Win32
* Copyright(C) 1998 John E. Bossom
- * Copyright(C) 1999,2005 Pthreads-win32 contributors
- *
- * Contact Email: rpj@callisto.canberra.edu.au
- *
+ * Copyright(C) 1999-2018, Pthreads4w contributors
+ *
+ * Homepage: https://sourceforge.net/projects/pthreads4w/
+ *
* The current list of contributors is contained
* in the file CONTRIBUTORS included with the source
* code distribution. The list can also be seen at the
* following World Wide Web location:
- * http://sources.redhat.com/pthreads-win32/contributors.html
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library in the file COPYING.LIB;
- * if not, write to the Free Software Foundation, Inc.,
- * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
+ * https://sourceforge.net/p/pthreads4w/wiki/Contributors/
+ *
+ * This file is part of Pthreads4w.
+ *
+ * Pthreads4w is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * Pthreads4w is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Pthreads4w. If not, see <http://www.gnu.org/licenses/>. *
*/
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
#include "pthread.h"
#include "implement.h"
#include "sched.h"
diff --git a/libs/pthreads/src/pthread_attr_getname_np.c b/libs/pthreads/src/pthread_attr_getname_np.c
new file mode 100644
index 0000000000..50dd5f6e85
--- /dev/null
+++ b/libs/pthreads/src/pthread_attr_getname_np.c
@@ -0,0 +1,53 @@
+/*
+ * pthread_attr_getname_np.c
+ *
+ * --------------------------------------------------------------------------
+ *
+ * Pthreads4w - POSIX Threads Library for Win32
+ * Copyright(C) 1998 John E. Bossom
+ * Copyright(C) 1999-2018, Pthreads4w contributors
+ *
+ * Homepage: https://sourceforge.net/projects/pthreads4w/
+ *
+ * The current list of contributors is contained
+ * in the file CONTRIBUTORS included with the source
+ * code distribution. The list can also be seen at the
+ * following World Wide Web location:
+ * https://sourceforge.net/p/pthreads4w/wiki/Contributors/
+ *
+ * This file is part of Pthreads4w.
+ *
+ * Pthreads4w is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * Pthreads4w is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Pthreads4w. If not, see <http://www.gnu.org/licenses/>. *
+ */
+
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
+#include <string.h>
+#include "pthread.h"
+#include "implement.h"
+
+int
+pthread_attr_getname_np(pthread_attr_t * attr, char *name, int len)
+{
+ //strncpy_s(name, len - 1, (*attr)->thrname, len - 1);
+#if defined(_MSVCRT_)
+# pragma warning(suppress:4996)
+ strncpy(name, (*attr)->thrname, len - 1);
+ (*attr)->thrname[len - 1] = '\0';
+#endif
+
+ return 0;
+}
diff --git a/libs/pthreads/src/pthread_attr_getschedparam.c b/libs/pthreads/src/pthread_attr_getschedparam.c
index ab89b2241a..d9cef38706 100644
--- a/libs/pthreads/src/pthread_attr_getschedparam.c
+++ b/libs/pthreads/src/pthread_attr_getschedparam.c
@@ -6,34 +6,38 @@
*
* --------------------------------------------------------------------------
*
- * Pthreads-win32 - POSIX Threads Library for Win32
+ * Pthreads4w - POSIX Threads Library for Win32
* Copyright(C) 1998 John E. Bossom
- * Copyright(C) 1999,2005 Pthreads-win32 contributors
- *
- * Contact Email: rpj@callisto.canberra.edu.au
- *
+ * Copyright(C) 1999-2018, Pthreads4w contributors
+ *
+ * Homepage: https://sourceforge.net/projects/pthreads4w/
+ *
* The current list of contributors is contained
* in the file CONTRIBUTORS included with the source
* code distribution. The list can also be seen at the
* following World Wide Web location:
- * http://sources.redhat.com/pthreads-win32/contributors.html
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library in the file COPYING.LIB;
- * if not, write to the Free Software Foundation, Inc.,
- * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
+ * https://sourceforge.net/p/pthreads4w/wiki/Contributors/
+ *
+ * This file is part of Pthreads4w.
+ *
+ * Pthreads4w is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * Pthreads4w is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Pthreads4w. If not, see <http://www.gnu.org/licenses/>. *
*/
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
#include "pthread.h"
#include "implement.h"
#include "sched.h"
diff --git a/libs/pthreads/src/pthread_attr_getschedpolicy.c b/libs/pthreads/src/pthread_attr_getschedpolicy.c
index 94a257d609..e23ca0c330 100644
--- a/libs/pthreads/src/pthread_attr_getschedpolicy.c
+++ b/libs/pthreads/src/pthread_attr_getschedpolicy.c
@@ -6,34 +6,38 @@
*
* --------------------------------------------------------------------------
*
- * Pthreads-win32 - POSIX Threads Library for Win32
+ * Pthreads4w - POSIX Threads Library for Win32
* Copyright(C) 1998 John E. Bossom
- * Copyright(C) 1999,2005 Pthreads-win32 contributors
- *
- * Contact Email: rpj@callisto.canberra.edu.au
- *
+ * Copyright(C) 1999-2018, Pthreads4w contributors
+ *
+ * Homepage: https://sourceforge.net/projects/pthreads4w/
+ *
* The current list of contributors is contained
* in the file CONTRIBUTORS included with the source
* code distribution. The list can also be seen at the
* following World Wide Web location:
- * http://sources.redhat.com/pthreads-win32/contributors.html
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library in the file COPYING.LIB;
- * if not, write to the Free Software Foundation, Inc.,
- * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
+ * https://sourceforge.net/p/pthreads4w/wiki/Contributors/
+ *
+ * This file is part of Pthreads4w.
+ *
+ * Pthreads4w is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * Pthreads4w is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Pthreads4w. If not, see <http://www.gnu.org/licenses/>. *
*/
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
#include "pthread.h"
#include "implement.h"
#include "sched.h"
@@ -46,15 +50,6 @@ pthread_attr_getschedpolicy (const pthread_attr_t * attr, int *policy)
return EINVAL;
}
- /*
- * Validate the policy arg.
- * Check that a policy constant wasn't passed rather than &policy.
- */
- if (policy <= (int *) SCHED_MAX)
- {
- return EINVAL;
- }
-
*policy = SCHED_OTHER;
return 0;
diff --git a/libs/pthreads/src/pthread_attr_getscope.c b/libs/pthreads/src/pthread_attr_getscope.c
index 2efdb2fe6d..288740fa6f 100644
--- a/libs/pthreads/src/pthread_attr_getscope.c
+++ b/libs/pthreads/src/pthread_attr_getscope.c
@@ -6,34 +6,38 @@
*
* --------------------------------------------------------------------------
*
- * Pthreads-win32 - POSIX Threads Library for Win32
+ * Pthreads4w - POSIX Threads Library for Win32
* Copyright(C) 1998 John E. Bossom
- * Copyright(C) 1999,2005 Pthreads-win32 contributors
- *
- * Contact Email: rpj@callisto.canberra.edu.au
- *
+ * Copyright(C) 1999-2018, Pthreads4w contributors
+ *
+ * Homepage: https://sourceforge.net/projects/pthreads4w/
+ *
* The current list of contributors is contained
* in the file CONTRIBUTORS included with the source
* code distribution. The list can also be seen at the
* following World Wide Web location:
- * http://sources.redhat.com/pthreads-win32/contributors.html
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library in the file COPYING.LIB;
- * if not, write to the Free Software Foundation, Inc.,
- * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
+ * https://sourceforge.net/p/pthreads4w/wiki/Contributors/
+ *
+ * This file is part of Pthreads4w.
+ *
+ * Pthreads4w is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * Pthreads4w is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Pthreads4w. If not, see <http://www.gnu.org/licenses/>. *
*/
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
#include "pthread.h"
#include "implement.h"
diff --git a/libs/pthreads/src/pthread_attr_getstackaddr.c b/libs/pthreads/src/pthread_attr_getstackaddr.c
index 1a2da01c78..7815779923 100644
--- a/libs/pthreads/src/pthread_attr_getstackaddr.c
+++ b/libs/pthreads/src/pthread_attr_getstackaddr.c
@@ -6,34 +6,38 @@
*
* --------------------------------------------------------------------------
*
- * Pthreads-win32 - POSIX Threads Library for Win32
+ * Pthreads4w - POSIX Threads Library for Win32
* Copyright(C) 1998 John E. Bossom
- * Copyright(C) 1999,2005 Pthreads-win32 contributors
- *
- * Contact Email: rpj@callisto.canberra.edu.au
- *
+ * Copyright(C) 1999-2018, Pthreads4w contributors
+ *
+ * Homepage: https://sourceforge.net/projects/pthreads4w/
+ *
* The current list of contributors is contained
* in the file CONTRIBUTORS included with the source
* code distribution. The list can also be seen at the
* following World Wide Web location:
- * http://sources.redhat.com/pthreads-win32/contributors.html
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library in the file COPYING.LIB;
- * if not, write to the Free Software Foundation, Inc.,
- * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
+ * https://sourceforge.net/p/pthreads4w/wiki/Contributors/
+ *
+ * This file is part of Pthreads4w.
+ *
+ * Pthreads4w is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * Pthreads4w is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Pthreads4w. If not, see <http://www.gnu.org/licenses/>. *
*/
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
#include "pthread.h"
#include "implement.h"
@@ -72,14 +76,14 @@ pthread_attr_getstackaddr (const pthread_attr_t * attr, void **stackaddr)
* address..
*
* RESULTS
- * 0 successfully retreived stack address,
+ * 0 successfully retrieved stack address,
* EINVAL 'attr' is invalid
* ENOSYS function not supported
*
* ------------------------------------------------------
*/
{
-#if defined( _POSIX_THREAD_ATTR_STACKADDR )
+#if defined( _POSIX_THREAD_ATTR_STACKADDR ) && _POSIX_THREAD_ATTR_STACKADDR != -1
if (ptw32_is_attr (attr) != 0)
{
diff --git a/libs/pthreads/src/pthread_attr_getstacksize.c b/libs/pthreads/src/pthread_attr_getstacksize.c
index dff9230f28..a8809687c5 100644
--- a/libs/pthreads/src/pthread_attr_getstacksize.c
+++ b/libs/pthreads/src/pthread_attr_getstacksize.c
@@ -6,34 +6,38 @@
*
* --------------------------------------------------------------------------
*
- * Pthreads-win32 - POSIX Threads Library for Win32
+ * Pthreads4w - POSIX Threads Library for Win32
* Copyright(C) 1998 John E. Bossom
- * Copyright(C) 1999,2005 Pthreads-win32 contributors
- *
- * Contact Email: rpj@callisto.canberra.edu.au
- *
+ * Copyright(C) 1999-2018, Pthreads4w contributors
+ *
+ * Homepage: https://sourceforge.net/projects/pthreads4w/
+ *
* The current list of contributors is contained
* in the file CONTRIBUTORS included with the source
* code distribution. The list can also be seen at the
* following World Wide Web location:
- * http://sources.redhat.com/pthreads-win32/contributors.html
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library in the file COPYING.LIB;
- * if not, write to the Free Software Foundation, Inc.,
- * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
+ * https://sourceforge.net/p/pthreads4w/wiki/Contributors/
+ *
+ * This file is part of Pthreads4w.
+ *
+ * Pthreads4w is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * Pthreads4w is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Pthreads4w. If not, see <http://www.gnu.org/licenses/>. *
*/
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
#include "pthread.h"
#include "implement.h"
@@ -80,7 +84,7 @@ pthread_attr_getstacksize (const pthread_attr_t * attr, size_t * stacksize)
* ------------------------------------------------------
*/
{
-#if defined(_POSIX_THREAD_ATTR_STACKSIZE)
+#if defined(_POSIX_THREAD_ATTR_STACKSIZE) && _POSIX_THREAD_ATTR_STACKSIZE != -1
if (ptw32_is_attr (attr) != 0)
{
diff --git a/libs/pthreads/src/pthread_attr_init.c b/libs/pthreads/src/pthread_attr_init.c
index ae9d3eb5f4..26aabb5d7f 100644
--- a/libs/pthreads/src/pthread_attr_init.c
+++ b/libs/pthreads/src/pthread_attr_init.c
@@ -6,34 +6,38 @@
*
* --------------------------------------------------------------------------
*
- * Pthreads-win32 - POSIX Threads Library for Win32
+ * Pthreads4w - POSIX Threads Library for Win32
* Copyright(C) 1998 John E. Bossom
- * Copyright(C) 1999,2005 Pthreads-win32 contributors
- *
- * Contact Email: rpj@callisto.canberra.edu.au
- *
+ * Copyright(C) 1999-2018, Pthreads4w contributors
+ *
+ * Homepage: https://sourceforge.net/projects/pthreads4w/
+ *
* The current list of contributors is contained
* in the file CONTRIBUTORS included with the source
* code distribution. The list can also be seen at the
* following World Wide Web location:
- * http://sources.redhat.com/pthreads-win32/contributors.html
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library in the file COPYING.LIB;
- * if not, write to the Free Software Foundation, Inc.,
- * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
+ * https://sourceforge.net/p/pthreads4w/wiki/Contributors/
+ *
+ * This file is part of Pthreads4w.
+ *
+ * Pthreads4w is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * Pthreads4w is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Pthreads4w. If not, see <http://www.gnu.org/licenses/>. *
*/
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
#include "pthread.h"
#include "implement.h"
@@ -66,6 +70,7 @@ pthread_attr_init (pthread_attr_t * attr)
*/
{
pthread_attr_t attr_result;
+ cpu_set_t cpuset;
if (attr == NULL)
{
@@ -108,6 +113,9 @@ pthread_attr_init (pthread_attr_t * attr)
attr_result->param.sched_priority = THREAD_PRIORITY_NORMAL;
attr_result->inheritsched = PTHREAD_EXPLICIT_SCHED;
attr_result->contentionscope = PTHREAD_SCOPE_SYSTEM;
+ CPU_ZERO(&cpuset);
+ attr_result->cpuset = ((_sched_cpu_set_vector_*)&cpuset)->_cpuset;
+ attr_result->thrname = NULL;
attr_result->valid = PTW32_ATTR_VALID;
diff --git a/libs/pthreads/src/pthread_attr_setaffinity_np.c b/libs/pthreads/src/pthread_attr_setaffinity_np.c
new file mode 100644
index 0000000000..4d67f50192
--- /dev/null
+++ b/libs/pthreads/src/pthread_attr_setaffinity_np.c
@@ -0,0 +1,56 @@
+/*
+ * pthread_attr_setaffinity_np.c
+ *
+ * Description:
+ * POSIX thread functions that deal with thread CPU affinity.
+ *
+ * --------------------------------------------------------------------------
+ *
+ * Pthreads4w - POSIX Threads Library for Win32
+ * Copyright(C) 1998 John E. Bossom
+ * Copyright(C) 1999-2018, Pthreads4w contributors
+ *
+ * Homepage: https://sourceforge.net/projects/pthreads4w/
+ *
+ * The current list of contributors is contained
+ * in the file CONTRIBUTORS included with the source
+ * code distribution. The list can also be seen at the
+ * following World Wide Web location:
+ * https://sourceforge.net/p/pthreads4w/wiki/Contributors/
+ *
+ * This file is part of Pthreads4w.
+ *
+ * Pthreads4w is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * Pthreads4w is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Pthreads4w. If not, see <http://www.gnu.org/licenses/>. *
+ */
+
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
+#include "pthread.h"
+#include "implement.h"
+#include "sched.h"
+
+int
+pthread_attr_setaffinity_np (pthread_attr_t * attr, size_t cpusetsize, const cpu_set_t * cpuset)
+{
+ if (ptw32_is_attr (attr) != 0 || cpuset == NULL)
+ {
+ return EINVAL;
+ }
+
+ (*attr)->cpuset = ((_sched_cpu_set_vector_*)cpuset)->_cpuset;
+
+ return 0;
+}
diff --git a/libs/pthreads/src/pthread_attr_setdetachstate.c b/libs/pthreads/src/pthread_attr_setdetachstate.c
index 784642a807..bd226a3f8d 100644
--- a/libs/pthreads/src/pthread_attr_setdetachstate.c
+++ b/libs/pthreads/src/pthread_attr_setdetachstate.c
@@ -6,34 +6,38 @@
*
* --------------------------------------------------------------------------
*
- * Pthreads-win32 - POSIX Threads Library for Win32
+ * Pthreads4w - POSIX Threads Library for Win32
* Copyright(C) 1998 John E. Bossom
- * Copyright(C) 1999,2005 Pthreads-win32 contributors
- *
- * Contact Email: rpj@callisto.canberra.edu.au
- *
+ * Copyright(C) 1999-2018, Pthreads4w contributors
+ *
+ * Homepage: https://sourceforge.net/projects/pthreads4w/
+ *
* The current list of contributors is contained
* in the file CONTRIBUTORS included with the source
* code distribution. The list can also be seen at the
* following World Wide Web location:
- * http://sources.redhat.com/pthreads-win32/contributors.html
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library in the file COPYING.LIB;
- * if not, write to the Free Software Foundation, Inc.,
- * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
+ * https://sourceforge.net/p/pthreads4w/wiki/Contributors/
+ *
+ * This file is part of Pthreads4w.
+ *
+ * Pthreads4w is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * Pthreads4w is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Pthreads4w. If not, see <http://www.gnu.org/licenses/>. *
*/
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
#include "pthread.h"
#include "implement.h"
diff --git a/libs/pthreads/src/pthread_attr_setinheritsched.c b/libs/pthreads/src/pthread_attr_setinheritsched.c
index e0a407a3b7..eb8341bbd1 100644
--- a/libs/pthreads/src/pthread_attr_setinheritsched.c
+++ b/libs/pthreads/src/pthread_attr_setinheritsched.c
@@ -6,34 +6,38 @@
*
* --------------------------------------------------------------------------
*
- * Pthreads-win32 - POSIX Threads Library for Win32
+ * Pthreads4w - POSIX Threads Library for Win32
* Copyright(C) 1998 John E. Bossom
- * Copyright(C) 1999,2005 Pthreads-win32 contributors
- *
- * Contact Email: rpj@callisto.canberra.edu.au
- *
+ * Copyright(C) 1999-2018, Pthreads4w contributors
+ *
+ * Homepage: https://sourceforge.net/projects/pthreads4w/
+ *
* The current list of contributors is contained
* in the file CONTRIBUTORS included with the source
* code distribution. The list can also be seen at the
* following World Wide Web location:
- * http://sources.redhat.com/pthreads-win32/contributors.html
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library in the file COPYING.LIB;
- * if not, write to the Free Software Foundation, Inc.,
- * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
+ * https://sourceforge.net/p/pthreads4w/wiki/Contributors/
+ *
+ * This file is part of Pthreads4w.
+ *
+ * Pthreads4w is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * Pthreads4w is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Pthreads4w. If not, see <http://www.gnu.org/licenses/>. *
*/
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
#include "pthread.h"
#include "implement.h"
#include "sched.h"
diff --git a/libs/pthreads/src/pthread_attr_setname_np.c b/libs/pthreads/src/pthread_attr_setname_np.c
new file mode 100644
index 0000000000..9425d8396d
--- /dev/null
+++ b/libs/pthreads/src/pthread_attr_setname_np.c
@@ -0,0 +1,98 @@
+/*
+ * pthread_attr_setname_np.c
+ *
+ * --------------------------------------------------------------------------
+ *
+ * Pthreads4w - POSIX Threads Library for Win32
+ * Copyright(C) 1998 John E. Bossom
+ * Copyright(C) 1999-2018, Pthreads4w contributors
+ *
+ * Homepage: https://sourceforge.net/projects/pthreads4w/
+ *
+ * The current list of contributors is contained
+ * in the file CONTRIBUTORS included with the source
+ * code distribution. The list can also be seen at the
+ * following World Wide Web location:
+ * https://sourceforge.net/p/pthreads4w/wiki/Contributors/
+ *
+ * This file is part of Pthreads4w.
+ *
+ * Pthreads4w is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * Pthreads4w is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Pthreads4w. If not, see <http://www.gnu.org/licenses/>. *
+ */
+
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
+#include <stdio.h>
+#include <string.h>
+#include "pthread.h"
+#include "implement.h"
+
+#if defined(PTW32_COMPATIBILITY_BSD) || defined(PTW32_COMPATIBILITY_TRU64)
+int
+pthread_attr_setname_np(pthread_attr_t * attr, const char *name, void *arg)
+{
+ int len;
+ int result;
+ char tmpbuf[PTHREAD_MAX_NAMELEN_NP];
+ char * newname;
+ char * oldname;
+
+ /*
+ * According to the MSDN description for snprintf()
+ * where count is the second parameter:
+ * If len < count, then len characters are stored in buffer, a null-terminator is appended, and len is returned.
+ * If len = count, then len characters are stored in buffer, no null-terminator is appended, and len is returned.
+ * If len > count, then count characters are stored in buffer, no null-terminator is appended, and a negative value is returned.
+ *
+ * This is different to the POSIX behaviour which returns the number of characters that would have been written in all cases.
+ */
+ len = snprintf(tmpbuf, PTHREAD_MAX_NAMELEN_NP-1, name, arg);
+ tmpbuf[PTHREAD_MAX_NAMELEN_NP-1] = '\0';
+ if (len < 0)
+ {
+ return EINVAL;
+ }
+
+ newname = _strdup(tmpbuf);
+
+ oldname = (*attr)->thrname;
+ (*attr)->thrname = newname;
+ if (oldname)
+ {
+ free(oldname);
+ }
+
+ return 0;
+}
+#else
+int
+pthread_attr_setname_np(pthread_attr_t * attr, const char *name)
+{
+ char * newname;
+ char * oldname;
+
+ newname = _strdup(name);
+
+ oldname = (*attr)->thrname;
+ (*attr)->thrname = newname;
+ if (oldname)
+ {
+ free(oldname);
+ }
+
+ return 0;
+}
+#endif
diff --git a/libs/pthreads/src/pthread_attr_setschedparam.c b/libs/pthreads/src/pthread_attr_setschedparam.c
index f246bfae7a..cf70698afe 100644
--- a/libs/pthreads/src/pthread_attr_setschedparam.c
+++ b/libs/pthreads/src/pthread_attr_setschedparam.c
@@ -6,34 +6,38 @@
*
* --------------------------------------------------------------------------
*
- * Pthreads-win32 - POSIX Threads Library for Win32
+ * Pthreads4w - POSIX Threads Library for Win32
* Copyright(C) 1998 John E. Bossom
- * Copyright(C) 1999,2005 Pthreads-win32 contributors
- *
- * Contact Email: rpj@callisto.canberra.edu.au
- *
+ * Copyright(C) 1999-2018, Pthreads4w contributors
+ *
+ * Homepage: https://sourceforge.net/projects/pthreads4w/
+ *
* The current list of contributors is contained
* in the file CONTRIBUTORS included with the source
* code distribution. The list can also be seen at the
* following World Wide Web location:
- * http://sources.redhat.com/pthreads-win32/contributors.html
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library in the file COPYING.LIB;
- * if not, write to the Free Software Foundation, Inc.,
- * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
+ * https://sourceforge.net/p/pthreads4w/wiki/Contributors/
+ *
+ * This file is part of Pthreads4w.
+ *
+ * Pthreads4w is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * Pthreads4w is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Pthreads4w. If not, see <http://www.gnu.org/licenses/>. *
*/
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
#include "pthread.h"
#include "implement.h"
#include "sched.h"
diff --git a/libs/pthreads/src/pthread_attr_setschedpolicy.c b/libs/pthreads/src/pthread_attr_setschedpolicy.c
index 45ff165973..6e55bfe8f1 100644
--- a/libs/pthreads/src/pthread_attr_setschedpolicy.c
+++ b/libs/pthreads/src/pthread_attr_setschedpolicy.c
@@ -6,34 +6,38 @@
*
* --------------------------------------------------------------------------
*
- * Pthreads-win32 - POSIX Threads Library for Win32
+ * Pthreads4w - POSIX Threads Library for Win32
* Copyright(C) 1998 John E. Bossom
- * Copyright(C) 1999,2005 Pthreads-win32 contributors
- *
- * Contact Email: rpj@callisto.canberra.edu.au
- *
+ * Copyright(C) 1999-2018, Pthreads4w contributors
+ *
+ * Homepage: https://sourceforge.net/projects/pthreads4w/
+ *
* The current list of contributors is contained
* in the file CONTRIBUTORS included with the source
* code distribution. The list can also be seen at the
* following World Wide Web location:
- * http://sources.redhat.com/pthreads-win32/contributors.html
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library in the file COPYING.LIB;
- * if not, write to the Free Software Foundation, Inc.,
- * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
+ * https://sourceforge.net/p/pthreads4w/wiki/Contributors/
+ *
+ * This file is part of Pthreads4w.
+ *
+ * Pthreads4w is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * Pthreads4w is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Pthreads4w. If not, see <http://www.gnu.org/licenses/>. *
*/
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
#include "pthread.h"
#include "implement.h"
#include "sched.h"
diff --git a/libs/pthreads/src/pthread_attr_setscope.c b/libs/pthreads/src/pthread_attr_setscope.c
index 39a51df887..82d07d5759 100644
--- a/libs/pthreads/src/pthread_attr_setscope.c
+++ b/libs/pthreads/src/pthread_attr_setscope.c
@@ -6,34 +6,38 @@
*
* --------------------------------------------------------------------------
*
- * Pthreads-win32 - POSIX Threads Library for Win32
+ * Pthreads4w - POSIX Threads Library for Win32
* Copyright(C) 1998 John E. Bossom
- * Copyright(C) 1999,2005 Pthreads-win32 contributors
- *
- * Contact Email: rpj@callisto.canberra.edu.au
- *
+ * Copyright(C) 1999-2018, Pthreads4w contributors
+ *
+ * Homepage: https://sourceforge.net/projects/pthreads4w/
+ *
* The current list of contributors is contained
* in the file CONTRIBUTORS included with the source
* code distribution. The list can also be seen at the
* following World Wide Web location:
- * http://sources.redhat.com/pthreads-win32/contributors.html
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library in the file COPYING.LIB;
- * if not, write to the Free Software Foundation, Inc.,
- * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
+ * https://sourceforge.net/p/pthreads4w/wiki/Contributors/
+ *
+ * This file is part of Pthreads4w.
+ *
+ * Pthreads4w is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * Pthreads4w is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Pthreads4w. If not, see <http://www.gnu.org/licenses/>. *
*/
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
#include "pthread.h"
#include "implement.h"
diff --git a/libs/pthreads/src/pthread_attr_setstackaddr.c b/libs/pthreads/src/pthread_attr_setstackaddr.c
index 1316c06592..46ba2eaad1 100644
--- a/libs/pthreads/src/pthread_attr_setstackaddr.c
+++ b/libs/pthreads/src/pthread_attr_setstackaddr.c
@@ -6,34 +6,38 @@
*
* --------------------------------------------------------------------------
*
- * Pthreads-win32 - POSIX Threads Library for Win32
+ * Pthreads4w - POSIX Threads Library for Win32
* Copyright(C) 1998 John E. Bossom
- * Copyright(C) 1999,2005 Pthreads-win32 contributors
- *
- * Contact Email: rpj@callisto.canberra.edu.au
- *
+ * Copyright(C) 1999-2018, Pthreads4w contributors
+ *
+ * Homepage: https://sourceforge.net/projects/pthreads4w/
+ *
* The current list of contributors is contained
* in the file CONTRIBUTORS included with the source
* code distribution. The list can also be seen at the
* following World Wide Web location:
- * http://sources.redhat.com/pthreads-win32/contributors.html
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library in the file COPYING.LIB;
- * if not, write to the Free Software Foundation, Inc.,
- * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
+ * https://sourceforge.net/p/pthreads4w/wiki/Contributors/
+ *
+ * This file is part of Pthreads4w.
+ *
+ * Pthreads4w is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * Pthreads4w is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Pthreads4w. If not, see <http://www.gnu.org/licenses/>. *
*/
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
#include "pthread.h"
#include "implement.h"
@@ -79,7 +83,7 @@ pthread_attr_setstackaddr (pthread_attr_t * attr, void *stackaddr)
* ------------------------------------------------------
*/
{
-#if defined( _POSIX_THREAD_ATTR_STACKADDR )
+#if defined( _POSIX_THREAD_ATTR_STACKADDR ) && _POSIX_THREAD_ATTR_STACKADDR != -1
if (ptw32_is_attr (attr) != 0)
{
diff --git a/libs/pthreads/src/pthread_attr_setstacksize.c b/libs/pthreads/src/pthread_attr_setstacksize.c
index eb13589a00..ea829eaf10 100644
--- a/libs/pthreads/src/pthread_attr_setstacksize.c
+++ b/libs/pthreads/src/pthread_attr_setstacksize.c
@@ -6,34 +6,38 @@
*
* --------------------------------------------------------------------------
*
- * Pthreads-win32 - POSIX Threads Library for Win32
+ * Pthreads4w - POSIX Threads Library for Win32
* Copyright(C) 1998 John E. Bossom
- * Copyright(C) 1999,2005 Pthreads-win32 contributors
- *
- * Contact Email: rpj@callisto.canberra.edu.au
- *
+ * Copyright(C) 1999-2018, Pthreads4w contributors
+ *
+ * Homepage: https://sourceforge.net/projects/pthreads4w/
+ *
* The current list of contributors is contained
* in the file CONTRIBUTORS included with the source
* code distribution. The list can also be seen at the
* following World Wide Web location:
- * http://sources.redhat.com/pthreads-win32/contributors.html
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library in the file COPYING.LIB;
- * if not, write to the Free Software Foundation, Inc.,
- * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
+ * https://sourceforge.net/p/pthreads4w/wiki/Contributors/
+ *
+ * This file is part of Pthreads4w.
+ *
+ * Pthreads4w is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * Pthreads4w is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Pthreads4w. If not, see <http://www.gnu.org/licenses/>. *
*/
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
#include "pthread.h"
#include "implement.h"
@@ -80,7 +84,7 @@ pthread_attr_setstacksize (pthread_attr_t * attr, size_t stacksize)
* ------------------------------------------------------
*/
{
-#if defined(_POSIX_THREAD_ATTR_STACKSIZE)
+#if defined(_POSIX_THREAD_ATTR_STACKSIZE) && _POSIX_THREAD_ATTR_STACKSIZE != -1
#if PTHREAD_STACK_MIN > 0
diff --git a/libs/pthreads/src/pthread_barrier_destroy.c b/libs/pthreads/src/pthread_barrier_destroy.c
index 55163cc858..e85beac166 100644
--- a/libs/pthreads/src/pthread_barrier_destroy.c
+++ b/libs/pthreads/src/pthread_barrier_destroy.c
@@ -6,34 +6,38 @@
*
* --------------------------------------------------------------------------
*
- * Pthreads-win32 - POSIX Threads Library for Win32
+ * Pthreads4w - POSIX Threads Library for Win32
* Copyright(C) 1998 John E. Bossom
- * Copyright(C) 1999,2005 Pthreads-win32 contributors
- *
- * Contact Email: rpj@callisto.canberra.edu.au
- *
+ * Copyright(C) 1999-2018, Pthreads4w contributors
+ *
+ * Homepage: https://sourceforge.net/projects/pthreads4w/
+ *
* The current list of contributors is contained
* in the file CONTRIBUTORS included with the source
* code distribution. The list can also be seen at the
* following World Wide Web location:
- * http://sources.redhat.com/pthreads-win32/contributors.html
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library in the file COPYING.LIB;
- * if not, write to the Free Software Foundation, Inc.,
- * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
+ * https://sourceforge.net/p/pthreads4w/wiki/Contributors/
+ *
+ * This file is part of Pthreads4w.
+ *
+ * Pthreads4w is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * Pthreads4w is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Pthreads4w. If not, see <http://www.gnu.org/licenses/>. *
*/
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
#include "pthread.h"
#include "implement.h"
diff --git a/libs/pthreads/src/pthread_barrier_init.c b/libs/pthreads/src/pthread_barrier_init.c
index 618bfae264..5d7be9b188 100644
--- a/libs/pthreads/src/pthread_barrier_init.c
+++ b/libs/pthreads/src/pthread_barrier_init.c
@@ -6,34 +6,38 @@
*
* --------------------------------------------------------------------------
*
- * Pthreads-win32 - POSIX Threads Library for Win32
+ * Pthreads4w - POSIX Threads Library for Win32
* Copyright(C) 1998 John E. Bossom
- * Copyright(C) 1999,2005 Pthreads-win32 contributors
- *
- * Contact Email: rpj@callisto.canberra.edu.au
- *
+ * Copyright(C) 1999-2018, Pthreads4w contributors
+ *
+ * Homepage: https://sourceforge.net/projects/pthreads4w/
+ *
* The current list of contributors is contained
* in the file CONTRIBUTORS included with the source
* code distribution. The list can also be seen at the
* following World Wide Web location:
- * http://sources.redhat.com/pthreads-win32/contributors.html
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library in the file COPYING.LIB;
- * if not, write to the Free Software Foundation, Inc.,
- * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
+ * https://sourceforge.net/p/pthreads4w/wiki/Contributors/
+ *
+ * This file is part of Pthreads4w.
+ *
+ * Pthreads4w is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * Pthreads4w is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Pthreads4w. If not, see <http://www.gnu.org/licenses/>. *
*/
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
#include "pthread.h"
#include "implement.h"
diff --git a/libs/pthreads/src/pthread_barrier_wait.c b/libs/pthreads/src/pthread_barrier_wait.c
index e0e97e6c78..95776d80f0 100644
--- a/libs/pthreads/src/pthread_barrier_wait.c
+++ b/libs/pthreads/src/pthread_barrier_wait.c
@@ -6,34 +6,38 @@
*
* --------------------------------------------------------------------------
*
- * Pthreads-win32 - POSIX Threads Library for Win32
+ * Pthreads4w - POSIX Threads Library for Win32
* Copyright(C) 1998 John E. Bossom
- * Copyright(C) 1999,2005 Pthreads-win32 contributors
- *
- * Contact Email: rpj@callisto.canberra.edu.au
- *
+ * Copyright(C) 1999-2018, Pthreads4w contributors
+ *
+ * Homepage: https://sourceforge.net/projects/pthreads4w/
+ *
* The current list of contributors is contained
* in the file CONTRIBUTORS included with the source
* code distribution. The list can also be seen at the
* following World Wide Web location:
- * http://sources.redhat.com/pthreads-win32/contributors.html
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library in the file COPYING.LIB;
- * if not, write to the Free Software Foundation, Inc.,
- * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
+ * https://sourceforge.net/p/pthreads4w/wiki/Contributors/
+ *
+ * This file is part of Pthreads4w.
+ *
+ * Pthreads4w is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * Pthreads4w is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Pthreads4w. If not, see <http://www.gnu.org/licenses/>. *
*/
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
#include "pthread.h"
#include "implement.h"
diff --git a/libs/pthreads/src/pthread_barrierattr_destroy.c b/libs/pthreads/src/pthread_barrierattr_destroy.c
index 5ab662e3f4..204b23ab47 100644
--- a/libs/pthreads/src/pthread_barrierattr_destroy.c
+++ b/libs/pthreads/src/pthread_barrierattr_destroy.c
@@ -6,34 +6,38 @@
*
* --------------------------------------------------------------------------
*
- * Pthreads-win32 - POSIX Threads Library for Win32
+ * Pthreads4w - POSIX Threads Library for Win32
* Copyright(C) 1998 John E. Bossom
- * Copyright(C) 1999,2005 Pthreads-win32 contributors
- *
- * Contact Email: rpj@callisto.canberra.edu.au
- *
+ * Copyright(C) 1999-2018, Pthreads4w contributors
+ *
+ * Homepage: https://sourceforge.net/projects/pthreads4w/
+ *
* The current list of contributors is contained
* in the file CONTRIBUTORS included with the source
* code distribution. The list can also be seen at the
* following World Wide Web location:
- * http://sources.redhat.com/pthreads-win32/contributors.html
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library in the file COPYING.LIB;
- * if not, write to the Free Software Foundation, Inc.,
- * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
+ * https://sourceforge.net/p/pthreads4w/wiki/Contributors/
+ *
+ * This file is part of Pthreads4w.
+ *
+ * Pthreads4w is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * Pthreads4w is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Pthreads4w. If not, see <http://www.gnu.org/licenses/>. *
*/
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
#include "pthread.h"
#include "implement.h"
diff --git a/libs/pthreads/src/pthread_barrierattr_getpshared.c b/libs/pthreads/src/pthread_barrierattr_getpshared.c
index 44c467e2bf..e34cc62bdb 100644
--- a/libs/pthreads/src/pthread_barrierattr_getpshared.c
+++ b/libs/pthreads/src/pthread_barrierattr_getpshared.c
@@ -6,34 +6,38 @@
*
* --------------------------------------------------------------------------
*
- * Pthreads-win32 - POSIX Threads Library for Win32
+ * Pthreads4w - POSIX Threads Library for Win32
* Copyright(C) 1998 John E. Bossom
- * Copyright(C) 1999,2005 Pthreads-win32 contributors
- *
- * Contact Email: rpj@callisto.canberra.edu.au
- *
+ * Copyright(C) 1999-2018, Pthreads4w contributors
+ *
+ * Homepage: https://sourceforge.net/projects/pthreads4w/
+ *
* The current list of contributors is contained
* in the file CONTRIBUTORS included with the source
* code distribution. The list can also be seen at the
* following World Wide Web location:
- * http://sources.redhat.com/pthreads-win32/contributors.html
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library in the file COPYING.LIB;
- * if not, write to the Free Software Foundation, Inc.,
- * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
+ * https://sourceforge.net/p/pthreads4w/wiki/Contributors/
+ *
+ * This file is part of Pthreads4w.
+ *
+ * Pthreads4w is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * Pthreads4w is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Pthreads4w. If not, see <http://www.gnu.org/licenses/>. *
*/
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
#include "pthread.h"
#include "implement.h"
diff --git a/libs/pthreads/src/pthread_barrierattr_init.c b/libs/pthreads/src/pthread_barrierattr_init.c
index 342f8b0c69..a6cb64634c 100644
--- a/libs/pthreads/src/pthread_barrierattr_init.c
+++ b/libs/pthreads/src/pthread_barrierattr_init.c
@@ -6,34 +6,38 @@
*
* --------------------------------------------------------------------------
*
- * Pthreads-win32 - POSIX Threads Library for Win32
+ * Pthreads4w - POSIX Threads Library for Win32
* Copyright(C) 1998 John E. Bossom
- * Copyright(C) 1999,2005 Pthreads-win32 contributors
- *
- * Contact Email: rpj@callisto.canberra.edu.au
- *
+ * Copyright(C) 1999-2018, Pthreads4w contributors
+ *
+ * Homepage: https://sourceforge.net/projects/pthreads4w/
+ *
* The current list of contributors is contained
* in the file CONTRIBUTORS included with the source
* code distribution. The list can also be seen at the
* following World Wide Web location:
- * http://sources.redhat.com/pthreads-win32/contributors.html
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library in the file COPYING.LIB;
- * if not, write to the Free Software Foundation, Inc.,
- * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
+ * https://sourceforge.net/p/pthreads4w/wiki/Contributors/
+ *
+ * This file is part of Pthreads4w.
+ *
+ * Pthreads4w is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * Pthreads4w is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Pthreads4w. If not, see <http://www.gnu.org/licenses/>. *
*/
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
#include "pthread.h"
#include "implement.h"
diff --git a/libs/pthreads/src/pthread_barrierattr_setpshared.c b/libs/pthreads/src/pthread_barrierattr_setpshared.c
index 08c6fde30b..36b0d3400e 100644
--- a/libs/pthreads/src/pthread_barrierattr_setpshared.c
+++ b/libs/pthreads/src/pthread_barrierattr_setpshared.c
@@ -6,34 +6,38 @@
*
* --------------------------------------------------------------------------
*
- * Pthreads-win32 - POSIX Threads Library for Win32
+ * Pthreads4w - POSIX Threads Library for Win32
* Copyright(C) 1998 John E. Bossom
- * Copyright(C) 1999,2005 Pthreads-win32 contributors
- *
- * Contact Email: rpj@callisto.canberra.edu.au
- *
+ * Copyright(C) 1999-2018, Pthreads4w contributors
+ *
+ * Homepage: https://sourceforge.net/projects/pthreads4w/
+ *
* The current list of contributors is contained
* in the file CONTRIBUTORS included with the source
* code distribution. The list can also be seen at the
* following World Wide Web location:
- * http://sources.redhat.com/pthreads-win32/contributors.html
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library in the file COPYING.LIB;
- * if not, write to the Free Software Foundation, Inc.,
- * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
+ * https://sourceforge.net/p/pthreads4w/wiki/Contributors/
+ *
+ * This file is part of Pthreads4w.
+ *
+ * Pthreads4w is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * Pthreads4w is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Pthreads4w. If not, see <http://www.gnu.org/licenses/>. *
*/
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
#include "pthread.h"
#include "implement.h"
diff --git a/libs/pthreads/src/pthread_cancel.c b/libs/pthreads/src/pthread_cancel.c
index ae60b72936..aa8c0a4818 100644
--- a/libs/pthreads/src/pthread_cancel.c
+++ b/libs/pthreads/src/pthread_cancel.c
@@ -6,34 +6,38 @@
*
* --------------------------------------------------------------------------
*
- * Pthreads-win32 - POSIX Threads Library for Win32
+ * Pthreads4w - POSIX Threads Library for Win32
* Copyright(C) 1998 John E. Bossom
- * Copyright(C) 1999,2005 Pthreads-win32 contributors
- *
- * Contact Email: rpj@callisto.canberra.edu.au
- *
+ * Copyright(C) 1999-2018, Pthreads4w contributors
+ *
+ * Homepage: https://sourceforge.net/projects/pthreads4w/
+ *
* The current list of contributors is contained
* in the file CONTRIBUTORS included with the source
* code distribution. The list can also be seen at the
* following World Wide Web location:
- * http://sources.redhat.com/pthreads-win32/contributors.html
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library in the file COPYING.LIB;
- * if not, write to the Free Software Foundation, Inc.,
- * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
+ * https://sourceforge.net/p/pthreads4w/wiki/Contributors/
+ *
+ * This file is part of Pthreads4w.
+ *
+ * Pthreads4w is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * Pthreads4w is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Pthreads4w. If not, see <http://www.gnu.org/licenses/>. *
*/
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
#include "pthread.h"
#include "implement.h"
#include "context.h"
@@ -55,12 +59,12 @@ ptw32_cancel_callback (ULONG_PTR unused)
}
/*
- * ptw32_RegisterCancelation() -
+ * ptw32_Registercancellation() -
* Must have args of same type as QueueUserAPCEx because this function
* is a substitute for QueueUserAPCEx if it's not available.
*/
DWORD
-ptw32_RegisterCancelation (PAPCFUNC unused1, HANDLE threadH, DWORD unused2)
+ptw32_Registercancellation (PAPCFUNC unused1, HANDLE threadH, DWORD unused2)
{
CONTEXT context;
@@ -101,8 +105,12 @@ pthread_cancel (pthread_t thread)
ptw32_thread_t * tp;
ptw32_mcs_local_node_t stateLock;
+ /*
+ * Validate the thread id. This method works for Pthreads4w because
+ * pthread_kill and pthread_t are designed to accommodate it, but the
+ * method is not portable.
+ */
result = pthread_kill (thread, 0);
-
if (0 != result)
{
return result;
@@ -155,10 +163,10 @@ pthread_cancel (pthread_t thread)
/*
* If alertdrv and QueueUserAPCEx is available then the following
* will result in a call to QueueUserAPCEx with the args given, otherwise
- * this will result in a call to ptw32_RegisterCancelation and only
+ * this will result in a call to ptw32_Registercancellation and only
* the threadH arg will be used.
*/
- ptw32_register_cancelation ((PAPCFUNC)ptw32_cancel_callback, threadH, 0);
+ ptw32_register_cancellation ((PAPCFUNC)ptw32_cancel_callback, threadH, 0);
ptw32_mcs_lock_release (&stateLock);
ResumeThread (threadH);
}
diff --git a/libs/pthreads/src/pthread_cond_destroy.c b/libs/pthreads/src/pthread_cond_destroy.c
index 40d4a0896c..9fa196fa3d 100644
--- a/libs/pthreads/src/pthread_cond_destroy.c
+++ b/libs/pthreads/src/pthread_cond_destroy.c
@@ -7,34 +7,38 @@
*
* --------------------------------------------------------------------------
*
- * Pthreads-win32 - POSIX Threads Library for Win32
+ * Pthreads4w - POSIX Threads Library for Win32
* Copyright(C) 1998 John E. Bossom
- * Copyright(C) 1999,2005 Pthreads-win32 contributors
- *
- * Contact Email: rpj@callisto.canberra.edu.au
- *
+ * Copyright(C) 1999-2018, Pthreads4w contributors
+ *
+ * Homepage: https://sourceforge.net/projects/pthreads4w/
+ *
* The current list of contributors is contained
* in the file CONTRIBUTORS included with the source
* code distribution. The list can also be seen at the
* following World Wide Web location:
- * http://sources.redhat.com/pthreads-win32/contributors.html
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library in the file COPYING.LIB;
- * if not, write to the Free Software Foundation, Inc.,
- * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
+ * https://sourceforge.net/p/pthreads4w/wiki/Contributors/
+ *
+ * This file is part of Pthreads4w.
+ *
+ * Pthreads4w is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * Pthreads4w is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Pthreads4w. If not, see <http://www.gnu.org/licenses/>. *
*/
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
#include "pthread.h"
#include "implement.h"
@@ -138,7 +142,7 @@ pthread_cond_destroy (pthread_cond_t * cond)
*/
if (ptw32_semwait (&(cv->semBlockLock)) != 0) /* Non-cancelable */
{
- result = errno;
+ result = PTW32_GET_ERRNO();
}
else
{
@@ -166,7 +170,7 @@ pthread_cond_destroy (pthread_cond_t * cond)
{
if (sem_post (&(cv->semBlockLock)) != 0)
{
- result = errno;
+ result = PTW32_GET_ERRNO();
}
result1 = pthread_mutex_unlock (&(cv->mtxUnblockLock));
result2 = EBUSY;
@@ -180,11 +184,11 @@ pthread_cond_destroy (pthread_cond_t * cond)
if (sem_destroy (&(cv->semBlockLock)) != 0)
{
- result = errno;
+ result = PTW32_GET_ERRNO();
}
if (sem_destroy (&(cv->semBlockQueue)) != 0)
{
- result1 = errno;
+ result1 = PTW32_GET_ERRNO();
}
if ((result2 = pthread_mutex_unlock (&(cv->mtxUnblockLock))) == 0)
{
diff --git a/libs/pthreads/src/pthread_cond_init.c b/libs/pthreads/src/pthread_cond_init.c
index f28fd67b43..0233bd5f4c 100644
--- a/libs/pthreads/src/pthread_cond_init.c
+++ b/libs/pthreads/src/pthread_cond_init.c
@@ -7,34 +7,38 @@
*
* --------------------------------------------------------------------------
*
- * Pthreads-win32 - POSIX Threads Library for Win32
+ * Pthreads4w - POSIX Threads Library for Win32
* Copyright(C) 1998 John E. Bossom
- * Copyright(C) 1999,2005 Pthreads-win32 contributors
- *
- * Contact Email: rpj@callisto.canberra.edu.au
- *
+ * Copyright(C) 1999-2018, Pthreads4w contributors
+ *
+ * Homepage: https://sourceforge.net/projects/pthreads4w/
+ *
* The current list of contributors is contained
* in the file CONTRIBUTORS included with the source
* code distribution. The list can also be seen at the
* following World Wide Web location:
- * http://sources.redhat.com/pthreads-win32/contributors.html
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library in the file COPYING.LIB;
- * if not, write to the Free Software Foundation, Inc.,
- * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
+ * https://sourceforge.net/p/pthreads4w/wiki/Contributors/
+ *
+ * This file is part of Pthreads4w.
+ *
+ * Pthreads4w is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * Pthreads4w is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Pthreads4w. If not, see <http://www.gnu.org/licenses/>. *
*/
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
#include "pthread.h"
#include "implement.h"
@@ -101,13 +105,13 @@ pthread_cond_init (pthread_cond_t * cond, const pthread_condattr_t * attr)
if (sem_init (&(cv->semBlockLock), 0, 1) != 0)
{
- result = errno;
+ result = PTW32_GET_ERRNO();
goto FAIL0;
}
if (sem_init (&(cv->semBlockQueue), 0, 0) != 0)
{
- result = errno;
+ result = PTW32_GET_ERRNO();
goto FAIL1;
}
diff --git a/libs/pthreads/src/pthread_cond_signal.c b/libs/pthreads/src/pthread_cond_signal.c
index 2b4f6d4d44..a7dd4af4da 100644
--- a/libs/pthreads/src/pthread_cond_signal.c
+++ b/libs/pthreads/src/pthread_cond_signal.c
@@ -7,38 +7,42 @@
*
* --------------------------------------------------------------------------
*
- * Pthreads-win32 - POSIX Threads Library for Win32
+ * Pthreads4w - POSIX Threads Library for Win32
* Copyright(C) 1998 John E. Bossom
- * Copyright(C) 1999,2005 Pthreads-win32 contributors
- *
- * Contact Email: rpj@callisto.canberra.edu.au
- *
+ * Copyright(C) 1999-2018, Pthreads4w contributors
+ *
+ * Homepage: https://sourceforge.net/projects/pthreads4w/
+ *
* The current list of contributors is contained
* in the file CONTRIBUTORS included with the source
* code distribution. The list can also be seen at the
* following World Wide Web location:
- * http://sources.redhat.com/pthreads-win32/contributors.html
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library in the file COPYING.LIB;
- * if not, write to the Free Software Foundation, Inc.,
- * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
+ * https://sourceforge.net/p/pthreads4w/wiki/Contributors/
+ *
+ * This file is part of Pthreads4w.
+ *
+ * Pthreads4w is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * Pthreads4w is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Pthreads4w. If not, see <http://www.gnu.org/licenses/>. *
*
* -------------------------------------------------------------
* Algorithm:
* See the comments at the top of pthread_cond_wait.c.
*/
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
#include "pthread.h"
#include "implement.h"
@@ -112,7 +116,7 @@ ptw32_cond_unblock (pthread_cond_t * cond, int unblockAll)
/* Use the non-cancellable version of sem_wait() */
if (ptw32_semwait (&(cv->semBlockLock)) != 0)
{
- result = errno;
+ result = PTW32_GET_ERRNO();
(void) pthread_mutex_unlock (&(cv->mtxUnblockLock));
return result;
}
@@ -141,7 +145,7 @@ ptw32_cond_unblock (pthread_cond_t * cond, int unblockAll)
{
if (sem_post_multiple (&(cv->semBlockQueue), nSignalsToIssue) != 0)
{
- result = errno;
+ result = PTW32_GET_ERRNO();
}
}
diff --git a/libs/pthreads/src/pthread_cond_wait.c b/libs/pthreads/src/pthread_cond_wait.c
index 359219ae9b..06d3ee30f7 100644
--- a/libs/pthreads/src/pthread_cond_wait.c
+++ b/libs/pthreads/src/pthread_cond_wait.c
@@ -7,32 +7,32 @@
*
* --------------------------------------------------------------------------
*
- * Pthreads-win32 - POSIX Threads Library for Win32
+ * Pthreads4w - POSIX Threads Library for Win32
* Copyright(C) 1998 John E. Bossom
- * Copyright(C) 1999,2005 Pthreads-win32 contributors
- *
- * Contact Email: rpj@callisto.canberra.edu.au
- *
+ * Copyright(C) 1999-2018, Pthreads4w contributors
+ *
+ * Homepage: https://sourceforge.net/projects/pthreads4w/
+ *
* The current list of contributors is contained
* in the file CONTRIBUTORS included with the source
* code distribution. The list can also be seen at the
* following World Wide Web location:
- * http://sources.redhat.com/pthreads-win32/contributors.html
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library in the file COPYING.LIB;
- * if not, write to the Free Software Foundation, Inc.,
- * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
+ * https://sourceforge.net/p/pthreads4w/wiki/Contributors/
+ *
+ * This file is part of Pthreads4w.
+ *
+ * Pthreads4w is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * Pthreads4w is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Pthreads4w. If not, see <http://www.gnu.org/licenses/>. *
*
* -------------------------------------------------------------
* Algorithm:
@@ -255,9 +255,12 @@
* return result;
* }
* -------------------------------------------------------------
- *
*/
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
#include "pthread.h"
#include "implement.h"
@@ -303,7 +306,7 @@ ptw32_cond_wait_cleanup (void *args)
/* Use the non-cancellable version of sem_wait() */
if (ptw32_semwait (&(cv->semBlockLock)) != 0)
{
- *resultPtr = errno;
+ *resultPtr = PTW32_GET_ERRNO();
/*
* This is a fatal error for this CV,
* so we deliberately don't unlock
@@ -314,7 +317,7 @@ ptw32_cond_wait_cleanup (void *args)
cv->nWaitersBlocked -= cv->nWaitersGone;
if (sem_post (&(cv->semBlockLock)) != 0)
{
- *resultPtr = errno;
+ *resultPtr = PTW32_GET_ERRNO();
/*
* This is a fatal error for this CV,
* so we deliberately don't unlock
@@ -335,7 +338,7 @@ ptw32_cond_wait_cleanup (void *args)
{
if (sem_post (&(cv->semBlockLock)) != 0)
{
- *resultPtr = errno;
+ *resultPtr = PTW32_GET_ERRNO();
return;
}
}
@@ -384,14 +387,14 @@ ptw32_cond_timedwait (pthread_cond_t * cond,
/* Thread can be cancelled in sem_wait() but this is OK */
if (sem_wait (&(cv->semBlockLock)) != 0)
{
- return errno;
+ return PTW32_GET_ERRNO();
}
++(cv->nWaitersBlocked);
if (sem_post (&(cv->semBlockLock)) != 0)
{
- return errno;
+ return PTW32_GET_ERRNO();
}
/*
@@ -401,7 +404,7 @@ ptw32_cond_timedwait (pthread_cond_t * cond,
cleanup_args.cv = cv;
cleanup_args.resultPtr = &result;
-#if defined(_MSC_VER) && _MSC_VER < 1400
+#if defined(PTW32_CONFIG_MSVC7)
#pragma inline_depth(0)
#endif
pthread_cleanup_push (ptw32_cond_wait_cleanup, (void *) &cleanup_args);
@@ -430,7 +433,7 @@ ptw32_cond_timedwait (pthread_cond_t * cond,
*/
if (sem_timedwait (&(cv->semBlockQueue), abstime) != 0)
{
- result = errno;
+ result = PTW32_GET_ERRNO();
}
}
@@ -438,7 +441,7 @@ ptw32_cond_timedwait (pthread_cond_t * cond,
* Always cleanup
*/
pthread_cleanup_pop (1);
-#if defined(_MSC_VER) && _MSC_VER < 1400
+#if defined(PTW32_CONFIG_MSVC7)
#pragma inline_depth()
#endif
diff --git a/libs/pthreads/src/pthread_condattr_destroy.c b/libs/pthreads/src/pthread_condattr_destroy.c
index 58a14828fd..85d871235b 100644
--- a/libs/pthreads/src/pthread_condattr_destroy.c
+++ b/libs/pthreads/src/pthread_condattr_destroy.c
@@ -7,34 +7,38 @@
*
* --------------------------------------------------------------------------
*
- * Pthreads-win32 - POSIX Threads Library for Win32
+ * Pthreads4w - POSIX Threads Library for Win32
* Copyright(C) 1998 John E. Bossom
- * Copyright(C) 1999,2005 Pthreads-win32 contributors
- *
- * Contact Email: rpj@callisto.canberra.edu.au
- *
+ * Copyright(C) 1999-2018, Pthreads4w contributors
+ *
+ * Homepage: https://sourceforge.net/projects/pthreads4w/
+ *
* The current list of contributors is contained
* in the file CONTRIBUTORS included with the source
* code distribution. The list can also be seen at the
* following World Wide Web location:
- * http://sources.redhat.com/pthreads-win32/contributors.html
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library in the file COPYING.LIB;
- * if not, write to the Free Software Foundation, Inc.,
- * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
+ * https://sourceforge.net/p/pthreads4w/wiki/Contributors/
+ *
+ * This file is part of Pthreads4w.
+ *
+ * Pthreads4w is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * Pthreads4w is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Pthreads4w. If not, see <http://www.gnu.org/licenses/>. *
*/
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
#include "pthread.h"
#include "implement.h"
diff --git a/libs/pthreads/src/pthread_condattr_getpshared.c b/libs/pthreads/src/pthread_condattr_getpshared.c
index a0ac6d8829..e4168c596e 100644
--- a/libs/pthreads/src/pthread_condattr_getpshared.c
+++ b/libs/pthreads/src/pthread_condattr_getpshared.c
@@ -7,34 +7,38 @@
*
* --------------------------------------------------------------------------
*
- * Pthreads-win32 - POSIX Threads Library for Win32
+ * Pthreads4w - POSIX Threads Library for Win32
* Copyright(C) 1998 John E. Bossom
- * Copyright(C) 1999,2005 Pthreads-win32 contributors
- *
- * Contact Email: rpj@callisto.canberra.edu.au
- *
+ * Copyright(C) 1999-2018, Pthreads4w contributors
+ *
+ * Homepage: https://sourceforge.net/projects/pthreads4w/
+ *
* The current list of contributors is contained
* in the file CONTRIBUTORS included with the source
* code distribution. The list can also be seen at the
* following World Wide Web location:
- * http://sources.redhat.com/pthreads-win32/contributors.html
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library in the file COPYING.LIB;
- * if not, write to the Free Software Foundation, Inc.,
- * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
+ * https://sourceforge.net/p/pthreads4w/wiki/Contributors/
+ *
+ * This file is part of Pthreads4w.
+ *
+ * Pthreads4w is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * Pthreads4w is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Pthreads4w. If not, see <http://www.gnu.org/licenses/>. *
*/
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
#include "pthread.h"
#include "implement.h"
diff --git a/libs/pthreads/src/pthread_condattr_init.c b/libs/pthreads/src/pthread_condattr_init.c
index 5987878e0c..4bda44a63b 100644
--- a/libs/pthreads/src/pthread_condattr_init.c
+++ b/libs/pthreads/src/pthread_condattr_init.c
@@ -7,34 +7,38 @@
*
* --------------------------------------------------------------------------
*
- * Pthreads-win32 - POSIX Threads Library for Win32
+ * Pthreads4w - POSIX Threads Library for Win32
* Copyright(C) 1998 John E. Bossom
- * Copyright(C) 1999,2005 Pthreads-win32 contributors
- *
- * Contact Email: rpj@callisto.canberra.edu.au
- *
+ * Copyright(C) 1999-2018, Pthreads4w contributors
+ *
+ * Homepage: https://sourceforge.net/projects/pthreads4w/
+ *
* The current list of contributors is contained
* in the file CONTRIBUTORS included with the source
* code distribution. The list can also be seen at the
* following World Wide Web location:
- * http://sources.redhat.com/pthreads-win32/contributors.html
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library in the file COPYING.LIB;
- * if not, write to the Free Software Foundation, Inc.,
- * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
+ * https://sourceforge.net/p/pthreads4w/wiki/Contributors/
+ *
+ * This file is part of Pthreads4w.
+ *
+ * Pthreads4w is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * Pthreads4w is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Pthreads4w. If not, see <http://www.gnu.org/licenses/>. *
*/
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
#include "pthread.h"
#include "implement.h"
diff --git a/libs/pthreads/src/pthread_condattr_setpshared.c b/libs/pthreads/src/pthread_condattr_setpshared.c
index 954fb38299..6c5f848254 100644
--- a/libs/pthreads/src/pthread_condattr_setpshared.c
+++ b/libs/pthreads/src/pthread_condattr_setpshared.c
@@ -7,34 +7,38 @@
*
* --------------------------------------------------------------------------
*
- * Pthreads-win32 - POSIX Threads Library for Win32
+ * Pthreads4w - POSIX Threads Library for Win32
* Copyright(C) 1998 John E. Bossom
- * Copyright(C) 1999,2005 Pthreads-win32 contributors
- *
- * Contact Email: rpj@callisto.canberra.edu.au
- *
+ * Copyright(C) 1999-2018, Pthreads4w contributors
+ *
+ * Homepage: https://sourceforge.net/projects/pthreads4w/
+ *
* The current list of contributors is contained
* in the file CONTRIBUTORS included with the source
* code distribution. The list can also be seen at the
* following World Wide Web location:
- * http://sources.redhat.com/pthreads-win32/contributors.html
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library in the file COPYING.LIB;
- * if not, write to the Free Software Foundation, Inc.,
- * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
+ * https://sourceforge.net/p/pthreads4w/wiki/Contributors/
+ *
+ * This file is part of Pthreads4w.
+ *
+ * Pthreads4w is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * Pthreads4w is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Pthreads4w. If not, see <http://www.gnu.org/licenses/>. *
*/
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
#include "pthread.h"
#include "implement.h"
diff --git a/libs/pthreads/src/pthread_delay_np.c b/libs/pthreads/src/pthread_delay_np.c
index e6c96d8070..c6d0999ff6 100644
--- a/libs/pthreads/src/pthread_delay_np.c
+++ b/libs/pthreads/src/pthread_delay_np.c
@@ -6,34 +6,38 @@
*
* --------------------------------------------------------------------------
*
- * Pthreads-win32 - POSIX Threads Library for Win32
+ * Pthreads4w - POSIX Threads Library for Win32
* Copyright(C) 1998 John E. Bossom
- * Copyright(C) 1999,2005 Pthreads-win32 contributors
- *
- * Contact Email: rpj@callisto.canberra.edu.au
- *
+ * Copyright(C) 1999-2018, Pthreads4w contributors
+ *
+ * Homepage: https://sourceforge.net/projects/pthreads4w/
+ *
* The current list of contributors is contained
* in the file CONTRIBUTORS included with the source
* code distribution. The list can also be seen at the
* following World Wide Web location:
- * http://sources.redhat.com/pthreads-win32/contributors.html
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library in the file COPYING.LIB;
- * if not, write to the Free Software Foundation, Inc.,
- * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
+ * https://sourceforge.net/p/pthreads4w/wiki/Contributors/
+ *
+ * This file is part of Pthreads4w.
+ *
+ * Pthreads4w is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * Pthreads4w is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Pthreads4w. If not, see <http://www.gnu.org/licenses/>. *
*/
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
#include "pthread.h"
#include "implement.h"
@@ -50,7 +54,7 @@
*
* Specifying an interval of zero (0) seconds and zero (0) nanoseconds is
* allowed and can be used to force the thread to give up the processor or to
- * deliver a pending cancelation request.
+ * deliver a pending cancellation request.
*
* The timespec structure contains the following two fields:
*
@@ -135,8 +139,8 @@ pthread_delay_np (struct timespec *interval)
if (sp->cancelState == PTHREAD_CANCEL_ENABLE)
{
/*
- * Async cancelation won't catch us until wait_time is up.
- * Deferred cancelation will cancel us immediately.
+ * Async cancellation won't catch us until wait_time is up.
+ * Deferred cancellation will cancel us immediately.
*/
if (WAIT_OBJECT_0 ==
(status = WaitForSingleObject (sp->cancelEvent, wait_time)))
diff --git a/libs/pthreads/src/pthread_detach.c b/libs/pthreads/src/pthread_detach.c
index 9ff6587f3c..3bbe4a11b2 100644
--- a/libs/pthreads/src/pthread_detach.c
+++ b/libs/pthreads/src/pthread_detach.c
@@ -7,34 +7,38 @@
*
* --------------------------------------------------------------------------
*
- * Pthreads-win32 - POSIX Threads Library for Win32
+ * Pthreads4w - POSIX Threads Library for Win32
* Copyright(C) 1998 John E. Bossom
- * Copyright(C) 1999,2005 Pthreads-win32 contributors
- *
- * Contact Email: rpj@callisto.canberra.edu.au
- *
+ * Copyright(C) 1999-2018, Pthreads4w contributors
+ *
+ * Homepage: https://sourceforge.net/projects/pthreads4w/
+ *
* The current list of contributors is contained
* in the file CONTRIBUTORS included with the source
* code distribution. The list can also be seen at the
* following World Wide Web location:
- * http://sources.redhat.com/pthreads-win32/contributors.html
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library in the file COPYING.LIB;
- * if not, write to the Free Software Foundation, Inc.,
- * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
+ * https://sourceforge.net/p/pthreads4w/wiki/Contributors/
+ *
+ * This file is part of Pthreads4w.
+ *
+ * Pthreads4w is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * Pthreads4w is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Pthreads4w. If not, see <http://www.gnu.org/licenses/>. *
*/
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
#include "pthread.h"
#include "implement.h"
@@ -77,9 +81,9 @@ pthread_detach (pthread_t thread)
int result;
BOOL destroyIt = PTW32_FALSE;
ptw32_thread_t * tp = (ptw32_thread_t *) thread.p;
- ptw32_mcs_local_node_t node;
+ ptw32_mcs_local_node_t reuseLock;
- ptw32_mcs_lock_acquire(&ptw32_thread_reuse_lock, &node);
+ ptw32_mcs_lock_acquire(&ptw32_thread_reuse_lock, &reuseLock);
if (NULL == tp
|| thread.x != tp->ptHandle.x)
@@ -101,9 +105,13 @@ pthread_detach (pthread_t thread)
result = 0;
ptw32_mcs_lock_acquire (&tp->stateLock, &stateLock);
- if (tp->state != PThreadStateLast)
+ if (tp->state < PThreadStateLast)
{
tp->detachState = PTHREAD_CREATE_DETACHED;
+ if (tp->state == PThreadStateExiting)
+ {
+ destroyIt = PTW32_TRUE;
+ }
}
else if (tp->detachState != PTHREAD_CREATE_DETACHED)
{
@@ -115,7 +123,7 @@ pthread_detach (pthread_t thread)
ptw32_mcs_lock_release (&stateLock);
}
- ptw32_mcs_lock_release(&node);
+ ptw32_mcs_lock_release(&reuseLock);
if (result == 0)
{
diff --git a/libs/pthreads/src/pthread_equal.c b/libs/pthreads/src/pthread_equal.c
index 5ddd82acba..938a5f0fb6 100644
--- a/libs/pthreads/src/pthread_equal.c
+++ b/libs/pthreads/src/pthread_equal.c
@@ -6,34 +6,38 @@
*
* --------------------------------------------------------------------------
*
- * Pthreads-win32 - POSIX Threads Library for Win32
+ * Pthreads4w - POSIX Threads Library for Win32
* Copyright(C) 1998 John E. Bossom
- * Copyright(C) 1999,2005 Pthreads-win32 contributors
- *
- * Contact Email: rpj@callisto.canberra.edu.au
- *
+ * Copyright(C) 1999-2018, Pthreads4w contributors
+ *
+ * Homepage: https://sourceforge.net/projects/pthreads4w/
+ *
* The current list of contributors is contained
* in the file CONTRIBUTORS included with the source
* code distribution. The list can also be seen at the
* following World Wide Web location:
- * http://sources.redhat.com/pthreads-win32/contributors.html
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library in the file COPYING.LIB;
- * if not, write to the Free Software Foundation, Inc.,
- * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
+ * https://sourceforge.net/p/pthreads4w/wiki/Contributors/
+ *
+ * This file is part of Pthreads4w.
+ *
+ * Pthreads4w is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * Pthreads4w is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Pthreads4w. If not, see <http://www.gnu.org/licenses/>. *
*/
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
#include "pthread.h"
#include "implement.h"
diff --git a/libs/pthreads/src/pthread_exit.c b/libs/pthreads/src/pthread_exit.c
index 37b3c09902..b09ea015be 100644
--- a/libs/pthreads/src/pthread_exit.c
+++ b/libs/pthreads/src/pthread_exit.c
@@ -7,34 +7,38 @@
*
* --------------------------------------------------------------------------
*
- * Pthreads-win32 - POSIX Threads Library for Win32
+ * Pthreads4w - POSIX Threads Library for Win32
* Copyright(C) 1998 John E. Bossom
- * Copyright(C) 1999,2005 Pthreads-win32 contributors
- *
- * Contact Email: rpj@callisto.canberra.edu.au
- *
+ * Copyright(C) 1999-2018, Pthreads4w contributors
+ *
+ * Homepage: https://sourceforge.net/projects/pthreads4w/
+ *
* The current list of contributors is contained
* in the file CONTRIBUTORS included with the source
* code distribution. The list can also be seen at the
* following World Wide Web location:
- * http://sources.redhat.com/pthreads-win32/contributors.html
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library in the file COPYING.LIB;
- * if not, write to the Free Software Foundation, Inc.,
- * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
+ * https://sourceforge.net/p/pthreads4w/wiki/Contributors/
+ *
+ * This file is part of Pthreads4w.
+ *
+ * Pthreads4w is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * Pthreads4w is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Pthreads4w. If not, see <http://www.gnu.org/licenses/>. *
*/
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
#include "pthread.h"
#include "implement.h"
#if !defined(_UWIN)
@@ -82,13 +86,13 @@ pthread_exit (void *value_ptr)
{
/*
* A POSIX thread handle was never created. I.e. this is a
- * Win32 thread that has never called a pthreads-win32 routine that
+ * Win32 thread that has never called a Pthreads4w routine that
* required a POSIX handle.
*
* Implicit POSIX handles are cleaned up in ptw32_throw() now.
*/
-#if ! (defined (__MINGW64__) || defined(__MINGW32__)) || defined (__MSVCRT__) || defined (__DMC__)
+#if ! defined (__MINGW32__) || defined (__MSVCRT__) || defined (__DMC__)
_endthreadex ((unsigned) (size_t) value_ptr);
#else
_endthread ();
diff --git a/libs/pthreads/src/pthread_getconcurrency.c b/libs/pthreads/src/pthread_getconcurrency.c
index cf9e9c85c2..e8ec83799d 100644
--- a/libs/pthreads/src/pthread_getconcurrency.c
+++ b/libs/pthreads/src/pthread_getconcurrency.c
@@ -6,34 +6,38 @@
*
* --------------------------------------------------------------------------
*
- * Pthreads-win32 - POSIX Threads Library for Win32
+ * Pthreads4w - POSIX Threads Library for Win32
* Copyright(C) 1998 John E. Bossom
- * Copyright(C) 1999,2005 Pthreads-win32 contributors
- *
- * Contact Email: rpj@callisto.canberra.edu.au
- *
+ * Copyright(C) 1999-2018, Pthreads4w contributors
+ *
+ * Homepage: https://sourceforge.net/projects/pthreads4w/
+ *
* The current list of contributors is contained
* in the file CONTRIBUTORS included with the source
* code distribution. The list can also be seen at the
* following World Wide Web location:
- * http://sources.redhat.com/pthreads-win32/contributors.html
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library in the file COPYING.LIB;
- * if not, write to the Free Software Foundation, Inc.,
- * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
+ * https://sourceforge.net/p/pthreads4w/wiki/Contributors/
+ *
+ * This file is part of Pthreads4w.
+ *
+ * Pthreads4w is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * Pthreads4w is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Pthreads4w. If not, see <http://www.gnu.org/licenses/>. *
*/
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
#include "pthread.h"
#include "implement.h"
diff --git a/libs/pthreads/src/pthread_getname_np.c b/libs/pthreads/src/pthread_getname_np.c
new file mode 100644
index 0000000000..2f7fb07d32
--- /dev/null
+++ b/libs/pthreads/src/pthread_getname_np.c
@@ -0,0 +1,71 @@
+/*
+ * pthread_getname_np.c
+ *
+ * --------------------------------------------------------------------------
+ *
+ * Pthreads4w - POSIX Threads Library for Win32
+ * Copyright(C) 1998 John E. Bossom
+ * Copyright(C) 1999-2018, Pthreads4w contributors
+ *
+ * Homepage: https://sourceforge.net/projects/pthreads4w/
+ *
+ * The current list of contributors is contained
+ * in the file CONTRIBUTORS included with the source
+ * code distribution. The list can also be seen at the
+ * following World Wide Web location:
+ * https://sourceforge.net/p/pthreads4w/wiki/Contributors/
+ *
+ * This file is part of Pthreads4w.
+ *
+ * Pthreads4w is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * Pthreads4w is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Pthreads4w. If not, see <http://www.gnu.org/licenses/>. *
+ */
+
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
+#include "pthread.h"
+#include "implement.h"
+
+int
+pthread_getname_np(pthread_t thr, char *name, int len)
+{
+ ptw32_mcs_local_node_t threadLock;
+ ptw32_thread_t * tp;
+ char * s, * d;
+ int result;
+
+ /*
+ * Validate the thread id. This method works for Pthreads4w because
+ * pthread_kill and pthread_t are designed to accommodate it, but the
+ * method is not portable.
+ */
+ result = pthread_kill (thr, 0);
+ if (0 != result)
+ {
+ return result;
+ }
+
+ tp = (ptw32_thread_t *) thr.p;
+
+ ptw32_mcs_lock_acquire (&tp->threadLock, &threadLock);
+
+ for (s = tp->name, d = name; *s && d < &name[len - 1]; *d++ = *s++)
+ {}
+
+ *d = '\0';
+ ptw32_mcs_lock_release (&threadLock);
+
+ return result;
+}
diff --git a/libs/pthreads/src/pthread_getschedparam.c b/libs/pthreads/src/pthread_getschedparam.c
index 0afcfb74a9..05490fc114 100644
--- a/libs/pthreads/src/pthread_getschedparam.c
+++ b/libs/pthreads/src/pthread_getschedparam.c
@@ -1,39 +1,43 @@
/*
* sched_getschedparam.c
- *
+ *
* Description:
* POSIX thread functions that deal with thread scheduling.
*
* --------------------------------------------------------------------------
*
- * Pthreads-win32 - POSIX Threads Library for Win32
+ * Pthreads4w - POSIX Threads Library for Win32
* Copyright(C) 1998 John E. Bossom
- * Copyright(C) 1999,2005 Pthreads-win32 contributors
- *
- * Contact Email: rpj@callisto.canberra.edu.au
- *
+ * Copyright(C) 1999-2018, Pthreads4w contributors
+ *
+ * Homepage: https://sourceforge.net/projects/pthreads4w/
+ *
* The current list of contributors is contained
* in the file CONTRIBUTORS included with the source
* code distribution. The list can also be seen at the
* following World Wide Web location:
- * http://sources.redhat.com/pthreads-win32/contributors.html
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library in the file COPYING.LIB;
- * if not, write to the Free Software Foundation, Inc.,
- * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
+ * https://sourceforge.net/p/pthreads4w/wiki/Contributors/
+ *
+ * This file is part of Pthreads4w.
+ *
+ * Pthreads4w is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * Pthreads4w is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Pthreads4w. If not, see <http://www.gnu.org/licenses/>. *
*/
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
#include "pthread.h"
#include "implement.h"
#include "sched.h"
@@ -44,18 +48,18 @@ pthread_getschedparam (pthread_t thread, int *policy,
{
int result;
- /* Validate the thread id. */
+ /*
+ * Validate the thread id. This method works for Pthreads4w because
+ * pthread_kill and pthread_t are designed to accommodate it, but the
+ * method is not portable.
+ */
result = pthread_kill (thread, 0);
if (0 != result)
{
return result;
}
- /*
- * Validate the policy and param args.
- * Check that a policy constant wasn't passed rather than &policy.
- */
- if (policy <= (int *) SCHED_MAX || param == NULL)
+ if (policy == NULL)
{
return EINVAL;
}
diff --git a/libs/pthreads/src/pthread_getspecific.c b/libs/pthreads/src/pthread_getspecific.c
index 5ee1641dc1..9a4c131c32 100644
--- a/libs/pthreads/src/pthread_getspecific.c
+++ b/libs/pthreads/src/pthread_getspecific.c
@@ -6,34 +6,38 @@
*
* --------------------------------------------------------------------------
*
- * Pthreads-win32 - POSIX Threads Library for Win32
+ * Pthreads4w - POSIX Threads Library for Win32
* Copyright(C) 1998 John E. Bossom
- * Copyright(C) 1999,2005 Pthreads-win32 contributors
- *
- * Contact Email: rpj@callisto.canberra.edu.au
- *
+ * Copyright(C) 1999-2018, Pthreads4w contributors
+ *
+ * Homepage: https://sourceforge.net/projects/pthreads4w/
+ *
* The current list of contributors is contained
* in the file CONTRIBUTORS included with the source
* code distribution. The list can also be seen at the
* following World Wide Web location:
- * http://sources.redhat.com/pthreads-win32/contributors.html
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library in the file COPYING.LIB;
- * if not, write to the Free Software Foundation, Inc.,
- * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
+ * https://sourceforge.net/p/pthreads4w/wiki/Contributors/
+ *
+ * This file is part of Pthreads4w.
+ *
+ * Pthreads4w is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * Pthreads4w is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Pthreads4w. If not, see <http://www.gnu.org/licenses/>. *
*/
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
#include "pthread.h"
#include "implement.h"
diff --git a/libs/pthreads/src/pthread_getunique_np.c b/libs/pthreads/src/pthread_getunique_np.c
index 4496c68bf5..2692d8bacc 100644
--- a/libs/pthreads/src/pthread_getunique_np.c
+++ b/libs/pthreads/src/pthread_getunique_np.c
@@ -6,34 +6,38 @@
*
* --------------------------------------------------------------------------
*
- * Pthreads-win32 - POSIX Threads Library for Win32
+ * Pthreads4w - POSIX Threads Library for Win32
* Copyright(C) 1998 John E. Bossom
- * Copyright(C) 1999,2005 Pthreads-win32 contributors
- *
- * Contact Email: rpj@callisto.canberra.edu.au
- *
+ * Copyright(C) 1999-2018, Pthreads4w contributors
+ *
+ * Homepage: https://sourceforge.net/projects/pthreads4w/
+ *
* The current list of contributors is contained
* in the file CONTRIBUTORS included with the source
* code distribution. The list can also be seen at the
* following World Wide Web location:
- * http://sources.redhat.com/pthreads-win32/contributors.html
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library in the file COPYING.LIB;
- * if not, write to the Free Software Foundation, Inc.,
- * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
+ * https://sourceforge.net/p/pthreads4w/wiki/Contributors/
+ *
+ * This file is part of Pthreads4w.
+ *
+ * Pthreads4w is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * Pthreads4w is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Pthreads4w. If not, see <http://www.gnu.org/licenses/>. *
*/
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
#include "pthread.h"
#include "implement.h"
diff --git a/libs/pthreads/src/pthread_getw32threadhandle_np.c b/libs/pthreads/src/pthread_getw32threadhandle_np.c
index 309a8f281f..f3fe0b1fc0 100644
--- a/libs/pthreads/src/pthread_getw32threadhandle_np.c
+++ b/libs/pthreads/src/pthread_getw32threadhandle_np.c
@@ -6,34 +6,38 @@
*
* --------------------------------------------------------------------------
*
- * Pthreads-win32 - POSIX Threads Library for Win32
+ * Pthreads4w - POSIX Threads Library for Win32
* Copyright(C) 1998 John E. Bossom
- * Copyright(C) 1999,2005 Pthreads-win32 contributors
- *
- * Contact Email: rpj@callisto.canberra.edu.au
- *
+ * Copyright(C) 1999-2018, Pthreads4w contributors
+ *
+ * Homepage: https://sourceforge.net/projects/pthreads4w/
+ *
* The current list of contributors is contained
* in the file CONTRIBUTORS included with the source
* code distribution. The list can also be seen at the
* following World Wide Web location:
- * http://sources.redhat.com/pthreads-win32/contributors.html
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library in the file COPYING.LIB;
- * if not, write to the Free Software Foundation, Inc.,
- * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
+ * https://sourceforge.net/p/pthreads4w/wiki/Contributors/
+ *
+ * This file is part of Pthreads4w.
+ *
+ * Pthreads4w is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * Pthreads4w is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Pthreads4w. If not, see <http://www.gnu.org/licenses/>. *
*/
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
#include "pthread.h"
#include "implement.h"
diff --git a/libs/pthreads/src/pthread_join.c b/libs/pthreads/src/pthread_join.c
index c2b7c1e757..27c6ccd347 100644
--- a/libs/pthreads/src/pthread_join.c
+++ b/libs/pthreads/src/pthread_join.c
@@ -7,34 +7,38 @@
*
* --------------------------------------------------------------------------
*
- * Pthreads-win32 - POSIX Threads Library for Win32
+ * Pthreads4w - POSIX Threads Library for Win32
* Copyright(C) 1998 John E. Bossom
- * Copyright(C) 1999,2005 Pthreads-win32 contributors
- *
- * Contact Email: rpj@callisto.canberra.edu.au
- *
+ * Copyright(C) 1999-2018, Pthreads4w contributors
+ *
+ * Homepage: https://sourceforge.net/projects/pthreads4w/
+ *
* The current list of contributors is contained
* in the file CONTRIBUTORS included with the source
* code distribution. The list can also be seen at the
* following World Wide Web location:
- * http://sources.redhat.com/pthreads-win32/contributors.html
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library in the file COPYING.LIB;
- * if not, write to the Free Software Foundation, Inc.,
- * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
+ * https://sourceforge.net/p/pthreads4w/wiki/Contributors/
+ *
+ * This file is part of Pthreads4w.
+ *
+ * Pthreads4w is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * Pthreads4w is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Pthreads4w. If not, see <http://www.gnu.org/licenses/>. *
*/
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
#include "pthread.h"
#include "implement.h"
@@ -123,9 +127,9 @@ pthread_join (pthread_t thread, void **value_ptr)
else
{
/*
- * Pthread_join is a cancelation point.
+ * Pthread_join is a cancellation point.
* If we are canceled then our target thread must not be
- * detached (destroyed). This is guarranteed because
+ * detached (destroyed). This is guaranteed because
* pthreadCancelableWait will not return if we
* are canceled.
*/
diff --git a/libs/pthreads/src/pthread_key_create.c b/libs/pthreads/src/pthread_key_create.c
index 65c6f95081..21e8b5f20b 100644
--- a/libs/pthreads/src/pthread_key_create.c
+++ b/libs/pthreads/src/pthread_key_create.c
@@ -6,34 +6,38 @@
*
* --------------------------------------------------------------------------
*
- * Pthreads-win32 - POSIX Threads Library for Win32
+ * Pthreads4w - POSIX Threads Library for Win32
* Copyright(C) 1998 John E. Bossom
- * Copyright(C) 1999,2005 Pthreads-win32 contributors
- *
- * Contact Email: rpj@callisto.canberra.edu.au
- *
+ * Copyright(C) 1999-2018, Pthreads4w contributors
+ *
+ * Homepage: https://sourceforge.net/projects/pthreads4w/
+ *
* The current list of contributors is contained
* in the file CONTRIBUTORS included with the source
* code distribution. The list can also be seen at the
* following World Wide Web location:
- * http://sources.redhat.com/pthreads-win32/contributors.html
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library in the file COPYING.LIB;
- * if not, write to the Free Software Foundation, Inc.,
- * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
+ * https://sourceforge.net/p/pthreads4w/wiki/Contributors/
+ *
+ * This file is part of Pthreads4w.
+ *
+ * Pthreads4w is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * Pthreads4w is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Pthreads4w. If not, see <http://www.gnu.org/licenses/>. *
*/
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
#include "pthread.h"
#include "implement.h"
diff --git a/libs/pthreads/src/pthread_key_delete.c b/libs/pthreads/src/pthread_key_delete.c
index 09d70c63f5..a713c9e725 100644
--- a/libs/pthreads/src/pthread_key_delete.c
+++ b/libs/pthreads/src/pthread_key_delete.c
@@ -6,65 +6,69 @@
*
* --------------------------------------------------------------------------
*
- * Pthreads-win32 - POSIX Threads Library for Win32
+ * Pthreads4w - POSIX Threads Library for Win32
* Copyright(C) 1998 John E. Bossom
- * Copyright(C) 1999,2005 Pthreads-win32 contributors
- *
- * Contact Email: rpj@callisto.canberra.edu.au
- *
+ * Copyright(C) 1999-2018, Pthreads4w contributors
+ *
+ * Homepage: https://sourceforge.net/projects/pthreads4w/
+ *
* The current list of contributors is contained
* in the file CONTRIBUTORS included with the source
* code distribution. The list can also be seen at the
* following World Wide Web location:
- * http://sources.redhat.com/pthreads-win32/contributors.html
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library in the file COPYING.LIB;
- * if not, write to the Free Software Foundation, Inc.,
- * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
+ * https://sourceforge.net/p/pthreads4w/wiki/Contributors/
+ *
+ * This file is part of Pthreads4w.
+ *
+ * Pthreads4w is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * Pthreads4w is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Pthreads4w. If not, see <http://www.gnu.org/licenses/>. *
*/
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
#include "pthread.h"
#include "implement.h"
int
pthread_key_delete (pthread_key_t key)
- /*
- * ------------------------------------------------------
- * DOCPUBLIC
- * This function deletes a thread-specific data key. This
- * does not change the value of the thread specific data key
- * for any thread and does not run the key's destructor
- * in any thread so it should be used with caution.
- *
- * PARAMETERS
- * key
- * pointer to an instance of pthread_key_t
- *
- *
- * DESCRIPTION
- * This function deletes a thread-specific data key. This
- * does not change the value of the thread specific data key
- * for any thread and does not run the key's destructor
- * in any thread so it should be used with caution.
- *
- * RESULTS
- * 0 successfully deleted the key,
- * EINVAL key is invalid,
- *
- * ------------------------------------------------------
- */
+/*
+ * ------------------------------------------------------
+ * DOCPUBLIC
+ * This function deletes a thread-specific data key. This
+ * does not change the value of the thread specific data key
+ * for any thread and does not run the key's destructor
+ * in any thread so it should be used with caution.
+ *
+ * PARAMETERS
+ * key
+ * pointer to an instance of pthread_key_t
+ *
+ *
+ * DESCRIPTION
+ * This function deletes a thread-specific data key. This
+ * does not change the value of the thread specific data key
+ * for any thread and does not run the key's destructor
+ * in any thread so it should be used with caution.
+ *
+ * RESULTS
+ * 0 successfully deleted the key,
+ * EINVAL key is invalid,
+ *
+ * ------------------------------------------------------
+ */
{
ptw32_mcs_local_node_t keyLock;
int result = 0;
@@ -72,48 +76,48 @@ pthread_key_delete (pthread_key_t key)
if (key != NULL)
{
if (key->threads != NULL && key->destructor != NULL)
- {
- ThreadKeyAssoc *assoc;
- ptw32_mcs_lock_acquire (&(key->keyLock), &keyLock);
- /*
- * Run through all Thread<-->Key associations
- * for this key.
- *
- * While we hold at least one of the locks guarding
- * the assoc, we know that the assoc pointed to by
- * key->threads is valid.
- */
- while ((assoc = (ThreadKeyAssoc *) key->threads) != NULL)
- {
+ {
+ ThreadKeyAssoc *assoc;
+ ptw32_mcs_lock_acquire (&(key->keyLock), &keyLock);
+ /*
+ * Run through all Thread<-->Key associations
+ * for this key.
+ *
+ * While we hold at least one of the locks guarding
+ * the assoc, we know that the assoc pointed to by
+ * key->threads is valid.
+ */
+ while ((assoc = (ThreadKeyAssoc *) key->threads) != NULL)
+ {
ptw32_mcs_local_node_t threadLock;
- ptw32_thread_t * thread = assoc->thread;
+ ptw32_thread_t * thread = assoc->thread;
- if (assoc == NULL)
- {
- /* Finished */
- break;
- }
+ if (assoc == NULL)
+ {
+ /* Finished */
+ break;
+ }
- ptw32_mcs_lock_acquire (&(thread->threadLock), &threadLock);
- /*
- * Since we are starting at the head of the key's threads
- * chain, this will also point key->threads at the next assoc.
- * While we hold key->keyLock, no other thread can insert
- * a new assoc via pthread_setspecific.
- */
- ptw32_tkAssocDestroy (assoc);
- ptw32_mcs_lock_release (&threadLock);
- ptw32_mcs_lock_release (&keyLock);
- }
- }
+ ptw32_mcs_lock_acquire (&(thread->threadLock), &threadLock);
+ /*
+ * Since we are starting at the head of the key's threads
+ * chain, this will also point key->threads at the next assoc.
+ * While we hold key->keyLock, no other thread can insert
+ * a new assoc for this key via pthread_setspecific.
+ */
+ ptw32_tkAssocDestroy (assoc);
+ ptw32_mcs_lock_release (&threadLock);
+ }
+ ptw32_mcs_lock_release (&keyLock);
+ }
TlsFree (key->key);
if (key->destructor != NULL)
- {
- /* A thread could be holding the keyLock */
- ptw32_mcs_lock_acquire (&(key->keyLock), &keyLock);
- ptw32_mcs_lock_release (&keyLock);
- }
+ {
+ /* A thread could be holding the keyLock */
+ ptw32_mcs_lock_acquire (&(key->keyLock), &keyLock);
+ ptw32_mcs_lock_release (&keyLock);
+ }
#if defined( _DEBUG )
memset ((char *) key, 0, sizeof (*key));
diff --git a/libs/pthreads/src/pthread_kill.c b/libs/pthreads/src/pthread_kill.c
index 5473b43cd4..4b5e481df3 100644
--- a/libs/pthreads/src/pthread_kill.c
+++ b/libs/pthreads/src/pthread_kill.c
@@ -6,34 +6,38 @@
*
* --------------------------------------------------------------------------
*
- * Pthreads-win32 - POSIX Threads Library for Win32
+ * Pthreads4w - POSIX Threads Library for Win32
* Copyright(C) 1998 John E. Bossom
- * Copyright(C) 1999,2005 Pthreads-win32 contributors
- *
- * Contact Email: rpj@callisto.canberra.edu.au
- *
+ * Copyright(C) 1999-2018, Pthreads4w contributors
+ *
+ * Homepage: https://sourceforge.net/projects/pthreads4w/
+ *
* The current list of contributors is contained
* in the file CONTRIBUTORS included with the source
* code distribution. The list can also be seen at the
* following World Wide Web location:
- * http://sources.redhat.com/pthreads-win32/contributors.html
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library in the file COPYING.LIB;
- * if not, write to the Free Software Foundation, Inc.,
- * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
+ * https://sourceforge.net/p/pthreads4w/wiki/Contributors/
+ *
+ * This file is part of Pthreads4w.
+ *
+ * Pthreads4w is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * Pthreads4w is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Pthreads4w. If not, see <http://www.gnu.org/licenses/>. *
*/
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
#include "pthread.h"
#include "implement.h"
diff --git a/libs/pthreads/src/pthread_mutex_consistent.c b/libs/pthreads/src/pthread_mutex_consistent.c
index b7805e7b19..c37e689835 100644
--- a/libs/pthreads/src/pthread_mutex_consistent.c
+++ b/libs/pthreads/src/pthread_mutex_consistent.c
@@ -6,34 +6,38 @@
*
* --------------------------------------------------------------------------
*
- * Pthreads-win32 - POSIX Threads Library for Win32
+ * Pthreads4w - POSIX Threads Library for Win32
* Copyright(C) 1998 John E. Bossom
- * Copyright(C) 1999,2005 Pthreads-win32 contributors
- *
- * Contact Email: rpj@callisto.canberra.edu.au
- *
+ * Copyright(C) 1999-2018, Pthreads4w contributors
+ *
+ * Homepage: https://sourceforge.net/projects/pthreads4w/
+ *
* The current list of contributors is contained
* in the file CONTRIBUTORS included with the source
* code distribution. The list can also be seen at the
* following World Wide Web location:
- * http://sources.redhat.com/pthreads-win32/contributors.html
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library in the file COPYING.LIB;
- * if not, write to the Free Software Foundation, Inc.,
- * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
+ * https://sourceforge.net/p/pthreads4w/wiki/Contributors/
+ *
+ * This file is part of Pthreads4w.
+ *
+ * Pthreads4w is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * Pthreads4w is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Pthreads4w. If not, see <http://www.gnu.org/licenses/>. *
*/
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
/*
* From the Sun Multi-threaded Programming Guide
*
@@ -41,29 +45,29 @@
* mutex, usually because its process terminated abnormally. The value of robustness that is
* defined in pthread.h is PTHREAD_MUTEX_ROBUST or PTHREAD_MUTEX_STALLED. The
* default value is PTHREAD_MUTEX_STALLED .
- * â–  PTHREAD_MUTEX_STALLED
+ * [] PTHREAD_MUTEX_STALLED
* When the owner of the mutex terminates without unlocking the mutex, all subsequent calls
* to pthread_mutex_lock() are blocked from progress in an unspecified manner.
- * â–  PTHREAD_MUTEX_ROBUST
+ * [] PTHREAD_MUTEX_ROBUST
* When the owner of the mutex terminates without unlocking the mutex, the mutex is
* unlocked. The next owner of this mutex acquires the mutex with an error return of
* EOWNERDEAD.
- * Note – Your application must always check the return code from pthread_mutex_lock() for
+ * Note - Your application must always check the return code from pthread_mutex_lock() for
* a mutex initialized with the PTHREAD_MUTEX_ROBUST attribute.
- * â–  The new owner of this mutex should make the state protected by the mutex consistent.
+ * [] The new owner of this mutex should make the state protected by the mutex consistent.
* This state might have been left inconsistent when the previous owner terminated.
- * â–  If the new owner is able to make the state consistent, call
+ * [] If the new owner is able to make the state consistent, call
* pthread_mutex_consistent() for the mutex before unlocking the mutex. This
* marks the mutex as consistent and subsequent calls to pthread_mutex_lock() and
* pthread_mutex_unlock() will behave in the normal manner.
- * â–  If the new owner is not able to make the state consistent, do not call
+ * [] If the new owner is not able to make the state consistent, do not call
* pthread_mutex_consistent() for the mutex, but unlock the mutex.
* All waiters are woken up and all subsequent calls to pthread_mutex_lock() fail to
* acquire the mutex. The return code is ENOTRECOVERABLE. The mutex can be made
* consistent by calling pthread_mutex_destroy() to uninitialize the mutex, and calling
* pthread_mutex_int() to reinitialize the mutex.However, the state that was protected
* by the mutex remains inconsistent and some form of application recovery is required.
- * â–  If the thread that acquires the lock with EOWNERDEAD terminates without unlocking the
+ * [] If the thread that acquires the lock with EOWNERDEAD terminates without unlocking the
* mutex, the next owner acquires the lock with an EOWNERDEAD return code.
*/
#if !defined(_UWIN)
@@ -100,9 +104,9 @@ ptw32_robust_mutex_inherit(pthread_mutex_t * mutex)
}
/*
- * The next two internal support functions depend on only being
- * called by the thread that owns the robust mutex. This enables
- * us to avoid additional locks.
+ * The next two internal support functions depend on being
+ * called only by the thread that owns the robust mutex. This
+ * enables us to avoid additional locks.
* Any mutex currently in the thread's robust mutex list is held
* by the thread, again eliminating the need for locks.
* The forward/backward links allow the thread to unlock mutexes
diff --git a/libs/pthreads/src/pthread_mutex_destroy.c b/libs/pthreads/src/pthread_mutex_destroy.c
index 7b8c9cd65b..9436661129 100644
--- a/libs/pthreads/src/pthread_mutex_destroy.c
+++ b/libs/pthreads/src/pthread_mutex_destroy.c
@@ -6,34 +6,38 @@
*
* --------------------------------------------------------------------------
*
- * Pthreads-win32 - POSIX Threads Library for Win32
+ * Pthreads4w - POSIX Threads Library for Win32
* Copyright(C) 1998 John E. Bossom
- * Copyright(C) 1999,2005 Pthreads-win32 contributors
- *
- * Contact Email: rpj@callisto.canberra.edu.au
- *
+ * Copyright(C) 1999-2018, Pthreads4w contributors
+ *
+ * Homepage: https://sourceforge.net/projects/pthreads4w/
+ *
* The current list of contributors is contained
* in the file CONTRIBUTORS included with the source
* code distribution. The list can also be seen at the
* following World Wide Web location:
- * http://sources.redhat.com/pthreads-win32/contributors.html
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library in the file COPYING.LIB;
- * if not, write to the Free Software Foundation, Inc.,
- * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
+ * https://sourceforge.net/p/pthreads4w/wiki/Contributors/
+ *
+ * This file is part of Pthreads4w.
+ *
+ * Pthreads4w is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * Pthreads4w is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Pthreads4w. If not, see <http://www.gnu.org/licenses/>. *
*/
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
#include "pthread.h"
#include "implement.h"
diff --git a/libs/pthreads/src/pthread_mutex_init.c b/libs/pthreads/src/pthread_mutex_init.c
index daf805e5bc..d3295a8d73 100644
--- a/libs/pthreads/src/pthread_mutex_init.c
+++ b/libs/pthreads/src/pthread_mutex_init.c
@@ -6,34 +6,38 @@
*
* --------------------------------------------------------------------------
*
- * Pthreads-win32 - POSIX Threads Library for Win32
+ * Pthreads4w - POSIX Threads Library for Win32
* Copyright(C) 1998 John E. Bossom
- * Copyright(C) 1999,2005 Pthreads-win32 contributors
- *
- * Contact Email: rpj@callisto.canberra.edu.au
- *
+ * Copyright(C) 1999-2018, Pthreads4w contributors
+ *
+ * Homepage: https://sourceforge.net/projects/pthreads4w/
+ *
* The current list of contributors is contained
* in the file CONTRIBUTORS included with the source
* code distribution. The list can also be seen at the
* following World Wide Web location:
- * http://sources.redhat.com/pthreads-win32/contributors.html
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library in the file COPYING.LIB;
- * if not, write to the Free Software Foundation, Inc.,
- * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
+ * https://sourceforge.net/p/pthreads4w/wiki/Contributors/
+ *
+ * This file is part of Pthreads4w.
+ *
+ * Pthreads4w is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * Pthreads4w is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Pthreads4w. If not, see <http://www.gnu.org/licenses/>. *
*/
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
#include "pthread.h"
#include "implement.h"
@@ -103,25 +107,43 @@ pthread_mutex_init (pthread_mutex_t * mutex, const pthread_mutexattr_t * attr)
mx->kind = -mx->kind - 1;
mx->robustNode = (ptw32_robust_node_t*) malloc(sizeof(ptw32_robust_node_t));
- mx->robustNode->stateInconsistent = PTW32_ROBUST_CONSISTENT;
- mx->robustNode->mx = mx;
- mx->robustNode->next = NULL;
- mx->robustNode->prev = NULL;
+ if (NULL == mx->robustNode)
+ {
+ result = ENOMEM;
+ }
+ else
+ {
+ mx->robustNode->stateInconsistent = PTW32_ROBUST_CONSISTENT;
+ mx->robustNode->mx = mx;
+ mx->robustNode->next = NULL;
+ mx->robustNode->prev = NULL;
+ }
}
}
- mx->ownerThread.p = NULL;
+ if (0 == result)
+ {
+ mx->ownerThread.p = NULL;
- mx->event = CreateEvent (NULL, PTW32_FALSE, /* manual reset = No */
- PTW32_FALSE, /* initial state = not signaled */
- NULL); /* event name */
+ mx->event = CreateEvent (NULL, PTW32_FALSE, /* manual reset = No */
+ PTW32_FALSE, /* initial state = not signalled */
+ NULL); /* event name */
- if (0 == mx->event)
- {
- result = ENOSPC;
- free (mx);
- mx = NULL;
- }
+ if (0 == mx->event)
+ {
+ result = ENOSPC;
+ }
+ }
+ }
+
+ if (0 != result)
+ {
+ if (NULL != mx->robustNode)
+ {
+ free (mx->robustNode);
+ }
+ free (mx);
+ mx = NULL;
}
*mutex = mx;
diff --git a/libs/pthreads/src/pthread_mutex_lock.c b/libs/pthreads/src/pthread_mutex_lock.c
index eee9abe8c7..eb8f0b4e16 100644
--- a/libs/pthreads/src/pthread_mutex_lock.c
+++ b/libs/pthreads/src/pthread_mutex_lock.c
@@ -6,34 +6,38 @@
*
* --------------------------------------------------------------------------
*
- * Pthreads-win32 - POSIX Threads Library for Win32
+ * Pthreads4w - POSIX Threads Library for Win32
* Copyright(C) 1998 John E. Bossom
- * Copyright(C) 1999,2005 Pthreads-win32 contributors
- *
- * Contact Email: rpj@callisto.canberra.edu.au
- *
+ * Copyright(C) 1999-2018, Pthreads4w contributors
+ *
+ * Homepage: https://sourceforge.net/projects/pthreads4w/
+ *
* The current list of contributors is contained
* in the file CONTRIBUTORS included with the source
* code distribution. The list can also be seen at the
* following World Wide Web location:
- * http://sources.redhat.com/pthreads-win32/contributors.html
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library in the file COPYING.LIB;
- * if not, write to the Free Software Foundation, Inc.,
- * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
+ * https://sourceforge.net/p/pthreads4w/wiki/Contributors/
+ *
+ * This file is part of Pthreads4w.
+ *
+ * Pthreads4w is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * Pthreads4w is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Pthreads4w. If not, see <http://www.gnu.org/licenses/>. *
*/
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
#if !defined(_UWIN)
/*# include <process.h> */
#endif
diff --git a/libs/pthreads/src/pthread_mutex_timedlock.c b/libs/pthreads/src/pthread_mutex_timedlock.c
index 1745316795..32850c93db 100644
--- a/libs/pthreads/src/pthread_mutex_timedlock.c
+++ b/libs/pthreads/src/pthread_mutex_timedlock.c
@@ -6,34 +6,38 @@
*
* --------------------------------------------------------------------------
*
- * Pthreads-win32 - POSIX Threads Library for Win32
+ * Pthreads4w - POSIX Threads Library for Win32
* Copyright(C) 1998 John E. Bossom
- * Copyright(C) 1999,2005 Pthreads-win32 contributors
- *
- * Contact Email: rpj@callisto.canberra.edu.au
- *
+ * Copyright(C) 1999-2018, Pthreads4w contributors
+ *
+ * Homepage: https://sourceforge.net/projects/pthreads4w/
+ *
* The current list of contributors is contained
* in the file CONTRIBUTORS included with the source
* code distribution. The list can also be seen at the
* following World Wide Web location:
- * http://sources.redhat.com/pthreads-win32/contributors.html
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library in the file COPYING.LIB;
- * if not, write to the Free Software Foundation, Inc.,
- * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
+ * https://sourceforge.net/p/pthreads4w/wiki/Contributors/
+ *
+ * This file is part of Pthreads4w.
+ *
+ * Pthreads4w is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * Pthreads4w is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Pthreads4w. If not, see <http://www.gnu.org/licenses/>. *
*/
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
#include "pthread.h"
#include "implement.h"
@@ -52,7 +56,7 @@ ptw32_timed_eventwait (HANDLE event, const struct timespec *abstime)
* block until it can successfully decrease the value or
* until interrupted by a signal.
*
- * This routine is not a cancelation point.
+ * This routine is not a cancellation point.
*
* RESULTS
* 0 successfully signaled,
@@ -86,18 +90,17 @@ ptw32_timed_eventwait (HANDLE event, const struct timespec *abstime)
status = WaitForSingleObject (event, milliseconds);
- if (status == WAIT_OBJECT_0)
- {
- return 0;
- }
- else if (status == WAIT_TIMEOUT)
- {
- return ETIMEDOUT;
- }
- else
- {
- return EINVAL;
- }
+ if (status != WAIT_OBJECT_0)
+ {
+ if (status == WAIT_TIMEOUT)
+ {
+ return ETIMEDOUT;
+ }
+ else
+ {
+ return EINVAL;
+ }
+ }
}
return 0;
diff --git a/libs/pthreads/src/pthread_mutex_trylock.c b/libs/pthreads/src/pthread_mutex_trylock.c
index 5728728b62..b1cb9913ef 100644
--- a/libs/pthreads/src/pthread_mutex_trylock.c
+++ b/libs/pthreads/src/pthread_mutex_trylock.c
@@ -6,34 +6,38 @@
*
* --------------------------------------------------------------------------
*
- * Pthreads-win32 - POSIX Threads Library for Win32
+ * Pthreads4w - POSIX Threads Library for Win32
* Copyright(C) 1998 John E. Bossom
- * Copyright(C) 1999,2005 Pthreads-win32 contributors
- *
- * Contact Email: rpj@callisto.canberra.edu.au
- *
+ * Copyright(C) 1999-2018, Pthreads4w contributors
+ *
+ * Homepage: https://sourceforge.net/projects/pthreads4w/
+ *
* The current list of contributors is contained
* in the file CONTRIBUTORS included with the source
* code distribution. The list can also be seen at the
* following World Wide Web location:
- * http://sources.redhat.com/pthreads-win32/contributors.html
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library in the file COPYING.LIB;
- * if not, write to the Free Software Foundation, Inc.,
- * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
+ * https://sourceforge.net/p/pthreads4w/wiki/Contributors/
+ *
+ * This file is part of Pthreads4w.
+ *
+ * Pthreads4w is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * Pthreads4w is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Pthreads4w. If not, see <http://www.gnu.org/licenses/>. *
*/
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
#include "pthread.h"
#include "implement.h"
@@ -64,10 +68,6 @@ pthread_mutex_trylock (pthread_mutex_t * mutex)
}
mx = *mutex;
- if (mx == NULL) {
- return EINVAL;
- }
-
kind = mx->kind;
if (kind >= 0)
diff --git a/libs/pthreads/src/pthread_mutex_unlock.c b/libs/pthreads/src/pthread_mutex_unlock.c
index 77175bb5da..27033b1cc4 100644
--- a/libs/pthreads/src/pthread_mutex_unlock.c
+++ b/libs/pthreads/src/pthread_mutex_unlock.c
@@ -6,34 +6,38 @@
*
* --------------------------------------------------------------------------
*
- * Pthreads-win32 - POSIX Threads Library for Win32
+ * Pthreads4w - POSIX Threads Library for Win32
* Copyright(C) 1998 John E. Bossom
- * Copyright(C) 1999,2005 Pthreads-win32 contributors
- *
- * Contact Email: rpj@callisto.canberra.edu.au
- *
+ * Copyright(C) 1999-2018, Pthreads4w contributors
+ *
+ * Homepage: https://sourceforge.net/projects/pthreads4w/
+ *
* The current list of contributors is contained
* in the file CONTRIBUTORS included with the source
* code distribution. The list can also be seen at the
* following World Wide Web location:
- * http://sources.redhat.com/pthreads-win32/contributors.html
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library in the file COPYING.LIB;
- * if not, write to the Free Software Foundation, Inc.,
- * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
+ * https://sourceforge.net/p/pthreads4w/wiki/Contributors/
+ *
+ * This file is part of Pthreads4w.
+ *
+ * Pthreads4w is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * Pthreads4w is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Pthreads4w. If not, see <http://www.gnu.org/licenses/>. *
*/
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
#include "pthread.h"
#include "implement.h"
@@ -50,9 +54,6 @@ pthread_mutex_unlock (pthread_mutex_t * mutex)
*/
mx = *mutex;
- if (mx == NULL) {
- return EINVAL;
- }
/*
* If the thread calling us holds the mutex then there is no
diff --git a/libs/pthreads/src/pthread_mutexattr_destroy.c b/libs/pthreads/src/pthread_mutexattr_destroy.c
index 9d424bfa28..4c9172c92d 100644
--- a/libs/pthreads/src/pthread_mutexattr_destroy.c
+++ b/libs/pthreads/src/pthread_mutexattr_destroy.c
@@ -6,34 +6,38 @@
*
* --------------------------------------------------------------------------
*
- * Pthreads-win32 - POSIX Threads Library for Win32
+ * Pthreads4w - POSIX Threads Library for Win32
* Copyright(C) 1998 John E. Bossom
- * Copyright(C) 1999,2005 Pthreads-win32 contributors
- *
- * Contact Email: rpj@callisto.canberra.edu.au
- *
+ * Copyright(C) 1999-2018, Pthreads4w contributors
+ *
+ * Homepage: https://sourceforge.net/projects/pthreads4w/
+ *
* The current list of contributors is contained
* in the file CONTRIBUTORS included with the source
* code distribution. The list can also be seen at the
* following World Wide Web location:
- * http://sources.redhat.com/pthreads-win32/contributors.html
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library in the file COPYING.LIB;
- * if not, write to the Free Software Foundation, Inc.,
- * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
+ * https://sourceforge.net/p/pthreads4w/wiki/Contributors/
+ *
+ * This file is part of Pthreads4w.
+ *
+ * Pthreads4w is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * Pthreads4w is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Pthreads4w. If not, see <http://www.gnu.org/licenses/>. *
*/
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
#include "pthread.h"
#include "implement.h"
diff --git a/libs/pthreads/src/pthread_mutexattr_getkind_np.c b/libs/pthreads/src/pthread_mutexattr_getkind_np.c
index 2d82ec6bc7..8bf8e3a503 100644
--- a/libs/pthreads/src/pthread_mutexattr_getkind_np.c
+++ b/libs/pthreads/src/pthread_mutexattr_getkind_np.c
@@ -6,34 +6,38 @@
*
* --------------------------------------------------------------------------
*
- * Pthreads-win32 - POSIX Threads Library for Win32
+ * Pthreads4w - POSIX Threads Library for Win32
* Copyright(C) 1998 John E. Bossom
- * Copyright(C) 1999,2005 Pthreads-win32 contributors
- *
- * Contact Email: rpj@callisto.canberra.edu.au
- *
+ * Copyright(C) 1999-2018, Pthreads4w contributors
+ *
+ * Homepage: https://sourceforge.net/projects/pthreads4w/
+ *
* The current list of contributors is contained
* in the file CONTRIBUTORS included with the source
* code distribution. The list can also be seen at the
* following World Wide Web location:
- * http://sources.redhat.com/pthreads-win32/contributors.html
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library in the file COPYING.LIB;
- * if not, write to the Free Software Foundation, Inc.,
- * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
+ * https://sourceforge.net/p/pthreads4w/wiki/Contributors/
+ *
+ * This file is part of Pthreads4w.
+ *
+ * Pthreads4w is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * Pthreads4w is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Pthreads4w. If not, see <http://www.gnu.org/licenses/>. *
*/
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
#include "pthread.h"
#include "implement.h"
diff --git a/libs/pthreads/src/pthread_mutexattr_getpshared.c b/libs/pthreads/src/pthread_mutexattr_getpshared.c
index 42f9589c51..eb9a0a0730 100644
--- a/libs/pthreads/src/pthread_mutexattr_getpshared.c
+++ b/libs/pthreads/src/pthread_mutexattr_getpshared.c
@@ -6,34 +6,38 @@
*
* --------------------------------------------------------------------------
*
- * Pthreads-win32 - POSIX Threads Library for Win32
+ * Pthreads4w - POSIX Threads Library for Win32
* Copyright(C) 1998 John E. Bossom
- * Copyright(C) 1999,2005 Pthreads-win32 contributors
- *
- * Contact Email: rpj@callisto.canberra.edu.au
- *
+ * Copyright(C) 1999-2018, Pthreads4w contributors
+ *
+ * Homepage: https://sourceforge.net/projects/pthreads4w/
+ *
* The current list of contributors is contained
* in the file CONTRIBUTORS included with the source
* code distribution. The list can also be seen at the
* following World Wide Web location:
- * http://sources.redhat.com/pthreads-win32/contributors.html
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library in the file COPYING.LIB;
- * if not, write to the Free Software Foundation, Inc.,
- * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
+ * https://sourceforge.net/p/pthreads4w/wiki/Contributors/
+ *
+ * This file is part of Pthreads4w.
+ *
+ * Pthreads4w is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * Pthreads4w is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Pthreads4w. If not, see <http://www.gnu.org/licenses/>. *
*/
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
#include "pthread.h"
#include "implement.h"
diff --git a/libs/pthreads/src/pthread_mutexattr_getrobust.c b/libs/pthreads/src/pthread_mutexattr_getrobust.c
index be004837bc..2e7d6528cc 100644
--- a/libs/pthreads/src/pthread_mutexattr_getrobust.c
+++ b/libs/pthreads/src/pthread_mutexattr_getrobust.c
@@ -6,34 +6,38 @@
*
* --------------------------------------------------------------------------
*
- * Pthreads-win32 - POSIX Threads Library for Win32
+ * Pthreads4w - POSIX Threads Library for Win32
* Copyright(C) 1998 John E. Bossom
- * Copyright(C) 1999,2005 Pthreads-win32 contributors
- *
- * Contact Email: rpj@callisto.canberra.edu.au
- *
+ * Copyright(C) 1999-2018, Pthreads4w contributors
+ *
+ * Homepage: https://sourceforge.net/projects/pthreads4w/
+ *
* The current list of contributors is contained
* in the file CONTRIBUTORS included with the source
* code distribution. The list can also be seen at the
* following World Wide Web location:
- * http://sources.redhat.com/pthreads-win32/contributors.html
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library in the file COPYING.LIB;
- * if not, write to the Free Software Foundation, Inc.,
- * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
+ * https://sourceforge.net/p/pthreads4w/wiki/Contributors/
+ *
+ * This file is part of Pthreads4w.
+ *
+ * Pthreads4w is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * Pthreads4w is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Pthreads4w. If not, see <http://www.gnu.org/licenses/>. *
*/
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
#include "pthread.h"
#include "implement.h"
diff --git a/libs/pthreads/src/pthread_mutexattr_gettype.c b/libs/pthreads/src/pthread_mutexattr_gettype.c
index c63fcfa03a..aa859524f7 100644
--- a/libs/pthreads/src/pthread_mutexattr_gettype.c
+++ b/libs/pthreads/src/pthread_mutexattr_gettype.c
@@ -6,34 +6,38 @@
*
* --------------------------------------------------------------------------
*
- * Pthreads-win32 - POSIX Threads Library for Win32
+ * Pthreads4w - POSIX Threads Library for Win32
* Copyright(C) 1998 John E. Bossom
- * Copyright(C) 1999,2005 Pthreads-win32 contributors
- *
- * Contact Email: rpj@callisto.canberra.edu.au
- *
+ * Copyright(C) 1999-2018, Pthreads4w contributors
+ *
+ * Homepage: https://sourceforge.net/projects/pthreads4w/
+ *
* The current list of contributors is contained
* in the file CONTRIBUTORS included with the source
* code distribution. The list can also be seen at the
* following World Wide Web location:
- * http://sources.redhat.com/pthreads-win32/contributors.html
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library in the file COPYING.LIB;
- * if not, write to the Free Software Foundation, Inc.,
- * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
+ * https://sourceforge.net/p/pthreads4w/wiki/Contributors/
+ *
+ * This file is part of Pthreads4w.
+ *
+ * Pthreads4w is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * Pthreads4w is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Pthreads4w. If not, see <http://www.gnu.org/licenses/>. *
*/
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
#include "pthread.h"
#include "implement.h"
diff --git a/libs/pthreads/src/pthread_mutexattr_init.c b/libs/pthreads/src/pthread_mutexattr_init.c
index d2797ff248..565479b5f3 100644
--- a/libs/pthreads/src/pthread_mutexattr_init.c
+++ b/libs/pthreads/src/pthread_mutexattr_init.c
@@ -6,34 +6,38 @@
*
* --------------------------------------------------------------------------
*
- * Pthreads-win32 - POSIX Threads Library for Win32
+ * Pthreads4w - POSIX Threads Library for Win32
* Copyright(C) 1998 John E. Bossom
- * Copyright(C) 1999,2005 Pthreads-win32 contributors
- *
- * Contact Email: rpj@callisto.canberra.edu.au
- *
+ * Copyright(C) 1999-2018, Pthreads4w contributors
+ *
+ * Homepage: https://sourceforge.net/projects/pthreads4w/
+ *
* The current list of contributors is contained
* in the file CONTRIBUTORS included with the source
* code distribution. The list can also be seen at the
* following World Wide Web location:
- * http://sources.redhat.com/pthreads-win32/contributors.html
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library in the file COPYING.LIB;
- * if not, write to the Free Software Foundation, Inc.,
- * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
+ * https://sourceforge.net/p/pthreads4w/wiki/Contributors/
+ *
+ * This file is part of Pthreads4w.
+ *
+ * Pthreads4w is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * Pthreads4w is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Pthreads4w. If not, see <http://www.gnu.org/licenses/>. *
*/
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
#include "pthread.h"
#include "implement.h"
@@ -78,6 +82,7 @@ pthread_mutexattr_init (pthread_mutexattr_t * attr)
{
ma->pshared = PTHREAD_PROCESS_PRIVATE;
ma->kind = PTHREAD_MUTEX_DEFAULT;
+ ma->robustness = PTHREAD_MUTEX_STALLED;
}
*attr = ma;
diff --git a/libs/pthreads/src/pthread_mutexattr_setkind_np.c b/libs/pthreads/src/pthread_mutexattr_setkind_np.c
index faa936658f..cf820dafd8 100644
--- a/libs/pthreads/src/pthread_mutexattr_setkind_np.c
+++ b/libs/pthreads/src/pthread_mutexattr_setkind_np.c
@@ -6,34 +6,38 @@
*
* --------------------------------------------------------------------------
*
- * Pthreads-win32 - POSIX Threads Library for Win32
+ * Pthreads4w - POSIX Threads Library for Win32
* Copyright(C) 1998 John E. Bossom
- * Copyright(C) 1999,2005 Pthreads-win32 contributors
- *
- * Contact Email: rpj@callisto.canberra.edu.au
- *
+ * Copyright(C) 1999-2018, Pthreads4w contributors
+ *
+ * Homepage: https://sourceforge.net/projects/pthreads4w/
+ *
* The current list of contributors is contained
* in the file CONTRIBUTORS included with the source
* code distribution. The list can also be seen at the
* following World Wide Web location:
- * http://sources.redhat.com/pthreads-win32/contributors.html
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library in the file COPYING.LIB;
- * if not, write to the Free Software Foundation, Inc.,
- * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
+ * https://sourceforge.net/p/pthreads4w/wiki/Contributors/
+ *
+ * This file is part of Pthreads4w.
+ *
+ * Pthreads4w is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * Pthreads4w is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Pthreads4w. If not, see <http://www.gnu.org/licenses/>. *
*/
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
#include "pthread.h"
#include "implement.h"
diff --git a/libs/pthreads/src/pthread_mutexattr_setpshared.c b/libs/pthreads/src/pthread_mutexattr_setpshared.c
index cfa6f71994..72c2ffabeb 100644
--- a/libs/pthreads/src/pthread_mutexattr_setpshared.c
+++ b/libs/pthreads/src/pthread_mutexattr_setpshared.c
@@ -6,34 +6,38 @@
*
* --------------------------------------------------------------------------
*
- * Pthreads-win32 - POSIX Threads Library for Win32
+ * Pthreads4w - POSIX Threads Library for Win32
* Copyright(C) 1998 John E. Bossom
- * Copyright(C) 1999,2005 Pthreads-win32 contributors
- *
- * Contact Email: rpj@callisto.canberra.edu.au
- *
+ * Copyright(C) 1999-2018, Pthreads4w contributors
+ *
+ * Homepage: https://sourceforge.net/projects/pthreads4w/
+ *
* The current list of contributors is contained
* in the file CONTRIBUTORS included with the source
* code distribution. The list can also be seen at the
* following World Wide Web location:
- * http://sources.redhat.com/pthreads-win32/contributors.html
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library in the file COPYING.LIB;
- * if not, write to the Free Software Foundation, Inc.,
- * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
+ * https://sourceforge.net/p/pthreads4w/wiki/Contributors/
+ *
+ * This file is part of Pthreads4w.
+ *
+ * Pthreads4w is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * Pthreads4w is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Pthreads4w. If not, see <http://www.gnu.org/licenses/>. *
*/
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
#include "pthread.h"
#include "implement.h"
diff --git a/libs/pthreads/src/pthread_mutexattr_setrobust.c b/libs/pthreads/src/pthread_mutexattr_setrobust.c
index b1acef7572..96f207f630 100644
--- a/libs/pthreads/src/pthread_mutexattr_setrobust.c
+++ b/libs/pthreads/src/pthread_mutexattr_setrobust.c
@@ -6,34 +6,38 @@
*
* --------------------------------------------------------------------------
*
- * Pthreads-win32 - POSIX Threads Library for Win32
+ * Pthreads4w - POSIX Threads Library for Win32
* Copyright(C) 1998 John E. Bossom
- * Copyright(C) 1999,2005 Pthreads-win32 contributors
- *
- * Contact Email: rpj@callisto.canberra.edu.au
- *
+ * Copyright(C) 1999-2018, Pthreads4w contributors
+ *
+ * Homepage: https://sourceforge.net/projects/pthreads4w/
+ *
* The current list of contributors is contained
* in the file CONTRIBUTORS included with the source
* code distribution. The list can also be seen at the
* following World Wide Web location:
- * http://sources.redhat.com/pthreads-win32/contributors.html
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library in the file COPYING.LIB;
- * if not, write to the Free Software Foundation, Inc.,
- * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
+ * https://sourceforge.net/p/pthreads4w/wiki/Contributors/
+ *
+ * This file is part of Pthreads4w.
+ *
+ * Pthreads4w is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * Pthreads4w is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Pthreads4w. If not, see <http://www.gnu.org/licenses/>. *
*/
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
#include "pthread.h"
#include "implement.h"
diff --git a/libs/pthreads/src/pthread_mutexattr_settype.c b/libs/pthreads/src/pthread_mutexattr_settype.c
index 8365daf65d..53fa19cb9a 100644
--- a/libs/pthreads/src/pthread_mutexattr_settype.c
+++ b/libs/pthreads/src/pthread_mutexattr_settype.c
@@ -6,34 +6,38 @@
*
* --------------------------------------------------------------------------
*
- * Pthreads-win32 - POSIX Threads Library for Win32
+ * Pthreads4w - POSIX Threads Library for Win32
* Copyright(C) 1998 John E. Bossom
- * Copyright(C) 1999,2005 Pthreads-win32 contributors
- *
- * Contact Email: rpj@callisto.canberra.edu.au
- *
+ * Copyright(C) 1999-2018, Pthreads4w contributors
+ *
+ * Homepage: https://sourceforge.net/projects/pthreads4w/
+ *
* The current list of contributors is contained
* in the file CONTRIBUTORS included with the source
* code distribution. The list can also be seen at the
* following World Wide Web location:
- * http://sources.redhat.com/pthreads-win32/contributors.html
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library in the file COPYING.LIB;
- * if not, write to the Free Software Foundation, Inc.,
- * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
+ * https://sourceforge.net/p/pthreads4w/wiki/Contributors/
+ *
+ * This file is part of Pthreads4w.
+ *
+ * Pthreads4w is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * Pthreads4w is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Pthreads4w. If not, see <http://www.gnu.org/licenses/>. *
*/
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
#include "pthread.h"
#include "implement.h"
diff --git a/libs/pthreads/src/pthread_num_processors_np.c b/libs/pthreads/src/pthread_num_processors_np.c
index 3067d117d3..22051b4a53 100644
--- a/libs/pthreads/src/pthread_num_processors_np.c
+++ b/libs/pthreads/src/pthread_num_processors_np.c
@@ -6,34 +6,38 @@
*
* --------------------------------------------------------------------------
*
- * Pthreads-win32 - POSIX Threads Library for Win32
+ * Pthreads4w - POSIX Threads Library for Win32
* Copyright(C) 1998 John E. Bossom
- * Copyright(C) 1999,2005 Pthreads-win32 contributors
- *
- * Contact Email: rpj@callisto.canberra.edu.au
- *
+ * Copyright(C) 1999-2018, Pthreads4w contributors
+ *
+ * Homepage: https://sourceforge.net/projects/pthreads4w/
+ *
* The current list of contributors is contained
* in the file CONTRIBUTORS included with the source
* code distribution. The list can also be seen at the
* following World Wide Web location:
- * http://sources.redhat.com/pthreads-win32/contributors.html
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library in the file COPYING.LIB;
- * if not, write to the Free Software Foundation, Inc.,
- * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
+ * https://sourceforge.net/p/pthreads4w/wiki/Contributors/
+ *
+ * This file is part of Pthreads4w.
+ *
+ * Pthreads4w is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * Pthreads4w is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Pthreads4w. If not, see <http://www.gnu.org/licenses/>. *
*/
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
#include "pthread.h"
#include "implement.h"
diff --git a/libs/pthreads/src/pthread_once.c b/libs/pthreads/src/pthread_once.c
index 3bfeb9f0bf..80427937b5 100644
--- a/libs/pthreads/src/pthread_once.c
+++ b/libs/pthreads/src/pthread_once.c
@@ -6,34 +6,38 @@
*
* --------------------------------------------------------------------------
*
- * Pthreads-win32 - POSIX Threads Library for Win32
+ * Pthreads4w - POSIX Threads Library for Win32
* Copyright(C) 1998 John E. Bossom
- * Copyright(C) 1999,2005 Pthreads-win32 contributors
- *
- * Contact Email: rpj@callisto.canberra.edu.au
- *
+ * Copyright(C) 1999-2018, Pthreads4w contributors
+ *
+ * Homepage: https://sourceforge.net/projects/pthreads4w/
+ *
* The current list of contributors is contained
* in the file CONTRIBUTORS included with the source
* code distribution. The list can also be seen at the
* following World Wide Web location:
- * http://sources.redhat.com/pthreads-win32/contributors.html
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library in the file COPYING.LIB;
- * if not, write to the Free Software Foundation, Inc.,
- * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
+ * https://sourceforge.net/p/pthreads4w/wiki/Contributors/
+ *
+ * This file is part of Pthreads4w.
+ *
+ * Pthreads4w is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * Pthreads4w is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Pthreads4w. If not, see <http://www.gnu.org/licenses/>. *
*/
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
#include "pthread.h"
#include "implement.h"
@@ -56,7 +60,7 @@ pthread_once (pthread_once_t * once_control, void (PTW32_CDECL *init_routine) (v
if (!once_control->done)
{
-#if defined(_MSC_VER) && _MSC_VER < 1400
+#if defined(PTW32_CONFIG_MSVC7)
#pragma inline_depth(0)
#endif
@@ -64,14 +68,14 @@ pthread_once (pthread_once_t * once_control, void (PTW32_CDECL *init_routine) (v
(*init_routine)();
pthread_cleanup_pop(0);
-#if defined(_MSC_VER) && _MSC_VER < 1400
+#if defined(PTW32_CONFIG_MSVC7)
#pragma inline_depth()
#endif
once_control->done = PTW32_TRUE;
}
- ptw32_mcs_lock_release(&node);
+ ptw32_mcs_lock_release(&node);
}
return 0;
diff --git a/libs/pthreads/src/pthread_rwlock_destroy.c b/libs/pthreads/src/pthread_rwlock_destroy.c
index 245a892410..14745a9e19 100644
--- a/libs/pthreads/src/pthread_rwlock_destroy.c
+++ b/libs/pthreads/src/pthread_rwlock_destroy.c
@@ -6,34 +6,38 @@
*
* --------------------------------------------------------------------------
*
- * Pthreads-win32 - POSIX Threads Library for Win32
+ * Pthreads4w - POSIX Threads Library for Win32
* Copyright(C) 1998 John E. Bossom
- * Copyright(C) 1999,2005 Pthreads-win32 contributors
- *
- * Contact Email: rpj@callisto.canberra.edu.au
- *
+ * Copyright(C) 1999-2018, Pthreads4w contributors
+ *
+ * Homepage: https://sourceforge.net/projects/pthreads4w/
+ *
* The current list of contributors is contained
* in the file CONTRIBUTORS included with the source
* code distribution. The list can also be seen at the
* following World Wide Web location:
- * http://sources.redhat.com/pthreads-win32/contributors.html
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library in the file COPYING.LIB;
- * if not, write to the Free Software Foundation, Inc.,
- * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
+ * https://sourceforge.net/p/pthreads4w/wiki/Contributors/
+ *
+ * This file is part of Pthreads4w.
+ *
+ * Pthreads4w is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * Pthreads4w is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Pthreads4w. If not, see <http://www.gnu.org/licenses/>. *
*/
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
#include <limits.h>
#include "pthread.h"
diff --git a/libs/pthreads/src/pthread_rwlock_init.c b/libs/pthreads/src/pthread_rwlock_init.c
index 597c1ff266..4be992aa41 100644
--- a/libs/pthreads/src/pthread_rwlock_init.c
+++ b/libs/pthreads/src/pthread_rwlock_init.c
@@ -6,34 +6,38 @@
*
* --------------------------------------------------------------------------
*
- * Pthreads-win32 - POSIX Threads Library for Win32
+ * Pthreads4w - POSIX Threads Library for Win32
* Copyright(C) 1998 John E. Bossom
- * Copyright(C) 1999,2005 Pthreads-win32 contributors
- *
- * Contact Email: rpj@callisto.canberra.edu.au
- *
+ * Copyright(C) 1999-2018, Pthreads4w contributors
+ *
+ * Homepage: https://sourceforge.net/projects/pthreads4w/
+ *
* The current list of contributors is contained
* in the file CONTRIBUTORS included with the source
* code distribution. The list can also be seen at the
* following World Wide Web location:
- * http://sources.redhat.com/pthreads-win32/contributors.html
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library in the file COPYING.LIB;
- * if not, write to the Free Software Foundation, Inc.,
- * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
+ * https://sourceforge.net/p/pthreads4w/wiki/Contributors/
+ *
+ * This file is part of Pthreads4w.
+ *
+ * Pthreads4w is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * Pthreads4w is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Pthreads4w. If not, see <http://www.gnu.org/licenses/>. *
*/
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
#include <limits.h>
#include "pthread.h"
diff --git a/libs/pthreads/src/pthread_rwlock_rdlock.c b/libs/pthreads/src/pthread_rwlock_rdlock.c
index 91e180835e..a0e62b38f1 100644
--- a/libs/pthreads/src/pthread_rwlock_rdlock.c
+++ b/libs/pthreads/src/pthread_rwlock_rdlock.c
@@ -6,34 +6,38 @@
*
* --------------------------------------------------------------------------
*
- * Pthreads-win32 - POSIX Threads Library for Win32
+ * Pthreads4w - POSIX Threads Library for Win32
* Copyright(C) 1998 John E. Bossom
- * Copyright(C) 1999,2005 Pthreads-win32 contributors
- *
- * Contact Email: rpj@callisto.canberra.edu.au
- *
+ * Copyright(C) 1999-2018, Pthreads4w contributors
+ *
+ * Homepage: https://sourceforge.net/projects/pthreads4w/
+ *
* The current list of contributors is contained
* in the file CONTRIBUTORS included with the source
* code distribution. The list can also be seen at the
* following World Wide Web location:
- * http://sources.redhat.com/pthreads-win32/contributors.html
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library in the file COPYING.LIB;
- * if not, write to the Free Software Foundation, Inc.,
- * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
+ * https://sourceforge.net/p/pthreads4w/wiki/Contributors/
+ *
+ * This file is part of Pthreads4w.
+ *
+ * Pthreads4w is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * Pthreads4w is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Pthreads4w. If not, see <http://www.gnu.org/licenses/>. *
*/
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
#include <limits.h>
#include "pthread.h"
diff --git a/libs/pthreads/src/pthread_rwlock_timedrdlock.c b/libs/pthreads/src/pthread_rwlock_timedrdlock.c
index 7133778bf1..903a8892ac 100644
--- a/libs/pthreads/src/pthread_rwlock_timedrdlock.c
+++ b/libs/pthreads/src/pthread_rwlock_timedrdlock.c
@@ -6,34 +6,38 @@
*
* --------------------------------------------------------------------------
*
- * Pthreads-win32 - POSIX Threads Library for Win32
+ * Pthreads4w - POSIX Threads Library for Win32
* Copyright(C) 1998 John E. Bossom
- * Copyright(C) 1999,2005 Pthreads-win32 contributors
- *
- * Contact Email: rpj@callisto.canberra.edu.au
- *
+ * Copyright(C) 1999-2018, Pthreads4w contributors
+ *
+ * Homepage: https://sourceforge.net/projects/pthreads4w/
+ *
* The current list of contributors is contained
* in the file CONTRIBUTORS included with the source
* code distribution. The list can also be seen at the
* following World Wide Web location:
- * http://sources.redhat.com/pthreads-win32/contributors.html
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library in the file COPYING.LIB;
- * if not, write to the Free Software Foundation, Inc.,
- * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
+ * https://sourceforge.net/p/pthreads4w/wiki/Contributors/
+ *
+ * This file is part of Pthreads4w.
+ *
+ * Pthreads4w is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * Pthreads4w is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Pthreads4w. If not, see <http://www.gnu.org/licenses/>. *
*/
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
#include <limits.h>
#include "pthread.h"
diff --git a/libs/pthreads/src/pthread_rwlock_timedwrlock.c b/libs/pthreads/src/pthread_rwlock_timedwrlock.c
index 8c111bbb1b..ee2e8a921c 100644
--- a/libs/pthreads/src/pthread_rwlock_timedwrlock.c
+++ b/libs/pthreads/src/pthread_rwlock_timedwrlock.c
@@ -6,34 +6,38 @@
*
* --------------------------------------------------------------------------
*
- * Pthreads-win32 - POSIX Threads Library for Win32
+ * Pthreads4w - POSIX Threads Library for Win32
* Copyright(C) 1998 John E. Bossom
- * Copyright(C) 1999,2005 Pthreads-win32 contributors
- *
- * Contact Email: rpj@callisto.canberra.edu.au
- *
+ * Copyright(C) 1999-2018, Pthreads4w contributors
+ *
+ * Homepage: https://sourceforge.net/projects/pthreads4w/
+ *
* The current list of contributors is contained
* in the file CONTRIBUTORS included with the source
* code distribution. The list can also be seen at the
* following World Wide Web location:
- * http://sources.redhat.com/pthreads-win32/contributors.html
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library in the file COPYING.LIB;
- * if not, write to the Free Software Foundation, Inc.,
- * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
+ * https://sourceforge.net/p/pthreads4w/wiki/Contributors/
+ *
+ * This file is part of Pthreads4w.
+ *
+ * Pthreads4w is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * Pthreads4w is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Pthreads4w. If not, see <http://www.gnu.org/licenses/>. *
*/
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
#include <limits.h>
#include "pthread.h"
@@ -101,10 +105,10 @@ pthread_rwlock_timedwrlock (pthread_rwlock_t * rwlock,
rwl->nCompletedSharedAccessCount = -rwl->nSharedAccessCount;
/*
- * This routine may be a cancelation point
+ * This routine may be a cancellation point
* according to POSIX 1003.1j section 18.1.2.
*/
-#if defined(_MSC_VER) && _MSC_VER < 1400
+#if defined(PTW32_CONFIG_MSVC7)
#pragma inline_depth(0)
#endif
pthread_cleanup_push (ptw32_rwlock_cancelwrwait, (void *) rwl);
@@ -119,7 +123,7 @@ pthread_rwlock_timedwrlock (pthread_rwlock_t * rwlock,
while (result == 0 && rwl->nCompletedSharedAccessCount < 0);
pthread_cleanup_pop ((result != 0) ? 1 : 0);
-#if defined(_MSC_VER) && _MSC_VER < 1400
+#if defined(PTW32_CONFIG_MSVC7)
#pragma inline_depth()
#endif
diff --git a/libs/pthreads/src/pthread_rwlock_tryrdlock.c b/libs/pthreads/src/pthread_rwlock_tryrdlock.c
index 0fc5458579..84e5dc58f2 100644
--- a/libs/pthreads/src/pthread_rwlock_tryrdlock.c
+++ b/libs/pthreads/src/pthread_rwlock_tryrdlock.c
@@ -6,34 +6,38 @@
*
* --------------------------------------------------------------------------
*
- * Pthreads-win32 - POSIX Threads Library for Win32
+ * Pthreads4w - POSIX Threads Library for Win32
* Copyright(C) 1998 John E. Bossom
- * Copyright(C) 1999,2005 Pthreads-win32 contributors
- *
- * Contact Email: rpj@callisto.canberra.edu.au
- *
+ * Copyright(C) 1999-2018, Pthreads4w contributors
+ *
+ * Homepage: https://sourceforge.net/projects/pthreads4w/
+ *
* The current list of contributors is contained
* in the file CONTRIBUTORS included with the source
* code distribution. The list can also be seen at the
* following World Wide Web location:
- * http://sources.redhat.com/pthreads-win32/contributors.html
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library in the file COPYING.LIB;
- * if not, write to the Free Software Foundation, Inc.,
- * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
+ * https://sourceforge.net/p/pthreads4w/wiki/Contributors/
+ *
+ * This file is part of Pthreads4w.
+ *
+ * Pthreads4w is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * Pthreads4w is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Pthreads4w. If not, see <http://www.gnu.org/licenses/>. *
*/
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
#include <limits.h>
#include "pthread.h"
diff --git a/libs/pthreads/src/pthread_rwlock_trywrlock.c b/libs/pthreads/src/pthread_rwlock_trywrlock.c
index 9997c5d7fb..906f64a27a 100644
--- a/libs/pthreads/src/pthread_rwlock_trywrlock.c
+++ b/libs/pthreads/src/pthread_rwlock_trywrlock.c
@@ -6,34 +6,38 @@
*
* --------------------------------------------------------------------------
*
- * Pthreads-win32 - POSIX Threads Library for Win32
+ * Pthreads4w - POSIX Threads Library for Win32
* Copyright(C) 1998 John E. Bossom
- * Copyright(C) 1999,2005 Pthreads-win32 contributors
- *
- * Contact Email: rpj@callisto.canberra.edu.au
- *
+ * Copyright(C) 1999-2018, Pthreads4w contributors
+ *
+ * Homepage: https://sourceforge.net/projects/pthreads4w/
+ *
* The current list of contributors is contained
* in the file CONTRIBUTORS included with the source
* code distribution. The list can also be seen at the
* following World Wide Web location:
- * http://sources.redhat.com/pthreads-win32/contributors.html
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library in the file COPYING.LIB;
- * if not, write to the Free Software Foundation, Inc.,
- * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
+ * https://sourceforge.net/p/pthreads4w/wiki/Contributors/
+ *
+ * This file is part of Pthreads4w.
+ *
+ * Pthreads4w is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * Pthreads4w is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Pthreads4w. If not, see <http://www.gnu.org/licenses/>. *
*/
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
#include <limits.h>
#include "pthread.h"
diff --git a/libs/pthreads/src/pthread_rwlock_unlock.c b/libs/pthreads/src/pthread_rwlock_unlock.c
index d48d18705b..d8dd98cc0c 100644
--- a/libs/pthreads/src/pthread_rwlock_unlock.c
+++ b/libs/pthreads/src/pthread_rwlock_unlock.c
@@ -6,34 +6,38 @@
*
* --------------------------------------------------------------------------
*
- * Pthreads-win32 - POSIX Threads Library for Win32
+ * Pthreads4w - POSIX Threads Library for Win32
* Copyright(C) 1998 John E. Bossom
- * Copyright(C) 1999,2005 Pthreads-win32 contributors
- *
- * Contact Email: rpj@callisto.canberra.edu.au
- *
+ * Copyright(C) 1999-2018, Pthreads4w contributors
+ *
+ * Homepage: https://sourceforge.net/projects/pthreads4w/
+ *
* The current list of contributors is contained
* in the file CONTRIBUTORS included with the source
* code distribution. The list can also be seen at the
* following World Wide Web location:
- * http://sources.redhat.com/pthreads-win32/contributors.html
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library in the file COPYING.LIB;
- * if not, write to the Free Software Foundation, Inc.,
- * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
+ * https://sourceforge.net/p/pthreads4w/wiki/Contributors/
+ *
+ * This file is part of Pthreads4w.
+ *
+ * Pthreads4w is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * Pthreads4w is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Pthreads4w. If not, see <http://www.gnu.org/licenses/>. *
*/
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
#include <limits.h>
#include "pthread.h"
diff --git a/libs/pthreads/src/pthread_rwlock_wrlock.c b/libs/pthreads/src/pthread_rwlock_wrlock.c
index e8b4fbb303..91b8a71f4e 100644
--- a/libs/pthreads/src/pthread_rwlock_wrlock.c
+++ b/libs/pthreads/src/pthread_rwlock_wrlock.c
@@ -6,34 +6,38 @@
*
* --------------------------------------------------------------------------
*
- * Pthreads-win32 - POSIX Threads Library for Win32
+ * Pthreads4w - POSIX Threads Library for Win32
* Copyright(C) 1998 John E. Bossom
- * Copyright(C) 1999,2005 Pthreads-win32 contributors
- *
- * Contact Email: rpj@callisto.canberra.edu.au
- *
+ * Copyright(C) 1999-2018, Pthreads4w contributors
+ *
+ * Homepage: https://sourceforge.net/projects/pthreads4w/
+ *
* The current list of contributors is contained
* in the file CONTRIBUTORS included with the source
* code distribution. The list can also be seen at the
* following World Wide Web location:
- * http://sources.redhat.com/pthreads-win32/contributors.html
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library in the file COPYING.LIB;
- * if not, write to the Free Software Foundation, Inc.,
- * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
+ * https://sourceforge.net/p/pthreads4w/wiki/Contributors/
+ *
+ * This file is part of Pthreads4w.
+ *
+ * Pthreads4w is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * Pthreads4w is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Pthreads4w. If not, see <http://www.gnu.org/licenses/>. *
*/
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
#include <limits.h>
#include "pthread.h"
@@ -97,10 +101,10 @@ pthread_rwlock_wrlock (pthread_rwlock_t * rwlock)
rwl->nCompletedSharedAccessCount = -rwl->nSharedAccessCount;
/*
- * This routine may be a cancelation point
+ * This routine may be a cancellation point
* according to POSIX 1003.1j section 18.1.2.
*/
-#if defined(_MSC_VER) && _MSC_VER < 1400
+#if defined(PTW32_CONFIG_MSVC7)
#pragma inline_depth(0)
#endif
pthread_cleanup_push (ptw32_rwlock_cancelwrwait, (void *) rwl);
@@ -113,7 +117,7 @@ pthread_rwlock_wrlock (pthread_rwlock_t * rwlock)
while (result == 0 && rwl->nCompletedSharedAccessCount < 0);
pthread_cleanup_pop ((result != 0) ? 1 : 0);
-#if defined(_MSC_VER) && _MSC_VER < 1400
+#if defined(PTW32_CONFIG_MSVC7)
#pragma inline_depth()
#endif
diff --git a/libs/pthreads/src/pthread_rwlockattr_destroy.c b/libs/pthreads/src/pthread_rwlockattr_destroy.c
index 868e727d30..472f9cc527 100644
--- a/libs/pthreads/src/pthread_rwlockattr_destroy.c
+++ b/libs/pthreads/src/pthread_rwlockattr_destroy.c
@@ -6,34 +6,38 @@
*
* --------------------------------------------------------------------------
*
- * Pthreads-win32 - POSIX Threads Library for Win32
+ * Pthreads4w - POSIX Threads Library for Win32
* Copyright(C) 1998 John E. Bossom
- * Copyright(C) 1999,2005 Pthreads-win32 contributors
- *
- * Contact Email: rpj@callisto.canberra.edu.au
- *
+ * Copyright(C) 1999-2018, Pthreads4w contributors
+ *
+ * Homepage: https://sourceforge.net/projects/pthreads4w/
+ *
* The current list of contributors is contained
* in the file CONTRIBUTORS included with the source
* code distribution. The list can also be seen at the
* following World Wide Web location:
- * http://sources.redhat.com/pthreads-win32/contributors.html
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library in the file COPYING.LIB;
- * if not, write to the Free Software Foundation, Inc.,
- * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
+ * https://sourceforge.net/p/pthreads4w/wiki/Contributors/
+ *
+ * This file is part of Pthreads4w.
+ *
+ * Pthreads4w is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * Pthreads4w is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Pthreads4w. If not, see <http://www.gnu.org/licenses/>. *
*/
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
#include <limits.h>
#include "pthread.h"
diff --git a/libs/pthreads/src/pthread_rwlockattr_getpshared.c b/libs/pthreads/src/pthread_rwlockattr_getpshared.c
index eeace207f2..3eb9060b7e 100644
--- a/libs/pthreads/src/pthread_rwlockattr_getpshared.c
+++ b/libs/pthreads/src/pthread_rwlockattr_getpshared.c
@@ -6,34 +6,38 @@
*
* --------------------------------------------------------------------------
*
- * Pthreads-win32 - POSIX Threads Library for Win32
+ * Pthreads4w - POSIX Threads Library for Win32
* Copyright(C) 1998 John E. Bossom
- * Copyright(C) 1999,2005 Pthreads-win32 contributors
- *
- * Contact Email: rpj@callisto.canberra.edu.au
- *
+ * Copyright(C) 1999-2018, Pthreads4w contributors
+ *
+ * Homepage: https://sourceforge.net/projects/pthreads4w/
+ *
* The current list of contributors is contained
* in the file CONTRIBUTORS included with the source
* code distribution. The list can also be seen at the
* following World Wide Web location:
- * http://sources.redhat.com/pthreads-win32/contributors.html
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library in the file COPYING.LIB;
- * if not, write to the Free Software Foundation, Inc.,
- * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
+ * https://sourceforge.net/p/pthreads4w/wiki/Contributors/
+ *
+ * This file is part of Pthreads4w.
+ *
+ * Pthreads4w is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * Pthreads4w is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Pthreads4w. If not, see <http://www.gnu.org/licenses/>. *
*/
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
#include <limits.h>
#include "pthread.h"
diff --git a/libs/pthreads/src/pthread_rwlockattr_init.c b/libs/pthreads/src/pthread_rwlockattr_init.c
index a2d2b945f4..652fe32e13 100644
--- a/libs/pthreads/src/pthread_rwlockattr_init.c
+++ b/libs/pthreads/src/pthread_rwlockattr_init.c
@@ -6,34 +6,38 @@
*
* --------------------------------------------------------------------------
*
- * Pthreads-win32 - POSIX Threads Library for Win32
+ * Pthreads4w - POSIX Threads Library for Win32
* Copyright(C) 1998 John E. Bossom
- * Copyright(C) 1999,2005 Pthreads-win32 contributors
- *
- * Contact Email: rpj@callisto.canberra.edu.au
- *
+ * Copyright(C) 1999-2018, Pthreads4w contributors
+ *
+ * Homepage: https://sourceforge.net/projects/pthreads4w/
+ *
* The current list of contributors is contained
* in the file CONTRIBUTORS included with the source
* code distribution. The list can also be seen at the
* following World Wide Web location:
- * http://sources.redhat.com/pthreads-win32/contributors.html
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library in the file COPYING.LIB;
- * if not, write to the Free Software Foundation, Inc.,
- * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
+ * https://sourceforge.net/p/pthreads4w/wiki/Contributors/
+ *
+ * This file is part of Pthreads4w.
+ *
+ * Pthreads4w is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * Pthreads4w is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Pthreads4w. If not, see <http://www.gnu.org/licenses/>. *
*/
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
#include <limits.h>
#include "pthread.h"
diff --git a/libs/pthreads/src/pthread_rwlockattr_setpshared.c b/libs/pthreads/src/pthread_rwlockattr_setpshared.c
index a83dd70a4b..2cbeea9518 100644
--- a/libs/pthreads/src/pthread_rwlockattr_setpshared.c
+++ b/libs/pthreads/src/pthread_rwlockattr_setpshared.c
@@ -6,34 +6,38 @@
*
* --------------------------------------------------------------------------
*
- * Pthreads-win32 - POSIX Threads Library for Win32
+ * Pthreads4w - POSIX Threads Library for Win32
* Copyright(C) 1998 John E. Bossom
- * Copyright(C) 1999,2005 Pthreads-win32 contributors
- *
- * Contact Email: rpj@callisto.canberra.edu.au
- *
+ * Copyright(C) 1999-2018, Pthreads4w contributors
+ *
+ * Homepage: https://sourceforge.net/projects/pthreads4w/
+ *
* The current list of contributors is contained
* in the file CONTRIBUTORS included with the source
* code distribution. The list can also be seen at the
* following World Wide Web location:
- * http://sources.redhat.com/pthreads-win32/contributors.html
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library in the file COPYING.LIB;
- * if not, write to the Free Software Foundation, Inc.,
- * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
+ * https://sourceforge.net/p/pthreads4w/wiki/Contributors/
+ *
+ * This file is part of Pthreads4w.
+ *
+ * Pthreads4w is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * Pthreads4w is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Pthreads4w. If not, see <http://www.gnu.org/licenses/>. *
*/
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
#include <limits.h>
#include "pthread.h"
diff --git a/libs/pthreads/src/pthread_self.c b/libs/pthreads/src/pthread_self.c
index 9a1765f82e..8eb4730e7f 100644
--- a/libs/pthreads/src/pthread_self.c
+++ b/libs/pthreads/src/pthread_self.c
@@ -6,34 +6,38 @@
*
* --------------------------------------------------------------------------
*
- * Pthreads-win32 - POSIX Threads Library for Win32
+ * Pthreads4w - POSIX Threads Library for Win32
* Copyright(C) 1998 John E. Bossom
- * Copyright(C) 1999,2005 Pthreads-win32 contributors
- *
- * Contact Email: rpj@callisto.canberra.edu.au
- *
+ * Copyright(C) 1999-2018, Pthreads4w contributors
+ *
+ * Homepage: https://sourceforge.net/projects/pthreads4w/
+ *
* The current list of contributors is contained
* in the file CONTRIBUTORS included with the source
* code distribution. The list can also be seen at the
* following World Wide Web location:
- * http://sources.redhat.com/pthreads-win32/contributors.html
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library in the file COPYING.LIB;
- * if not, write to the Free Software Foundation, Inc.,
- * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
+ * https://sourceforge.net/p/pthreads4w/wiki/Contributors/
+ *
+ * This file is part of Pthreads4w.
+ *
+ * Pthreads4w is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * Pthreads4w is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Pthreads4w. If not, see <http://www.gnu.org/licenses/>. *
*/
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
#include "pthread.h"
#include "implement.h"
@@ -76,6 +80,7 @@ pthread_self (void)
}
else
{
+ int fail = PTW32_FALSE;
/*
* Need to create an implicit 'self' for the currently
* executing thread.
@@ -84,58 +89,90 @@ pthread_self (void)
sp = (ptw32_thread_t *) self.p;
if (sp != NULL)
- {
- /*
- * This is a non-POSIX thread which has chosen to call
- * a POSIX threads function for some reason. We assume that
- * it isn't joinable, but we do assume that it's
- * (deferred) cancelable.
- */
- sp->implicit = 1;
- sp->detachState = PTHREAD_CREATE_DETACHED;
- sp->thread = GetCurrentThreadId ();
+ {
+ /*
+ * This is a non-POSIX thread which has chosen to call
+ * a POSIX threads function for some reason. We assume that
+ * it isn't joinable, but we do assume that it's
+ * (deferred) cancelable.
+ */
+ sp->implicit = 1;
+ sp->detachState = PTHREAD_CREATE_DETACHED;
+ sp->thread = GetCurrentThreadId ();
#if defined(NEED_DUPLICATEHANDLE)
- /*
- * DuplicateHandle does not exist on WinCE.
- *
- * NOTE:
- * GetCurrentThread only returns a pseudo-handle
- * which is only valid in the current thread context.
- * Therefore, you should not pass the handle to
- * other threads for whatever purpose.
- */
- sp->threadH = GetCurrentThread ();
+ /*
+ * DuplicateHandle does not exist on WinCE.
+ *
+ * NOTE:
+ * GetCurrentThread only returns a pseudo-handle
+ * which is only valid in the current thread context.
+ * Therefore, you should not pass the handle to
+ * other threads for whatever purpose.
+ */
+ sp->threadH = GetCurrentThread ();
#else
- if (!DuplicateHandle (GetCurrentProcess (),
+ if (!DuplicateHandle (GetCurrentProcess (),
GetCurrentThread (),
GetCurrentProcess (),
&sp->threadH,
0, FALSE, DUPLICATE_SAME_ACCESS))
- {
- /*
- * Should not do this, but we have no alternative if
- * we can't get a Win32 thread handle.
- * Thread structs are never freed.
- */
- ptw32_threadReusePush (self);
- /*
- * As this is a win32 thread calling us and we have failed,
- * return a value that makes sense to win32.
- */
- return nil;
- }
+ {
+ fail = PTW32_TRUE;
+ }
#endif
- /*
- * No need to explicitly serialise access to sched_priority
- * because the new handle is not yet public.
- */
- sp->sched_priority = GetThreadPriority (sp->threadH);
- pthread_setspecific (ptw32_selfThreadKey, (void *) sp);
- }
+ if (!fail)
+ {
+
+#if defined(HAVE_CPU_AFFINITY)
+
+ /*
+ * Get this threads CPU affinity by temporarily setting the threads
+ * affinity to that of the process to get the old thread affinity,
+ * then reset to the old affinity.
+ */
+ DWORD_PTR vThreadMask, vProcessMask, vSystemMask;
+ if (GetProcessAffinityMask(GetCurrentProcess(), &vProcessMask, &vSystemMask))
+ {
+ vThreadMask = SetThreadAffinityMask(sp->threadH, vProcessMask);
+ if (vThreadMask)
+ {
+ if (SetThreadAffinityMask(sp->threadH, vThreadMask))
+ {
+ sp->cpuset = (size_t) vThreadMask;
+ }
+ else fail = PTW32_TRUE;
+ }
+ else fail = PTW32_TRUE;
+ }
+ else fail = PTW32_TRUE;
+
+#endif
+
+ /*
+ * No need to explicitly serialise access to sched_priority
+ * because the new handle is not yet public.
+ */
+ sp->sched_priority = GetThreadPriority (sp->threadH);
+ pthread_setspecific (ptw32_selfThreadKey, (void *) sp);
+ }
+ }
+
+ if (fail)
+ {
+ /*
+ * Thread structs are never freed but are reused so if this
+ * continues to fail at least we don't leak memory.
+ */
+ ptw32_threadReusePush (self);
+ /*
+ * As this is a win32 thread calling us and we have failed,
+ * return a value that makes sense to win32.
+ */
+ return nil;
+ }
}
return (self);
-
-} /* pthread_self */
+}
diff --git a/libs/pthreads/src/pthread_setaffinity.c b/libs/pthreads/src/pthread_setaffinity.c
new file mode 100644
index 0000000000..81baaf8784
--- /dev/null
+++ b/libs/pthreads/src/pthread_setaffinity.c
@@ -0,0 +1,242 @@
+/*
+ * pthread_setaffinity.c
+ *
+ * Description:
+ * This translation unit implements thread cpu affinity setting.
+ *
+ * --------------------------------------------------------------------------
+ *
+ * Pthreads4w - POSIX Threads Library for Win32
+ * Copyright(C) 1998 John E. Bossom
+ * Copyright(C) 1999-2018, Pthreads4w contributors
+ *
+ * Homepage: https://sourceforge.net/projects/pthreads4w/
+ *
+ * The current list of contributors is contained
+ * in the file CONTRIBUTORS included with the source
+ * code distribution. The list can also be seen at the
+ * following World Wide Web location:
+ * https://sourceforge.net/p/pthreads4w/wiki/Contributors/
+ *
+ * This file is part of Pthreads4w.
+ *
+ * Pthreads4w is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * Pthreads4w is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Pthreads4w. If not, see <http://www.gnu.org/licenses/>. *
+ */
+
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
+#include "pthread.h"
+#include "implement.h"
+
+int
+pthread_setaffinity_np (pthread_t thread, size_t cpusetsize,
+ const cpu_set_t *cpuset)
+ /*
+ * ------------------------------------------------------
+ * DOCPUBLIC
+ * The pthread_setaffinity_np() function sets the CPU affinity mask
+ * of the thread thread to the CPU set pointed to by cpuset. If the
+ * call is successful, and the thread is not currently running on one
+ * of the CPUs in cpuset, then it is migrated to one of those CPUs.
+ *
+ * PARAMETERS
+ * thread
+ * The target thread
+ *
+ * cpusetsize
+ * Ignored in pthreads4w.
+ * Usually set to sizeof(cpu_set_t)
+ *
+ * cpuset
+ * The new cpu set mask.
+ *
+ * The set of CPUs on which the thread will actually run
+ * is the intersection of the set specified in the cpuset
+ * argument and the set of CPUs actually present for
+ * the process.
+ *
+ * DESCRIPTION
+ * The pthread_setaffinity_np() function sets the CPU affinity mask
+ * of the thread thread to the CPU set pointed to by cpuset. If the
+ * call is successful, and the thread is not currently running on one
+ * of the CPUs in cpuset, then it is migrated to one of those CPUs.
+ *
+ * RESULTS
+ * 0 Success
+ * ESRCH Thread does not exist
+ * EFAULT pcuset is NULL
+ * EAGAIN The thread affinity could not be set
+ * ENOSYS The platform does not support this function
+ *
+ * ------------------------------------------------------
+ */
+{
+#if ! defined(HAVE_CPU_AFFINITY)
+
+ return ENOSYS;
+
+#else
+
+ int result = 0;
+ ptw32_thread_t * tp;
+ ptw32_mcs_local_node_t node;
+ cpu_set_t processCpuset;
+
+ ptw32_mcs_lock_acquire (&ptw32_thread_reuse_lock, &node);
+
+ tp = (ptw32_thread_t *) thread.p;
+
+ if (NULL == tp || thread.x != tp->ptHandle.x || NULL == tp->threadH)
+ {
+ result = ESRCH;
+ }
+ else
+ {
+ if (cpuset)
+ {
+ if (sched_getaffinity(0, sizeof(cpu_set_t), &processCpuset))
+ {
+ result = PTW32_GET_ERRNO();
+ }
+ else
+ {
+ /*
+ * Result is the intersection of available CPUs and the mask.
+ */
+ cpu_set_t newMask;
+
+ CPU_AND(&newMask, &processCpuset, cpuset);
+
+ if (((_sched_cpu_set_vector_*)&newMask)->_cpuset)
+ {
+ if (SetThreadAffinityMask (tp->threadH, ((_sched_cpu_set_vector_*)&newMask)->_cpuset))
+ {
+ /*
+ * We record the intersection of the process affinity
+ * and the thread affinity cpusets so that
+ * pthread_getaffinity_np() returns the actual thread
+ * CPU set.
+ */
+ tp->cpuset = ((_sched_cpu_set_vector_*)&newMask)->_cpuset;
+ }
+ else
+ {
+ result = EAGAIN;
+ }
+ }
+ else
+ {
+ result = EINVAL;
+ }
+ }
+ }
+ else
+ {
+ result = EFAULT;
+ }
+ }
+
+ ptw32_mcs_lock_release (&node);
+
+ return result;
+
+#endif
+}
+
+int
+pthread_getaffinity_np (pthread_t thread, size_t cpusetsize, cpu_set_t *cpuset)
+ /*
+ * ------------------------------------------------------
+ * DOCPUBLIC
+ * The pthread_getaffinity_np() function returns the CPU affinity mask
+ * of the thread thread in the CPU set pointed to by cpuset.
+ *
+ * PARAMETERS
+ * thread
+ * The target thread
+ *
+ * cpusetsize
+ * Ignored in pthreads4w.
+ * Usually set to sizeof(cpu_set_t)
+ *
+ * cpuset
+ * The location where the current cpu set
+ * will be returned.
+ *
+ *
+ * DESCRIPTION
+ * The pthread_getaffinity_np() function returns the CPU affinity mask
+ * of the thread thread in the CPU set pointed to by cpuset.
+ *
+ * RESULTS
+ * 0 Success
+ * ESRCH thread does not exist
+ * EFAULT cpuset is NULL
+ * ENOSYS The platform does not support this function
+ *
+ * ------------------------------------------------------
+ */
+{
+#if ! defined(HAVE_CPU_AFFINITY)
+
+ return ENOSYS;
+
+#else
+
+ int result = 0;
+ ptw32_thread_t * tp;
+ ptw32_mcs_local_node_t node;
+
+ ptw32_mcs_lock_acquire(&ptw32_thread_reuse_lock, &node);
+
+ tp = (ptw32_thread_t *) thread.p;
+
+ if (NULL == tp || thread.x != tp->ptHandle.x || NULL == tp->threadH)
+ {
+ result = ESRCH;
+ }
+ else
+ {
+ if (cpuset)
+ {
+ if (tp->cpuset)
+ {
+ /*
+ * The application may have set thread affinity independently
+ * via SetThreadAffinityMask(). If so, we adjust our record of the threads
+ * affinity and try to do so in a reasonable way.
+ */
+ DWORD_PTR vThreadMask = SetThreadAffinityMask(tp->threadH, tp->cpuset);
+ if (vThreadMask && vThreadMask != tp->cpuset)
+ {
+ (void) SetThreadAffinityMask(tp->threadH, vThreadMask);
+ tp->cpuset = vThreadMask;
+ }
+ }
+ ((_sched_cpu_set_vector_*)cpuset)->_cpuset = tp->cpuset;
+ }
+ else
+ {
+ result = EFAULT;
+ }
+ }
+
+ ptw32_mcs_lock_release(&node);
+
+ return result;
+
+#endif
+}
diff --git a/libs/pthreads/src/pthread_setcancelstate.c b/libs/pthreads/src/pthread_setcancelstate.c
index bbcd624af8..e27d329241 100644
--- a/libs/pthreads/src/pthread_setcancelstate.c
+++ b/libs/pthreads/src/pthread_setcancelstate.c
@@ -6,34 +6,38 @@
*
* --------------------------------------------------------------------------
*
- * Pthreads-win32 - POSIX Threads Library for Win32
+ * Pthreads4w - POSIX Threads Library for Win32
* Copyright(C) 1998 John E. Bossom
- * Copyright(C) 1999,2005 Pthreads-win32 contributors
- *
- * Contact Email: rpj@callisto.canberra.edu.au
- *
+ * Copyright(C) 1999-2018, Pthreads4w contributors
+ *
+ * Homepage: https://sourceforge.net/projects/pthreads4w/
+ *
* The current list of contributors is contained
* in the file CONTRIBUTORS included with the source
* code distribution. The list can also be seen at the
* following World Wide Web location:
- * http://sources.redhat.com/pthreads-win32/contributors.html
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library in the file COPYING.LIB;
- * if not, write to the Free Software Foundation, Inc.,
- * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
+ * https://sourceforge.net/p/pthreads4w/wiki/Contributors/
+ *
+ * This file is part of Pthreads4w.
+ *
+ * Pthreads4w is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * Pthreads4w is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Pthreads4w. If not, see <http://www.gnu.org/licenses/>. *
*/
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
#include "pthread.h"
#include "implement.h"
diff --git a/libs/pthreads/src/pthread_setcanceltype.c b/libs/pthreads/src/pthread_setcanceltype.c
index 72b0af5bbc..e588ba268b 100644
--- a/libs/pthreads/src/pthread_setcanceltype.c
+++ b/libs/pthreads/src/pthread_setcanceltype.c
@@ -6,34 +6,38 @@
*
* --------------------------------------------------------------------------
*
- * Pthreads-win32 - POSIX Threads Library for Win32
+ * Pthreads4w - POSIX Threads Library for Win32
* Copyright(C) 1998 John E. Bossom
- * Copyright(C) 1999,2005 Pthreads-win32 contributors
- *
- * Contact Email: rpj@callisto.canberra.edu.au
- *
+ * Copyright(C) 1999-2018, Pthreads4w contributors
+ *
+ * Homepage: https://sourceforge.net/projects/pthreads4w/
+ *
* The current list of contributors is contained
* in the file CONTRIBUTORS included with the source
* code distribution. The list can also be seen at the
* following World Wide Web location:
- * http://sources.redhat.com/pthreads-win32/contributors.html
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library in the file COPYING.LIB;
- * if not, write to the Free Software Foundation, Inc.,
- * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
+ * https://sourceforge.net/p/pthreads4w/wiki/Contributors/
+ *
+ * This file is part of Pthreads4w.
+ *
+ * Pthreads4w is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * Pthreads4w is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Pthreads4w. If not, see <http://www.gnu.org/licenses/>. *
*/
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
#include "pthread.h"
#include "implement.h"
@@ -52,7 +56,7 @@ pthread_setcanceltype (int type, int *oldtype)
* type,
* oldtype
* PTHREAD_CANCEL_DEFERRED
- * only deferred cancelation is allowed,
+ * only deferred cancellation is allowed,
*
* PTHREAD_CANCEL_ASYNCHRONOUS
* Asynchronous cancellation is allowed
diff --git a/libs/pthreads/src/pthread_setconcurrency.c b/libs/pthreads/src/pthread_setconcurrency.c
index f62346f8e5..df8d785e66 100644
--- a/libs/pthreads/src/pthread_setconcurrency.c
+++ b/libs/pthreads/src/pthread_setconcurrency.c
@@ -6,34 +6,38 @@
*
* --------------------------------------------------------------------------
*
- * Pthreads-win32 - POSIX Threads Library for Win32
+ * Pthreads4w - POSIX Threads Library for Win32
* Copyright(C) 1998 John E. Bossom
- * Copyright(C) 1999,2005 Pthreads-win32 contributors
- *
- * Contact Email: rpj@callisto.canberra.edu.au
- *
+ * Copyright(C) 1999-2018, Pthreads4w contributors
+ *
+ * Homepage: https://sourceforge.net/projects/pthreads4w/
+ *
* The current list of contributors is contained
* in the file CONTRIBUTORS included with the source
* code distribution. The list can also be seen at the
* following World Wide Web location:
- * http://sources.redhat.com/pthreads-win32/contributors.html
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library in the file COPYING.LIB;
- * if not, write to the Free Software Foundation, Inc.,
- * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
+ * https://sourceforge.net/p/pthreads4w/wiki/Contributors/
+ *
+ * This file is part of Pthreads4w.
+ *
+ * Pthreads4w is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * Pthreads4w is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Pthreads4w. If not, see <http://www.gnu.org/licenses/>. *
*/
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
#include "pthread.h"
#include "implement.h"
diff --git a/libs/pthreads/src/pthread_setname_np.c b/libs/pthreads/src/pthread_setname_np.c
new file mode 100644
index 0000000000..cca2bff733
--- /dev/null
+++ b/libs/pthreads/src/pthread_setname_np.c
@@ -0,0 +1,192 @@
+/*
+ * pthread_setname_np.c
+ *
+ * --------------------------------------------------------------------------
+ *
+ * Pthreads4w - POSIX Threads Library for Win32
+ * Copyright(C) 1998 John E. Bossom
+ * Copyright(C) 1999-2018, Pthreads4w contributors
+ *
+ * Homepage: https://sourceforge.net/projects/pthreads4w/
+ *
+ * The current list of contributors is contained
+ * in the file CONTRIBUTORS included with the source
+ * code distribution. The list can also be seen at the
+ * following World Wide Web location:
+ * https://sourceforge.net/p/pthreads4w/wiki/Contributors/
+ *
+ * This file is part of Pthreads4w.
+ *
+ * Pthreads4w is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * Pthreads4w is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Pthreads4w. If not, see <http://www.gnu.org/licenses/>. *
+ */
+
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
+#include <stdio.h>
+#include <string.h>
+#include "pthread.h"
+#include "implement.h"
+
+#if defined(_MSC_VER)
+#define MS_VC_EXCEPTION 0x406D1388
+
+#pragma pack(push,8)
+typedef struct tagTHREADNAME_INFO
+{
+ DWORD dwType; // Must be 0x1000.
+ LPCSTR szName; // Pointer to name (in user addr space).
+ DWORD dwThreadID; // Thread ID (-1=caller thread).
+ DWORD dwFlags; // Reserved for future use, must be zero.
+} THREADNAME_INFO;
+#pragma pack(pop)
+
+void
+SetThreadName( DWORD dwThreadID, char* threadName)
+{
+ THREADNAME_INFO info;
+ info.dwType = 0x1000;
+ info.szName = threadName;
+ info.dwThreadID = dwThreadID;
+ info.dwFlags = 0;
+
+ __try
+ {
+ RaiseException( MS_VC_EXCEPTION, 0, sizeof(info)/sizeof(ULONG_PTR), (ULONG_PTR*)&info );
+ }
+ __except(EXCEPTION_EXECUTE_HANDLER)
+ {
+ }
+}
+#endif
+
+#if defined(PTW32_COMPATIBILITY_BSD) || defined(PTW32_COMPATIBILITY_TRU64)
+int
+pthread_setname_np(pthread_t thr, const char *name, void *arg)
+{
+ ptw32_mcs_local_node_t threadLock;
+ int len;
+ int result;
+ char tmpbuf[PTHREAD_MAX_NAMELEN_NP];
+ char * newname;
+ char * oldname;
+ ptw32_thread_t * tp;
+#if defined(_MSC_VER)
+ DWORD Win32ThreadID;
+#endif
+
+ /*
+ * Validate the thread id. This method works for Pthreads4w because
+ * pthread_kill and pthread_t are designed to accommodate it, but the
+ * method is not portable.
+ */
+ result = pthread_kill (thr, 0);
+ if (0 != result)
+ {
+ return result;
+ }
+
+ /*
+ * According to the MSDN description for snprintf()
+ * where count is the second parameter:
+ * If len < count, then len characters are stored in buffer, a null-terminator is appended, and len is returned.
+ * If len = count, then len characters are stored in buffer, no null-terminator is appended, and len is returned.
+ * If len > count, then count characters are stored in buffer, no null-terminator is appended, and a negative value is returned.
+ *
+ * This is different to the POSIX behaviour which returns the number of characters that would have been written in all cases.
+ */
+ len = snprintf(tmpbuf, PTHREAD_MAX_NAMELEN_NP-1, name, arg);
+ tmpbuf[PTHREAD_MAX_NAMELEN_NP-1] = '\0';
+ if (len < 0)
+ {
+ return EINVAL;
+ }
+
+ newname = _strdup(tmpbuf);
+
+#if defined(_MSC_VER)
+ Win32ThreadID = pthread_getw32threadid_np (thr);
+ if (Win32ThreadID)
+ {
+ SetThreadName(Win32ThreadID, newname);
+ }
+#endif
+
+ tp = (ptw32_thread_t *) thr.p;
+
+ ptw32_mcs_lock_acquire (&tp->threadLock, &threadLock);
+
+ oldname = tp->name;
+ tp->name = newname;
+ if (oldname)
+ {
+ free(oldname);
+ }
+
+ ptw32_mcs_lock_release (&threadLock);
+
+ return 0;
+}
+#else
+int
+pthread_setname_np(pthread_t thr, const char *name)
+{
+ ptw32_mcs_local_node_t threadLock;
+ int result;
+ char * newname;
+ char * oldname;
+ ptw32_thread_t * tp;
+#if defined(_MSC_VER)
+ DWORD Win32ThreadID;
+#endif
+
+ /*
+ * Validate the thread id. This method works for Pthreads4w because
+ * pthread_kill and pthread_t are designed to accommodate it, but the
+ * method is not portable.
+ */
+ result = pthread_kill (thr, 0);
+ if (0 != result)
+ {
+ return result;
+ }
+
+ newname = _strdup(name);
+
+#if defined(_MSC_VER)
+ Win32ThreadID = pthread_getw32threadid_np (thr);
+
+ if (Win32ThreadID)
+ {
+ SetThreadName(Win32ThreadID, newname);
+ }
+#endif
+
+ tp = (ptw32_thread_t *) thr.p;
+
+ ptw32_mcs_lock_acquire (&tp->threadLock, &threadLock);
+
+ oldname = tp->name;
+ tp->name = newname;
+ if (oldname)
+ {
+ free(oldname);
+ }
+
+ ptw32_mcs_lock_release (&threadLock);
+
+ return 0;
+}
+#endif
diff --git a/libs/pthreads/src/pthread_setschedparam.c b/libs/pthreads/src/pthread_setschedparam.c
index b762753cdd..f69e405828 100644
--- a/libs/pthreads/src/pthread_setschedparam.c
+++ b/libs/pthreads/src/pthread_setschedparam.c
@@ -1,39 +1,43 @@
/*
* sched_setschedparam.c
- *
+ *
* Description:
* POSIX thread functions that deal with thread scheduling.
*
* --------------------------------------------------------------------------
*
- * Pthreads-win32 - POSIX Threads Library for Win32
+ * Pthreads4w - POSIX Threads Library for Win32
* Copyright(C) 1998 John E. Bossom
- * Copyright(C) 1999,2005 Pthreads-win32 contributors
- *
- * Contact Email: rpj@callisto.canberra.edu.au
- *
+ * Copyright(C) 1999-2018, Pthreads4w contributors
+ *
+ * Homepage: https://sourceforge.net/projects/pthreads4w/
+ *
* The current list of contributors is contained
* in the file CONTRIBUTORS included with the source
* code distribution. The list can also be seen at the
* following World Wide Web location:
- * http://sources.redhat.com/pthreads-win32/contributors.html
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library in the file COPYING.LIB;
- * if not, write to the Free Software Foundation, Inc.,
- * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
+ * https://sourceforge.net/p/pthreads4w/wiki/Contributors/
+ *
+ * This file is part of Pthreads4w.
+ *
+ * Pthreads4w is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * Pthreads4w is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Pthreads4w. If not, see <http://www.gnu.org/licenses/>. *
*/
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
#include "pthread.h"
#include "implement.h"
#include "sched.h"
@@ -44,7 +48,11 @@ pthread_setschedparam (pthread_t thread, int policy,
{
int result;
- /* Validate the thread id. */
+ /*
+ * Validate the thread id. This method works for Pthreads4w because
+ * pthread_kill and pthread_t are designed to accommodate it, but the
+ * method is not portable.
+ */
result = pthread_kill (thread, 0);
if (0 != result)
{
diff --git a/libs/pthreads/src/pthread_setspecific.c b/libs/pthreads/src/pthread_setspecific.c
index 0f29e704ab..5dbf86433e 100644
--- a/libs/pthreads/src/pthread_setspecific.c
+++ b/libs/pthreads/src/pthread_setspecific.c
@@ -6,34 +6,38 @@
*
* --------------------------------------------------------------------------
*
- * Pthreads-win32 - POSIX Threads Library for Win32
+ * Pthreads4w - POSIX Threads Library for Win32
* Copyright(C) 1998 John E. Bossom
- * Copyright(C) 1999,2005 Pthreads-win32 contributors
- *
- * Contact Email: rpj@callisto.canberra.edu.au
- *
+ * Copyright(C) 1999-2018, Pthreads4w contributors
+ *
+ * Homepage: https://sourceforge.net/projects/pthreads4w/
+ *
* The current list of contributors is contained
* in the file CONTRIBUTORS included with the source
* code distribution. The list can also be seen at the
* following World Wide Web location:
- * http://sources.redhat.com/pthreads-win32/contributors.html
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library in the file COPYING.LIB;
- * if not, write to the Free Software Foundation, Inc.,
- * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
+ * https://sourceforge.net/p/pthreads4w/wiki/Contributors/
+ *
+ * This file is part of Pthreads4w.
+ *
+ * Pthreads4w is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * Pthreads4w is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Pthreads4w. If not, see <http://www.gnu.org/licenses/>. *
*/
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
#include "pthread.h"
#include "implement.h"
diff --git a/libs/pthreads/src/pthread_spin_destroy.c b/libs/pthreads/src/pthread_spin_destroy.c
index 786c4e34cd..a681fab512 100644
--- a/libs/pthreads/src/pthread_spin_destroy.c
+++ b/libs/pthreads/src/pthread_spin_destroy.c
@@ -6,34 +6,38 @@
*
* --------------------------------------------------------------------------
*
- * Pthreads-win32 - POSIX Threads Library for Win32
+ * Pthreads4w - POSIX Threads Library for Win32
* Copyright(C) 1998 John E. Bossom
- * Copyright(C) 1999,2005 Pthreads-win32 contributors
- *
- * Contact Email: rpj@callisto.canberra.edu.au
- *
+ * Copyright(C) 1999-2018, Pthreads4w contributors
+ *
+ * Homepage: https://sourceforge.net/projects/pthreads4w/
+ *
* The current list of contributors is contained
* in the file CONTRIBUTORS included with the source
* code distribution. The list can also be seen at the
* following World Wide Web location:
- * http://sources.redhat.com/pthreads-win32/contributors.html
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library in the file COPYING.LIB;
- * if not, write to the Free Software Foundation, Inc.,
- * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
+ * https://sourceforge.net/p/pthreads4w/wiki/Contributors/
+ *
+ * This file is part of Pthreads4w.
+ *
+ * Pthreads4w is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * Pthreads4w is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Pthreads4w. If not, see <http://www.gnu.org/licenses/>. *
*/
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
#include "pthread.h"
#include "implement.h"
diff --git a/libs/pthreads/src/pthread_spin_init.c b/libs/pthreads/src/pthread_spin_init.c
index 553af7eac8..b49da6c3c9 100644
--- a/libs/pthreads/src/pthread_spin_init.c
+++ b/libs/pthreads/src/pthread_spin_init.c
@@ -6,34 +6,38 @@
*
* --------------------------------------------------------------------------
*
- * Pthreads-win32 - POSIX Threads Library for Win32
+ * Pthreads4w - POSIX Threads Library for Win32
* Copyright(C) 1998 John E. Bossom
- * Copyright(C) 1999,2005 Pthreads-win32 contributors
- *
- * Contact Email: rpj@callisto.canberra.edu.au
- *
+ * Copyright(C) 1999-2018, Pthreads4w contributors
+ *
+ * Homepage: https://sourceforge.net/projects/pthreads4w/
+ *
* The current list of contributors is contained
* in the file CONTRIBUTORS included with the source
* code distribution. The list can also be seen at the
* following World Wide Web location:
- * http://sources.redhat.com/pthreads-win32/contributors.html
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library in the file COPYING.LIB;
- * if not, write to the Free Software Foundation, Inc.,
- * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
+ * https://sourceforge.net/p/pthreads4w/wiki/Contributors/
+ *
+ * This file is part of Pthreads4w.
+ *
+ * Pthreads4w is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * Pthreads4w is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Pthreads4w. If not, see <http://www.gnu.org/licenses/>. *
*/
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
#include "pthread.h"
#include "implement.h"
diff --git a/libs/pthreads/src/pthread_spin_lock.c b/libs/pthreads/src/pthread_spin_lock.c
index b560e14891..d846014c85 100644
--- a/libs/pthreads/src/pthread_spin_lock.c
+++ b/libs/pthreads/src/pthread_spin_lock.c
@@ -6,34 +6,38 @@
*
* --------------------------------------------------------------------------
*
- * Pthreads-win32 - POSIX Threads Library for Win32
+ * Pthreads4w - POSIX Threads Library for Win32
* Copyright(C) 1998 John E. Bossom
- * Copyright(C) 1999,2005 Pthreads-win32 contributors
- *
- * Contact Email: rpj@callisto.canberra.edu.au
- *
+ * Copyright(C) 1999-2018, Pthreads4w contributors
+ *
+ * Homepage: https://sourceforge.net/projects/pthreads4w/
+ *
* The current list of contributors is contained
* in the file CONTRIBUTORS included with the source
* code distribution. The list can also be seen at the
* following World Wide Web location:
- * http://sources.redhat.com/pthreads-win32/contributors.html
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library in the file COPYING.LIB;
- * if not, write to the Free Software Foundation, Inc.,
- * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
+ * https://sourceforge.net/p/pthreads4w/wiki/Contributors/
+ *
+ * This file is part of Pthreads4w.
+ *
+ * Pthreads4w is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * Pthreads4w is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Pthreads4w. If not, see <http://www.gnu.org/licenses/>. *
*/
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
#include "pthread.h"
#include "implement.h"
diff --git a/libs/pthreads/src/pthread_spin_trylock.c b/libs/pthreads/src/pthread_spin_trylock.c
index a6c65aff6a..026e627ada 100644
--- a/libs/pthreads/src/pthread_spin_trylock.c
+++ b/libs/pthreads/src/pthread_spin_trylock.c
@@ -6,34 +6,38 @@
*
* --------------------------------------------------------------------------
*
- * Pthreads-win32 - POSIX Threads Library for Win32
+ * Pthreads4w - POSIX Threads Library for Win32
* Copyright(C) 1998 John E. Bossom
- * Copyright(C) 1999,2005 Pthreads-win32 contributors
- *
- * Contact Email: rpj@callisto.canberra.edu.au
- *
+ * Copyright(C) 1999-2018, Pthreads4w contributors
+ *
+ * Homepage: https://sourceforge.net/projects/pthreads4w/
+ *
* The current list of contributors is contained
* in the file CONTRIBUTORS included with the source
* code distribution. The list can also be seen at the
* following World Wide Web location:
- * http://sources.redhat.com/pthreads-win32/contributors.html
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library in the file COPYING.LIB;
- * if not, write to the Free Software Foundation, Inc.,
- * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
+ * https://sourceforge.net/p/pthreads4w/wiki/Contributors/
+ *
+ * This file is part of Pthreads4w.
+ *
+ * Pthreads4w is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * Pthreads4w is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Pthreads4w. If not, see <http://www.gnu.org/licenses/>. *
*/
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
#include "pthread.h"
#include "implement.h"
diff --git a/libs/pthreads/src/pthread_spin_unlock.c b/libs/pthreads/src/pthread_spin_unlock.c
index 3a6932aef3..93cd5c51b6 100644
--- a/libs/pthreads/src/pthread_spin_unlock.c
+++ b/libs/pthreads/src/pthread_spin_unlock.c
@@ -6,34 +6,38 @@
*
* --------------------------------------------------------------------------
*
- * Pthreads-win32 - POSIX Threads Library for Win32
+ * Pthreads4w - POSIX Threads Library for Win32
* Copyright(C) 1998 John E. Bossom
- * Copyright(C) 1999,2005 Pthreads-win32 contributors
- *
- * Contact Email: rpj@callisto.canberra.edu.au
- *
+ * Copyright(C) 1999-2018, Pthreads4w contributors
+ *
+ * Homepage: https://sourceforge.net/projects/pthreads4w/
+ *
* The current list of contributors is contained
* in the file CONTRIBUTORS included with the source
* code distribution. The list can also be seen at the
* following World Wide Web location:
- * http://sources.redhat.com/pthreads-win32/contributors.html
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library in the file COPYING.LIB;
- * if not, write to the Free Software Foundation, Inc.,
- * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
+ * https://sourceforge.net/p/pthreads4w/wiki/Contributors/
+ *
+ * This file is part of Pthreads4w.
+ *
+ * Pthreads4w is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * Pthreads4w is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Pthreads4w. If not, see <http://www.gnu.org/licenses/>. *
*/
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
#include "pthread.h"
#include "implement.h"
diff --git a/libs/pthreads/src/pthread_testcancel.c b/libs/pthreads/src/pthread_testcancel.c
index 6658650000..3ae79bbd2d 100644
--- a/libs/pthreads/src/pthread_testcancel.c
+++ b/libs/pthreads/src/pthread_testcancel.c
@@ -6,34 +6,38 @@
*
* --------------------------------------------------------------------------
*
- * Pthreads-win32 - POSIX Threads Library for Win32
+ * Pthreads4w - POSIX Threads Library for Win32
* Copyright(C) 1998 John E. Bossom
- * Copyright(C) 1999,2005 Pthreads-win32 contributors
- *
- * Contact Email: rpj@callisto.canberra.edu.au
- *
+ * Copyright(C) 1999-2018, Pthreads4w contributors
+ *
+ * Homepage: https://sourceforge.net/projects/pthreads4w/
+ *
* The current list of contributors is contained
* in the file CONTRIBUTORS included with the source
* code distribution. The list can also be seen at the
* following World Wide Web location:
- * http://sources.redhat.com/pthreads-win32/contributors.html
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library in the file COPYING.LIB;
- * if not, write to the Free Software Foundation, Inc.,
- * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
+ * https://sourceforge.net/p/pthreads4w/wiki/Contributors/
+ *
+ * This file is part of Pthreads4w.
+ *
+ * Pthreads4w is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * Pthreads4w is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Pthreads4w. If not, see <http://www.gnu.org/licenses/>. *
*/
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
#include "pthread.h"
#include "implement.h"
diff --git a/libs/pthreads/src/pthread_timechange_handler_np.c b/libs/pthreads/src/pthread_timechange_handler_np.c
index 0f97e74f14..c34571d2ce 100644
--- a/libs/pthreads/src/pthread_timechange_handler_np.c
+++ b/libs/pthreads/src/pthread_timechange_handler_np.c
@@ -6,34 +6,38 @@
*
* --------------------------------------------------------------------------
*
- * Pthreads-win32 - POSIX Threads Library for Win32
+ * Pthreads4w - POSIX Threads Library for Win32
* Copyright(C) 1998 John E. Bossom
- * Copyright(C) 1999,2005 Pthreads-win32 contributors
- *
- * Contact Email: rpj@callisto.canberra.edu.au
- *
+ * Copyright(C) 1999-2018, Pthreads4w contributors
+ *
+ * Homepage: https://sourceforge.net/projects/pthreads4w/
+ *
* The current list of contributors is contained
* in the file CONTRIBUTORS included with the source
* code distribution. The list can also be seen at the
* following World Wide Web location:
- * http://sources.redhat.com/pthreads-win32/contributors.html
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library in the file COPYING.LIB;
- * if not, write to the Free Software Foundation, Inc.,
- * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
+ * https://sourceforge.net/p/pthreads4w/wiki/Contributors/
+ *
+ * This file is part of Pthreads4w.
+ *
+ * Pthreads4w is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * Pthreads4w is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Pthreads4w. If not, see <http://www.gnu.org/licenses/>. *
*/
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
#include "pthread.h"
#include "implement.h"
@@ -47,7 +51,7 @@
* 1) The problem: threads doing a timedwait on a CV may expect to timeout
* at a specific absolute time according to a system timer. If the
* system clock is adjusted backwards then those threads sleep longer than
- * expected. Also, pthreads-win32 converts absolute times to intervals in
+ * expected. Also, Pthreads4w converts absolute times to intervals in
* order to make use of the underlying Win32, and so waiting threads may
* awake before their proper abstimes.
*
diff --git a/libs/pthreads/src/pthread_timedjoin_np.c b/libs/pthreads/src/pthread_timedjoin_np.c
new file mode 100644
index 0000000000..854ba0abb5
--- /dev/null
+++ b/libs/pthreads/src/pthread_timedjoin_np.c
@@ -0,0 +1,187 @@
+/*
+ * pthread_timedjoin_np.c
+ *
+ * Description:
+ * This translation unit implements functions related to thread
+ * synchronisation.
+ *
+ * --------------------------------------------------------------------------
+ *
+ * Pthreads4w - POSIX Threads Library for Win32
+ * Copyright(C) 1998 John E. Bossom
+ * Copyright(C) 1999-2018, Pthreads4w contributors
+ *
+ * Homepage: https://sourceforge.net/projects/pthreads4w/
+ *
+ * The current list of contributors is contained
+ * in the file CONTRIBUTORS included with the source
+ * code distribution. The list can also be seen at the
+ * following World Wide Web location:
+ * https://sourceforge.net/p/pthreads4w/wiki/Contributors/
+ *
+ * This file is part of Pthreads4w.
+ *
+ * Pthreads4w is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * Pthreads4w is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Pthreads4w. If not, see <http://www.gnu.org/licenses/>. *
+ */
+
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
+#include "pthread.h"
+#include "implement.h"
+
+/*
+ * Not needed yet, but defining it should indicate clashes with build target
+ * environment that should be fixed.
+ */
+#if !defined(WINCE)
+# include <signal.h>
+#endif
+
+
+int
+pthread_timedjoin_np (pthread_t thread, void **value_ptr, const struct timespec *abstime)
+ /*
+ * ------------------------------------------------------
+ * DOCPUBLIC
+ * This function waits for 'thread' to terminate and
+ * returns the thread's exit value if 'value_ptr' is not
+ * NULL or until 'abstime' passes and returns an
+ * error. If 'abstime' is NULL then the function waits
+ * forever, i.e. reverts to pthread_join behaviour.
+ * This function detaches the thread on successful
+ * completion.
+ *
+ * PARAMETERS
+ * thread
+ * an instance of pthread_t
+ *
+ * value_ptr
+ * pointer to an instance of pointer to void
+ *
+ * abstime
+ * pointer to an instance of struct timespec
+ * representing an absolute time value
+ *
+ *
+ * DESCRIPTION
+ * This function waits for 'thread' to terminate and
+ * returns the thread's exit value if 'value_ptr' is not
+ * NULL or until 'abstime' passes and returns an
+ * error. If 'abstime' is NULL then the function waits
+ * forever, i.e. reverts to pthread_join behaviour.
+ * This function detaches the thread on successful
+ * completion.
+ * NOTE: Detached threads cannot be joined or canceled.
+ * In this implementation 'abstime' will be
+ * resolved to the nearest millisecond.
+ *
+ * RESULTS
+ * 0 'thread' has completed
+ * ETIMEDOUT abstime passed
+ * EINVAL thread is not a joinable thread,
+ * ESRCH no thread could be found with ID 'thread',
+ * ENOENT thread couldn't find it's own valid handle,
+ * EDEADLK attempt to join thread with self
+ *
+ * ------------------------------------------------------
+ */
+{
+ int result;
+ pthread_t self;
+ DWORD milliseconds;
+ ptw32_thread_t * tp = (ptw32_thread_t *) thread.p;
+ ptw32_mcs_local_node_t node;
+
+ if (abstime == NULL)
+ {
+ milliseconds = INFINITE;
+ }
+ else
+ {
+ /*
+ * Calculate timeout as milliseconds from current system time.
+ */
+ milliseconds = ptw32_relmillisecs (abstime);
+ }
+
+ ptw32_mcs_lock_acquire(&ptw32_thread_reuse_lock, &node);
+
+ if (NULL == tp
+ || thread.x != tp->ptHandle.x)
+ {
+ result = ESRCH;
+ }
+ else if (PTHREAD_CREATE_DETACHED == tp->detachState)
+ {
+ result = EINVAL;
+ }
+ else
+ {
+ result = 0;
+ }
+
+ ptw32_mcs_lock_release(&node);
+
+ if (result == 0)
+ {
+ /*
+ * The target thread is joinable and can't be reused before we join it.
+ */
+ self = pthread_self();
+
+ if (NULL == self.p)
+ {
+ result = ENOENT;
+ }
+ else if (pthread_equal (self, thread))
+ {
+ result = EDEADLK;
+ }
+ else
+ {
+ /*
+ * Pthread_join is a cancellation point.
+ * If we are canceled then our target thread must not be
+ * detached (destroyed). This is guaranteed because
+ * pthreadCancelableTimedWait will not return if we
+ * are canceled.
+ */
+ result = pthreadCancelableTimedWait (tp->threadH, milliseconds);
+
+ if (0 == result)
+ {
+ if (value_ptr != NULL)
+ {
+ *value_ptr = tp->exitStatus;
+ }
+
+ /*
+ * The result of making multiple simultaneous calls to
+ * pthread_join() or pthread_timedjoin_np() or pthread_detach()
+ * specifying the same target is undefined.
+ */
+ result = pthread_detach (thread);
+ }
+ else if (ETIMEDOUT != result)
+ {
+ result = ESRCH;
+ }
+ }
+ }
+
+ return (result);
+
+}
diff --git a/libs/pthreads/src/pthread_tryjoin_np.c b/libs/pthreads/src/pthread_tryjoin_np.c
new file mode 100644
index 0000000000..d09bb72c0b
--- /dev/null
+++ b/libs/pthreads/src/pthread_tryjoin_np.c
@@ -0,0 +1,172 @@
+/*
+ * pthread_tryjoin_np.c
+ *
+ * Description:
+ * This translation unit implements functions related to thread
+ * synchronisation.
+ *
+ * --------------------------------------------------------------------------
+ *
+ * Pthreads4w - POSIX Threads Library for Win32
+ * Copyright(C) 1998 John E. Bossom
+ * Copyright(C) 1999-2018, Pthreads4w contributors
+ *
+ * Homepage: https://sourceforge.net/projects/pthreads4w/
+ *
+ * The current list of contributors is contained
+ * in the file CONTRIBUTORS included with the source
+ * code distribution. The list can also be seen at the
+ * following World Wide Web location:
+ * https://sourceforge.net/p/pthreads4w/wiki/Contributors/
+ *
+ * This file is part of Pthreads4w.
+ *
+ * Pthreads4w is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * Pthreads4w is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Pthreads4w. If not, see <http://www.gnu.org/licenses/>. *
+ */
+
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
+#include "pthread.h"
+#include "implement.h"
+
+/*
+ * Not needed yet, but defining it should indicate clashes with build target
+ * environment that should be fixed.
+ */
+#if !defined(WINCE)
+# include <signal.h>
+#endif
+
+
+int
+pthread_tryjoin_np (pthread_t thread, void **value_ptr)
+ /*
+ * ------------------------------------------------------
+ * DOCPUBLIC
+ * This function checks if 'thread' has terminated and
+ * returns the thread's exit value if 'value_ptr' is not
+ * NULL or until 'abstime' passes and returns an
+ * error. If the thread has not exited the function returns
+ * immediately. This function detaches the thread on successful
+ * completion.
+ *
+ * PARAMETERS
+ * thread
+ * an instance of pthread_t
+ *
+ * value_ptr
+ * pointer to an instance of pointer to void
+ *
+ *
+ * DESCRIPTION
+ * This function checks if 'thread' has terminated and
+ * returns the thread's exit value if 'value_ptr' is not
+ * NULL or until 'abstime' passes and returns an
+ * error. If the thread has not exited the function returns
+ * immediately. This function detaches the thread on successful
+ * completion.
+ * NOTE: Detached threads cannot be joined or canceled.
+ * In this implementation 'abstime' will be
+ * resolved to the nearest millisecond.
+ *
+ * RESULTS
+ * 0 'thread' has completed
+ * EBUSY 'thread' is still live
+ * EINVAL thread is not a joinable thread,
+ * ESRCH no thread could be found with ID 'thread',
+ * ENOENT thread couldn't find it's own valid handle,
+ * EDEADLK attempt to join thread with self
+ *
+ * ------------------------------------------------------
+ */
+{
+ int result;
+ pthread_t self;
+ ptw32_thread_t * tp = (ptw32_thread_t *) thread.p;
+ ptw32_mcs_local_node_t node;
+
+ ptw32_mcs_lock_acquire(&ptw32_thread_reuse_lock, &node);
+
+ if (NULL == tp
+ || thread.x != tp->ptHandle.x)
+ {
+ result = ESRCH;
+ }
+ else if (PTHREAD_CREATE_DETACHED == tp->detachState)
+ {
+ result = EINVAL;
+ }
+ else
+ {
+ result = 0;
+ }
+
+ ptw32_mcs_lock_release(&node);
+
+ if (result == 0)
+ {
+ /*
+ * The target thread is joinable and can't be reused before we join it.
+ */
+ self = pthread_self();
+
+ if (NULL == self.p)
+ {
+ result = ENOENT;
+ }
+ else if (pthread_equal (self, thread))
+ {
+ result = EDEADLK;
+ }
+ else
+ {
+ /*
+ * Pthread_join is a cancellation point.
+ * If we are canceled then our target thread must not be
+ * detached (destroyed). This is guaranteed because
+ * pthreadCancelableTimedWait will not return if we
+ * are canceled.
+ */
+ result = pthreadCancelableTimedWait (tp->threadH, 0);
+
+ if (0 == result)
+ {
+ if (value_ptr != NULL)
+ {
+ *value_ptr = tp->exitStatus;
+ }
+
+ /*
+ * The result of making multiple simultaneous calls to
+ * pthread_join(), pthread_timedjoin_np(), pthread_tryjoin_np()
+ * or pthread_detach() specifying the same target is undefined.
+ */
+ result = pthread_detach (thread);
+ }
+ else if (ETIMEDOUT == result)
+ {
+ result = EBUSY;
+ }
+ else
+ {
+ result = ESRCH;
+ }
+ }
+ }
+
+ return (result);
+
+}
diff --git a/libs/pthreads/src/pthread_win32_attach_detach_np.c b/libs/pthreads/src/pthread_win32_attach_detach_np.c
index bfad450653..68a20f443f 100644
--- a/libs/pthreads/src/pthread_win32_attach_detach_np.c
+++ b/libs/pthreads/src/pthread_win32_attach_detach_np.c
@@ -6,39 +6,47 @@
*
* --------------------------------------------------------------------------
*
- * Pthreads-win32 - POSIX Threads Library for Win32
+ * Pthreads4w - POSIX Threads Library for Win32
* Copyright(C) 1998 John E. Bossom
- * Copyright(C) 1999,2005 Pthreads-win32 contributors
- *
- * Contact Email: rpj@callisto.canberra.edu.au
- *
+ * Copyright(C) 1999-2018, Pthreads4w contributors
+ *
+ * Homepage: https://sourceforge.net/projects/pthreads4w/
+ *
* The current list of contributors is contained
* in the file CONTRIBUTORS included with the source
* code distribution. The list can also be seen at the
* following World Wide Web location:
- * http://sources.redhat.com/pthreads-win32/contributors.html
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library in the file COPYING.LIB;
- * if not, write to the Free Software Foundation, Inc.,
- * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
+ * https://sourceforge.net/p/pthreads4w/wiki/Contributors/
+ *
+ * This file is part of Pthreads4w.
+ *
+ * Pthreads4w is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * Pthreads4w is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Pthreads4w. If not, see <http://www.gnu.org/licenses/>. *
*/
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
#include "pthread.h"
#include "implement.h"
+#include <tchar.h>
+#if ! (defined(__GNUC__) || defined(PTW32_CONFIG_MSVC7) || defined(WINCE))
+# include <stdlib.h>
+#endif
/*
- * Handle to quserex.dll
+ * Handle to quserex.dll
*/
static HINSTANCE ptw32_h_quserex;
@@ -70,7 +78,7 @@ pthread_win32_process_attach_np ()
*
* This should take care of any security issues.
*/
-#if defined(__GNUC__) || _MSC_VER < 1400
+#if defined(__GNUC__) || defined(PTW32_CONFIG_MSVC7)
if(GetSystemDirectory(QuserExDLLPathBuf, sizeof(QuserExDLLPathBuf)))
{
(void) strncat(QuserExDLLPathBuf,
@@ -79,17 +87,18 @@ pthread_win32_process_attach_np ()
ptw32_h_quserex = LoadLibrary(QuserExDLLPathBuf);
}
#else
- /* strncat is secure - this is just to avoid a warning */
- if(GetSystemDirectory(QuserExDLLPathBuf, sizeof(QuserExDLLPathBuf)) &&
- 0 == strncat_s(QuserExDLLPathBuf, sizeof(QuserExDLLPathBuf), "\\QUSEREX.DLL", 12))
- {
- ptw32_h_quserex = LoadLibrary(QuserExDLLPathBuf);
- }
+# if ! defined(WINCE)
+ if(GetSystemDirectory(QuserExDLLPathBuf, sizeof(QuserExDLLPathBuf)/sizeof(TCHAR)) &&
+ 0 == _tcsncat_s(QuserExDLLPathBuf, _countof(QuserExDLLPathBuf), TEXT("\\QUSEREX.DLL"), 12))
+ {
+ ptw32_h_quserex = LoadLibrary(QuserExDLLPathBuf);
+ }
+# endif
#endif
if (ptw32_h_quserex != NULL)
{
- ptw32_register_cancelation = (DWORD (*)(PAPCFUNC, HANDLE, DWORD))
+ ptw32_register_cancellation = (DWORD (*)(PAPCFUNC, HANDLE, DWORD))
#if defined(NEED_UNICODE_CONSTS)
GetProcAddress (ptw32_h_quserex,
(const TCHAR *) TEXT ("QueueUserAPCEx"));
@@ -98,9 +107,9 @@ pthread_win32_process_attach_np ()
#endif
}
- if (NULL == ptw32_register_cancelation)
+ if (NULL == ptw32_register_cancellation)
{
- ptw32_register_cancelation = ptw32_RegisterCancelation;
+ ptw32_register_cancellation = ptw32_Registercancellation;
if (ptw32_h_quserex != NULL)
{
@@ -123,7 +132,7 @@ pthread_win32_process_attach_np ()
if (queue_user_apc_ex_init == NULL || !queue_user_apc_ex_init ())
{
- ptw32_register_cancelation = ptw32_RegisterCancelation;
+ ptw32_register_cancellation = ptw32_Registercancellation;
(void) FreeLibrary (ptw32_h_quserex);
ptw32_h_quserex = 0;
@@ -155,7 +164,10 @@ pthread_win32_process_detach_np ()
if (sp->detachState == PTHREAD_CREATE_DETACHED)
{
ptw32_threadDestroy (sp->ptHandle);
- TlsSetValue (ptw32_selfThreadKey->key, NULL);
+ if (ptw32_selfThreadKey)
+ {
+ TlsSetValue (ptw32_selfThreadKey->key, NULL);
+ }
}
}
@@ -230,7 +242,7 @@ pthread_win32_thread_detach_np ()
(PTW32_INTERLOCKED_LONG)-1);
/*
* If there are no waiters then the next thread to block will
- * sleep, wakeup immediately and then go back to sleep.
+ * sleep, wake up immediately and then go back to sleep.
* See pthread_mutex_lock.c.
*/
SetEvent(mx->event);
@@ -241,7 +253,10 @@ pthread_win32_thread_detach_np ()
{
ptw32_threadDestroy (sp->ptHandle);
- TlsSetValue (ptw32_selfThreadKey->key, NULL);
+ if (ptw32_selfThreadKey)
+ {
+ TlsSetValue (ptw32_selfThreadKey->key, NULL);
+ }
}
}
}
diff --git a/libs/pthreads/src/ptw32_MCS_lock.c b/libs/pthreads/src/ptw32_MCS_lock.c
index 659cda60de..9116f35308 100644
--- a/libs/pthreads/src/ptw32_MCS_lock.c
+++ b/libs/pthreads/src/ptw32_MCS_lock.c
@@ -6,41 +6,42 @@
*
* --------------------------------------------------------------------------
*
- * Pthreads-win32 - POSIX Threads Library for Win32
+ * Pthreads4w - POSIX Threads Library for Win32
* Copyright(C) 1998 John E. Bossom
- * Copyright(C) 1999,2005 Pthreads-win32 contributors
- *
- * Contact Email: rpj@callisto.canberra.edu.au
- *
+ * Copyright(C) 1999-2018, Pthreads4w contributors
+ *
+ * Homepage: https://sourceforge.net/projects/pthreads4w/
+ *
* The current list of contributors is contained
* in the file CONTRIBUTORS included with the source
* code distribution. The list can also be seen at the
* following World Wide Web location:
- * http://sources.redhat.com/pthreads-win32/contributors.html
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library in the file COPYING.LIB;
- * if not, write to the Free Software Foundation, Inc.,
- * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
+ * https://sourceforge.net/p/pthreads4w/wiki/Contributors/
+ *
+ * This file is part of Pthreads4w.
+ *
+ * Pthreads4w is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * Pthreads4w is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Pthreads4w. If not, see <http://www.gnu.org/licenses/>. *
*/
/*
+
* About MCS locks:
*
* MCS locks are queue-based locks, where the queue nodes are local to the
* thread. The 'lock' is nothing more than a global pointer that points to
* the last node in the queue, or is NULL if the queue is empty.
- *
+ *
* Originally designed for use as spin locks requiring no kernel resources
* for synchronisation or blocking, the implementation below has adapted
* the MCS spin lock for use as a general mutex that will suspend threads
@@ -63,7 +64,7 @@
* every lock held concurrently by a thread.
*
* E.g.:
- *
+ *
* ptw32_mcs_lock_t lock1 = 0;
* ptw32_mcs_lock_t lock2 = 0;
*
@@ -87,26 +88,41 @@
* }
* return (void *)0;
* }
+ *
*/
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
#include "pthread.h"
#include "sched.h"
#include "implement.h"
/*
* ptw32_mcs_flag_set -- notify another thread about an event.
- *
+ *
* Set event if an event handle has been stored in the flag, and
* set flag to -1 otherwise. Note that -1 cannot be a valid handle value.
*/
-INLINE void
+INLINE void
ptw32_mcs_flag_set (HANDLE * flag)
{
HANDLE e = (HANDLE)(PTW32_INTERLOCKED_SIZE)PTW32_INTERLOCKED_COMPARE_EXCHANGE_SIZE(
(PTW32_INTERLOCKED_SIZEPTR)flag,
(PTW32_INTERLOCKED_SIZE)-1,
(PTW32_INTERLOCKED_SIZE)0);
- if ((HANDLE)0 != e)
+ /*
+ * NOTE: when e == -1 and the MSVC debugger is attached to
+ * the process, we get an exception that halts the
+ * program noting that the handle value is invalid;
+ * although innocuous this behavior is cumbersome when
+ * debugging. Therefore we avoid calling SetEvent()
+ * for 'known' invalid HANDLE values that can arise
+ * when the above interlocked-compare-and-exchange
+ * is executed.
+ */
+ if (((HANDLE)0 != e) && ((HANDLE)-1 != e))
{
/* another thread has already stored an event handle in the flag */
SetEvent(e);
@@ -114,15 +130,15 @@ ptw32_mcs_flag_set (HANDLE * flag)
}
/*
- * ptw32_mcs_flag_set -- wait for notification from another.
- *
+ * ptw32_mcs_flag_wait -- wait for notification from another.
+ *
* Store an event handle in the flag and wait on it if the flag has not been
* set, and proceed without creating an event otherwise.
*/
-INLINE void
+INLINE void
ptw32_mcs_flag_wait (HANDLE * flag)
{
- if ((PTW32_INTERLOCKED_LONG)0 ==
+ if ((PTW32_INTERLOCKED_SIZE)0 ==
PTW32_INTERLOCKED_EXCHANGE_ADD_SIZE((PTW32_INTERLOCKED_SIZEPTR)flag,
(PTW32_INTERLOCKED_SIZE)0)) /* MBR fence */
{
@@ -145,25 +161,25 @@ ptw32_mcs_flag_wait (HANDLE * flag)
/*
* ptw32_mcs_lock_acquire -- acquire an MCS lock.
- *
- * See:
+ *
+ * See:
* J. M. Mellor-Crummey and M. L. Scott.
* Algorithms for Scalable Synchronization on Shared-Memory Multiprocessors.
* ACM Transactions on Computer Systems, 9(1):21-65, Feb. 1991.
*/
#if defined(PTW32_BUILD_INLINED)
-INLINE
+INLINE
#endif /* PTW32_BUILD_INLINED */
-void
+void
ptw32_mcs_lock_acquire (ptw32_mcs_lock_t * lock, ptw32_mcs_local_node_t * node)
{
ptw32_mcs_local_node_t *pred;
-
+
node->lock = lock;
node->nextFlag = 0;
node->readyFlag = 0;
node->next = 0; /* initially, no successor */
-
+
/* queue for the lock */
pred = (ptw32_mcs_local_node_t *)PTW32_INTERLOCKED_EXCHANGE_PTR((PTW32_INTERLOCKED_PVOID_PTR)lock,
(PTW32_INTERLOCKED_PVOID)node);
@@ -171,7 +187,7 @@ ptw32_mcs_lock_acquire (ptw32_mcs_lock_t * lock, ptw32_mcs_local_node_t * node)
if (0 != pred)
{
/* the lock was not free. link behind predecessor. */
- pred->next = node;
+ PTW32_INTERLOCKED_EXCHANGE_PTR((PTW32_INTERLOCKED_PVOID_PTR)&pred->next, (PTW32_INTERLOCKED_PVOID)node);
ptw32_mcs_flag_set(&pred->nextFlag);
ptw32_mcs_flag_wait(&node->readyFlag);
}
@@ -179,16 +195,16 @@ ptw32_mcs_lock_acquire (ptw32_mcs_lock_t * lock, ptw32_mcs_local_node_t * node)
/*
* ptw32_mcs_lock_release -- release an MCS lock.
- *
- * See:
+ *
+ * See:
* J. M. Mellor-Crummey and M. L. Scott.
* Algorithms for Scalable Synchronization on Shared-Memory Multiprocessors.
* ACM Transactions on Computer Systems, 9(1):21-65, Feb. 1991.
*/
#if defined(PTW32_BUILD_INLINED)
-INLINE
+INLINE
#endif /* PTW32_BUILD_INLINED */
-void
+void
ptw32_mcs_lock_release (ptw32_mcs_local_node_t * node)
{
ptw32_mcs_lock_t *lock = node->lock;
@@ -208,12 +224,17 @@ ptw32_mcs_lock_release (ptw32_mcs_local_node_t * node)
/* no successor, lock is free now */
return;
}
-
- /* A successor has started enqueueing behind us so wait for them to link to us */
+
+ /* wait for successor */
ptw32_mcs_flag_wait(&node->nextFlag);
next = (ptw32_mcs_local_node_t *)
PTW32_INTERLOCKED_EXCHANGE_ADD_SIZE((PTW32_INTERLOCKED_SIZEPTR)&node->next, (PTW32_INTERLOCKED_SIZE)0); /* MBR fence */
}
+ else
+ {
+ /* Even if the next is non-0, the successor may still be trying to set the next flag on us, therefore we must wait. */
+ ptw32_mcs_flag_wait(&node->nextFlag);
+ }
/* pass the lock */
ptw32_mcs_flag_set(&next->readyFlag);
@@ -223,9 +244,9 @@ ptw32_mcs_lock_release (ptw32_mcs_local_node_t * node)
* ptw32_mcs_lock_try_acquire
*/
#if defined(PTW32_BUILD_INLINED)
-INLINE
+INLINE
#endif /* PTW32_BUILD_INLINED */
-int
+int
ptw32_mcs_lock_try_acquire (ptw32_mcs_lock_t * lock, ptw32_mcs_local_node_t * node)
{
node->lock = lock;
@@ -251,9 +272,9 @@ ptw32_mcs_lock_try_acquire (ptw32_mcs_lock_t * lock, ptw32_mcs_local_node_t * no
* Should only be called by the thread that has the lock.
*/
#if defined(PTW32_BUILD_INLINED)
-INLINE
+INLINE
#endif /* PTW32_BUILD_INLINED */
-void
+void
ptw32_mcs_node_transfer (ptw32_mcs_local_node_t * new_node, ptw32_mcs_local_node_t * old_node)
{
new_node->lock = old_node->lock;
@@ -269,10 +290,18 @@ ptw32_mcs_node_transfer (ptw32_mcs_local_node_t * new_node, ptw32_mcs_local_node
/*
* A successor has queued after us, so wait for them to link to us
*/
- while (old_node->next == 0)
+ while (0 == old_node->next)
{
sched_yield();
}
+
+ /* we must wait for the next Node to finish inserting itself. */
+ ptw32_mcs_flag_wait(&old_node->nextFlag);
+ /*
+ * Copy the nextFlag state also so we don't block on it when releasing
+ * this lock.
+ */
new_node->next = old_node->next;
+ new_node->nextFlag = old_node->nextFlag;
}
}
diff --git a/libs/pthreads/src/ptw32_OLL_lock.c b/libs/pthreads/src/ptw32_OLL_lock.c
deleted file mode 100644
index 789d0ad8c6..0000000000
--- a/libs/pthreads/src/ptw32_OLL_lock.c
+++ /dev/null
@@ -1,734 +0,0 @@
-/*
- * ptw32_OLL_lock.c
- *
- * Description:
- * This translation unit implements extended reader/writer queue-based locks.
- *
- * --------------------------------------------------------------------------
- *
- * Pthreads-win32 - POSIX Threads Library for Win32
- * Copyright(C) 1998 John E. Bossom
- * Copyright(C) 1999,2005 Pthreads-win32 contributors
- *
- * Contact Email: rpj@callisto.canberra.edu.au
- *
- * The current list of contributors is contained
- * in the file CONTRIBUTORS included with the source
- * code distribution. The list can also be seen at the
- * following World Wide Web location:
- * http://sources.redhat.com/pthreads-win32/contributors.html
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library in the file COPYING.LIB;
- * if not, write to the Free Software Foundation, Inc.,
- * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
- */
-
-/*
- * About the OLL lock (Scalable Reader-Writer Lock):
- *
- * OLL locks are queue-based locks similar to the MCS queue lock, where the queue
- * nodes are local to the thread but where reader threads can enter the critical
- * section immediately without going through a central guard lock if there are
- * already readers holding the lock.
- *
- * Covered by United States Patent Application 20100241774 (Oracle)
- */
-
-#include "pthread.h"
-#include "sched.h"
-#include "implement.h"
-
-/*
- * C-SNZI support
- */
-typedef union ptw32_oll_counter_t_ ptw32_oll_counter_t;
-typedef struct ptw32_oll_snziRoot_t_ ptw32_oll_snziRoot_t;
-typedef struct ptw32_oll_snziNode_t_ ptw32_oll_snziNode_t;
-typedef union ptw32_oll_snziNodeOrRoot_t_ ptw32_oll_snziNodeOrRoot_t;
-typedef struct ptw32_oll_queryResult_t_ ptw32_oll_queryResult_t;
-typedef struct ptw32_oll_ticket_t_ ptw32_oll_ticket_t;
-typedef struct ptw32_oll_csnzi_t_ ptw32_oll_csnzi_t;
-
-enum
-{
- ptw32_archWidth = sizeof(size_t)*8,
- ptw32_oll_countWidth = ptw32_archWidth-2
-};
-
-#define PTW32_OLL_MAXREADERS (((size_t)2<<(ptw32_oll_countWidth-1))-1)
-
-union ptw32_oll_counter_t_
-{
- size_t word : ptw32_archWidth;
- struct
- {
- /*
- * This needs to be a single word
- *
- * ------------------------------------
- * | STATE | ROOT | COUNT (readers) |
- * ------------------------------------
- * 63 / 31 62 / 30 61 / 29 .. 0
- */
- size_t count : ptw32_oll_countWidth;
- size_t root : 1; /* ROOT or NODE */
- size_t state : 1; /* OPEN or CLOSED (root only) */
- } internal;
-};
-
-struct ptw32_oll_snziRoot_t_
-{
- /*
- * "counter" must be at same offset in both
- * ptw32_oll_snziNode_t and ptw32_oll_snziRoot_t
- */
- ptw32_oll_counter_t counter;
-};
-
-enum
-{
- ptw32_oll_snziRoot_open = 0,
- ptw32_oll_snziRoot_closed = 1
-};
-
-enum
-{
- ptw32_oll_snzi_root = 0,
- ptw32_oll_snzi_node = 1
-};
-
-/*
- * Some common SNZI root whole-word states that can be used to set or compare
- * root words with a single operation.
- */
-ptw32_oll_snziRoot_t ptw32_oll_snziRoot_openAndZero = {.counter.internal.count = 0,
- .counter.internal.root = ptw32_oll_snzi_root,
- .counter.internal.state = ptw32_oll_snziRoot_open};
-ptw32_oll_snziRoot_t ptw32_oll_snziRoot_closedAndZero = {.counter.internal.count = 0,
- .counter.internal.root = ptw32_oll_snzi_root,
- .counter.internal.state = ptw32_oll_snziRoot_closed};
-
-struct ptw32_oll_queryResult_t_
-{
- BOOL nonZero;
- BOOL open;
-};
-
-union ptw32_oll_snziNodeOrRoot_t_
-{
- ptw32_oll_snziRoot_t* rootPtr;
- ptw32_oll_snziNode_t* nodePtr;
-};
-
-struct ptw32_oll_snziNode_t_
-{
- /* "counter" must be at same offset in both
- * ptw32_oll_snziNode_t and ptw32_oll_snziRoot_t
- */
- ptw32_oll_counter_t counter;
- ptw32_oll_snziNodeOrRoot_t parentPtr;
-};
-
-struct ptw32_oll_ticket_t_
-{
- ptw32_oll_snziNodeOrRoot_t snziNodeOrRoot;
-};
-
-ptw32_oll_ticket_t ptw32_oll_ticket_null = {NULL};
-
-struct ptw32_oll_csnzi_t_
-{
- ptw32_oll_snziRoot_t proxyRoot;
- ptw32_oll_snziNode_t leafs[];
-};
-
-/*
- * FOLL lock support
- */
-
-typedef struct ptw32_foll_node_t_ ptw32_foll_node_t;
-typedef struct ptw32_foll_local_t_ ptw32_foll_local_t;
-typedef struct ptw32_foll_rwlock_t_ ptw32_foll_rwlock_t;
-
-enum
-{
- ptw32_srwl_reader,
- ptw32_srwl_writer
-};
-
-enum
-{
- ptw32_srwl_free,
- ptw32_srwl_in_use
-};
-
-struct ptw32_foll_node_t_
-{
- ptw32_foll_node_t* qNextPtr;
- ptw32_oll_csnzi_t* csnziPtr;
- ptw32_foll_node_t* nextPtr;
- int kind;
- int allocState;
- BOOL spin;
-};
-
-struct ptw32_foll_local_t_
-{
- ptw32_foll_node_t* rNodePtr; // Default read node. Immutable
- ptw32_foll_node_t* wNodePtr; // Write node. Immutable.
- ptw32_foll_node_t* departFromPtr; // List node we last arrived at.
- ptw32_oll_ticket_t ticket; // C-SNZI ticket
-};
-
-struct ptw32_foll_rwlock_t_
-{
- ptw32_foll_node_t* tailPtr;
- ptw32_foll_node_t* rNodesPtr; // Head of reader node
-};
-
-/*
- * ShouldArriveAtTree() returns true if:
- * the compare_exchange in Arrive() fails too often under read access; or
- * ??
- * Note that this is measured across all access to
- * this lock, not just this attempt, so that highly
- * read-contended locks will use C-SNZI. Lightly
- * read-contended locks can reduce memory usage and some
- * processing by using the root directly.
- */
-BOOL
-ptw32_oll_ShouldArriveAtTree()
-{
- return PTW32_FALSE;
-}
-
-size_t
-ptw32_oll_GetLeafForThread()
-{
- return 0;
-}
-
-/*
- * Only readers call ptw32_oll_Arrive()
- *
- * Checks whether the C-SNZI state is OPEN, and if so,
- * increments the surplus of the C-SNZI by either directly
- * arriving at the root node, or calling TreeArrive on one
- * of the leaf nodes. Returns a ticket pointing to the node
- * that was arrived at. If the state is CLOSED, makes no
- * change and returns a ticket that contains no pointer.
- */
-ptw32_oll_ticket_t
-ptw32_oll_Arrive(ptw32_oll_csnzi_t* csnzi)
-{
- for (;;)
- {
- ptw32_oll_ticket_t ticket;
- ptw32_oll_snziRoot_t oldProxy = csnzi->proxyRoot;
- if (oldProxy.counter.internal.state != ptw32_oll_snziRoot_open)
- {
- ticket.snziNodeOrRoot.rootPtr = (ptw32_oll_snziRoot_t*)NULL;
- return ticket;
- }
- if (!ptw32_oll_ShouldArriveAtTree())
- {
- ptw32_oll_snziRoot_t newProxy = oldProxy;
- newProxy.counter.internal.count++;
- if (PTW32_INTERLOCKED_COMPARE_EXCHANGE_SIZE(
- (PTW32_INTERLOCKED_SIZEPTR)&csnzi->proxyRoot.counter,
- (PTW32_INTERLOCKED_SIZE)newProxy.counter.word,
- (PTW32_INTERLOCKED_SIZE)oldProxy.counter.word)
- == (PTW32_INTERLOCKED_SIZE)oldProxy.counter.word)
- {
- /* Exchange successful */
- ticket.snziNodeOrRoot.rootPtr = &csnzi->proxyRoot;
- return ticket;
- }
- }
- else
- {
- ptw32_oll_snziNode_t* leafPtr = &csnzi->leafs[ptw32_oll_GetLeafForThread()];
- ticket.snziNodeOrRoot.nodePtr = (ptw32_oll_TreeArrive(leafPtr) ? leafPtr : (ptw32_oll_snziNode_t*)NULL);
- return ticket;
- }
- }
-}
-
-/*
- * Decrements the C-SNZI surplus. Returns false iff the
- * resulting state is CLOSED and the surplus is zero.
- * Ticket must have been returned by an arrival. Must have
- * received this ticket from Arrive more times than Depart
- * has been called with the ticket. (Thus, the surplus
- * must be greater than zero.)
- */
-BOOL
-ptw32_oll_Depart(ptw32_oll_ticket_t ticket)
-{
- return ptw32_oll_TreeDepart(ticket.snziNodeOrRoot);
-}
-
-/*
- * Increments the C-SNZI surplus and returns true if the
- * C-SNZI is open or has a surplus. Calls TreeArrive
- * recursively on the node’s parent if needed.
- * Otherwise, returns false without making any changes.
- */
-BOOL
-ptw32_oll_TreeArrive(ptw32_oll_snziNodeOrRoot_t snziNodeOrRoot)
-{
- if (snziNodeOrRoot.nodePtr->counter.internal.root != ptw32_oll_snzi_root)
- {
- /* Non-root node */
- ptw32_oll_counter_t newCounter, oldCounter;
- BOOL arrivedAtParent = PTW32_FALSE;
- do
- {
- oldCounter = snziNodeOrRoot.nodePtr->counter;
- if (0 == oldCounter.internal.count && !arrivedAtParent)
- {
- if (ptw32_oll_TreeArrive(snziNodeOrRoot.nodePtr->parentPtr))
- arrivedAtParent = PTW32_TRUE;
- else
- return PTW32_FALSE;
- }
- newCounter = oldCounter;
- newCounter.internal.count++;
- } while (PTW32_INTERLOCKED_COMPARE_EXCHANGE_SIZE(
- (PTW32_INTERLOCKED_SIZEPTR)&snziNodeOrRoot.nodePtr->counter,
- (PTW32_INTERLOCKED_SIZE)newCounter.word,
- (PTW32_INTERLOCKED_SIZE)oldCounter.word)
- != (PTW32_INTERLOCKED_SIZE)oldCounter.word);
- if (newCounter.internal.count != 0 && arrivedAtParent)
- ptw32_oll_TreeDepart(snziNodeOrRoot.nodePtr->parentPtr);
- return PTW32_TRUE;
- }
- else
- {
- /* Root node */
- ptw32_oll_snziRoot_t newRoot, oldRoot;
- do
- {
- oldRoot = *(ptw32_oll_snziRoot_t*)snziNodeOrRoot.rootPtr;
- if (oldRoot.counter.word == ptw32_oll_snziRoot_closedAndZero.counter.word)
- return PTW32_FALSE;
- newRoot = oldRoot;
- newRoot.counter.internal.count++;
- } while (PTW32_INTERLOCKED_COMPARE_EXCHANGE_SIZE(
- (PTW32_INTERLOCKED_SIZEPTR)&snziNodeOrRoot.rootPtr->counter,
- (PTW32_INTERLOCKED_SIZE)newRoot.counter.word,
- (PTW32_INTERLOCKED_SIZE)oldRoot.counter.word)
- != (PTW32_INTERLOCKED_SIZE)oldRoot.counter.word);
- return PTW32_TRUE;
- }
-}
-
-/*
- * Decrements the C-SNZI surplus, calling TreeDepart
- * recursively on the node’s parent if needed. Returns
- * false iff the resulting state of the C-SNZI is CLOSED
- * and the surplus is zero. Otherwise, returns true.
- */
-BOOL
-ptw32_oll_TreeDepart(ptw32_oll_snziNodeOrRoot_t snziNodeOrRoot)
-{
- if (snziNodeOrRoot.nodePtr->counter.internal.root != ptw32_oll_snzi_root)
- {
- /* Non-root node */
- ptw32_oll_counter_t newCounter, oldCounter;
- do
- {
- newCounter = oldCounter = snziNodeOrRoot.nodePtr->counter;
- newCounter.internal.count--;
- } while (PTW32_INTERLOCKED_COMPARE_EXCHANGE_SIZE(
- (PTW32_INTERLOCKED_SIZEPTR)&snziNodeOrRoot.nodePtr->counter,
- (PTW32_INTERLOCKED_SIZE)newCounter.word,
- (PTW32_INTERLOCKED_SIZE)oldCounter.word)
- != (PTW32_INTERLOCKED_SIZE)oldCounter.word);
- return (0 == newCounter.internal.count)
- ? ptw32_oll_TreeDepart(snziNodeOrRoot.nodePtr->parentPtr)
- : PTW32_TRUE;
- }
- else
- {
- /* Root node */
- ptw32_oll_snziRoot_t newRoot, oldRoot;
- do
- {
- newRoot = oldRoot = *(ptw32_oll_snziRoot_t*)snziNodeOrRoot.rootPtr;
- newRoot.counter.internal.count--;
- } while (PTW32_INTERLOCKED_COMPARE_EXCHANGE_SIZE(
- (PTW32_INTERLOCKED_SIZEPTR)&snziNodeOrRoot.rootPtr->counter,
- (PTW32_INTERLOCKED_SIZE)newRoot.counter.word,
- (PTW32_INTERLOCKED_SIZE)oldRoot.counter.word)
- != (PTW32_INTERLOCKED_SIZE)oldRoot.counter.word);
- return (newRoot.counter.word != ptw32_oll_snziRoot_closedAndZero.counter.word);
- }
-}
-
-/*
- * Opens a C-SNZI object. Requires C-SNZI state to be
- * CLOSED and the surplus to be zero.
- */
-void
-ptw32_oll_Open(ptw32_oll_csnzi_t* csnziPtr)
-{
- csnziPtr->proxyRoot = ptw32_oll_snziRoot_openAndZero;
-}
-
-/*
- * Opens a C-SNZI object while atomically performing count
- * arrivals. Requires C-SNZI state to be CLOSED and
- * the surplus to be zero.
- */
-void
-ptw32_oll_OpenWithArrivals(ptw32_oll_csnzi_t* csnziPtr, size_t count, BOOL close)
-{
- csnziPtr->proxyRoot.counter.internal.count = count;
- csnziPtr->proxyRoot.counter.internal.state = (close ? ptw32_oll_snziRoot_closed : ptw32_oll_snziRoot_open);
-}
-
-/*
- * Closes a C-SNZI object. Returns true iff the C-SNZI
- * state changed from OPEN to CLOSED and the surplus is
- * zero.
- */
-BOOL
-ptw32_oll_Close(ptw32_oll_csnzi_t* csnziPtr)
-{
- ptw32_oll_snziRoot_t newProxy, oldProxy;
- do
- {
- oldProxy = csnziPtr->proxyRoot;
- if (oldProxy.counter.internal.state != ptw32_oll_snziRoot_open)
- {
- return PTW32_FALSE;
- }
- newProxy = oldProxy;
- newProxy.counter.internal.state = ptw32_oll_snziRoot_closed;
- } while (PTW32_INTERLOCKED_COMPARE_EXCHANGE_SIZE(
- (PTW32_INTERLOCKED_SIZEPTR)&csnziPtr->proxyRoot.counter,
- (PTW32_INTERLOCKED_SIZE)newProxy.counter.word,
- (PTW32_INTERLOCKED_SIZE)oldProxy.counter.word)
- != (PTW32_INTERLOCKED_SIZE)oldProxy.counter.word);
- return (newProxy.counter.word == ptw32_oll_snziRoot_closedAndZero.counter.word);
-}
-
-/*
- * Closes a C-SNZI if its surplus is zero. Otherwise, does
- * nothing. Returns true iff C-SNZI state changed from
- * OPEN to CLOSED.
- */
-BOOL
-ptw32_oll_CloseIfEmpty(ptw32_oll_csnzi_t* csnziPtr)
-{
- ptw32_oll_snziRoot_t newProxy, oldProxy;
- do
- {
- oldProxy = csnziPtr->proxyRoot;
- if (oldProxy.counter.word != ptw32_oll_snziRoot_openAndZero.counter.word)
- {
- return PTW32_FALSE;
- }
- newProxy = ptw32_oll_snziRoot_closedAndZero;
- } while (PTW32_INTERLOCKED_COMPARE_EXCHANGE_SIZE(
- (PTW32_INTERLOCKED_SIZEPTR)&csnziPtr->proxyRoot.counter,
- (PTW32_INTERLOCKED_SIZE)newProxy.counter.word,
- (PTW32_INTERLOCKED_SIZE)oldProxy.counter.word)
- != (PTW32_INTERLOCKED_SIZE)oldProxy.counter.word);
- return PTW32_TRUE;
-}
-
-/*
- * Returns whether the C-SNZI has a nonzero surplus and
- * whether the C-SNZI is open.
- * "nonZero" doesn't appear to be used anywhere in the algorithms.
- */
-ptw32_oll_queryResult_t
-ptw32_oll_Query(ptw32_oll_csnzi_t* csnziPtr)
-{
- ptw32_oll_queryResult_t query;
- ptw32_oll_snziRoot_t proxy = csnziPtr->proxyRoot;
-
- query.nonZero = (proxy.counter.internal.count > 0);
- query.open = (proxy.counter.internal.state == ptw32_oll_snziRoot_open);
- return query;
-}
-
-/*
- * Returns whether the Arrive operation that returned
- * the ticket succeeded.
- */
-BOOL
-ptw32_oll_Arrived(ptw32_oll_ticket_t t)
-{
- return (t.snziNodeOrRoot.nodePtr != NULL);
-}
-
-/*
- * Constructs and returns a ticket that can be used to
- * depart from the root node.
- */
-ptw32_oll_ticket_t
-ptw32_oll_DirectTicket(ptw32_oll_csnzi_t* csnziPtr)
-{
- ptw32_oll_ticket_t ticket;
- ticket.snziNodeOrRoot.rootPtr = &csnziPtr->proxyRoot;
- return ticket;
-}
-
-/* Scalable RW Locks */
-
-typedef struct ptw32_srwl_rwlock_t_ ptw32_srwl_rwlock_t;
-typedef struct ptw32_srwl_node_t_ ptw32_srwl_node_t;
-typedef struct ptw32_srwl_local_t_ ptw32_srwl_local_t;
-
-enum
-{
- ptw32_srwl_reader = 0,
- ptw32_srwl_writer = 1
-};
-
-enum
-{
- ptw32_srwl_free = 0,
- ptw32_srwl_in_use = 1
-};
-
-struct ptw32_srwl_rwlock_t_
-{
- ptw32_srwl_node_t* tailPtr;
- ptw32_srwl_node_t* readerNodePtr;
-};
-
-struct ptw32_srwl_node_t_
-{
- ptw32_srwl_node_t* qNextPtr;
- ptw32_oll_csnzi_t* csnziPtr;
- ptw32_srwl_node_t* nextReaderPtr;
- int kind; /* ptw32_srwl_reader, ptw32_srwl_writer */
- int allocState; /* ptw32_srwl_free, ptw32_srwl_in_use */
- BOOL spin;
-};
-
-/*
- * When a ptw32_srwl_local_t is instantiated the "kind" of each of
- * rNode and wNode must be set as appropriate. This is the only
- * time "kind" is set.
- */
-struct ptw32_srwl_local_t_
-{
- ptw32_srwl_node_t* rNodePtr;
- ptw32_srwl_node_t* wNodePtr;
- ptw32_srwl_node_t* departFromPtr;
- ptw32_oll_ticket_t ticket;
-};
-
-/* Allocates a new reader node. */
-ptw32_srwl_node_t*
-ptw32_srwl_AllocReaderNode(ptw32_srwl_local_t* local)
-{
- ptw32_srwl_node_t* currNodePtr = local->rNodePtr;
- for (;;)
- {
- if (currNodePtr->allocState == ptw32_srwl_free)
- {
- if (PTW32_INTERLOCKED_COMPARE_EXCHANGE_LONG(
- (PTW32_INTERLOCKED_LONGPTR)&currNodePtr->allocState,
- (PTW32_INTERLOCKED_LONG)ptw32_srwl_in_use,
- (PTW32_INTERLOCKED_LONG)ptw32_srwl_free)
- == (PTW32_INTERLOCKED_LONG)ptw32_srwl_in_use)
- {
- return currNodePtr;
- }
- }
- currNodePtr = currNodePtr->next;
- }
-}
-
-/*
- * Frees a reader node. Requires that its allocState
- * is ptw32_srwl_in_use.
- */
-void
-ptw32_srwl_FreeReaderNode(ptw32_srwl_node_t* nodePtr)
-{
- nodePtr->allocState := ptw32_srwl_free;
-}
-
-void
-ptw32_srwl_WriterLock(ptw32_srwl_rwlock_t* lockPtr, ptw32_srwl_local_t* localPtr)
-{
- oldTailPtr = (ptw32_srwl_rwlock_t*)PTW32_INTERLOCKED_EXCHANGE_PTR(
- (PTW32_INTERLOCKED_PVOID_PTR)&lockPtr->tailPtr,
- (PTW32_INTERLOCKED_PVOID)localPtr->wNodePtr);
- if (oldTailPtr != NULL)
- {
- localPtr->wNodePtr->spin := PTW32_TRUE;
- oldTailPtr->qNextPtr = localPtr->wNodePtr;
- if (oldTailPtr->kind == ptw32_srwl_writer)
- {
- while (localPtr->wNodePtr->spin);
- }
- else
- {
- /* Wait until node is properly recycled */
- while (ptw32_oll_Query(oldTailPtr->csnzi).open);
- /*
- * Close C-SNZI of previous reader node.
- * If there are no readers to signal us, spin on
- * previous node and free it before entering
- * critical section.
- */
- if (ptw32_oll_Close(oldTailPtr->csnzi))
- {
- while (oldTailPtr->spin);
- ptw32_srwl_FreeReaderNode(oldTailPtr);
- }
- else
- {
- while (localPtr->wNodePtr->spin);
- }
- }
- }
-}
-
-void
-ptw32_srwl_WriterUnlock(ptw32_srwl_rwlock_t* lockPtr, ptw32_srwl_local_t* localPtr)
-{
- if (localPtr->wNodePtr->qNextPtr == NULL)
- {
- if (PTW32_INTERLOCKED_COMPARE_EXCHANGE_PTR(
- (PTW32_INTERLOCKED_PVOIDPTR)&lockPtr->tailPtr,
- (PTW32_INTERLOCKED_PVOID)NULL,
- (PTW32_INTERLOCKED_PVOID)localPtr->wNodePtr)
- == (PTW32_INTERLOCKED_PVOID)NULL)
- {
- return;
- }
- else
- {
- while (localPtr->wNodePtr->qNextPtr == NULL);
- }
- }
- /* Clean up */
- localPtr->wNodePtr->qNextPtr->spin = PTW32_FALSE;
- localPtr->wNodePtr->qNextPtr = NULL;
-}
-
-void
-ptw32_srwl_ReaderLock(ptw32_srwl_rwlock_t* lockPtr, ptw32_srwl_local_t* localPtr)
-{
- ptw32_srwl_node_t* rNodePtr = NULL;
- for (;;)
- {
- ptw32_srwl_node_t* tailPtr = lockPtr->tailPtr;
- /* If no nodes are in the queue */
- if (tailPtr == NULL)
- {
- if (rNodePtr == NULL)
- {
- rNodePtr = ptw32_srwl_AllocReaderNode(localPtr);
- }
- rNodePtr->spin = PTW32_FALSE;
- if (PTW32_INTERLOCKED_COMPARE_EXCHANGE_PTR(
- (PTW32_INTERLOCKED_PVOIDPTR)&lockPtr->tailPtr,
- (PTW32_INTERLOCKED_PVOID)rNodePtr,
- (PTW32_INTERLOCKED_PVOID)NULL)
- == (PTW32_INTERLOCKED_PVOID)rNodePtr)
- {
- ptw32_oll_Open(rNodePtr->csnzi);
- localPtr->ticket = ptw32_oll_Arrive(rNodePtr->csnzi);
- if (ptw32_oll_Arrived(localPtr->ticket))
- {
- localPtr->departFromPtr = rNodePtr;
- return;
- }
- /* Avoid reusing inserted node */
- rNodePtr = NULL;
- }
- }
- /* Otherwise, there is a node in the queue */
- else
- {
- /* Is last node a writer node? */
- if (tailPtr->kind == ptw32_srwl_writer)
- {
- if (rNodePtr == NULL)
- {
- rNodePtr = ptw32_srwl_AllocReaderNode(localPtr);
- }
- rNodePtr->spin = PTW32_TRUE;
- if (PTW32_INTERLOCKED_COMPARE_EXCHANGE_PTR(
- (PTW32_INTERLOCKED_PVOIDPTR)&lockPtr->tailPtr,
- (PTW32_INTERLOCKED_PVOID)rNodePtr,
- (PTW32_INTERLOCKED_PVOID)tailPtr)
- == (PTW32_INTERLOCKED_PVOID)rNodePtr)
- {
- tailPtr->qNextPtr = rNodePtr;
- localPtr->ticket = ptw32_oll_Arrive(rNodePtr->csnzi);
- if (ptw32_oll_Arrived(localPtr->ticket))
- {
- localPtr->departFromPtr = rNodePtr;
- while (rNodePtr->spin);
- return;
- }
- /* Avoid reusing inserted node */
- rNodePtr = NULL;
- }
- }
- /*
- * Otherwise, last node is a reader node.
- * (tailPtr->kind == ptw32_srwl_reader)
- */
- else
- {
- localPtr->ticket = ptw32_oll_Arrive(tailPtr->csnzi);
- if (ptw32_oll_Arrived(localPtr->ticket))
- {
- if (rNodePtr != NULL)
- {
- ptw32_srwl_FreeReaderNode(rNodePtr);
- }
- localPtr->departFromPtr = tailPtr;
- while (tailPtr->spin);
- return;
- }
- }
- }
- }
-}
-
-void
-ptw32_srwl_ReaderUnlock(ptw32_srwl_rwlock_t* lockPtr, ptw32_srwl_local_t* localPtr)
-{
- if (ptw32_oll_Depart(localPtr->departFromPtr->csnzi, localPtr->ticket))
- {
- return;
- }
- /* Clean up */
- localPtr->departFromPtr->qNextPtr->spin = PTW32_FALSE;
- localPtr->departFromPtr->qNextPtr = NULL;
- ptw32_srwl_FreeReaderNode(localPtr->departFromPtr);
-}
-
-
-#include <stdio.h>
-
-int main()
-{
- printf("%lx\n", PTW32_OLL_MAXREADERS);
- return 0;
-}
-
diff --git a/libs/pthreads/src/ptw32_callUserDestroyRoutines.c b/libs/pthreads/src/ptw32_callUserDestroyRoutines.c
index f290f7ba54..e28f639235 100644
--- a/libs/pthreads/src/ptw32_callUserDestroyRoutines.c
+++ b/libs/pthreads/src/ptw32_callUserDestroyRoutines.c
@@ -7,34 +7,38 @@
*
* --------------------------------------------------------------------------
*
- * Pthreads-win32 - POSIX Threads Library for Win32
+ * Pthreads4w - POSIX Threads Library for Win32
* Copyright(C) 1998 John E. Bossom
- * Copyright(C) 1999,2005 Pthreads-win32 contributors
- *
- * Contact Email: rpj@callisto.canberra.edu.au
- *
+ * Copyright(C) 1999-2018, Pthreads4w contributors
+ *
+ * Homepage: https://sourceforge.net/projects/pthreads4w/
+ *
* The current list of contributors is contained
* in the file CONTRIBUTORS included with the source
* code distribution. The list can also be seen at the
* following World Wide Web location:
- * http://sources.redhat.com/pthreads-win32/contributors.html
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library in the file COPYING.LIB;
- * if not, write to the Free Software Foundation, Inc.,
- * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
+ * https://sourceforge.net/p/pthreads4w/wiki/Contributors/
+ *
+ * This file is part of Pthreads4w.
+ *
+ * Pthreads4w is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * Pthreads4w is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Pthreads4w. If not, see <http://www.gnu.org/licenses/>. *
*/
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
#include "pthread.h"
#include "implement.h"
diff --git a/libs/pthreads/src/ptw32_calloc.c b/libs/pthreads/src/ptw32_calloc.c
index e7b9e64fe6..b5877111b7 100644
--- a/libs/pthreads/src/ptw32_calloc.c
+++ b/libs/pthreads/src/ptw32_calloc.c
@@ -6,34 +6,38 @@
*
* --------------------------------------------------------------------------
*
- * Pthreads-win32 - POSIX Threads Library for Win32
+ * Pthreads4w - POSIX Threads Library for Win32
* Copyright(C) 1998 John E. Bossom
- * Copyright(C) 1999,2005 Pthreads-win32 contributors
- *
- * Contact Email: rpj@callisto.canberra.edu.au
- *
+ * Copyright(C) 1999-2018, Pthreads4w contributors
+ *
+ * Homepage: https://sourceforge.net/projects/pthreads4w/
+ *
* The current list of contributors is contained
* in the file CONTRIBUTORS included with the source
* code distribution. The list can also be seen at the
* following World Wide Web location:
- * http://sources.redhat.com/pthreads-win32/contributors.html
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library in the file COPYING.LIB;
- * if not, write to the Free Software Foundation, Inc.,
- * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
+ * https://sourceforge.net/p/pthreads4w/wiki/Contributors/
+ *
+ * This file is part of Pthreads4w.
+ *
+ * Pthreads4w is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * Pthreads4w is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Pthreads4w. If not, see <http://www.gnu.org/licenses/>. *
*/
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
#include "pthread.h"
#include "implement.h"
diff --git a/libs/pthreads/src/ptw32_cond_check_need_init.c b/libs/pthreads/src/ptw32_cond_check_need_init.c
index ec3e8bbd69..4cd84a872a 100644
--- a/libs/pthreads/src/ptw32_cond_check_need_init.c
+++ b/libs/pthreads/src/ptw32_cond_check_need_init.c
@@ -7,34 +7,38 @@
*
* --------------------------------------------------------------------------
*
- * Pthreads-win32 - POSIX Threads Library for Win32
+ * Pthreads4w - POSIX Threads Library for Win32
* Copyright(C) 1998 John E. Bossom
- * Copyright(C) 1999,2005 Pthreads-win32 contributors
- *
- * Contact Email: rpj@callisto.canberra.edu.au
- *
+ * Copyright(C) 1999-2018, Pthreads4w contributors
+ *
+ * Homepage: https://sourceforge.net/projects/pthreads4w/
+ *
* The current list of contributors is contained
* in the file CONTRIBUTORS included with the source
* code distribution. The list can also be seen at the
* following World Wide Web location:
- * http://sources.redhat.com/pthreads-win32/contributors.html
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library in the file COPYING.LIB;
- * if not, write to the Free Software Foundation, Inc.,
- * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
+ * https://sourceforge.net/p/pthreads4w/wiki/Contributors/
+ *
+ * This file is part of Pthreads4w.
+ *
+ * Pthreads4w is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * Pthreads4w is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Pthreads4w. If not, see <http://www.gnu.org/licenses/>. *
*/
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
#include "pthread.h"
#include "implement.h"
diff --git a/libs/pthreads/src/ptw32_getprocessors.c b/libs/pthreads/src/ptw32_getprocessors.c
index e60c3143f9..e0be251462 100644
--- a/libs/pthreads/src/ptw32_getprocessors.c
+++ b/libs/pthreads/src/ptw32_getprocessors.c
@@ -7,34 +7,38 @@
*
* --------------------------------------------------------------------------
*
- * Pthreads-win32 - POSIX Threads Library for Win32
+ * Pthreads4w - POSIX Threads Library for Win32
* Copyright(C) 1998 John E. Bossom
- * Copyright(C) 1999,2005 Pthreads-win32 contributors
- *
- * Contact Email: rpj@callisto.canberra.edu.au
- *
+ * Copyright(C) 1999-2018, Pthreads4w contributors
+ *
+ * Homepage: https://sourceforge.net/projects/pthreads4w/
+ *
* The current list of contributors is contained
* in the file CONTRIBUTORS included with the source
* code distribution. The list can also be seen at the
* following World Wide Web location:
- * http://sources.redhat.com/pthreads-win32/contributors.html
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library in the file COPYING.LIB;
- * if not, write to the Free Software Foundation, Inc.,
- * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
+ * https://sourceforge.net/p/pthreads4w/wiki/Contributors/
+ *
+ * This file is part of Pthreads4w.
+ *
+ * Pthreads4w is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * Pthreads4w is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Pthreads4w. If not, see <http://www.gnu.org/licenses/>. *
*/
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
#include "pthread.h"
#include "implement.h"
diff --git a/libs/pthreads/src/ptw32_is_attr.c b/libs/pthreads/src/ptw32_is_attr.c
index 36395f81f0..e4ebdfc641 100644
--- a/libs/pthreads/src/ptw32_is_attr.c
+++ b/libs/pthreads/src/ptw32_is_attr.c
@@ -6,34 +6,38 @@
*
* --------------------------------------------------------------------------
*
- * Pthreads-win32 - POSIX Threads Library for Win32
+ * Pthreads4w - POSIX Threads Library for Win32
* Copyright(C) 1998 John E. Bossom
- * Copyright(C) 1999,2005 Pthreads-win32 contributors
- *
- * Contact Email: rpj@callisto.canberra.edu.au
- *
+ * Copyright(C) 1999-2018, Pthreads4w contributors
+ *
+ * Homepage: https://sourceforge.net/projects/pthreads4w/
+ *
* The current list of contributors is contained
* in the file CONTRIBUTORS included with the source
* code distribution. The list can also be seen at the
* following World Wide Web location:
- * http://sources.redhat.com/pthreads-win32/contributors.html
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library in the file COPYING.LIB;
- * if not, write to the Free Software Foundation, Inc.,
- * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
+ * https://sourceforge.net/p/pthreads4w/wiki/Contributors/
+ *
+ * This file is part of Pthreads4w.
+ *
+ * Pthreads4w is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * Pthreads4w is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Pthreads4w. If not, see <http://www.gnu.org/licenses/>. *
*/
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
#include "pthread.h"
#include "implement.h"
diff --git a/libs/pthreads/src/ptw32_mutex_check_need_init.c b/libs/pthreads/src/ptw32_mutex_check_need_init.c
index 897db3c68e..f2258f01af 100644
--- a/libs/pthreads/src/ptw32_mutex_check_need_init.c
+++ b/libs/pthreads/src/ptw32_mutex_check_need_init.c
@@ -6,41 +6,45 @@
*
* --------------------------------------------------------------------------
*
- * Pthreads-win32 - POSIX Threads Library for Win32
+ * Pthreads4w - POSIX Threads Library for Win32
* Copyright(C) 1998 John E. Bossom
- * Copyright(C) 1999,2005 Pthreads-win32 contributors
- *
- * Contact Email: rpj@callisto.canberra.edu.au
- *
+ * Copyright(C) 1999-2018, Pthreads4w contributors
+ *
+ * Homepage: https://sourceforge.net/projects/pthreads4w/
+ *
* The current list of contributors is contained
* in the file CONTRIBUTORS included with the source
* code distribution. The list can also be seen at the
* following World Wide Web location:
- * http://sources.redhat.com/pthreads-win32/contributors.html
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library in the file COPYING.LIB;
- * if not, write to the Free Software Foundation, Inc.,
- * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
+ * https://sourceforge.net/p/pthreads4w/wiki/Contributors/
+ *
+ * This file is part of Pthreads4w.
+ *
+ * Pthreads4w is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * Pthreads4w is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Pthreads4w. If not, see <http://www.gnu.org/licenses/>. *
*/
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
#include "pthread.h"
#include "implement.h"
static struct pthread_mutexattr_t_ ptw32_recursive_mutexattr_s =
- {PTHREAD_PROCESS_PRIVATE, PTHREAD_MUTEX_RECURSIVE};
+ {PTHREAD_PROCESS_PRIVATE, PTHREAD_MUTEX_RECURSIVE, PTHREAD_MUTEX_STALLED};
static struct pthread_mutexattr_t_ ptw32_errorcheck_mutexattr_s =
- {PTHREAD_PROCESS_PRIVATE, PTHREAD_MUTEX_ERRORCHECK};
+ {PTHREAD_PROCESS_PRIVATE, PTHREAD_MUTEX_ERRORCHECK, PTHREAD_MUTEX_STALLED};
static pthread_mutexattr_t ptw32_recursive_mutexattr = &ptw32_recursive_mutexattr_s;
static pthread_mutexattr_t ptw32_errorcheck_mutexattr = &ptw32_errorcheck_mutexattr_s;
diff --git a/libs/pthreads/src/ptw32_new.c b/libs/pthreads/src/ptw32_new.c
index ac836ead3a..1708ee8d41 100644
--- a/libs/pthreads/src/ptw32_new.c
+++ b/libs/pthreads/src/ptw32_new.c
@@ -6,34 +6,38 @@
*
* --------------------------------------------------------------------------
*
- * Pthreads-win32 - POSIX Threads Library for Win32
+ * Pthreads4w - POSIX Threads Library for Win32
* Copyright(C) 1998 John E. Bossom
- * Copyright(C) 1999,2005 Pthreads-win32 contributors
- *
- * Contact Email: rpj@callisto.canberra.edu.au
- *
+ * Copyright(C) 1999-2018, Pthreads4w contributors
+ *
+ * Homepage: https://sourceforge.net/projects/pthreads4w/
+ *
* The current list of contributors is contained
* in the file CONTRIBUTORS included with the source
* code distribution. The list can also be seen at the
* following World Wide Web location:
- * http://sources.redhat.com/pthreads-win32/contributors.html
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library in the file COPYING.LIB;
- * if not, write to the Free Software Foundation, Inc.,
- * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
+ * https://sourceforge.net/p/pthreads4w/wiki/Contributors/
+ *
+ * This file is part of Pthreads4w.
+ *
+ * Pthreads4w is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * Pthreads4w is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Pthreads4w. If not, see <http://www.gnu.org/licenses/>. *
*/
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
#include "pthread.h"
#include "implement.h"
@@ -79,6 +83,10 @@ ptw32_new (void)
tp->threadLock = 0;
tp->robustMxListLock = 0;
tp->robustMxList = NULL;
+ tp->name = NULL;
+#if defined(HAVE_CPU_AFFINITY)
+ CPU_ZERO((cpu_set_t*)&tp->cpuset);
+#endif
tp->cancelEvent = CreateEvent (0, (int) PTW32_TRUE, /* manualReset */
(int) PTW32_FALSE, /* setSignaled */
NULL);
diff --git a/libs/pthreads/src/ptw32_processInitialize.c b/libs/pthreads/src/ptw32_processInitialize.c
index 8da3e41fa1..8697076bdd 100644
--- a/libs/pthreads/src/ptw32_processInitialize.c
+++ b/libs/pthreads/src/ptw32_processInitialize.c
@@ -7,34 +7,38 @@
*
* --------------------------------------------------------------------------
*
- * Pthreads-win32 - POSIX Threads Library for Win32
+ * Pthreads4w - POSIX Threads Library for Win32
* Copyright(C) 1998 John E. Bossom
- * Copyright(C) 1999,2005 Pthreads-win32 contributors
- *
- * Contact Email: rpj@callisto.canberra.edu.au
- *
+ * Copyright(C) 1999-2018, Pthreads4w contributors
+ *
+ * Homepage: https://sourceforge.net/projects/pthreads4w/
+ *
* The current list of contributors is contained
* in the file CONTRIBUTORS included with the source
* code distribution. The list can also be seen at the
* following World Wide Web location:
- * http://sources.redhat.com/pthreads-win32/contributors.html
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library in the file COPYING.LIB;
- * if not, write to the Free Software Foundation, Inc.,
- * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
+ * https://sourceforge.net/p/pthreads4w/wiki/Contributors/
+ *
+ * This file is part of Pthreads4w.
+ *
+ * Pthreads4w is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * Pthreads4w is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Pthreads4w. If not, see <http://www.gnu.org/licenses/>. *
*/
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
#include "pthread.h"
#include "implement.h"
@@ -65,16 +69,78 @@ ptw32_processInitialize (void)
{
if (ptw32_processInitialized)
{
- /*
- * Ignore if already initialized. this is useful for
- * programs that uses a non-dll pthread
- * library. Such programs must call ptw32_processInitialize() explicitly,
- * since this initialization routine is automatically called only when
- * the dll is loaded.
- */
return PTW32_TRUE;
}
+ /*
+ * Explicitly initialise all variables from global.c
+ */
+ ptw32_threadReuseTop = PTW32_THREAD_REUSE_EMPTY;
+ ptw32_threadReuseBottom = PTW32_THREAD_REUSE_EMPTY;
+ ptw32_selfThreadKey = NULL;
+ ptw32_cleanupKey = NULL;
+ ptw32_cond_list_head = NULL;
+ ptw32_cond_list_tail = NULL;
+
+ ptw32_concurrency = 0;
+
+ /* What features have been auto-detected */
+ ptw32_features = 0;
+
+ /*
+ * Global [process wide] thread sequence Number
+ */
+ ptw32_threadSeqNumber = 0;
+
+ /*
+ * Function pointer to QueueUserAPCEx if it exists, otherwise
+ * it will be set at runtime to a substitute routine which cannot unblock
+ * blocked threads.
+ */
+ ptw32_register_cancellation = NULL;
+
+ /*
+ * Global lock for managing pthread_t struct reuse.
+ */
+ ptw32_thread_reuse_lock = 0;
+
+ /*
+ * Global lock for testing internal state of statically declared mutexes.
+ */
+ ptw32_mutex_test_init_lock = 0;
+
+ /*
+ * Global lock for testing internal state of PTHREAD_COND_INITIALIZER
+ * created condition variables.
+ */
+ ptw32_cond_test_init_lock = 0;
+
+ /*
+ * Global lock for testing internal state of PTHREAD_RWLOCK_INITIALIZER
+ * created read/write locks.
+ */
+ ptw32_rwlock_test_init_lock = 0;
+
+ /*
+ * Global lock for testing internal state of PTHREAD_SPINLOCK_INITIALIZER
+ * created spin locks.
+ */
+ ptw32_spinlock_test_init_lock = 0;
+
+ /*
+ * Global lock for condition variable linked list. The list exists
+ * to wake up CVs when a WM_TIMECHANGE message arrives. See
+ * w32_TimeChangeHandler.c.
+ */
+ ptw32_cond_list_lock = 0;
+
+ #if defined(_UWIN)
+ /*
+ * Keep a count of the number of threads.
+ */
+ pthread_count = 0;
+ #endif
+
ptw32_processInitialized = PTW32_TRUE;
/*
diff --git a/libs/pthreads/src/ptw32_processTerminate.c b/libs/pthreads/src/ptw32_processTerminate.c
index 83f0f23cab..bc2ebe83ca 100644
--- a/libs/pthreads/src/ptw32_processTerminate.c
+++ b/libs/pthreads/src/ptw32_processTerminate.c
@@ -7,34 +7,38 @@
*
* --------------------------------------------------------------------------
*
- * Pthreads-win32 - POSIX Threads Library for Win32
+ * Pthreads4w - POSIX Threads Library for Win32
* Copyright(C) 1998 John E. Bossom
- * Copyright(C) 1999,2005 Pthreads-win32 contributors
- *
- * Contact Email: rpj@callisto.canberra.edu.au
- *
+ * Copyright(C) 1999-2018, Pthreads4w contributors
+ *
+ * Homepage: https://sourceforge.net/projects/pthreads4w/
+ *
* The current list of contributors is contained
* in the file CONTRIBUTORS included with the source
* code distribution. The list can also be seen at the
* following World Wide Web location:
- * http://sources.redhat.com/pthreads-win32/contributors.html
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library in the file COPYING.LIB;
- * if not, write to the Free Software Foundation, Inc.,
- * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
+ * https://sourceforge.net/p/pthreads4w/wiki/Contributors/
+ *
+ * This file is part of Pthreads4w.
+ *
+ * Pthreads4w is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * Pthreads4w is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Pthreads4w. If not, see <http://www.gnu.org/licenses/>. *
*/
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
#include "pthread.h"
#include "implement.h"
diff --git a/libs/pthreads/src/ptw32_relmillisecs.c b/libs/pthreads/src/ptw32_relmillisecs.c
index 894d5c9d46..286ba04387 100644
--- a/libs/pthreads/src/ptw32_relmillisecs.c
+++ b/libs/pthreads/src/ptw32_relmillisecs.c
@@ -6,68 +6,64 @@
*
* --------------------------------------------------------------------------
*
- * Pthreads-win32 - POSIX Threads Library for Win32
+ * Pthreads4w - POSIX Threads Library for Win32
* Copyright(C) 1998 John E. Bossom
- * Copyright(C) 1999,2005 Pthreads-win32 contributors
- *
- * Contact Email: rpj@callisto.canberra.edu.au
- *
+ * Copyright(C) 1999-2018, Pthreads4w contributors
+ *
+ * Homepage: https://sourceforge.net/projects/pthreads4w/
+ *
* The current list of contributors is contained
* in the file CONTRIBUTORS included with the source
* code distribution. The list can also be seen at the
* following World Wide Web location:
- * http://sources.redhat.com/pthreads-win32/contributors.html
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library in the file COPYING.LIB;
- * if not, write to the Free Software Foundation, Inc.,
- * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
+ * https://sourceforge.net/p/pthreads4w/wiki/Contributors/
+ *
+ * This file is part of Pthreads4w.
+ *
+ * Pthreads4w is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * Pthreads4w is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Pthreads4w. If not, see <http://www.gnu.org/licenses/>. *
*/
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
#include "pthread.h"
#include "implement.h"
-#if !defined(NEED_FTIME)
-#include <sys/timeb.h>
-#endif
+static const int64_t NANOSEC_PER_SEC = 1000000000;
+static const int64_t NANOSEC_PER_MILLISEC = 1000000;
+static const int64_t MILLISEC_PER_SEC = 1000;
#if defined(PTW32_BUILD_INLINED)
-INLINE
+INLINE
#endif /* PTW32_BUILD_INLINED */
DWORD
ptw32_relmillisecs (const struct timespec * abstime)
{
- const int64_t NANOSEC_PER_MILLISEC = 1000000;
- const int64_t MILLISEC_PER_SEC = 1000;
DWORD milliseconds;
- int64_t tmpAbsMilliseconds;
- int64_t tmpCurrMilliseconds;
-#if defined(NEED_FTIME)
+ int64_t tmpAbsNanoseconds;
+ int64_t tmpCurrNanoseconds;
+
struct timespec currSysTime;
FILETIME ft;
+
+# if defined(WINCE)
SYSTEMTIME st;
-#else /* ! NEED_FTIME */
-#if ( defined(_MSC_VER) && _MSC_VER >= 1300 ) || \
- ( (defined(__MINGW64__) || defined(__MINGW32__)) && __MSVCRT_VERSION__ >= 0x0601 )
- struct __timeb64 currSysTime;
-#else
- struct _timeb currSysTime;
#endif
-#endif /* NEED_FTIME */
-
- /*
- * Calculate timeout as milliseconds from current system time.
+ /*
+ * Calculate timeout as milliseconds from current system time.
*/
/*
@@ -77,50 +73,34 @@ ptw32_relmillisecs (const struct timespec * abstime)
*
* Assume all integers are unsigned, i.e. cannot test if less than 0.
*/
- tmpAbsMilliseconds = (int64_t)abstime->tv_sec * MILLISEC_PER_SEC;
- tmpAbsMilliseconds += ((int64_t)abstime->tv_nsec + (NANOSEC_PER_MILLISEC/2)) / NANOSEC_PER_MILLISEC;
+ tmpAbsNanoseconds = (int64_t)abstime->tv_nsec + ((int64_t)abstime->tv_sec * NANOSEC_PER_SEC);
/* get current system time */
-#if defined(NEED_FTIME)
-
+# if defined(WINCE)
GetSystemTime(&st);
SystemTimeToFileTime(&st, &ft);
- /*
- * GetSystemTimeAsFileTime(&ft); would be faster,
- * but it does not exist on WinCE
- */
+# else
+ GetSystemTimeAsFileTime(&ft);
+# endif
ptw32_filetime_to_timespec(&ft, &currSysTime);
- tmpCurrMilliseconds = (int64_t)currSysTime.tv_sec * MILLISEC_PER_SEC;
- tmpCurrMilliseconds += ((int64_t)currSysTime.tv_nsec + (NANOSEC_PER_MILLISEC/2))
- / NANOSEC_PER_MILLISEC;
-
-#else /* ! NEED_FTIME */
-
-#if defined(_MSC_VER) && _MSC_VER >= 1400
- _ftime64_s(&currSysTime);
-#elif ( defined(_MSC_VER) && _MSC_VER >= 1300 ) || \
- ( (defined(__MINGW64__) || defined(__MINGW32__)) && __MSVCRT_VERSION__ >= 0x0601 )
- _ftime64(&currSysTime);
-#else
- _ftime(&currSysTime);
-#endif
-
- tmpCurrMilliseconds = (int64_t) currSysTime.time * MILLISEC_PER_SEC;
- tmpCurrMilliseconds += (int64_t) currSysTime.millitm;
-
-#endif /* NEED_FTIME */
+ tmpCurrNanoseconds = (int64_t)currSysTime.tv_nsec + ((int64_t)currSysTime.tv_sec * NANOSEC_PER_SEC);
- if (tmpAbsMilliseconds > tmpCurrMilliseconds)
+ if (tmpAbsNanoseconds > tmpCurrNanoseconds)
{
- milliseconds = (DWORD) (tmpAbsMilliseconds - tmpCurrMilliseconds);
- if (milliseconds == INFINITE)
- {
- /* Timeouts must be finite */
- milliseconds--;
- }
+ int64_t deltaNanoseconds = tmpAbsNanoseconds - tmpCurrNanoseconds;
+
+ if (deltaNanoseconds >= ((int64_t)INFINITE * NANOSEC_PER_MILLISEC))
+ {
+ /* Timeouts must be finite */
+ milliseconds = INFINITE - 1;
+ }
+ else
+ {
+ milliseconds = (DWORD)(deltaNanoseconds / NANOSEC_PER_MILLISEC);
+ }
}
else
{
@@ -128,5 +108,61 @@ ptw32_relmillisecs (const struct timespec * abstime)
milliseconds = 0;
}
+ if (milliseconds == 0 && tmpAbsNanoseconds > tmpCurrNanoseconds) {
+ /*
+ * millisecond granularity was too small to represent the wait time.
+ * return the minimum time in milliseconds.
+ */
+ milliseconds = 1;
+ }
+
return milliseconds;
}
+
+
+/*
+ * Return the first parameter "abstime" modified to represent the current system time.
+ * If "relative" is not NULL it represents an interval to add to "abstime".
+ */
+
+struct timespec *
+pthread_win32_getabstime_np (struct timespec * abstime, const struct timespec * relative)
+{
+ int64_t sec;
+ int64_t nsec;
+
+ struct timespec currSysTime;
+ FILETIME ft;
+
+ /* get current system time */
+
+# if defined(WINCE)
+
+ SYSTEMTIME st;
+ GetSystemTime(&st);
+ SystemTimeToFileTime(&st, &ft);
+# else
+ GetSystemTimeAsFileTime(&ft);
+# endif
+
+ ptw32_filetime_to_timespec(&ft, &currSysTime);
+
+ sec = currSysTime.tv_sec;
+ nsec = currSysTime.tv_nsec;
+
+ if (NULL != relative)
+ {
+ nsec += relative->tv_nsec;
+ if (nsec >= NANOSEC_PER_SEC)
+ {
+ sec++;
+ nsec -= NANOSEC_PER_SEC;
+ }
+ sec += relative->tv_sec;
+ }
+
+ abstime->tv_sec = (time_t) sec;
+ abstime->tv_nsec = (long) nsec;
+
+ return abstime;
+}
diff --git a/libs/pthreads/src/ptw32_reuse.c b/libs/pthreads/src/ptw32_reuse.c
index 7325857ba2..f6270bb08f 100644
--- a/libs/pthreads/src/ptw32_reuse.c
+++ b/libs/pthreads/src/ptw32_reuse.c
@@ -6,64 +6,70 @@
*
* --------------------------------------------------------------------------
*
- * Pthreads-win32 - POSIX Threads Library for Win32
+ * Pthreads4w - POSIX Threads Library for Win32
* Copyright(C) 1998 John E. Bossom
- * Copyright(C) 1999,2005 Pthreads-win32 contributors
- *
- * Contact Email: rpj@callisto.canberra.edu.au
- *
+ * Copyright(C) 1999-2018, Pthreads4w contributors
+ *
+ * Homepage: https://sourceforge.net/projects/pthreads4w/
+ *
* The current list of contributors is contained
* in the file CONTRIBUTORS included with the source
* code distribution. The list can also be seen at the
* following World Wide Web location:
- * http://sources.redhat.com/pthreads-win32/contributors.html
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library in the file COPYING.LIB;
- * if not, write to the Free Software Foundation, Inc.,
- * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
+ * https://sourceforge.net/p/pthreads4w/wiki/Contributors/
+ *
+ * This file is part of Pthreads4w.
+ *
+ * Pthreads4w is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * Pthreads4w is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Pthreads4w. If not, see <http://www.gnu.org/licenses/>. *
*/
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
#include "pthread.h"
#include "implement.h"
/*
* How it works:
- * A pthread_t is a struct (2x32 bit scalar types on IA-32, 2x64 bit on IA-64)
+ * A pthread_t is a struct (2x32 bit scalar types on x86, 2x64 bit on x86_64)
+ * [FIXME: This is not true, x86_64 is 64 bit pointer and 32 bit counter. This
+ * should be fixed in version 3.0.0]
* which is normally passed/returned by value to/from pthreads routines.
* Applications are therefore storing a copy of the struct as it is at that
* time.
*
* The original pthread_t struct plus all copies of it contain the address of
* the thread state struct ptw32_thread_t_ (p), plus a reuse counter (x). Each
- * ptw32_thread_t contains the original copy of it's pthread_t.
+ * ptw32_thread_t contains the original copy of it's pthread_t (ptHandle).
* Once malloced, a ptw32_thread_t_ struct is not freed until the process exits.
- *
+ *
* The thread reuse stack is a simple LILO stack managed through a singly
* linked list element in the ptw32_thread_t.
*
* Each time a thread is destroyed, the ptw32_thread_t address is pushed onto the
* reuse stack after it's ptHandle's reuse counter has been incremented.
- *
+ *
* The following can now be said from this:
- * - two pthread_t's are identical if their ptw32_thread_t reference pointers
- * are equal and their reuse counters are equal. That is,
+ * - two pthread_t's refer to the same thread iff their ptw32_thread_t reference
+ * pointers are equal and their reuse counters are equal. That is,
*
* equal = (a.p == b.p && a.x == b.x)
*
* - a pthread_t copy refers to a destroyed thread if the reuse counter in
- * the copy is not equal to the reuse counter in the original.
+ * the copy is not equal to (i.e less than) the reuse counter in the original.
*
* threadDestroyed = (copy.x != ((ptw32_thread_t *)copy.p)->ptHandle.x)
*
@@ -108,7 +114,7 @@ ptw32_threadReusePop (void)
* Push a clean pthread_t struct onto the reuse stack.
* Must be re-initialised when reused.
* All object elements (mutexes, events etc) must have been either
- * detroyed before this, or never initialised.
+ * destroyed before this, or never initialised.
*/
void
ptw32_threadReusePush (pthread_t thread)
diff --git a/libs/pthreads/src/ptw32_rwlock_cancelwrwait.c b/libs/pthreads/src/ptw32_rwlock_cancelwrwait.c
index a057bd1d72..160b84b886 100644
--- a/libs/pthreads/src/ptw32_rwlock_cancelwrwait.c
+++ b/libs/pthreads/src/ptw32_rwlock_cancelwrwait.c
@@ -6,34 +6,38 @@
*
* --------------------------------------------------------------------------
*
- * Pthreads-win32 - POSIX Threads Library for Win32
+ * Pthreads4w - POSIX Threads Library for Win32
* Copyright(C) 1998 John E. Bossom
- * Copyright(C) 1999,2005 Pthreads-win32 contributors
- *
- * Contact Email: rpj@callisto.canberra.edu.au
- *
+ * Copyright(C) 1999-2018, Pthreads4w contributors
+ *
+ * Homepage: https://sourceforge.net/projects/pthreads4w/
+ *
* The current list of contributors is contained
* in the file CONTRIBUTORS included with the source
* code distribution. The list can also be seen at the
* following World Wide Web location:
- * http://sources.redhat.com/pthreads-win32/contributors.html
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library in the file COPYING.LIB;
- * if not, write to the Free Software Foundation, Inc.,
- * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
+ * https://sourceforge.net/p/pthreads4w/wiki/Contributors/
+ *
+ * This file is part of Pthreads4w.
+ *
+ * Pthreads4w is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * Pthreads4w is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Pthreads4w. If not, see <http://www.gnu.org/licenses/>. *
*/
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
#include "pthread.h"
#include "implement.h"
diff --git a/libs/pthreads/src/ptw32_rwlock_check_need_init.c b/libs/pthreads/src/ptw32_rwlock_check_need_init.c
index 858ee271ce..d517847c68 100644
--- a/libs/pthreads/src/ptw32_rwlock_check_need_init.c
+++ b/libs/pthreads/src/ptw32_rwlock_check_need_init.c
@@ -6,34 +6,38 @@
*
* --------------------------------------------------------------------------
*
- * Pthreads-win32 - POSIX Threads Library for Win32
+ * Pthreads4w - POSIX Threads Library for Win32
* Copyright(C) 1998 John E. Bossom
- * Copyright(C) 1999,2005 Pthreads-win32 contributors
- *
- * Contact Email: rpj@callisto.canberra.edu.au
- *
+ * Copyright(C) 1999-2018, Pthreads4w contributors
+ *
+ * Homepage: https://sourceforge.net/projects/pthreads4w/
+ *
* The current list of contributors is contained
* in the file CONTRIBUTORS included with the source
* code distribution. The list can also be seen at the
* following World Wide Web location:
- * http://sources.redhat.com/pthreads-win32/contributors.html
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library in the file COPYING.LIB;
- * if not, write to the Free Software Foundation, Inc.,
- * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
+ * https://sourceforge.net/p/pthreads4w/wiki/Contributors/
+ *
+ * This file is part of Pthreads4w.
+ *
+ * Pthreads4w is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * Pthreads4w is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Pthreads4w. If not, see <http://www.gnu.org/licenses/>. *
*/
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
#include "pthread.h"
#include "implement.h"
diff --git a/libs/pthreads/src/ptw32_semwait.c b/libs/pthreads/src/ptw32_semwait.c
index c3c4fd0e5e..3c2ab535bb 100644
--- a/libs/pthreads/src/ptw32_semwait.c
+++ b/libs/pthreads/src/ptw32_semwait.c
@@ -6,34 +6,38 @@
*
* --------------------------------------------------------------------------
*
- * Pthreads-win32 - POSIX Threads Library for Win32
+ * Pthreads4w - POSIX Threads Library for Win32
* Copyright(C) 1998 John E. Bossom
- * Copyright(C) 1999,2005 Pthreads-win32 contributors
- *
- * Contact Email: rpj@callisto.canberra.edu.au
- *
+ * Copyright(C) 1999-2018, Pthreads4w contributors
+ *
+ * Homepage: https://sourceforge.net/projects/pthreads4w/
+ *
* The current list of contributors is contained
* in the file CONTRIBUTORS included with the source
* code distribution. The list can also be seen at the
* following World Wide Web location:
- * http://sources.redhat.com/pthreads-win32/contributors.html
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library in the file COPYING.LIB;
- * if not, write to the Free Software Foundation, Inc.,
- * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
+ * https://sourceforge.net/p/pthreads4w/wiki/Contributors/
+ *
+ * This file is part of Pthreads4w.
+ *
+ * Pthreads4w is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * Pthreads4w is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Pthreads4w. If not, see <http://www.gnu.org/licenses/>. *
*/
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
#if !defined(_UWIN)
/*# include <process.h> */
#endif
@@ -43,90 +47,63 @@
int
ptw32_semwait (sem_t * sem)
- /*
- * ------------------------------------------------------
- * DESCRIPTION
- * This function waits on a POSIX semaphore. If the
- * semaphore value is greater than zero, it decreases
- * its value by one. If the semaphore value is zero, then
- * the calling thread (or process) is blocked until it can
- * successfully decrease the value.
- *
- * Unlike sem_wait(), this routine is non-cancelable.
- *
- * RESULTS
- * 0 successfully decreased semaphore,
- * -1 failed, error in errno.
- * ERRNO
- * EINVAL 'sem' is not a valid semaphore,
- * ENOSYS semaphores are not supported,
- * EINTR the function was interrupted by a signal,
- * EDEADLK a deadlock condition was detected.
- *
- * ------------------------------------------------------
- */
+/*
+ * ------------------------------------------------------
+ * DESCRIPTION
+ * This function waits on a POSIX semaphore. If the
+ * semaphore value is greater than zero, it decreases
+ * its value by one. If the semaphore value is zero, then
+ * the calling thread (or process) is blocked until it can
+ * successfully decrease the value.
+ *
+ * Unlike sem_wait(), this routine is non-cancelable.
+ *
+ * RESULTS
+ * 0 successfully decreased semaphore,
+ * -1 failed, error in errno.
+ * ERRNO
+ * EINVAL 'sem' is not a valid semaphore,
+ * ENOSYS semaphores are not supported,
+ * EINTR the function was interrupted by a signal,
+ * EDEADLK a deadlock condition was detected.
+ *
+ * ------------------------------------------------------
+ */
{
+ ptw32_mcs_local_node_t node;
+ int v;
int result = 0;
sem_t s = *sem;
- if (s == NULL)
- {
- result = EINVAL;
- }
- else
+ ptw32_mcs_lock_acquire(&s->lock, &node);
+ v = --s->value;
+ ptw32_mcs_lock_release(&node);
+
+ if (v < 0)
{
- if ((result = pthread_mutex_lock (&s->lock)) == 0)
+ /* Must wait */
+ if (WaitForSingleObject (s->sem, INFINITE) == WAIT_OBJECT_0)
{
- int v;
-
- /* See sem_destroy.c
- */
- if (*sem == NULL)
- {
- (void) pthread_mutex_unlock (&s->lock);
- errno = EINVAL;
- return -1;
- }
-
- v = --s->value;
- (void) pthread_mutex_unlock (&s->lock);
-
- if (v < 0)
- {
- /* Must wait */
- if (WaitForSingleObject (s->sem, INFINITE) == WAIT_OBJECT_0)
- {
#if defined(NEED_SEM)
- if (pthread_mutex_lock (&s->lock) == 0)
- {
- if (*sem == NULL)
- {
- (void) pthread_mutex_unlock (&s->lock);
- errno = EINVAL;
- return -1;
- }
-
- if (s->leftToUnblock > 0)
- {
- --s->leftToUnblock;
- SetEvent(s->sem);
- }
- (void) pthread_mutex_unlock (&s->lock);
- }
-#endif
- return 0;
- }
+ ptw32_mcs_lock_acquire(&s->lock, &node);
+ if (s->leftToUnblock > 0)
+ {
+ --s->leftToUnblock;
+ SetEvent(s->sem);
}
- else
- {
- return 0;
- }
+ ptw32_mcs_lock_release(&node);
+#endif
+return 0;
}
}
+ else
+ {
+ return 0;
+ }
if (result != 0)
{
- errno = result;
+ PTW32_SET_ERRNO(result);
return -1;
}
diff --git a/libs/pthreads/src/ptw32_spinlock_check_need_init.c b/libs/pthreads/src/ptw32_spinlock_check_need_init.c
index 8808454ee8..f58e6b4117 100644
--- a/libs/pthreads/src/ptw32_spinlock_check_need_init.c
+++ b/libs/pthreads/src/ptw32_spinlock_check_need_init.c
@@ -6,34 +6,38 @@
*
* --------------------------------------------------------------------------
*
- * Pthreads-win32 - POSIX Threads Library for Win32
+ * Pthreads4w - POSIX Threads Library for Win32
* Copyright(C) 1998 John E. Bossom
- * Copyright(C) 1999,2005 Pthreads-win32 contributors
- *
- * Contact Email: rpj@callisto.canberra.edu.au
- *
+ * Copyright(C) 1999-2018, Pthreads4w contributors
+ *
+ * Homepage: https://sourceforge.net/projects/pthreads4w/
+ *
* The current list of contributors is contained
* in the file CONTRIBUTORS included with the source
* code distribution. The list can also be seen at the
* following World Wide Web location:
- * http://sources.redhat.com/pthreads-win32/contributors.html
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library in the file COPYING.LIB;
- * if not, write to the Free Software Foundation, Inc.,
- * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
+ * https://sourceforge.net/p/pthreads4w/wiki/Contributors/
+ *
+ * This file is part of Pthreads4w.
+ *
+ * Pthreads4w is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * Pthreads4w is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Pthreads4w. If not, see <http://www.gnu.org/licenses/>. *
*/
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
#include "pthread.h"
#include "implement.h"
diff --git a/libs/pthreads/src/ptw32_threadDestroy.c b/libs/pthreads/src/ptw32_threadDestroy.c
index 41499b11b6..f80fc2888f 100644
--- a/libs/pthreads/src/ptw32_threadDestroy.c
+++ b/libs/pthreads/src/ptw32_threadDestroy.c
@@ -7,34 +7,38 @@
*
* --------------------------------------------------------------------------
*
- * Pthreads-win32 - POSIX Threads Library for Win32
+ * Pthreads4w - POSIX Threads Library for Win32
* Copyright(C) 1998 John E. Bossom
- * Copyright(C) 1999,2005 Pthreads-win32 contributors
- *
- * Contact Email: rpj@callisto.canberra.edu.au
- *
+ * Copyright(C) 1999-2018, Pthreads4w contributors
+ *
+ * Homepage: https://sourceforge.net/projects/pthreads4w/
+ *
* The current list of contributors is contained
* in the file CONTRIBUTORS included with the source
* code distribution. The list can also be seen at the
* following World Wide Web location:
- * http://sources.redhat.com/pthreads-win32/contributors.html
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library in the file COPYING.LIB;
- * if not, write to the Free Software Foundation, Inc.,
- * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
+ * https://sourceforge.net/p/pthreads4w/wiki/Contributors/
+ *
+ * This file is part of Pthreads4w.
+ *
+ * Pthreads4w is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * Pthreads4w is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Pthreads4w. If not, see <http://www.gnu.org/licenses/>. *
*/
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
#include "pthread.h"
#include "implement.h"
@@ -64,7 +68,7 @@ ptw32_threadDestroy (pthread_t thread)
CloseHandle (threadCopy.cancelEvent);
}
-#if ! (defined(__MINGW64__) || defined(__MINGW32__)) || defined (__MSVCRT__) || defined (__DMC__)
+#if ! defined(__MINGW32__) || defined (__MSVCRT__) || defined (__DMC__)
/*
* See documentation for endthread vs endthreadex.
*/
diff --git a/libs/pthreads/src/ptw32_threadStart.c b/libs/pthreads/src/ptw32_threadStart.c
index e83ede0ec4..fb1ced9b8e 100644
--- a/libs/pthreads/src/ptw32_threadStart.c
+++ b/libs/pthreads/src/ptw32_threadStart.c
@@ -7,34 +7,38 @@
*
* --------------------------------------------------------------------------
*
- * Pthreads-win32 - POSIX Threads Library for Win32
+ * Pthreads4w - POSIX Threads Library for Win32
* Copyright(C) 1998 John E. Bossom
- * Copyright(C) 1999,2005 Pthreads-win32 contributors
- *
- * Contact Email: rpj@callisto.canberra.edu.au
- *
+ * Copyright(C) 1999-2018, Pthreads4w contributors
+ *
+ * Homepage: https://sourceforge.net/projects/pthreads4w/
+ *
* The current list of contributors is contained
* in the file CONTRIBUTORS included with the source
* code distribution. The list can also be seen at the
* following World Wide Web location:
- * http://sources.redhat.com/pthreads-win32/contributors.html
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library in the file COPYING.LIB;
- * if not, write to the Free Software Foundation, Inc.,
- * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
+ * https://sourceforge.net/p/pthreads4w/wiki/Contributors/
+ *
+ * This file is part of Pthreads4w.
+ *
+ * Pthreads4w is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * Pthreads4w is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Pthreads4w. If not, see <http://www.gnu.org/licenses/>. *
*/
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
#include "pthread.h"
#include "implement.h"
#include <stdio.h>
@@ -59,7 +63,7 @@ ExceptionFilter (EXCEPTION_POINTERS * ep, DWORD * ei)
for (param = 0; param < numParams; param++)
{
- ei[param] = ep->ExceptionRecord->ExceptionInformation[param];
+ ei[param] = (DWORD) ep->ExceptionRecord->ExceptionInformation[param];
}
return EXCEPTION_EXECUTE_HANDLER;
@@ -89,38 +93,32 @@ ExceptionFilter (EXCEPTION_POINTERS * ep, DWORD * ei)
#elif defined(__WATCOMC__)
# include <eh.h>
# include <exceptio.h>
-typedef terminate_handler
- terminate_function;
#else
# if defined(__GNUC__) && __GNUC__ < 3
# include <new.h>
# else
# include <new>
using
- std::terminate_handler;
-using
std::terminate;
using
std::set_terminate;
# endif
-typedef terminate_handler
- terminate_function;
#endif
-static terminate_function
- ptw32_oldTerminate;
-
-void
-ptw32_terminate ()
-{
- set_terminate (ptw32_oldTerminate);
- (void) pthread_win32_thread_detach_np ();
- terminate ();
-}
+#endif /* __CLEANUP_CXX */
+/*
+ * MSVC6 does not optimize ptw32_threadStart() safely
+ * (i.e. tests/context1.c fails with "abnormal program
+ * termination" in some configurations), and there's no
+ * point to optimizing this routine anyway
+ */
+#ifdef _MSC_VER
+# pragma optimize("g", off)
+# pragma warning( disable : 4748 )
#endif
-#if ! (defined(__MINGW64__) || defined(__MINGW32__)) || (defined (__MSVCRT__) && ! defined (__DMC__))
+#if ! defined (__MINGW32__) || (defined (__MSVCRT__) && ! defined (__DMC__))
unsigned
__stdcall
#else
@@ -153,24 +151,22 @@ ptw32_threadStart (void *vthreadParms)
free (threadParms);
-#if (defined(__MINGW64__) || defined(__MINGW32__)) && ! defined (__MSVCRT__)
+#if ! defined (__MINGW32__) || defined (__MSVCRT__) || defined (__DMC__)
+#else
/*
- * beginthread does not return the thread id and is running
+ * _beginthread does not return the thread id and is running
* before it returns us the thread handle, and so we do it here.
*/
sp->thread = GetCurrentThreadId ();
+#endif
+
+ pthread_setspecific (ptw32_selfThreadKey, sp);
/*
* Here we're using stateLock as a general-purpose lock
* to make the new thread wait until the creating thread
* has the new handle.
*/
ptw32_mcs_lock_acquire (&sp->stateLock, &stateLock);
- pthread_setspecific (ptw32_selfThreadKey, sp);
-#else
- pthread_setspecific (ptw32_selfThreadKey, sp);
- ptw32_mcs_lock_acquire (&sp->stateLock, &stateLock);
-#endif
-
sp->state = PThreadStateRunning;
ptw32_mcs_lock_release (&stateLock);
@@ -194,19 +190,19 @@ ptw32_threadStart (void *vthreadParms)
{
switch (ei[0])
{
- case PTW32_EPS_CANCEL:
- status = sp->exitStatus = PTHREAD_CANCELED;
+ case PTW32_EPS_CANCEL:
+ status = sp->exitStatus = PTHREAD_CANCELED;
#if defined(_UWIN)
- if (--pthread_count <= 0)
- exit (0);
+ if (--pthread_count <= 0)
+ exit (0);
#endif
- break;
- case PTW32_EPS_EXIT:
- status = sp->exitStatus;
- break;
- default:
- status = sp->exitStatus = PTHREAD_CANCELED;
- break;
+ break;
+ case PTW32_EPS_EXIT:
+ status = sp->exitStatus;
+ break;
+ default:
+ status = sp->exitStatus = PTHREAD_CANCELED;
+ break;
}
}
@@ -218,7 +214,6 @@ ptw32_threadStart (void *vthreadParms)
if (0 == setjmp_rc)
{
-
/*
* Run the caller's routine;
*/
@@ -228,64 +223,27 @@ ptw32_threadStart (void *vthreadParms)
else
{
switch (setjmp_rc)
- {
- case PTW32_EPS_CANCEL:
- status = sp->exitStatus = PTHREAD_CANCELED;
- break;
- case PTW32_EPS_EXIT:
- status = sp->exitStatus;
- break;
- default:
- status = sp->exitStatus = PTHREAD_CANCELED;
- break;
- }
+ {
+ case PTW32_EPS_CANCEL:
+ status = sp->exitStatus = PTHREAD_CANCELED;
+ break;
+ case PTW32_EPS_EXIT:
+ status = sp->exitStatus;
+ break;
+ default:
+ status = sp->exitStatus = PTHREAD_CANCELED;
+ break;
+ }
}
#else /* __CLEANUP_C */
#if defined(__CLEANUP_CXX)
- ptw32_oldTerminate = set_terminate (&ptw32_terminate);
-
try
{
- /*
- * Run the caller's routine in a nested try block so that we
- * can run the user's terminate function, which may call
- * pthread_exit() or be canceled.
- */
- try
- {
- status = sp->exitStatus = (*start) (arg);
- sp->state = PThreadStateExiting;
- }
- catch (ptw32_exception &)
- {
- /*
- * Pass these through to the outer block.
- */
- throw;
- }
- catch (...)
- {
- /*
- * We want to run the user's terminate function if supplied.
- * That function may call pthread_exit() or be canceled, which will
- * be handled by the outer try block.
- *
- * ptw32_terminate() will be called if there is no user
- * supplied function.
- */
- terminate_function
- term_func = set_terminate (0);
- set_terminate (term_func);
-
- if (term_func != 0)
- {
- term_func ();
- }
- throw;
- }
+ status = sp->exitStatus = (*start) (arg);
+ sp->state = PThreadStateExiting;
}
catch (ptw32_exception_cancel &)
{
@@ -304,16 +262,13 @@ ptw32_threadStart (void *vthreadParms)
catch (...)
{
/*
- * A system unexpected exception has occurred running the user's
- * terminate routine. We get control back within this block
- * and exit with a substitute status. If the thread was not
- * cancelled then this indicates the unhandled exception.
+ * Some other exception occurred. Clean up while we have
+ * the opportunity, and call the terminate handler.
*/
- status = sp->exitStatus = PTHREAD_CANCELED;
+ (void) pthread_win32_thread_detach_np ();
+ terminate ();
}
- (void) set_terminate (ptw32_oldTerminate);
-
#else
#error ERROR [__FILE__, line __LINE__]: Cleanup type undefined.
@@ -326,7 +281,7 @@ ptw32_threadStart (void *vthreadParms)
/*
* We need to cleanup the pthread now if we have
* been statically linked, in which case the cleanup
- * in dllMain won't get done. Joinable threads will
+ * in DllMain won't get done. Joinable threads will
* only be partially cleaned up and must be fully cleaned
* up by pthread_join() or pthread_detach().
*
@@ -334,13 +289,13 @@ ptw32_threadStart (void *vthreadParms)
* implicitly created pthreads (those created
* for Win32 threads which have called pthreads routines)
* must be cleaned up explicitly by the application
- * (by calling pthread_win32_thread_detach_np()).
- * For the dll, dllMain will do the cleanup automatically.
+ * by calling pthread_exit().
+ * For the dll, DllMain will do the cleanup automatically.
*/
(void) pthread_win32_thread_detach_np ();
#endif
-#if ! (defined(__MINGW64__) || defined(__MINGW32__)) || defined (__MSVCRT__) || defined (__DMC__)
+#if ! defined (__MINGW32__) || defined (__MSVCRT__) || defined (__DMC__)
_endthreadex ((unsigned)(size_t) status);
#else
_endthread ();
@@ -350,8 +305,23 @@ ptw32_threadStart (void *vthreadParms)
* Never reached.
*/
-#if ! (defined(__MINGW64__) || defined(__MINGW32__)) || defined (__MSVCRT__) || defined (__DMC__)
+#if ! defined (__MINGW32__) || defined (__MSVCRT__) || defined (__DMC__)
return (unsigned)(size_t) status;
#endif
} /* ptw32_threadStart */
+
+/*
+ * Reset optimization
+ */
+#ifdef _MSC_VER
+# pragma optimize("", on)
+#endif
+
+#if defined (PTW32_USES_SEPARATE_CRT) && (defined(__CLEANUP_CXX) || defined(__CLEANUP_SEH))
+ptw32_terminate_handler
+pthread_win32_set_terminate_np(ptw32_terminate_handler termFunction)
+{
+ return set_terminate(termFunction);
+}
+#endif
diff --git a/libs/pthreads/src/ptw32_throw.c b/libs/pthreads/src/ptw32_throw.c
index 1404e940f5..2dd1949d26 100644
--- a/libs/pthreads/src/ptw32_throw.c
+++ b/libs/pthreads/src/ptw32_throw.c
@@ -7,34 +7,38 @@
*
* --------------------------------------------------------------------------
*
- * Pthreads-win32 - POSIX Threads Library for Win32
+ * Pthreads4w - POSIX Threads Library for Win32
* Copyright(C) 1998 John E. Bossom
- * Copyright(C) 1999,2005 Pthreads-win32 contributors
- *
- * Contact Email: rpj@callisto.canberra.edu.au
- *
+ * Copyright(C) 1999-2018, Pthreads4w contributors
+ *
+ * Homepage: https://sourceforge.net/projects/pthreads4w/
+ *
* The current list of contributors is contained
* in the file CONTRIBUTORS included with the source
* code distribution. The list can also be seen at the
* following World Wide Web location:
- * http://sources.redhat.com/pthreads-win32/contributors.html
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library in the file COPYING.LIB;
- * if not, write to the Free Software Foundation, Inc.,
- * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
+ * https://sourceforge.net/p/pthreads4w/wiki/Contributors/
+ *
+ * This file is part of Pthreads4w.
+ *
+ * Pthreads4w is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * Pthreads4w is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Pthreads4w. If not, see <http://www.gnu.org/licenses/>. *
*/
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
#include "pthread.h"
#include "implement.h"
@@ -45,24 +49,13 @@
/*
* ptw32_throw
*
- * All canceled and explicitly exited POSIX threads go through
+ * All cancelled and explicitly exited POSIX threads go through
* here. This routine knows how to exit both POSIX initiated threads and
* 'implicit' POSIX threads for each of the possible language modes (C,
* C++, and SEH).
*/
-#if defined(_MSC_VER)
-/*
- * Ignore the warning:
- * "C++ exception specification ignored except to indicate that
- * the function is not __declspec(nothrow)."
- */
-#pragma warning(disable:4290)
-#endif
void
ptw32_throw (DWORD exception)
-#if defined(__CLEANUP_CXX)
- throw(ptw32_exception_cancel,ptw32_exception_exit)
-#endif
{
/*
* Don't use pthread_self() to avoid creating an implicit POSIX thread handle
@@ -90,21 +83,21 @@ ptw32_throw (DWORD exception)
* explicit thread exit here after cleaning up POSIX
* residue (i.e. cleanup handlers, POSIX thread handle etc).
*/
-#if ! (defined(__MINGW64__) || defined(__MINGW32__)) || defined (__MSVCRT__) || defined (__DMC__)
+#if ! defined (__MINGW32__) || defined (__MSVCRT__) || defined (__DMC__)
unsigned exitCode = 0;
switch (exception)
- {
- case PTW32_EPS_CANCEL:
- exitCode = (unsigned)(size_t) PTHREAD_CANCELED;
- break;
- case PTW32_EPS_EXIT:
- if (NULL != sp)
- {
- exitCode = (unsigned)(size_t) sp->exitStatus;
- }
- break;
- }
+ {
+ case PTW32_EPS_CANCEL:
+ exitCode = (unsigned)(size_t) PTHREAD_CANCELED;
+ break;
+ case PTW32_EPS_EXIT:
+ if (NULL != sp)
+ {
+ exitCode = (unsigned)(size_t) sp->exitStatus;
+ }
+ break;
+ }
#endif
#if defined(PTW32_STATIC_LIB)
@@ -113,7 +106,7 @@ ptw32_throw (DWORD exception)
#endif
-#if ! (defined(__MINGW64__) || defined(__MINGW32__)) || defined (__MSVCRT__) || defined (__DMC__)
+#if ! defined (__MINGW32__) || defined (__MSVCRT__) || defined (__DMC__)
_endthreadex (exitCode);
#else
_endthread ();
@@ -128,7 +121,7 @@ ptw32_throw (DWORD exception)
exceptionInformation[1] = (DWORD) (0);
exceptionInformation[2] = (DWORD) (0);
- RaiseException (EXCEPTION_PTW32_SERVICES, 0, 3, exceptionInformation);
+ RaiseException (EXCEPTION_PTW32_SERVICES, 0, 3, (ULONG_PTR *) exceptionInformation);
#else /* __CLEANUP_SEH */
diff --git a/libs/pthreads/src/ptw32_timespec.c b/libs/pthreads/src/ptw32_timespec.c
index 6318957a89..e82e35e370 100644
--- a/libs/pthreads/src/ptw32_timespec.c
+++ b/libs/pthreads/src/ptw32_timespec.c
@@ -7,45 +7,46 @@
*
* --------------------------------------------------------------------------
*
- * Pthreads-win32 - POSIX Threads Library for Win32
+ * Pthreads4w - POSIX Threads Library for Win32
* Copyright(C) 1998 John E. Bossom
- * Copyright(C) 1999,2005 Pthreads-win32 contributors
- *
- * Contact Email: rpj@callisto.canberra.edu.au
- *
+ * Copyright(C) 1999-2018, Pthreads4w contributors
+ *
+ * Homepage: https://sourceforge.net/projects/pthreads4w/
+ *
* The current list of contributors is contained
* in the file CONTRIBUTORS included with the source
* code distribution. The list can also be seen at the
* following World Wide Web location:
- * http://sources.redhat.com/pthreads-win32/contributors.html
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library in the file COPYING.LIB;
- * if not, write to the Free Software Foundation, Inc.,
- * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
+ * https://sourceforge.net/p/pthreads4w/wiki/Contributors/
+ *
+ * This file is part of Pthreads4w.
+ *
+ * Pthreads4w is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * Pthreads4w is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Pthreads4w. If not, see <http://www.gnu.org/licenses/>. *
*/
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
#include "pthread.h"
#include "implement.h"
-
-#if defined(NEED_FTIME)
-
/*
* time between jan 1, 1601 and jan 1, 1970 in units of 100 nanoseconds
*/
#define PTW32_TIMESPEC_TO_FILETIME_OFFSET \
- ( ((int64_t) 27111902 << 32) + (int64_t) 3577643008 )
+ ( ((uint64_t) 27111902UL << 32) + (uint64_t) 3577643008UL )
INLINE void
ptw32_timespec_to_filetime (const struct timespec *ts, FILETIME * ft)
@@ -58,7 +59,7 @@ ptw32_timespec_to_filetime (const struct timespec *ts, FILETIME * ft)
* -------------------------------------------------------------------
*/
{
- *(int64_t *) ft = ts->tv_sec * 10000000
+ *(uint64_t *) ft = ts->tv_sec * 10000000UL
+ (ts->tv_nsec + 50) / 100 + PTW32_TIMESPEC_TO_FILETIME_OFFSET;
}
@@ -74,10 +75,8 @@ ptw32_filetime_to_timespec (const FILETIME * ft, struct timespec *ts)
*/
{
ts->tv_sec =
- (int) ((*(int64_t *) ft - PTW32_TIMESPEC_TO_FILETIME_OFFSET) / 10000000);
+ (int) ((*(uint64_t *) ft - PTW32_TIMESPEC_TO_FILETIME_OFFSET) / 10000000UL);
ts->tv_nsec =
- (int) ((*(int64_t *) ft - PTW32_TIMESPEC_TO_FILETIME_OFFSET -
- ((int64_t) ts->tv_sec * (int64_t) 10000000)) * 100);
+ (int) ((*(uint64_t *) ft - PTW32_TIMESPEC_TO_FILETIME_OFFSET -
+ ((uint64_t) ts->tv_sec * (uint64_t) 10000000UL)) * 100);
}
-
-#endif /* NEED_FTIME */
diff --git a/libs/pthreads/src/ptw32_tkAssocCreate.c b/libs/pthreads/src/ptw32_tkAssocCreate.c
index 50d6c500c3..67efb3a631 100644
--- a/libs/pthreads/src/ptw32_tkAssocCreate.c
+++ b/libs/pthreads/src/ptw32_tkAssocCreate.c
@@ -7,34 +7,38 @@
*
* --------------------------------------------------------------------------
*
- * Pthreads-win32 - POSIX Threads Library for Win32
+ * Pthreads4w - POSIX Threads Library for Win32
* Copyright(C) 1998 John E. Bossom
- * Copyright(C) 1999,2005 Pthreads-win32 contributors
- *
- * Contact Email: rpj@callisto.canberra.edu.au
- *
+ * Copyright(C) 1999-2018, Pthreads4w contributors
+ *
+ * Homepage: https://sourceforge.net/projects/pthreads4w/
+ *
* The current list of contributors is contained
* in the file CONTRIBUTORS included with the source
* code distribution. The list can also be seen at the
* following World Wide Web location:
- * http://sources.redhat.com/pthreads-win32/contributors.html
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library in the file COPYING.LIB;
- * if not, write to the Free Software Foundation, Inc.,
- * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
+ * https://sourceforge.net/p/pthreads4w/wiki/Contributors/
+ *
+ * This file is part of Pthreads4w.
+ *
+ * Pthreads4w is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * Pthreads4w is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Pthreads4w. If not, see <http://www.gnu.org/licenses/>. *
*/
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
#include "pthread.h"
#include "implement.h"
diff --git a/libs/pthreads/src/ptw32_tkAssocDestroy.c b/libs/pthreads/src/ptw32_tkAssocDestroy.c
index fedebf5935..e1ea0630b1 100644
--- a/libs/pthreads/src/ptw32_tkAssocDestroy.c
+++ b/libs/pthreads/src/ptw32_tkAssocDestroy.c
@@ -7,34 +7,38 @@
*
* --------------------------------------------------------------------------
*
- * Pthreads-win32 - POSIX Threads Library for Win32
+ * Pthreads4w - POSIX Threads Library for Win32
* Copyright(C) 1998 John E. Bossom
- * Copyright(C) 1999,2005 Pthreads-win32 contributors
- *
- * Contact Email: rpj@callisto.canberra.edu.au
- *
+ * Copyright(C) 1999-2018, Pthreads4w contributors
+ *
+ * Homepage: https://sourceforge.net/projects/pthreads4w/
+ *
* The current list of contributors is contained
* in the file CONTRIBUTORS included with the source
* code distribution. The list can also be seen at the
* following World Wide Web location:
- * http://sources.redhat.com/pthreads-win32/contributors.html
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library in the file COPYING.LIB;
- * if not, write to the Free Software Foundation, Inc.,
- * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
+ * https://sourceforge.net/p/pthreads4w/wiki/Contributors/
+ *
+ * This file is part of Pthreads4w.
+ *
+ * Pthreads4w is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * Pthreads4w is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Pthreads4w. If not, see <http://www.gnu.org/licenses/>. *
*/
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
#include "pthread.h"
#include "implement.h"
diff --git a/libs/pthreads/src/rwlock.c b/libs/pthreads/src/rwlock.c
deleted file mode 100644
index 4a3cd2594c..0000000000
--- a/libs/pthreads/src/rwlock.c
+++ /dev/null
@@ -1,51 +0,0 @@
-/*
- * rwlock.c
- *
- * Description:
- * This translation unit implements read/write lock primitives.
- *
- * --------------------------------------------------------------------------
- *
- * Pthreads-win32 - POSIX Threads Library for Win32
- * Copyright(C) 1998 John E. Bossom
- * Copyright(C) 1999,2005 Pthreads-win32 contributors
- *
- * Contact Email: rpj@callisto.canberra.edu.au
- *
- * The current list of contributors is contained
- * in the file CONTRIBUTORS included with the source
- * code distribution. The list can also be seen at the
- * following World Wide Web location:
- * http://sources.redhat.com/pthreads-win32/contributors.html
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library in the file COPYING.LIB;
- * if not, write to the Free Software Foundation, Inc.,
- * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
- */
-
-#include "ptw32_rwlock_check_need_init.c"
-#include "ptw32_rwlock_cancelwrwait.c"
-#include "pthread_rwlock_init.c"
-#include "pthread_rwlock_destroy.c"
-#include "pthread_rwlockattr_init.c"
-#include "pthread_rwlockattr_destroy.c"
-#include "pthread_rwlockattr_getpshared.c"
-#include "pthread_rwlockattr_setpshared.c"
-#include "pthread_rwlock_rdlock.c"
-#include "pthread_rwlock_timedrdlock.c"
-#include "pthread_rwlock_wrlock.c"
-#include "pthread_rwlock_timedwrlock.c"
-#include "pthread_rwlock_unlock.c"
-#include "pthread_rwlock_tryrdlock.c"
-#include "pthread_rwlock_trywrlock.c"
diff --git a/libs/pthreads/src/sched.c b/libs/pthreads/src/sched.c
deleted file mode 100644
index ed30ea7b24..0000000000
--- a/libs/pthreads/src/sched.c
+++ /dev/null
@@ -1,53 +0,0 @@
-/*
- * sched.c
- *
- * Description:
- * POSIX thread functions that deal with thread scheduling.
- *
- * --------------------------------------------------------------------------
- *
- * Pthreads-win32 - POSIX Threads Library for Win32
- * Copyright(C) 1998 John E. Bossom
- * Copyright(C) 1999,2005 Pthreads-win32 contributors
- *
- * Contact Email: rpj@callisto.canberra.edu.au
- *
- * The current list of contributors is contained
- * in the file CONTRIBUTORS included with the source
- * code distribution. The list can also be seen at the
- * following World Wide Web location:
- * http://sources.redhat.com/pthreads-win32/contributors.html
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library in the file COPYING.LIB;
- * if not, write to the Free Software Foundation, Inc.,
- * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
- */
-
-#include "pthread.h"
-#include "implement.h"
-#include "sched.h"
-
-#include "pthread_attr_setschedpolicy.c"
-#include "pthread_attr_getschedpolicy.c"
-#include "pthread_attr_setschedparam.c"
-#include "pthread_attr_getschedparam.c"
-#include "pthread_attr_setinheritsched.c"
-#include "pthread_attr_getinheritsched.c"
-#include "pthread_setschedparam.c"
-#include "pthread_getschedparam.c"
-#include "sched_get_priority_max.c"
-#include "sched_get_priority_min.c"
-#include "sched_setscheduler.c"
-#include "sched_getscheduler.c"
-#include "sched_yield.c"
diff --git a/libs/pthreads/src/sched.h b/libs/pthreads/src/sched.h
index f36a97a66b..34a93003d2 100644
--- a/libs/pthreads/src/sched.h
+++ b/libs/pthreads/src/sched.h
@@ -3,181 +3,235 @@
*
* Purpose:
* Provides an implementation of POSIX realtime extensions
- * as defined in
+ * as defined in
*
* POSIX 1003.1b-1993 (POSIX.1b)
*
* --------------------------------------------------------------------------
*
- * Pthreads-win32 - POSIX Threads Library for Win32
+ * Pthreads4w - POSIX Threads Library for Win32
* Copyright(C) 1998 John E. Bossom
- * Copyright(C) 1999,2005 Pthreads-win32 contributors
- *
- * Contact Email: rpj@callisto.canberra.edu.au
- *
+ * Copyright(C) 1999-2018, Pthreads4w contributors
+ *
+ * Homepage: https://sourceforge.net/projects/pthreads4w/
+ *
* The current list of contributors is contained
* in the file CONTRIBUTORS included with the source
* code distribution. The list can also be seen at the
* following World Wide Web location:
- * http://sources.redhat.com/pthreads-win32/contributors.html
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library in the file COPYING.LIB;
- * if not, write to the Free Software Foundation, Inc.,
- * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
+ * https://sourceforge.net/p/pthreads4w/wiki/Contributors/
+ *
+ * This file is part of Pthreads4w.
+ *
+ * Pthreads4w is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * Pthreads4w is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Pthreads4w. If not, see <http://www.gnu.org/licenses/>. *
*/
#if !defined(_SCHED_H)
#define _SCHED_H
+#define __SCHED_H_SOURCED__
-#undef PTW32_SCHED_LEVEL
-
-#if defined(_POSIX_SOURCE)
-#define PTW32_SCHED_LEVEL 0
-/* Early POSIX */
-#endif
+#include <_ptw32.h>
-#if defined(_POSIX_C_SOURCE) && _POSIX_C_SOURCE >= 199309
-#undef PTW32_SCHED_LEVEL
-#define PTW32_SCHED_LEVEL 1
-/* Include 1b, 1c and 1d */
-#endif
+/* We need a typedef for pid_t, (and POSIX requires <sched.h> to
+ * define it, as it is defined in <sys/types.h>, but it does NOT
+ * sanction exposure of everything from <sys/types.h>); there is
+ * no pid_t in Windows anyway, (except that MinGW does define it
+ * in their <sys/types.h>), so just provide a suitable typedef,
+ * but note that we must do so cautiously, to avoid a typedef
+ * conflict if MinGW's <sys/types.h> is also #included:
+ */
+#if ! defined __MINGW32__ || ! defined __have_typedef_pid_t
-#if defined(INCLUDE_NP)
-#undef PTW32_SCHED_LEVEL
-#define PTW32_SCHED_LEVEL 2
-/* Include Non-Portable extensions */
+# if defined __MINGW64__
+ typedef __int64 pid_t;
+# else
+ typedef int pid_t;
#endif
-#define PTW32_SCHED_LEVEL_MAX 3
-
-#if ( defined(_POSIX_C_SOURCE) && _POSIX_C_SOURCE >= 200112 ) || !defined(PTW32_SCHED_LEVEL)
-#define PTW32_SCHED_LEVEL PTW32_SCHED_LEVEL_MAX
-/* Include everything */
+#if __GNUC__ < 4
+/* GCC v4.0 and later, (as used by MinGW), allows us to repeat a
+ * typedef, provided every duplicate is consistent; only set this
+ * multiple definition guard when we cannot be certain that it is
+ * permissable to repeat typedefs.
+ */
+#define __have_typedef_pid_t 1
#endif
-
-
-#if defined(__GNUC__) && !defined(__declspec)
-# error Please upgrade your GNU compiler to one that supports __declspec.
#endif
-/*
- * When building the library, you should define PTW32_BUILD so that
- * the variables/functions are exported correctly. When using the library,
- * do NOT define PTW32_BUILD, and then the variables/functions will
- * be imported correctly.
+/* POSIX.1-1993 says that <sched.h> WILL expose all of <time.h>
*/
-#if !defined(PTW32_STATIC_LIB)
-# if defined(PTW32_BUILD)
-# define PTW32_DLLPORT __declspec (dllexport)
-# else
-# define PTW32_DLLPORT __declspec (dllimport)
-# endif
-#else
-# define PTW32_DLLPORT
+#undef __SCHED_H_SOURCED__
+#if _POSIX_C_SOURCE >= 200112L
+/* POSIX.1-2001 and later revises this to say only that it MAY do so;
+ * only struct timespec, and associated time_t are actually required,
+ * so prefer to be selective; (MinGW.org's <time.h> offers an option
+ * for selective #inclusion, when __SCHED_H_SOURCED__ is defined):
+ */
+#define __SCHED_H_SOURCED__
+#define __need_struct_timespec
+#define __need_time_t
#endif
-
-/*
- * This is a duplicate of what is in the autoconf config.h,
- * which is only used when building the pthread-win32 libraries.
+#include <time.h>
+
+#if defined __MINGW64__ || _MSC_VER >= 1900
+/* These are known to define struct timespec, when <time.h> has been
+ * #included, but may not, (probably don't), follow the convention of
+ * defining __struct_timespec_defined, as adopted by MinGW.org; for
+ * these cases, we unconditionally assume that struct timespec has
+ * been defined, otherwise, if MinGW.org's criterion has not been
+ * satisfied...
*/
-
-#if !defined(PTW32_CONFIG_H)
-# if defined(WINCE)
-# define NEED_ERRNO
-# define NEED_SEM
-# endif
-# if defined(__MINGW64__)
-# define HAVE_STRUCT_TIMESPEC
-# define HAVE_MODE_T
-# elif defined(_UWIN) || defined(__MINGW32__)
-# define HAVE_MODE_T
+#elif ! defined __struct_timespec_defined
+# ifndef _TIMESPEC_DEFINED
+# define _TIMESPEC_DEFINED
+struct timespec
+{ /* ...we fall back on this explicit definition.
+ */
+ time_t tv_sec;
+ int tv_nsec;
+};
# endif
#endif
/*
- *
+ * Microsoft VC++6.0 lacks these *_PTR types
*/
-
-#if PTW32_SCHED_LEVEL >= PTW32_SCHED_LEVEL_MAX
-#if defined(NEED_ERRNO)
-#include "need_errno.h"
-#else
-#include <errno.h>
-#endif
-#endif /* PTW32_SCHED_LEVEL >= PTW32_SCHED_LEVEL_MAX */
-
-#if (defined(__MINGW64__) || defined(__MINGW32__)) || defined(_UWIN)
-# if PTW32_SCHED_LEVEL >= PTW32_SCHED_LEVEL_MAX
-/* For pid_t */
-# include <sys/types.h>
-/* Required by Unix 98 */
-# include <time.h>
-# else
- typedef int pid_t;
-# endif
-#else
- typedef int pid_t;
+#if defined(_MSC_VER) && _MSC_VER < 1300 && !defined(PTW32_HAVE_DWORD_PTR)
+typedef unsigned long ULONG_PTR;
+typedef ULONG_PTR DWORD_PTR;
#endif
/* Thread scheduling policies */
-enum {
- SCHED_OTHER = 0,
+enum
+{ SCHED_OTHER = 0,
SCHED_FIFO,
SCHED_RR,
SCHED_MIN = SCHED_OTHER,
SCHED_MAX = SCHED_RR
};
-struct sched_param {
- int sched_priority;
+struct sched_param
+{ int sched_priority;
};
-#if defined(__cplusplus)
-extern "C"
-{
-#endif /* __cplusplus */
+/*
+ * CPU affinity
+ *
+ * cpu_set_t:
+ * Considered opaque but cannot be an opaque pointer due to the need for
+ * compatibility with GNU systems and sched_setaffinity() et.al., which
+ * include the cpusetsize parameter "normally set to sizeof(cpu_set_t)".
+ *
+ * FIXME: These are GNU, and NOT specified by POSIX; maybe consider
+ * occluding them within a _GNU_SOURCE (or similar) feature test.
+ */
+
+#define CPU_SETSIZE (sizeof(size_t)*8)
+
+#define CPU_COUNT(setptr) (_sched_affinitycpucount(setptr))
+
+#define CPU_ZERO(setptr) (_sched_affinitycpuzero(setptr))
+
+#define CPU_SET(cpu, setptr) (_sched_affinitycpuset((cpu),(setptr)))
+
+#define CPU_CLR(cpu, setptr) (_sched_affinitycpuclr((cpu),(setptr)))
+
+#define CPU_ISSET(cpu, setptr) (_sched_affinitycpuisset((cpu),(setptr)))
+
+#define CPU_AND(destsetptr, srcset1ptr, srcset2ptr) (_sched_affinitycpuand((destsetptr),(srcset1ptr),(srcset2ptr)))
+
+#define CPU_OR(destsetptr, srcset1ptr, srcset2ptr) (_sched_affinitycpuor((destsetptr),(srcset1ptr),(srcset2ptr)))
-PTW32_DLLPORT int __cdecl sched_yield (void);
+#define CPU_XOR(destsetptr, srcset1ptr, srcset2ptr) \
+ (_sched_affinitycpuxor((destsetptr),(srcset1ptr),(srcset2ptr)))
-PTW32_DLLPORT int __cdecl sched_get_priority_min (int policy);
+#define CPU_EQUAL(set1ptr, set2ptr) (_sched_affinitycpuequal((set1ptr),(set2ptr)))
-PTW32_DLLPORT int __cdecl sched_get_priority_max (int policy);
+typedef union
+{ char cpuset[CPU_SETSIZE/8];
+ size_t _align;
+} cpu_set_t;
-PTW32_DLLPORT int __cdecl sched_setscheduler (pid_t pid, int policy);
+__PTW32_BEGIN_C_DECLS
-PTW32_DLLPORT int __cdecl sched_getscheduler (pid_t pid);
+PTW32_DLLPORT int PTW32_CDECL sched_yield (void);
+
+PTW32_DLLPORT int PTW32_CDECL sched_get_priority_min (int policy);
+
+PTW32_DLLPORT int PTW32_CDECL sched_get_priority_max (int policy);
+
+/* FIXME: this declaration of sched_setscheduler() is NOT as prescribed
+ * by POSIX; it lacks const struct sched_param * as third argument.
+ */
+PTW32_DLLPORT int PTW32_CDECL sched_setscheduler (pid_t pid, int policy);
+
+/* FIXME: In addition to the above five functions, POSIX also requires:
+ *
+ * int sched_getparam (pid_t, struct sched_param *);
+ * int sched_setparam (pid_t, const struct sched_param *);
+ *
+ * both of which are conspicuous by their absence here!
+ */
+
+/* Compatibility with Linux - not standard in POSIX
+ * FIXME: consider occluding within a _GNU_SOURCE (or similar) feature test.
+ */
+PTW32_DLLPORT int PTW32_CDECL sched_setaffinity (pid_t pid, size_t cpusetsize, cpu_set_t *mask);
+
+PTW32_DLLPORT int PTW32_CDECL sched_getaffinity (pid_t pid, size_t cpusetsize, cpu_set_t *mask);
/*
- * Note that this macro returns ENOTSUP rather than
- * ENOSYS as might be expected. However, returning ENOSYS
- * should mean that sched_get_priority_{min,max} are
- * not implemented as well as sched_rr_get_interval.
- * This is not the case, since we just don't support
- * round-robin scheduling. Therefore I have chosen to
- * return the same value as sched_setscheduler when
- * SCHED_RR is passed to it.
+ * Support routines and macros for cpu_set_t
*/
-#define sched_rr_get_interval(_pid, _interval) \
- ( errno = ENOTSUP, (int) -1 )
+PTW32_DLLPORT int PTW32_CDECL _sched_affinitycpucount (const cpu_set_t *set);
+
+PTW32_DLLPORT void PTW32_CDECL _sched_affinitycpuzero (cpu_set_t *pset);
+
+PTW32_DLLPORT void PTW32_CDECL _sched_affinitycpuset (int cpu, cpu_set_t *pset);
+
+PTW32_DLLPORT void PTW32_CDECL _sched_affinitycpuclr (int cpu, cpu_set_t *pset);
+PTW32_DLLPORT int PTW32_CDECL _sched_affinitycpuisset (int cpu, const cpu_set_t *pset);
-#if defined(__cplusplus)
-} /* End of extern "C" */
-#endif /* __cplusplus */
+PTW32_DLLPORT void PTW32_CDECL _sched_affinitycpuand(cpu_set_t *pdestset, const cpu_set_t *psrcset1, const cpu_set_t *psrcset2);
-#undef PTW32_SCHED_LEVEL
-#undef PTW32_SCHED_LEVEL_MAX
+PTW32_DLLPORT void PTW32_CDECL _sched_affinitycpuor(cpu_set_t *pdestset, const cpu_set_t *psrcset1, const cpu_set_t *psrcset2);
+
+PTW32_DLLPORT void PTW32_CDECL _sched_affinitycpuxor(cpu_set_t *pdestset, const cpu_set_t *psrcset1, const cpu_set_t *psrcset2);
+
+PTW32_DLLPORT int PTW32_CDECL _sched_affinitycpuequal (const cpu_set_t *pset1, const cpu_set_t *pset2);
+
+/* Note that this macro returns ENOTSUP rather than ENOSYS, as
+ * might be expected. However, returning ENOSYS should mean that
+ * sched_get_priority_{min,max} are not implemented as well as
+ * sched_rr_get_interval. This is not the case, since we just
+ * don't support round-robin scheduling. Therefore I have chosen
+ * to return the same value as sched_setscheduler when SCHED_RR
+ * is passed to it.
+ *
+ * FIXME: POSIX requires this to be defined as a function; this
+ * macro implementation is permitted IN ADDITION to the function,
+ * but the macro alone is not POSIX compliant! Worse still, it
+ * imposes a requirement on the caller, to ensure that both the
+ * declaration of errno, and the definition of ENOTSUP, are in
+ * scope at point of call, (which it may wish to do anyway, but
+ * POSIX imposes no such constraint)!
+ */
+#define sched_rr_get_interval(_pid, _interval) \
+ ( errno = ENOTSUP, (int) -1 )
-#endif /* !_SCHED_H */
+__PTW32_END_C_DECLS
+#undef __SCHED_H_SOURCED__
+#endif /* !_SCHED_H */
diff --git a/libs/pthreads/src/sched_get_priority_max.c b/libs/pthreads/src/sched_get_priority_max.c
index cabf2320a7..b74f101f73 100644
--- a/libs/pthreads/src/sched_get_priority_max.c
+++ b/libs/pthreads/src/sched_get_priority_max.c
@@ -6,34 +6,38 @@
*
* --------------------------------------------------------------------------
*
- * Pthreads-win32 - POSIX Threads Library for Win32
+ * Pthreads4w - POSIX Threads Library for Win32
* Copyright(C) 1998 John E. Bossom
- * Copyright(C) 1999,2005 Pthreads-win32 contributors
- *
- * Contact Email: rpj@callisto.canberra.edu.au
- *
+ * Copyright(C) 1999-2018, Pthreads4w contributors
+ *
+ * Homepage: https://sourceforge.net/projects/pthreads4w/
+ *
* The current list of contributors is contained
* in the file CONTRIBUTORS included with the source
* code distribution. The list can also be seen at the
* following World Wide Web location:
- * http://sources.redhat.com/pthreads-win32/contributors.html
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library in the file COPYING.LIB;
- * if not, write to the Free Software Foundation, Inc.,
- * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
+ * https://sourceforge.net/p/pthreads4w/wiki/Contributors/
+ *
+ * This file is part of Pthreads4w.
+ *
+ * Pthreads4w is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * Pthreads4w is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Pthreads4w. If not, see <http://www.gnu.org/licenses/>. *
*/
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
#include "pthread.h"
#include "implement.h"
#include "sched.h"
@@ -120,7 +124,7 @@ sched_get_priority_max (int policy)
{
if (policy < SCHED_MIN || policy > SCHED_MAX)
{
- errno = EINVAL;
+ PTW32_SET_ERRNO(EINVAL);
return -1;
}
diff --git a/libs/pthreads/src/sched_get_priority_min.c b/libs/pthreads/src/sched_get_priority_min.c
index 9c4f8591e5..b9f30684ab 100644
--- a/libs/pthreads/src/sched_get_priority_min.c
+++ b/libs/pthreads/src/sched_get_priority_min.c
@@ -6,34 +6,38 @@
*
* --------------------------------------------------------------------------
*
- * Pthreads-win32 - POSIX Threads Library for Win32
+ * Pthreads4w - POSIX Threads Library for Win32
* Copyright(C) 1998 John E. Bossom
- * Copyright(C) 1999,2005 Pthreads-win32 contributors
- *
- * Contact Email: rpj@callisto.canberra.edu.au
- *
+ * Copyright(C) 1999-2018, Pthreads4w contributors
+ *
+ * Homepage: https://sourceforge.net/projects/pthreads4w/
+ *
* The current list of contributors is contained
* in the file CONTRIBUTORS included with the source
* code distribution. The list can also be seen at the
* following World Wide Web location:
- * http://sources.redhat.com/pthreads-win32/contributors.html
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library in the file COPYING.LIB;
- * if not, write to the Free Software Foundation, Inc.,
- * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
+ * https://sourceforge.net/p/pthreads4w/wiki/Contributors/
+ *
+ * This file is part of Pthreads4w.
+ *
+ * Pthreads4w is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * Pthreads4w is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Pthreads4w. If not, see <http://www.gnu.org/licenses/>. *
*/
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
#include "pthread.h"
#include "implement.h"
#include "sched.h"
@@ -121,7 +125,7 @@ sched_get_priority_min (int policy)
{
if (policy < SCHED_MIN || policy > SCHED_MAX)
{
- errno = EINVAL;
+ PTW32_SET_ERRNO(EINVAL);
return -1;
}
diff --git a/libs/pthreads/src/sched_getscheduler.c b/libs/pthreads/src/sched_getscheduler.c
index 8769c15e5a..5fd951aadc 100644
--- a/libs/pthreads/src/sched_getscheduler.c
+++ b/libs/pthreads/src/sched_getscheduler.c
@@ -6,34 +6,38 @@
*
* --------------------------------------------------------------------------
*
- * Pthreads-win32 - POSIX Threads Library for Win32
+ * Pthreads4w - POSIX Threads Library for Win32
* Copyright(C) 1998 John E. Bossom
- * Copyright(C) 1999,2005 Pthreads-win32 contributors
- *
- * Contact Email: rpj@callisto.canberra.edu.au
- *
+ * Copyright(C) 1999-2018, Pthreads4w contributors
+ *
+ * Homepage: https://sourceforge.net/projects/pthreads4w/
+ *
* The current list of contributors is contained
* in the file CONTRIBUTORS included with the source
* code distribution. The list can also be seen at the
* following World Wide Web location:
- * http://sources.redhat.com/pthreads-win32/contributors.html
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library in the file COPYING.LIB;
- * if not, write to the Free Software Foundation, Inc.,
- * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
+ * https://sourceforge.net/p/pthreads4w/wiki/Contributors/
+ *
+ * This file is part of Pthreads4w.
+ *
+ * Pthreads4w is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * Pthreads4w is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Pthreads4w. If not, see <http://www.gnu.org/licenses/>. *
*/
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
#include "pthread.h"
#include "implement.h"
#include "sched.h"
@@ -57,9 +61,7 @@ sched_getscheduler (pid_t pid)
if (NULL == h)
{
- errno =
- (GetLastError () ==
- (0xFF & ERROR_ACCESS_DENIED)) ? EPERM : ESRCH;
+ PTW32_SET_ERRNO(((0xFF & ERROR_ACCESS_DENIED) == GetLastError()) ? EPERM : ESRCH);
return -1;
}
else
diff --git a/libs/pthreads/src/sched_setaffinity.c b/libs/pthreads/src/sched_setaffinity.c
new file mode 100644
index 0000000000..de44fd4461
--- /dev/null
+++ b/libs/pthreads/src/sched_setaffinity.c
@@ -0,0 +1,351 @@
+/*
+ * sched_setaffinity.c
+ *
+ * Description:
+ * POSIX scheduling functions that deal with CPU affinity.
+ *
+ * --------------------------------------------------------------------------
+ *
+ * Pthreads4w - POSIX Threads Library for Win32
+ * Copyright(C) 1998 John E. Bossom
+ * Copyright(C) 1999-2018, Pthreads4w contributors
+ *
+ * Homepage: https://sourceforge.net/projects/pthreads4w/
+ *
+ * The current list of contributors is contained
+ * in the file CONTRIBUTORS included with the source
+ * code distribution. The list can also be seen at the
+ * following World Wide Web location:
+ * https://sourceforge.net/p/pthreads4w/wiki/Contributors/
+ *
+ * This file is part of Pthreads4w.
+ *
+ * Pthreads4w is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * Pthreads4w is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Pthreads4w. If not, see <http://www.gnu.org/licenses/>. *
+ */
+
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
+#include "pthread.h"
+#include "implement.h"
+#include "sched.h"
+
+int
+sched_setaffinity (pid_t pid, size_t cpusetsize, cpu_set_t *set)
+ /*
+ * ------------------------------------------------------
+ * DOCPUBLIC
+ * Sets the CPU affinity mask of the process whose ID is pid
+ * to the value specified by mask. If pid is zero, then the
+ * calling process is used. The argument cpusetsize is the
+ * length (in bytes) of the data pointed to by mask. Normally
+ * this argument would be specified as sizeof(cpu_set_t).
+ *
+ * If the process specified by pid is not currently running on
+ * one of the CPUs specified in mask, then that process is
+ * migrated to one of the CPUs specified in mask.
+ *
+ * PARAMETERS
+ * pid
+ * Process ID
+ *
+ * cpusetsize
+ * Currently ignored in pthreads4w.
+ * Usually set to sizeof(cpu_set_t)
+ *
+ * mask
+ * Pointer to the CPU mask to set (cpu_set_t).
+ *
+ * DESCRIPTION
+ * Sets the CPU affinity mask of the process whose ID is pid
+ * to the value specified by mask. If pid is zero, then the
+ * calling process is used. The argument cpusetsize is the
+ * length (in bytes) of the data pointed to by mask. Normally
+ * this argument would be specified as sizeof(cpu_set_t).
+ *
+ * If the process specified by pid is not currently running on
+ * one of the CPUs specified in mask, then that process is
+ * migrated to one of the CPUs specified in mask.
+ *
+ * RESULTS
+ * 0 successfully created semaphore,
+ * EFAULT 'mask' is a NULL pointer.
+ * EINVAL '*mask' contains no CPUs in the set
+ * of available CPUs.
+ * EAGAIN The system available CPUs could not
+ * be obtained.
+ * EPERM The process referred to by 'pid' is
+ * not modifiable by us.
+ * ESRCH The process referred to by 'pid' was
+ * not found.
+ * ENOSYS Function not supported.
+ *
+ * ------------------------------------------------------
+ */
+{
+#if ! defined(NEED_PROCESS_AFFINITY_MASK)
+
+ DWORD_PTR vProcessMask;
+ DWORD_PTR vSystemMask;
+ HANDLE h;
+ int targetPid = (int)(size_t) pid;
+ int result = 0;
+
+ if (NULL == set)
+ {
+ result = EFAULT;
+ }
+ else
+ {
+ if (0 == targetPid)
+ {
+ targetPid = (int) GetCurrentProcessId ();
+ }
+
+ h = OpenProcess (PROCESS_QUERY_INFORMATION|PROCESS_SET_INFORMATION, PTW32_FALSE, (DWORD) targetPid);
+
+ if (NULL == h)
+ {
+ result = (((0xFF & ERROR_ACCESS_DENIED) == GetLastError()) ? EPERM : ESRCH);
+ }
+ else
+ {
+ if (GetProcessAffinityMask (h, &vProcessMask, &vSystemMask))
+ {
+ /*
+ * Result is the intersection of available CPUs and the mask.
+ */
+ DWORD_PTR newMask = vSystemMask & ((_sched_cpu_set_vector_*)set)->_cpuset;
+
+ if (newMask)
+ {
+ if (SetProcessAffinityMask(h, newMask) == 0)
+ {
+ switch (GetLastError())
+ {
+ case (0xFF & ERROR_ACCESS_DENIED):
+ result = EPERM;
+ break;
+ case (0xFF & ERROR_INVALID_PARAMETER):
+ result = EINVAL;
+ break;
+ default:
+ result = EAGAIN;
+ break;
+ }
+ }
+ }
+ else
+ {
+ /*
+ * Mask does not contain any CPUs currently available on the system.
+ */
+ result = EINVAL;
+ }
+ }
+ else
+ {
+ result = EAGAIN;
+ }
+ }
+ CloseHandle(h);
+ }
+
+ if (result != 0)
+ {
+ PTW32_SET_ERRNO(result);
+ return -1;
+ }
+ else
+ {
+ return 0;
+ }
+
+#else
+
+ PTW32_SET_ERRNO(ENOSYS);
+ return -1;
+
+#endif
+}
+
+
+int
+sched_getaffinity (pid_t pid, size_t cpusetsize, cpu_set_t *set)
+ /*
+ * ------------------------------------------------------
+ * DOCPUBLIC
+ * Gets the CPU affinity mask of the process whose ID is pid
+ * to the value specified by mask. If pid is zero, then the
+ * calling process is used. The argument cpusetsize is the
+ * length (in bytes) of the data pointed to by mask. Normally
+ * this argument would be specified as sizeof(cpu_set_t).
+ *
+ * PARAMETERS
+ * pid
+ * Process ID
+ *
+ * cpusetsize
+ * Currently ignored in pthreads4w.
+ * Usually set to sizeof(cpu_set_t)
+ *
+ * mask
+ * Pointer to the CPU mask to set (cpu_set_t).
+ *
+ * DESCRIPTION
+ * Sets the CPU affinity mask of the process whose ID is pid
+ * to the value specified by mask. If pid is zero, then the
+ * calling process is used. The argument cpusetsize is the
+ * length (in bytes) of the data pointed to by mask. Normally
+ * this argument would be specified as sizeof(cpu_set_t).
+ *
+ * RESULTS
+ * 0 successfully created semaphore,
+ * EFAULT 'mask' is a NULL pointer.
+ * EAGAIN The system available CPUs could not
+ * be obtained.
+ * EPERM The process referred to by 'pid' is
+ * not modifiable by us.
+ * ESRCH The process referred to by 'pid' was
+ * not found.
+ *
+ * ------------------------------------------------------
+ */
+{
+ DWORD_PTR vProcessMask;
+ DWORD_PTR vSystemMask;
+ HANDLE h;
+ int targetPid = (int)(size_t) pid;
+ int result = 0;
+
+ if (NULL == set)
+ {
+ result = EFAULT;
+ }
+ else
+ {
+
+#if ! defined(NEED_PROCESS_AFFINITY_MASK)
+
+ if (0 == targetPid)
+ {
+ targetPid = (int) GetCurrentProcessId ();
+ }
+
+ h = OpenProcess (PROCESS_QUERY_INFORMATION, PTW32_FALSE, (DWORD) targetPid);
+
+ if (NULL == h)
+ {
+ result = (((0xFF & ERROR_ACCESS_DENIED) == GetLastError()) ? EPERM : ESRCH);
+ }
+ else
+ {
+ if (GetProcessAffinityMask (h, &vProcessMask, &vSystemMask))
+ {
+ ((_sched_cpu_set_vector_*)set)->_cpuset = vProcessMask;
+ }
+ else
+ {
+ result = EAGAIN;
+ }
+ }
+ CloseHandle(h);
+
+#else
+ ((_sched_cpu_set_vector_*)set)->_cpuset = (size_t)0x1;
+#endif
+
+ }
+
+ if (result != 0)
+ {
+ PTW32_SET_ERRNO(result);
+ return -1;
+ }
+ else
+ {
+ return 0;
+ }
+}
+
+/*
+ * Support routines for cpu_set_t
+ */
+int _sched_affinitycpucount (const cpu_set_t *set)
+{
+ size_t tset;
+ int count;
+
+ /*
+ * Relies on tset being unsigned, otherwise the right-shift will
+ * be arithmetic rather than logical and the 'for' will loop forever.
+ */
+ for (count = 0, tset = ((_sched_cpu_set_vector_*)set)->_cpuset; tset; tset >>= 1)
+ {
+ if (tset & (size_t)1)
+ {
+ count++;
+ }
+ }
+ return count;
+}
+
+void _sched_affinitycpuzero (cpu_set_t *pset)
+{
+ ((_sched_cpu_set_vector_*)pset)->_cpuset = (size_t)0;
+}
+
+void _sched_affinitycpuset (int cpu, cpu_set_t *pset)
+{
+ ((_sched_cpu_set_vector_*)pset)->_cpuset |= ((size_t)1 << cpu);
+}
+
+void _sched_affinitycpuclr (int cpu, cpu_set_t *pset)
+{
+ ((_sched_cpu_set_vector_*)pset)->_cpuset &= ~((size_t)1 << cpu);
+}
+
+int _sched_affinitycpuisset (int cpu, const cpu_set_t *pset)
+{
+ return ((((_sched_cpu_set_vector_*)pset)->_cpuset &
+ ((size_t)1 << cpu)) != (size_t)0);
+}
+
+void _sched_affinitycpuand(cpu_set_t *pdestset, const cpu_set_t *psrcset1, const cpu_set_t *psrcset2)
+{
+ ((_sched_cpu_set_vector_*)pdestset)->_cpuset =
+ (((_sched_cpu_set_vector_*)psrcset1)->_cpuset &
+ ((_sched_cpu_set_vector_*)psrcset2)->_cpuset);
+}
+
+void _sched_affinitycpuor(cpu_set_t *pdestset, const cpu_set_t *psrcset1, const cpu_set_t *psrcset2)
+{
+ ((_sched_cpu_set_vector_*)pdestset)->_cpuset =
+ (((_sched_cpu_set_vector_*)psrcset1)->_cpuset |
+ ((_sched_cpu_set_vector_*)psrcset2)->_cpuset);
+}
+
+void _sched_affinitycpuxor(cpu_set_t *pdestset, const cpu_set_t *psrcset1, const cpu_set_t *psrcset2)
+{
+ ((_sched_cpu_set_vector_*)pdestset)->_cpuset =
+ (((_sched_cpu_set_vector_*)psrcset1)->_cpuset ^
+ ((_sched_cpu_set_vector_*)psrcset2)->_cpuset);
+}
+
+int _sched_affinitycpuequal (const cpu_set_t *pset1, const cpu_set_t *pset2)
+{
+ return (((_sched_cpu_set_vector_*)pset1)->_cpuset ==
+ ((_sched_cpu_set_vector_*)pset2)->_cpuset);
+}
diff --git a/libs/pthreads/src/sched_setscheduler.c b/libs/pthreads/src/sched_setscheduler.c
index 8691316371..77d82ce617 100644
--- a/libs/pthreads/src/sched_setscheduler.c
+++ b/libs/pthreads/src/sched_setscheduler.c
@@ -6,34 +6,38 @@
*
* --------------------------------------------------------------------------
*
- * Pthreads-win32 - POSIX Threads Library for Win32
+ * Pthreads4w - POSIX Threads Library for Win32
* Copyright(C) 1998 John E. Bossom
- * Copyright(C) 1999,2005 Pthreads-win32 contributors
- *
- * Contact Email: rpj@callisto.canberra.edu.au
- *
+ * Copyright(C) 1999-2018, Pthreads4w contributors
+ *
+ * Homepage: https://sourceforge.net/projects/pthreads4w/
+ *
* The current list of contributors is contained
* in the file CONTRIBUTORS included with the source
* code distribution. The list can also be seen at the
* following World Wide Web location:
- * http://sources.redhat.com/pthreads-win32/contributors.html
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library in the file COPYING.LIB;
- * if not, write to the Free Software Foundation, Inc.,
- * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
+ * https://sourceforge.net/p/pthreads4w/wiki/Contributors/
+ *
+ * This file is part of Pthreads4w.
+ *
+ * Pthreads4w is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * Pthreads4w is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Pthreads4w. If not, see <http://www.gnu.org/licenses/>. *
*/
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
#include "pthread.h"
#include "implement.h"
#include "sched.h"
@@ -59,9 +63,7 @@ sched_setscheduler (pid_t pid, int policy)
if (NULL == h)
{
- errno =
- (GetLastError () ==
- (0xFF & ERROR_ACCESS_DENIED)) ? EPERM : ESRCH;
+ PTW32_SET_ERRNO((GetLastError () == (0xFF & ERROR_ACCESS_DENIED)) ? EPERM : ESRCH);
return -1;
}
else
@@ -71,7 +73,7 @@ sched_setscheduler (pid_t pid, int policy)
if (SCHED_OTHER != policy)
{
- errno = ENOSYS;
+ PTW32_SET_ERRNO(ENOSYS);
return -1;
}
diff --git a/libs/pthreads/src/sched_yield.c b/libs/pthreads/src/sched_yield.c
index 6ac5ed9263..17947884e6 100644
--- a/libs/pthreads/src/sched_yield.c
+++ b/libs/pthreads/src/sched_yield.c
@@ -6,34 +6,38 @@
*
* --------------------------------------------------------------------------
*
- * Pthreads-win32 - POSIX Threads Library for Win32
+ * Pthreads4w - POSIX Threads Library for Win32
* Copyright(C) 1998 John E. Bossom
- * Copyright(C) 1999,2005 Pthreads-win32 contributors
- *
- * Contact Email: rpj@callisto.canberra.edu.au
- *
+ * Copyright(C) 1999-2018, Pthreads4w contributors
+ *
+ * Homepage: https://sourceforge.net/projects/pthreads4w/
+ *
* The current list of contributors is contained
* in the file CONTRIBUTORS included with the source
* code distribution. The list can also be seen at the
* following World Wide Web location:
- * http://sources.redhat.com/pthreads-win32/contributors.html
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library in the file COPYING.LIB;
- * if not, write to the Free Software Foundation, Inc.,
- * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
+ * https://sourceforge.net/p/pthreads4w/wiki/Contributors/
+ *
+ * This file is part of Pthreads4w.
+ *
+ * Pthreads4w is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * Pthreads4w is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Pthreads4w. If not, see <http://www.gnu.org/licenses/>. *
*/
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
#include "pthread.h"
#include "implement.h"
#include "sched.h"
diff --git a/libs/pthreads/src/sem_close.c b/libs/pthreads/src/sem_close.c
index 6d7280f299..108d35153a 100644
--- a/libs/pthreads/src/sem_close.c
+++ b/libs/pthreads/src/sem_close.c
@@ -13,34 +13,38 @@
*
* --------------------------------------------------------------------------
*
- * Pthreads-win32 - POSIX Threads Library for Win32
+ * Pthreads4w - POSIX Threads Library for Win32
* Copyright(C) 1998 John E. Bossom
- * Copyright(C) 1999,2005 Pthreads-win32 contributors
- *
- * Contact Email: rpj@callisto.canberra.edu.au
- *
+ * Copyright(C) 1999-2018, Pthreads4w contributors
+ *
+ * Homepage: https://sourceforge.net/projects/pthreads4w/
+ *
* The current list of contributors is contained
* in the file CONTRIBUTORS included with the source
* code distribution. The list can also be seen at the
* following World Wide Web location:
- * http://sources.redhat.com/pthreads-win32/contributors.html
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library in the file COPYING.LIB;
- * if not, write to the Free Software Foundation, Inc.,
- * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
+ * https://sourceforge.net/p/pthreads4w/wiki/Contributors/
+ *
+ * This file is part of Pthreads4w.
+ *
+ * Pthreads4w is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * Pthreads4w is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Pthreads4w. If not, see <http://www.gnu.org/licenses/>. *
*/
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
#include "pthread.h"
#include "semaphore.h"
#include "implement.h"
@@ -53,6 +57,6 @@
int
sem_close (sem_t * sem)
{
- errno = ENOSYS;
+ PTW32_SET_ERRNO(ENOSYS);
return -1;
} /* sem_close */
diff --git a/libs/pthreads/src/sem_destroy.c b/libs/pthreads/src/sem_destroy.c
index 6c98e80b93..d7b74e0c88 100644
--- a/libs/pthreads/src/sem_destroy.c
+++ b/libs/pthreads/src/sem_destroy.c
@@ -13,34 +13,38 @@
*
* --------------------------------------------------------------------------
*
- * Pthreads-win32 - POSIX Threads Library for Win32
+ * Pthreads4w - POSIX Threads Library for Win32
* Copyright(C) 1998 John E. Bossom
- * Copyright(C) 1999,2005 Pthreads-win32 contributors
- *
- * Contact Email: rpj@callisto.canberra.edu.au
- *
+ * Copyright(C) 1999-2018, Pthreads4w contributors
+ *
+ * Homepage: https://sourceforge.net/projects/pthreads4w/
+ *
* The current list of contributors is contained
* in the file CONTRIBUTORS included with the source
* code distribution. The list can also be seen at the
* following World Wide Web location:
- * http://sources.redhat.com/pthreads-win32/contributors.html
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library in the file COPYING.LIB;
- * if not, write to the Free Software Foundation, Inc.,
- * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
+ * https://sourceforge.net/p/pthreads4w/wiki/Contributors/
+ *
+ * This file is part of Pthreads4w.
+ *
+ * Pthreads4w is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * Pthreads4w is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Pthreads4w. If not, see <http://www.gnu.org/licenses/>. *
*/
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
#include "pthread.h"
#include "semaphore.h"
#include "implement.h"
@@ -48,29 +52,29 @@
int
sem_destroy (sem_t * sem)
- /*
- * ------------------------------------------------------
- * DOCPUBLIC
- * This function destroys an unnamed semaphore.
- *
- * PARAMETERS
- * sem
- * pointer to an instance of sem_t
- *
- * DESCRIPTION
- * This function destroys an unnamed semaphore.
- *
- * RESULTS
- * 0 successfully destroyed semaphore,
- * -1 failed, error in errno
- * ERRNO
- * EINVAL 'sem' is not a valid semaphore,
- * ENOSYS semaphores are not supported,
- * EBUSY threads (or processes) are currently
- * blocked on 'sem'
- *
- * ------------------------------------------------------
- */
+/*
+ * ------------------------------------------------------
+ * DOCPUBLIC
+ * This function destroys an unnamed semaphore.
+ *
+ * PARAMETERS
+ * sem
+ * pointer to an instance of sem_t
+ *
+ * DESCRIPTION
+ * This function destroys an unnamed semaphore.
+ *
+ * RESULTS
+ * 0 successfully destroyed semaphore,
+ * -1 failed, error in errno
+ * ERRNO
+ * EINVAL 'sem' is not a valid semaphore,
+ * ENOSYS semaphores are not supported,
+ * EBUSY threads (or processes) are currently
+ * blocked on 'sem'
+ *
+ * ------------------------------------------------------
+ */
{
int result = 0;
sem_t s = NULL;
@@ -81,59 +85,34 @@ sem_destroy (sem_t * sem)
}
else
{
+ ptw32_mcs_local_node_t node;
s = *sem;
- if ((result = pthread_mutex_lock (&s->lock)) == 0)
+ if ((result = ptw32_mcs_lock_try_acquire(&s->lock, &node)) == 0)
{
if (s->value < 0)
{
- (void) pthread_mutex_unlock (&s->lock);
result = EBUSY;
}
else
{
- /* There are no threads currently blocked on this semaphore. */
-
+ /*
+ * There are no threads currently blocked on this semaphore
+ * however there could be threads about to wait behind us.
+ * It is up to the application to ensure this is not the case.
+ */
if (!CloseHandle (s->sem))
- {
- (void) pthread_mutex_unlock (&s->lock);
- result = EINVAL;
- }
- else
- {
- /*
- * Invalidate the semaphore handle when we have the lock.
- * Other sema operations should test this after acquiring the lock
- * to check that the sema is still valid, i.e. before performing any
- * operations. This may only be necessary before the sema op routine
- * returns so that the routine can return EINVAL - e.g. if setting
- * s->value to SEM_VALUE_MAX below does force a fall-through.
- */
- *sem = NULL;
-
- /* Prevent anyone else actually waiting on or posting this sema.
- */
- s->value = SEM_VALUE_MAX;
-
- (void) pthread_mutex_unlock (&s->lock);
-
- do
- {
- /* Give other threads a chance to run and exit any sema op
- * routines. Due to the SEM_VALUE_MAX value, if sem_post or
- * sem_wait were blocked by us they should fall through.
- */
- Sleep(0);
- }
- while (pthread_mutex_destroy (&s->lock) == EBUSY);
+ {
+ result = EINVAL;
}
}
+ ptw32_mcs_lock_release(&node);
}
}
if (result != 0)
{
- errno = result;
+ PTW32_SET_ERRNO(result);
return -1;
}
diff --git a/libs/pthreads/src/sem_getvalue.c b/libs/pthreads/src/sem_getvalue.c
index baafb02cf0..d578596eb4 100644
--- a/libs/pthreads/src/sem_getvalue.c
+++ b/libs/pthreads/src/sem_getvalue.c
@@ -13,34 +13,38 @@
*
* --------------------------------------------------------------------------
*
- * Pthreads-win32 - POSIX Threads Library for Win32
+ * Pthreads4w - POSIX Threads Library for Win32
* Copyright(C) 1998 John E. Bossom
- * Copyright(C) 1999,2005 Pthreads-win32 contributors
- *
- * Contact Email: rpj@callisto.canberra.edu.au
- *
+ * Copyright(C) 1999-2018, Pthreads4w contributors
+ *
+ * Homepage: https://sourceforge.net/projects/pthreads4w/
+ *
* The current list of contributors is contained
* in the file CONTRIBUTORS included with the source
* code distribution. The list can also be seen at the
* following World Wide Web location:
- * http://sources.redhat.com/pthreads-win32/contributors.html
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library in the file COPYING.LIB;
- * if not, write to the Free Software Foundation, Inc.,
- * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
+ * https://sourceforge.net/p/pthreads4w/wiki/Contributors/
+ *
+ * This file is part of Pthreads4w.
+ *
+ * Pthreads4w is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * Pthreads4w is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Pthreads4w. If not, see <http://www.gnu.org/licenses/>. *
*/
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
#include "pthread.h"
#include "semaphore.h"
#include "implement.h"
@@ -48,63 +52,49 @@
int
sem_getvalue (sem_t * sem, int *sval)
- /*
- * ------------------------------------------------------
- * DOCPUBLIC
- * This function stores the current count value of the
- * semaphore.
- * RESULTS
- *
- * Return value
- *
- * 0 sval has been set.
- * -1 failed, error in errno
- *
- * in global errno
- *
- * EINVAL 'sem' is not a valid semaphore,
- * ENOSYS this function is not supported,
- *
- *
- * PARAMETERS
- *
- * sem pointer to an instance of sem_t
- *
- * sval pointer to int.
- *
- * DESCRIPTION
- * This function stores the current count value of the semaphore
- * pointed to by sem in the int pointed to by sval.
- */
+/*
+ * ------------------------------------------------------
+ * DOCPUBLIC
+ * This function stores the current count value of the
+ * semaphore.
+ * RESULTS
+ *
+ * Return value
+ *
+ * 0 sval has been set.
+ * -1 failed, error in errno
+ *
+ * in global errno
+ *
+ * EINVAL 'sem' is not a valid semaphore,
+ * ENOSYS this function is not supported,
+ *
+ *
+ * PARAMETERS
+ *
+ * sem pointer to an instance of sem_t
+ *
+ * sval pointer to int.
+ *
+ * DESCRIPTION
+ * This function stores the current count value of the semaphore
+ * pointed to by sem in the int pointed to by sval.
+ */
{
- if (sem == NULL || *sem == NULL || sval == NULL)
- {
- errno = EINVAL;
- return -1;
- }
- else
- {
- long value;
- register sem_t s = *sem;
- int result = 0;
+ int result = 0;
- if ((result = pthread_mutex_lock(&s->lock)) == 0)
- {
- /* See sem_destroy.c
- */
- if (*sem == NULL)
- {
- (void) pthread_mutex_unlock (&s->lock);
- errno = EINVAL;
- return -1;
- }
+ ptw32_mcs_local_node_t node;
+ register sem_t s = *sem;
- value = s->value;
- (void) pthread_mutex_unlock(&s->lock);
- *sval = value;
- }
+ ptw32_mcs_lock_acquire(&s->lock, &node);
+ *sval = s->value;
+ ptw32_mcs_lock_release(&node);
- return result;
+ if (result != 0)
+ {
+ PTW32_SET_ERRNO(result);
+ return -1;
}
+ return 0;
} /* sem_getvalue */
diff --git a/libs/pthreads/src/sem_init.c b/libs/pthreads/src/sem_init.c
index f682f4b204..a4fc012023 100644
--- a/libs/pthreads/src/sem_init.c
+++ b/libs/pthreads/src/sem_init.c
@@ -11,76 +11,80 @@
*
* -------------------------------------------------------------
*
- * Pthreads-win32 - POSIX Threads Library for Win32
+ * Pthreads4w - POSIX Threads Library for Win32
* Copyright(C) 1998 John E. Bossom
- * Copyright(C) 1999,2005 Pthreads-win32 contributors
- *
- * Contact Email: rpj@callisto.canberra.edu.au
- *
+ * Copyright(C) 1999-2018, Pthreads4w contributors
+ *
+ * Homepage: https://sourceforge.net/projects/pthreads4w/
+ *
* The current list of contributors is contained
* in the file CONTRIBUTORS included with the source
* code distribution. The list can also be seen at the
* following World Wide Web location:
- * http://sources.redhat.com/pthreads-win32/contributors.html
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library in the file COPYING.LIB;
- * if not, write to the Free Software Foundation, Inc.,
- * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
+ * https://sourceforge.net/p/pthreads4w/wiki/Contributors/
+ *
+ * This file is part of Pthreads4w.
+ *
+ * Pthreads4w is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * Pthreads4w is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Pthreads4w. If not, see <http://www.gnu.org/licenses/>. *
*/
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
#include "pthread.h"
#include "semaphore.h"
#include "implement.h"
int
sem_init (sem_t * sem, int pshared, unsigned int value)
- /*
- * ------------------------------------------------------
- * DOCPUBLIC
- * This function initializes a semaphore. The
- * initial value of the semaphore is 'value'
- *
- * PARAMETERS
- * sem
- * pointer to an instance of sem_t
- *
- * pshared
- * if zero, this semaphore may only be shared between
- * threads in the same process.
- * if nonzero, the semaphore can be shared between
- * processes
- *
- * value
- * initial value of the semaphore counter
- *
- * DESCRIPTION
- * This function initializes a semaphore. The
- * initial value of the semaphore is set to 'value'.
- *
- * RESULTS
- * 0 successfully created semaphore,
- * -1 failed, error in errno
- * ERRNO
- * EINVAL 'sem' is not a valid semaphore, or
- * 'value' >= SEM_VALUE_MAX
- * ENOMEM out of memory,
- * ENOSPC a required resource has been exhausted,
- * ENOSYS semaphores are not supported,
- * EPERM the process lacks appropriate privilege
- *
- * ------------------------------------------------------
- */
+/*
+ * ------------------------------------------------------
+ * DOCPUBLIC
+ * This function initializes a semaphore. The
+ * initial value of the semaphore is 'value'
+ *
+ * PARAMETERS
+ * sem
+ * pointer to an instance of sem_t
+ *
+ * pshared
+ * if zero, this semaphore may only be shared between
+ * threads in the same process.
+ * if nonzero, the semaphore can be shared between
+ * processes
+ *
+ * value
+ * initial value of the semaphore counter
+ *
+ * DESCRIPTION
+ * This function initializes a semaphore. The
+ * initial value of the semaphore is set to 'value'.
+ *
+ * RESULTS
+ * 0 successfully created semaphore,
+ * -1 failed, error in errno
+ * ERRNO
+ * EINVAL 'sem' is not a valid semaphore, or
+ * 'value' >= SEM_VALUE_MAX
+ * ENOMEM out of memory,
+ * ENOSPC a required resource has been exhausted,
+ * ENOSYS semaphores are not supported,
+ * EPERM the process lacks appropriate privilege
+ *
+ * ------------------------------------------------------
+ */
{
int result = 0;
sem_t s = NULL;
@@ -102,63 +106,53 @@ sem_init (sem_t * sem, int pshared, unsigned int value)
s = (sem_t) calloc (1, sizeof (*s));
if (NULL == s)
- {
- result = ENOMEM;
- }
+ {
+ result = ENOMEM;
+ }
else
- {
+ {
- s->value = value;
- if (pthread_mutex_init(&s->lock, NULL) == 0)
- {
+ s->value = value;
+ s->lock = NULL;
#if defined(NEED_SEM)
- s->sem = CreateEvent (NULL,
- PTW32_FALSE, /* auto (not manual) reset */
- PTW32_FALSE, /* initial state is unset */
- NULL);
-
- if (0 == s->sem)
- {
- free (s);
- (void) pthread_mutex_destroy(&s->lock);
- result = ENOSPC;
- }
- else
- {
- s->leftToUnblock = 0;
- }
+ s->sem = CreateEvent (NULL,
+ PTW32_FALSE, /* auto (not manual) reset */
+ PTW32_FALSE, /* initial state is unset */
+ NULL);
+
+ if (0 == s->sem)
+ {
+ result = ENOSPC;
+ }
+ else
+ {
+ s->leftToUnblock = 0;
+ }
#else /* NEED_SEM */
- if ((s->sem = CreateSemaphore (NULL, /* Always NULL */
- (long) 0, /* Force threads to wait */
- (long) SEM_VALUE_MAX, /* Maximum value */
- NULL)) == 0) /* Name */
- {
- (void) pthread_mutex_destroy(&s->lock);
- result = ENOSPC;
- }
+ if ((s->sem = CreateSemaphore (NULL, /* Always NULL */
+ (long) 0, /* Force threads to wait */
+ (long) SEM_VALUE_MAX, /* Maximum value */
+ NULL)) == 0) /* Name */
+ {
+ result = ENOSPC;
+ }
#endif /* NEED_SEM */
- }
- else
- {
- result = ENOSPC;
- }
-
- if (result != 0)
- {
- free(s);
- }
- }
+ if (result != 0)
+ {
+ free(s);
+ }
+ }
}
if (result != 0)
{
- errno = result;
+ PTW32_SET_ERRNO(result);
return -1;
}
diff --git a/libs/pthreads/src/sem_open.c b/libs/pthreads/src/sem_open.c
index fb1cc541f8..371f56e09c 100644
--- a/libs/pthreads/src/sem_open.c
+++ b/libs/pthreads/src/sem_open.c
@@ -13,34 +13,38 @@
*
* --------------------------------------------------------------------------
*
- * Pthreads-win32 - POSIX Threads Library for Win32
+ * Pthreads4w - POSIX Threads Library for Win32
* Copyright(C) 1998 John E. Bossom
- * Copyright(C) 1999,2005 Pthreads-win32 contributors
- *
- * Contact Email: rpj@callisto.canberra.edu.au
- *
+ * Copyright(C) 1999-2018, Pthreads4w contributors
+ *
+ * Homepage: https://sourceforge.net/projects/pthreads4w/
+ *
* The current list of contributors is contained
* in the file CONTRIBUTORS included with the source
* code distribution. The list can also be seen at the
* following World Wide Web location:
- * http://sources.redhat.com/pthreads-win32/contributors.html
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library in the file COPYING.LIB;
- * if not, write to the Free Software Foundation, Inc.,
- * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
+ * https://sourceforge.net/p/pthreads4w/wiki/Contributors/
+ *
+ * This file is part of Pthreads4w.
+ *
+ * Pthreads4w is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * Pthreads4w is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Pthreads4w. If not, see <http://www.gnu.org/licenses/>. *
*/
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
#include "pthread.h"
#include "semaphore.h"
#include "implement.h"
@@ -50,9 +54,14 @@
#pragma warning( disable : 4100 )
#endif
-int
-sem_open (const char *name, int oflag, mode_t mode, unsigned int value)
+sem_t
+*sem_open (const char *name, int oflag, ...)
{
- errno = ENOSYS;
- return -1;
+ /* Note: this is a POSIX.1b-1993 conforming stub; POSIX.1-2001 removed
+ * the requirement to provide this stub, and also removed the validity
+ * of ENOSYS as a resultant errno state; nevertheless, it makes sense
+ * to retain the POSIX.1b-1993 conforming behaviour here.
+ */
+ PTW32_SET_ERRNO(ENOSYS);
+ return SEM_FAILED;
} /* sem_open */
diff --git a/libs/pthreads/src/sem_post.c b/libs/pthreads/src/sem_post.c
index 34832527b8..52485b235a 100644
--- a/libs/pthreads/src/sem_post.c
+++ b/libs/pthreads/src/sem_post.c
@@ -13,34 +13,38 @@
*
* --------------------------------------------------------------------------
*
- * Pthreads-win32 - POSIX Threads Library for Win32
+ * Pthreads4w - POSIX Threads Library for Win32
* Copyright(C) 1998 John E. Bossom
- * Copyright(C) 1999,2005 Pthreads-win32 contributors
- *
- * Contact Email: rpj@callisto.canberra.edu.au
- *
+ * Copyright(C) 1999-2018, Pthreads4w contributors
+ *
+ * Homepage: https://sourceforge.net/projects/pthreads4w/
+ *
* The current list of contributors is contained
* in the file CONTRIBUTORS included with the source
* code distribution. The list can also be seen at the
* following World Wide Web location:
- * http://sources.redhat.com/pthreads-win32/contributors.html
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library in the file COPYING.LIB;
- * if not, write to the Free Software Foundation, Inc.,
- * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
+ * https://sourceforge.net/p/pthreads4w/wiki/Contributors/
+ *
+ * This file is part of Pthreads4w.
+ *
+ * Pthreads4w is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * Pthreads4w is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Pthreads4w. If not, see <http://www.gnu.org/licenses/>. *
*/
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
#include "pthread.h"
#include "semaphore.h"
#include "implement.h"
@@ -48,81 +52,66 @@
int
sem_post (sem_t * sem)
- /*
- * ------------------------------------------------------
- * DOCPUBLIC
- * This function posts a wakeup to a semaphore.
- *
- * PARAMETERS
- * sem
- * pointer to an instance of sem_t
- *
- * DESCRIPTION
- * This function posts a wakeup to a semaphore. If there
- * are waiting threads (or processes), one is awakened;
- * otherwise, the semaphore value is incremented by one.
- *
- * RESULTS
- * 0 successfully posted semaphore,
- * -1 failed, error in errno
- * ERRNO
- * EINVAL 'sem' is not a valid semaphore,
- * ENOSYS semaphores are not supported,
- * ERANGE semaphore count is too big
- *
- * ------------------------------------------------------
- */
+/*
+ * ------------------------------------------------------
+ * DOCPUBLIC
+ * This function posts a wakeup to a semaphore.
+ *
+ * PARAMETERS
+ * sem
+ * pointer to an instance of sem_t
+ *
+ * DESCRIPTION
+ * This function posts a wakeup to a semaphore. If there
+ * are waiting threads (or processes), one is awakened;
+ * otherwise, the semaphore value is incremented by one.
+ *
+ * RESULTS
+ * 0 successfully posted semaphore,
+ * -1 failed, error in errno
+ * ERRNO
+ * EINVAL 'sem' is not a valid semaphore,
+ * ENOSYS semaphores are not supported,
+ * ERANGE semaphore count is too big
+ *
+ * ------------------------------------------------------
+ */
{
int result = 0;
+
+ ptw32_mcs_local_node_t node;
sem_t s = *sem;
- if (s == NULL)
- {
- result = EINVAL;
- }
- else if ((result = pthread_mutex_lock (&s->lock)) == 0)
+ ptw32_mcs_lock_acquire(&s->lock, &node);
+ if (s->value < SEM_VALUE_MAX)
{
- /* See sem_destroy.c
- */
- if (*sem == NULL)
+#if defined(NEED_SEM)
+ if (++s->value <= 0
+ && !SetEvent(s->sem))
{
- (void) pthread_mutex_unlock (&s->lock);
+ s->value--;
result = EINVAL;
- return -1;
}
-
- if (s->value < SEM_VALUE_MAX)
- {
-#if defined(NEED_SEM)
- if (++s->value <= 0
- && !SetEvent(s->sem))
- {
- s->value--;
- result = EINVAL;
- }
#else
- if (++s->value <= 0
- && !ReleaseSemaphore (s->sem, 1, NULL))
- {
- s->value--;
- result = EINVAL;
- }
+ if (++s->value <= 0
+ && !ReleaseSemaphore (s->sem, 1, NULL))
+ {
+ s->value--;
+ result = EINVAL;
+ }
#endif /* NEED_SEM */
- }
- else
- {
- result = ERANGE;
- }
-
- (void) pthread_mutex_unlock (&s->lock);
}
+ else
+ {
+ result = ERANGE;
+ }
+ ptw32_mcs_lock_release(&node);
if (result != 0)
{
- errno = result;
+ PTW32_SET_ERRNO(result);
return -1;
}
return 0;
-
-} /* sem_post */
+}
diff --git a/libs/pthreads/src/sem_post_multiple.c b/libs/pthreads/src/sem_post_multiple.c
index 44c168c6cf..cab9c46a2d 100644
--- a/libs/pthreads/src/sem_post_multiple.c
+++ b/libs/pthreads/src/sem_post_multiple.c
@@ -13,34 +13,38 @@
*
* --------------------------------------------------------------------------
*
- * Pthreads-win32 - POSIX Threads Library for Win32
+ * Pthreads4w - POSIX Threads Library for Win32
* Copyright(C) 1998 John E. Bossom
- * Copyright(C) 1999,2005 Pthreads-win32 contributors
- *
- * Contact Email: rpj@callisto.canberra.edu.au
- *
+ * Copyright(C) 1999-2018, Pthreads4w contributors
+ *
+ * Homepage: https://sourceforge.net/projects/pthreads4w/
+ *
* The current list of contributors is contained
* in the file CONTRIBUTORS included with the source
* code distribution. The list can also be seen at the
* following World Wide Web location:
- * http://sources.redhat.com/pthreads-win32/contributors.html
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library in the file COPYING.LIB;
- * if not, write to the Free Software Foundation, Inc.,
- * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
+ * https://sourceforge.net/p/pthreads4w/wiki/Contributors/
+ *
+ * This file is part of Pthreads4w.
+ *
+ * Pthreads4w is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * Pthreads4w is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Pthreads4w. If not, see <http://www.gnu.org/licenses/>. *
*/
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
#include "pthread.h"
#include "semaphore.h"
#include "implement.h"
@@ -48,95 +52,81 @@
int
sem_post_multiple (sem_t * sem, int count)
- /*
- * ------------------------------------------------------
- * DOCPUBLIC
- * This function posts multiple wakeups to a semaphore.
- *
- * PARAMETERS
- * sem
- * pointer to an instance of sem_t
- *
- * count
- * counter, must be greater than zero.
- *
- * DESCRIPTION
- * This function posts multiple wakeups to a semaphore. If there
- * are waiting threads (or processes), n <= count are awakened;
- * the semaphore value is incremented by count - n.
- *
- * RESULTS
- * 0 successfully posted semaphore,
- * -1 failed, error in errno
- * ERRNO
- * EINVAL 'sem' is not a valid semaphore
- * or count is less than or equal to zero.
- * ERANGE semaphore count is too big
- *
- * ------------------------------------------------------
- */
+/*
+ * ------------------------------------------------------
+ * DOCPUBLIC
+ * This function posts multiple wakeups to a semaphore.
+ *
+ * PARAMETERS
+ * sem
+ * pointer to an instance of sem_t
+ *
+ * count
+ * counter, must be greater than zero.
+ *
+ * DESCRIPTION
+ * This function posts multiple wakeups to a semaphore. If there
+ * are waiting threads (or processes), n <= count are awakened;
+ * the semaphore value is incremented by count - n.
+ *
+ * RESULTS
+ * 0 successfully posted semaphore,
+ * -1 failed, error in errno
+ * ERRNO
+ * EINVAL 'sem' is not a valid semaphore
+ * or count is less than or equal to zero.
+ * ERANGE semaphore count is too big
+ *
+ * ------------------------------------------------------
+ */
{
+ ptw32_mcs_local_node_t node;
int result = 0;
long waiters;
sem_t s = *sem;
- if (s == NULL || count <= 0)
- {
- result = EINVAL;
- }
- else if ((result = pthread_mutex_lock (&s->lock)) == 0)
+ ptw32_mcs_lock_acquire(&s->lock, &node);
+
+ if (s->value <= (SEM_VALUE_MAX - count))
{
- /* See sem_destroy.c
- */
- if (*sem == NULL)
+ waiters = -s->value;
+ s->value += count;
+ if (waiters > 0)
{
- (void) pthread_mutex_unlock (&s->lock);
- result = EINVAL;
- return -1;
- }
-
- if (s->value <= (SEM_VALUE_MAX - count))
- {
- waiters = -s->value;
- s->value += count;
- if (waiters > 0)
- {
#if defined(NEED_SEM)
- if (SetEvent(s->sem))
- {
- waiters--;
- s->leftToUnblock += count - 1;
- if (s->leftToUnblock > waiters)
- {
- s->leftToUnblock = waiters;
- }
- }
+ if (SetEvent(s->sem))
+ {
+ waiters--;
+ s->leftToUnblock += count - 1;
+ if (s->leftToUnblock > waiters)
+ {
+ s->leftToUnblock = waiters;
+ }
+ }
#else
- if (ReleaseSemaphore (s->sem, (waiters<=count)?waiters:count, 0))
- {
- /* No action */
- }
+ if (ReleaseSemaphore (s->sem, (waiters<=count)?waiters:count, 0))
+ {
+ /* No action */
+ }
#endif
- else
- {
- s->value -= count;
- result = EINVAL;
- }
- }
- }
- else
- {
- result = ERANGE;
- }
- (void) pthread_mutex_unlock (&s->lock);
+ else
+ {
+ s->value -= count;
+ result = EINVAL;
+ }
+ }
}
+ else
+ {
+ result = ERANGE;
+ }
+ ptw32_mcs_lock_release(&node);
if (result != 0)
{
- errno = result;
+ PTW32_SET_ERRNO(result);
return -1;
}
return 0;
-
-} /* sem_post_multiple */
+}
diff --git a/libs/pthreads/src/sem_timedwait.c b/libs/pthreads/src/sem_timedwait.c
index 638431cf1f..d569746ab8 100644
--- a/libs/pthreads/src/sem_timedwait.c
+++ b/libs/pthreads/src/sem_timedwait.c
@@ -13,34 +13,38 @@
*
* --------------------------------------------------------------------------
*
- * Pthreads-win32 - POSIX Threads Library for Win32
+ * Pthreads4w - POSIX Threads Library for Win32
* Copyright(C) 1998 John E. Bossom
- * Copyright(C) 1999,2005 Pthreads-win32 contributors
- *
- * Contact Email: rpj@callisto.canberra.edu.au
- *
+ * Copyright(C) 1999-2018, Pthreads4w contributors
+ *
+ * Homepage: https://sourceforge.net/projects/pthreads4w/
+ *
* The current list of contributors is contained
* in the file CONTRIBUTORS included with the source
* code distribution. The list can also be seen at the
* following World Wide Web location:
- * http://sources.redhat.com/pthreads-win32/contributors.html
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library in the file COPYING.LIB;
- * if not, write to the Free Software Foundation, Inc.,
- * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
+ * https://sourceforge.net/p/pthreads4w/wiki/Contributors/
+ *
+ * This file is part of Pthreads4w.
+ *
+ * Pthreads4w is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * Pthreads4w is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Pthreads4w. If not, see <http://www.gnu.org/licenses/>. *
*/
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
#include "pthread.h"
#include "semaphore.h"
#include "implement.h"
@@ -55,180 +59,153 @@ typedef struct {
static void PTW32_CDECL
ptw32_sem_timedwait_cleanup (void * args)
{
+ ptw32_mcs_local_node_t node;
sem_timedwait_cleanup_args_t * a = (sem_timedwait_cleanup_args_t *)args;
sem_t s = a->sem;
- if (pthread_mutex_lock (&s->lock) == 0)
+ ptw32_mcs_lock_acquire(&s->lock, &node);
+ /*
+ * We either timed out or were cancelled.
+ * If someone has posted between then and now we try to take the semaphore.
+ * Otherwise the semaphore count may be wrong after we
+ * return. In the case of a cancellation, it is as if we
+ * were cancelled just before we return (after taking the semaphore)
+ * which is ok.
+ */
+ if (WaitForSingleObject(s->sem, 0) == WAIT_OBJECT_0)
{
- /*
- * We either timed out or were cancelled.
- * If someone has posted between then and now we try to take the semaphore.
- * Otherwise the semaphore count may be wrong after we
- * return. In the case of a cancellation, it is as if we
- * were cancelled just before we return (after taking the semaphore)
- * which is ok.
- */
- if (WaitForSingleObject(s->sem, 0) == WAIT_OBJECT_0)
- {
- /* We got the semaphore on the second attempt */
- *(a->resultPtr) = 0;
- }
- else
- {
- /* Indicate we're no longer waiting */
- s->value++;
+ /* We got the semaphore on the second attempt */
+ *(a->resultPtr) = 0;
+ }
+ else
+ {
+ /* Indicate we're no longer waiting */
+ s->value++;
#if defined(NEED_SEM)
- if (s->value > 0)
- {
- s->leftToUnblock = 0;
- }
+ if (s->value > 0)
+ {
+ s->leftToUnblock = 0;
+ }
#else
- /*
- * Don't release the W32 sema, it doesn't need adjustment
- * because it doesn't record the number of waiters.
- */
+ /*
+ * Don't release the W32 sema, it doesn't need adjustment
+ * because it doesn't record the number of waiters.
+ */
#endif
- }
- (void) pthread_mutex_unlock (&s->lock);
}
+ ptw32_mcs_lock_release(&node);
}
int
sem_timedwait (sem_t * sem, const struct timespec *abstime)
- /*
- * ------------------------------------------------------
- * DOCPUBLIC
- * This function waits on a semaphore possibly until
- * 'abstime' time.
- *
- * PARAMETERS
- * sem
- * pointer to an instance of sem_t
- *
- * abstime
- * pointer to an instance of struct timespec
- *
- * DESCRIPTION
- * This function waits on a semaphore. If the
- * semaphore value is greater than zero, it decreases
- * its value by one. If the semaphore value is zero, then
- * the calling thread (or process) is blocked until it can
- * successfully decrease the value or until interrupted by
- * a signal.
- *
- * If 'abstime' is a NULL pointer then this function will
- * block until it can successfully decrease the value or
- * until interrupted by a signal.
- *
- * RESULTS
- * 0 successfully decreased semaphore,
- * -1 failed, error in errno
- * ERRNO
- * EINVAL 'sem' is not a valid semaphore,
- * ENOSYS semaphores are not supported,
- * EINTR the function was interrupted by a signal,
- * EDEADLK a deadlock condition was detected.
- * ETIMEDOUT abstime elapsed before success.
- *
- * ------------------------------------------------------
- */
+/*
+ * ------------------------------------------------------
+ * DOCPUBLIC
+ * This function waits on a semaphore possibly until
+ * 'abstime' time.
+ *
+ * PARAMETERS
+ * sem
+ * pointer to an instance of sem_t
+ *
+ * abstime
+ * pointer to an instance of struct timespec
+ *
+ * DESCRIPTION
+ * This function waits on a semaphore. If the
+ * semaphore value is greater than zero, it decreases
+ * its value by one. If the semaphore value is zero, then
+ * the calling thread (or process) is blocked until it can
+ * successfully decrease the value or until interrupted by
+ * a signal.
+ *
+ * If 'abstime' is a NULL pointer then this function will
+ * block until it can successfully decrease the value or
+ * until interrupted by a signal.
+ *
+ * RESULTS
+ * 0 successfully decreased semaphore,
+ * -1 failed, error in errno
+ * ERRNO
+ * EINVAL 'sem' is not a valid semaphore,
+ * ENOSYS semaphores are not supported,
+ * EINTR the function was interrupted by a signal,
+ * EDEADLK a deadlock condition was detected.
+ * ETIMEDOUT abstime elapsed before success.
+ *
+ * ------------------------------------------------------
+ */
{
+ ptw32_mcs_local_node_t node;
+ DWORD milliseconds;
+ int v;
int result = 0;
sem_t s = *sem;
pthread_testcancel();
- if (sem == NULL)
+ if (abstime == NULL)
{
- result = EINVAL;
+ milliseconds = INFINITE;
}
else
{
- DWORD milliseconds;
-
- if (abstime == NULL)
- {
- milliseconds = INFINITE;
- }
- else
- {
- /*
- * Calculate timeout as milliseconds from current system time.
- */
- milliseconds = ptw32_relmillisecs (abstime);
- }
-
- if ((result = pthread_mutex_lock (&s->lock)) == 0)
- {
- int v;
-
- /* See sem_destroy.c
- */
- if (*sem == NULL)
- {
- (void) pthread_mutex_unlock (&s->lock);
- errno = EINVAL;
- return -1;
- }
-
- v = --s->value;
- (void) pthread_mutex_unlock (&s->lock);
-
- if (v < 0)
- {
+ /*
+ * Calculate timeout as milliseconds from current system time.
+ */
+ milliseconds = ptw32_relmillisecs (abstime);
+ }
+
+ ptw32_mcs_lock_acquire(&s->lock, &node);
+ v = --s->value;
+ ptw32_mcs_lock_release(&node);
+
+ if (v < 0)
+ {
#if defined(NEED_SEM)
- int timedout;
+ int timedout;
#endif
- sem_timedwait_cleanup_args_t cleanup_args;
+ sem_timedwait_cleanup_args_t cleanup_args;
- cleanup_args.sem = s;
- cleanup_args.resultPtr = &result;
+ cleanup_args.sem = s;
+ cleanup_args.resultPtr = &result;
-#if defined(_MSC_VER) && _MSC_VER < 1400
+#if defined(PTW32_CONFIG_MSVC7)
#pragma inline_depth(0)
#endif
- /* Must wait */
- pthread_cleanup_push(ptw32_sem_timedwait_cleanup, (void *) &cleanup_args);
+ /* Must wait */
+ pthread_cleanup_push(ptw32_sem_timedwait_cleanup, (void *) &cleanup_args);
#if defined(NEED_SEM)
- timedout =
+ timedout =
#endif
- result = pthreadCancelableTimedWait (s->sem, milliseconds);
- pthread_cleanup_pop(result);
-#if defined(_MSC_VER) && _MSC_VER < 1400
+ result = pthreadCancelableTimedWait (s->sem, milliseconds);
+ pthread_cleanup_pop(result);
+#if defined(PTW32_CONFIG_MSVC7)
#pragma inline_depth()
#endif
#if defined(NEED_SEM)
- if (!timedout && pthread_mutex_lock (&s->lock) == 0)
- {
- if (*sem == NULL)
- {
- (void) pthread_mutex_unlock (&s->lock);
- errno = EINVAL;
- return -1;
- }
-
- if (s->leftToUnblock > 0)
- {
- --s->leftToUnblock;
- SetEvent(s->sem);
- }
- (void) pthread_mutex_unlock (&s->lock);
- }
+ if (!timedout)
+ {
+ ptw32_mcs_lock_acquire(&s->lock, &node);
+ if (s->leftToUnblock > 0)
+ {
+ --s->leftToUnblock;
+ SetEvent(s->sem);
+ }
+ ptw32_mcs_lock_release(&node);
+ }
#endif /* NEED_SEM */
- }
- }
-
}
if (result != 0)
{
- errno = result;
+ PTW32_SET_ERRNO(result);
return -1;
}
diff --git a/libs/pthreads/src/sem_trywait.c b/libs/pthreads/src/sem_trywait.c
index 63614ba2b8..48a3b113fe 100644
--- a/libs/pthreads/src/sem_trywait.c
+++ b/libs/pthreads/src/sem_trywait.c
@@ -13,34 +13,38 @@
*
* --------------------------------------------------------------------------
*
- * Pthreads-win32 - POSIX Threads Library for Win32
+ * Pthreads4w - POSIX Threads Library for Win32
* Copyright(C) 1998 John E. Bossom
- * Copyright(C) 1999,2005 Pthreads-win32 contributors
- *
- * Contact Email: rpj@callisto.canberra.edu.au
- *
+ * Copyright(C) 1999-2018, Pthreads4w contributors
+ *
+ * Homepage: https://sourceforge.net/projects/pthreads4w/
+ *
* The current list of contributors is contained
* in the file CONTRIBUTORS included with the source
* code distribution. The list can also be seen at the
* following World Wide Web location:
- * http://sources.redhat.com/pthreads-win32/contributors.html
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library in the file COPYING.LIB;
- * if not, write to the Free Software Foundation, Inc.,
- * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
+ * https://sourceforge.net/p/pthreads4w/wiki/Contributors/
+ *
+ * This file is part of Pthreads4w.
+ *
+ * Pthreads4w is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * Pthreads4w is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Pthreads4w. If not, see <http://www.gnu.org/licenses/>. *
*/
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
#include "pthread.h"
#include "semaphore.h"
#include "implement.h"
@@ -48,67 +52,54 @@
int
sem_trywait (sem_t * sem)
- /*
- * ------------------------------------------------------
- * DOCPUBLIC
- * This function tries to wait on a semaphore.
- *
- * PARAMETERS
- * sem
- * pointer to an instance of sem_t
- *
- * DESCRIPTION
- * This function tries to wait on a semaphore. If the
- * semaphore value is greater than zero, it decreases
- * its value by one. If the semaphore value is zero, then
- * this function returns immediately with the error EAGAIN
- *
- * RESULTS
- * 0 successfully decreased semaphore,
- * -1 failed, error in errno
- * ERRNO
- * EAGAIN the semaphore was already locked,
- * EINVAL 'sem' is not a valid semaphore,
- * ENOTSUP sem_trywait is not supported,
- * EINTR the function was interrupted by a signal,
- * EDEADLK a deadlock condition was detected.
- *
- * ------------------------------------------------------
- */
+/*
+ * ------------------------------------------------------
+ * DOCPUBLIC
+ * This function tries to wait on a semaphore.
+ *
+ * PARAMETERS
+ * sem
+ * pointer to an instance of sem_t
+ *
+ * DESCRIPTION
+ * This function tries to wait on a semaphore. If the
+ * semaphore value is greater than zero, it decreases
+ * its value by one. If the semaphore value is zero, then
+ * this function returns immediately with the error EAGAIN
+ *
+ * RESULTS
+ * 0 successfully decreased semaphore,
+ * -1 failed, error in errno
+ * ERRNO
+ * EAGAIN the semaphore was already locked,
+ * EINVAL 'sem' is not a valid semaphore,
+ * ENOTSUP sem_trywait is not supported,
+ * EINTR the function was interrupted by a signal,
+ * EDEADLK a deadlock condition was detected.
+ *
+ * ------------------------------------------------------
+ */
{
int result = 0;
sem_t s = *sem;
+ ptw32_mcs_local_node_t node;
- if (s == NULL)
+ ptw32_mcs_lock_acquire(&s->lock, &node);
+
+ if (s->value > 0)
{
- result = EINVAL;
+ s->value--;
}
- else if ((result = pthread_mutex_lock (&s->lock)) == 0)
+ else
{
- /* See sem_destroy.c
- */
- if (*sem == NULL)
- {
- (void) pthread_mutex_unlock (&s->lock);
- errno = EINVAL;
- return -1;
- }
-
- if (s->value > 0)
- {
- s->value--;
- }
- else
- {
- result = EAGAIN;
- }
-
- (void) pthread_mutex_unlock (&s->lock);
+ result = EAGAIN;
}
+ ptw32_mcs_lock_release(&node);
+
if (result != 0)
{
- errno = result;
+ PTW32_SET_ERRNO(result);
return -1;
}
diff --git a/libs/pthreads/src/sem_unlink.c b/libs/pthreads/src/sem_unlink.c
index fb80569a0a..2eb062df8d 100644
--- a/libs/pthreads/src/sem_unlink.c
+++ b/libs/pthreads/src/sem_unlink.c
@@ -13,34 +13,38 @@
*
* --------------------------------------------------------------------------
*
- * Pthreads-win32 - POSIX Threads Library for Win32
+ * Pthreads4w - POSIX Threads Library for Win32
* Copyright(C) 1998 John E. Bossom
- * Copyright(C) 1999,2005 Pthreads-win32 contributors
- *
- * Contact Email: rpj@callisto.canberra.edu.au
- *
+ * Copyright(C) 1999-2018, Pthreads4w contributors
+ *
+ * Homepage: https://sourceforge.net/projects/pthreads4w/
+ *
* The current list of contributors is contained
* in the file CONTRIBUTORS included with the source
* code distribution. The list can also be seen at the
* following World Wide Web location:
- * http://sources.redhat.com/pthreads-win32/contributors.html
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library in the file COPYING.LIB;
- * if not, write to the Free Software Foundation, Inc.,
- * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
+ * https://sourceforge.net/p/pthreads4w/wiki/Contributors/
+ *
+ * This file is part of Pthreads4w.
+ *
+ * Pthreads4w is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * Pthreads4w is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Pthreads4w. If not, see <http://www.gnu.org/licenses/>. *
*/
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
#include "pthread.h"
#include "semaphore.h"
#include "implement.h"
@@ -53,6 +57,6 @@
int
sem_unlink (const char *name)
{
- errno = ENOSYS;
+ PTW32_SET_ERRNO(ENOSYS);
return -1;
} /* sem_unlink */
diff --git a/libs/pthreads/src/sem_wait.c b/libs/pthreads/src/sem_wait.c
index 50c11d8080..2844b27346 100644
--- a/libs/pthreads/src/sem_wait.c
+++ b/libs/pthreads/src/sem_wait.c
@@ -13,34 +13,38 @@
*
* --------------------------------------------------------------------------
*
- * Pthreads-win32 - POSIX Threads Library for Win32
+ * Pthreads4w - POSIX Threads Library for Win32
* Copyright(C) 1998 John E. Bossom
- * Copyright(C) 1999,2005 Pthreads-win32 contributors
- *
- * Contact Email: rpj@callisto.canberra.edu.au
- *
+ * Copyright(C) 1999-2018, Pthreads4w contributors
+ *
+ * Homepage: https://sourceforge.net/projects/pthreads4w/
+ *
* The current list of contributors is contained
* in the file CONTRIBUTORS included with the source
* code distribution. The list can also be seen at the
* following World Wide Web location:
- * http://sources.redhat.com/pthreads-win32/contributors.html
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library in the file COPYING.LIB;
- * if not, write to the Free Software Foundation, Inc.,
- * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
+ * https://sourceforge.net/p/pthreads4w/wiki/Contributors/
+ *
+ * This file is part of Pthreads4w.
+ *
+ * Pthreads4w is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * Pthreads4w is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Pthreads4w. If not, see <http://www.gnu.org/licenses/>. *
*/
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
#include "pthread.h"
#include "semaphore.h"
#include "implement.h"
@@ -50,135 +54,109 @@ static void PTW32_CDECL
ptw32_sem_wait_cleanup(void * sem)
{
sem_t s = (sem_t) sem;
-
- if (pthread_mutex_lock (&s->lock) == 0)
+ ptw32_mcs_local_node_t node;
+
+ ptw32_mcs_lock_acquire(&s->lock, &node);
+ /*
+ * If sema is destroyed do nothing, otherwise:-
+ * If the sema is posted between us being canceled and us locking
+ * the sema again above then we need to consume that post but cancel
+ * anyway. If we don't get the semaphore we indicate that we're no
+ * longer waiting.
+ */
+ if (*((sem_t *)sem) != NULL && !(WaitForSingleObject(s->sem, 0) == WAIT_OBJECT_0))
{
- /*
- * If sema is destroyed do nothing, otherwise:-
- * If the sema is posted between us being cancelled and us locking
- * the sema again above then we need to consume that post but cancel
- * anyway. If we don't get the semaphore we indicate that we're no
- * longer waiting.
- */
- if (*((sem_t *)sem) != NULL && !(WaitForSingleObject(s->sem, 0) == WAIT_OBJECT_0))
- {
- ++s->value;
+ ++s->value;
#if defined(NEED_SEM)
- if (s->value > 0)
- {
- s->leftToUnblock = 0;
- }
+ if (s->value > 0)
+ {
+ s->leftToUnblock = 0;
+ }
#else
- /*
- * Don't release the W32 sema, it doesn't need adjustment
- * because it doesn't record the number of waiters.
- */
+ /*
+ * Don't release the W32 sema, it doesn't need adjustment
+ * because it doesn't record the number of waiters.
+ */
#endif /* NEED_SEM */
- }
- (void) pthread_mutex_unlock (&s->lock);
}
+ ptw32_mcs_lock_release(&node);
}
int
sem_wait (sem_t * sem)
- /*
- * ------------------------------------------------------
- * DOCPUBLIC
- * This function waits on a semaphore.
- *
- * PARAMETERS
- * sem
- * pointer to an instance of sem_t
- *
- * DESCRIPTION
- * This function waits on a semaphore. If the
- * semaphore value is greater than zero, it decreases
- * its value by one. If the semaphore value is zero, then
- * the calling thread (or process) is blocked until it can
- * successfully decrease the value or until interrupted by
- * a signal.
- *
- * RESULTS
- * 0 successfully decreased semaphore,
- * -1 failed, error in errno
- * ERRNO
- * EINVAL 'sem' is not a valid semaphore,
- * ENOSYS semaphores are not supported,
- * EINTR the function was interrupted by a signal,
- * EDEADLK a deadlock condition was detected.
- *
- * ------------------------------------------------------
- */
+/*
+ * ------------------------------------------------------
+ * DOCPUBLIC
+ * This function waits on a semaphore.
+ *
+ * PARAMETERS
+ * sem
+ * pointer to an instance of sem_t
+ *
+ * DESCRIPTION
+ * This function waits on a semaphore. If the
+ * semaphore value is greater than zero, it decreases
+ * its value by one. If the semaphore value is zero, then
+ * the calling thread (or process) is blocked until it can
+ * successfully decrease the value or until interrupted by
+ * a signal.
+ *
+ * RESULTS
+ * 0 successfully decreased semaphore,
+ * -1 failed, error in errno
+ * ERRNO
+ * EINVAL 'sem' is not a valid semaphore,
+ * ENOSYS semaphores are not supported,
+ * EINTR the function was interrupted by a signal,
+ * EDEADLK a deadlock condition was detected.
+ *
+ * ------------------------------------------------------
+ */
{
+ ptw32_mcs_local_node_t node;
+ int v;
int result = 0;
sem_t s = *sem;
pthread_testcancel();
- if (s == NULL)
- {
- result = EINVAL;
- }
- else
- {
- if ((result = pthread_mutex_lock (&s->lock)) == 0)
- {
- int v;
-
- /* See sem_destroy.c
- */
- if (*sem == NULL)
- {
- (void) pthread_mutex_unlock (&s->lock);
- errno = EINVAL;
- return -1;
- }
-
- v = --s->value;
- (void) pthread_mutex_unlock (&s->lock);
+ ptw32_mcs_lock_acquire(&s->lock, &node);
+ v = --s->value;
+ ptw32_mcs_lock_release(&node);
- if (v < 0)
- {
-#if defined(_MSC_VER) && _MSC_VER < 1400
+ if (v < 0)
+ {
+#if defined(PTW32_CONFIG_MSVC7)
#pragma inline_depth(0)
#endif
- /* Must wait */
- pthread_cleanup_push(ptw32_sem_wait_cleanup, (void *) s);
- result = pthreadCancelableWait (s->sem);
- /* Cleanup if we're canceled or on any other error */
- pthread_cleanup_pop(result);
-#if defined(_MSC_VER) && _MSC_VER < 1400
+ /* Must wait */
+ pthread_cleanup_push(ptw32_sem_wait_cleanup, (void *) s);
+ result = pthreadCancelableWait (s->sem);
+ /* Cleanup if we're canceled or on any other error */
+ pthread_cleanup_pop(result);
+#if defined(PTW32_CONFIG_MSVC7)
#pragma inline_depth()
#endif
- }
+ }
#if defined(NEED_SEM)
- if (!result && pthread_mutex_lock (&s->lock) == 0)
- {
- if (*sem == NULL)
- {
- (void) pthread_mutex_unlock (&s->lock);
- errno = EINVAL;
- return -1;
- }
-
- if (s->leftToUnblock > 0)
- {
- --s->leftToUnblock;
- SetEvent(s->sem);
- }
- (void) pthread_mutex_unlock (&s->lock);
- }
+ if (!result)
+ {
+ ptw32_mcs_lock_acquire(&s->lock, &node);
+
+ if (s->leftToUnblock > 0)
+ {
+ --s->leftToUnblock;
+ SetEvent(s->sem);
+ }
+ ptw32_mcs_lock_release(&node);
+ }
#endif /* NEED_SEM */
- }
-
- }
-
if (result != 0)
{
- errno = result;
+ PTW32_SET_ERRNO(result);
return -1;
}
diff --git a/libs/pthreads/src/semaphore.c b/libs/pthreads/src/semaphore.c
deleted file mode 100644
index 64fc0e366d..0000000000
--- a/libs/pthreads/src/semaphore.c
+++ /dev/null
@@ -1,69 +0,0 @@
-/*
- * -------------------------------------------------------------
- *
- * Module: semaphore.c
- *
- * Purpose:
- * Concatenated version of separate modules to allow
- * inlining optimisation, which it is assumed can only
- * be effective within a single module.
- *
- * Semaphores aren't actually part of the PThreads standard.
- * They are defined by the POSIX Standard:
- *
- * POSIX 1003.1b-1993 (POSIX.1b)
- *
- * -------------------------------------------------------------
- *
- * --------------------------------------------------------------------------
- *
- * Pthreads-win32 - POSIX Threads Library for Win32
- * Copyright(C) 1998 John E. Bossom
- * Copyright(C) 1999,2005 Pthreads-win32 contributors
- *
- * Contact Email: rpj@callisto.canberra.edu.au
- *
- * The current list of contributors is contained
- * in the file CONTRIBUTORS included with the source
- * code distribution. The list can also be seen at the
- * following World Wide Web location:
- * http://sources.redhat.com/pthreads-win32/contributors.html
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library in the file COPYING.LIB;
- * if not, write to the Free Software Foundation, Inc.,
- * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
- */
-
-#if !defined(NEED_FTIME)
-# include <sys/timeb.h>
-#endif
-
-#include <limits.h>
-
-#include "pthread.h"
-#include "semaphore.h"
-#include "implement.h"
-
-
-#include "sem_init.c"
-#include "sem_destroy.c"
-#include "sem_trywait.c"
-#include "sem_wait.c"
-#include "sem_timedwait.c"
-#include "sem_post.c"
-#include "sem_post_multiple.c"
-#include "sem_getvalue.c"
-#include "sem_open.c"
-#include "sem_close.c"
-#include "sem_unlink.c"
diff --git a/libs/pthreads/src/semaphore.h b/libs/pthreads/src/semaphore.h
index c6e9407e25..1288be8955 100644
--- a/libs/pthreads/src/semaphore.h
+++ b/libs/pthreads/src/semaphore.h
@@ -9,161 +9,110 @@
*
* --------------------------------------------------------------------------
*
- * Pthreads-win32 - POSIX Threads Library for Win32
+ * Pthreads4w - POSIX Threads Library for Win32
* Copyright(C) 1998 John E. Bossom
- * Copyright(C) 1999,2005 Pthreads-win32 contributors
- *
- * Contact Email: rpj@callisto.canberra.edu.au
- *
+ * Copyright(C) 1999-2018, Pthreads4w contributors
+ *
+ * Homepage: https://sourceforge.net/projects/pthreads4w/
+ *
* The current list of contributors is contained
* in the file CONTRIBUTORS included with the source
* code distribution. The list can also be seen at the
* following World Wide Web location:
- * http://sources.redhat.com/pthreads-win32/contributors.html
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library in the file COPYING.LIB;
- * if not, write to the Free Software Foundation, Inc.,
- * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
+ * https://sourceforge.net/p/pthreads4w/wiki/Contributors/
+ *
+ * This file is part of Pthreads4w.
+ *
+ * Pthreads4w is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * Pthreads4w is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Pthreads4w. If not, see <http://www.gnu.org/licenses/>. *
*/
#if !defined( SEMAPHORE_H )
#define SEMAPHORE_H
-#undef PTW32_SEMAPHORE_LEVEL
-
-#if defined(_POSIX_SOURCE)
-#define PTW32_SEMAPHORE_LEVEL 0
-/* Early POSIX */
-#endif
-
-#if defined(_POSIX_C_SOURCE) && _POSIX_C_SOURCE >= 199309
-#undef PTW32_SEMAPHORE_LEVEL
-#define PTW32_SEMAPHORE_LEVEL 1
-/* Include 1b, 1c and 1d */
-#endif
-
-#if defined(INCLUDE_NP)
-#undef PTW32_SEMAPHORE_LEVEL
-#define PTW32_SEMAPHORE_LEVEL 2
-/* Include Non-Portable extensions */
-#endif
-
-#define PTW32_SEMAPHORE_LEVEL_MAX 3
-
-#if !defined(PTW32_SEMAPHORE_LEVEL)
-#define PTW32_SEMAPHORE_LEVEL PTW32_SEMAPHORE_LEVEL_MAX
-/* Include everything */
-#endif
-
-#if defined(__GNUC__) && ! defined (__declspec)
-# error Please upgrade your GNU compiler to one that supports __declspec.
-#endif
-
-/*
- * When building the library, you should define PTW32_BUILD so that
- * the variables/functions are exported correctly. When using the library,
- * do NOT define PTW32_BUILD, and then the variables/functions will
- * be imported correctly.
- */
-#if !defined(PTW32_STATIC_LIB)
-# if defined(PTW32_BUILD)
-# define PTW32_DLLPORT __declspec (dllexport)
-# else
-# define PTW32_DLLPORT __declspec (dllimport)
-# endif
-#else
-# define PTW32_DLLPORT
-#endif
-
-/*
- * This is a duplicate of what is in the autoconf config.h,
- * which is only used when building the pthread-win32 libraries.
- */
-
-#if !defined(PTW32_CONFIG_H)
-# if defined(WINCE)
-# define NEED_ERRNO
-# define NEED_SEM
-# endif
-# if defined(__MINGW64__)
-# define HAVE_STRUCT_TIMESPEC
-# define HAVE_MODE_T
-# elif defined(_UWIN) || defined(__MINGW32__)
-# define HAVE_MODE_T
-# endif
-#endif
-
-/*
+/* FIXME: POSIX.1 says that _POSIX_SEMAPHORES should be defined
+ * in <unistd.h>, not here; for later POSIX.1 versions, its value
+ * should match the corresponding _POSIX_VERSION number, but in
+ * the case of POSIX.1b-1993, the value is unspecified.
*
+ * Notwithstanding the above, since POSIX semaphores, (and indeed
+ * having any <unistd.h> to #include), are not a standard feature
+ * on MS-Windows, it is convenient to retain this definition here;
+ * we may consider adding a hook, to make it selectively available
+ * for inclusion by <unistd.h>, in those cases (e.g. MinGW) where
+ * <unistd.h> is provided.
*/
-
-#if PTW32_SEMAPHORE_LEVEL >= PTW32_SEMAPHORE_LEVEL_MAX
-#if defined(NEED_ERRNO)
-#include "need_errno.h"
-#else
-#include <errno.h>
-#endif
-#endif /* PTW32_SEMAPHORE_LEVEL >= PTW32_SEMAPHORE_LEVEL_MAX */
-
#define _POSIX_SEMAPHORES
-#if defined(__cplusplus)
-extern "C"
-{
-#endif /* __cplusplus */
-
-#if !defined(HAVE_MODE_T)
-typedef unsigned int mode_t;
-#endif
+/* Internal macros, common to the public interfaces for various
+ * Pthreads4w components, are defined in <_ptw32.h>; we must
+ * include them here.
+ */
+#include <_ptw32.h>
+/* The sem_timedwait() function was added in POSIX.1-2001; it
+ * requires struct timespec to be defined, at least as a partial
+ * (a.k.a. incomplete) data type. Forward declare it as such,
+ * then include <time.h> selectively, to acquire a complete
+ * definition, (if available).
+ */
+struct timespec;
+#define __need_struct_timespec
+#include <time.h>
+/* The data type used to represent our semaphore implementation,
+ * as required by POSIX.1; FIXME: consider renaming the underlying
+ * structure tag, to avoid possible pollution of user namespace.
+ */
typedef struct sem_t_ * sem_t;
-PTW32_DLLPORT int __cdecl sem_init (sem_t * sem,
- int pshared,
- unsigned int value);
+/* POSIX.1b (and later) mandates SEM_FAILED as the value to be
+ * returned on failure of sem_open(); (our implementation is a
+ * stub, which will always return this).
+ */
+#define SEM_FAILED (sem_t *)(-1)
+
+__PTW32_BEGIN_C_DECLS
-PTW32_DLLPORT int __cdecl sem_destroy (sem_t * sem);
+/* Function prototypes: some are implemented as stubs, which
+ * always fail; (FIXME: identify them).
+ */
+PTW32_DLLPORT int PTW32_CDECL sem_init (sem_t * sem,
+ int pshared,
+ unsigned int value);
-PTW32_DLLPORT int __cdecl sem_trywait (sem_t * sem);
+PTW32_DLLPORT int PTW32_CDECL sem_destroy (sem_t * sem);
-PTW32_DLLPORT int __cdecl sem_wait (sem_t * sem);
+PTW32_DLLPORT int PTW32_CDECL sem_trywait (sem_t * sem);
-PTW32_DLLPORT int __cdecl sem_timedwait (sem_t * sem,
- const struct timespec * abstime);
+PTW32_DLLPORT int PTW32_CDECL sem_wait (sem_t * sem);
-PTW32_DLLPORT int __cdecl sem_post (sem_t * sem);
+PTW32_DLLPORT int PTW32_CDECL sem_timedwait (sem_t * sem,
+ const struct timespec * abstime);
-PTW32_DLLPORT int __cdecl sem_post_multiple (sem_t * sem,
- int count);
+PTW32_DLLPORT int PTW32_CDECL sem_post (sem_t * sem);
-PTW32_DLLPORT int __cdecl sem_open (const char * name,
- int oflag,
- mode_t mode,
- unsigned int value);
+PTW32_DLLPORT int PTW32_CDECL sem_post_multiple (sem_t * sem,
+ int count);
-PTW32_DLLPORT int __cdecl sem_close (sem_t * sem);
+PTW32_DLLPORT sem_t * PTW32_CDECL sem_open (const char *, int, ...);
-PTW32_DLLPORT int __cdecl sem_unlink (const char * name);
+PTW32_DLLPORT int PTW32_CDECL sem_close (sem_t * sem);
-PTW32_DLLPORT int __cdecl sem_getvalue (sem_t * sem,
- int * sval);
+PTW32_DLLPORT int PTW32_CDECL sem_unlink (const char * name);
-#if defined(__cplusplus)
-} /* End of extern "C" */
-#endif /* __cplusplus */
+PTW32_DLLPORT int PTW32_CDECL sem_getvalue (sem_t * sem,
+ int * sval);
-#undef PTW32_SEMAPHORE_LEVEL
-#undef PTW32_SEMAPHORE_LEVEL_MAX
+__PTW32_END_C_DECLS
#endif /* !SEMAPHORE_H */
diff --git a/libs/pthreads/src/signal.c b/libs/pthreads/src/signal.c
index eef466962b..6978d0b409 100644
--- a/libs/pthreads/src/signal.c
+++ b/libs/pthreads/src/signal.c
@@ -6,32 +6,32 @@
*
* --------------------------------------------------------------------------
*
- * Pthreads-win32 - POSIX Threads Library for Win32
+ * Pthreads4w - POSIX Threads Library for Win32
* Copyright(C) 1998 John E. Bossom
- * Copyright(C) 1999,2005 Pthreads-win32 contributors
- *
- * Contact Email: rpj@callisto.canberra.edu.au
- *
+ * Copyright(C) 1999-2018, Pthreads4w contributors
+ *
+ * Homepage: https://sourceforge.net/projects/pthreads4w/
+ *
* The current list of contributors is contained
* in the file CONTRIBUTORS included with the source
* code distribution. The list can also be seen at the
* following World Wide Web location:
- * http://sources.redhat.com/pthreads-win32/contributors.html
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library in the file COPYING.LIB;
- * if not, write to the Free Software Foundation, Inc.,
- * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
+ * https://sourceforge.net/p/pthreads4w/wiki/Contributors/
+ *
+ * This file is part of Pthreads4w.
+ *
+ * Pthreads4w is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * Pthreads4w is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Pthreads4w. If not, see <http://www.gnu.org/licenses/>. *
*/
/*
@@ -44,7 +44,7 @@
* signal (interrupt) to a specified thread in the same
* process.
* Signals are always asynchronous (no deferred signals).
- * Pthread-win32 has an async cancelation mechanism.
+ * Pthread-win32 has an async cancellation mechanism.
* A similar system can be written to deliver signals
* within the same process (on ix86 processors at least).
*
@@ -81,6 +81,10 @@
* pthread_t structure.
*/
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
#include "pthread.h"
#include "implement.h"
diff --git a/libs/pthreads/src/spin.c b/libs/pthreads/src/spin.c
deleted file mode 100644
index 41b5aa5251..0000000000
--- a/libs/pthreads/src/spin.c
+++ /dev/null
@@ -1,46 +0,0 @@
-/*
- * spin.c
- *
- * Description:
- * This translation unit implements spin lock primitives.
- *
- * --------------------------------------------------------------------------
- *
- * Pthreads-win32 - POSIX Threads Library for Win32
- * Copyright(C) 1998 John E. Bossom
- * Copyright(C) 1999,2005 Pthreads-win32 contributors
- *
- * Contact Email: rpj@callisto.canberra.edu.au
- *
- * The current list of contributors is contained
- * in the file CONTRIBUTORS included with the source
- * code distribution. The list can also be seen at the
- * following World Wide Web location:
- * http://sources.redhat.com/pthreads-win32/contributors.html
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library in the file COPYING.LIB;
- * if not, write to the Free Software Foundation, Inc.,
- * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
- */
-
-#include "pthread.h"
-#include "implement.h"
-
-
-#include "ptw32_spinlock_check_need_init.c"
-#include "pthread_spin_init.c"
-#include "pthread_spin_destroy.c"
-#include "pthread_spin_lock.c"
-#include "pthread_spin_unlock.c"
-#include "pthread_spin_trylock.c"
diff --git a/libs/pthreads/src/sync.c b/libs/pthreads/src/sync.c
deleted file mode 100644
index 5e56fa9a1f..0000000000
--- a/libs/pthreads/src/sync.c
+++ /dev/null
@@ -1,43 +0,0 @@
-/*
- * sync.c
- *
- * Description:
- * This translation unit implements functions related to thread
- * synchronisation.
- *
- * --------------------------------------------------------------------------
- *
- * Pthreads-win32 - POSIX Threads Library for Win32
- * Copyright(C) 1998 John E. Bossom
- * Copyright(C) 1999,2005 Pthreads-win32 contributors
- *
- * Contact Email: rpj@callisto.canberra.edu.au
- *
- * The current list of contributors is contained
- * in the file CONTRIBUTORS included with the source
- * code distribution. The list can also be seen at the
- * following World Wide Web location:
- * http://sources.redhat.com/pthreads-win32/contributors.html
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library in the file COPYING.LIB;
- * if not, write to the Free Software Foundation, Inc.,
- * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
- */
-
-#include "pthread.h"
-#include "implement.h"
-
-
-#include "pthread_detach.c"
-#include "pthread_join.c"
diff --git a/libs/pthreads/src/tsd.c b/libs/pthreads/src/tsd.c
deleted file mode 100644
index ed44fe6cb4..0000000000
--- a/libs/pthreads/src/tsd.c
+++ /dev/null
@@ -1,44 +0,0 @@
-/*
- * tsd.c
- *
- * Description:
- * POSIX thread functions which implement thread-specific data (TSD).
- *
- * --------------------------------------------------------------------------
- *
- * Pthreads-win32 - POSIX Threads Library for Win32
- * Copyright(C) 1998 John E. Bossom
- * Copyright(C) 1999,2005 Pthreads-win32 contributors
- *
- * Contact Email: rpj@callisto.canberra.edu.au
- *
- * The current list of contributors is contained
- * in the file CONTRIBUTORS included with the source
- * code distribution. The list can also be seen at the
- * following World Wide Web location:
- * http://sources.redhat.com/pthreads-win32/contributors.html
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library in the file COPYING.LIB;
- * if not, write to the Free Software Foundation, Inc.,
- * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
- */
-
-#include "pthread.h"
-#include "implement.h"
-
-
-#include "pthread_key_create.c"
-#include "pthread_key_delete.c"
-#include "pthread_setspecific.c"
-#include "pthread_getspecific.c"
diff --git a/libs/pthreads/src/w32_CancelableWait.c b/libs/pthreads/src/w32_CancelableWait.c
index 070633e0f9..5f7027f47f 100644
--- a/libs/pthreads/src/w32_CancelableWait.c
+++ b/libs/pthreads/src/w32_CancelableWait.c
@@ -6,34 +6,38 @@
*
* --------------------------------------------------------------------------
*
- * Pthreads-win32 - POSIX Threads Library for Win32
+ * Pthreads4w - POSIX Threads Library for Win32
* Copyright(C) 1998 John E. Bossom
- * Copyright(C) 1999,2005 Pthreads-win32 contributors
- *
- * Contact Email: rpj@callisto.canberra.edu.au
- *
+ * Copyright(C) 1999-2018, Pthreads4w contributors
+ *
+ * Homepage: https://sourceforge.net/projects/pthreads4w/
+ *
* The current list of contributors is contained
* in the file CONTRIBUTORS included with the source
* code distribution. The list can also be seen at the
* following World Wide Web location:
- * http://sources.redhat.com/pthreads-win32/contributors.html
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library in the file COPYING.LIB;
- * if not, write to the Free Software Foundation, Inc.,
- * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
+ * https://sourceforge.net/p/pthreads4w/wiki/Contributors/
+ *
+ * This file is part of Pthreads4w.
+ *
+ * Pthreads4w is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * Pthreads4w is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Pthreads4w. If not, see <http://www.gnu.org/licenses/>. *
*/
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
#include "pthread.h"
#include "implement.h"
@@ -45,7 +49,7 @@ ptw32_cancelable_wait (HANDLE waitHandle, DWORD timeout)
* This provides an extra hook into the pthread_cancel
* mechanism that will allow you to wait on a Windows handle and make it a
* cancellation point. This function blocks until the given WIN32 handle is
- * signaled or pthread_cancel has been called. It is implemented using
+ * signalled or pthread_cancel has been called. It is implemented using
* WaitForMultipleObjects on 'waitHandle' and a manually reset WIN32
* event used to implement pthread_cancel.
*
@@ -103,7 +107,7 @@ ptw32_cancelable_wait (HANDLE waitHandle, DWORD timeout)
case 1:
/*
* Got cancel request.
- * In the event that both handles are signaled, the cancel will
+ * In the event that both handles are signalled, the cancel will
* be ignored (see case 0 comment).
*/
ResetEvent (handles[1]);
@@ -112,8 +116,8 @@ ptw32_cancelable_wait (HANDLE waitHandle, DWORD timeout)
{
ptw32_mcs_local_node_t stateLock;
/*
- * Should handle POSIX and implicit POSIX threads..
- * Make sure we haven't been async-canceled in the meantime.
+ * Should handle POSIX and implicit POSIX threads.
+ * Make sure we haven't been async-cancelled in the meantime.
*/
ptw32_mcs_lock_acquire (&sp->stateLock, &stateLock);
if (sp->state < PThreadStateCanceling)