summaryrefslogtreecommitdiff
path: root/lib/libthr/thread/thr_spec.c
Commit message (Collapse)AuthorAgeFilesLines
* Avoid conflicts with libc symbols in libthr jump table.Konstantin Belousov2019-07-311-9/+12
| | | | | | | | | | | | | | | | | | | In some corner cases of static linking and unexpected libraries order on the linker command line, libc symbol might preempt the same libthr symbol, in which case libthr jump table points back to libc causing either infinite recursion or loop. Handle all of such symbols by using private libthr names for them, ensuring that the right pointers are installed into the table. In collaboration with: arichardson PR: 239475 Tested by: pho MFC after: 2 weeks Sponsored by: The FreeBSD Foundation Differential revision: https://reviews.freebsd.org/D21088 Notes: svn path=/head/; revision=350481
* Untangle jemalloc and mutexes initialization.Konstantin Belousov2019-01-291-6/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | The need to use libc malloc(3) from some places in libthr always caused issues. For instance, per-thread key allocation was switched to use plain mmap(2) to get storage, because some third party mallocs used keys for implementation of calloc(3). Even more important, libthr calls calloc(3) during initialization of pthread mutexes, and jemalloc uses pthread mutexes. Jemalloc provides some way to both postpone the initialization, and to make initialization to use specialized allocator, but this is very fragile and often breaks. See the referenced PR for another example. Add the small malloc implementation used by rtld, to libthr. Use it in thr_spec.c and for mutexes initialization. This avoids the issues with mutual dependencies between malloc and libthr in principle. The drawback is that some more allocations are not interceptable for alternate malloc implementations. There should be not too much memory use from this allocator, and the alternative, direct use of mmap(2) is obviously worse. PR: 235211 MFC after: 2 weeks Sponsored by: The FreeBSD Foundation Differential revision: https://reviews.freebsd.org/D18988 Notes: svn path=/head/; revision=343566
* General further adoption of SPDX licensing ID tags.Pedro F. Giffuni2017-11-201-1/+3
| | | | | | | | | | | | | | | | | 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
* [libthr] revert change of visibility of _thread_keytable to unbreak debuggerMichael Zhilin2017-10-021-1/+2
| | | | | | | | | | | | | | | | 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
* libthr: fix warnings at WARNS=6Eric van Gyzen2017-05-191-1/+1
| | | | | | | | | | | | | | | | | | | Fix warnings about the following when WARNS=6 (which I will commit soon): - casting away const - no previous 'extern' declaration for non-static variable - others as explained by #pragmas and comments - unused parameters The last is the only functional change. Reviewed by: kib MFC after: 3 days Sponsored by: Dell EMC Differential Revision: https://reviews.freebsd.org/D10808 Notes: svn path=/head/; revision=318539
* Use __FBSDID() for .c files from lib/libthr/thread.Konstantin Belousov2016-04-081-2/+3
| | | | | | | Sponsored by: The FreeBSD Foundation Notes: svn path=/head/; revision=297706
* Some third-party malloc(3) implementations use pthread_setspecific(3)Konstantin Belousov2015-05-151-110/+91
| | | | | | | | | | | | | | | | | | | | | | | | | | | | to handle per-thread information. Since our pthread_setspecific() implementation calls calloc(3) to allocate per-thread specific data storage, things get complicated. Switch the allocator to use bare mmap(2). There is some loss of the allocated page, since e.g. on amd64, PTHREAD_KEYS_MAX * sizeof(struct pthread_specific_elem) is 3K (it actually spans whole page due to padding), but I believe it is more acceptable than additional code for specialized allocator(). The alternatives would either to make the specific data array be part of the struct thread, or use internal bindings to call the libc malloc, avoiding interposing. Also do the style pass over the thr_spec.c, esp. simplify the conditionals nesting by returning early when an error detected. Remove trivial comments. Found by: yuri@rawbw.com PR: 200138 Sponsored by: The FreeBSD Foundation MFC after: 2 weeks Notes: svn path=/head/; revision=282948
* Return one-based key so that user can check if the key is ever allocatedDavid Xu2013-05-161-4/+7
| | | | | | | | | in the first place. Initial patch submitted by: phk Notes: svn path=/head/; revision=250691
* Unregister thread specific data destructor when a corresponding dsoDavid Xu2010-08-271-0/+21
| | | | | | | is unloaded. Notes: svn path=/head/; revision=211860
* don't report error if key was deleted.David Xu2009-09-251-1/+11
| | | | | | | PR: threads/135462 Notes: svn path=/head/; revision=197477
* In _pthread_key_create() ensure that libthr is initialized. ThisMarius Strobl2007-11-061-1/+5
| | | | | | | | | | | | | | fixes a NULL-dereference of curthread when libstdc+ initializes the exception handling globals on archs we can't use GNU TLS due to lack of support in binutils 2.15 (i.e. arm and sparc64), yet, thus making threaded C++ programs compiled with GCC 4.2.1 work again on these archs. Reviewed by: davidxu MFC after: 3 days Notes: svn path=/head/; revision=173394
* Remove 3rd clause, renumber, ok per emailWarner Losh2007-01-121-4/+1
| | | | Notes: svn path=/head/; revision=165967
* Explicitly request pre-zeroed memory instead of memset'ing ourXin LI2006-05-311-5/+1
| | | | | | | | | own. Ok'ed by: davidxu Notes: svn path=/head/; revision=159090
* WARNS level 4 cleanup.David Xu2006-04-041-7/+8
| | | | Notes: svn path=/head/; revision=157457
* Import my recent 1:1 threading working. some features improved includes:David Xu2005-04-021-74/+85
| | | | | | | | | | | | | | | | | | | 1. fast simple type mutex. 2. __thread tls works. 3. asynchronous cancellation works ( using signal ). 4. thread synchronization is fully based on umtx, mainly, condition variable and other synchronization objects were rewritten by using umtx directly. those objects can be shared between processes via shared memory, it has to change ABI which does not happen yet. 5. default stack size is increased to 1M on 32 bits platform, 2M for 64 bits platform. As the result, some mysql super-smack benchmarks show performance is improved massivly. Okayed by: jeff, mtm, rwatson, scottl Notes: svn path=/head/; revision=144518
* - Define curthread as _get_curthread() and remove all direct calls toJeff Roberson2003-04-021-9/+2
| | | | | | | | | | _get_curthread(). This is similar to the kernel's curthread. Doing this saves stack overhead and is more convenient to the programmer. - Pass the pointer to the newly created thread to _thread_init(). - Remove _get_curthread_slow(). Notes: svn path=/head/; revision=112965
* - Add libthr but don't hook it up to the regular build yet. This is anJeff Roberson2003-04-011-0/+225
adaptation of libc_r for the thr system call interface. This is beta quality code. Notes: svn path=/head/; revision=112918