summaryrefslogtreecommitdiff
path: root/src/thread/pthread_setcancelstate.c
diff options
context:
space:
mode:
authorRich Felker <dalias@aerifal.cx>2011-04-05 18:00:28 -0400
committerRich Felker <dalias@aerifal.cx>2011-04-05 18:00:28 -0400
commit729cb49f52c825ac44f437e1ff0865d9f0b3626a (patch)
tree18db05e36f16fcdfc1147f4ba1ea19a0ee4bea9c /src/thread/pthread_setcancelstate.c
parent918a40f257328a2d7490829b54687cd38d7b787b (diff)
downloadmusl-729cb49f52c825ac44f437e1ff0865d9f0b3626a.tar.gz
new framework to inhibit thread cancellation when needed
with these small changes, libc functions which need to call functions which are cancellation points, but which themselves must not be cancellation points, can use the CANCELPT_INHIBIT and CANCELPT_RESUME macros to temporarily inhibit all cancellation.
Diffstat (limited to 'src/thread/pthread_setcancelstate.c')
-rw-r--r--src/thread/pthread_setcancelstate.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/src/thread/pthread_setcancelstate.c b/src/thread/pthread_setcancelstate.c
index 23c38851..a85cc800 100644
--- a/src/thread/pthread_setcancelstate.c
+++ b/src/thread/pthread_setcancelstate.c
@@ -3,8 +3,8 @@
int pthread_setcancelstate(int new, int *old)
{
struct pthread *self = pthread_self();
- if (old) *old = self->canceldisable;
+ if (old) *old = self->canceldisable & 1;
if ((unsigned)new > 1) return EINVAL;
- self->canceldisable = new;
+ self->canceldisable = (self->canceldisable & ~1) | new;
return 0;
}