标签:c 内存管理 linux kernel 嵌入式 算法
TBOX的内存管理模型,参考了linux kernel的内存管理机制,并在其基础上做了一些改进和优化。
    static __tb_inline__ tb_size_t tb_bits_cl0_u32_be_inline(tb_uint32_t x)
    {
        // check
        tb_check_return_val(x, 32);
        // done
        tb_size_t n = 31;
        if (x & 0xffff0000) { n -= 16;  x >>= 16;   }
        if (x & 0xff00)     { n -= 8;   x >>= 8;    }
        if (x & 0xf0)       { n -= 4;   x >>= 4;    }
        if (x & 0xc)        { n -= 2;   x >>= 2;    }
        if (x & 0x2)        { n--;                  }
        return n;
    }标签:c 内存管理 linux kernel 嵌入式 算法
原文地址:http://blog.csdn.net/waruqi/article/details/38663563