Skip to content

Commit 8e6aa75

Browse files
author
rpj
committed
1 parent 1a6b3c8 commit 8e6aa75

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+1976
-518
lines changed

ANNOUNCE

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -267,14 +267,21 @@ The following functions are implemented:
267267
for thread validity checking)
268268

269269
---------------------------
270-
Non-portable routines (see the README.NONPORTABLE file for usage)
270+
Non-portable routines
271271
---------------------------
272+
(See the README.NONPORTABLE file or HTML manual pages for usage.)
273+
pthread_attr_getname_np
274+
pthread_attr_setname_np
275+
pthread_getname_np
276+
pthread_setname_np
272277
pthread_timedjoin_np
273278
pthread_tryjoin_np
274279
pthread_getw32threadhandle_np
275280
pthread_timechange_handler_np
276281
pthread_delay_np
277282
pthread_getunique_np
283+
pthread_attr_getaffinity_np
284+
pthread_attr_setaffinity_np
278285
pthread_getaffinity_np
279286
pthread_setaffinity_np
280287
pthread_mutexattr_getkind_np

ChangeLog

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,34 @@
1+
2013-06-19 Ross Johnson <ross dot johnson at homemail dot com dot au>
2+
3+
* pthread_attr_init.c: Initialise thread name element.
4+
* create.c: Initialise thread name from attributes.
5+
6+
2013-06-13 Ross Johnson <ross dot johnson at homemail dot com dot au>
7+
8+
* pthread_setname_np.c: Initial version.
9+
* pthread_getname_np.c: Initial version.
10+
* pthread_attr_setname_np.c: Initial version.
11+
* pthread_attr_getname_np.c: Initial version.
12+
* pthread.h: Add new prototypes.
13+
* implement.h (pthread_attr_t_): Add "thrname" element.
14+
* (ptw32_thread_t): Add "name" element.
15+
16+
2013-06-06 Ross Johnson <ross dot johnson at homemail dot com dot au>
17+
18+
* pthread.h (_POSIX_THREAD_ATTR_STACKADDR): Now set to -1. The API
19+
prototypes are defined but return ENOSYS; previously the addr value was
20+
stored in the attribute struct and retreivable but unused.
21+
* pthread_attr_setstackaddr.c: Should return ENOSYS rather than silently
22+
ignore the setting.
23+
* pthread_attr_getstackaddr.c: Likewise.
24+
* pthread_attr_getaffinity_np.c: Initial version.
25+
* pthread_attr_setaffinity_np.c: Initial version.
26+
27+
2013-05-01 Andrew Chernow <achernow at gmail dot com>
28+
29+
* dll.c: Add invocation of thread detach logic for static linked
30+
applications for MSVC8.0 or later builds.
31+
132
2012-12-19 Jason Baker <jason underscore baker at symantec dot com>
233

334
* pthread_win32_attach_detach_np.c (pthread_win32_process_attach_np):

GNUmakefile

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ GCE_CFLAGS = $(PTW32_FLAGS) -mthreads
140140

141141
## Mingw
142142
#MAKE ?= make
143-
CFLAGS = $(OPT) $(XOPT) $(ARCH) -I. -DHAVE_CONFIG_H -Wall
143+
CFLAGS = $(OPT) $(XOPT) $(ARCH) -I. -DHAVE_CONFIG_H -DMINGW_HAS_SECURE_API -Wall
144144

145145
OBJEXT = o
146146
RESEXT = o
@@ -172,6 +172,8 @@ PTHREAD_DEF = pthread.def
172172

173173
help:
174174
@ echo "Run one of the following command lines:"
175+
@ echo "$(MAKE) clean all (build targets GC, GCE, GC-static, GCE-static)"
176+
@ echo "$(MAKE) clean all-tests (build and test all non-debug targets below)"
175177
@ echo "$(MAKE) clean GC (to build the GNU C dll with C cleanup code)"
176178
@ echo "$(MAKE) clean GC-debug (to build the GNU C debug dll with C cleanup code)"
177179
@ echo "$(MAKE) clean GCE (to build the GNU C dll with C++ exception handling)"

Makefile

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -88,12 +88,12 @@ all:
8888
TEST_ENV = CFLAGS="$(CFLAGS) /DNO_ERROR_DIALOGS"
8989

