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, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
37
2, 1, 1, 1, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0,
38
2, 1, 1, 1, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0,
39
2, 1, 1, 1, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0,
40
2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
41
2, 1, 1, 1, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0,
42
2, 1, 1, 1, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0,
43
2, 1, 1, 1, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0,
44
2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
45
2, 1, 1, 1, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0,
46
2, 1, 1, 1, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0,
47
2, 1, 1, 1, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, -1
52
51
* NAME: ujfs_maxbuddy
120
int8_t ujfs_adjtree( int8_t *treep,
118
int8_t ujfs_adjtree(int8_t * treep, int32_t l2leaves, int32_t l2min)
124
int32_t nleaves, leaf_index, l2max, nextb, bsize, index;
125
int32_t l2free, leaf, num_this_level, nextp;
126
int8_t *cp0, *cp1, *cp = treep;
129
* Determine the number of leaves of the tree and the
130
* index of the first leaf.
131
* Note: I don't know why the leaf_index calculation works, but it does.
133
nleaves = (1 << l2leaves);
134
leaf_index = (nleaves - 1) / 3;
137
* Determine the maximum free string possible for the leaves.
139
l2max = l2min + l2leaves;
142
* Try to combine buddies starting with a buddy size of 1 (i.e. two leaves).
143
* At a buddy size of 1 two buddy leaves can be combined if both buddies
144
* have a maximum free of l2min; the combination will result in the
145
* left-most buddy leaf having a maximum free of l2min+1. After processing
146
* all buddies for a certain size, process buddies at the next higher buddy
147
* size (i.e. current size * 2) and the next maximum free
148
* (current free + 1). This continues until the maximum possible buddy
149
* combination yields maximum free.
151
for ( l2free = l2min, bsize = 1; l2free < l2max; l2free++, bsize = nextb ) {
154
for ( cp0 = cp + leaf_index, index = 0; index < nleaves;
155
index += nextb, cp0 += nextb ) {
156
if ( *cp0 == l2free && *(cp0 + bsize) == l2free ) {
164
* With the leaves reflecting maximum free values bubble this information up
165
* the tree. Starting at the leaf node level, the four nodes described by
166
* the higher level parent node are compared for a maximum free and this
167
* maximum becomes the value of the parent node. All lower level nodes are
168
* processed in this fashion then we move up to the next level (parent
169
* becomes a lower level node) and continue the process for that level.
171
for ( leaf = leaf_index, num_this_level = nleaves >> 2; num_this_level > 0;
172
num_this_level >>= 2, leaf = nextp ) {
173
nextp = (leaf - 1) >> 2;
176
* Process all lower level nodes at this level setting the value of the
177
* parent node as the maximum of the four lower level nodes.
179
for ( cp0 = cp + leaf, cp1 = cp + nextp, index = 0;
180
index < num_this_level; index++, cp0 += 4, cp1++ ) {
120
int32_t nleaves, leaf_index, l2max, nextb, bsize, index;
121
int32_t l2free, leaf, num_this_level, nextp;
122
int8_t *cp0, *cp1, *cp = treep;
125
* Determine the number of leaves of the tree and the
126
* index of the first leaf.
127
* Note: I don't know why the leaf_index calculation works, but it does.
129
nleaves = (1 << l2leaves);
130
leaf_index = (nleaves - 1) / 3;
133
* Determine the maximum free string possible for the leaves.
135
l2max = l2min + l2leaves;
138
* Try to combine buddies starting with a buddy size of 1 (i.e. two leaves).
139
* At a buddy size of 1 two buddy leaves can be combined if both buddies
140
* have a maximum free of l2min; the combination will result in the
141
* left-most buddy leaf having a maximum free of l2min+1. After processing
142
* all buddies for a certain size, process buddies at the next higher buddy
143
* size (i.e. current size * 2) and the next maximum free
144
* (current free + 1). This continues until the maximum possible buddy
145
* combination yields maximum free.
147
for (l2free = l2min, bsize = 1; l2free < l2max; l2free++, bsize = nextb) {
150
for (cp0 = cp + leaf_index, index = 0; index < nleaves;
151
index += nextb, cp0 += nextb) {
152
if (*cp0 == l2free && *(cp0 + bsize) == l2free) {
160
* With the leaves reflecting maximum free values bubble this information up
161
* the tree. Starting at the leaf node level, the four nodes described by
162
* the higher level parent node are compared for a maximum free and this
163
* maximum becomes the value of the parent node. All lower level nodes are
164
* processed in this fashion then we move up to the next level (parent
165
* becomes a lower level node) and continue the process for that level.
167
for (leaf = leaf_index, num_this_level = nleaves >> 2; num_this_level > 0;
168
num_this_level >>= 2, leaf = nextp) {
169
nextp = (leaf - 1) >> 2;
172
* Process all lower level nodes at this level setting the value of the
173
* parent node as the maximum of the four lower level nodes.
175
for (cp0 = cp + leaf, cp1 = cp + nextp, index = 0;
176
index < num_this_level; index++, cp0 += 4, cp1++) {
190
185
* NAME: ujfs_complete_dmap