ULTIMA8: Remove valgrind-specific code

This commit is contained in:
Matthew Duggan 2020-03-28 20:48:46 +09:00
parent af4bb06909
commit 2fcae50af1
3 changed files with 3 additions and 79 deletions

View File

@ -37,18 +37,9 @@ DEFINE_RUNTIME_CLASSTYPE_CODE(SegmentedPool, Pool)
#define OFFSET_ALIGN(X) ( (X + sizeof(uintptr) - 1) & ~(sizeof(uintptr) - 1) )
#ifdef USE_VALGRIND
const int redzoneSize = 8;
#else
const int redzoneSize = 0;
#endif
struct SegmentedPoolNode {
SegmentedPool *pool;
SegmentedPoolNode *nextFree;
#ifdef USE_VALGRIND
int valgrind_handle;
#endif
size_t size;
};
@ -61,17 +52,15 @@ SegmentedPool::SegmentedPool(size_t nodeCapacity_, uint32 nodes)
// Give it its real capacity.
// One redzone is added after the memory block.
_nodeCapacity = OFFSET_ALIGN(nodeCapacity_ + redzoneSize);
_nodeCapacity = OFFSET_ALIGN(nodeCapacity_);
// Node offsets are aligned to the next uintptr offset after the real size.
// Another redzone is added between the node and the memory block.
_nodeOffset = OFFSET_ALIGN(sizeof(SegmentedPoolNode) + redzoneSize) + _nodeCapacity;
_nodeOffset = OFFSET_ALIGN(sizeof(SegmentedPoolNode)) + _nodeCapacity;
_startOfPool = new uint8[_nodeOffset * nodes];
_endOfPool = _startOfPool + (_nodeOffset * nodes);
VALGRIND_CREATE_MEMPOOL(_startOfPool, redzoneSize, 0);
_firstFree = reinterpret_cast<SegmentedPoolNode *>(_startOfPool);
_firstFree->pool = this;
_firstFree->size = 0;
@ -92,8 +81,6 @@ SegmentedPool::SegmentedPool(size_t nodeCapacity_, uint32 nodes)
SegmentedPool::~SegmentedPool() {
assert(isEmpty());
VALGRIND_DESTROY_MEMPOOL(_startOfPool);
delete [] _startOfPool;
}
@ -118,13 +105,7 @@ void *SegmentedPool::allocate(size_t size) {
// debugN"Allocating Node 0x%08X\n", node);
uint8 *p = reinterpret_cast<uint8 *>(node) +
OFFSET_ALIGN(sizeof(SegmentedPoolNode) + redzoneSize);
VALGRIND_MEMPOOL_ALLOC(_startOfPool, p, size);
#ifdef USE_VALGRIND
node->valgrind_handle = VALGRIND_CREATE_BLOCK(p, size,
"SegmentedPoolBlock");
#endif
OFFSET_ALIGN(sizeof(SegmentedPoolNode));
return p;
}
@ -137,9 +118,6 @@ void SegmentedPool::deallocate(void *ptr) {
node->size = 0;
assert(node->pool == this);
VALGRIND_MEMPOOL_FREE(_startOfPool, ptr);
VALGRIND_DISCARD(node->valgrind_handle);
// debugN"Free Node 0x%08X\n", node);
if (isFull()) {
_firstFree = node;

View File

@ -94,10 +94,6 @@
//
#define CANT_HAPPEN_MSG(msg) do { assert(msg && false); } while(0)
//
// Wrapper around valgrind functions.
#include "ultima/ultima8/misc/pent_valgrind.h"
namespace Ultima {
namespace Ultima8 {

View File

@ -1,50 +0,0 @@
/* ScummVM - Graphic Adventure Engine
*
* ScummVM is the legal property of its developers, whose names
* are too numerous to list here. Please refer to the COPYRIGHT
* file distributed with this source distribution.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
*/
#ifndef PENT_VALGRIND_H
#define PENT_VALGRIND_H
#ifdef USE_VALGRIND
#include <valgrind/memcheck.h>
#else
#define VALGRIND_MAKE_MEM_NOACCESS(_qzz_addr,_qzz_len)
#define VALGRIND_MAKE_MEM_UNDEFINED(_qzz_addr,_qzz_len)
#define VALGRIND_MAKE_MEM_DEFINED(_qzz_addr,_qzz_len)
#define VALGRIND_CHECK_MEM_IS_DEFINED(_qzz_addr,_qzz_len)
#define VALGRIND_CHECK_VALUE_IS_DEFINED(__lvalue)
#define VALGRIND_CHECK_MEM_IS_ADDRESSABLE(_qzz_addr,_qzz_len)
#define VALGRIND_CREATE_MEMPOOL(pool,rzB,is_zeroed)
#define VALGRIND_DESTROY_MEMPOOL(pool)
#define VALGRIND_MEMPOOL_ALLOC(pool,addr,size)
#define VALGRIND_MEMPOOL_FREE(pool,addr)
#define VALGRIND_CREATE_BLOCK(_qzz_addr,_qzz_len,_qzz_desc) 0
#define VALGRIND_DISCARD(_qzz_blkindex)
#endif
#endif