Annotation of src/lib/libpthread/pthread_types.h, Revision 1.1.2.4
1.1.2.4 ! nathanw 1: /* $NetBSD: pthread_types.h,v 1.1.2.3 2001/07/24 21:28:11 nathanw Exp $ */
1.1.2.1 nathanw 2:
1.1.2.2 nathanw 3: /*-
4: * Copyright (c) 2001 The NetBSD Foundation, Inc.
5: * All rights reserved.
6: *
7: * This code is derived from software contributed to The NetBSD Foundation
8: * by Nathan J. Williams.
9: *
10: * Redistribution and use in source and binary forms, with or without
11: * modification, are permitted provided that the following conditions
12: * are met:
13: * 1. Redistributions of source code must retain the above copyright
14: * notice, this list of conditions and the following disclaimer.
15: * 2. Redistributions in binary form must reproduce the above copyright
16: * notice, this list of conditions and the following disclaimer in the
17: * documentation and/or other materials provided with the distribution.
18: * 3. All advertising materials mentioning features or use of this software
19: * must display the following acknowledgement:
20: * This product includes software developed by the NetBSD
21: * Foundation, Inc. and its contributors.
22: * 4. Neither the name of The NetBSD Foundation nor the names of its
23: * contributors may be used to endorse or promote products derived
24: * from this software without specific prior written permission.
25: *
26: * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
27: * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
28: * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
29: * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
30: * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
31: * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
32: * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
33: * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
34: * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
35: * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
36: * POSSIBILITY OF SUCH DAMAGE.
1.1.2.1 nathanw 37: */
38:
39: #ifndef _LIB_PTHREAD_TYPES_H
40: #define _LIB_PTHREAD_TYPES_H
41:
42: #include <machine/lock.h>
43: #include "pthread_queue.h"
44:
45: typedef __cpu_simple_lock_t pt_spin_t;
46:
47: PTQ_HEAD(pt_queue_t, pthread_st);
48:
49: struct pthread_st;
50: struct pthread_attr_st;
51: struct pthread_mutex_st;
52: struct pthread_mutexattr_st;
53: struct pthread_cond_st;
54: struct pthread_condattr_st;
55:
56: typedef struct pthread_st *pthread_t;
57: typedef struct pthread_attr_st pthread_attr_t;
58: typedef struct pthread_mutex_st pthread_mutex_t;
59: typedef struct pthread_mutexattr_st pthread_mutexattr_t;
60: typedef struct pthread_cond_st pthread_cond_t;
61: typedef struct pthread_condattr_st pthread_condattr_t;
62:
63:
64: struct pthread_attr_st {
65: unsigned int pta_magic;
66:
67: int pta_flags;
68: };
69:
70: struct pthread_mutex_st {
71: unsigned int ptm_magic;
72:
73: /* Not a real spinlock; will never be spun on. Locked with
74: * __cpu_simple_lock_try() or not at all. Therefore, not
75: * subject to preempted-spinlock-continuation.
76: *
77: * Open research question: Would it help threaded applications if
78: * preempted-lock-continuation were applied to mutexes?
79: */
80: pt_spin_t ptm_lock;
81:
82: /* Protects the owner and blocked queue */
83: pt_spin_t ptm_interlock;
84: pthread_t ptm_owner;
85: struct pt_queue_t ptm_blocked;
86: };
87:
1.1.2.3 nathanw 88: #define _PT_MUTEX_MAGIC 0xCAFEFEED
89: #define _PT_MUTEX_DEAD 0xFEEDDEAD
1.1.2.1 nathanw 90:
91: #define PTHREAD_MUTEX_INITIALIZER { PT_MUTEX_MAGIC, \
92: __SIMPLELOCK_UNLOCKED, \
93: __SIMPLELOCK_UNLOCKED, \
94: NULL, \
95: PTQ_HEAD_INITIALIZER \
96: }
97:
98:
99: struct pthread_mutexattr_st {
1.1.2.4 ! nathanw 100: int pad;
! 101: };
! 102:
! 103:
! 104: struct pthread_cond_st {
! 105: unsigned int ptc_magic;
! 106:
! 107: /* Protects the queue of waiters */
! 108: pt_spin_t ptc_lock;
! 109: struct pt_queue_t ptc_waiters;
! 110:
! 111: pthread_mutex_t *ptc_mutex; /* Current mutex */
! 112: };
! 113:
! 114: #define _PT_COND_MAGIC 0xCAFEC00D
! 115: #define _PT_COND_DEAD 0xDEADC00D
! 116:
! 117: struct pthread_condattr_st {
1.1.2.1 nathanw 118: int pad;
119: };
120:
121: #endif /* _LIB_PTHREAD_TYPES_H */
CVSweb <webmaster@jp.NetBSD.org>