宏的妙用

1587阅读 0评论2012-04-04 datao0907
分类:C/C++


  1. #define P2END(x,align) (-(~(x) & -(align)))
  2. #define P2ROUNDUP(x,align) (-(-(x) & -(align)))

  3. P2END(0x1234,0x100 – 1) ==>0x12ff
  4. P2ROUNDUP(0x1234,0x100-1) ==>0x1300
来自openSolaris:

上一篇:FUSE中的slab分配器分析
下一篇:Fibonacci 堆