Commit Graph

832 Commits

Author SHA1 Message Date
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
yamt
93af5b695c add assertions 2013-03-06 11:30:56 +00:00
apb
6cee3c7cf5 Explain what PTHREAD__COMPAT is for. This comment in
src/libpthread/Makefile is adated from a comment in
src/doc/CHANGES.prev.
2013-02-25 17:04:46 +00:00
riastradh
d86328195e Add pthread_condattr_setclock(3) man page link. 2013-01-31 20:57:58 +00:00
dsl
2bf5f9db37 Don't rely on sys/lwp.h includeing sys/resource.h for us. 2013-01-01 18:42:39 +00:00
christos
fe230c9d39 Don't call the destructor in pthread_key_delete() following the standard. 2012-11-22 08:32:36 +00:00
christos
55f47ec332 Replace the simple implementation of pthread_key_{create,destroy}
and pthread_{g,s}etspecific functions, to one that invalidates
values of keys in other threads when pthread_key_delete() is called.
This fixes chromium, which expects pthread_key_delete() to do
cleanup in all threads.
2012-11-21 19:19:24 +00:00
christos
cb292d56ab add argsused 2012-11-14 23:25:05 +00:00
uwe
ed34834025 Mark up (unsupported) PTHREAD_PROCESS_SHARED with .Dv macro. 2012-11-12 23:34:50 +00:00
uwe
7fe27706ff Refer to init_routine in the DESCRIPTION section with .Fa instead of .Fn 2012-11-12 23:28:11 +00:00
uwe
b5c99d4306 Use
.Vt type var No = Dv INITIALIZER;

to provide examples of static initialization in SYNOPSIS section.
.Va macro does the wrong thing (check groff PostScript output) and the
need for .Pp kludge (now dropped) should have been an indication too.

While here move static initialization example to be right after the
declaration of *_init().
2012-11-12 23:11:05 +00:00
uwe
b89e4203ae Each get function "has" a set counterpart, it doesn't "contain" it. 2012-11-10 23:12:36 +00:00
apb
9d94c0263d Remove duplicate "const" modifier found by clang -Wduplicate-decl-specifier 2012-11-06 09:03:03 +00:00
rmind
d79b47c370 libpthread: replace the use of obsolete sys/tree.h interface with rbtree(9). 2012-11-03 23:42:27 +00:00
wiz
2268525138 Fix pasto. 2012-11-03 09:20:36 +00:00
christos
2a29ccd3da add pthread_condattr_setclock(3) 2012-11-03 03:10:50 +00:00
christos
284dc1a8fd cast return of sysconf 2012-11-03 03:10:35 +00:00