xref: /aosp_15_r20/external/compiler-rt/test/msan/pthread_setcancelstate.cc (revision 7c3d14c8b49c529e04be81a3ce6f5cc23712e4c6)
1*7c3d14c8STreehugger Robot // RUN: %clangxx_msan -O0 %s -o %t && %run %t
2*7c3d14c8STreehugger Robot 
3*7c3d14c8STreehugger Robot #include <assert.h>
4*7c3d14c8STreehugger Robot #include <pthread.h>
5*7c3d14c8STreehugger Robot #include <sanitizer/msan_interface.h>
6*7c3d14c8STreehugger Robot 
main(void)7*7c3d14c8STreehugger Robot int main(void) {
8*7c3d14c8STreehugger Robot   int oldstate;
9*7c3d14c8STreehugger Robot   int oldtype;
10*7c3d14c8STreehugger Robot   int res = pthread_setcancelstate(PTHREAD_CANCEL_DISABLE, &oldstate);
11*7c3d14c8STreehugger Robot   assert(res == 0);
12*7c3d14c8STreehugger Robot   __msan_check_mem_is_initialized(&oldstate, sizeof(oldstate));
13*7c3d14c8STreehugger Robot 
14*7c3d14c8STreehugger Robot   res = pthread_setcanceltype(PTHREAD_CANCEL_DEFERRED, &oldtype);
15*7c3d14c8STreehugger Robot   assert(res == 0);
16*7c3d14c8STreehugger Robot   __msan_check_mem_is_initialized(&oldtype, sizeof(oldtype));
17*7c3d14c8STreehugger Robot 
18*7c3d14c8STreehugger Robot   return 0;
19*7c3d14c8STreehugger Robot }
20