Home | History | Annotate | Download | only in libpthread
History log of /src/lib/libpthread/pthread_cancelstub.c
RevisionDateAuthorComments
 1.51  04-Apr-2025  riastradh pthread_cancelstub.c: Use restrict, not __restrict.

Only reason to use __restrict is to make header files safe for
pre-C99 clients, but we have built this code as C99 for many years
(and we build it as C11 now anyway).

No functional change intended.

PR lib/59240: POSIX.1-2024: cancellation point audit
 1.50  04-Apr-2025  riastradh libpthread: Sort cancelstub definitions.

No functional change intended.

PR lib/59240: POSIX.1-2024: cancellation point audit
 1.49  04-Apr-2025  riastradh libpthread: Use typeof rather than copying signatures of cancelstubs.

This would have caught my previous mistake with paccept.

Omit needless declarations that are already covered by the
compat/*/*.h header files.

No functional change intended. This is purely an improvement to
build-time error detection.

PR lib/59134: POSIX-1.2024: pthread_setcancelstate must be
async-signal-safe

PR lib/59247: pthread_cancelstub.c is inadequately tested
 1.48  02-Apr-2025  riastradh libpthread: Fix signature of _sys_paccept symbol for paccept(2).

This is not, in fact, an alias for accept4(2): it has an extra
argument for a signal mask to restore while sleeping.

It would be nice if we had a .h file which could check the signature
in both definition and use, but that might be tricky to arrange.

PR lib/59240: POSIX.1-2024: cancellation point audit
 1.47  31-Mar-2025  riastradh libpthread(3): Add missing cancellation points.

- accept4
- tcdrain

XXX Should our nonstandard alias paccept(2) also be a cancellation
point?

PR lib/59240: POSIX.1-2024: cancellation point audit
 1.46  31-Mar-2025  riastradh pthread_cancel(3): Rework.

Make pthread_setcancelstate(3) async-signal-safe. (As a side effect,
this also makes pthread_setcanceltype(3) async-signal-safe, although
that is not required.)

PR lib/59134: POSIX-1.2024: pthread_setcancelstate must be
async-signal-safe
 1.45  19-Jan-2024  christos branches: 1.45.2;
Add missing headers
 1.44  28-Jul-2023  christos Add epoll(2) from Theodore Preduta as part of GSoC 2023
 1.43  19-Apr-2022  rillig lib: remove CONSTCOND comment

Since 2021-01-31, lint doesn't need it anymore for the common pattern of
'do ... while (0)'.
 1.42  10-Apr-2022  riastradh pthread: Nix trailing whitespace.
 1.41  12-Feb-2022  riastradh libpthread: Move namespacing include to top of .c files.

Stuff like libc's namespace.h, or atomic_op_namespace.h, which does
namespacing tricks like `#define atomic_cas_uint _atomic_cas_uint',
has to go at the top of each .c file. If it goes in the middle, it
might be too late to affect the declarations, and result in compile
errors.

I tripped over this by including <sys/atomic.h> in mips
<machine/lock.h>.

(Maybe we should create a new pthread_namespace.h file for the
purpose, but this'll do for now.)
 1.40  01-Oct-2021  christos remove parameter names from decls.
 1.39  01-Oct-2021  christos PR/56424: Clay Mayers: recvfrom() is not a cancelation point as documented
in pthread_setcanceltype.3
 1.38  21-Mar-2013  christos branches: 1.38.32;
- 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.37  04-Apr-2012  christos branches: 1.37.2;
trailing whitespace police.
 1.36  04-Apr-2012  agc Add a pthread cancel stub for sigwait, following Onno van der Linden's
analysis in PR 45131. Kindly tested by Hisashi T Fujinaka (using csup
as the test case) with a successful outcome.

OK martin@
 1.35  22-Apr-2011  joerg branches: 1.35.4; 1.35.6;
Don't kill the read(2) stub, just the magic around it.
 1.34  21-Apr-2011  joerg Disable Fortification for pthread and rump stubs.
 1.33  21-Apr-2011  martin Backout previous, it causes lots of test failures (tests/fs/nfs for
example).
 1.32  12-Apr-2011  christos Fix SSP builds (Vladimir Kirillov)
 1.31  26-Jan-2011  christos make the code more re-usable
 1.30  26-Jan-2011  christos Moving the ssp check inside the source code does not work properly because
the compiler loses information about the size of the object. So instead of
the hacky #define mess we did before, add a way to inject our function between
the user call and the system call.
 1.29  25-Jan-2011  christos Fix SSP build.
XXX: This is gross.
 1.28  06-Aug-2010  christos branches: 1.28.2;
make kevent(2) a cancelation point, and document properly all the cancelation
points we currently support.
 1.27  12-Aug-2009  enami Make nanosleep cancelable again.
 1.26  13-Jan-2009  christos fix __sigtimedwait50
 1.25  11-Jan-2009  christos merge christos-time_t
 1.24  29-Dec-2008  christos branches: 1.24.2;
revert previous. It was meant for the branch
 1.23  28-Dec-2008  christos adjust for time_t 64
 1.22  08-Oct-2008  ad branches: 1.22.2; 1.22.6;
Adjust the compat stuff slightly so that the changes are mostly self
contained (Makefile, pthread_compat.c).
 1.21  29-Sep-2008  ad make PTHREAD__COMPAT=1

Builds a libpthread that can be dropped into a NetBSD 2/3/4 chroot.

This makes threading work in the chroot when using a NetBSD 5 kernel, no
other modifications required.
 1.20  28-Jun-2008  ad Shut lint up.
 1.19  28-Apr-2008  martin branches: 1.19.2;
Remove clause 3 and 4 from TNF licenses
 1.18  02-Feb-2008  christos branches: 1.18.4;
PR/37932: Yakovetsky Vladimir: build distribution with USE_FORT fails
Avoid read redefinition
 1.17  24-Dec-2007  ad - Use pthread__cancelled() in more places.
- pthread_join(): assert that pthread_cond_wait() returns zero.
 1.16  19-Nov-2007  ad int -> ssize_t in a couple of places.
 1.15  09-Oct-2007  rmind Add cancellation stubs in libpthread for POSIX messages queues and
asynchronous I/O.

OK by <ad>.
 1.14  04-Mar-2007  ad branches: 1.14.6;
Add __sigsuspend14, sigtimedwait as cancellation points.
 1.13  13-Sep-2005  christos XXX: Work around libpthread's "intimate" connection with libc.
 1.12  21-Mar-2005  kleink Include <sys/select.h> explicitly rather than relying on other headers
to do it.
 1.11  18-Mar-2005  kleink Interpose cancellation points in pollts() and pselect(), bringing us
to libc.so.12.127 and libpthread.so.0.6.
 1.10  10-Mar-2005  kleink branches: 1.10.2;
Move up the definition of __LIBC12_SOURCE__; since <poll.h> now includes
<sys/sigtypes.h> this is needed earlier.
 1.9  21-May-2004  kleink IEEE Std 1003.1-2001/Cor 2-2004, item XSH/TC2/D6/5: fdatasync() shall
have cancellation points.

Note: we ride today's resolver-related version bumps.
 1.8  24-Nov-2003  cl add CONSTCOND in constant condition.
 1.7  21-Nov-2003  nathanw Manually inline pthread__testcancel in these routines; two function
calls' worth of overhead per cancellable syscall is overkill.
 1.6  18-Nov-2003  thorpej Userland portion of fsync_range(2), written by Bill Studenmund, and
contributed by Wasabi Systems, Inc.
 1.5  08-Mar-2003  lukem add __RCSID()
 1.4  15-Feb-2003  nathanw Implement nanosleep() at userlevel. Threaded applications seem to like
to sleep a lot, and there's no need for each such thread to consume kernel
resources.

(accidentally checked the pthread.c part of this in yesterday; no reason
not to finish the job)
 1.3  27-Jan-2003  nathanw Add cancellation stubs for accept() and connect().
 1.2  18-Jan-2003  thorpej Merge the nathanw_sa branch.
 1.1  28-Jan-2002  nathanw branches: 1.1.2;
file pthread_cancelstub.c was initially added on branch nathanw_sa.
 1.1.2.6  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.1.2.5  03-Nov-2002  skrll Whitespace.
 1.1.2.4  14-Aug-2002  nathanw Oops, re-add nanosleep stub, which had been accidentally deleted.
 1.1.2.3  02-Aug-2002  nathanw Adapt to new syscall stub names. Create strong aliases for override functions.
 1.1.2.2  20-May-2002  nathanw Many signal improvements:

- Implement sigsuspend()
- Take pending signals that are unblocked in pthread_sigmask().
- Tweak the signal mask passed by sigaction() to permit us to manage
our own thread-specific signal masks.
- Don't try to deliver signals to zombie threads.
- Prevent a race between deciding a thread can take a signal and actually
taking it.
- Don't put threads that are blocked in a syscall on the run queue.
- Add debug logging.
 1.1.2.1  28-Jan-2002  nathanw Add cancellation-wrapped syscall stubs that override the weak symbols
in libsyscall.
 1.10.2.2  21-Mar-2005  tron Pull up revision 1.12 (requested by kleink in ticket #38):
Include <sys/select.h> explicitly rather than relying on other headers
to do it.
 1.10.2.1  20-Mar-2005  tron Pull up revision 1.11 (requested by kleink in ticket #27):
Interpose cancellation points in pollts() and pselect(), bringing us
to libc.so.12.127 and libpthread.so.0.6.
 1.14.6.3  23-Mar-2008  matt sync with HEAD
 1.14.6.2  09-Jan-2008  matt sync with HEAD
 1.14.6.1  06-Nov-2007  matt sync with HEAD
 1.18.4.1  18-May-2008  yamt sync with head.
 1.19.2.1  18-Sep-2008  wrstuden Sync with wrstuden-revivesa-base-2.
 1.22.6.1  21-Apr-2010  matt sync to netbsd-5
 1.22.2.1  05-Sep-2009  bouyer Pull up following revision(s) (requested by enami in ticket #921):
lib/libpthread/pthread_misc.c: revision 1.14 via patch
lib/libpthread/pthread_cancelstub.c: revision 1.27 via patch
Make nanosleep cancelable again.
 1.24.2.3  10-Jan-2009  christos use the proper sigtimedwait.
 1.24.2.2  29-Dec-2008  christos commit changes to the right branch.
 1.24.2.1  29-Dec-2008  christos file pthread_cancelstub.c was added on branch christos-time_t on 2008-12-29 15:10:58 +0000
 1.28.2.1  08-Feb-2011  bouyer Sync with HEAD
 1.35.6.2  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.35.6.1  09-Apr-2012  riz Pull up following revision(s) (requested by agc in ticket #174):
lib/libpthread/pthread_cancelstub.c: revision 1.36
Add a pthread cancel stub for sigwait, following Onno van der Linden's
analysis in PR 45131. Kindly tested by Hisashi T Fujinaka (using csup
as the test case) with a successful outcome.
OK martin@
 1.35.4.2  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.35.4.1  17-Apr-2012  yamt sync with head
 1.37.2.1  23-Jun-2013  tls resync from head
 1.38.32.1  05-Oct-2021  martin Pull up following revision(s) (requested by christos in ticket #1355):

lib/libpthread/pthread_cancelstub.c: revision 1.39
lib/libc/sys/Makefile.inc: revision 1.247
lib/libpthread/pthread_cancelstub.c: revision 1.40

PR/56424: Clay Mayers: recvfrom() is not a cancelation point as documented
in pthread_setcanceltype.3

remove parameter names from decls.
 1.45.2.1  02-Aug-2025  perseant Sync with HEAD

RSS XML Feed