summaryrefslogtreecommitdiffstats
path: root/lib/libc/thread (follow)
Commit message (Collapse)AuthorAgeFilesLines
* Fix two issues related to thread private data in asr.otto2021-01-062-14/+18
| | | | | | | | - setting up asr in single thread mode and then starting threads using asr would lead to multiple threads sharing the same resolver. - destruction of a thread that has been using asr would leak data. Problem originally reported by Alexey Sokolov and Uli Schlachter. ok kettenis@
* annoying whitespacederaadt2020-10-121-2/+2
|
* Add support for timeconting in userland.pirofti2020-07-061-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | This diff exposes parts of clock_gettime(2) and gettimeofday(2) to userland via libc eliberating processes from the need for a context switch everytime they want to count the passage of time. If a timecounter clock can be exposed to userland than it needs to set its tc_user member to a non-zero value. Tested with one or multiple counters per architecture. The timing data is shared through a pointer found in the new ELF auxiliary vector AUX_openbsd_timekeep containing timehands information that is frequently updated by the kernel. Timing differences between the last kernel update and the current time are adjusted in userland by the tc_get_timecount() function inside the MD usertc.c file. This permits a much more responsive environment, quite visible in browsers, office programs and gaming (apparently one is are able to fly in Minecraft now). Tested by robert@, sthen@, naddy@, kmos@, phessler@, and many others! OK from at least kettenis@, cheloha@, naddy@, sthen@
* Instead of opting in to futexes on archs with atomics opt out on archsjsg2020-02-061-8/+5
| | | | | | without atomics, a smaller list. ok mpi@ visa@
* Kill unused _wait() function.mpi2019-10-211-8/+1
| | | | ok visa@
* KNF.mpi2019-02-131-2/+2
| | | | Pointed out by pirofti@ while reviewing my rwlock impl. based on this one.
* Remove unused <assert.h> header.mpi2019-01-291-2/+1
|
* There's no point in asserting that a pointer is not NULL beforempi2019-01-291-3/+1
| | | | | | dereferencing it. ok kettenis@, visa@
* Make the "not my pool" searching loop a tiny bit smarter, whileotto2019-01-101-3/+59
| | | | | | making the number of pools variable. Do not document the malloc conf settings atm, don't know yet if they will stay. Thanks to all the testers. ok deraadt@
* Switch alpha to futex(2) based condvars, mutexes and semaphores.visa2018-10-211-5/+6
| | | | From Brad, tested by Miod, OK kettenis@
* Switch powerpc to futex(2) based condvars, mutexes and semaphores.visa2018-10-151-2/+2
| | | | From Brad, OK mpi@ kettenis@
* enable futex(2) based mutexes on armv7 and use futex based semaphores injsg2018-09-241-3/+3
| | | | | librthread on armv7 as well from brad ok visa@ kettenis@ mpi@
* Use process-private futexes. This avoids the overhead of calling into uvmkettenis2018-06-041-6/+6
| | | | | | to look up the mapping for the futex address. ok visa@, mpi@
* Switch sparc64 to futex(2) based mutexes and condvars.mpi2018-05-191-2/+3
| | | | ok visa@
* Enable futex(2)-based mutex on arm64.visa2018-05-131-2/+3
| | | | OK mpi@, kettenis@
* Add memory barriers to libc's _spinlock() to make the mechanismvisa2018-05-131-2/+11
| | | | | | | | | | serialize memory accesses properly. _spinlock()'s backend, _atomic_lock(), already issues an entry barrier on some architectures, but that practice has not been consistent. This patch generalizes the barrier use. OK kettenis@, mpi@
* Validate timespec and return ECANCELED when interrupted with SA_RESTART.pirofti2018-04-241-3/+5
| | | | | | | | | | | | | | | Discussing with mpi@ and guenther@, we decided to first fix the existing semaphore implementation with regards to SA_RESTART and POSIX compliant returns in the case where we deal with restartable signals. Currently we return EINTR everywhere which is mostly incorrect as the user can not know if she needs to recall the syscall or not. Return ECANCELED to signal that SA_RESTART was set and EINTR otherwise. Regression tests pass and so does the posixsuite. Timespec validation bits are needed to pass the later. OK mpi@, guenther@
* Implement __cxa_thread_atexit to support C++11 thread_local scope. Thekettenis2017-12-051-1/+2
| | | | | | | interface is also made available as __cxa_thread_atexit_impl to satisfy the needs of GNU libstdc++. ok guenther@, millert@
* Revert recent changes to unbreak ports/net/sambajca2017-11-044-101/+10
| | | | | | | | While it is not clear (to me) why that ports ends up with corrupted shared libs, reverting those changes fixes the issue and should allow us to close p2k17 more smoothly. Discussed with a bunch, ok ajacoutot@ guenther@
* If the init_routine used with pthread_once() is canceled, then we need toguenther2017-10-281-1/+11
| | | | | | | unlock the mutex inside the pthread_once_t. Push a cleanup wrapper for that. Diff from Scott Cheloha <scottcheloha@gmail.com> ok mpi@
* Change pthread_cleanup_{push,pop} to macros that store the cleanup infoguenther2017-10-283-9/+90
| | | | | | | | | | | | | | on the stack instead of mallocing the list and move the APIs from libpthread to libc so that they can be used inside libc. Note: the standard was explicitly written to permit/support this "macro with unmatched brace" style and it's what basically everyone else already does. We xor the info with random cookies with a random magic to detect/trip-up overwrites. Major bump to both libc and libpthread due to the API move. ok mpi@
* Move mutex, condvar, and thread-specific data routes, pthread_once, andguenther2017-09-0512-863/+161
| | | | | | | | pthread_exit from libpthread to libc, along with low-level bits to support them. Major bump to both libc and libpthread. Requested by libressl team. Ports testing by naddy@ ok kettenis@
* s/DEF_STD/DEF_STRONG/ to match namespace.h differences between librthreadguenther2017-08-155-29/+29
| | | | and libc
* Sort headers per style(9)guenther2017-08-1510-34/+31
|
* Copy files from ../librthread in preparation for moving functionalityguenther2017-08-1513-0/+3158
| | | | | | | from libpthread to libc. No changes to the build yet, just making it easier to review the substantive diffs. ok beck@ kettenis@ tedu@
* fix format stringchl2016-09-021-2/+2
| | | | ok guenther@
* Use a Thread Information Block in both single and multi-threaded programs.guenther2016-05-074-137/+22
| | | | | | | | | | | | | | | | | This stores errno, the cancelation flags, and related bits for each thread and is allocated by ld.so or libc.a. This is an ABI break from 5.9-stable! Make libpthread dlopen'able by moving the cancelation wrappers into libc and doing locking and fork/errno handling via callbacks that libpthread registers when it first initializes. 'errno' *must* be declared via <errno.h> now! Clean up libpthread's symbol exports like libc. On powerpc, offset the TIB/TCB/TLS data from the register per the ELF spec. Testing by various, particularly sthen@ and patrick@ ok kettenis@
* libc.so can't be unloaded, so move the hidden atexit() and pthread_atfork()guenther2015-11-101-1/+18
| | | | | | | | | | | stubs for the executable from crtbegin.o into libc, which lets them be excluded from static links that don't use them. For this, drop the normal crt{begin,end}S.o from libc.so: the .init and .fini sections for libc aren't called at the right times anyway, so it's good that they're unused. libc.so just needs __guard_local and the .note.openbsd.ident section, so add them to stack_protector.c for now (this will be improved) "good time" deraadt@
* Make pthread_atfork() track the DSO that called it like atexit() does,guenther2015-04-073-3/+77
| | | | | | | | | | unregistering callbacks if the DSO is unloaded. Move the callback handling from libpthread to libc, though libpthread still overrides the inner call to handle locking and thread-library reinitialization. Major version bump for both libc and libpthread. verification that this fixes various ports ajacoutot@ asm assistance miod@; ok millert@ deraadt@
* zap trailing newlines; "go for it" deraadtokan2014-07-161-2/+1
|
* remove _MALLOC_LOCK_INIT; major bump; ok deraadt@otto2008-06-131-9/+1
|
* - make arc4random*() functions thread safe. Use a custom spinlock functionkurt2008-01-011-1/+19
| | | | | | | | | | | instead of the generic pthread macros since free(3) uses __arc4_getbyte() when freeing small sized allocations and the generic pthread macros call malloc(3). - eliminate passing pointers to a static variable with global scope (rs) for additional code clarity and reduction. - shlib minor bumps for libc and libpthread due to new functions. From andreas@ with some bits from me. okay tedu@ marc@ w/some spot checking from millert@
* remove unused zero length file.kurt2007-11-191-0/+0
|
* _FD_LOCK/UNLOCK() is libpthread specific and not needed for librthread, sokurt2007-06-053-24/+51
| | | | | | | | | | | | | | | | | | | | | | | | | | isolate its usage to libpthread only and replace with generic non-static mutex support in the one place it is needed: - remove _FD_LOCK/UNLOCK from lseek and ftruncate in libc and make the functions weak so that libpthread can override with its own new versions that do the locking. - remove _thread_fd_lock/unlock() weak functions from libc and adjust libpthread for the change. - add generic _thread_mutex_lock/unlock/destroy() weak functions in libc to support non-static mutexes in libc and add libpthread and librthread implementations for them. libc can utilize non-static mutexes via the new _MUTEX_LOCK/UNLOCK/DESTROY() macros. Actually these new macros can support both static and non-static mutexes but currently only using them for non-static. - make opendir/closedir/readdir/readdir_r/seekdir/telldir() thread-safe for both thread libraries by using a non-static mutex in the struct _dirdesc (typedef DIR), utilizing it in the *dir functions and remove remaining and incorrect _FD_LOCK/UNLOCK() use in libc. - add comments to both thread libraries to indicate libc depends on the current implementation of static mutex initialization. suggested by marc@ - major bump libc and libpthread due to function removal, structure change and weak symbol conversions. okay marc@, tedu@
* Avouid a race in atexit() handling by introducing a lock. Problemotto2006-02-221-1/+19
| | | | | originally reported by Gergely Kovacs; help from dhartmei@; ok tedu@ millert@
* major bump to libc and libpthread to break the dependency of amarc2004-06-075-51/+39
| | | | | | particular implementation of libpthread for libc. libc no longer needs pthread.h to compile. OK millert@, brad@, tedu@
* thread safe libc -- 2nd try. OK miod@, millert@marc2002-11-053-37/+20
| | | | Thanks to miod@ for m68k and vax fixes
* back out previous patch.. there are still some vax/m68k issuesmarc2002-11-033-20/+37
|
* libc changes for thread safety. Tested on:marc2002-11-033-37/+20
| | | | | | | alpha (millert@), i386 (marc@), m68k (millert@ and miod@), powerpc (drahn@ and dhartmei@), sparc (millert@ and marc@), sparc64 (marc@), and vax (millert@ and miod@). Thanks to millert@, miod@, and mickey@ for fixes along the way.
* put changes back, this time ALL the files.fgsch2001-09-041-3/+3
|
* Back out fgsch@'s tree breaking commits.todd2001-08-301-3/+3
| | | | Test next time, ok?
* fix some const warningsfgsch2001-08-301-3/+3
|
* malloc lock helpersd2000-01-141-0/+21
|
* rename thread_storage to unithread_storage to avoid object name conflictd2000-01-062-3/+3
|
* thread specific storage and fd locking for single-threaded libc (ie, no-ops)d2000-01-063-0/+98