1 /*
2  * (c) Copyright 1990-1996 OPEN SOFTWARE FOUNDATION, INC.
3  * (c) Copyright 1990-1996 HEWLETT-PACKARD COMPANY
4  * (c) Copyright 1990-1996 DIGITAL EQUIPMENT CORPORATION
5  * (c) Copyright 1991, 1992 Siemens-Nixdorf Information Systems
6  * To anyone who acknowledges that this file is provided "AS IS" without
7  * any express or implied warranty: permission to use, copy, modify, and
8  * distribute this file for any purpose is hereby granted without fee,
9  * provided that the above copyright notices and this notice appears in
10  * all source code copies, and that none of the names listed above be used
11  * in advertising or publicity pertaining to distribution of the software
12  * without specific, written prior permission.  None of these organizations
13  * makes any representations about the suitability of this software for
14  * any purpose.
15  */
16 /*
17  *	Header file for handles
18  */
19 
20 #ifndef CMA_HANDLE
21 #define CMA_HANDLE
22 
23 /*
24  *  INCLUDE FILES
25  */
26 
27 #include <cma_defs.h>
28 #include <cma_attr.h>
29 
30 /*
31  * CONSTANTS AND MACROS
32  */
33 
34 #define cma__validate_attr(handle) \
35     ((cma__t_int_attr *)cma__validate_handle ( \
36 	    (cma_t_handle *)(handle), \
37 	    cma__c_obj_attr))
38 
39 #define cma__validate_cv(handle) \
40     ((cma__t_int_cv *)cma__validate_handle ( \
41 	    (cma_t_handle *)(handle), \
42 	    cma__c_obj_cv))
43 
44 #define cma__validate_mutex(handle) \
45     ((cma__t_int_mutex *)cma__validate_handle ( \
46 	    (cma_t_handle *)(handle), \
47 	    cma__c_obj_mutex))
48 
49 #define cma__validate_tcb(handle) \
50     ((cma__t_int_tcb *)cma__validate_handle ( \
51 	    (cma_t_handle *)(handle), \
52 	    cma__c_obj_tcb))
53 
54 #define cma__validate_stack(handle) \
55     ((cma__t_int_stack *)cma__validate_handle ( \
56 	    (cma_t_handle *)(handle), \
57 	    cma__c_obj_stack))
58 
59 #define cma__validate_null_attr(handle) \
60     ((cma__t_int_attr *)cma__validate_handle_null ( \
61 	    (cma_t_handle *)(handle), \
62 	    cma__c_obj_attr))
63 
64 #define cma__validate_null_cv(handle) \
65     ((cma__t_int_cv *)cma__validate_handle_null ( \
66 	    (cma_t_handle *)(handle), \
67 	    cma__c_obj_cv))
68 
69 #define cma__validate_null_mutex(handle) \
70     ((cma__t_int_mutex *)cma__validate_handle_null ( \
71 	    (cma_t_handle *)(handle), \
72 	    cma__c_obj_mutex))
73 
74 #define cma__validate_null_tcb(handle) \
75     ((cma__t_int_tcb *)cma__validate_handle_null ( \
76 	    (cma_t_handle *)(handle), \
77 	    cma__c_obj_tcb))
78 
79 #define cma__validate_null_stack(handle) \
80     ((cma__t_int_stack *)cma__validate_handle_null ( \
81 	    (cma_t_handle *)(handle), \
82 	    cma__c_obj_stack))
83 
84 #define cma__val_attr_stat(handle,obj) \
85     cma__val_hand_stat ( \
86 	    (cma_t_handle *)(handle), \
87 	    cma__c_obj_attr, \
88 	    (cma__t_object **)obj)
89 
90 #define cma__val_cv_stat(handle,obj) \
91     cma__val_hand_stat ( \
92 	    (cma_t_handle *)(handle), \
93 	    cma__c_obj_cv, \
94 	    (cma__t_object **)obj)
95 
96 #define cma__val_mutex_stat(handle,obj) \
97     cma__val_hand_stat ( \
98 	    (cma_t_handle *)(handle), \
99 	    cma__c_obj_mutex, \
100 	    (cma__t_object **)obj)
101 
102 #define cma__val_tcb_stat(handle) \
103     cma__val_hand_stat ( \
104 	    (cma_t_handle *)(handle), \
105 	    cma__c_obj_tcb, \
106 	    (cma__t_object **)obj)
107 
108 #define cma__val_stack_stat(handle,obj) \
109     cma__val_hand_stat ( \
110 	    (cma_t_handle *)(handle), \
111 	    cma__c_obj_stack, \
112 	    (cma__t_object **)obj)
113 
114 #define cma__val_nullattr_stat(handle,obj) \
115     cma__val_handnull_stat ( \
116 	    (cma_t_handle *)(handle), \
117 	    cma__c_obj_attr, \
118 	    (cma__t_object **)obj)
119 
120 #define cma__val_nullcv_stat(handle,obj) \
121     cma__val_handnull_stat ( \
122 	    (cma_t_handle *)(handle), \
123 	    cma__c_obj_cv, \
124 	    (cma__t_object **)obj)
125 
126 #define cma__val_nullmutex_stat(handle,obj) \
127     cma__val_handnull_stat ( \
128 	    (cma_t_handle *)(handle), \
129 	    cma__c_obj_mutex, \
130 	    (cma__t_object **)obj)
131 
132 #define cma__val_nulltcb_stat(handle,obj) \
133     cma__val_handnull_stat ( \
134 	    (cma_t_handle *)(handle), \
135 	    cma__c_obj_tcb, \
136 	    (cma__t_object **)obj)
137 
138 #define cma__val_nullstack_stat(handle) \
139     cma__val_handnull_stat ( \
140 	    (cma_t_handle *)(handle), \
141 	    cma__c_obj_stack, \
142 	    (cma__t_object **)obj)
143 
144 /*
145  * TYPEDEFS
146  */
147 
148 /*
149  * Internal format of a handle (to the outside world it's an array of two
150  * addresses, but we know better).
151  */
152 typedef struct CMA__T_INT_HANDLE {
153     cma__t_object	*pointer;	/* Address of internal structure */
154     cma__t_short	sequence;	/* Sequence number of object */
155     cma__t_short	type;		/* Type code of object */
156     } cma__t_int_handle;
157 
158 /*
159  *  GLOBAL DATA
160  */
161 
162 /*
163  * INTERNAL INTERFACES
164  */
165 
166 extern void cma__clear_handle (cma_t_handle *);
167 
168 extern void cma__object_to_handle (cma__t_object *,cma_t_handle *);
169 
170 extern cma__t_int_attr * cma__validate_default_attr (cma_t_handle *);
171 
172 extern cma_t_status cma__val_defattr_stat (cma_t_handle *,cma__t_int_attr **);
173 
174 extern cma__t_object * cma__validate_handle (cma_t_handle *,cma_t_natural );
175 
176 extern cma_t_status cma__val_hand_stat (cma_t_handle *,cma_t_natural,cma__t_object **);
177 
178 extern 	cma__t_object	*cma__validate_handle_null (cma_t_handle *,cma_t_natural);
179 
180 extern cma_t_status cma__val_handnull_stat (cma_t_handle *,cma_t_natural,cma__t_object **);
181 
182 #endif
183