update dev300-m58
[ooovba.git] / sal / rtl / source / alloc_arena.h
bloba802e058ebd1566de0065de3295b30b175c5b8fe
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_arena.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_ARENA_H
32 #define INCLUDED_RTL_ALLOC_ARENA_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_arena_stat_type
43 * @internal
45 typedef struct rtl_arena_stat_st rtl_arena_stat_type;
46 struct rtl_arena_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_arena_segment_type
57 * @internal
59 #define RTL_ARENA_SEGMENT_TYPE_HEAD ((sal_Size)(0x01))
60 #define RTL_ARENA_SEGMENT_TYPE_SPAN ((sal_Size)(0x02))
61 #define RTL_ARENA_SEGMENT_TYPE_FREE ((sal_Size)(0x04))
62 #define RTL_ARENA_SEGMENT_TYPE_USED ((sal_Size)(0x08))
64 typedef struct rtl_arena_segment_st rtl_arena_segment_type;
65 struct rtl_arena_segment_st
67 /* segment list linkage */
68 rtl_arena_segment_type * m_snext;
69 rtl_arena_segment_type * m_sprev;
71 /* free/used list linkage */
72 rtl_arena_segment_type * m_fnext;
73 rtl_arena_segment_type * m_fprev;
75 /* segment description */
76 sal_uIntPtr m_addr;
77 sal_Size m_size;
78 sal_Size m_type;
82 /** rtl_arena_type
83 * @internal
85 #define RTL_ARENA_FREELIST_SIZE (sizeof(void*) * 8)
86 #define RTL_ARENA_HASH_SIZE 64
88 #define RTL_ARENA_FLAG_RESCALE 1 /* within hash rescale operation */
90 struct rtl_arena_st
92 /* linkage */
93 rtl_arena_type * m_arena_next;
94 rtl_arena_type * m_arena_prev;
96 /* properties */
97 char m_name[RTL_ARENA_NAME_LENGTH + 1];
98 long m_flags;
100 rtl_memory_lock_type m_lock;
101 rtl_arena_stat_type m_stats;
103 rtl_arena_type * m_source_arena;
104 void * (SAL_CALL * m_source_alloc)(rtl_arena_type *, sal_Size *);
105 void (SAL_CALL * m_source_free) (rtl_arena_type *, void *, sal_Size);
107 sal_Size m_quantum;
108 sal_Size m_quantum_shift; /* log2(m_quantum) */
110 rtl_arena_segment_type m_segment_reserve_span_head;
111 rtl_arena_segment_type m_segment_reserve_head;
113 rtl_arena_segment_type m_segment_head;
115 rtl_arena_segment_type m_freelist_head[RTL_ARENA_FREELIST_SIZE];
116 sal_Size m_freelist_bitmap;
118 rtl_arena_segment_type ** m_hash_table;
119 rtl_arena_segment_type * m_hash_table_0[RTL_ARENA_HASH_SIZE];
120 sal_Size m_hash_size; /* m_hash_mask + 1 */
121 sal_Size m_hash_shift; /* log2(m_hash_size) */
123 sal_Size m_qcache_max;
124 rtl_cache_type ** m_qcache_ptr;
128 /** gp_default_arena
129 * default arena with pagesize quantum
131 * @internal
133 extern rtl_arena_type * gp_default_arena;
136 #ifdef __cplusplus
138 #endif
140 #endif /* INCLUDED_RTL_ALLOC_ARENA_H */