From 52851faeb69a747a04314929f098a5ef0f1468d7 Mon Sep 17 00:00:00 2001 From: janwas Date: Mon, 1 Nov 2010 11:09:03 +0000 Subject: [PATCH] cleanup - remove old cpu_memcpy and cpu_i64FromDouble that are no longer needed This was SVN commit r8517. --- source/graphics/Terrain.cpp | 10 +++++----- source/i18n/StrImmutable.h | 2 +- source/lib/allocators/dynarray.cpp | 4 ++-- source/lib/allocators/string_pool.cpp | 3 +-- source/lib/debug.cpp | 2 +- source/lib/file/archive/archive_zip.cpp | 7 +++---- source/lib/file/archive/codec_zlib.cpp | 2 +- source/lib/file/io/io.cpp | 5 ++--- source/lib/file/io/write_buffer.cpp | 8 ++++---- source/lib/sysdep/acpi.cpp | 2 +- source/lib/sysdep/arch/amd64/amd64.cpp | 5 ----- source/lib/sysdep/arch/ia32/ia32.cpp | 6 ------ source/lib/sysdep/cpu.h | 15 ++------------- source/lib/sysdep/os/win/wdll_delay_load.cpp | 2 +- source/lib/sysdep/os/win/whrt/whrt.cpp | 2 +- source/lib/sysdep/os/win/wposix/wtime.cpp | 5 ++--- source/lib/sysdep/tests/test_sysdep.h | 18 ------------------ source/lib/tex/tex.cpp | 6 +++--- source/ps/FileIo.cpp | 2 +- source/ps/Util.cpp | 2 +- source/ps/XML/XMLWriter.cpp | 2 +- source/renderer/VertexBuffer.cpp | 4 ++-- .../GameInterface/Handlers/MiscHandlers.cpp | 6 +++--- 23 files changed, 38 insertions(+), 82 deletions(-) diff --git a/source/graphics/Terrain.cpp b/source/graphics/Terrain.cpp index cdf9388a50..092042167a 100644 --- a/source/graphics/Terrain.cpp +++ b/source/graphics/Terrain.cpp @@ -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;jm_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;idata = 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) diff --git a/source/lib/allocators/dynarray.cpp b/source/lib/allocators/dynarray.cpp index 0ad9e2bd7b..e653685eae 100644 --- a/source/lib/allocators/dynarray.cpp +++ b/source/lib/allocators/dynarray.cpp @@ -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; } diff --git a/source/lib/allocators/string_pool.cpp b/source/lib/allocators/string_pool.cpp index 1811c42536..612c4cf92d 100644 --- a/source/lib/allocators/string_pool.cpp +++ b/source/lib/allocators/string_pool.cpp @@ -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); diff --git a/source/lib/debug.cpp b/source/lib/debug.cpp index 493f3c9388..d55bcae83c 100644 --- a/source/lib/debug.cpp +++ b/source/lib/debug.cpp @@ -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) } diff --git a/source/lib/file/archive/archive_zip.cpp b/source/lib/file/archive/archive_zip.cpp index 2f3725815c..9bda6bd805 100644 --- a/source/lib/file/archive/archive_zip.cpp +++ b/source/lib/file/archive/archive_zip.cpp @@ -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; diff --git a/source/lib/file/archive/codec_zlib.cpp b/source/lib/file/archive/codec_zlib.cpp index 8fb64be428..8ff8be9cf0 100644 --- a/source/lib/file/archive/codec_zlib.cpp +++ b/source/lib/file/archive/codec_zlib.cpp @@ -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; diff --git a/source/lib/file/io/io.cpp b/source/lib/file/io/io.cpp index 5f69ffa570..04df642dc8 100644 --- a/source/lib/file/io/io.cpp +++ b/source/lib/file/io/io.cpp @@ -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 diff --git a/source/lib/file/io/write_buffer.cpp b/source/lib/file/io/write_buffer.cpp index 0003f61ca2..34e2ca6b16 100644 --- a/source/lib/file/io/write_buffer.cpp +++ b/source/lib/file/io/write_buffer.cpp @@ -41,11 +41,11 @@ void WriteBuffer::Append(const void* data, size_t size) { m_capacity = round_up_to_pow2(m_size + size); shared_ptr 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; diff --git a/source/lib/sysdep/acpi.cpp b/source/lib/sysdep/acpi.cpp index 74135427ff..40683e75e3 100644 --- a/source/lib/sysdep/acpi.cpp +++ b/source/lib/sysdep/acpi.cpp @@ -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; } diff --git a/source/lib/sysdep/arch/amd64/amd64.cpp b/source/lib/sysdep/arch/amd64/amd64.cpp index 188190f9b0..ccef774944 100644 --- a/source/lib/sysdep/arch/amd64/amd64.cpp +++ b/source/lib/sysdep/arch/amd64/amd64.cpp @@ -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 diff --git a/source/lib/sysdep/arch/ia32/ia32.cpp b/source/lib/sysdep/arch/ia32/ia32.cpp index f60051275e..90fed2b2f9 100644 --- a/source/lib/sysdep/arch/ia32/ia32.cpp +++ b/source/lib/sysdep/arch/ia32/ia32.cpp @@ -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); -} diff --git a/source/lib/sysdep/cpu.h b/source/lib/sysdep/cpu.h index dd0c53e1d9..7d582e066f 100644 --- a/source/lib/sysdep/cpu.h +++ b/source/lib/sysdep/cpu.h @@ -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 diff --git a/source/lib/sysdep/os/win/wdll_delay_load.cpp b/source/lib/sysdep/os/win/wdll_delay_load.cpp index 20f2bad539..c7c43176e7 100644 --- a/source/lib/sysdep/os/win/wdll_delay_load.cpp +++ b/source/lib/sysdep/os/win/wdll_delay_load.cpp @@ -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 diff --git a/source/lib/sysdep/os/win/whrt/whrt.cpp b/source/lib/sysdep/os/win/whrt/whrt.cpp index 2e2a710517..d0b6604165 100644 --- a/source/lib/sysdep/os/win/whrt/whrt.cpp +++ b/source/lib/sysdep/os/win/whrt/whrt.cpp @@ -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(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 diff --git a/source/lib/sysdep/os/win/wposix/wtime.cpp b/source/lib/sysdep/os/win/wposix/wtime.cpp index 4e19102a94..17134e5dc8 100644 --- a/source/lib/sysdep/os/win/wposix/wtime.cpp +++ b/source/lib/sysdep/os/win/wposix/wtime.cpp @@ -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; } diff --git a/source/lib/sysdep/tests/test_sysdep.h b/source/lib/sysdep/tests/test_sysdep.h index 64c066f1ae..227dbce411 100644 --- a/source/lib/sysdep/tests/test_sysdep.h +++ b/source/lib/sysdep/tests/test_sysdep.h @@ -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); diff --git a/source/lib/tex/tex.cpp b/source/lib/tex/tex.cpp index e992d85a6c..f3f711d1c7 100644 --- a/source/lib/tex/tex.cpp +++ b/source/lib/tex/tex.cpp @@ -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; } diff --git a/source/ps/FileIo.cpp b/source/ps/FileIo.cpp index a8dcf4fd0e..90b5b29967 100644 --- a/source/ps/FileIo.cpp +++ b/source/ps/FileIo.cpp @@ -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; } diff --git a/source/ps/Util.cpp b/source/ps/Util.cpp index 1504ed1258..ad4763e0dd 100644 --- a/source/ps/Util.cpp +++ b/source/ps/Util.cpp @@ -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); } } } diff --git a/source/ps/XML/XMLWriter.cpp b/source/ps/XML/XMLWriter.cpp index c0d232c42c..b14a176de3 100644 --- a/source/ps/XML/XMLWriter.cpp +++ b/source/ps/XML/XMLWriter.cpp @@ -97,7 +97,7 @@ bool XMLWriter_File::StoreVFS(const PIVFS& vfs, const VfsPath& pathname) const size_t size = m_Data.length(); shared_ptr 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) { diff --git a/source/renderer/VertexBuffer.cpp b/source/renderer/VertexBuffer.cpp index 6a2c45ead9..fc8d87d045 100644 --- a/source/renderer/VertexBuffer.cpp +++ b/source/renderer/VertexBuffer.cpp @@ -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(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); } } diff --git a/source/tools/atlas/GameInterface/Handlers/MiscHandlers.cpp b/source/tools/atlas/GameInterface/Handlers/MiscHandlers.cpp index fc32629c6e..77337a67c1 100644 --- a/source/tools/atlas/GameInterface/Handlers/MiscHandlers.cpp +++ b/source/tools/atlas/GameInterface/Handlers/MiscHandlers.cpp @@ -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); } //*/