Do not inline lockutil functions

This duplicates chars in the final binary.
master
Romain Vimont 8 years ago
parent a9b276aa67
commit d5b349f670

@ -5,6 +5,7 @@ src = [
'src/command.c', 'src/command.c',
'src/decoder.c', 'src/decoder.c',
'src/frames.c', 'src/frames.c',
'src/lockutil.c',
'src/netutil.c', 'src/netutil.c',
'src/screen.c', 'src/screen.c',
'src/strutil.c', 'src/strutil.c',

@ -0,0 +1,32 @@
#include <stdlib.h>
#include <SDL2/SDL_log.h>
#include <SDL2/SDL_mutex.h>
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();
}
}

@ -1,36 +1,13 @@
#ifndef LOCKUTIL_H #ifndef LOCKUTIL_H
#define LOCKUTIL_H #define LOCKUTIL_H
#include <stdlib.h> // forward declarations
#include <SDL2/SDL_log.h> typedef struct SDL_mutex SDL_mutex;
#include <SDL2/SDL_mutex.h> typedef struct SDL_cond SDL_cond;
static inline void mutex_lock(SDL_mutex *mutex) { void mutex_lock(SDL_mutex *mutex);
if (SDL_LockMutex(mutex)) { void mutex_unlock(SDL_mutex *mutex);
SDL_LogCritical(SDL_LOG_CATEGORY_SYSTEM, "Could not lock mutex"); void cond_wait(SDL_cond *cond, SDL_mutex *mutex);
exit(1); void cond_signal(SDL_cond *cond);
}
}
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);
}
}
#endif #endif

Loading…
Cancel
Save