merge the formfield patch from ooo-build
[ooovba.git] / sal / rtl / source / alloc_cache.h
blobf8b2c1f2922bee6662b83814079aab66fb441410
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: alloc_cache.h,v $
10 * $Revision: 1.3 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 #ifndef INCLUDED_RTL_ALLOC_CACHE_H
32 #define INCLUDED_RTL_ALLOC_CACHE_H
34 #include "sal/types.h"
35 #include "rtl/alloc.h"
36 #include "alloc_impl.h"
38 #ifdef __cplusplus
39 extern "C" {
40 #endif
42 /** rtl_cache_stat_type
43 * @internal
45 typedef struct rtl_cache_stat_st rtl_cache_stat_type;
46 struct rtl_cache_stat_st
48 sal_uInt64 m_alloc;
49 sal_uInt64 m_free;
51 sal_Size m_mem_total;
52 sal_Size m_mem_alloc;
56 /** rtl_cache_bufctl_type
57 * @internal
59 typedef struct rtl_cache_bufctl_st rtl_cache_bufctl_type;
60 struct rtl_cache_bufctl_st
62 rtl_cache_bufctl_type * m_next; /* linkage */
64 sal_uIntPtr m_addr; /* buffer address */
65 sal_uIntPtr m_slab; /* parent slab address */
69 /** rtl_cache_slab_type
70 * @internal
72 typedef struct rtl_cache_slab_st rtl_cache_slab_type;
73 struct rtl_cache_slab_st
75 rtl_cache_slab_type * m_slab_next; /* slab linkage */
76 rtl_cache_slab_type * m_slab_prev; /* slab linkage */
78 sal_Size m_ntypes; /* number of buffers used */
79 sal_uIntPtr m_data; /* buffer start addr */
81 sal_uIntPtr m_bp; /* free buffer linkage 'base pointer' */
82 rtl_cache_bufctl_type * m_sp; /* free buffer linkage 'stack pointer' */
86 /** rtl_cache_magazine_type
87 * @internal
89 #define RTL_CACHE_MAGAZINE_SIZE 61
91 typedef struct rtl_cache_magazine_st rtl_cache_magazine_type;
92 struct rtl_cache_magazine_st
94 rtl_cache_magazine_type * m_mag_next; /* depot linkage */
96 sal_Size m_mag_size;
97 sal_Size m_mag_used;
99 void * m_objects[RTL_CACHE_MAGAZINE_SIZE];
103 /** rtl_cache_depot_type
104 * @internal
106 typedef struct rtl_cache_depot_st rtl_cache_depot_type;
107 struct rtl_cache_depot_st
109 /* magazine list */
110 rtl_cache_magazine_type * m_mag_next; /* linkage */
111 sal_Size m_mag_count; /* count */
113 /* working set parameters */
114 sal_Size m_curr_min;
115 sal_Size m_prev_min;
119 /** rtl_cache_type
120 * @internal
122 #define RTL_CACHE_HASH_SIZE 8
124 #define RTL_CACHE_FEATURE_HASH 1
125 #define RTL_CACHE_FEATURE_BULKDESTROY 2
126 #define RTL_CACHE_FEATURE_RESCALE 4 /* within hash rescale operation */
128 struct rtl_cache_st
130 /* linkage */
131 rtl_cache_type * m_cache_next;
132 rtl_cache_type * m_cache_prev;
134 /* properties */
135 char m_name[RTL_CACHE_NAME_LENGTH + 1];
136 long m_features;
138 sal_Size m_type_size; /* const */
139 sal_Size m_type_align; /* const */
140 sal_Size m_type_shift; /* log2(m_type_size); const */
142 int (SAL_CALL * m_constructor)(void * obj, void * userarg); /* const */
143 void (SAL_CALL * m_destructor) (void * obj, void * userarg); /* const */
144 void (SAL_CALL * m_reclaim) (void * userarg); /* const */
145 void * m_userarg;
147 /* slab layer */
148 rtl_memory_lock_type m_slab_lock;
149 rtl_cache_stat_type m_slab_stats;
151 rtl_arena_type * m_source; /* slab supplier; const */
152 sal_Size m_slab_size; /* const */
153 sal_Size m_ntypes; /* number of buffers per slab; const */
154 sal_Size m_ncolor; /* next slab color */
155 sal_Size m_ncolor_max; /* max. slab color */
157 rtl_cache_slab_type m_free_head;
158 rtl_cache_slab_type m_used_head;
160 rtl_cache_bufctl_type ** m_hash_table;
161 rtl_cache_bufctl_type * m_hash_table_0[RTL_CACHE_HASH_SIZE];
162 sal_Size m_hash_size; /* m_hash_mask + 1 */
163 sal_Size m_hash_shift; /* log2(m_hash_size) */
165 /* depot layer */
166 rtl_memory_lock_type m_depot_lock;
168 rtl_cache_depot_type m_depot_empty;
169 rtl_cache_depot_type m_depot_full;
171 rtl_cache_type * m_magazine_cache; /* magazine supplier; const */
173 /* cpu layer */
174 rtl_cache_magazine_type * m_cpu_curr;
175 rtl_cache_magazine_type * m_cpu_prev;
177 rtl_cache_stat_type m_cpu_stats;
181 #ifdef __cplusplus
183 #endif
185 #endif /* INCLUDED_RTL_ALLOC_CACHE_H */