Commit Graph

894 Commits

Author SHA1 Message Date
maya 07975b2231 Make CLEANFILES actually work. .TARGET is not defined when not in a target
rule.

Thanks xtos for the heads up.
2019-05-07 18:45:37 +00:00
maya 53af5ae4cc Replace the link command for libpthread.a so that we create a single section
with all the libpthread symbols in it.
This makes -lpthread behave like to -Wl,--whole-archive -lpthread.

This avoids a situation where threaded static binaries use some libc thread
stubs, which are racy.

Fixes PR lib/54001: call_once2_32, call_once2_static test cases failing on
amd64 since gcc7 import.

Suggested by Jonathan Wakely, thanks!
2019-05-07 18:12:53 +00:00
kamil 45dae6038c Avoid incompatible function pointer casts in thrd_create(3)
Use an intermediate function trampoline to workaround different function
pointer prototypes.

While there, correct scenario returning thrd_nomem from thrd_create(3).
In practice ENOMEM is rarely returned from pthread(3).

Older code worked on tested ports, but was depending on unneeded UB.
2019-04-29 20:11:43 +00:00
wiz 1dcc590110 Fix some typos, improve wording. 2019-04-27 10:57:11 +00:00
kamil c3c6e74f96 Drop error path from C11 call_once
The original implementation of C11 threads(3) contained check for error
paths, but it was stripped in the calls that are documented to return
no status from an operation. Do the same in call_once(3).
2019-04-24 21:41:15 +00:00
kamil d39119472e Introduce minor changes to the C11 threading library
Switch tss_t type from int to pthread_key_t (no functional change as
pthread_key_t was already typedefed as int).

Noted by <enh from Google>.

Use C11 _Noreturn in thrd_exit(3) instead of NetBSD specific __dead.
The former is documented in the standard as an attribute of thrd_exit(3),
the latter is more portable to pre-C11 compilers, however C11 thread
support library needs C11 compiler for TLS anyway. __dead made a little bit
more point 3 years ago than today as 3 years ago pre-C11 compilers were
more common.
2019-04-24 18:47:54 +00:00
kamil 945ffcea06 Bump the libpthread(3) minor number to 4
Added C11 Threading library support.
2019-04-24 13:01:52 +00:00
kamil a9ca1710c0 Add a complete C11 threads(3) implementation
C11 Thread support library is a portable threading C API between OSs,
similar to std::threads in the C++ world.

The library is implemented as a thin shim over POSIX interfaces.

NetBSD implements the API as a part of the POSIX threading library
(libpthread(3)).

C11 threads(3) are in the process of making them an integral part
of the POSIX standard. The interface has been implemented in major
OSs and used with stopgap libraries for older versions of them.

C11 threading library is already used (with a stopgap implementation)
in the NetBSD distribution in MESA.

Original implementation by myself from 2016.

ATF tests are new and cover almost all interfaces.

Proposed on tech-userlevel@.
2019-04-24 11:43:19 +00:00
christos 2cb70116d4 Jemalloc initializes mutexes before we become threaded and expects to use
them later.
2019-03-05 22:49:38 +00:00
christos 939c050d54 Transfer all the keys that were created in the libc stub implementation
to the pthread tsd implementation when the main thread is created.
This corrects a problem where a process created keys before libpthread
was loaded (either from the libc constructor or because libpthread
was dlopened later). This fixes a problem with jemalloc which creates
keys in the constructor.
2019-03-05 01:35:52 +00:00
thorpej 68e270a267 Implement support for "pshared" POSIX semaphores.
Fixes lib/53273 (and Firefox's multi-process tab feature).
2019-02-03 03:20:23 +00:00
skrll e9071591eb G/C __APCS_26__ support 2018-11-22 20:38:59 +00:00
maya 591f556772 Add a todo item for a future major bump (rename many symbols) 2018-09-09 07:24:59 +00:00
kamil 66f17364ec Drop a duplicate instruction line
No functional change intended.
2018-08-19 02:10:42 +00:00
kre 65afe3be98 PR lib/53477 (rudolf at eq.cz) - correct an obvious mistake. 2018-07-28 14:00:19 +00:00
christos aa66956410 But set NOSANITIZER 2018-06-09 23:45:56 +00:00
christos 64715b9aa8 We can't build those three with MKSANITIZER, they are used too early. 2018-06-09 22:41:55 +00:00
chs 9f52f2295e remove hard-coded -fomit-frame-pointer for pthread stuff,
let these use the same setting as the rest of the tree.
the performance difference is marginal and this allows
dtrace ustack() to work better.
2018-02-25 18:51:18 +00:00
kamil 6dca39b9a1 Remove namespace restriction from pthread_condattr_{g,s}etclock(3)
These functions were marked as _NETBSD_SOURCE when introduced to the
sources. In fact they are regular POSIX threading functions available
since the 2001 standard. There is an older mention about alignment with
"IEEE Std 1003.1j-2000".

This corrects usage of these functions when a source code is compiled
with a POSIX namespace option.
2018-02-20 05:10:51 +00:00
christos 97e40f12ae fix duplicate declaration of pthread_atfork in unistd.h 2018-02-06 20:22:23 +00:00
christos 4491ce1a6d Needs to be protected since it has a timespec argument. Found by lint(1) 2017-12-26 17:00:50 +00:00
kre 93e0a20756 Revert last 2 updates - these are, of course, not needed at all... 2017-12-08 09:59:26 +00:00
kre 4ebaec0fd9 This time do _lwp_park() timeout unconsting correctly not just compilably. 2017-12-08 09:41:16 +00:00
kre 85d957d42b Deal with more lwp_park() timestamp unconsting 2017-12-08 09:24:31 +00:00
christos 01521b4a47 unconst the timestamp 2017-12-08 03:08:19 +00:00
wiz 661e3b5159 Remove superfluous Tn. 2017-10-23 01:03:23 +00:00
abhinav d06479fa8d All the four functions described in the man page conform to POSIX.1 2017-10-22 18:37:01 +00:00
abhinav 3a2c8ba99e Add missing word in the sentence 2017-10-22 18:26:46 +00:00
abhinav 3e5ec8a33f Add missing function names in the NAME section for rest of the man pages in libpthread 2017-10-22 16:37:24 +00:00
abhinav 3aabdfe0ee Remove description of pthread_barrierattr_getpshared and pthread_barrierattr_setpshared
These functions are described in pthread_barrierattr(3) man page
2017-10-22 16:15:02 +00:00
abhinav 3db8282e27 Add rest of the pthread_barrier functions in the NAME section 2017-10-22 16:09:22 +00:00
abhinav 73a3e7fa13 Add pthread_attr_setdetachstate to NAME section 2017-10-22 15:48:11 +00:00
abhinav ccdb3ad6e1 Add pthread_getattr_np to the NAME section 2017-10-22 15:44:21 +00:00
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