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
17 * Header file for stack management (internal to cma_stack.c, but
18 * separate for convenience, and unit testing).
29 #include <cma_queue.h>
31 #include <cma_tcb_defs.h>
34 * CONSTANTS AND MACROS
37 #define cma___c_first_free_chunk 0
38 #define cma___c_min_count 2 /* Smallest number of chunks
40 #define cma___c_end (-1) /* End of free list (flag) */
41 #define cma__c_yellow_size 0
46 #define cma___c_cluster 0 /* Default cluster */
47 #define cma___c_bigstack 1 /* Looks like a cluster, but it's a stack */
50 #define cma___c_null_cluster (cma___t_cluster *)cma_c_null_ptr
58 struct CMA__T_INT_STACK
;
61 typedef cma_t_natural cma___t_index
; /* Type for chunk index */
63 typedef struct CMA___T_CLU_DESC
{
64 cma__t_list list
; /* Queue element for cluster list */
65 cma_t_integer type
; /* Type of cluster */
70 typedef union CMA___T_MAP_ENTRY
{
72 cma__t_int_tcb
*tcb
; /* TCB associated with stack chunk */
73 struct CMA__T_INT_STACK
*stack
; /* Stack desc. ass. with stack chunk */
76 cma___t_index size
; /* Number of chunks in block */
77 cma___t_index next
; /* Next free block */
82 * NOTE: It is VERY IMPORTANT that both cma___t_cluster and cma___t_bigstack
83 * begin with the cma___t_clu_desc structure, as there is some code in the
84 * stack manager that relies on being able to treat both as equivalent!
86 typedef struct CMA___T_CLUSTER
{
87 cma___t_clu_desc desc
; /* Describe this cluster */
88 cma___t_map_entry map
[cma__c_chunk_count
]; /* thread map */
89 cma___t_index free
; /* First free chunk index */
93 * NOTE: It is VERY IMPORTANT that both cma___t_cluster and cma___t_bigstack
94 * begin with the cma___t_clu_desc structure, as there is some code in the
95 * stack manager that relies on being able to treat both as equivalent!
97 typedef struct CMA___T_BIGSTACK
{
98 cma___t_clu_desc desc
; /* Describe this cluster */
99 cma__t_int_tcb
*tcb
; /* TCB associated with stack */
100 struct CMA__T_INT_STACK
*stack
; /* Stack desc. ass. with stack */
101 cma_t_natural size
; /* Size of big stack */
102 cma_t_boolean in_use
; /* Set if allocated */
105 #if _CMA_PROTECT_MEMORY_
106 typedef struct CMA___T_INT_HOLE
{
107 cma__t_queue link
; /* Link holes together */
108 cma_t_boolean
protected; /* Set when pages are protected */
109 cma_t_address first
; /* First protected byte */
110 cma_t_address last
; /* Last protected byte */
114 typedef struct CMA__T_INT_STACK
{
115 cma__t_object header
; /* Common header (sequence,
117 cma__t_int_attr
*attributes
; /* Backpointer to attr obj */
118 cma___t_cluster
*cluster
; /* Stack's cluster */
119 cma_t_address stack_base
; /* base address of stack */
120 cma_t_address yellow_zone
; /* first address of yellow zone */
121 cma_t_address last_guard
; /* last address of guard pages */
122 cma_t_natural first_chunk
; /* First chunk allocated */
123 cma_t_natural chunk_count
; /* Count of chunks allocated */
124 cma__t_int_tcb
*tcb
; /* TCB backpointer */
125 #if _CMA_PROTECT_MEMORY_
126 cma___t_int_hole hole
; /* Description of hole */
135 * INTERNAL INTERFACES