9090
all-tests:
91-
$(MAKE) /E realclean VC-small-static$(XDBG)
92-
cd tests && $(MAKE) /E clean VC-small-static$(XDBG) $(TEST_ENV) && $(MAKE) /E clean VCX-small-static$(XDBG) $(TEST_ENV)
93-
$(MAKE) /E realclean VCE-small-static$(XDBG)
94-
cd tests && $(MAKE) /E clean VCE-small-static$(XDBG) $(TEST_ENV)
95-
$(MAKE) /E realclean VSE-small-static$(XDBG)
96-
cd tests && $(MAKE) /E clean VSE-small-static$(XDBG) $(TEST_ENV)
91+
# $(MAKE) /E realclean VC-small-static$(XDBG)
92+
# cd tests && $(MAKE) /E clean VC-small-static$(XDBG) $(TEST_ENV) && $(MAKE) /E clean VCX-small-static$(XDBG) $(TEST_ENV)
93+
# $(MAKE) /E realclean VCE-small-static$(XDBG)
94+
# cd tests && $(MAKE) /E clean VCE-small-static$(XDBG) $(TEST_ENV)
95+
# $(MAKE) /E realclean VSE-small-static$(XDBG)
96+
# cd tests && $(MAKE) /E clean VSE-small-static$(XDBG) $(TEST_ENV)
9797
$(MAKE) /E realclean VC$(XDBG)
9898
cd tests && $(MAKE) /E clean VC$(XDBG) $(TEST_ENV) && $(MAKE) /E clean VCX$(XDBG) $(TEST_ENV)
9999
$(MAKE) /E realclean VCE$(XDBG)

NEWS

Lines changed: 31 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,8 @@ we are successfully passing the full test suite with all build
2121
configurations. If you see failures then please consider how your
2222
toolchains might be contributing to the failure. See the README file
2323
for more detailed descriptions of the toolchains and test systems that
24-
we have used to get the tests to pass successfully.
24+
we have used to get the tests to pass successfully. We recommend
25+
MinGW64 over MinGW32 for both 64 and 32 bit builds.
2526

2627
New Features
2728
------------
@@ -32,11 +33,28 @@ pthread_tryjoin_np()
3233
sched_getaffinity()
3334
sched_setaffinity()
3435
pthread_getaffinity_np()
35-
pthread_getaffinity_np()
36+
pthread_setaffinity_np()
37+
pthread_attr_getaffinity_np()
38+
pthread_attr_setaffinity_np()
3639
- added for compatibility with Linux and other libgcc-based systems.
3740
The macros to manipulate cpu_set_t objects (the cpu affinity mask
3841
vector) are also defined: CPU_ZERO, CPU_CLR, CPU_SET, CPU_EQUAL,
3942
CPU_AND, CPU_OR, CPU_XOR, CPU_COUNT, CPU_ISSET.
43+
pthread_getname_np()
44+
pthread_setname_np()
45+
pthread_attr_getname_np()
46+
pthread_attr_setname_np()
47+
- added for compatibility with other POSIX implementations. Because
48+
some implementations use different *_setname_np() prototypes
49+
you can define one of the following macros when building the library:
50+
PTW32_COMPATIBILITY_BSD (compatibility with NetBSD, FreeBSD)
51+
PTW32_COMPATIBILITY_TRU64
52+
If not defined then compatibility is with Linux and other equivalents.
53+
We don't impose a strict limit on the length of the thread name for the
54+
default compatibility case. Unlike Linux, no default thread name is set.
55+
For MSVC builds, the thread name if set is made available for use by the
56+
MSVS debugger, i.e. it should be displayed within the debugger to
57+
identify the thread in place of/as well as a threadID.
4058

4159
Builds:
4260
New makefile targets have been added and existing targets modified or
@@ -47,6 +65,12 @@ The makefiles now know how to build both 32 and 64 bit versions if
4765
the toolchain allows it (MinGW only). See the README file "Building
4866
with ..." sections for details.
4967

68+
Static linking:
69+
The autostatic functionality has been extended so that builds using
70+
MSVC8 and later no longer require apps to call
71+
pthread_win32_thread_detach_np(). That is, all of the DllMain
72+
functionality is not automatic for static linking for these builds.
73+
5074
Bug Fixes
5175
---------
5276
Small object file static linking now works. The autostatic.c code is
@@ -85,6 +109,11 @@ pthread_win32_process_attach_np() fix potential failure/security around
85109
finding and loading of QUSEREX.DLL.
86110
- Jason Baker
87111

