Commit Graph

861 Commits

Author SHA1 Message Date
kamil 133682b8bb Support <pthread_typs.h> on C89 compilers
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
2017-09-09 23:21:45 +00:00
martin 7f878ea30c pthread__attr_init_private:
malloc+memset -> calloc. Also initialize all values to the proper
defaults.
This fixes the "rustc panic" discussed on pkgsrc-users.
OK: joerg
2017-08-01 12:31:45 +00:00
skrll 8342d7e564 Typo in comment 2017-07-17 20:24:07 +00:00
joerg e5678be828 Implement __cxa_thread_atexit and __cxa_thread_atexit_impl. This
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.
2017-07-11 15:21:31 +00:00
christos e7a07d38ee PR/52386: Use the number of iterations we document. 2017-07-09 20:21:08 +00:00
wiz 01869ca4d2 Remove workaround for ancient HTML generation code. 2017-07-03 21:28:48 +00:00
joerg d3a99cd597 Do not look at environmental variables for suid/guid binaries. 2017-07-02 17:13:07 +00:00
joerg 5f391f4ae2 Export the guard size of the main thread via vm.guard_size. Add a
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.
2017-07-02 16:41:32 +00:00
maya 38f9590df4 Remove outdated CAVEATS.
Not sure everything is standards compliant, but I've been told non-default
values are supported and pshared exists.
2017-03-28 17:42:52 +00:00
njoly 9be71c742b Fix man page ERRORS section for (clock,pthread}_getcpuclockid to match
reality.
2017-03-05 18:42:51 +00:00
njoly 5e0724b3f9 Fix {clock,pthread}_getcpuclockid to return an error number on
failure, to match OpenGroup specifications.
2017-03-04 11:16:33 +00:00
kamil 0892a29a1a libpthread_dbg(3) deletion from the base distribution
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>
2017-02-08 03:44:40 +00:00
njoly cada2c18c7 Fix a typo : pthread_mutexaddr_init -> pthread_mutexattr_init. 2017-02-02 10:48:22 +00:00
wiz fe65e38bd3 Bump date for previous. 2016-11-24 12:19:28 +00:00
kamil 6c74bd40be Add reference in SEE ALSO to pthread_dbg(3)
Sponsored by <The NetBSD Foundation>
2016-11-22 00:32:09 +00:00
christos 6e03f6000c Don't spin if we already own the mutex, otherwise we will get stuck spinning
forever, fixes timemutex{1,2} tests.
2016-10-31 23:53:12 +00:00
kamil 06b9d77598 POSIX harder the pthread_mutex_timedlock(3) prototype
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.
2016-10-30 23:26:33 +00:00
christos 285a8995e1 unnamed unions need special treatment since they need braced initializers
for old style initializations.
2016-07-20 21:02:04 +00:00
christos 353946982c cplusplus does not like complex named initializers... 2016-07-20 20:06:04 +00:00
christos b826eda4de use named initializers 2016-07-20 19:26:52 +00:00
skrll 3b2c691c07 Use anonymous union for ptm_ceiling and old __pthread_spin_t field to
maintain backward compatibility and fix hppa build.  hppa has an non-
integer type __pthread_spin_t
2016-07-17 13:49:43 +00:00
skrll d946c609af KNF 2016-07-16 12:58:11 +00:00
wiz b9737c740d Fix some lint.
Too much or too little whitespace;
improve macro usage;
add missing .El;
merge error sections for same error code.
2016-07-05 10:04:17 +00:00
christos 7cf7644fc7 GSoC 2016 Charles Cui: Implement thread priority protection based on work
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).
2016-07-03 14:24:58 +00:00
wiz a0a33836af Formatting, typos, whitespace fixes. 2016-04-24 09:01:45 +00:00
christos 3c50b65c77 commit the right file. 2016-04-24 00:05:28 +00:00
christos ed7dbad892 bump 2016-04-23 23:23:17 +00:00
christos d394d2a9b5 Add pthread_getcpuclockid(3) 2016-04-23 23:12:19 +00:00
dholland eb0c9743f2 _SC_PAGESIZE is not the page size; it's a symbolic code for retrieving
the page size.
2016-04-07 06:21:48 +00:00
pooka 01d7ebdd80 Fix PTHREAD_FOO_INITIALIZER for C++ by not using volatile in the relevant
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.
2015-08-27 12:30:50 +00:00
pooka 2d85d43b0f Revert 1.14 now that the arduous task of fixing rumphijack to allow
mmap() in early init has been completed.
2015-08-25 13:46:23 +00:00
pooka a83d5ed5dd Rev 1.14 was nice except it didn't work with _INITIALIZER, which
sort of negates the whole point ... so revert everything while in
drawing board mode.
2015-06-26 11:25:22 +00:00
pooka 24bdf1ef99 Don't depend on __CPU_SIMPLE_LOCK_PAD to determine the type of
__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.
2015-06-26 10:05:17 +00:00
pooka 7cc7e65751 C++ (namely libc++) expects to be using PTHREAD_FOO_INITIALIZER as a
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.
2015-06-26 01:33:08 +00:00
christos 8c0cb8e7ec Thanks rump for not letting us use even mmap during initialization. 2015-05-30 14:42:26 +00:00
wiz dbea196857 Bump date for previous.
New sentence, new line.
2015-05-29 18:00:51 +00:00
christos cb27e6553e Fix previous: Can't use calloc/malloc before we complete initialization
of the thread library, because malloc uses pthread_foo_specific, and it will
end up initializing itself incorrectly.
2015-05-29 16:05:13 +00:00
manu 841339f07f Make PTHREAD_KEYS_MAX dynamically adjustable
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.
2015-05-29 07:37:31 +00:00
martin f89f6560d4 Dummy ia64 support 2015-04-17 13:14:19 +00:00
matt b12144c585 We have _REG_SP so use it. 2015-03-31 01:36:27 +00:00
pooka aa91aeb3c8 include correct header for "last minute just-in-case defensive addition
that's too trivial to check"
2014-12-17 01:49:08 +00:00
pooka 082d249a16 Allow for arbitrary MI scheduler implementations.
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
2014-12-16 20:05:54 +00:00
matt 6cf6fe02a9 New files for Userland support of UCB RISC-V (both 32-bit and 64-bit) 2014-09-19 17:36:24 +00:00
matt 27620987b8 New files for OR1K support 2014-09-03 19:34:25 +00:00
matt 11614bb2b2 MKCOMPAT fixes for when compat MACHINE_CPU != normal MACHINE_CPU 2014-08-10 23:25:49 +00:00
matt beb9c6d1b5 Preliminary files for AARCH64 (64-bit ARM) support.
Enough for a distribution build.
2014-08-10 05:47:35 +00:00
riastradh 6cb10275d0 Merge riastradh-drm2 to HEAD. 2014-03-18 18:20:35 +00:00
dholland 1e9d60e3bf typo 2014-03-12 07:32:46 +00:00
matt 1de2b6f186 This is no different from the 32bit powerpc one.
Remove the redundancy.
2014-03-07 07:26:42 +00:00
rmind 2e17c78b61 pthread__mutex_lock_slow: fix the handling of a potential race with the
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.
2014-02-03 15:51:01 +00:00