mirror of
https://github.com/corda/corda.git
synced 2025-06-18 23:28:21 +00:00
progress towards thread support
This includes support for using the least significant bits of the class pointer to indicate object state, which we'll use to indicate the presence of a monitor pointer, among other things.
This commit is contained in:
10
src/common.h
10
src/common.h
@ -26,6 +26,9 @@ typedef void* object;
|
||||
const unsigned BytesPerWord = sizeof(uintptr_t);
|
||||
const unsigned BitsPerWord = BytesPerWord * 8;
|
||||
|
||||
const uintptr_t PointerMask
|
||||
= ((~static_cast<uintptr_t>(0)) / BytesPerWord) * BytesPerWord;
|
||||
|
||||
const unsigned LikelyPageSizeInBytes = 4 * 1024;
|
||||
|
||||
inline unsigned
|
||||
@ -109,6 +112,13 @@ cast(object p, unsigned offset)
|
||||
return *reinterpret_cast<T*>(static_cast<uint8_t*>(p) + offset);
|
||||
}
|
||||
|
||||
template <class T>
|
||||
inline T*
|
||||
mask(T* p)
|
||||
{
|
||||
return reinterpret_cast<T*>(reinterpret_cast<uintptr_t>(p) & PointerMask);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
#endif//COMMON_H
|
||||
|
Reference in New Issue
Block a user