提交 9beb6330 编写于 作者: R Rich Felker

simplify cancellation point handling

we take advantage of the fact that unless self->cancelpt is 1,
cancellation cannot happen. so just increment it by 2 to temporarily
block cancellation. this drops pthread_create.o well under 1k.
上级 19c1830e
...@@ -63,19 +63,8 @@ static void cancel_handler(int sig, siginfo_t *si, void *ctx) ...@@ -63,19 +63,8 @@ static void cancel_handler(int sig, siginfo_t *si, void *ctx)
static void cancelpt(int x) static void cancelpt(int x)
{ {
struct pthread *self = __pthread_self(); struct pthread *self = __pthread_self();
switch (x) { if ((self->cancelpoint+=x)==1 && self->cancel
case 1: && x<2U && !self->canceldisable) docancel(self);
self->cancelpoint++;
case 0:
if (self->cancel && self->cancelpoint==1 && !self->canceldisable)
docancel(self);
break;
case -1:
self->cancelpoint--;
break;
default:
self->canceldisable += x;
}
} }
static void init_threads() static void init_threads()
......
...@@ -3,8 +3,8 @@ ...@@ -3,8 +3,8 @@
int pthread_setcancelstate(int new, int *old) int pthread_setcancelstate(int new, int *old)
{ {
struct pthread *self = pthread_self(); struct pthread *self = pthread_self();
if (old) *old = self->canceldisable & 1; if (old) *old = self->canceldisable;
if ((unsigned)new > 1) return EINVAL; if (new > 1U) return EINVAL;
self->canceldisable = (self->canceldisable & ~1) | new; self->canceldisable = new;
return 0; return 0;
} }
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册