summaryrefslogtreecommitdiff
path: root/lib/libthr/thread/thr_once.c
Commit message (Collapse)AuthorAgeFilesLines
* Avoid conflicts with libc symbols in libthr jump table.Konstantin Belousov2019-07-311-2/+3
| | | | | | | | | | | | | | | | | | | 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
* lib: further adoption of SPDX licensing ID tags.Pedro F. Giffuni2017-11-261-1/+3
| | | | | | | | | | | | | | | 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
* Remove empty initializer for the once facility. It was not neededKonstantin Belousov2016-07-271-5/+0
| | | | | | | | | | since r179417. Sponsored by: The FreeBSD Foundation MFC after: 1 week Notes: svn path=/head/; revision=303393
* Use __FBSDID() for .c files from lib/libthr/thread.Konstantin Belousov2016-04-081-3/+3
| | | | | | | Sponsored by: The FreeBSD Foundation Notes: svn path=/head/; revision=297706
* Style. Use ANSI definition, wrap long lines, no initialization inKonstantin Belousov2015-09-081-8/+15
| | | | | | | | | | declaration for locals. Sponsored by: The FreeBSD Foundation MFC after: 1 week Notes: svn path=/head/; revision=287557
* In the pthread_once(), if the initializer has already run, then theKonstantin Belousov2015-09-081-3/+5
| | | | | | | | | | | | | | | | | | | | calling thread is supposed to see accesses issued by the initializer. This means that the read of the once_control->state variable should have an acquire semantic. Use atomic_thread_fence_acq() when the value read is ONCE_DONE, instead of straightforward atomic_load_acq(), to only put a barrier when needed (*). On the other hand, the updates of the once_control->state with the intermediate progress state do not need to synchronize with other state accesses, remove _acq suffix. Reviewed by: alc (previous version) Suggested by: alc (*) Sponsored by: The FreeBSD Foundation MFC after: 1 week Notes: svn path=/head/; revision=287556
* r179417 introduced a bug into pthread_once(). Previously pthread_once()Ryan Stone2011-04-201-0/+2
| | | | | | | | | | | | | | | | | | | | used a global pthread_mutex_t for synchronization. r179417 replaced that with an implementation that directly used atomic instructions and thr_* syscalls to synchronize callers to pthread_once. However, calling pthread_mutex_lock on the global mutex implicitly ensured that _thr_check_init() had been called but with r179417 this was no longer guaranteed. This meant that if you were unlucky enough to have your first call into libthr be a call to pthread_once(), you would segfault when trying to access the pointer returned by _get_curthread(). The fix is to explicitly call _thr_check_init() from pthread_once(). Reviewed by: davidxu Approved by: emaste (mentor) MFC after: 1 week Notes: svn path=/head/; revision=220888
* Eliminate global mutex by using pthread_once's state field asDavid Xu2008-05-301-33/+29
| | | | | | | a semaphore. Notes: svn path=/head/; revision=179417
* Use macro THR_CLEANUP_PUSH/POP, they are cheaper than pthread_cleanup_push/pop.David Xu2007-10-161-2/+4
| | | | Notes: svn path=/head/; revision=172695
* Rework last change of pthread_once, create a function _thr_once_init toDavid Xu2006-02-151-2/+8
| | | | | | | reinitialize its internal locks. Notes: svn path=/head/; revision=155739
* After fork(), reinitialize internal locks for pthread_once().David Xu2006-02-151-11/+11
| | | | Notes: svn path=/head/; revision=155714
* Update copyright.David Xu2005-12-171-19/+14
| | | | Notes: svn path=/head/; revision=153496
* Import my recent 1:1 threading working. some features improved includes:David Xu2005-04-021-10/+55
| | | | | | | | | | | | | | | | | | | 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
* - Add libthr but don't hook it up to the regular build yet. This is anJeff Roberson2003-04-011-0/+53
adaptation of libc_r for the thr system call interface. This is beta quality code. Notes: svn path=/head/; revision=112918