Example #1
0
void RecordableInt<I>::Restore(char * snapshot, I & num)
{
	typedef unsigned long long cast_t;
	GPX_ASSERT(sizeof(I) <= sizeof(cast_t), "type of number to store exceeds size limit: sizeof(" << sizeof(I) << ") <= sizeof(" << sizeof(cast_t) << ")");

	char sign = snapshot[0];
	cast_t castval = 0;
	for (std::size_t byte = SnapshotSize() - 1; byte > 0; byte--) {
		castval <<= BYTE_BITS;
		castval |= snapshot[byte] & BYTE_MASK;
	}
	num = sign ? -static_cast<I>(castval) : static_cast<I>(castval);
}
Example #2
0
void RecordableInt<I>::Store(char * snapshot, I num)
{
	typedef unsigned long long cast_t;
	GPX_ASSERT(sizeof(I) <= sizeof(cast_t), "type of number to store exceeds size limit: sizeof(" << sizeof(I) << ") <= sizeof(" << sizeof(cast_t) << ")");

	char sign = num < 0 ? 1 : 0;
	cast_t castval;
	castval = sign ? static_cast<cast_t>(-num) : static_cast<cast_t>(num);
	snapshot[0] = sign;
	for (std::size_t byte = 1; byte < SnapshotSize(); byte++) {
		snapshot[byte] = castval & BYTE_MASK;
		castval >>= BYTE_BITS;
	}
}
Example #3
0
uint32_t ThreadReuseMemStartCompute(void)
{
	uint32_t size=0;

	size+=sizeof(PMHEAD);

	size+=sizeof(THREAD);

	size+=sizeof(TransactionData);

	size+=SnapshotSize();

	size+=sizeof(TransactionId)*MAXPROCS;

	size+=DataMemSize();

	size+=MaxDataLockNum*sizeof(DataLock);

	return size;
}