1799172d60d32feb1acba1a6867f3a9c39a999e5cPirama Arumuga Nainar// RUN: %clangxx_msan -O0 -g %s -o %t && %run %t 2799172d60d32feb1acba1a6867f3a9c39a999e5cPirama Arumuga Nainar 3799172d60d32feb1acba1a6867f3a9c39a999e5cPirama Arumuga Nainar#include <assert.h> 4799172d60d32feb1acba1a6867f3a9c39a999e5cPirama Arumuga Nainar#include <sanitizer/msan_interface.h> 5799172d60d32feb1acba1a6867f3a9c39a999e5cPirama Arumuga Nainar#include <semaphore.h> 6799172d60d32feb1acba1a6867f3a9c39a999e5cPirama Arumuga Nainar 7799172d60d32feb1acba1a6867f3a9c39a999e5cPirama Arumuga Nainarint main(void) { 8799172d60d32feb1acba1a6867f3a9c39a999e5cPirama Arumuga Nainar sem_t sem; 9799172d60d32feb1acba1a6867f3a9c39a999e5cPirama Arumuga Nainar int res = sem_init(&sem, 0, 42); 10799172d60d32feb1acba1a6867f3a9c39a999e5cPirama Arumuga Nainar assert(res == 0); 11799172d60d32feb1acba1a6867f3a9c39a999e5cPirama Arumuga Nainar 12799172d60d32feb1acba1a6867f3a9c39a999e5cPirama Arumuga Nainar int v; 13799172d60d32feb1acba1a6867f3a9c39a999e5cPirama Arumuga Nainar res = sem_getvalue(&sem, &v); 14799172d60d32feb1acba1a6867f3a9c39a999e5cPirama Arumuga Nainar assert(res == 0); 15799172d60d32feb1acba1a6867f3a9c39a999e5cPirama Arumuga Nainar __msan_check_mem_is_initialized(&v, sizeof(v)); 16799172d60d32feb1acba1a6867f3a9c39a999e5cPirama Arumuga Nainar assert(v == 42); 17799172d60d32feb1acba1a6867f3a9c39a999e5cPirama Arumuga Nainar 18799172d60d32feb1acba1a6867f3a9c39a999e5cPirama Arumuga Nainar res = sem_destroy(&sem); 19799172d60d32feb1acba1a6867f3a9c39a999e5cPirama Arumuga Nainar assert(res == 0); 20799172d60d32feb1acba1a6867f3a9c39a999e5cPirama Arumuga Nainar 21799172d60d32feb1acba1a6867f3a9c39a999e5cPirama Arumuga Nainar return 0; 22799172d60d32feb1acba1a6867f3a9c39a999e5cPirama Arumuga Nainar} 23