5 * (C) Copyright 2011 Novell, Inc
7 * Permission is hereby granted, free of charge, to any person obtaining
8 * a copy of this software and associated documentation files (the
9 * "Software"), to deal in the Software without restriction, including
10 * without limitation the rights to use, copy, modify, merge, publish,
11 * distribute, sublicense, and/or sell copies of the Software, and to
12 * permit persons to whom the Software is furnished to do so, subject to
13 * the following conditions:
15 * The above copyright notice and this permission notice shall be
16 * included in all copies or substantial portions of the Software.
18 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
19 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
20 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
21 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
22 * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
23 * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
24 * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
27 #ifndef __MONO_LOCKFREEALLOC_H__
28 #define __MONO_LOCKFREEALLOC_H__
31 #include <mono/utils/lock-free-queue.h>
32 #include <mono/utils/mono-mmap.h>
35 MonoLockFreeQueue partial
;
36 unsigned int slot_size
;
37 unsigned int block_size
;
38 } MonoLockFreeAllocSizeClass
;
40 struct _MonoLockFreeAllocDescriptor
;
43 struct _MonoLockFreeAllocDescriptor
*active
;
44 MonoLockFreeAllocSizeClass
*sc
;
45 MonoMemAccountType account_type
;
46 } MonoLockFreeAllocator
;
48 #define LOCK_FREE_ALLOC_SB_MAX_SIZE 16384
49 #define LOCK_FREE_ALLOC_SB_HEADER_SIZE (sizeof (gpointer))
50 #define LOCK_FREE_ALLOC_SB_USABLE_SIZE(block_size) ((block_size) - LOCK_FREE_ALLOC_SB_HEADER_SIZE)
52 MONO_API
void mono_lock_free_allocator_init_size_class (MonoLockFreeAllocSizeClass
*sc
, unsigned int slot_size
, unsigned int block_size
);
53 MONO_API
void mono_lock_free_allocator_init_allocator (MonoLockFreeAllocator
*heap
, MonoLockFreeAllocSizeClass
*sc
, MonoMemAccountType account_type
);
55 MONO_API gpointer
mono_lock_free_alloc (MonoLockFreeAllocator
*heap
);
56 MONO_API
void mono_lock_free_free (gpointer ptr
, size_t block_size
);
58 MONO_API gboolean
mono_lock_free_allocator_check_consistency (MonoLockFreeAllocator
*heap
);