cleanup - remove old cpu_memcpy and cpu_i64FromDouble that are no longer needed
This was SVN commit r8517.
This commit is contained in:
parent
b27d6d38e3
commit
52851faeb6
@ -81,7 +81,7 @@ bool CTerrain::Initialize(ssize_t patchesPerSide,const u16* data)
|
||||
// given a heightmap?
|
||||
if (data) {
|
||||
// yes; keep a copy of it
|
||||
cpu_memcpy(m_Heightmap,data,m_MapSize*m_MapSize*sizeof(u16));
|
||||
memcpy(m_Heightmap,data,m_MapSize*m_MapSize*sizeof(u16));
|
||||
} else {
|
||||
// build a flat terrain
|
||||
memset(m_Heightmap,0,m_MapSize*m_MapSize*sizeof(u16));
|
||||
@ -364,7 +364,7 @@ void CTerrain::Resize(ssize_t size)
|
||||
u16* dst=newHeightmap;
|
||||
ssize_t copysize=std::min(newMapSize, m_MapSize);
|
||||
for (ssize_t j=0;j<copysize;j++) {
|
||||
cpu_memcpy(dst,src,copysize*sizeof(u16));
|
||||
memcpy(dst,src,copysize*sizeof(u16));
|
||||
dst+=copysize;
|
||||
src+=m_MapSize;
|
||||
if (newMapSize>m_MapSize) {
|
||||
@ -381,7 +381,7 @@ void CTerrain::Resize(ssize_t size)
|
||||
src=newHeightmap+((m_MapSize-1)*newMapSize);
|
||||
dst=src+newMapSize;
|
||||
for (ssize_t i=0;i<newMapSize-m_MapSize;i++) {
|
||||
cpu_memcpy(dst,src,newMapSize*sizeof(u16));
|
||||
memcpy(dst,src,newMapSize*sizeof(u16));
|
||||
dst+=newMapSize;
|
||||
}
|
||||
}
|
||||
@ -391,7 +391,7 @@ void CTerrain::Resize(ssize_t size)
|
||||
for (ssize_t i=0;i<size;i++) {
|
||||
// copy over texture data from existing tiles, if possible
|
||||
if (i<m_MapSizePatches && j<m_MapSizePatches) {
|
||||
cpu_memcpy(newPatches[j*size+i].m_MiniPatches,m_Patches[j*m_MapSizePatches+i].m_MiniPatches,sizeof(CMiniPatch)*PATCH_SIZE*PATCH_SIZE);
|
||||
memcpy(newPatches[j*size+i].m_MiniPatches,m_Patches[j*m_MapSizePatches+i].m_MiniPatches,sizeof(CMiniPatch)*PATCH_SIZE*PATCH_SIZE);
|
||||
}
|
||||
}
|
||||
|
||||
@ -460,7 +460,7 @@ void CTerrain::InitialisePatches()
|
||||
void CTerrain::SetHeightMap(u16* heightmap)
|
||||
{
|
||||
// keep a copy of the given heightmap
|
||||
cpu_memcpy(m_Heightmap,heightmap,m_MapSize*m_MapSize*sizeof(u16));
|
||||
memcpy(m_Heightmap,heightmap,m_MapSize*m_MapSize*sizeof(u16));
|
||||
|
||||
// recalculate patch bounds, invalidate vertices
|
||||
for (ssize_t j=0;j<m_MapSizePatches;j++) {
|
||||
|
@ -54,7 +54,7 @@ namespace I18n
|
||||
ref = new strImW_data;
|
||||
size_t len = wcslen(s)+1;
|
||||
ref->data = new wchar_t[len];
|
||||
cpu_memcpy((void*)ref->data, s, len*sizeof(wchar_t));
|
||||
memcpy((void*)ref->data, s, len*sizeof(wchar_t));
|
||||
}
|
||||
|
||||
StrImW(const char* s)
|
||||
|
@ -189,7 +189,7 @@ LibError da_read(DynArray* da, void* data, size_t size)
|
||||
if(da->pos+size > da->cur_size)
|
||||
WARN_RETURN(ERR::FAIL);
|
||||
|
||||
cpu_memcpy(data, da->base+da->pos, size);
|
||||
memcpy(data, da->base+da->pos, size);
|
||||
da->pos += size;
|
||||
return INFO::OK;
|
||||
}
|
||||
@ -198,7 +198,7 @@ LibError da_read(DynArray* da, void* data, size_t size)
|
||||
LibError da_append(DynArray* da, const void* data, size_t size)
|
||||
{
|
||||
RETURN_ERR(da_reserve(da, size));
|
||||
cpu_memcpy(da->base+da->pos, data, size);
|
||||
memcpy(da->base+da->pos, data, size);
|
||||
da->pos += size;
|
||||
return INFO::OK;
|
||||
}
|
||||
|
@ -28,7 +28,6 @@
|
||||
#include "lib/allocators/string_pool.h"
|
||||
|
||||
#include "lib/rand.h"
|
||||
#include "lib/sysdep/cpu.h" // cpu_memcpy
|
||||
|
||||
|
||||
StringPool::StringPool(size_t maxSize)
|
||||
@ -63,7 +62,7 @@ const char* StringPool::UniqueCopy(const char* string)
|
||||
char* uniqueCopy = (char*)pool_alloc(&m_pool, length+1);
|
||||
if(!uniqueCopy)
|
||||
throw std::bad_alloc();
|
||||
cpu_memcpy((void*)uniqueCopy, string, length);
|
||||
memcpy((void*)uniqueCopy, string, length);
|
||||
uniqueCopy[length] = '\0';
|
||||
|
||||
m_map.insert(uniqueCopy, uniqueCopy);
|
||||
|
@ -72,7 +72,7 @@ void debug_wprintf_mem(const wchar_t* fmt, ...)
|
||||
{
|
||||
const size_t copySize = sizeof(wchar_t) * LOG_CHARS/2;
|
||||
wchar_t* const middle = &debug_log[LOG_CHARS/2];
|
||||
cpu_memcpy(debug_log, middle, copySize);
|
||||
memcpy(debug_log, middle, copySize);
|
||||
memset(middle, 0, copySize);
|
||||
debug_log_pos -= LOG_CHARS/2; // don't assign middle (may leave gap)
|
||||
}
|
||||
|
@ -36,7 +36,6 @@
|
||||
#include "lib/fat_time.h"
|
||||
#include "lib/path_util.h"
|
||||
#include "lib/allocators/pool.h"
|
||||
#include "lib/sysdep/cpu.h" // cpu_memcpy
|
||||
#include "lib/file/archive/archive.h"
|
||||
#include "lib/file/archive/codec_zlib.h"
|
||||
#include "lib/file/archive/stream.h"
|
||||
@ -81,7 +80,7 @@ public:
|
||||
m_fn_len = to_le16(u16_from_larger(pathnameLength));
|
||||
m_e_len = to_le16(0);
|
||||
|
||||
cpu_memcpy((char*)this + sizeof(LFH), pathname_c.string().c_str(), pathnameLength);
|
||||
memcpy((char*)this + sizeof(LFH), pathname_c.string().c_str(), pathnameLength);
|
||||
}
|
||||
|
||||
size_t Size() const
|
||||
@ -133,7 +132,7 @@ public:
|
||||
m_x3 = to_le32(0);
|
||||
m_lfh_ofs = to_le32(u32_from_larger(ofs));
|
||||
|
||||
cpu_memcpy((char*)this + sizeof(CDFH), pathname_c.string().c_str(), pathnameLength);
|
||||
memcpy((char*)this + sizeof(CDFH), pathname_c.string().c_str(), pathnameLength);
|
||||
}
|
||||
|
||||
fs::wpath Pathname() const
|
||||
@ -332,7 +331,7 @@ private:
|
||||
LFH_Copier* p = (LFH_Copier*)cbData;
|
||||
|
||||
debug_assert(size <= p->lfh_bytes_remaining);
|
||||
cpu_memcpy(p->lfh_dst, block, size);
|
||||
memcpy(p->lfh_dst, block, size);
|
||||
p->lfh_dst += size;
|
||||
p->lfh_bytes_remaining -= size;
|
||||
|
||||
|
@ -84,7 +84,7 @@ public:
|
||||
virtual LibError Process(const u8* in, size_t inSize, u8* out, size_t outSize, size_t& inConsumed, size_t& outProduced)
|
||||
{
|
||||
const size_t transferSize = std::min(inSize, outSize);
|
||||
cpu_memcpy(out, in, transferSize);
|
||||
memcpy(out, in, transferSize);
|
||||
inConsumed = outProduced = transferSize;
|
||||
m_checksum = UpdateChecksum(m_checksum, out, outProduced);
|
||||
return INFO::OK;
|
||||
|
@ -24,7 +24,6 @@
|
||||
#include "lib/file/io/io.h"
|
||||
|
||||
#include "lib/allocators/allocators.h" // AllocatorChecker
|
||||
#include "lib/sysdep/cpu.h" // cpu_memcpy
|
||||
#include "lib/file/file.h"
|
||||
#include "lib/file/common/file_stats.h"
|
||||
#include "lib/file/io/block_cache.h"
|
||||
@ -35,7 +34,7 @@ static const size_t ioDepth = 16;
|
||||
|
||||
// the underlying aio implementation likes buffer and offset to be
|
||||
// sector-aligned; if not, the transfer goes through an align buffer,
|
||||
// and requires an extra cpu_memcpy.
|
||||
// and requires an extra memcpy.
|
||||
//
|
||||
// if the user specifies an unaligned buffer, there's not much we can
|
||||
// do - we can't assume the buffer contains padding. therefore,
|
||||
@ -138,7 +137,7 @@ public:
|
||||
// copy from cache into user buffer
|
||||
if(alignedBuf)
|
||||
{
|
||||
cpu_memcpy(alignedBuf, m_cachedBlock.get(), BLOCK_SIZE);
|
||||
memcpy(alignedBuf, m_cachedBlock.get(), BLOCK_SIZE);
|
||||
m_alignedBuf = alignedBuf;
|
||||
}
|
||||
// return cached block
|
||||
|
@ -41,11 +41,11 @@ void WriteBuffer::Append(const void* data, size_t size)
|
||||
{
|
||||
m_capacity = round_up_to_pow2(m_size + size);
|
||||
shared_ptr<u8> newData = io_Allocate(m_capacity);
|
||||
cpu_memcpy(newData.get(), m_data.get(), m_size);
|
||||
memcpy(newData.get(), m_data.get(), m_size);
|
||||
m_data = newData;
|
||||
}
|
||||
|
||||
cpu_memcpy(m_data.get() + m_size, data, size);
|
||||
memcpy(m_data.get() + m_size, data, size);
|
||||
m_size += size;
|
||||
}
|
||||
|
||||
@ -53,7 +53,7 @@ void WriteBuffer::Append(const void* data, size_t size)
|
||||
void WriteBuffer::Overwrite(const void* data, size_t size, size_t offset)
|
||||
{
|
||||
debug_assert(offset+size < m_size);
|
||||
cpu_memcpy(m_data.get()+offset, data, size);
|
||||
memcpy(m_data.get()+offset, data, size);
|
||||
}
|
||||
|
||||
|
||||
@ -93,7 +93,7 @@ LibError UnalignedWriter::Append(const u8* data, size_t size) const
|
||||
}
|
||||
|
||||
const size_t chunkSize = std::min(size, BLOCK_SIZE-m_bytesUsed);
|
||||
cpu_memcpy(m_alignedBuf.get()+m_bytesUsed, data, chunkSize);
|
||||
memcpy(m_alignedBuf.get()+m_bytesUsed, data, chunkSize);
|
||||
m_bytesUsed += chunkSize;
|
||||
data += chunkSize;
|
||||
size -= chunkSize;
|
||||
|
@ -248,7 +248,7 @@ static void* UnsafeAllocateAndCopyTable(PCV_u8 mem, size_t numBytes, void* arg)
|
||||
if(!copy)
|
||||
return FAILED;
|
||||
|
||||
cpu_memcpy((void*)copy, (const void*)mem, tableSize);
|
||||
memcpy((void*)copy, (const void*)mem, tableSize);
|
||||
return (void*)copy;
|
||||
}
|
||||
|
||||
|
@ -34,9 +34,4 @@ void cpu_ConfigureFloatingPoint()
|
||||
// *guess* we don't need to do anything...
|
||||
}
|
||||
|
||||
void* cpu_memcpy(void* RESTRICT dst, const void* RESTRICT src, size_t size)
|
||||
{
|
||||
return memcpy(dst, src, size);
|
||||
}
|
||||
|
||||
#endif // ARCH_AMD64
|
||||
|
@ -145,9 +145,3 @@ void cpu_ConfigureFloatingPoint()
|
||||
// results were changed significantly, so it had to be disabled.
|
||||
//ia32_asm_control87(IA32_RC_CHOP, IA32_MCW_RC);
|
||||
}
|
||||
|
||||
|
||||
void* cpu_memcpy(void* RESTRICT dst, const void* RESTRICT src, size_t size)
|
||||
{
|
||||
return memcpy(dst, src, size);
|
||||
}
|
||||
|
@ -110,23 +110,12 @@ inline void cpu_Pause()
|
||||
//-----------------------------------------------------------------------------
|
||||
// misc
|
||||
|
||||
/**
|
||||
* drop-in replacement for POSIX memcpy().
|
||||
**/
|
||||
LIB_API void* cpu_memcpy(void* RESTRICT dst, const void* RESTRICT src, size_t size);
|
||||
|
||||
|
||||
/**
|
||||
* set the FPU control word to "desirable" values (see implementation)
|
||||
**/
|
||||
LIB_API void cpu_ConfigureFloatingPoint();
|
||||
|
||||
// convert float to int much faster than _ftol2, which would normally be
|
||||
// used by (int) casts.
|
||||
// VC8 and GCC with -ffast-math now manage to generate SSE instructions,
|
||||
// so our implementation is no longer needed.
|
||||
#define cpu_i32FromFloat(f) ((i32)(f))
|
||||
#define cpu_i32FromDouble(d) ((i32)(d))
|
||||
#define cpu_i64FromDouble(d) ((i64)(d))
|
||||
// NB: cpu_i64FromDouble et al. were faster than _ftol2, but are obsolete
|
||||
// since VC8 and GCC (with -ffast-math) generate SSE instructions.
|
||||
|
||||
#endif // #ifndef INCLUDED_CPU
|
||||
|
@ -254,7 +254,7 @@ PinhFromImageBase(HMODULE hmod) {
|
||||
|
||||
static inline void WINAPI
|
||||
OverlayIAT(PImgThunkData pitdDst, PCImgThunkData pitdSrc) {
|
||||
cpu_memcpy(pitdDst, pitdSrc, CountOfImports(pitdDst) * sizeof IMAGE_THUNK_DATA);
|
||||
memcpy(pitdDst, pitdSrc, CountOfImports(pitdDst) * sizeof IMAGE_THUNK_DATA);
|
||||
}
|
||||
|
||||
static inline DWORD WINAPI
|
||||
|
@ -265,7 +265,7 @@ static inline LibError InitUpdateThread()
|
||||
// make sure our interval isn't too long
|
||||
// (counterBits can be 64 => Bit() would overflow => calculate period/2)
|
||||
const double period_2 = Bit<u64>(counterBits-1) / nominalFrequency;
|
||||
const size_t rolloversPerInterval = size_t(UPDATE_INTERVAL_MS / cpu_i64FromDouble(period_2*2.0*1000.0));
|
||||
const size_t rolloversPerInterval = size_t(UPDATE_INTERVAL_MS / i64(period_2*2.0*1000.0));
|
||||
debug_assert(rolloversPerInterval <= 1);
|
||||
|
||||
hExitEvent = CreateEvent(0, TRUE, FALSE, 0); // manual reset, initially false
|
||||
|
@ -32,7 +32,6 @@
|
||||
#include "lib/sysdep/os/win/wposix/wtime.h"
|
||||
|
||||
#include "lib/sysdep/os/win/wposix/wposix_internal.h"
|
||||
#include "lib/sysdep/cpu.h" // cpu_i64FromDouble
|
||||
#include "lib/sysdep/os/win/whrt/whrt.h"
|
||||
|
||||
WINIT_REGISTER_MAIN_INIT(wtime_Init); // whrt -> wtime
|
||||
@ -96,7 +95,7 @@ static void LatchInitialSystemTime()
|
||||
// algorithm: add current HRT value to the startup system time
|
||||
static i64 CurrentSystemTime_ns()
|
||||
{
|
||||
const i64 ns = stInitial_ns + cpu_i64FromDouble(whrt_Time() * _1e9);
|
||||
const i64 ns = stInitial_ns + i64(whrt_Time() * _1e9);
|
||||
return ns;
|
||||
}
|
||||
|
||||
@ -134,7 +133,7 @@ int clock_getres(clockid_t clock, struct timespec* ts)
|
||||
debug_assert(clock == CLOCK_REALTIME || clock == CLOCK_MONOTONIC);
|
||||
|
||||
const double resolution = whrt_Resolution();
|
||||
const i64 ns = cpu_i64FromDouble(resolution * 1e9);
|
||||
const i64 ns = i64(resolution * 1e9);
|
||||
*ts = TimespecFromNs(ns);
|
||||
return 0;
|
||||
}
|
||||
|
@ -40,24 +40,6 @@
|
||||
class TestSysdep : public CxxTest::TestSuite
|
||||
{
|
||||
public:
|
||||
void test_float_int()
|
||||
{
|
||||
TS_ASSERT_EQUALS(cpu_i32FromFloat(0.99999f), 0);
|
||||
TS_ASSERT_EQUALS(cpu_i32FromFloat(1.0f), 1);
|
||||
TS_ASSERT_EQUALS(cpu_i32FromFloat(1.01f), 1);
|
||||
TS_ASSERT_EQUALS(cpu_i32FromFloat(5.6f), 5);
|
||||
|
||||
TS_ASSERT_EQUALS(cpu_i32FromDouble(0.99999), 0);
|
||||
TS_ASSERT_EQUALS(cpu_i32FromDouble(1.0), 1);
|
||||
TS_ASSERT_EQUALS(cpu_i32FromDouble(1.01), 1);
|
||||
TS_ASSERT_EQUALS(cpu_i32FromDouble(5.6), 5);
|
||||
|
||||
TS_ASSERT_EQUALS(cpu_i64FromDouble(0.99999), 0LL);
|
||||
TS_ASSERT_EQUALS(cpu_i64FromDouble(1.0), 1LL);
|
||||
TS_ASSERT_EQUALS(cpu_i64FromDouble(1.01), 1LL);
|
||||
TS_ASSERT_EQUALS(cpu_i64FromDouble(5.6), 5LL);
|
||||
}
|
||||
|
||||
void test_round()
|
||||
{
|
||||
TS_ASSERT_EQUALS(rintf(0.99999f), 1.0f);
|
||||
|
@ -191,7 +191,7 @@ static void create_level(size_t level, size_t level_w, size_t level_h, const u8*
|
||||
if(level == 0)
|
||||
{
|
||||
debug_assert(level_data_size == cld->prev_level_data_size);
|
||||
cpu_memcpy(dst, src, level_data_size);
|
||||
memcpy(dst, src, level_data_size);
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -356,7 +356,7 @@ TIMER_ACCRUE(tc_plain_transform);
|
||||
else
|
||||
{
|
||||
src = (const u8*)newData.get();
|
||||
cpu_memcpy(newData.get(), data, data_size);
|
||||
memcpy(newData.get(), data, data_size);
|
||||
}
|
||||
|
||||
// no conversion necessary
|
||||
@ -366,7 +366,7 @@ TIMER_ACCRUE(tc_plain_transform);
|
||||
{
|
||||
for(size_t y = 0; y < h; y++)
|
||||
{
|
||||
cpu_memcpy(dst, src, pitch);
|
||||
memcpy(dst, src, pitch);
|
||||
dst += pitch;
|
||||
src += row_ofs;
|
||||
}
|
||||
|
@ -149,7 +149,7 @@ void CFileUnpacker::UnpackRaw(void* rawData, size_t rawDataSize)
|
||||
throw PSERROR_File_UnexpectedEOF();
|
||||
|
||||
void* src = m_buf.get() + m_unpackPos;
|
||||
cpu_memcpy(rawData, src, rawDataSize);
|
||||
memcpy(rawData, src, rawDataSize);
|
||||
m_unpackPos += rawDataSize;
|
||||
}
|
||||
|
||||
|
@ -345,7 +345,7 @@ void WriteBigScreenshot(const std::wstring& extension, int tiles)
|
||||
{
|
||||
void* dest = (char*)img + ((tile_y*tile_h + y) * img_w + (tile_x*tile_w)) * bpp/8;
|
||||
void* src = (char*)tile_data + y * tile_w * bpp/8;
|
||||
cpu_memcpy(dest, src, tile_w * bpp/8);
|
||||
memcpy(dest, src, tile_w * bpp/8);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -97,7 +97,7 @@ bool XMLWriter_File::StoreVFS(const PIVFS& vfs, const VfsPath& pathname)
|
||||
|
||||
const size_t size = m_Data.length();
|
||||
shared_ptr<u8> data = io_Allocate(size);
|
||||
cpu_memcpy(data.get(), m_Data.data(), size);
|
||||
memcpy(data.get(), m_Data.data(), size);
|
||||
LibError ret = vfs->CreateFile(pathname, data, size);
|
||||
if (ret < 0)
|
||||
{
|
||||
|
@ -207,7 +207,7 @@ void CVertexBuffer::AppendBatch(VBChunk* UNUSED(chunk),Handle texture,size_t num
|
||||
|
||||
// resize the chunk's batch to fit its indices
|
||||
batch->m_IndexData.push_back(std::pair<size_t,u16*>(numIndices,indices));
|
||||
// cpu_memcpy(&batch->m_Indices[0]+cursize,indices,sizeof(u16)*numIndices);
|
||||
// memcpy(&batch->m_Indices[0]+cursize,indices,sizeof(u16)*numIndices);
|
||||
}
|
||||
|
||||
|
||||
@ -224,7 +224,7 @@ void CVertexBuffer::UpdateChunkVertices(VBChunk* chunk,void* data)
|
||||
// if (glGetError() != GL_NO_ERROR) throw PSERROR_Renderer_VBOFailed();
|
||||
} else {
|
||||
debug_assert(m_SysMem);
|
||||
cpu_memcpy(m_SysMem + chunk->m_Index * m_VertexSize, data, chunk->m_Count * m_VertexSize);
|
||||
memcpy(m_SysMem + chunk->m_Index * m_VertexSize, data, chunk->m_Count * m_VertexSize);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -87,9 +87,9 @@ QUERYHANDLER(CinemaRecord)
|
||||
//* // TODO: BGR24 output doesn't need flipping, YUV420 and RGBA32 do
|
||||
for (int y = 0; y < h/2; ++y)
|
||||
{
|
||||
cpu_memcpy(temp, &img[y*w*3], w*3);
|
||||
cpu_memcpy(&img[y*w*3], &img[(h-1-y)*w*3], w*3);
|
||||
cpu_memcpy(&img[(h-1-y)*w*3], temp, w*3);
|
||||
memcpy(temp, &img[y*w*3], w*3);
|
||||
memcpy(&img[y*w*3], &img[(h-1-y)*w*3], w*3);
|
||||
memcpy(&img[(h-1-y)*w*3], temp, w*3);
|
||||
}
|
||||
//*/
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user