From b08714313d047b98bbb79d6865d5caf4fb1735b3 Mon Sep 17 00:00:00 2001 From: Phillip Stephens Date: Tue, 11 Oct 2022 21:44:08 -0700 Subject: [PATCH] Match COutputStream::DoPut (Thanks HeartPiece!) Former-commit-id: 26d6394bb1ca6e6e494a38bbf132669c591cfd38 --- configure.py | 2 +- obj_files.mk | 2 +- src/Kyoto/Streams/COutputStream.cpp | 46 ++++++++++++++++------------- src/Runtime/e_pow.c | 1 - 4 files changed, 27 insertions(+), 24 deletions(-) diff --git a/configure.py b/configure.py index 2b66f67c..3d1c0956 100755 --- a/configure.py +++ b/configure.py @@ -883,7 +883,7 @@ LIBS = [ "Runtime/e_pow", ["Runtime/e_rem_pio2", True], ["Runtime/k_cos", True], - "Runtime/k_rem_pio2", + ["Runtime/k_rem_pio2", True], ["Runtime/k_sin", True], ["Runtime/k_tan", True], "Runtime/s_atan", diff --git a/obj_files.mk b/obj_files.mk index 13eb8f78..8d3cc064 100644 --- a/obj_files.mk +++ b/obj_files.mk @@ -760,7 +760,7 @@ MSL_COMMON_MATH :=\ $(BUILD_DIR)/asm/Runtime/e_pow.o\ $(BUILD_DIR)/src/Runtime/e_rem_pio2.o\ $(BUILD_DIR)/src/Runtime/k_cos.o\ - $(BUILD_DIR)/asm/Runtime/k_rem_pio2.o\ + $(BUILD_DIR)/src/Runtime/k_rem_pio2.o\ $(BUILD_DIR)/src/Runtime/k_sin.o\ $(BUILD_DIR)/src/Runtime/k_tan.o\ $(BUILD_DIR)/asm/Runtime/s_atan.o\ diff --git a/src/Kyoto/Streams/COutputStream.cpp b/src/Kyoto/Streams/COutputStream.cpp index fac2f0e3..c3fd330b 100644 --- a/src/Kyoto/Streams/COutputStream.cpp +++ b/src/Kyoto/Streams/COutputStream.cpp @@ -21,28 +21,32 @@ COutputStream::~COutputStream() { } void COutputStream::DoPut(const void* ptr, size_t len) { - if (len == 0) { - return; - } - - mNumWrites += len; - if (mBufLen <= len + mUnwrittenLen) { - memcpy((uchar*)mBufPtr + mUnwrittenLen, ptr, len); - mUnwrittenLen += len; - return; - } - while (len != 0) { - uint count = mBufLen - mUnwrittenLen; - uint offset = len; - if (count < len) { - len = count; + uint offset; + uchar* offsetPtr; + uint tempLen = len; + if (tempLen != 0) { + mNumWrites += tempLen; + if (tempLen + mUnwrittenLen <= mBufLen) { + memcpy((uchar*)mBufPtr + mUnwrittenLen, ptr, tempLen); + mUnwrittenLen += tempLen; + return; } - if (count != 0) { - memcpy((uchar*)mBufPtr + mUnwrittenLen, (uchar*)ptr + offset, len); - mUnwrittenLen += len; - len -= len; - } else { - DoFlush(); + + offsetPtr = (uchar*)ptr + tempLen; + while (tempLen != 0) { + uint count = mBufLen - mUnwrittenLen; + offset = count; + if (tempLen < count) { + offset = tempLen; + } + if (offset != 0) { + memcpy((uchar*)mBufPtr + mUnwrittenLen, (offsetPtr - tempLen), offset); + + tempLen -= offset; + mUnwrittenLen += offset; + } else { + DoFlush(); + } } } } diff --git a/src/Runtime/e_pow.c b/src/Runtime/e_pow.c index ae0f3b1e..335679df 100644 --- a/src/Runtime/e_pow.c +++ b/src/Runtime/e_pow.c @@ -56,7 +56,6 @@ */ #include "fdlibm.h" - #ifdef __STDC__ static const double #else