summaryrefslogtreecommitdiff
path: root/test/msan/pthread_setcancelstate.cc
blob: 087c2223a83d22f50b6647a66c3f59ad1fc48a8c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
// RUN: %clangxx_msan -O0 %s -o %t && %run %t

#include <assert.h>
#include <pthread.h>
#include <sanitizer/msan_interface.h>

int main(void) {
  int oldstate;
  int oldtype;
  int res = pthread_setcancelstate(PTHREAD_CANCEL_DISABLE, &oldstate);
  assert(res == 0);
  __msan_check_mem_is_initialized(&oldstate, sizeof(oldstate));

  res = pthread_setcanceltype(PTHREAD_CANCEL_DEFERRED, &oldtype);
  assert(res == 0);
  __msan_check_mem_is_initialized(&oldtype, sizeof(oldtype));

  return 0;
}