aboutsummaryrefslogtreecommitdiff
path: root/gdb/osf-share/cma_attr.h
blob: 389fd6fd207c6a27f20a8313d4ff9effd66ad3f4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
/* 
 * (c) Copyright 1990-1996 OPEN SOFTWARE FOUNDATION, INC.
 * (c) Copyright 1990-1996 HEWLETT-PACKARD COMPANY
 * (c) Copyright 1990-1996 DIGITAL EQUIPMENT CORPORATION
 * (c) Copyright 1991, 1992 Siemens-Nixdorf Information Systems
 * To anyone who acknowledges that this file is provided "AS IS" without
 * any express or implied warranty: permission to use, copy, modify, and
 * distribute this file for any purpose is hereby granted without fee,
 * provided that the above copyright notices and this notice appears in
 * all source code copies, and that none of the names listed above be used
 * in advertising or publicity pertaining to distribution of the software
 * without specific, written prior permission.  None of these organizations
 * makes any representations about the suitability of this software for
 * any purpose.
 */
/*
 *	Header file for attributes object
 */

#ifndef CMA_ATTR
#define CMA_ATTR

/*
 *  INCLUDE FILES
 */

#include <cma_defs.h>
#include <cma_queue.h>
#ifdef __hpux
# include <sys/param.h>
#endif
#if _CMA_UNIX_TYPE == _CMA__SVR4
#include <sys/unistd.h>
#endif
/*
 * CONSTANTS AND MACROS
 */


/*
 *  FUNCTIONAL DESCRIPTION:
 *
 *	cma__int_attr_get_priority -  Performs the work of cma_attr_get_priority
 *
 *  FORMAL PARAMETERS:
 *
 *	cma_t_attr	    *_att_	- Attribute object to get from
 *	cma_t_priority	    *_setting_	- Current setting
 *
 *  IMPLICIT INPUTS:
 *
 *	none
 *
 *  IMPLICIT OUTPUTS:
 *
 *	priority
 *
 *  FUNCTION VALUE:
 *
 *	none
 *
 *  SIDE EFFECTS:
 *
 *	none
 */
#define cma__int_attr_get_priority(_att_,_setting_) { \
    cma__t_int_attr     *_int_att_; \
    (_int_att_) = cma__validate_default_attr (_att_); \
    cma__int_lock ((_int_att_)->mutex); \
    (*(_setting_)) = (_int_att_)->priority; \
    cma__int_unlock ((_int_att_)->mutex); \
    }


/*
 *  FUNCTIONAL DESCRIPTION:
 *
 *	cma__int_attr_get_sched - Performs work of cma_attr_get_sched
 *
 *  FORMAL PARAMETERS:
 *
 *	cma_t_attr	    *_att_	_ Attributes object used
 *	cma_t_sched_policy  *_setting_	- Current setting
 *
 *  IMPLICIT INPUTS:
 *
 *	none
 *
 *  IMPLICIT OUTPUTS:
 *
 *	scheduling policy
 *
 *  FUNCTION VALUE:
 *
 *	none
 *
 *  SIDE EFFECTS:
 *
 *	none
 */
#define cma__int_attr_get_sched(_att_,_setting_) { \
    cma__t_int_attr     *_int_att_; \
    (_int_att_) = cma__validate_default_attr (_att_); \
    cma__int_lock ((_int_att_)->mutex); \
    (*(_setting_)) = (_int_att_)->policy; \
    cma__int_unlock ((_int_att_)->mutex); \
    }


/*
 *  FUNCTIONAL DESCRIPTION:
 *
 *	cma__int_attr_get_inherit_sched - Performs work of 
 *	cma_attr_get_inherit_sched
 *
 *  FORMAL PARAMETERS:
 *
 *	cma_t_attr	    *_att_	- Attributes object to use
 *	cma_t_sched_inherit *_setting_	- Current setting
 *
 *  IMPLICIT INPUTS:
 *
 *	none
 *
 *  IMPLICIT OUTPUTS:
 *
 *	Inheritable scheduling policy
 *
 *  FUNCTION VALUE:
 *
 *	none
 *
 *  SIDE EFFECTS:
 *
 *	none
 */
#define cma__int_attr_get_inherit_sched(_att_,_setting_) { \
    cma__t_int_attr	*_int_att_; \
    (_int_att_) = cma__validate_default_attr (_att_); \
    cma__int_lock ((_int_att_)->mutex); \
    (*(_setting_)) \
        = ((_int_att_)->inherit_sched ? cma_c_sched_inherit : cma_c_sched_use_default); \
    cma__int_unlock ((_int_att_)->mutex); \
    }

/*
 *  FUNCTIONAL DESCRIPTION:
 *
 *	cma__int_attr_set_stacksize - Performs work for cma_attr_set_stacksize
 *
 *  FORMAL PARAMETERS:
 *
 *      cma_t_attr          *_att_      - Attributes object to use
 *	cma_t_natural	    _setting_	- Setting
 *
 *  IMPLICIT INPUTS:
 *
 *	none
 *
 *  IMPLICIT OUTPUTS:
 *
 *	none
 *
 *  FUNCTION VALUE:
 *
 *	none
 *
 *  SIDE EFFECTS:
 *
 *	Change attribute objects stack size setting
 */
