Clang 5.0.0(svn) reports warnings on <pthread_types.h> for C99 constructs
when used with strict -std=c89.
Restrict designated initializers usage to C99 or newer code.
C89 and C++ will share the same code without extension of designated
initializers.
PR 52285
functions are used for destructors of thread_local objects.
If a pending destructor exists, prevent unloading of shared objects.
Introduce __dl_cxa_refcount interface for this purpose. When the last
reference is gone and the object has been dlclose'd before, the
unloading is finalized.
Ideally, __cxa_thread_atexit_impl wouldn't exist, but libstdc++ insists
on providing __cxa_thread_atexit as direct wrapper without further
patching.
complementary writable sysctl for the initial guard size of threads
created via pthread_create. Let the existing attribut accessors do the
right thing. Raise the default guard size for threads to 64KB.
libpthread_dbg(3) is a remnant library from the M:N thread model
(pre-NetBSD-5.0) API to introspect threads within a process and for use
of debuggers.
Currently in the 1:1 model it's not used in GDB neither in LLDB and it's
not either planned to be used. It's current function to read pthread_t
structures is realizable within a regular debugger capable to
instrospect objects within a tracee (GDB, LLDB...).
Remaining users of this API can still use this library from
pkgsrc/devel/libpthread_dbg.
Sponsored by <The NetBSD Foundation>
Add missing __restrict keyword to the first pointer parameter.
It was already used for the second argument, should not be a functional
change and generated code should be the same.
This new form is now aligned with POSIX.
by Andy Doran. Also document the get/set pshared thread calls as not
implemented, and add a skeleton implementation that is disabled.
XXX: document _sched_protect(2).
pthread types in C++ builds, attempt 2.
The problem with attempt 1 was making assumptions of what the MD
__cpu_simple_lock_t (declared volatile) looks like. To get a same type
except non-volatile, we change the MD type to __cpu_simple_lock_nv_t
and typedef __cpu_simple_lock_t as a volatile __cpu_simple_lock_nv_t.
IMO, __cpu_simple_lock_t should not be volatile at all, but changing it
now is too risky.
Fixes at least Rumprun w/ gcc 5.1/5.2. Furthermore, the mpd application
(and possibly others) will no longer require NetBSD-specific patches.
Tested: build.sh for i386, Rumprun for x86_64 w/ gcc 5.2.
Based on the patch from Christos in lib/49989.
__cpu_simple_lock_t (because it doesn't). Instead, use sizeof/alignof
with a struct { uchar[] }.
Fixes problem in previous commit, caught by Nick Hudson.
member initializer. This does not work for volatile types. Since C++
does not touch the guts of those types, redefine them as non-volatile.
Fixes libc++ compilation with g++ 5.1, as reported in PR lib/49989.
NetBSD's PTHREAD_KEYS_MAX is set to 256, which is low compared to
other systems like Linux (1024) or MacOS X (512). As a result some
setups tested on Linux will exhibit problems on NetBSD because of
pthread_keys usage beyond the limit. This happens for instance on
Apache with various module loaded, and in this case no particular
developper can be blamed for going beyond the limit, since several
modules from different sources contribute to the problem.
This patch makes the limit conigurable through the PTHREAD_KEYS_MAX
environement variable. If undefined, the default remains unchanged
(256). In any case, the value cannot be lowered below POSIX-mandated
_POSIX_THREAD_KEYS_MAX (128).
While there:
- use EXIT_FAILURE instead of 1 when calling err(3) in libpthread.
- Reset _POSIX_THREAD_KEYS_MAX to POSIX mandated 128, instead of 256.
A concrete result is enabling unpatched libpthread to run on the
rumprun stacks (e.g. Xen and bare metal) with a non-NetBSD scheduler.
Those schedulers hook into the existing _lwp_frobnitz() NetBSD syscall
interfaces (well, "syscall" interfaces in that scenario ;)
More specifically about the change itself:
1) instead of calling _lwp_makecontext() followed by _lwp_create()
and passing the entry point in ucontext_t (MD) through the calls, roll
the calls into pthread__makelwp() and allow alternate implementations
for that MI interface.
2) allow compile-time overriding of __lwp_gettcb_fast() or
__lwp_getprivate_fast, which are inline and leak MD scheduler/thread
details into libpthread
Additionally, two small nits:
I) define LIB=pthread before including mk.conf so that it's possible
to test for LIB==pthread in mk.conf
II) make it possible to leave out pthread_cancelstub.c. This is required
by the current implementation of rumprun-posix (i.e. rumprun on
POSIX hosts) due to symbol collisions. It needs to be fixed properly
some day, but for now allows an almost-correct libpthread to run.
I am sure @justin will be happy to explain the details ;)
no change to NetBSD
tested: anita+atf
non-interlocked CAS in the fast unlock path -- it is unsafe to test for
the waiters-bit while the owner thread is running, we have to spin for
the owner or its state change to be sure about the presence of the bit.
Split off the logic into the pthread__mutex_setwaiters() routine.
This is a partial fix to the named lockup problem (also see PR/44756).
It seems there is another race which can be reproduced on faster CPUs.