aboutsummaryrefslogtreecommitdiff
path: root/lib/libthr
Commit message (Collapse)AuthorAgeFilesLines
* Use uintptr_t for return type of _Unwind_GetCFA.John Baldwin2022-02-201-2/+2
| | | | | | | | | This matches the type in other unwind headers. Reviewed by: dim, emaste Differential Revision: https://reviews.freebsd.org/D34050 (cherry picked from commit 3a502289d316f726fec24087012fabb06313a2bf)
* Use an unsigned 64-bit integer for exception class.John Baldwin2022-02-201-2/+2
| | | | | | | | | | | | This matches the type in other unwind headers (LLVM libunwind, libcxxrt, glibc). NB: include/unwind.h is not installed but is only used by libthr Reviewed by: imp, dim, emaste Differential Revision: https://reviews.freebsd.org/D34049 (cherry picked from commit b84693501af6521487327ec4eb7c6ae0097ac5d7)
* libthr(3): explain some internals of the locks implementationKonstantin Belousov2021-10-081-2/+61
| | | | (cherry picked from commit f5b9747075a9b489226e2a911f8a1597f4b9d072)
* Revert the changes that removed support for old gcc, as stable/12 stillDimitry Andric2021-09-031-0/+3
| | | | | | | | | | | | uses gcc 4.2.1 for mips, powerpc and sparc64. Revert "Revert part of r360964" This reverts commit 2ebf10e7a1ced5d3dc4059d0595743277464d915. Revert "Remove tests for obsolete compilers in the build system" This reverts commit a606cb388f975561c37dbabc2fee82c27ef09929.
* Remove tests for obsolete compilers in the build systemEric van Gyzen2021-09-021-3/+0
| | | | | | | | | | | | Assume gcc is at least 6.4, the oldest xtoolchain in the ports tree. Assume clang is at least 6, which was in 11.2-RELEASE. Drop conditions for older compilers. Reviewed by: imp (earlier version), emaste, jhb Sponsored by: Dell EMC Isilon Differential Revision: https://reviews.freebsd.org/D24802 (cherry picked from commit fac6dee9eb58b2b558fec2aea749460ca623f6d6)
* libthr malloc: support recursion on thr_malloc_umtx.Konstantin Belousov2021-01-181-2/+11
| | | | | | PR: 252579 (cherry picked from commit 85d028223bc2768651f4d44881644ceb5dc2a664)
* libthr: wrap pdfork(2), same as fork(2).Konstantin Belousov2021-01-183-6/+60
| | | | (cherry picked from commit 21f749da82e755aafab127618affeffb86cff9a5)
* MFC r368190:Konstantin Belousov2020-12-071-0/+2
| | | | | | | Ensure that threading library is initialized in pthread_mutex_init(). Notes: svn path=/stable/12/; revision=368401
* MFC r368125:Konstantin Belousov2020-12-051-0/+1
| | | | | | | | | libc: Add pthread_attr_get_np(3) stub, reporting ESRCH. PR: 251112 Notes: svn path=/stable/12/; revision=368361
* MFC r367742-r367743: _umtx_op: documentation and compat32 fixKyle Evans2020-12-042-0/+110
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | r367742: _umtx_op: document UMTX_OP_SEM2_WAIT copyout behavior This clever technique to get a time remaining back was added to support sem_clockwait_np. Reviewed by: kib, vangyzen Differential Revision: https://reviews.freebsd.org/D27160 r367743: _umtx_op: fix a compat32 bug in UMTX_OP_NWAKE_PRIVATE Specifically, if we're waking up some value n > BATCH_SIZE, then the copyin(9) is wrong on the second iteration due to upp being the wrong type. upp is currently a uint32_t**, so upp + pos advances it by twice as many elements as it should (host pointer size vs. compat32 pointer size). Fix it by just making upp a uint32_t*; it's still technically a double pointer, but the distinction doesn't matter all that much here since we're just doing arithmetic on it. Add a test case that demonstrates the problem, placed with the libthr tests since one messing with _umtx_op should be running these tests. Running under compat32, the new test case will hang as threads after the first 128 get missed in the wake. it's not immediately clear how to hit it in practice, since pthread_cond_broadcast() uses a smaller (sleepq batch?) size observed to be around ~50 -- I did not spend much time digging into it. The uintptr_t change makes no functional difference, but i've tossed it in since it's more accurate (semantically). Notes: svn path=/stable/12/; revision=368325
* MFC r368082:Konstantin Belousov2020-11-291-18/+18
| | | | | | | Style. Notes: svn path=/stable/12/; revision=368144
* MFC r361770, r361784, r362032:Konstantin Belousov2020-06-172-17/+61
| | | | | | | | Add pthread_getname_np() and pthread_setname_np() aliases for pthread_get_name_np() and pthread_set_name_np(). Notes: svn path=/stable/12/; revision=362264
* MFC r357985:Konstantin Belousov2020-02-292-7/+30
| | | | | | | Add pthread_peekjoin_np(3). Notes: svn path=/stable/12/; revision=358473
* MFC r357894:Konstantin Belousov2020-02-201-1/+1
| | | | | | | | Return success, instead of ESRCH, from pthread_cancel(3) applied to the exited but not yet joined thread. Notes: svn path=/stable/12/; revision=358140
* Add Makefile.depend.optionsSimon J. Gerraty2019-12-191-1/+0
| | | | | | | | | | | | | | | | | | | | | | | Leaf directories that have dependencies impacted by options need a Makefile.depend.options file to avoid churn in Makefile.depend DIRDEPS for cases such as OPENSSL, TCP_WRAPPERS etc can be set in local.dirdeps-options.mk which can add to those set in Makefile.depend.options See share/mk/dirdeps-options.mk Also update affected Makefile.depend files. MFC of r355616 and r355617 Reviewed by: bdrewery Sponsored by: Juniper Networks Differential Revision: https://reviews.freebsd.org/D22469 Notes: svn path=/stable/12/; revision=355906
* MFC r353334:Mitchell Horne2019-11-021-4/+4
| | | | | | | | | | | | | | | RISC-V: Fix an alignment warning in libthr Compiling with clang gives a loss-of-alignment error due the cast to uint8_t *. Since the TLS is always tcb aligned and TP_OFFSET is defined as sizeof(struct tcb) we can guarantee there is no misalignment. Silence the error by moving the offset into the inline assembly. Reviewed by: br Differential Revision: https://reviews.freebsd.org/D21926 Notes: svn path=/stable/12/; revision=354263
* MFC r352620:Konstantin Belousov2019-09-301-1/+5
| | | | | | | Fix destruction of the robust mutexes. Notes: svn path=/stable/12/; revision=352892
* MFC r351349:Konstantin Belousov2019-08-243-4/+8
| | | | | | | | | Fix _pthread_cancel_enter() and _pthread_cancel_leave() jmptable entries. PR: 240022 Notes: svn path=/stable/12/; revision=351451
* MFC r350481, r350483:Konstantin Belousov2019-08-1421-216/+351
| | | | | | | Avoid conflicts with libc symbols in libthr jump table. Notes: svn path=/stable/12/; revision=351010
* MFC r349912:Konstantin Belousov2019-07-141-1/+1
| | | | | | | | | | Restore ability to pass NULL name argument to pthread_set_name_np(3) to clear the thread name. PR: 239142 Notes: svn path=/stable/12/; revision=349982
* MFC r349299:Konstantin Belousov2019-07-031-0/+1
| | | | | | | | | Add libc stub for pthread_getthreadid_np(3). PR: 238650 Notes: svn path=/stable/12/; revision=349679
* MFC r346158:Konstantin Belousov2019-04-191-2/+3
| | | | | | | | | Do not access mutex memory after unlock. PR: 237195 Notes: svn path=/stable/12/; revision=346371
* MFC r345703:Konstantin Belousov2019-04-1212-2/+408
| | | | | | | Fix initial exec TLS mode for dynamically loaded shared objects. Notes: svn path=/stable/12/; revision=346155
* MFC r344935:Mark Johnston2019-03-251-5/+14
| | | | | | | | | Have pthread_cond_destroy() return EBUSY if the condvar has waiters. PR: 234805 Notes: svn path=/stable/12/; revision=345501
* MFC r339877-r339879,r343564-r343566,r343580,r343754:Konstantin Belousov2019-02-118-10/+172
| | | | | | | | | | | Untangle jemalloc and mutexes initialization. The merge includes required warnings cleanup by arichardson, both to avoid conflicts and to make rtld_malloc.c compilable with the libthr WARNS settings. Notes: svn path=/stable/12/; revision=344011
* libthr: minor spacing cleanup.Pedro F. Giffuni2018-08-211-2/+2
| | | | | | | | | No functional change. X-MFC with: r337992 Notes: svn path=/head/; revision=338125
* POSIX compliance improvements in the pthread(3) functions.Pedro F. Giffuni2018-08-1811-44/+61
| | | | | | | | | | | | | | | | This basically adds makes use of the C99 restrict keyword, and also adds some 'const's to four threading functions: pthread_mutexattr_gettype(), pthread_mutexattr_getprioceiling(), pthread_mutexattr_getprotocol(), and pthread_mutex_getprioceiling. The changes are in accordance to POSIX/SUSv4-2018. Hinted by: DragonFlyBSD Relnotes: yes MFC after: 1 month Differential Revision: D16722 Notes: svn path=/head/; revision=337992
* Add pthread_get_name_np(3).Konstantin Belousov2018-08-174-11/+62
| | | | | | | | | | | | | | | | The function retrieves the thread name previously set by pthread_set_name_np(3). The name is cached in the process memory. Requested by: Willem Jan Withagen <wjw@digiware.nl> Man page update: Yuri Pankov <yuripv@yuripv.net> Reviewed by: ian (previous version) Discussed with: arichardson, bjk (man page) Sponsored by: The FreeBSD Foundation MFC after: 2 weeks Differential revision: https://reviews.freebsd.org/D16702 Notes: svn path=/head/; revision=337983
* Remove unused file.Konstantin Belousov2018-06-161-29/+0
| | | | | | | | | | | The thr_new(2) syscall is called through libc stub. r154212 stopped generating it for libthr but did not cleaned the unused remnants. Sponsored by: The FreeBSD Foundation MFC after: 1 week Notes: svn path=/head/; revision=335258
* Remove references to the LIBC_SCCS and SYSLIBC_SCCS C macros.John Baldwin2018-05-231-4/+1
| | | | | | | | | This language dates back to when libthr was libc_r that included its own syscalls and replaced libc entirely. It hasn't been relevant for a long time. Notes: svn path=/head/; revision=334107
* Ensure thread library is initialized in pthread_testcancel().John Baldwin2018-03-211-1/+3
| | | | | | | | | | | | | | | | | | | | Call _thr_check_init() before reading curthread in pthread_testcancel(). If a constructor in a library creates a semaphore via sem_init() and then waits for it via sem_wait(), the program can core dump in _pthread_testcancel() called from sem_wait(). This is because the semaphore implementation lives in libc, so the library's constructors can be run before libthr's constructors. Reported by: arichardson Reviewed by: kib Obtained from: CheriBSD MFC after: 1 week Sponsored by: DARPA / AFRL Differential Revision: https://reviews.freebsd.org/D14786 Notes: svn path=/head/; revision=331324
* libthr: Fix missing break in switch.Pedro F. Giffuni2018-01-271-0/+1
| | | | | | | | | | This is also a warning in recent GCC with -Wimplicit-fallthrough. CID: 1356262 Obtained from: DragonFly (git 0f037c78 - partial) Notes: svn path=/head/; revision=328493
* lib: further adoption of SPDX licensing ID tags.Pedro F. Giffuni2017-11-2633-22/+88
| | | | | | | | | | | | | | | Mainly focus on files that use BSD 2-Clause license, however the tool I was using mis-identified many licenses so this was mostly a manual - error prone - task. The Software Package Data Exchange (SPDX) group provides a specification to make it easier for automated tools to detect and summarize well known opensource licenses. We are gradually adopting the specification, noting that the tags are considered only advisory and do not, in any way, superceed or replace the license texts. Notes: svn path=/head/; revision=326219
* General further adoption of SPDX licensing ID tags.Pedro F. Giffuni2017-11-2020-20/+61
| | | | | | | | | | | | | | | | | Mainly focus on files that use BSD 3-Clause license. The Software Package Data Exchange (SPDX) group provides a specification to make it easier for automated tools to detect and summarize well known opensource licenses. We are gradually adopting the specification, noting that the tags are considered only advisory and do not, in any way, superceed or replace the license texts. Special thanks to Wind River for providing access to "The Duke of Highlander" tool: an older (2014) run over FreeBSD tree was useful as a starting point. Notes: svn path=/head/; revision=326025
* spdx: initial adoption of licensing ID tags.Pedro F. Giffuni2017-11-189-9/+27
| | | | | | | | | | | | | | | | | | | | The Software Package Data Exchange (SPDX) group provides a specification to make it easier for automated tools to detect and summarize well known opensource licenses. We are gradually adopting the specification, noting that the tags are considered only advisory and do not, in any way, superceed or replace the license texts. Special thanks to Wind River for providing access to "The Duke of Highlander" tool: an older (2014) run over FreeBSD tree was useful as a starting point. Initially, only tag files that use BSD 4-Clause "Original" license. RelNotes: yes Differential Revision: https://reviews.freebsd.org/D13133 Notes: svn path=/head/; revision=325966
* Use MACHINE_CPUARCH in preference MACHINE for userland.Warner Losh2017-11-071-1/+1
| | | | | | | Sponsored by: Netflix Notes: svn path=/head/; revision=325510
* DIRDEPS_BUILD: Update dependencies.Bryan Drewery2017-10-314-4/+0
| | | | | | | Sponsored by: Dell EMC Isilon Notes: svn path=/head/; revision=325188
* Fix misleading comment.Michal Meloun2017-10-291-1/+2
| | | | | | | | | Not a functional change. MFC after: 3 days Notes: svn path=/head/; revision=325103
* [libthr] revert change of visibility of _thread_keytable to unbreak debuggerMichael Zhilin2017-10-022-1/+4
| | | | | | | | | | | | | | | | Fix regression by r318539. The sysutils/pstack uses library libthread_db to read information about threads state. The function pt_ta_new makes lookup of several key symbols including _thread_keytable. But r318539 mades this field static. It causes silent ignore of libthr library by pstack and as result sysutils/pstack doesn't output any thread information. This fix changes this field back to non-static. MFC after: 2 weeks Differential Revision: https://reviews.freebsd.org/D11738 Notes: svn path=/head/; revision=324219
* Add HAS_TESTS to all Makefiles that are currently using theEnji Cooper2017-08-021-0/+1
| | | | | | | | | `SUBDIR.${MK_TESTS}+= tests` idiom. This is a follow up to r321912. Notes: svn path=/projects/make-check-sandbox/; revision=321914
* Convert traditional ${MK_TESTS} conditional idiom for including testEnji Cooper2017-08-021-3/+1
| | | | | | | | | | | | | | directories to SUBDIR.${MK_TESTS} idiom This is being done to pave the way for future work (and homogenity) in ^/projects/make-check-sandbox . No functional change intended. MFC after: 1 weeks Notes: svn path=/head/; revision=321912
* libthr: check for possible overflow in the pthread_barrier_init() count.Pedro F. Giffuni2017-07-151-1/+1
| | | | | | | | | | | | | Following up on r320900, where the check for negative count values was removed, add a check to prevent integer overflow. This is to account that b_count, b_waiters but most importantly the total number of threads in the system are signed values. Discussed with: kib MFC after: 2 weeks Notes: svn path=/head/; revision=321011
* libthr: 'count' is unsigned so don't check for negative values.Pedro F. Giffuni2017-07-141-1/+1
| | | | | | | Obtained from: DragonFlyBSD (git e7db8139) Notes: svn path=/head/; revision=320990
* libthr: increase WARNS to the default (6)Eric van Gyzen2017-05-261-1/+1
| | | | | | | | | | | | ...and silence cast-align warnings from gcc. Reviewed by: kib MFC after: 3 days Sponsored by: Dell EMC Differential Revision: https://reviews.freebsd.org/D10935 Notes: svn path=/head/; revision=318956
* libthr: fix warnings at WARNS=6Eric van Gyzen2017-05-266-11/+3
| | | | | | | | | | | | Fix more warnings about redundant declarations. Reviewed by: kib emaste MFC after: 3 days Sponsored by: Dell EMC Differential Revision: https://reviews.freebsd.org/D10932 Notes: svn path=/head/; revision=318955
* libthr: fix style in previous commitEric van Gyzen2017-05-261-1/+1
| | | | | | | | | | | I intended to add this to the previous commit. Reviewed by: kib MFC after: 3 days Sponsored by: Dell EMC Notes: svn path=/head/; revision=318953
* libthr: prevent setcontext() from masking SIGTHREric van Gyzen2017-05-261-1/+1
| | | | | | | | | | | | | | | | | __thr_setcontext() mistakenly tested for the presence of SIGCANCEL in its local ucontext_t instead of the parameter. Therefore, if a thread calls setcontext() with a context whose signal mask contains SIGTHR (a.k.a. SIGCANCEL), that signal will be blocked, preventing the thread from being cancelled or suspended. Reported by: gcc 6.1 via RISC-V tinderbox Reviewed by: kib MFC after: 3 days Sponsored by: Dell EMC Differential Revision: https://reviews.freebsd.org/D10933 Notes: svn path=/head/; revision=318952
* libthr: fix warnings from GCC when WARNS=6Eric van Gyzen2017-05-235-20/+32
| | | | | | | | | | | | | | | | | | | Fix warnings about: - redundant declarations - a local variable shadowing a global function (dlinfo) - an old-style function definition (with an empty parameter list) - a variable that is possibly used uninitialized "make tinderbox" passes this time, except for a few unrelated kernel failures. Reviewed by: kib MFC after: 3 days Sponsored by: Dell EMC Differential Revision: https://reviews.freebsd.org/D10870 Notes: svn path=/head/; revision=318749
* Revert r318583 (libthr: use default WARNS level of 6)Eric van Gyzen2017-05-221-0/+1
| | | | | | | | | | | | Revert this while I fix RISC-V, SPARC, and probably all architectures that use GCC. Reported by: kib Pointy hat to: vangyzen Sponsored by: Dell EMC Notes: svn path=/head/; revision=318641
* libthr: Use CLI flags instead of pragmas to disable warningsEric van Gyzen2017-05-203-21/+6
| | | | | | | | | | | | | | | | | | People tweaking the build system or compilers tend to look into the Makefile and not into the source. Having some warning controls in the Makefile and some in the source code is surprising. Pragmas have the advantage that they leave the warnings enabled for more code, but that advantage isn't very relevant in these cases. Requested by: kib Reviewed by: kib MFC after: 3 days Sponsored by: Dell EMC Differential Revision: https://reviews.freebsd.org/D10832 Notes: svn path=/head/; revision=318584