#define cma__int_attr_set_stacksize(_att_,_setting_) { \
    cma__t_int_attr     *_int_att_; \
    if ((_setting_) <= 0) \
        cma__error (cma_s_badparam); \
    _int_att_ = cma__validate_attr (_att_); \
    cma__int_lock ((_int_att_)->mutex); \
    _int_att_->stack_size = cma__roundup_chunksize(_setting_); \
    cma__free_cache (_int_att_, cma__c_obj_tcb); \
    _int_att_->cache[cma__c_obj_tcb].revision++; \
    _int_att_->cache[cma__c_obj_stack].revision++; \
    cma__int_unlock (_int_att_->mutex); \
    }

/*
 *  FUNCTIONAL DESCRIPTION:
 *
 *	cma__int_attr_get_stacksize - Performs work of cma_attr_get_stacksize
 *
 *  FORMAL PARAMETERS:
 *
 *      cma_t_attr          *_att_      - Attributes object to use
 *	cma_t_natural	    *_setting_	- Current setting
 *
 *  IMPLICIT INPUTS:
 *
 *	none
 *
 *  IMPLICIT OUTPUTS:
 *
 *	Attribute objects stack size setting
 *
 *  FUNCTION VALUE:
 *
 *	none
 *
 *  SIDE EFFECTS:
 *
 *	none
 */
#define cma__int_attr_get_stacksize(_att_,_setting_) { \
    cma__t_int_attr     *_int_att_; \
    (_int_att_) = cma__validate_default_attr (_att_); \
    cma__int_lock ((_int_att_)->mutex); \
    (*(_setting_)) = (_int_att_)->stack_size; \
    cma__int_unlock ((_int_att_)->mutex); \
    }


/*
 *  FUNCTIONAL DESCRIPTION:
 *
 *	cma__int_attr_set_guardsize - Performs work for cma_attr_set_guardsize
 *
 *  FORMAL PARAMETERS:
 *
 *      cma_t_attr          *_att_      - Attributes object to use
 *	cma_t_natural	    _setting_	- Setting
 *
 *  IMPLICIT INPUTS:
 *
 *	none
 *
 *  IMPLICIT OUTPUTS:
 *
 *	none
 *
 *  FUNCTION VALUE:
 *
 *	none
 *
 *  SIDE EFFECTS:
 *
 *	Change attribute objects guard size setting
 */
#define cma__int_attr_set_guardsize(_att_,_setting_) { \
    cma__t_int_attr     *_int_att_; \
    _int_att_ = cma__validate_attr (_att_); \
    cma__int_lock ((_int_att_)->mutex); \
    _int_att_->guard_size = cma__roundup_chunksize(_setting_); \
    cma__free_cache (_int_att_, cma__c_obj_tcb); \
    _int_att_->cache[cma__c_obj_tcb].revision++; \
    _int_att_->cache[cma__c_obj_stack].revision++; \
    cma__int_unlock (_int_att_->mutex); \
    }

/*
 *  FUNCTIONAL DESCRIPTION:
 *
 *	cma__int_attr_get_guardsize - Performs work of cma_attr_get_guardsize
 *
 *  FORMAL PARAMETERS:
 *
 *      cma_t_attr          *_att_      - Attributes object to use
 *	cma_t_natural	    *_setting_	- Current setting
 *
 *  IMPLICIT INPUTS:
 *
 *	none
 *
 *  IMPLICIT OUTPUTS:
 *
 *	Attribute objects guard size setting
 *
 *  FUNCTION VALUE:
 *
 *	none
 *
 *  SIDE EFFECTS:
 *
 *	none
 */
#define cma__int_attr_get_guardsize(_att_,_setting_) { \
    cma__t_int_attr     *_int_att_; \
    (_int_att_) = cma__validate_default_attr (_att_); \
    cma__int_lock ((_int_att_)->mutex); \
    (*(_setting_)) = (_int_att_)->guard_size; \
    cma__int_unlock ((_int_att_)->mutex); \
    }

/*
 * TYPEDEFS
 */
#ifndef __STDC__
struct CMA__T_INT_MUTEX;		/* Avoid circular dependency */
#endif

typedef struct CMA__T_CACHE {
    cma_t_natural		revision;	/* Revisions */
    cma_t_natural		count;
    cma__t_queue		queue;	/* Cache headers */
    } cma__t_cache;

typedef struct CMA__T_INT_ATTR {
    cma__t_object		header;		/* Common header */
    struct CMA__T_INT_ATTR	*attributes;	/* Point to controlling attr */
    struct CMA__T_INT_MUTEX	*mutex;		/* Serialize access to object */
    cma_t_priority		priority;	/* Priority of new thread */
    cma_t_sched_policy		policy;		/* Sched policy of thread */
    cma_t_boolean		inherit_sched;	/* Is scheduling inherited? */
    cma_t_natural		stack_size;	/* Size of stack (bytes) */
    cma_t_natural		guard_size;	/* Size of guard (bytes) */
    cma_t_mutex_kind		mutex_kind;	/* Mutex kind */
    cma__t_cache		cache[cma__c_obj_num];	/* Cache information */
    cma_t_boolean		delete_pending;	/* attr. obj. is deleted */
    cma_t_natural		refcnt;	/* Number of objects using attr. obj */
    } cma__t_int_attr;

/*
 *  GLOBAL DATA
 */

extern cma__t_int_attr	cma__g_def_attr;

/*
 * INTERNAL INTERFACES
 */

extern void cma__destroy_attributes  (cma__t_int_attr *);

extern void cma__free_attributes  (cma__t_int_attr	*);

extern void cma__free_cache  (cma__t_int_attr *,cma_t_natural );

extern cma__t_int_attr *cma__get_attributes  (cma__t_int_attr	*);

extern void cma__init_attr  (void);

extern void cma__reinit_attr  (cma_t_integer);

#endif