mirror of
https://github.com/libretro/RetroArch
synced 2025-03-20 19:21:27 +00:00
Remove rsemaphore
This commit is contained in:
parent
dd1da5154f
commit
5b1ecbff87
@ -609,7 +609,6 @@ endif
|
|||||||
|
|
||||||
ifeq ($(HAVE_THREADS), 1)
|
ifeq ($(HAVE_THREADS), 1)
|
||||||
OBJ += $(LIBRETRO_COMM_DIR)/rthreads/rthreads.o \
|
OBJ += $(LIBRETRO_COMM_DIR)/rthreads/rthreads.o \
|
||||||
$(LIBRETRO_COMM_DIR)/rthreads/rsemaphore.o \
|
|
||||||
gfx/video_thread_wrapper.o \
|
gfx/video_thread_wrapper.o \
|
||||||
audio/audio_thread_wrapper.o
|
audio/audio_thread_wrapper.o
|
||||||
DEFINES += -DHAVE_THREADS
|
DEFINES += -DHAVE_THREADS
|
||||||
|
@ -886,7 +886,6 @@ THREAD
|
|||||||
#include "../thread/xenon_sdl_threads.c"
|
#include "../thread/xenon_sdl_threads.c"
|
||||||
#elif defined(HAVE_THREADS)
|
#elif defined(HAVE_THREADS)
|
||||||
#include "../libretro-common/rthreads/rthreads.c"
|
#include "../libretro-common/rthreads/rthreads.c"
|
||||||
#include "../libretro-common/rthreads/rsemaphore.c"
|
|
||||||
#include "../gfx/video_thread_wrapper.c"
|
#include "../gfx/video_thread_wrapper.c"
|
||||||
#include "../audio/audio_thread_wrapper.c"
|
#include "../audio/audio_thread_wrapper.c"
|
||||||
#endif
|
#endif
|
||||||
|
@ -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_common_api.h>
|
|
||||||
|
|
||||||
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 */
|
|
@ -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 <stdlib.h>
|
|
||||||
|
|
||||||
#include <rthreads/rthreads.h>
|
|
||||||
#include <rthreads/rsemaphore.h>
|
|
||||||
|
|
||||||
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);
|
|
||||||
}
|
|
Loading…
x
Reference in New Issue
Block a user