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 to leave */
39 #define cma___c_end (-1) /* End of free list (flag) */
40 #define cma__c_yellow_size 0
45 #define cma___c_cluster 0 /* Default cluster */
46 #define cma___c_bigstack 1 /* Looks like a cluster, but it's a stack */
49 #define cma___c_null_cluster (cma___t_cluster *)cma_c_null_ptr
57 struct CMA__T_INT_STACK;
60 typedef cma_t_natural cma___t_index; /* Type for chunk index */
62 typedef struct CMA___T_CLU_DESC {
63 cma__t_list list; /* Queue element for cluster list */
64 cma_t_integer type; /* Type of cluster */
69 typedef union CMA___T_MAP_ENTRY {
71 cma__t_int_tcb *tcb; /* TCB associated with stack chunk */
72 struct CMA__T_INT_STACK *stack; /* Stack desc. ass. with stack chunk */
75 cma___t_index size; /* Number of chunks in block */
76 cma___t_index next; /* Next free block */
81 * NOTE: It is VERY IMPORTANT that both cma___t_cluster and cma___t_bigstack
82 * begin with the cma___t_clu_desc structure, as there is some code in the
83 * stack manager that relies on being able to treat both as equivalent!
85 typedef struct CMA___T_CLUSTER {
86 cma___t_clu_desc desc; /* Describe this cluster */
87 cma___t_map_entry map[cma__c_chunk_count]; /* thread map */
88 cma___t_index free; /* First free chunk index */
92 * NOTE: It is VERY IMPORTANT that both cma___t_cluster and cma___t_bigstack
93 * begin with the cma___t_clu_desc structure, as there is some code in the
94 * stack manager that relies on being able to treat both as equivalent!
96 typedef struct CMA___T_BIGSTACK {
97 cma___t_clu_desc desc; /* Describe this cluster */
98 cma__t_int_tcb *tcb; /* TCB associated with stack */
99 struct CMA__T_INT_STACK *stack; /* Stack desc. ass. with stack */
100 cma_t_natural size; /* Size of big stack */
101 cma_t_boolean in_use; /* Set if allocated */
104 #if _CMA_PROTECT_MEMORY_
105 typedef struct CMA___T_INT_HOLE {
106 cma__t_queue link; /* Link holes together */
107 cma_t_boolean protected; /* Set when pages are protected */
108 cma_t_address first; /* First protected byte */
109 cma_t_address last; /* Last protected byte */
113 typedef struct CMA__T_INT_STACK {
114 cma__t_object header; /* Common header (sequence, type info */
115 cma__t_int_attr *attributes; /* Backpointer to attr obj */
116 cma___t_cluster *cluster; /* Stack's cluster */
117 cma_t_address stack_base; /* base address of stack */
118 cma_t_address yellow_zone; /* first address of yellow zone */
119 cma_t_address last_guard; /* last address of guard pages */
120 cma_t_natural first_chunk; /* First chunk allocated */
121 cma_t_natural chunk_count; /* Count of chunks allocated */
122 cma__t_int_tcb *tcb; /* TCB backpointer */
123 #if _CMA_PROTECT_MEMORY_
124 cma___t_int_hole hole; /* Description of hole */
133 * INTERNAL INTERFACES