blob: e4697afd5d8a8dac15abdccf11d31bdd2143e8e7 [file] [log] [blame]
bartc8441502009-07-27 16:03:51 +00001/**
2 * @file rwlock_type_checking.c
3 *
4 * @brief Test whether DRD reports attempts to use a user-defined rwlock as
5 * a POSIX rwlock and vice versa.
6 */
7
8
9#define _GNU_SOURCE 1
10
11#include <pthread.h>
12#include <stdio.h>
bart67707ec2009-07-27 17:02:52 +000013#include <string.h>
bartc8441502009-07-27 16:03:51 +000014#include "../../config.h"
15#include "../../drd/drd.h"
16
17
18int main(int argc, char** argv)
19{
20 pthread_rwlock_t posix_rwlock;
bart67707ec2009-07-27 17:02:52 +000021 pthread_rwlock_t user_defined_rwlock;
bartc8441502009-07-27 16:03:51 +000022
bart67707ec2009-07-27 17:02:52 +000023 memset(&user_defined_rwlock, 0, sizeof(user_defined_rwlock));
bartc8441502009-07-27 16:03:51 +000024 ANNOTATE_RWLOCK_CREATE(&user_defined_rwlock);
25 pthread_rwlock_init(&posix_rwlock, 0);
26
bart67707ec2009-07-27 17:02:52 +000027 pthread_rwlock_init((pthread_rwlock_t*)&user_defined_rwlock, 0);
bartc8441502009-07-27 16:03:51 +000028
bart67707ec2009-07-27 17:02:52 +000029 ANNOTATE_READERLOCK_RELEASED(&posix_rwlock);
bartc8441502009-07-27 16:03:51 +000030
31 pthread_rwlock_destroy(&posix_rwlock);
32 ANNOTATE_RWLOCK_DESTROY(&user_defined_rwlock);
33
34 fprintf(stderr, "Finished.\n");
35
36 return 0;
37}