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