Subversion Repositories HelenOS

Rev

Rev 377 | Rev 379 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 377 Rev 378
Line 46... Line 46...
46
buddy_system_t *buddy_system_create(__u8 max_order, buddy_operations_t *op)
46
buddy_system_t *buddy_system_create(__u8 max_order, buddy_operations_t *op)
47
{
47
{
48
    buddy_system_t *b;
48
    buddy_system_t *b;
49
    int i;
49
    int i;
50
 
50
 
-
 
51
    ASSERT(max_order < BUDDY_SYSTEM_INNER_BLOCK);
-
 
52
 
51
    ASSERT(op->find_buddy);
53
    ASSERT(op->find_buddy);
52
    ASSERT(op->set_order);
54
    ASSERT(op->set_order);
53
    ASSERT(op->get_order);
55
    ASSERT(op->get_order);
54
    ASSERT(op->bisect);
56
    ASSERT(op->bisect);
55
    ASSERT(op->coalesce);
57
    ASSERT(op->coalesce);
Line 164... Line 166...
164
     * See if there is any buddy in the list of order i.
166
     * See if there is any buddy in the list of order i.
165
     */
167
     */
166
    buddy = b->op->find_buddy(block);
168
    buddy = b->op->find_buddy(block);
167
   
169
   
168
    if (buddy && i != b->max_order - 1) {
170
    if (buddy && i != b->max_order - 1) {
-
 
171
 
-
 
172
        ASSERT(b->op->get_order(buddy) == i);
-
 
173
       
169
        /*
174
        /*
170
         * Remove buddy from the list of order i.
175
         * Remove buddy from the list of order i.
171
         */
176
         */
172
        list_remove(buddy);
177
        list_remove(buddy);
173
       
178
       
174
        /*
179
        /*
-
 
180
         * Invalidate order of both block and buddy.
-
 
181
         */
-
 
182
        b->op->set_order(block, BUDDY_SYSTEM_INNER_BLOCK);
-
 
183
        b->op->set_order(buddy, BUDDY_SYSTEM_INNER_BLOCK);
-
 
184
       
-
 
185
        /*
175
         * Coalesce block and buddy into one block.
186
         * Coalesce block and buddy into one block.
176
         */
187
         */
177
        hlp = b->op->coalesce(block, buddy);
188
        hlp = b->op->coalesce(block, buddy);
178
 
189
 
179
        /*
190
        /*