diff --git a/Makefile.common b/Makefile.common index e933af5797..6b43c66536 100644 --- a/Makefile.common +++ b/Makefile.common @@ -609,7 +609,6 @@ endif ifeq ($(HAVE_THREADS), 1) OBJ += $(LIBRETRO_COMM_DIR)/rthreads/rthreads.o \ - $(LIBRETRO_COMM_DIR)/rthreads/rsemaphore.o \ gfx/video_thread_wrapper.o \ audio/audio_thread_wrapper.o DEFINES += -DHAVE_THREADS diff --git a/griffin/griffin.c b/griffin/griffin.c index ae8d7c7bbf..5be8e8af3a 100644 --- a/griffin/griffin.c +++ b/griffin/griffin.c @@ -886,7 +886,6 @@ THREAD #include "../thread/xenon_sdl_threads.c" #elif defined(HAVE_THREADS) #include "../libretro-common/rthreads/rthreads.c" -#include "../libretro-common/rthreads/rsemaphore.c" #include "../gfx/video_thread_wrapper.c" #include "../audio/audio_thread_wrapper.c" #endif diff --git a/libretro-common/include/rthreads/rsemaphore.h b/libretro-common/include/rthreads/rsemaphore.h deleted file mode 100644 index a2e964fb67..0000000000 --- a/libretro-common/include/rthreads/rsemaphore.h +++ /dev/null @@ -1,52 +0,0 @@ -/* Copyright (C) 2010-2017 The RetroArch team - * - * --------------------------------------------------------------------------------------- - * The following license statement only applies to this file (rsemaphore.h). - * --------------------------------------------------------------------------------------- - * - * Permission is hereby granted, free of charge, - * to any person obtaining a copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation the rights to - * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, - * and to permit persons to whom the Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, - * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. - * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, - * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - -#ifndef __LIBRETRO_SDK_SEMAPHORE_H -#define __LIBRETRO_SDK_SEMAPHORE_H - -#include - -RETRO_BEGIN_DECLS - -typedef struct ssem ssem_t; - -/** - * ssem_create: - * @value : initial value for the semaphore - * - * Create a new semaphore. - * - * Returns: pointer to new semaphore if successful, otherwise NULL. - */ -ssem_t *ssem_new(int value); - -void ssem_free(ssem_t *semaphore); - -int ssem_get(ssem_t *semaphore); - -void ssem_wait(ssem_t *semaphore); - -void ssem_signal(ssem_t *semaphore); - -RETRO_END_DECLS - -#endif /* __LIBRETRO_SDK_SEMAPHORE_H */ diff --git a/libretro-common/rthreads/rsemaphore.c b/libretro-common/rthreads/rsemaphore.c deleted file mode 100644 index 8050e40f15..0000000000 --- a/libretro-common/rthreads/rsemaphore.c +++ /dev/null @@ -1,133 +0,0 @@ -/* Copyright (C) 2010-2017 The RetroArch team - * - * --------------------------------------------------------------------------------------- - * The following license statement only applies to this file (rsemaphore.c). - * --------------------------------------------------------------------------------------- - * - * Permission is hereby granted, free of charge, - * to any person obtaining a copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation the rights to - * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, - * and to permit persons to whom the Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, - * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. - * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, - * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - -#ifdef __unix__ -#define _POSIX_C_SOURCE 199309 -#endif - -#include - -#include -#include - -struct ssem -{ - int value; - int wakeups; - slock_t *mutex; - scond_t *cond; -}; - -ssem_t *ssem_new(int value) -{ - ssem_t *semaphore = (ssem_t*)calloc(1, sizeof(*semaphore)); - - if (!semaphore) - goto error; - - semaphore->value = value; - semaphore->wakeups = 0; - semaphore->mutex = slock_new(); - - if (!semaphore->mutex) - goto error; - - semaphore->cond = scond_new(); - - if (!semaphore->cond) - goto error; - - return semaphore; - -error: - if (semaphore) - { - if (semaphore->mutex) - slock_free(semaphore->mutex); - semaphore->mutex = NULL; - free((void*)semaphore); - } - return NULL; -} - -void ssem_free(ssem_t *semaphore) -{ - if (!semaphore) - return; - - scond_free(semaphore->cond); - slock_free(semaphore->mutex); - free((void*)semaphore); -} - -int ssem_get(ssem_t *semaphore) -{ - int val = 0; - if (!semaphore) - return 0; - - slock_lock(semaphore->mutex); - - val = semaphore->value; - - slock_unlock(semaphore->mutex); - - return val; -} - -void ssem_wait(ssem_t *semaphore) -{ - if (!semaphore) - return; - - slock_lock(semaphore->mutex); - semaphore->value--; - - if (semaphore->value < 0) - { - do - { - scond_wait(semaphore->cond, semaphore->mutex); - }while (semaphore->wakeups < 1); - - semaphore->wakeups--; - } - - slock_unlock(semaphore->mutex); -} - -void ssem_signal(ssem_t *semaphore) -{ - if (!semaphore) - return; - - slock_lock(semaphore->mutex); - semaphore->value++; - - if (semaphore->value <= 0) - { - semaphore->wakeups++; - scond_signal(semaphore->cond); - } - - slock_unlock(semaphore->mutex); -}