码迷,mamicode.com
首页 > 其他好文 > 详细

函数page_align

时间:2015-11-23 18:20:48      阅读:301      评论:0      收藏:0      [点我收藏+]

标签:

 

/************************************************************//**
Gets the start of a page.
@return    start of the page */
UNIV_INLINE
page_t*
page_align(
/*=======*/
    const void*    ptr)    /*!< in: pointer to page frame */
{
    return((page_t*) ut_align_down(ptr, UNIV_PAGE_SIZE));
}



/*********************************************************//**
The following function rounds down a pointer to the nearest
aligned address.
@return    aligned pointer */
UNIV_INLINE
void*
ut_align_down(
/*==========*/
    const void*    ptr,        /*!< in: pointer */
    ulint        align_no)    /*!< in: align by this number */
{
    ut_ad(align_no > 0);
    ut_ad(((align_no - 1) & align_no) == 0);
    ut_ad(ptr);

    ut_ad(sizeof(void*) == sizeof(ulint));

    return((void*)((((ulint)ptr)) & ~(align_no - 1)));
}

 

函数page_align

标签:

原文地址:http://www.cnblogs.com/taek/p/4988923.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!