Commit Graph

848 Commits

Author SHA1 Message Date
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
christos cdce479a47 remove compatibility code for handling CLOCK_MONOTONIC and handle it in the
syscall directly.
2014-01-31 20:44:01 +00:00
christos de79b4937c PR/44756: Sad Clouds: Prevent leakage of errno = ESRCH from _lwp_park. This
has two parts:
	- in pthread_cond_timedwait() if the thread we are trying to unpark
	  exited, retry the the _lwp_park call without it.
	- pthread_mutex() was affecting errno since it is calling _lwp_park()
	  from pthread_mutex_lock_slow(). preserve the original errno.
Note that the example problem still causes an occassional deadlock on machines
with many CPUs and it is the same deadlock we observe with named.
2014-01-31 19:22:00 +00:00
matt fa741d8823 Use MACHINE_CPU for m68k. Use similar logic for both tests. 2013-10-09 22:33:41 +00:00
matt 06cb4b73b7 Add support for an optional ARCHSUBDIR/Makefile.inc 2013-08-15 22:38:24 +00:00
matt 77f07e0bd7 Use the thumb1 versions of sev/wfe for thumb && armv6+.
if using armv5t don't do anything for thumb.
2013-08-15 22:37:29 +00:00
joerg a6c6eb019c Some architectures can't create unwind tables without the frame pointer,
so don't use -fomit-frame-pointer on those.
2013-08-12 17:15:46 +00:00
wiz a5684d07dd Use Mt for email addresses. 2013-07-20 21:39:55 +00:00
christos 53c7ca1dc2 s/inherited/inherit/ 2013-05-10 21:06:14 +00:00
christos bbae94036a bump for pthread_cond_setclock 2013-04-03 15:45:21 +00:00
christos 5ef4443346 for safety, declare mono on the outermost block it is used. 2013-04-01 13:28:21 +00:00
christos 1f8d3d6eb5 PR/47703: Yasushi Oshima: pthread_cond_timedwait() does not wait
after call pthread_condattr_setclock(CLOCK_MONOTONIC)

_lwp_park(2) expects a realtime clock, and it gets passed a monotonic
one.  Since monotonic < real, it never sleeps. This patch adjusts
the monotonic clock to be a real one before it passes is to
_lwp_park(2). This is the minimal hacky fix and it will be fixed
properly in _lwp_park(2) in the future.

XXX: pullup to 6.
2013-03-28 18:07:12 +00:00
christos 71d484f921 - Allow libpthread to be dlopened again, by providing libc stubs to libpthread.
- Fail if the dlopened libpthread does pthread_create(). From manu@
- Discussed at length in the mailing lists; approved by core@
- This was chosen as the least intrusive patch that will provide
  the necessary functionality.
XXX: pullup to 6
2013-03-21 16:49:11 +00:00
yamt a74bc62145 add comments
whitespace
2013-03-06 11:31:34 +00:00