]> git.saurik.com Git - apple/xnu.git/blob - bsd/hfs/hfscommon/headers/HybridAllocator.h
4add9daee039311481513c4ff2c6e0eee7b096fb
[apple/xnu.git] / bsd / hfs / hfscommon / headers / HybridAllocator.h
1 /*
2 * Copyright (c) 2009 Apple Inc. All rights reserved.
3 *
4 * @APPLE_OSREFERENCE_LICENSE_HEADER_START@
5 *
6 * This file contains Original Code and/or Modifications of Original Code
7 * as defined in and that are subject to the Apple Public Source License
8 * Version 2.0 (the 'License'). You may not use this file except in
9 * compliance with the License. The rights granted to you under the License
10 * may not be used to create, or enable the creation or redistribution of,
11 * unlawful or unlicensed copies of an Apple operating system, or to
12 * circumvent, violate, or enable the circumvention or violation of, any
13 * terms of an Apple operating system software license agreement.
14 *
15 * Please obtain a copy of the License at
16 * http://www.opensource.apple.com/apsl/ and read it before using this file.
17 *
18 * The Original Code and all software distributed under the License are
19 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
20 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
21 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
22 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
23 * Please see the License for the specific language governing rights and
24 * limitations under the License.
25 *
26 * @APPLE_OSREFERENCE_LICENSE_HEADER_END@
27 */
28
29
30 #ifndef __HYBRID_ALLOC__
31 #define __HYBRID_ALLOC__
32
33 #include <sys/types.h>
34 #include "RedBlackTree.h"
35
36 typedef struct extent_node extent_node_t;
37
38 struct extent_node
39 {
40 u_int32_t length;
41 u_int32_t offset;
42 struct extent_node *offset_next;
43 rb_node(extent_node_t) offset_link;
44 };
45
46 typedef rb_tree(extent_node_t) extent_tree_offset_t;
47
48 extern extent_node_t *
49 alloc_node(u_int32_t length, u_int32_t offset);
50
51 extern void
52 free_node(extent_node_t *node);
53
54 extern extent_node_t *
55 extent_tree_free_space( extent_tree_offset_t *offset_tree, u_int32_t size, u_int32_t offset);
56
57 extern void
58 extent_tree_offset_print(extent_tree_offset_t *offset_tree);
59
60 extern int32_t
61 extent_tree_offset_alloc_space(extent_tree_offset_t *offset_tree, u_int32_t size, u_int32_t offset);
62
63 extern int32_t
64 extent_tree_offset_alloc_unaligned(extent_tree_offset_t *tree, u_int32_t size, u_int32_t offset);
65
66
67 extern void
68 extent_tree_remove_node (extent_tree_offset_t *offset_tree, extent_node_t * node);
69
70 extern extent_node_t *
71 extent_tree_off_first (extent_tree_offset_t *offset_tree);
72
73 extern extent_node_t *
74 extent_tree_off_search(extent_tree_offset_t *offset_tree, extent_node_t *node);
75
76 extern extent_node_t *
77 extent_tree_off_search_next(extent_tree_offset_t *offset_tree, extent_node_t *node);
78
79 extern extent_node_t*
80 extent_tree_off_search_nextWithSize (extent_tree_offset_t *offset_tree, extent_node_t *node);
81
82 extern extent_node_t *
83 extent_tree_off_search_prev(extent_tree_offset_t *offset_tree, extent_node_t *node);
84
85 extern extent_node_t *
86 extent_tree_off_next(extent_tree_offset_t *offset_tree, extent_node_t *node);
87
88 extern extent_node_t *
89 extent_tree_off_prev(extent_tree_offset_t *offset_tree, extent_node_t *node);
90
91 extern void
92 extent_tree_init(extent_tree_offset_t *offset_tree);
93
94 extern void
95 extent_tree_destroy(extent_tree_offset_t *offset_tree);
96
97 extern int
98 cmp_offset_node(extent_node_t *node_1, extent_node_t *node_2);
99
100
101 #endif