112+
_POSIX_THREAD_ATTR_STACKADDR is now set equal to -1 in pthread.h. As a
113+
consequence pthread_attr_setstackaddr() now returns ENOSYS. Previously
114+
the value was stored and could be retrieved but was otherwise unused.
115+
pthread_attr_getstackaddr() returns ENOSYS correspondingly.
116+
- Ross Johnson
88117

89118
RELEASE 2.9.1
90119
-------------

README.NONPORTABLE

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,7 @@ pthread_mutexattr_getkind_np(pthread_mutexattr_t * attr, int *kind)
110110
PTHREAD_MUTEX_ERRORCHECK
111111
PTHREAD_MUTEX_RECURSIVE
112112

113+
113114
int
114115
pthread_delay_np (const struct timespec *interval)
115116

@@ -138,14 +139,14 @@ pthread_delay_np (const struct timespec *interval)
138139
0 Successful completion.
139140
[EINVAL] The value specified by interval is invalid.
140141

142+
141143
int
142144
pthread_timedjoin_np (pthread_t thread, void **value_ptr, const struct timespec *abstime)
143145

144146
int
145147
pthread_tryjoin_np (pthread_t thread, void **value_ptr)
146148

147149
These function is added for compatibility with Linux.
148-
149150

150151

151152
int
@@ -156,6 +157,7 @@ pthread_num_processors_np (void)
156157
processors available to the process, which can be a lower number
157158
than the system's number, depending on the process's affinity mask.
158159

160+
159161
BOOL
160162
pthread_win32_process_attach_np (void);
161163

@@ -185,6 +187,23 @@ pthread_win32_thread_detach_np (void);
185187
pthread_win32_process_attach_np() which will return FALSE
186188
if pthreads-win32 initialisation fails.
187189

190+
191+
int
192+
pthread_attr_getaffinity_np (pthread_attr_t * attr, size_t cpusetsize, cpu_set_t * cpuset);
193+
194+
int
195+
pthread_attr_setaffinity_np (pthread_attr_t * attr, size_t cpusetsize, const cpu_set_t * cpuset);
196+
197+
int
198+
pthread_getaffinity_np (pthread_t thread, size_t cpusetsize, cpu_set_t * cpuset);
199+
200+
int
201+
pthread_setaffinity_np (pthread_t thread, size_t cpusetsize, const cpu_set_t * cpuset);
202+
203+
Manipulate the CPU affinity of threads. Compatibility with libgcc-based pthreads
204+
implementations.
205+
206+
188207
int
189208
pthreadCancelableWait (HANDLE waitHandle);
190209

@@ -354,7 +373,7 @@ rewritten.]
354373

355374
Doesn't the compiler take care of padding?
356375

357-
The C89 and later standards only effectively guarrantee element-by-element
376+
The C89 and later standards only effectively guarantee element-by-element
358377
equivalence following an assignment or pass by value of a struct or union,
359378
therefore undefined areas of any two otherwise equivalent pthread_t instances
360379
can still compare differently, e.g. attempting to compare two such pthread_t
@@ -574,7 +593,7 @@ bitclear((void*) &non-id, (void*) pthread_normalize(&id), sizeof(pthread_t));
574593

575594
A pthread_t type change proposal to neutralise the effects of padding
576595

577-
Even if pthread_nornalize() is available, padding is still a problem because
596+
Even if pthread_normalize() is available, padding is still a problem because
578597
the standard only garrantees element-by-element equivalence through
579598
copy operations (assignment and pass-by-value). So padding bit values can
580599
still change randomly after calls to pthread_normalize().

autostatic.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,11 @@
3939
# include <config.h>
4040
#endif
4141

42+
#if defined(PTW32_STATIC_LIB) && defined(_MSC_VER) && _MSC_VER >= 1400
43+
# undef PTW32_STATIC_LIB
44+
# define PTW32_STATIC_TLSLIB
45+
#endif
46+
4247
#include "pthread.h"
4348
#include "implement.h"
4449

