From d5b349f670a9ee896c7e16bbdf9582534a00e016 Mon Sep 17 00:00:00 2001 From: Romain Vimont Date: Fri, 15 Dec 2017 17:31:23 +0100 Subject: [PATCH] Do not inline lockutil functions This duplicates chars in the final binary. --- app/meson.build | 1 + app/src/lockutil.c | 32 ++++++++++++++++++++++++++++++++ app/src/lockutil.h | 37 +++++++------------------------------ 3 files changed, 40 insertions(+), 30 deletions(-) create mode 100644 app/src/lockutil.c diff --git a/app/meson.build b/app/meson.build index f43a6bd6..3482f14c 100644 --- a/app/meson.build +++ b/app/meson.build @@ -5,6 +5,7 @@ src = [ 'src/command.c', 'src/decoder.c', 'src/frames.c', + 'src/lockutil.c', 'src/netutil.c', 'src/screen.c', 'src/strutil.c', diff --git a/app/src/lockutil.c b/app/src/lockutil.c new file mode 100644 index 00000000..8891e6df --- /dev/null +++ b/app/src/lockutil.c @@ -0,0 +1,32 @@ +#include +#include +#include + +void mutex_lock(SDL_mutex *mutex) { + if (SDL_LockMutex(mutex)) { + SDL_LogCritical(SDL_LOG_CATEGORY_SYSTEM, "Could not lock mutex"); + abort(); + } +} + +void mutex_unlock(SDL_mutex *mutex) { + if (SDL_UnlockMutex(mutex)) { + SDL_LogCritical(SDL_LOG_CATEGORY_SYSTEM, "Could not unlock mutex"); + abort(); + } +} + +void cond_wait(SDL_cond *cond, SDL_mutex *mutex) { + if (SDL_CondWait(cond, mutex)) { + SDL_LogCritical(SDL_LOG_CATEGORY_SYSTEM, "Could not wait on condition"); + abort(); + } +} + +void cond_signal(SDL_cond *cond) { + if (SDL_CondSignal(cond)) { + SDL_LogCritical(SDL_LOG_CATEGORY_SYSTEM, "Could not signal a condition"); + abort(); + } +} + diff --git a/app/src/lockutil.h b/app/src/lockutil.h index 10a9adf2..255cafe4 100644 --- a/app/src/lockutil.h +++ b/app/src/lockutil.h @@ -1,36 +1,13 @@ #ifndef LOCKUTIL_H #define LOCKUTIL_H -#include -#include -#include +// forward declarations +typedef struct SDL_mutex SDL_mutex; +typedef struct SDL_cond SDL_cond; -static inline void mutex_lock(SDL_mutex *mutex) { - if (SDL_LockMutex(mutex)) { - SDL_LogCritical(SDL_LOG_CATEGORY_SYSTEM, "Could not lock mutex"); - exit(1); - } -} - -static inline void mutex_unlock(SDL_mutex *mutex) { - if (SDL_UnlockMutex(mutex)) { - SDL_LogCritical(SDL_LOG_CATEGORY_SYSTEM, "Could not unlock mutex"); - exit(1); - } -} - -static inline void cond_wait(SDL_cond *cond, SDL_mutex *mutex) { - if (SDL_CondWait(cond, mutex)) { - SDL_LogCritical(SDL_LOG_CATEGORY_SYSTEM, "Could not wait on condition"); - exit(1); - } -} - -static inline void cond_signal(SDL_cond *cond) { - if (SDL_CondSignal(cond)) { - SDL_LogCritical(SDL_LOG_CATEGORY_SYSTEM, "Could not signal a condition"); - exit(1); - } -} +void mutex_lock(SDL_mutex *mutex); +void mutex_unlock(SDL_mutex *mutex); +void cond_wait(SDL_cond *cond, SDL_mutex *mutex); +void cond_signal(SDL_cond *cond); #endif