From e8b7d180bfa016a487fb79329c23545a06e5c4b5 Mon Sep 17 00:00:00 2001 From: Jeffrey Pfau Date: Thu, 8 Sep 2016 19:09:20 -0700 Subject: [PATCH] Util: Add PRIz macro for libc versions that don't support %z --- CHANGES | 1 + src/gba/renderers/thread-proxy.c | 2 +- src/util/common.h | 7 +++++++ src/util/gui/file-select.c | 4 ++-- 4 files changed, 11 insertions(+), 3 deletions(-) diff --git a/CHANGES b/CHANGES index e9bb48017..d659c1e00 100644 --- a/CHANGES +++ b/CHANGES @@ -93,6 +93,7 @@ Misc: - FFmpeg: Full support for libavcodec 56+ - Util: PNG utils should support 16-bit when applicable - Debugger: Add software breakpoint support to gdb + - Util: Add PRIz macro for libc versions that don't support %z 0.4.1: (2016-07-11) Bugfixes: diff --git a/src/gba/renderers/thread-proxy.c b/src/gba/renderers/thread-proxy.c index deea1e24e..f144ff8ea 100644 --- a/src/gba/renderers/thread-proxy.c +++ b/src/gba/renderers/thread-proxy.c @@ -139,7 +139,7 @@ void _proxyThreadRecover(struct GBAVideoThreadProxyRenderer* proxyRenderer) { static bool _writeData(struct GBAVideoThreadProxyRenderer* proxyRenderer, void* data, size_t length) { while (!RingFIFOWrite(&proxyRenderer->dirtyQueue, data, length)) { - mLOG(GBA_VIDEO, WARN, "Can't write %zu bytes. Proxy thread asleep?", length); + mLOG(GBA_VIDEO, WARN, "Can't write %"PRIz"u bytes. Proxy thread asleep?", length); mLOG(GBA_VIDEO, DEBUG, "Queue status: read: %p, write: %p", proxyRenderer->dirtyQueue.readPtr, proxyRenderer->dirtyQueue.writePtr); MutexLock(&proxyRenderer->mutex); if (proxyRenderer->threadState == PROXY_THREAD_STOPPED) { diff --git a/src/util/common.h b/src/util/common.h index 614d49db9..6f17d58e9 100644 --- a/src/util/common.h +++ b/src/util/common.h @@ -69,6 +69,13 @@ typedef intptr_t ssize_t; #define ATOMIC_CMPXCHG(DST, EXPECTED, OP) ((DST == EXPECTED) ? ((DST = OP), true) : false) #endif +#if defined(_3DS) || defined(GEKKO) || defined(PSP2) +// newlib doesn't support %z properly +#define PRIz "" +#else +#define PRIz "z" +#endif + #if defined(__PPC__) || defined(__POWERPC__) #define LOAD_32LE(DEST, ADDR, ARR) { \ uint32_t _addr = (ADDR); \ diff --git a/src/util/gui/file-select.c b/src/util/gui/file-select.c index f13b5c86e..70bc91120 100644 --- a/src/util/gui/file-select.c +++ b/src/util/gui/file-select.c @@ -71,7 +71,7 @@ static bool _refreshDirectory(struct GUIParams* params, const char* currentPath, if (params->guiPrepare) { params->guiPrepare(); } - GUIFontPrintf(params->font, 0, GUIFontHeight(params->font), GUI_ALIGN_LEFT, 0xFFFFFFFF, "(scanning for items: %zu)", i); + GUIFontPrintf(params->font, 0, GUIFontHeight(params->font), GUI_ALIGN_LEFT, 0xFFFFFFFF, "(scanning for items: %"PRIz"u)", i); GUIFontPrintf(params->font, 0, GUIFontHeight(params->font) * 2, GUI_ALIGN_LEFT, 0xFFFFFFFF, "%s", currentPath); if (params->guiFinish) { params->guiFinish(); @@ -109,7 +109,7 @@ static bool _refreshDirectory(struct GUIParams* params, const char* currentPath, if (params->guiPrepare) { params->guiPrepare(); } - GUIFontPrintf(params->font, 0, GUIFontHeight(params->font), GUI_ALIGN_LEFT, 0xFFFFFFFF, "(scanning item %zu of %zu)", i, items); + GUIFontPrintf(params->font, 0, GUIFontHeight(params->font), GUI_ALIGN_LEFT, 0xFFFFFFFF, "(scanning item %"PRIz"u of %"PRIz"u)", i, items); GUIFontPrintf(params->font, 0, GUIFontHeight(params->font) * 2, GUI_ALIGN_LEFT, 0xFFFFFFFF, "%s", currentPath); if (params->guiFinish) { params->guiFinish();