Home | History | Annotate | Download | only in thread-stub
History log of /src/lib/libc/thread-stub/thread-stub.c
RevisionDateAuthorComments
 1.33  23-Sep-2024  christos Add weak aliases for methods used by the new jemalloc. Co-opt the mutex
catchall for now for it.
 1.32  19-Apr-2022  rillig branches: 1.32.4;
lib: remove CONSTCOND comment

Since 2021-01-31, lint doesn't need it anymore for the common pattern of
'do ... while (0)'.
 1.31  06-Feb-2021  jdolecek change libc sched_yield() stub to actually still call the syscall
instead of doing nothing when app is not linked with pthread; this matches
other systems

suggested by Mateusz Guzik in:
http://mail-index.netbsd.org/tech-kern/2020/07/19/msg026620.html
 1.30  14-Jan-2020  kamil Adjust the error return value of pthread_sigmask for !libpthread usage

Instead of returning -1, return errno on error.

Catch up after the fix in libpthread by Andrew Doran in 2008
in lib/libpthread/pthread_misc.c r.1.9.

It's an open question whether this function shall be used without linked
in the POSIX thread library.

Detected by Bruno Haible (GNU) and documented in gnulib in commit
"pthread_sigmask: Avoid test failure on NetBSD 8.0. " r. 4d16a83b0c1fcb6c.
 1.29  05-Mar-2019  christos branches: 1.29.2;
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.
 1.28  31-Oct-2016  kamil branches: 1.28.14;
Add CHECK_NOT_THREADED() in __libc_mutexattr_settype_stub()

This makes this function consistent with __libc_mutex_catchall_stub()
and others in the same group.

Approved by <christos>.
 1.27  28-May-2013  christos branches: 1.27.10;
mark __libc_thr_exit_stub dead here too
 1.26  27-Apr-2013  joerg Provide stubs for pthread_detach/pthread_join.
 1.25  12-Apr-2013  joerg Weak alias directly to the catchall stub and don't strong alias twice.
 1.24  05-Apr-2013  christos split init and errno to a separate file. No point in growing rtld 10K.
 1.23  21-Mar-2013  christos - Allow libpthread to be dlopened again, by providing libc stubs to libpthread.
- Fail if the dlopened libpthread does pthread_create(). From manu@
- Discussed at length in the mailing lists; approved by core@
- This was chosen as the least intrusive patch that will provide
the necessary functionality.
XXX: pullup to 6
 1.22  16-Sep-2011  joerg branches: 1.22.2; 1.22.4; 1.22.8;
Use __dead
 1.21  30-Jan-2009  ad Make threaded programs die correctly:

kill(getpid(), SIGFOO) -> raise(SIGFOO)
 1.20  28-Apr-2008  martin branches: 1.20.6; 1.20.8;
Remove clause 3 and 4 from TNF licenses
 1.19  14-Dec-2007  christos branches: 1.19.4;
