Skip to content

Commit 7230f35

Browse files
photoszztwkozaczuk
authored andcommitted
add pthread_setcanceltype implementation
Signed-off-by: Zhiting Zhu <zhitingz@cs.utexas.edu> Message-Id: <20191230193403.61022-1-zhitingz@cs.utexas.edu>
1 parent c7fce2e commit 7230f35

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

libc/pthread.cc

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ namespace pthread_private {
3939
__thread void* tsd[tsd_nkeys];
4040
__thread pthread_t current_pthread;
4141
__thread int cancel_state = PTHREAD_CANCEL_ENABLE;
42+
__thread int cancel_type = PTHREAD_CANCEL_DEFERRED;
4243

4344
// NOTE: currently, the list of keys and destructor for each is global,
4445
// not per shared object or ELF namespace. So if a shared object uses
@@ -736,9 +737,16 @@ int pthread_setcancelstate(int state, int *oldstate)
736737
return 0;
737738
}
738739

739-
int pthread_setcanceltype(int state, int *oldstate)
740+
int pthread_setcanceltype(int type, int *oldtype)
740741
{
741-
WARN_STUBBED();
742+
if (type != PTHREAD_CANCEL_ASYNCHRONOUS &&
743+
type != PTHREAD_CANCEL_DEFERRED) {
744+
return EINVAL;
745+
}
746+
if (oldtype) {
747+
(*oldtype) = cancel_type;
748+
}
749+
cancel_type = type;
742750
return 0;
743751
}
744752

0 commit comments

Comments
 (0)