From 25aea134ef85e38e72c0859e36d477beb85adacf Mon Sep 17 00:00:00 2001 From: Themaister Date: Tue, 13 Dec 2011 19:34:45 +0100 Subject: [PATCH] Add temporary hack for SDL cond in Xenon. --- Makefile.xenon | 2 +- xenon/cond.c | 54 ++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 55 insertions(+), 1 deletion(-) create mode 100644 xenon/cond.c diff --git a/Makefile.xenon b/Makefile.xenon index ca1b873143..a248c922ec 100644 --- a/Makefile.xenon +++ b/Makefile.xenon @@ -18,7 +18,7 @@ PPU_TARGET_ADJUSTED := ssnes-libxenon.elf32 LDDIRS = -L. -L$(DEVKITXENON)/usr/lib -L$(DEVKITXENON)/xenon/lib/32 INCDIRS = -I. -I$(DEVKITXENON)/usr/include -I$(DEVKITXENON)/usr/include/SDL -OBJ = fifo_buffer.o ssnes.o driver.o file.o settings.o message.o rewind.o movie.o input/sdl.o audio/sdl.o gfx/sdl.o gfx/sdlwrap.o gfx/gfx_common.o ups.o bps.o strl.o screenshot.o audio/hermite.o dynamic.o audio/utils.o conf/config_file.o +OBJ = fifo_buffer.o ssnes.o driver.o file.o settings.o message.o rewind.o movie.o input/sdl.o audio/sdl.o gfx/sdl.o gfx/sdlwrap.o gfx/gfx_common.o ups.o bps.o strl.o screenshot.o audio/hermite.o dynamic.o audio/utils.o conf/config_file.o xenon/cond.o LIBS = -lsnes -lSDL -lxenon -lm -lc DEFINES = -std=gnu99 -DHAVE_CONFIGFILE=1 -DHAVE_SDL=1 -DPACKAGE_VERSION=\"0.9.3\" -DHAVE_GETOPT_LONG=1 diff --git a/xenon/cond.c b/xenon/cond.c new file mode 100644 index 0000000000..ef1baacb4b --- /dev/null +++ b/xenon/cond.c @@ -0,0 +1,54 @@ +/* SSNES - A Super Nintendo Entertainment System (SNES) Emulator frontend for libsnes. + * Copyright (C) 2010-2011 - Hans-Kristian Arntzen + * + * Some code herein may be based on code found in BSNES. + * + * SSNES is free software: you can redistribute it and/or modify it under the terms + * of the GNU General Public License as published by the Free Software Found- + * ation, either version 3 of the License, or (at your option) any later version. + * + * SSNES is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; + * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + * PURPOSE. See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along with SSNES. + * If not, see . + */ + +// libSDLxenon doesn't implement this yet :[. Implement it very stupidly for now. ;) + +#include "SDL_thread.h" +#include "SDL_mutex.h" +#include +#include + +SDL_cond *SDL_CreateCond(void) +{ + bool *sleeping = calloc(1, sizeof(sleeping)); + return (SDL_cond*)sleeping; +} + +void SDL_DestroyCond(SDL_cond *sleeping) +{ + free(sleeping); +} + +int SDL_CondWait(SDL_cond *cond, SDL_mutex *lock) +{ + (void)lock; + volatile bool *sleeping = (volatile bool*)cond; + + SDL_mutexV(lock); + *sleeping = true; + while (*sleeping); // Yeah, we all love busyloops don't we? ._. + SDL_mutexP(lock); + + return 0; +} + +int SDL_CondSignal(SDL_cond *cond) +{ + *(volatile bool*)cond = false; + return 0; +} +