aboutsummaryrefslogtreecommitdiffstats
path: root/common
diff options
context:
space:
mode:
authorChris Robinson <[email protected]>2018-11-26 21:19:20 -0800
committerChris Robinson <[email protected]>2018-11-26 21:39:31 -0800
commitb108d0acfd062756da69074242e24ea7b2856b8a (patch)
tree40a573fbefeb77310f375ace284bc847b4014973 /common
parent7860a11ae2723d744eb35eae9bbbc6f9a55e9caa (diff)
Remove the last remaining uses of althrd_t
Diffstat (limited to 'common')
-rw-r--r--common/threads.cpp85
-rw-r--r--common/threads.h7
2 files changed, 0 insertions, 92 deletions
diff --git a/common/threads.cpp b/common/threads.cpp
index 86fbb7b5..489e5f5b 100644
--- a/common/threads.cpp
+++ b/common/threads.cpp
@@ -158,91 +158,6 @@ void althrd_setname(const char *name)
}
-typedef struct thread_cntr {
- althrd_start_t func;
- void *arg;
-} thread_cntr;
-
-static void *althrd_starter(void *arg)
-{
- thread_cntr cntr;
- memcpy(&cntr, arg, sizeof(cntr));
- free(arg);
-
- return (void*)(intptr_t)((*cntr.func)(cntr.arg));
-}
-
-
-int althrd_create(althrd_t *thr, althrd_start_t func, void *arg)
-{
- thread_cntr *cntr;
- pthread_attr_t attr;
- size_t stackmult = 1;
- int err;
-
- cntr = static_cast<thread_cntr*>(malloc(sizeof(*cntr)));
- if(!cntr) return althrd_nomem;
-
- if(pthread_attr_init(&attr) != 0)
- {
- free(cntr);
- return althrd_error;
- }
-retry_stacksize:
- if(pthread_attr_setstacksize(&attr, THREAD_STACK_SIZE*stackmult) != 0)
- {
- pthread_attr_destroy(&attr);
- free(cntr);
- return althrd_error;
- }
-
- cntr->func = func;
- cntr->arg = arg;
- if((err=pthread_create(thr, &attr, althrd_starter, cntr)) == 0)
- {
- pthread_attr_destroy(&attr);
- return althrd_success;
- }
-
- if(err == EINVAL)
- {
- /* If an invalid stack size, try increasing it (limit x4, 8MB). */
- if(stackmult < 4)
- {
- stackmult *= 2;
- goto retry_stacksize;
- }
- /* If still nothing, try defaults and hope they're good enough. */
- if(pthread_create(thr, NULL, althrd_starter, cntr) == 0)
- {
- pthread_attr_destroy(&attr);
- return althrd_success;
- }
- }
- pthread_attr_destroy(&attr);
- free(cntr);
- return althrd_error;
-}
-
-int althrd_detach(althrd_t thr)
-{
- if(pthread_detach(thr) != 0)
- return althrd_error;
- return althrd_success;
-}
-
-int althrd_join(althrd_t thr, int *res)
-{
- void *code;
-
- if(pthread_join(thr, &code) != 0)
- return althrd_error;
- if(res != NULL)
- *res = (int)(intptr_t)code;
- return althrd_success;
-}
-
-
int almtx_init(almtx_t *mtx, int type)
{
int ret;
diff --git a/common/threads.h b/common/threads.h
index a5f6ce45..53b56147 100644
--- a/common/threads.h
+++ b/common/threads.h
@@ -70,7 +70,6 @@ inline int almtx_unlock(almtx_t *mtx)
#include <semaphore.h>
#endif /* __APPLE__ */
-typedef pthread_t althrd_t;
typedef pthread_mutex_t almtx_t;
#ifdef __APPLE__
typedef dispatch_semaphore_t alsem_t;
@@ -78,8 +77,6 @@ typedef dispatch_semaphore_t alsem_t;
typedef sem_t alsem_t;
#endif /* __APPLE__ */
-typedef int (*althrd_start_t)(void*);
-
inline void althrd_yield(void)
{
@@ -101,10 +98,6 @@ inline int almtx_unlock(almtx_t *mtx)
return althrd_success;
}
-int althrd_create(althrd_t *thr, althrd_start_t func, void *arg);
-int althrd_detach(althrd_t thr);
-int althrd_join(althrd_t thr, int *res);
-
#endif
void althrd_setname(const char *name);