bart | c844150 | 2009-07-27 16:03:51 +0000 | [diff] [blame] | 1 | /** |
| 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> |
bart | 67707ec | 2009-07-27 17:02:52 +0000 | [diff] [blame^] | 13 | #include <string.h> |
bart | c844150 | 2009-07-27 16:03:51 +0000 | [diff] [blame] | 14 | #include "../../config.h" |
| 15 | #include "../../drd/drd.h" |
| 16 | |
| 17 | |
| 18 | int main(int argc, char** argv) |
| 19 | { |
| 20 | pthread_rwlock_t posix_rwlock; |
bart | 67707ec | 2009-07-27 17:02:52 +0000 | [diff] [blame^] | 21 | pthread_rwlock_t user_defined_rwlock; |
bart | c844150 | 2009-07-27 16:03:51 +0000 | [diff] [blame] | 22 | |
bart | 67707ec | 2009-07-27 17:02:52 +0000 | [diff] [blame^] | 23 | memset(&user_defined_rwlock, 0, sizeof(user_defined_rwlock)); |
bart | c844150 | 2009-07-27 16:03:51 +0000 | [diff] [blame] | 24 | ANNOTATE_RWLOCK_CREATE(&user_defined_rwlock); |
| 25 | pthread_rwlock_init(&posix_rwlock, 0); |
| 26 | |
bart | 67707ec | 2009-07-27 17:02:52 +0000 | [diff] [blame^] | 27 | pthread_rwlock_init((pthread_rwlock_t*)&user_defined_rwlock, 0); |
bart | c844150 | 2009-07-27 16:03:51 +0000 | [diff] [blame] | 28 | |
bart | 67707ec | 2009-07-27 17:02:52 +0000 | [diff] [blame^] | 29 | ANNOTATE_READERLOCK_RELEASED(&posix_rwlock); |
bart | c844150 | 2009-07-27 16:03:51 +0000 | [diff] [blame] | 30 | |
| 31 | pthread_rwlock_destroy(&posix_rwlock); |
| 32 | ANNOTATE_RWLOCK_DESTROY(&user_defined_rwlock); |
| 33 | |
| 34 | fprintf(stderr, "Finished.\n"); |
| 35 | |
| 36 | return 0; |
| 37 | } |