From 8ee1e7b39febc94bf171db876eae9dec473ccf95 Mon Sep 17 00:00:00 2001 From: bparker06 Date: Tue, 30 Jul 2019 14:53:03 -0400 Subject: [PATCH] remove rsemaphore (#8645) --- Makefile.common | 1 - griffin/griffin.c | 1 - libretro-common/rthreads/rsemaphore.c | 116 -------------------------- 3 files changed, 118 deletions(-) delete mode 100644 libretro-common/rthreads/rsemaphore.c diff --git a/Makefile.common b/Makefile.common index 6e4b08d430..28c8ec8b4a 100644 --- a/Makefile.common +++ b/Makefile.common @@ -868,7 +868,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 986abcdbe6..cc6c7c7b7a 100644 --- a/griffin/griffin.c +++ b/griffin/griffin.c @@ -1159,7 +1159,6 @@ THREAD #endif #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/rthreads/rsemaphore.c b/libretro-common/rthreads/rsemaphore.c deleted file mode 100644 index aa2a285d50..0000000000 --- a/libretro-common/rthreads/rsemaphore.c +++ /dev/null @@ -1,116 +0,0 @@ -/* - Copyright 2005 Allen B. Downey - - This file contains an example program from The Little Book of - Semaphores, available from Green Tea Press, greenteapress.com - - This program 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 Foundation; either version 2 of the License, or - (at your option) any later version. - - This program 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 this program; if not, see http://www.gnu.org/licenses/gpl.html - or write to the Free Software Foundation, Inc., 51 Franklin St, - Fifth Floor, Boston, MA 02110-1301 USA -*/ - -/* Code taken from http://greenteapress.com/semaphores/semaphore.c - * and changed to use libretro-common's mutexes and conditions. - */ - -#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->mutex) - slock_free(semaphore->mutex); - semaphore->mutex = NULL; - if (semaphore) - 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); -} - -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); -}