[_DECTHREADS_] Drop support for DECthreads d4, a.k.a. DCE threads,
which are obsolete since at least 1997. (empth_terminate, empth_wakeup) [__ppc__]: Ancient versions of OS X lacked pthread_kill(). As a work-around, its use was disabled here for all versions of OS X. The work-around could lead to hangs. Remove it and drop support for ancient versions of OS X. (empth_create) [__linux__]: Linux has supported thread attribute stacksize for ages. Remove the special case. (_MIT_POSIX_THREADS): Unused, remove.
This commit is contained in:
parent
bf61ce9f38
commit
59c15ea9d4
2 changed files with 0 additions and 68 deletions
|
@ -80,9 +80,6 @@ typedef struct lwpSem empth_sem_t;
|
||||||
#endif /* _EMPTH_LWP */
|
#endif /* _EMPTH_LWP */
|
||||||
|
|
||||||
#ifdef _EMPTH_POSIX
|
#ifdef _EMPTH_POSIX
|
||||||
#ifdef __linux__
|
|
||||||
#define _MIT_POSIX_THREADS 1
|
|
||||||
#endif
|
|
||||||
#include <pthread.h>
|
#include <pthread.h>
|
||||||
#define EMPTH_FD_READ 0x1
|
#define EMPTH_FD_READ 0x1
|
||||||
#define EMPTH_FD_WRITE 0x2
|
#define EMPTH_FD_WRITE 0x2
|
||||||
|
@ -110,15 +107,6 @@ typedef struct {
|
||||||
|
|
||||||
#endif /* _EMPTH_POSIX */
|
#endif /* _EMPTH_POSIX */
|
||||||
|
|
||||||
/* DEC has slightly different names for whatever reason... */
|
|
||||||
#ifdef _DECTHREADS_
|
|
||||||
#define pthread_key_create pthread_keycreate
|
|
||||||
#define pthread_attr_init pthread_attr_create
|
|
||||||
#define pthread_attr_destroy pthread_attr_delete
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
#if defined(_EMPTH_WIN32)
|
#if defined(_EMPTH_WIN32)
|
||||||
/* The Windows NT Threads */
|
/* The Windows NT Threads */
|
||||||
#define EMPTH_FD_READ 0x1
|
#define EMPTH_FD_READ 0x1
|
||||||
|
|
|
@ -128,11 +128,7 @@ empth_init(void **ctx_ptr, int flags)
|
||||||
|
|
||||||
|
|
||||||
pthread_key_create(&ctx_key, 0);
|
pthread_key_create(&ctx_key, 0);
|
||||||
#ifdef _DECTHREADS_
|
|
||||||
pthread_mutex_init(&mtx_ctxsw, pthread_mutexattr_default);
|
|
||||||
#else
|
|
||||||
pthread_mutex_init(&mtx_ctxsw, 0);
|
pthread_mutex_init(&mtx_ctxsw, 0);
|
||||||
#endif
|
|
||||||
|
|
||||||
act.sa_flags = 0;
|
act.sa_flags = 0;
|
||||||
sigemptyset(&act.sa_mask);
|
sigemptyset(&act.sa_mask);
|
||||||
|
@ -188,37 +184,18 @@ empth_create(int prio, void (*entry)(void *), int size, int flags,
|
||||||
ctx->state = 0;
|
ctx->state = 0;
|
||||||
ctx->ep = entry;
|
ctx->ep = entry;
|
||||||
|
|
||||||
#ifdef _DECTHREADS_
|
|
||||||
eno = pthread_attr_init(&attr) ? errno : 0;
|
|
||||||
#else
|
|
||||||
eno = pthread_attr_init(&attr);
|
eno = pthread_attr_init(&attr);
|
||||||
#endif
|
|
||||||
if (eno) {
|
if (eno) {
|
||||||
logerror("can not create thread attribute %s (%s): %s", name, desc,
|
logerror("can not create thread attribute %s (%s): %s", name, desc,
|
||||||
strerror(eno));
|
strerror(eno));
|
||||||
goto bad;
|
goto bad;
|
||||||
}
|
}
|
||||||
#if defined(__linux__)
|
|
||||||
/* Linux doesn't let you adjust the stack */
|
|
||||||
#elif defined(_DECTHREADS_)
|
|
||||||
/* DEC does not have PTHREAD_STACK_MIN constant */
|
|
||||||
/* Do not go below default size */
|
|
||||||
if (size > pthread_attr_getstacksize(attr))
|
|
||||||
pthread_attr_setstacksize(&attr, size);
|
|
||||||
#else
|
|
||||||
if (size < PTHREAD_STACK_MIN)
|
if (size < PTHREAD_STACK_MIN)
|
||||||
size = PTHREAD_STACK_MIN + 1;
|
size = PTHREAD_STACK_MIN + 1;
|
||||||
|
|
||||||
pthread_attr_setstacksize(&attr, size);
|
pthread_attr_setstacksize(&attr, size);
|
||||||
#endif
|
|
||||||
|
|
||||||
pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED);
|
pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED);
|
||||||
|
|
||||||
#ifdef _DECTHREADS_
|
|
||||||
eno = pthread_create(&t, attr, empth_start, ctx) ? errno : 0;
|
|
||||||
#else
|
|
||||||
eno = pthread_create(&t, &attr, empth_start, ctx);
|
eno = pthread_create(&t, &attr, empth_start, ctx);
|
||||||
#endif
|
|
||||||
if (eno) {
|
if (eno) {
|
||||||
logerror("can not create thread: %s (%s): %s", name, desc,
|
logerror("can not create thread: %s (%s): %s", name, desc,
|
||||||
strerror(eno));
|
strerror(eno));
|
||||||
|
@ -239,11 +216,7 @@ empth_restorectx(void)
|
||||||
{
|
{
|
||||||
empth_t *ctx_ptr;
|
empth_t *ctx_ptr;
|
||||||
|
|
||||||
#ifdef _DECTHREADS_
|
|
||||||
pthread_getspecific(ctx_key, (pthread_addr_t *) & ctx_ptr);
|
|
||||||
#else
|
|
||||||
ctx_ptr = (empth_t *)pthread_getspecific(ctx_key);
|
ctx_ptr = (empth_t *)pthread_getspecific(ctx_key);
|
||||||
#endif
|
|
||||||
*udata = ctx_ptr->ud;
|
*udata = ctx_ptr->ud;
|
||||||
if (ctx_ptr->state == EMPTH_KILLED) {
|
if (ctx_ptr->state == EMPTH_KILLED) {
|
||||||
empth_status("i am dead");
|
empth_status("i am dead");
|
||||||
|
@ -255,14 +228,7 @@ empth_restorectx(void)
|
||||||
empth_t *
|
empth_t *
|
||||||
empth_self(void)
|
empth_self(void)
|
||||||
{
|
{
|
||||||
#ifdef _DECTHREADS_
|
|
||||||
empth_t *ctx_ptr;
|
|
||||||
|
|
||||||
pthread_getspecific(ctx_key, (pthread_addr_t *) & ctx_ptr);
|
|
||||||
return ctx_ptr;
|
|
||||||
#else
|
|
||||||
return (empth_t *)pthread_getspecific(ctx_key);
|
return (empth_t *)pthread_getspecific(ctx_key);
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
@ -272,18 +238,11 @@ empth_exit(void)
|
||||||
|
|
||||||
pthread_mutex_unlock(&mtx_ctxsw);
|
pthread_mutex_unlock(&mtx_ctxsw);
|
||||||
empth_status("empth_exit");
|
empth_status("empth_exit");
|
||||||
#ifdef _DECTHREADS_
|
|
||||||
pthread_getspecific(ctx_key, (pthread_addr_t *) & ctx_ptr);
|
|
||||||
#else
|
|
||||||
ctx_ptr = (empth_t *)pthread_getspecific(ctx_key);
|
ctx_ptr = (empth_t *)pthread_getspecific(ctx_key);
|
||||||
#endif
|
|
||||||
/* We want to leave the main thread around forever, until it's time
|
/* We want to leave the main thread around forever, until it's time
|
||||||
for it to die for real (in a shutdown) */
|
for it to die for real (in a shutdown) */
|
||||||
if (!strcmp(ctx_ptr->name, "Main")) {
|
if (!strcmp(ctx_ptr->name, "Main")) {
|
||||||
while (1) {
|
while (1) {
|
||||||
#ifdef _DECTHREADS_
|
|
||||||
pthread_yield();
|
|
||||||
#endif
|
|
||||||
sleep(60);
|
sleep(60);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -308,12 +267,7 @@ empth_terminate(empth_t *a)
|
||||||
__FILE__, __LINE__); */
|
__FILE__, __LINE__); */
|
||||||
empth_status("killing thread %s", a->name);
|
empth_status("killing thread %s", a->name);
|
||||||
a->state = EMPTH_KILLED;
|
a->state = EMPTH_KILLED;
|
||||||
#ifndef _DECTHREADS_
|
|
||||||
/* DEC and OSX do not have pthread_kill. Not sure that cancel is correct. */
|
|
||||||
#if (!defined __ppc__)
|
|
||||||
pthread_kill(a->id, SIGALRM);
|
pthread_kill(a->id, SIGALRM);
|
||||||
#endif
|
|
||||||
#endif
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -397,11 +351,7 @@ void
|
||||||
empth_wakeup(empth_t *a)
|
empth_wakeup(empth_t *a)
|
||||||
{
|
{
|
||||||
empth_status("waking up thread %s", a->name);
|
empth_status("waking up thread %s", a->name);
|
||||||
#ifndef _DECTHREADS_
|
|
||||||
#if (!defined __ppc__)
|
|
||||||
pthread_kill(a->id, SIGALRM);
|
pthread_kill(a->id, SIGALRM);
|
||||||
#endif
|
|
||||||
#endif
|
|
||||||
empth_status("waiting for it to run");
|
empth_status("waiting for it to run");
|
||||||
/* empth_yield(); */
|
/* empth_yield(); */
|
||||||
}
|
}
|
||||||
|
@ -436,15 +386,9 @@ empth_sem_create(char *name, int cnt)
|
||||||
}
|
}
|
||||||
strncpy(sm->name, name, sizeof(sm->name) - 1);
|
strncpy(sm->name, name, sizeof(sm->name) - 1);
|
||||||
sm->count = cnt;
|
sm->count = cnt;
|
||||||
#ifdef _DECTHREADS_
|
|
||||||
pthread_mutex_init(&sm->mtx_update, pthread_mutexattr_default);
|
|
||||||
pthread_mutex_init(&sm->mtx_sem, pthread_mutexattr_default);
|
|
||||||
pthread_cond_init(&sm->cnd_sem, pthread_condattr_default);
|
|
||||||
#else
|
|
||||||
pthread_mutex_init(&sm->mtx_update, 0);
|
pthread_mutex_init(&sm->mtx_update, 0);
|
||||||
pthread_mutex_init(&sm->mtx_sem, 0);
|
pthread_mutex_init(&sm->mtx_sem, 0);
|
||||||
pthread_cond_init(&sm->cnd_sem, 0);
|
pthread_cond_init(&sm->cnd_sem, 0);
|
||||||
#endif
|
|
||||||
return sm;
|
return sm;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue