aboutsummaryrefslogtreecommitdiffstats
path: root/common/threads.c
diff options
context:
space:
mode:
Diffstat (limited to 'common/threads.c')
-rw-r--r--common/threads.c119
1 files changed, 0 insertions, 119 deletions
diff --git a/common/threads.c b/common/threads.c
index 999bb768..b95cb548 100644
--- a/common/threads.c
+++ b/common/threads.c
@@ -208,12 +208,6 @@ void almtx_destroy(almtx_t *mtx)
DeleteCriticalSection(mtx);
}
-int almtx_timedlock(almtx_t* UNUSED(mtx), const struct timespec* UNUSED(ts))
-{
- /* Windows CRITICAL_SECTIONs don't seem to have a timedlock method. */
- return althrd_error;
-}
-
#if defined(_WIN32_WINNT) && _WIN32_WINNT >= 0x0600
int alcnd_init(alcnd_t *cond)
{
@@ -240,30 +234,6 @@ int alcnd_wait(alcnd_t *cond, almtx_t *mtx)
return althrd_error;
}
-int alcnd_timedwait(alcnd_t *cond, almtx_t *mtx, const struct timespec *time_point)
-{
- struct timespec curtime;
- DWORD sleeptime;
-
- if(altimespec_get(&curtime, AL_TIME_UTC) != AL_TIME_UTC)
- return althrd_error;
-
- if(curtime.tv_sec > time_point->tv_sec || (curtime.tv_sec == time_point->tv_sec &&
- curtime.tv_nsec >= time_point->tv_nsec))
- {
- if(SleepConditionVariableCS(cond, mtx, 0) != 0)
- return althrd_success;
- }
- else
- {
- sleeptime = (time_point->tv_nsec - curtime.tv_nsec + 999999)/1000000;
- sleeptime += (DWORD)(time_point->tv_sec - curtime.tv_sec)*1000;
- if(SleepConditionVariableCS(cond, mtx, sleeptime) != 0)
- return althrd_success;
- }
- return (GetLastError()==ERROR_TIMEOUT) ? althrd_timedout : althrd_error;
-}
-
void alcnd_destroy(alcnd_t* UNUSED(cond))
{
/* Nothing to delete? */
@@ -348,37 +318,6 @@ int alcnd_wait(alcnd_t *cond, almtx_t *mtx)
return althrd_success;
}
-int alcnd_timedwait(alcnd_t *cond, almtx_t *mtx, const struct timespec *time_point)
-{
- _int_alcnd_t *icond = cond->Ptr;
- struct timespec curtime;
- DWORD sleeptime;
- int res;
-
- if(altimespec_get(&curtime, AL_TIME_UTC) != AL_TIME_UTC)
- return althrd_error;
-
- if(curtime.tv_sec > time_point->tv_sec || (curtime.tv_sec == time_point->tv_sec &&
- curtime.tv_nsec >= time_point->tv_nsec))
- sleeptime = 0;
- else
- {
- sleeptime = (time_point->tv_nsec - curtime.tv_nsec + 999999)/1000000;
- sleeptime += (DWORD)(time_point->tv_sec - curtime.tv_sec)*1000;
- }
-
- IncrementRef(&icond->wait_count);
- LeaveCriticalSection(mtx);
-
- res = WaitForMultipleObjects(2, icond->events, FALSE, sleeptime);
-
- if(DecrementRef(&icond->wait_count) == 0 && res == WAIT_OBJECT_0+BROADCAST)
- ResetEvent(icond->events[BROADCAST]);
- EnterCriticalSection(mtx);
-
- return (res == WAIT_TIMEOUT) ? althrd_timedout : althrd_success;
-}
-
void alcnd_destroy(alcnd_t *cond)
{
_int_alcnd_t *icond = cond->Ptr;
@@ -415,29 +354,6 @@ int alsem_wait(alsem_t *sem)
return althrd_error;
}
-int alsem_timedwait(alsem_t *sem, const struct timespec *time_point)
-{
- struct timespec curtime;
- DWORD sleeptime, ret;
-
- if(altimespec_get(&curtime, AL_TIME_UTC) != AL_TIME_UTC)
- return althrd_error;
-
- if(curtime.tv_sec > time_point->tv_sec || (curtime.tv_sec == time_point->tv_sec &&
- curtime.tv_nsec >= time_point->tv_nsec))
- sleeptime = 0;
- else
- {
- sleeptime = (DWORD)(time_point->tv_sec - curtime.tv_sec)*1000;
- sleeptime += (time_point->tv_nsec - curtime.tv_nsec + 999999)/1000000;
- }
-
- ret = WaitForSingleObject(*sem, sleeptime);
- if(ret == WAIT_OBJECT_0) return althrd_success;
- if(ret == WAIT_TIMEOUT) return althrd_timedout;
- return althrd_error;
-}
-
/* An associative map of uint:void* pairs. The key is the TLS index (given by
* TlsAlloc), and the value is the altss_dtor_t callback. When a thread exits,
@@ -654,15 +570,9 @@ int almtx_init(almtx_t *mtx, int type)
int ret;
if(!mtx) return althrd_error;
-#ifdef HAVE_PTHREAD_MUTEX_TIMEDLOCK
- if((type&~(almtx_recursive|almtx_timed)) != 0)
- return althrd_error;
-#else
if((type&~almtx_recursive) != 0)
return althrd_error;
-#endif
- type &= ~almtx_timed;
if(type == almtx_plain)
ret = pthread_mutex_init(mtx, NULL);
else
@@ -694,20 +604,6 @@ void almtx_destroy(almtx_t *mtx)
pthread_mutex_destroy(mtx);
}
-int almtx_timedlock(almtx_t *mtx, const struct timespec *ts)
-{
-#ifdef HAVE_PTHREAD_MUTEX_TIMEDLOCK
- int ret = pthread_mutex_timedlock(mtx, ts);
- switch(ret)
- {
- case 0: return althrd_success;
- case ETIMEDOUT: return althrd_timedout;
- case EBUSY: return althrd_busy;
- }
-#endif
- return althrd_error;
-}
-
int alcnd_init(alcnd_t *cond)
{
if(pthread_cond_init(cond, NULL) == 0)
@@ -736,13 +632,6 @@ int alcnd_wait(alcnd_t *cond, almtx_t *mtx)
return althrd_error;
}
-int alcnd_timedwait(alcnd_t *cond, almtx_t *mtx, const struct timespec *time_point)
-{
- if(pthread_cond_timedwait(cond, mtx, time_point) == 0)
- return althrd_success;
- return althrd_error;
-}
-
void alcnd_destroy(alcnd_t *cond)
{
pthread_cond_destroy(cond);
@@ -775,14 +664,6 @@ int alsem_wait(alsem_t *sem)
return althrd_error;
}
-int alsem_timedwait(alsem_t *sem, const struct timespec *time_point)
-{
- if(sem_timedwait(sem, time_point) == 0) return althrd_success;
- if(errno == ETIMEDOUT) return althrd_timedout;
- if(errno == EINTR) return -2;
- return althrd_error;
-}
-
int altss_create(altss_t *tss_id, altss_dtor_t callback)
{