1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 #ifndef INCLUDED_RTL_ALLOC_ARENA_HXX
21 #define INCLUDED_RTL_ALLOC_ARENA_HXX
23 #include "sal/types.h"
24 #include "rtl/alloc.h"
25 #include "alloc_impl.hxx"
27 /** rtl_arena_stat_type
30 struct rtl_arena_stat_type
40 /** rtl_arena_segment_type
43 #define RTL_ARENA_SEGMENT_TYPE_HEAD ((sal_Size)(0x01))
44 #define RTL_ARENA_SEGMENT_TYPE_SPAN ((sal_Size)(0x02))
45 #define RTL_ARENA_SEGMENT_TYPE_FREE ((sal_Size)(0x04))
46 #define RTL_ARENA_SEGMENT_TYPE_USED ((sal_Size)(0x08))
48 struct rtl_arena_segment_type
50 /* segment list linkage */
51 rtl_arena_segment_type
* m_snext
;
52 rtl_arena_segment_type
* m_sprev
;
54 /* free/used list linkage */
55 rtl_arena_segment_type
* m_fnext
;
56 rtl_arena_segment_type
* m_fprev
;
58 /* segment description */
68 #define RTL_ARENA_FREELIST_SIZE (sizeof(void*) * 8)
69 #define RTL_ARENA_HASH_SIZE 64
71 #define RTL_ARENA_FLAG_RESCALE 1 /* within hash rescale operation */
76 rtl_arena_type
* m_arena_next
;
77 rtl_arena_type
* m_arena_prev
;
80 char m_name
[RTL_ARENA_NAME_LENGTH
+ 1];
83 rtl_memory_lock_type m_lock
;
84 rtl_arena_stat_type m_stats
;
86 rtl_arena_type
* m_source_arena
;
87 void * (SAL_CALL
* m_source_alloc
)(rtl_arena_type
*, sal_Size
*);
88 void (SAL_CALL
* m_source_free
) (rtl_arena_type
*, void *, sal_Size
);
91 sal_Size m_quantum_shift
; /* log2(m_quantum) */
93 rtl_arena_segment_type m_segment_reserve_span_head
;
94 rtl_arena_segment_type m_segment_reserve_head
;
96 rtl_arena_segment_type m_segment_head
;
98 rtl_arena_segment_type m_freelist_head
[RTL_ARENA_FREELIST_SIZE
];
99 sal_Size m_freelist_bitmap
;
101 rtl_arena_segment_type
** m_hash_table
;
102 rtl_arena_segment_type
* m_hash_table_0
[RTL_ARENA_HASH_SIZE
];
103 sal_Size m_hash_size
; /* m_hash_mask + 1 */
104 sal_Size m_hash_shift
; /* log2(m_hash_size) */
106 sal_Size m_qcache_max
;
107 rtl_cache_type
** m_qcache_ptr
;
112 * default arena with pagesize quantum
116 extern rtl_arena_type
* gp_default_arena
;
118 #endif /* INCLUDED_RTL_ALLOC_ARENA_HXX */
120 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */