mirror of
https://gitlab.winehq.org/wine/vkd3d.git
synced 2025-04-13 05:43:18 -07:00
vkd3d: Move the vkd3d_cond implementation to vkd3d-common.
Much like the vkd3d_mutex implementation.
This commit is contained in:
committed by
Alexandre Julliard
parent
8345b9b6f5
commit
7b4a1fdfbc
Notes:
Alexandre Julliard
2024-04-22 23:39:23 +02:00
Approved-by: Giovanni Mascellani (@giomasce) Approved-by: Alexandre Julliard (@julliard) Merge-Request: https://gitlab.winehq.org/wine/vkd3d/-/merge_requests/818
@ -492,6 +492,76 @@ static inline void vkd3d_mutex_destroy(struct vkd3d_mutex *lock)
|
||||
#endif
|
||||
}
|
||||
|
||||
struct vkd3d_cond
|
||||
{
|
||||
#ifdef _WIN32
|
||||
CONDITION_VARIABLE cond;
|
||||
#else
|
||||
pthread_cond_t cond;
|
||||
#endif
|
||||
};
|
||||
|
||||
static inline void vkd3d_cond_init(struct vkd3d_cond *cond)
|
||||
{
|
||||
#ifdef _WIN32
|
||||
InitializeConditionVariable(&cond->cond);
|
||||
#else
|
||||
int ret;
|
||||
|
||||
if ((ret = pthread_cond_init(&cond->cond, NULL)))
|
||||
ERR("Failed to initialise the condition variable, ret %d.\n", ret);
|
||||
#endif
|
||||
}
|
||||
|
||||
static inline void vkd3d_cond_signal(struct vkd3d_cond *cond)
|
||||
{
|
||||
#ifdef _WIN32
|
||||
WakeConditionVariable(&cond->cond);
|
||||
#else
|
||||
int ret;
|
||||
|
||||
if ((ret = pthread_cond_signal(&cond->cond)))
|
||||
ERR("Failed to signal the condition variable, ret %d.\n", ret);
|
||||
#endif
|
||||
}
|
||||
|
||||
static inline void vkd3d_cond_broadcast(struct vkd3d_cond *cond)
|
||||
{
|
||||
#ifdef _WIN32
|
||||
WakeAllConditionVariable(&cond->cond);
|
||||
#else
|
||||
int ret;
|
||||
|
||||
if ((ret = pthread_cond_broadcast(&cond->cond)))
|
||||
ERR("Failed to broadcast the condition variable, ret %d.\n", ret);
|
||||
#endif
|
||||
}
|
||||
|
||||
static inline void vkd3d_cond_wait(struct vkd3d_cond *cond, struct vkd3d_mutex *lock)
|
||||
{
|
||||
#ifdef _WIN32
|
||||
if (!SleepConditionVariableCS(&cond->cond, &lock->lock, INFINITE))
|
||||
ERR("Failed to wait on the condition variable, error %lu.\n", GetLastError());
|
||||
#else
|
||||
int ret;
|
||||
|
||||
if ((ret = pthread_cond_wait(&cond->cond, &lock->lock)))
|
||||
ERR("Failed to wait on the condition variable, ret %d.\n", ret);
|
||||
#endif
|
||||
}
|
||||
|
||||
static inline void vkd3d_cond_destroy(struct vkd3d_cond *cond)
|
||||
{
|
||||
#ifdef _WIN32
|
||||
/* Nothing to do. */
|
||||
#else
|
||||
int ret;
|
||||
|
||||
if ((ret = pthread_cond_destroy(&cond->cond)))
|
||||
ERR("Failed to destroy the condition variable, ret %d.\n", ret);
|
||||
#endif
|
||||
}
|
||||
|
||||
static inline void vkd3d_parse_version(const char *version, int *major, int *minor)
|
||||
{
|
||||
*major = atoi(version);
|
||||
|
Reference in New Issue
Block a user