From e86b23fec2e2e72d552caa6fe8f8f4abcb3185eb Mon Sep 17 00:00:00 2001 From: TheoryOfNekomata Date: Fri, 17 Feb 2023 12:25:26 +0800 Subject: [PATCH] Update macOS compat Properly declare shims for macOS. --- src/packages/asset-inv/main.c | 2 +- src/packages/compat/IZ_windows.h | 18 ++++++++++++++---- src/packages/game/IZ_app_input.c | 6 +++--- src/packages/io/IZ_io.h | 2 ++ src/packages/log/IZ_log.c | 6 +----- src/packages/timer/IZ_timer.c | 2 +- src/packages/timer/IZ_timer.h | 5 +---- 7 files changed, 23 insertions(+), 18 deletions(-) diff --git a/src/packages/asset-inv/main.c b/src/packages/asset-inv/main.c index 5ffc167..22d8787 100644 --- a/src/packages/asset-inv/main.c +++ b/src/packages/asset-inv/main.c @@ -3,7 +3,7 @@ #include "../common/IZ_common.h" #include "../stdinc/IZ_string.h" -#ifdef IZ_WINDOWS +#if defined IZ_WINDOWS #include #endif diff --git a/src/packages/compat/IZ_windows.h b/src/packages/compat/IZ_windows.h index 4e846d6..da24f65 100644 --- a/src/packages/compat/IZ_windows.h +++ b/src/packages/compat/IZ_windows.h @@ -1,12 +1,22 @@ #ifndef IZ_WINDOWS_H #define IZ_WINDOWS_H -#ifndef IZ_WINDOWS -typedef int errno_t; -typedef size_t rsize_t; -#else +#if defined IZ_WINDOWS #include #include +#define _isatty isatty +#define _fileno fileno +#endif + +#if defined IZ_UNIX +typedef size_t rsize_t; +typedef int errno_t; +#endif + +#if defined IZ_MACOS +#include + +typedef int errno_t; #endif #endif //IZ_WINDOWS_H diff --git a/src/packages/game/IZ_app_input.c b/src/packages/game/IZ_app_input.c index ec8cc00..b3b4a57 100644 --- a/src/packages/game/IZ_app_input.c +++ b/src/packages/game/IZ_app_input.c @@ -1,14 +1,14 @@ #include "IZ_app_input.h" -#ifdef IZ_WINDOWS +#if defined IZ_WINDOWS #define IZ_DEBUG_CONNECT SDLK_PAGEUP #define IZ_DEBUG_DISCONNECT SDLK_PAGEDOWN #define IZ_DEBUG_SEND_MESSAGE SDLK_INSERT -#elif IZ_UNIX +#elif defined IZ_UNIX #define IZ_DEBUG_CONNECT SDLK_PAGEUP #define IZ_DEBUG_DISCONNECT SDLK_PAGEDOWN #define IZ_DEBUG_SEND_MESSAGE SDLK_INSERT -#elif IZ_MACOS +#elif defined IZ_MACOS #define IZ_DEBUG_CONNECT SDLK_EQUALS #define IZ_DEBUG_DISCONNECT SDLK_MINUS #define IZ_DEBUG_SEND_MESSAGE SDLK_BACKSLASH diff --git a/src/packages/io/IZ_io.h b/src/packages/io/IZ_io.h index 24d8d6e..d35f712 100644 --- a/src/packages/io/IZ_io.h +++ b/src/packages/io/IZ_io.h @@ -7,6 +7,8 @@ #include "../compat/IZ_windows.h" #ifdef IZ_UNIX #include +#elif defined IZ_MACOS +#include #endif int IZ_sprintf(char*, size_t, const char*, ...); diff --git a/src/packages/log/IZ_log.c b/src/packages/log/IZ_log.c index 26c1995..dae993d 100644 --- a/src/packages/log/IZ_log.c +++ b/src/packages/log/IZ_log.c @@ -4,7 +4,7 @@ bool IZ_LogIsSupportedTerminal() { bool result; const char *term = getenv("TERM"); result = term && strcmp(term, "") != 0; -#ifndef _WIN32 +#ifndef IZ_WINDOWS return result; #else if (result) { @@ -33,11 +33,7 @@ bool IZ_LogIsSupportedTerminal() { } bool IZ_LogIsSupportedColor(FILE* s) { -#ifdef IZ_WINDOWS - return _isatty(_fileno(s)) && IZ_LogIsSupportedTerminal(); -#else return isatty(fileno(s)) && IZ_LogIsSupportedTerminal(); -#endif } void IZ_LogInitialize(const char* context, bool force_output) { diff --git a/src/packages/timer/IZ_timer.c b/src/packages/timer/IZ_timer.c index dc7475b..aef99c4 100644 --- a/src/packages/timer/IZ_timer.c +++ b/src/packages/timer/IZ_timer.c @@ -1,6 +1,6 @@ #include "IZ_timer.h" -#ifdef IZ_WINDOWS +#if defined IZ_WINDOWS typedef enum { _CLOCK_REALTIME = 0, #define CLOCK_REALTIME _CLOCK_REALTIME diff --git a/src/packages/timer/IZ_timer.h b/src/packages/timer/IZ_timer.h index ef40ecd..f65158d 100644 --- a/src/packages/timer/IZ_timer.h +++ b/src/packages/timer/IZ_timer.h @@ -1,9 +1,6 @@ #ifndef IZ_TIMER_H #define IZ_TIMER_H -//#define IZ_LOG_DATE_FRIENDLY -#define IZ_LOG_DATE_ELAPSED_FRIENDLY - #include #include @@ -11,7 +8,7 @@ * The start timestamp. * @sa IZ_TimerStart */ -static time_t IZ_TIMER_START_TIMESTAMP = 0; +static time_t IZ_TIMER_START_TIMESTAMP; /** * Gets the start timestamp.