summaryrefslogtreecommitdiff
path: root/tests/rwlock2.c
blob: cfb32282c96e99b058bd8b4ee210e77da0ce8750 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
/* 
 * rwlock2.c
 *
 * Declare a static rwlock object, lock it, 
 * and then unlock it again.
 *
 * Depends on API functions: 
 *	pthread_rwlock_rdlock()
 *	pthread_rwlock_unlock()
 */

#include "test.h"
 
pthread_rwlock_t rwlock = PTHREAD_RWLOCK_INITIALIZER;

int
main()
{
  assert(rwlock == PTHREAD_RWLOCK_INITIALIZER);

  assert(pthread_rwlock_rdlock(&rwlock) == 0);

  assert(rwlock != PTHREAD_RWLOCK_INITIALIZER);

  assert(rwlock != NULL);

  assert(pthread_rwlock_unlock(&rwlock) == 0);

  assert(pthread_rwlock_destroy(&rwlock) == 0);

  assert(rwlock == NULL);

  return 0;
}