File: pthread.c

package info (click to toggle)
cairo 1.18.4-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 72,788 kB
  • sloc: ansic: 217,451; cpp: 2,108; cs: 1,763; xml: 1,280; sh: 990; python: 433; javascript: 347; awk: 89; makefile: 83
file content (35 lines) | stat: -rw-r--r-- 844 bytes parent folder | download | duplicates (15)
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
35
#ifndef _GNU_SOURCE
#define _GNU_SOURCE /* for PTHREAD_MUTEX_INITIALIZER under linux */
#endif
#include <pthread.h>

pthread_mutex_t test_mutex_initializer = PTHREAD_MUTEX_INITIALIZER;
int test_mutex (void)
{
	int x = 0;
	pthread_mutex_t mutex;
	x |= pthread_mutex_init (&mutex, NULL);
	x |= pthread_mutex_lock (&mutex);
	x |= pthread_mutex_unlock (&mutex);
	x |= pthread_mutex_destroy (&mutex);
	return 0;
}

int test_mutex_attr (void)
{
	int x = 0;
	pthread_mutexattr_t attr;
	pthread_mutex_t mutex;
	x |= pthread_mutexattr_init (&attr);
	x |= pthread_mutexattr_settype (&attr, PTHREAD_MUTEX_RECURSIVE);
	x |= pthread_mutex_init (&mutex, &attr);
	x |= pthread_mutex_lock (&mutex);
	x |= pthread_mutex_unlock (&mutex);
	x |= pthread_mutex_destroy (&mutex);
	x |= pthread_mutexattr_destroy (&attr);
	return x;
}

int main(void) {
  return 0;
}