aboutsummaryrefslogtreecommitdiffstats
path: root/common
diff options
context:
space:
mode:
authorChris Robinson <[email protected]>2018-02-01 22:24:17 -0800
committerChris Robinson <[email protected]>2018-02-01 22:24:17 -0800
commita114d6cbb56470db87c2b0bd7c76ce26bdaeb63c (patch)
tree743679fd83e38abdcb9d08f91e026f169b789099 /common
parent3acd2a55addecf646475bbf45aed03927c7d84e6 (diff)
Remove unused _timed methods
They're not reliably implemented anyway, as some systems will just flat out fail when trying to use them.
Diffstat (limited to 'common')
-rw-r--r--common/threads.c119
-rw-r--r--common/threads.h4
2 files changed, 0 insertions, 123 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)
{
diff --git a/common/threads.h b/common/threads.h
index a8096546..ffd7fac5 100644
--- a/common/threads.h
+++ b/common/threads.h
@@ -28,7 +28,6 @@ enum {
enum {
almtx_plain = 0,
almtx_recursive = 1,
- almtx_timed = 2
};
typedef int (*althrd_start_t)(void*);
@@ -227,20 +226,17 @@ void althrd_setname(althrd_t thr, const char *name);
int almtx_init(almtx_t *mtx, int type);
void almtx_destroy(almtx_t *mtx);
-int almtx_timedlock(almtx_t *mtx, const struct timespec *ts);
int alcnd_init(alcnd_t *cond);
int alcnd_signal(alcnd_t *cond);
int alcnd_broadcast(alcnd_t *cond);
int alcnd_wait(alcnd_t *cond, almtx_t *mtx);
-int alcnd_timedwait(alcnd_t *cond, almtx_t *mtx, const struct timespec *time_point);
void alcnd_destroy(alcnd_t *cond);
int alsem_init(alsem_t *sem, unsigned int initial);
void alsem_destroy(alsem_t *sem);
int alsem_post(alsem_t *sem);
int alsem_wait(alsem_t *sem);
-int alsem_timedwait(alsem_t *sem, const struct timespec *time_point);
int altss_create(altss_t *tss_id, altss_dtor_t callback);
void altss_delete(altss_t tss_id);