common.mk

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,16 +16,20 @@ STATIC_OBJS = \
1616
errno.$(OBJEXT) \
1717
global.$(OBJEXT) \
1818
pthread_attr_destroy.$(OBJEXT) \
19+
pthread_attr_getaffinity_np.$(OBJEXT) \
1920
pthread_attr_getdetachstate.$(OBJEXT) \
2021
pthread_attr_getinheritsched.$(OBJEXT) \
22+
pthread_attr_getname_np.$(OBJEXT) \
2123
pthread_attr_getschedparam.$(OBJEXT) \
2224
pthread_attr_getschedpolicy.$(OBJEXT) \
2325
pthread_attr_getscope.$(OBJEXT) \
2426
pthread_attr_getstackaddr.$(OBJEXT) \
2527
pthread_attr_getstacksize.$(OBJEXT) \
2628
pthread_attr_init.$(OBJEXT) \
29+
pthread_attr_setaffinity_np.$(OBJEXT) \
2730
pthread_attr_setdetachstate.$(OBJEXT) \
2831
pthread_attr_setinheritsched.$(OBJEXT) \
32+
pthread_attr_setname_np.$(OBJEXT) \
2933
pthread_attr_setschedparam.$(OBJEXT) \
3034
pthread_attr_setschedpolicy.$(OBJEXT) \
3135
pthread_attr_setscope.$(OBJEXT) \
@@ -52,6 +56,7 @@ STATIC_OBJS = \
5256
pthread_equal.$(OBJEXT) \
5357
pthread_exit.$(OBJEXT) \
5458
pthread_getconcurrency.$(OBJEXT) \
59+
pthread_getname_np.$(OBJEXT) \
5560
pthread_getschedparam.$(OBJEXT) \
5661
pthread_getspecific.$(OBJEXT) \
5762
pthread_getunique_np.$(OBJEXT) \
@@ -99,6 +104,7 @@ STATIC_OBJS = \
99104
pthread_setcancelstate.$(OBJEXT) \
100105
pthread_setcanceltype.$(OBJEXT) \
101106
pthread_setconcurrency.$(OBJEXT) \
107+
pthread_setname_np.$(OBJEXT) \
102108
pthread_setschedparam.$(OBJEXT) \
103109
pthread_setspecific.$(OBJEXT) \
104110
pthread_spin_destroy.$(OBJEXT) \
@@ -176,8 +182,12 @@ PTHREAD_SRCS = \
176182
ptw32_spinlock_check_need_init.c \
177183
pthread_attr_init.c \
178184
pthread_attr_destroy.c \
185+
pthread_attr_getaffinity_np.c \
186+
pthread_attr_setaffinity_np.c \
179187
pthread_attr_getdetachstate.c \
180188
pthread_attr_setdetachstate.c \
189+
pthread_attr_getname_np.c \
190+
pthread_attr_setname_np.c \
181191
pthread_attr_getscope.c \
182192
pthread_attr_setscope.c \
183193
pthread_attr_getstackaddr.c \
@@ -260,6 +270,8 @@ PTHREAD_SRCS = \
260270
pthread_attr_getschedparam.c \
261271
pthread_attr_setinheritsched.c \
262272
pthread_attr_getinheritsched.c \
273+
pthread_getname_np.c \
274+
pthread_setname_np.c \
263275
pthread_setschedparam.c \
264276
pthread_getschedparam.c \
265277
sched_get_priority_max.c \

create.c

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,9 +152,20 @@ pthread_create (pthread_t * tid,
152152

153153
if (a != NULL)
154154
{
155+
cpu_set_t none;
156+
cpu_set_t attr_cpuset;
157+
((_sched_cpu_set_vector_*)&attr_cpuset)->_cpuset = a->cpuset;
158+
155159
stackSize = (unsigned int)a->stacksize;
156160
tp->detachState = a->detachstate;
157161
priority = a->param.sched_priority;
162+
CPU_ZERO(&none);
163+
if (! CPU_EQUAL(&attr_cpuset, &none))
164+
{
165+
tp->cpuset = a->cpuset;
166+
}
167+
if (a->thrname != NULL)
168+
tp->name = _strdup(a->thrname);
158169

159170
#if (THREAD_PRIORITY_LOWEST > THREAD_PRIORITY_NORMAL)
160171
/* WinCE */

0 commit comments

Comments
 (0)