Commit | Line | Data |
---|---|---|
90269d47 | 1 | /* ==== cond.h ============================================================ |
56a62443 | 2 | * Copyright (c) 1993 by Chris Provenzano, proven@mit.edu |
30b08b75 AM |
3 | * All rights reserved. |
4 | * | |
5 | * Redistribution and use in source and binary forms, with or without | |
6 | * modification, are permitted provided that the following conditions | |
7 | * are met: | |
8 | * 1. Redistributions of source code must retain the above copyright | |
9 | * notice, this list of conditions and the following disclaimer. | |
10 | * 2. Redistributions in binary form must reproduce the above copyright | |
11 | * notice, this list of conditions and the following disclaimer in the | |
12 | * documentation and/or other materials provided with the distribution. | |
13 | * 3. All advertising materials mentioning features or use of this software | |
14 | * must display the following acknowledgement: | |
56a62443 CP |
15 | * This product includes software developed by Chris Provenzano. |
16 | * 4. The name of Chris Provenzano may not be used to endorse or promote | |
17 | * products derived from this software without specific prior written | |
18 | * permission. | |
30b08b75 | 19 | * |
56a62443 | 20 | * THIS SOFTWARE IS PROVIDED BY CHRIS PROVENZANO ``AS IS'' AND |
30b08b75 AM |
21 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
22 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | |
56a62443 CP |
23 | * ARE DISCLAIMED. IN NO EVENT SHALL CHRIS PROVENZANO BE LIABLE FOR ANY |
24 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | |
25 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR | |
26 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER | |
27 | * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | |
28 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | |
29 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | |
30 | * SUCH DAMAGE. | |
31 | * | |
32 | * Description : mutex header. | |
33 | * | |
34 | * 1.00 93/10/30 proven | |
35 | * -Started coding this file. | |
30b08b75 | 36 | */ |
56a62443 | 37 | |
90269d47 AM |
38 | /* |
39 | * New cond structures | |
40 | */ | |
41 | enum pthread_cond_type { | |
42 | COND_TYPE_FAST, | |
43 | COND_TYPE_STATIC_FAST, | |
44 | COND_TYPE_METERED, | |
45 | COND_TYPE_DEBUG, /* Debug conds will have lots of options */ | |
46 | COND_TYPE_MAX | |
47 | }; | |
48 | ||
49 | typedef struct pthread_cond { | |
50 | enum pthread_cond_type c_type; | |
51 | struct pthread_queue c_queue; | |
52 | semaphore c_lock; | |
53 | void * c_data; | |
54 | long c_flags; | |
55 | } pthread_cond_t; | |
56 | ||
57 | typedef struct pthread_cond_attr { | |
58 | enum pthread_cond_type c_type; | |
59 | long c_flags; | |
60 | } pthread_condattr_t; | |
61 | ||
62 | /* | |
63 | * Flags for conds. | |
64 | */ | |
65 | #define COND_FLAGS_PRIVATE 0x01 | |
66 | #define COND_FLAGS_INITED 0x02 | |
67 | #define COND_FLAGS_BUSY 0x04 | |
68 | ||
69 | /* | |
70 | * Static cond initialization values. | |
71 | */ | |
72 | #define PTHREAD_COND_INITIALIZER \ | |
73 | { COND_TYPE_STATIC_FAST, PTHREAD_QUEUE_INITIALIZER, \ | |
74 | NULL, SEMAPHORE_CLEAR, COND_FLAGS_INITED } | |
75 | ||
76 | /* | |
77 | * New functions | |
78 | */ | |
79 | ||
80 | __BEGIN_DECLS | |
81 | ||
82 | int pthread_cond_init __P((pthread_cond_t *, pthread_condattr_t *)); | |
83 | int pthread_cond_wait __P((pthread_cond_t *, pthread_mutex_t *)); | |
84 | int pthread_cond_signal __P((pthread_cond_t *)); | |
85 | int pthread_cond_broadcast __P((pthread_cond_t *)); | |
86 | int pthread_cond_destroy __P((pthread_cond_t *)); | |
87 | ||
88 | __END_DECLS | |
89 |