Remove compat support from mthread

This commit is contained in:
2017-11-26 11:26:22 +00:00
parent ae9be57160
commit 09f6dfc808
10 changed files with 0 additions and 292 deletions

View File

@@ -143,97 +143,4 @@ int mthread_yield(void);
void mthread_yield_all(void);
__END_DECLS
#if defined(_MTHREADIFY_PTHREADS)
typedef mthread_thread_t pthread_t;
typedef mthread_once_t pthread_once_t;
typedef mthread_key_t pthread_key_t;
typedef mthread_cond_t pthread_cond_t;
typedef mthread_mutex_t pthread_mutex_t;
typedef mthread_condattr_t pthread_condattr_t;
typedef mthread_mutexattr_t pthread_mutexattr_t;
typedef mthread_attr_t pthread_attr_t;
typedef mthread_event_t pthread_event_t;
typedef mthread_rwlock_t pthread_rwlock_t;
/* LSC: No equivalent, so void* for now. */
typedef void *pthread_rwlockattr_t;
#define PTHREAD_ONCE_INIT 0
#define PTHREAD_MUTEX_INITIALIZER ((pthread_mutex_t) -1)
#define PTHREAD_COND_INITIALIZER ((pthread_cond_t) -1)
__BEGIN_DECLS
/* allocate.c */
int pthread_create(pthread_t *thread, pthread_attr_t *tattr, void
*(*proc)(void *), void *arg);
int pthread_detach(pthread_t thread);
int pthread_equal(pthread_t l, pthread_t r);
void pthread_exit(void *value);
int pthread_join(pthread_t thread, void **value);
int pthread_once(pthread_once_t *once, void (*proc)(void));
pthread_t pthread_self(void);
/* attribute.c */
int pthread_attr_destroy(pthread_attr_t *tattr);
int pthread_attr_getdetachstate(pthread_attr_t *tattr, int
*detachstate);
int pthread_attr_getstack(pthread_attr_t *tattr, void **stackaddr,
size_t *stacksize);
int pthread_attr_getstacksize(pthread_attr_t *tattr, size_t *stacksize);
int pthread_attr_init(pthread_attr_t *tattr);
int pthread_attr_setdetachstate(pthread_attr_t *tattr, int detachstate);
int pthread_attr_setstack(pthread_attr_t *tattr, void *stackaddr, size_t
stacksize);
int pthread_attr_setstacksize(pthread_attr_t *tattr, size_t stacksize);
/* condition.c */
int pthread_cond_broadcast(pthread_cond_t *cond);
int pthread_cond_destroy(pthread_cond_t *cond);
int pthread_cond_init(pthread_cond_t *cond, pthread_condattr_t *cattr);
int pthread_cond_signal(pthread_cond_t *cond);
int pthread_cond_wait(pthread_cond_t *cond, pthread_mutex_t *mutex);
/* key.c */
int pthread_key_create(pthread_key_t *key, void (*destructor)(void *));
int pthread_key_delete(pthread_key_t key);
void *pthread_getspecific(pthread_key_t key);
int pthread_setspecific(pthread_key_t key, void *value);
/* mutex.c */
int pthread_mutex_destroy(pthread_mutex_t *mutex);
int pthread_mutex_init(pthread_mutex_t *mutex, pthread_mutexattr_t
*mattr);
int pthread_mutex_lock(pthread_mutex_t *mutex);
int pthread_mutex_trylock(pthread_mutex_t *mutex);
int pthread_mutex_unlock(pthread_mutex_t *mutex);
/* event.c */
int pthread_event_destroy(pthread_event_t *event);
int pthread_event_init(pthread_event_t *event);
int pthread_event_wait(pthread_event_t *event);
int pthread_event_fire(pthread_event_t *event);
int pthread_event_fire_all(pthread_event_t *event);
/* rwlock.c */
int pthread_rwlock_destroy(pthread_rwlock_t *rwlock);
int pthread_rwlock_init(pthread_rwlock_t *rwlock,
pthread_rwlockattr_t *UNUSED(attr));
int pthread_rwlock_rdlock(pthread_rwlock_t *rwlock);
int pthread_rwlock_wrlock(pthread_rwlock_t *rwlock);
int pthread_rwlock_unlock(pthread_rwlock_t *rwlock);
/* schedule.c */
int pthread_yield(void);
int sched_yield(void);
void pthread_yield_all(void);
/* LSC: FIXME: Maybe we should really do something with those... */
#define pthread_mutexattr_init(u) (0)
#define pthread_mutexattr_destroy(u) (0)
#define PTHREAD_MUTEX_RECURSIVE 0
#define pthread_mutexattr_settype(x, y) (EINVAL)
__END_DECLS
#endif /* defined(_MTHREADIFY_PTHREADS) */
#endif

View File

@@ -10,7 +10,6 @@ SRCS= \
key.c \
misc.c \
mutex.c \
pthread_compat.c \
queue.c \
rwlock.c \
scheduler.c \

View File

@@ -538,13 +538,3 @@ static void mthread_trampoline(void)
r = (tcb->m_proc)(tcb->m_arg);
mthread_exit(r);
}
/* pthread compatibility layer. */
__weak_alias(pthread_create, mthread_create)
__weak_alias(pthread_detach, mthread_detach)
__weak_alias(pthread_equal, mthread_equal)
__weak_alias(pthread_exit, mthread_exit)
__weak_alias(pthread_join, mthread_join)
__weak_alias(pthread_once, mthread_once)
__weak_alias(pthread_self, mthread_self)

View File

@@ -299,14 +299,3 @@ int mthread_attr_verify(void)
return(1);
}
#endif
/* pthread compatibility layer. */
__weak_alias(pthread_attr_destroy, mthread_attr_destroy)
__weak_alias(pthread_attr_getdetachstate, mthread_attr_getdetachstate)
__weak_alias(pthread_attr_getstack, mthread_attr_getstack)
__weak_alias(pthread_attr_getstacksize, mthread_attr_getstacksize)
__weak_alias(pthread_attr_init, mthread_attr_init)
__weak_alias(pthread_attr_setdetachstate, mthread_attr_setdetachstate)
__weak_alias(pthread_attr_setstack, mthread_attr_setstack)
__weak_alias(pthread_attr_setstacksize, mthread_attr_setstacksize)

View File

@@ -269,7 +269,3 @@ mthread_mutex_t *mutex;
return(0);
}
/* pthread compatibility layer. */
__weak_alias(pthread_cond_init, mthread_cond_init)

View File

@@ -124,11 +124,3 @@ mthread_event_t *event; /* The event to be fired */
return mthread_mutex_unlock(&event->mutex);
}
/* pthread compatibility layer. */
__weak_alias(pthread_event_destroy, mthread_event_destroy)
__weak_alias(pthread_event_init, mthread_event_init)
__weak_alias(pthread_event_wait, mthread_event_wait)
__weak_alias(pthread_event_fire, mthread_event_fire)
__weak_alias(pthread_event_fire_all, mthread_event_fire_all)

View File

@@ -181,10 +181,3 @@ void mthread_cleanup_values(void)
}
} while (found);
}
/* pthread compatibility layer. */
__weak_alias(pthread_key_create, mthread_key_create)
__weak_alias(pthread_key_delete, mthread_key_delete)
__weak_alias(pthread_getspecific, mthread_getspecific)
__weak_alias(pthread_setspecific, mthread_setspecific)

View File

@@ -1,145 +0,0 @@
#define _MTHREADIFY_PTHREADS
#include <minix/mthread.h>
#include "global.h"
#include "proto.h"
/* WARNING:
* The following works under the hypothesis that we have only green threads,
* which implies that we have no preemption, unless explicit yield or possible
* calls done to mthread functions.
*
* This has impact on the fact we do not maintain a table of currently being
* initialized mutexes or condition variables, to prevent double initialization
* and/or TOCTU problems. TOCTU could appear between the test against the
* initializer value, and the actual initialization, which could lead to double
* initialization of the same mutex AND get two threads at the same time in the
* critical section as they both hold a (different) mutex.
*/
/*===========================================================================*
* pthread_mutex_init *
*===========================================================================*/
int pthread_mutex_init(pthread_mutex_t *mutex, pthread_mutexattr_t *mattr)
{
return mthread_mutex_init(mutex, mattr);
}
/*===========================================================================*
* pthread_mutex_destroy *
*===========================================================================*/
int pthread_mutex_destroy(pthread_mutex_t *mutex)
{
if (PTHREAD_MUTEX_INITIALIZER == *mutex) {
*mutex = NULL;
return 0;
}
return mthread_mutex_destroy(mutex);
}
/*===========================================================================*
* pthread_mutex_lock *
*===========================================================================*/
int pthread_mutex_lock(pthread_mutex_t *mutex)
{
if (PTHREAD_MUTEX_INITIALIZER == *mutex) {
mthread_mutex_init(mutex, NULL);
}
return mthread_mutex_lock(mutex);
}
/*===========================================================================*
* pthread_mutex_trylock *
*===========================================================================*/
int pthread_mutex_trylock(pthread_mutex_t *mutex)
{
if (PTHREAD_MUTEX_INITIALIZER == *mutex) {
mthread_mutex_init(mutex, NULL);
}
return pthread_mutex_trylock(mutex);
}
/*===========================================================================*
* pthread_mutex_unlock *
*===========================================================================*/
int pthread_mutex_unlock(pthread_mutex_t *mutex)
{
if (PTHREAD_MUTEX_INITIALIZER == *mutex) {
mthread_mutex_init(mutex, NULL);
}
return mthread_mutex_unlock(mutex);
}
/*===========================================================================*
* pthread_cond_init *
*===========================================================================*/
int pthread_cond_init(pthread_cond_t *cond, pthread_condattr_t *cattr)
{
return mthread_cond_init(cond, cattr);
}
/*===========================================================================*
* pthread_cond_broadcast *
*===========================================================================*/
int pthread_cond_broadcast(pthread_cond_t *cond)
{
if (PTHREAD_COND_INITIALIZER == *cond) {
mthread_cond_init(cond, NULL);
}
return mthread_cond_broadcast(cond);
}
/*===========================================================================*
* pthread_cond_destroy *
*===========================================================================*/
int pthread_cond_destroy(pthread_cond_t *cond)
{
if (PTHREAD_COND_INITIALIZER == *cond) {
*cond = NULL;
return 0;
}
return mthread_cond_destroy(cond);
}
/*===========================================================================*
* pthread_cond_signal *
*===========================================================================*/
int pthread_cond_signal(pthread_cond_t *cond)
{
if (PTHREAD_COND_INITIALIZER == *cond) {
mthread_cond_init(cond, NULL);
}
return mthread_cond_signal(cond);
}
/*===========================================================================*
* pthread_cond_wait *
*===========================================================================*/
int pthread_cond_wait(pthread_cond_t *cond, pthread_mutex_t *mutex)
{
if (PTHREAD_COND_INITIALIZER == *cond) {
mthread_cond_init(cond, NULL);
}
return mthread_cond_wait(cond, mutex);
}
/*===========================================================================*
* pthread_rwlock_init *
*===========================================================================*/
int pthread_rwlock_init(pthread_rwlock_t *rwlock, pthread_rwlockattr_t *UNUSED(attr))
{
return mthread_rwlock_init(rwlock);
}
#if !defined(__weak_alias)
#error __weak_alias is required to compile the pthread compat library
#endif

View File

@@ -128,10 +128,3 @@ mthread_rwlock_t *rwlock; /* The rwlock to be unlocked */
return r;
}
/* pthread compatibility layer. */
__weak_alias(pthread_rwlock_destroy, mthread_rwlock_destroy)
__weak_alias(pthread_rwlock_rdlock, mthread_rwlock_rdlock)
__weak_alias(pthread_rwlock_wrlock, mthread_rwlock_wrlock)
__weak_alias(pthread_rwlock_unlock, mthread_rwlock_unlock)

View File

@@ -207,9 +207,3 @@ void mthread_yield_all(void)
/* Done yielding all threads. */
yield_all = 0;
}
/* pthread compatibility layer. */
__weak_alias(pthread_yield, mthread_yield)
__weak_alias(sched_yield, mthread_yield)
__weak_alias(pthread_yield_all, mthread_yield_all)