Standardize License information
[openafs.git] / src / WINNT / pthread / test / tsd.c
1 /*
2  * Copyright 2000, International Business Machines Corporation and others.
3  * All Rights Reserved.
4  * 
5  * This software has been released under the terms of the IBM Public
6  * License.  For details, see the LICENSE file in the top-level source
7  * directory or online at http://www.openafs.org/dl/license10.html
8  */
9
10 /*
11  * Test thread specific data functionality.
12  *
13  */
14
15 #include <afs/param.h>
16 #include <afs/stds.h>
17
18 #include <stdio.h>
19 #include <stdlib.h>
20 #include <time.h>
21 #include <pthread.h>
22 #include <assert.h>
23
24 #define NTH 10
25
26 pthread_key_t key;
27
28 void destruct(void *val) {
29 }
30
31 void * threadFunc(void *arg) {
32
33     pthread_setspecific(key, arg);
34     assert(pthread_getspecific(key) == arg);
35     return (void *) 0;
36 }
37
38
39 int main(int argc, char **argv) {
40
41     pthread_t tid[NTH];
42     int i,j;
43
44     i = pthread_key_create(&key,destruct);
45     assert(i==0);
46
47     for(j=0;j<NTH;j++) {
48         i = pthread_create(&tid[j], (const pthread_attr_t *) 0,
49             threadFunc, (void *) j);
50         assert(i==0);
51     }
52     for(j=0;j<NTH;j++) {
53         i = pthread_join(tid[j], (void **) 0);
54         assert(i==0);
55     }
56     return 0;
57 }