add fw decl.
 1.18  14-Dec-2007  christos fix obvious bogon [can't alias symbol to itself]
 1.17  27-Nov-2007  ad Add thr_curcpu(), pthread_curcpu_np().
 1.16  14-Nov-2007  drochner Add pthread_equal() to libc stubs; this makes a lot of sense for
threadsafe libraries implementing own locking functions.
Ride on yesterday's minor version bumps.
 1.15  13-Nov-2007  ad - stack_protector.c doesn't really belong under sys/. Add a new directory
for misc support routines and put it there.
- Add a libc constructor. Use this to initialize threading and the
stack protector stuff. libpthread cannot be initialized safely using
its own constructor because libc and libpthread are deeply intertwined.
PR bin/37347
 1.14  29-Nov-2005  christos branches: 1.14.10;
WARNS=4
 1.13  12-Jun-2005  lukem Add missing __RCSID()
 1.12  14-Dec-2004  nathanw Fix the __libc_thr_yield_stub() signature.
 1.11  13-Dec-2004  nathanw The __libc_thr_yield_stub() for scched_yield() should return int (and
a 0), not void.
 1.10  06-Dec-2004  nathanw Implement __libc_thr_sigsetmask_stub() in terms of sigprocmask(),
instead of having a dummy function.
 1.9  18-Jul-2003  nathanw Add a stub for setcancelstate().
 1.8  01-Mar-2003  matt Add #include <stdlib.h> for exit definition.
 1.7  20-Jan-2003  thorpej Simple TSD implementation, since some thread-safe libraries want
to use it.
 1.6  20-Jan-2003  thorpej Make thr_self() not return NULL.
 1.5  19-Jan-2003  thorpej Add some threadlib stubs that are used by X:
* thr_create() (stub in libc aborts)
* thr_exit() (stub in libc calls exit())
* thr_yield() (stub in libc does nothing)

Also make the libc thr_self() stub not abort.

XXX Should we add thrattr_*() stubs for setting the detach-state?
 1.4  19-Jan-2003  thorpej Add mutexattr_init(), mutexattr_destroy(), and mutexattr_settype() (recursive
mutexes are used by the X libraries).
 1.3  19-Jan-2003  thorpej Make the libc thr_once() stub functional.
 1.2  18-Jan-2003  thorpej Merge the nathanw_sa branch.
 1.1  08-Jan-2003  thorpej branches: 1.1.2;
file thread-stub.c was initially added on branch nathanw_sa.
 1.1.2.2  09-Jan-2003  nathanw __weak_alias() declarations don't compile with a semicolon at the
end.
 1.1.2.1  08-Jan-2003  thorpej Rewrite the way libpthread provides thread primitives to libc, using
strong and weak aliases (the way cancelation points are handled).

Work around lame Unix static library semantics which could cause
the wrong thread primitives or cancelation point functions to be
included in a statically-linked program.

THIS IS AN ABI CHANGE. People running the nathanw_sa branch should
ensure that their libc and libpthread are in sync after updating.
 1.14.10.1  09-Jan-2008  matt sync with HEAD
 1.19.4.1  18-May-2008  yamt sync with head.
 1.20.8.2  28-Apr-2008  martin Remove clause 3 and 4 from TNF licenses
 1.20.8.1  28-Apr-2008  martin file thread-stub.c was added on branch christos-time_t on 2008-04-28 20:23:02 +0000
 1.20.6.1  02-Feb-2009  snj Pull up following revision(s) (requested by ad in ticket #399):
lib/libc/misc/stack_protector.c: revision 1.3
lib/libc/stdlib/abort.c: revision 1.13
lib/libc/thread-stub/thread-stub.c: revision 1.21
Make threaded programs die correctly:
kill(getpid(), SIGFOO) -> raise(SIGFOO)
 1.22.8.1  23-Jun-2013  tls resync from head
 1.22.4.2  29-Apr-2013  riz Pull up following revision(s) (requested by joerg in ticket #869):

Needed to fix build on alpha:

lib/libc/thread-stub/thread-stub.c: revision 1.25
Weak alias directly to the catchall stub and don't strong alias twice.
 1.22.4.1  29-Apr-2013  riz Pull up following revision(s) (requested by manu in ticket #869):
lib/libpthread/pthread_rwlock.c: revision 1.33
lib/libc/include/reentrant.h: revision 1.16
lib/libpthread/pthread_cond.c: revision 1.59
lib/libpthread/pthread_misc.c: revision 1.15
lib/libc/thread-stub/thread-stub.c: revision 1.23
lib/libpthread/pthread_cancelstub.c: revision 1.38
lib/libpthread/pthread_specific.c: revision 1.26
lib/libpthread/pthread_mutex.c: revision 1.56
lib/libpthread/pthread_tsd.c: revision 1.11
lib/libpthread/Makefile: revision 1.80
lib/libpthread/pthread.c: revision 1.143
lib/libpthread/pthread_int.h: revision 1.89
- Allow libpthread to be dlopened again, by providing libc stubs to
libpthread.
- Fail if the dlopened libpthread does pthread_create(). From manu@
- Discussed at length in the mailing lists; approved by core@
- This was chosen as the least intrusive patch that will provide
the necessary functionality.
XXX: pullup to 6
 1.22.2.1  22-May-2014  yamt sync with head.

for a reference, the tree before this commit was tagged
as yamt-pagecache-tag8.

this commit was splitted into small chunks to avoid
a limitation of cvs. ("Protocol error: too many arguments")
 1.27.10.1  04-Nov-2016  pgoyette Sync with HEAD
 1.28.14.2  08-Apr-2020  martin Merge changes from current as of 20200406
 1.28.14.1  10-Jun-2019  christos Sync with HEAD
 1.29.2.2  04-Feb-2023  martin Pull up following revision(s) (requested by uwe in ticket #1584):

lib/libc/thread-stub/thread-stub.c: revision 1.31

change libc sched_yield() stub to actually still call the syscall
instead of doing nothing when app is not linked with pthread; this matches
other systems

suggested by Mateusz Guzik in:
http://mail-index.netbsd.org/tech-kern/2020/07/19/msg026620.html
 1.29.2.1  04-Feb-2023  martin Pull up following revision(s) (requested by uwe in ticket #1583):

lib/libc/thread-stub/thread-stub.c: revision 1.30

Adjust the error return value of pthread_sigmask for !libpthread usage

Instead of returning -1, return errno on error.
Catch up after the fix in libpthread by Andrew Doran in 2008
in lib/libpthread/pthread_misc.c r.1.9.

It's an open question whether this function shall be used without linked
in the POSIX thread library.

Detected by Bruno Haible (GNU) and documented in gnulib in commit
"pthread_sigmask: Avoid test failure on NetBSD 8.0. " r. 4d16a83b0c1fcb6c.
 1.32.4.1  02-Aug-2025  perseant Sync with HEAD

RSS XML Feed