summaryrefslogtreecommitdiff
path: root/tests/equal.c
blob: 12dbfc23e7fdf3155bfd21cb680eb134c9b59fa1 (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
35
36
37
38
39
/*
 * Test for pthread_equal().
 *
 * Depends on API functions: pthread_create().
 */

#include <pthread.h>
#include <stdlib.h>
#include <stdio.h>

void *
func(void * arg)
{
	for (;;)
	{ /* spin */ }
}

int
main(int argc, char * argv[])
{
	pthread_t id[2];
	int rc;

	/* Create two threads and compare their thread IDs.
	   The threads will chew CPU, but ensure that their
	   IDs will be valid for a long time :-). */

	pthread_create(&id[0], NULL, entry, NULL);
	pthread_create(&id[1], NULL, entry, NULL);

	if (pthread_equal(id[0], id[1]) == 0)
	{
		/* This is impossible. */
		abort();
	}
	
	/* Never reached. */
	return 0;
}