From 914b87dd71aeaa3d4d8b9e9308b336994be9d600 Mon Sep 17 00:00:00 2001 From: bje Date: Wed, 22 Jul 1998 05:01:25 +0000 Subject: New files. --- tests/equal.c | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 tests/equal.c (limited to 'tests/equal.c') diff --git a/tests/equal.c b/tests/equal.c new file mode 100644 index 0000000..12dbfc2 --- /dev/null +++ b/tests/equal.c @@ -0,0 +1,39 @@ +/* + * Test for pthread_equal(). + * + * Depends on API functions: pthread_create(). + */ + +#include +#include +#include + +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; +} -- cgit v1.2.3