Roger Luo

超越梦想一起飞
  博客园  :: 首页  :: 新随笔  :: 联系 :: 订阅 订阅  :: 管理

qf

Posted on 2013-05-06 18:14  Roger Luo  阅读(353)  评论(0编辑  收藏  举报
#pragma intrinsic (_InterlockedIncrement)
#pragma intrinsic (_InterlockedDecrement)
#pragma intrinsic (memcpy)

The intrinsic pragma tells the compiler that a function has known behavior. The compiler may call the function and not replace the function call with inline instructions, if it will result in better performance. Link

 

For Windows

__declspec(align(8)) volatile long m_lRefCount;

For Linux

__attribute__((aligned(8))) volatile long m_lRefCount;

This usage make the align for variable and require the value from variable, not from register.

 

保证申请的代码是在这个类对象之后,+1相当于+sizeof(class),因为指针的+-是根据左操作数来决定的。

                inline unsigned char *GetBuffer()
                {
                  // the buffer follows immediately after this class
                  return (unsigned char *)(this + 1);
                };