summaryrefslogtreecommitdiff
path: root/libpthread
diff options
context:
space:
mode:
authorPeter S. Mazinger <ps.m@gmx.net>2011-04-26 23:35:32 +0200
committerBernhard Reutner-Fischer <rep.dot.nop@gmail.com>2012-06-15 14:00:43 +0200
commite7575150911d8ee230d17ab7c03864df24a8be07 (patch)
tree72699cf46eb41dcd1f6448f97a47213634511229 /libpthread
parentd60ef5b6d8b6c8fb1650e351028aa2fbd41488e8 (diff)
linuxthreads.old: remove __old_sem_* and rename __new_sem_* to sem_*
Signed-off-by: Peter S. Mazinger <ps.m@gmx.net> Signed-off-by: Bernhard Reutner-Fischer <rep.dot.nop@gmail.com>
Diffstat (limited to 'libpthread')
-rw-r--r--libpthread/linuxthreads.old/Makefile.in2
-rw-r--r--libpthread/linuxthreads.old/internals.h2
-rw-r--r--libpthread/linuxthreads.old/manager.c2
-rw-r--r--libpthread/linuxthreads.old/oldsemaphore.c241
-rw-r--r--libpthread/linuxthreads.old/semaphore.c29
5 files changed, 10 insertions, 266 deletions
diff --git a/libpthread/linuxthreads.old/Makefile.in b/libpthread/linuxthreads.old/Makefile.in
index f599b1697..7ef621889 100644
--- a/libpthread/linuxthreads.old/Makefile.in
+++ b/libpthread/linuxthreads.old/Makefile.in
@@ -34,7 +34,7 @@ libpthread_OUT := $(top_builddir)libpthread/linuxthreads.old
libpthread_SRC := \
attr.c cancel.c condvar.c errno.c events.c join.c lockfile.c manager.c \
- mutex.c oldsemaphore.c pt-machine.c ptfork.c ptlongjmp.c \
+ mutex.c pt-machine.c ptfork.c ptlongjmp.c \
rwlock.c semaphore.c signals.c specific.c spinlock.c wrapsyscall.c
ifeq ($(UCLIBC_HAS_XLOCALE),y)
libpthread_SRC += locale.c
diff --git a/libpthread/linuxthreads.old/internals.h b/libpthread/linuxthreads.old/internals.h
index 7a230f4e4..1313ec612 100644
--- a/libpthread/linuxthreads.old/internals.h
+++ b/libpthread/linuxthreads.old/internals.h
@@ -511,7 +511,7 @@ extern __typeof(pthread_mutex_unlock) __pthread_mutex_unlock attribute_hidden;
#endif
/* Prototypes for some of the new semaphore functions. */
-extern int __new_sem_post (sem_t * sem);
+/*extern int __new_sem_post (sem_t * sem);*/
/* TSD. */
extern int __pthread_internal_tsd_set (int key, const void * pointer);
diff --git a/libpthread/linuxthreads.old/manager.c b/libpthread/linuxthreads.old/manager.c
index 2a3bc26d7..e4022f8ea 100644
--- a/libpthread/linuxthreads.old/manager.c
+++ b/libpthread/linuxthreads.old/manager.c
@@ -232,7 +232,7 @@ int attribute_noreturn __pthread_manager(void *arg)
break;
case REQ_POST:
PDEBUG("got REQ_POST\n");
- __new_sem_post(request.req_args.post);
+ sem_post(request.req_args.post);
break;
case REQ_DEBUG:
PDEBUG("got REQ_DEBUG\n");
diff --git a/libpthread/linuxthreads.old/oldsemaphore.c b/libpthread/linuxthreads.old/oldsemaphore.c
deleted file mode 100644
index 2a7b40acc..000000000
--- a/libpthread/linuxthreads.old/oldsemaphore.c
+++ /dev/null
@@ -1,241 +0,0 @@
-/*
- * This file contains the old semaphore code that we need to
- * preserve for glibc-2.0 backwards compatibility. Port to glibc 2.1
- * done by Cristian Gafton.
- */
-
-/* Linuxthreads - a simple clone()-based implementation of Posix */
-/* threads for Linux. */
-/* Copyright (C) 1996 Xavier Leroy (Xavier.Leroy@inria.fr) */
-/* */
-/* This program is free software; you can redistribute it and/or */
-/* modify it under the terms of the GNU Library General Public License */
-/* as published by the Free Software Foundation; either version 2 */
-/* of the License, or (at your option) any later version. */
-/* */
-/* This program is distributed in the hope that it will be useful, */
-/* but WITHOUT ANY WARRANTY; without even the implied warranty of */
-/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
-/* GNU Library General Public License for more details. */
-
-/* Semaphores a la POSIX 1003.1b */
-
-#include <errno.h>
-#include "pthread.h"
-#include "internals.h"
-#include "spinlock.h"
-#include "restart.h"
-#include "queue.h"
-
-typedef struct {
- long int sem_status;
- int sem_spinlock;
-} old_sem_t;
-
-/* Maximum value the semaphore can have. */
-#define SEM_VALUE_MAX ((int) ((~0u) >> 1))
-
-static __inline__ int sem_compare_and_swap(old_sem_t *sem, long oldval, long newval)
-{
- return compare_and_swap(&sem->sem_status, oldval, newval, &sem->sem_spinlock);
-}
-
-/* The state of a semaphore is represented by a long int encoding
- either the semaphore count if >= 0 and no thread is waiting on it,
- or the head of the list of threads waiting for the semaphore.
- To distinguish the two cases, we encode the semaphore count N
- as 2N+1, so that it has the lowest bit set.
-
- A sequence of sem_wait operations on a semaphore initialized to N
- result in the following successive states:
- 2N+1, 2N-1, ..., 3, 1, &first_waiting_thread, &second_waiting_thread, ...
-*/
-
-static void sem_restart_list(pthread_descr waiting);
-
-int __old_sem_init(old_sem_t *sem, int pshared, unsigned int value);
-int __old_sem_init(old_sem_t *sem, int pshared, unsigned int value)
-{
- if (value > SEM_VALUE_MAX) {
- errno = EINVAL;
- return -1;
- }
- if (pshared) {
- errno = ENOSYS;
- return -1;
- }
- sem->sem_spinlock = 0;
- sem->sem_status = ((long)value << 1) + 1;
- return 0;
-}
-
-/* Function called by pthread_cancel to remove the thread from
- waiting inside __old_sem_wait. Here we simply unconditionally
- indicate that the thread is to be woken, by returning 1. */
-
-static int old_sem_extricate_func(void *obj attribute_unused, pthread_descr th attribute_unused)
-{
- return 1;
-}
-
-int __old_sem_wait(old_sem_t * sem);
-int __old_sem_wait(old_sem_t * sem)
-{
- long oldstatus, newstatus;
- volatile pthread_descr self = thread_self();
- pthread_descr * th;
- pthread_extricate_if extr;
-
- /* Set up extrication interface */
- extr.pu_object = 0;
- extr.pu_extricate_func = old_sem_extricate_func;
-
- while (1) {
- /* Register extrication interface */
- __pthread_set_own_extricate_if(self, &extr);
- do {
- oldstatus = sem->sem_status;
- if ((oldstatus & 1) && (oldstatus != 1))
- newstatus = oldstatus - 2;
- else {
- newstatus = (long) self;
- self->p_nextwaiting = (pthread_descr) oldstatus;
- }
- }
- while (! sem_compare_and_swap(sem, oldstatus, newstatus));
- if (newstatus & 1) {
- /* We got the semaphore. */
- __pthread_set_own_extricate_if(self, 0);
- return 0;
- }
- /* Wait for sem_post or cancellation */
- suspend(self);
- __pthread_set_own_extricate_if(self, 0);
-
- /* This is a cancellation point */
- if (self->p_canceled && self->p_cancelstate == PTHREAD_CANCEL_ENABLE) {
- /* Remove ourselves from the waiting list if we're still on it */
- /* First check if we're at the head of the list. */
- do {
- oldstatus = sem->sem_status;
- if (oldstatus != (long) self) break;
- newstatus = (long) self->p_nextwaiting;
- }
- while (! sem_compare_and_swap(sem, oldstatus, newstatus));
- /* Now, check if we're somewhere in the list.
- There's a race condition with sem_post here, but it does not matter:
- the net result is that at the time pthread_exit is called,
- self is no longer reachable from sem->sem_status. */
- if (oldstatus != (long) self && (oldstatus & 1) == 0) {
- for (th = &(((pthread_descr) oldstatus)->p_nextwaiting);
- *th != NULL && *th != (pthread_descr) 1;
- th = &((*th)->p_nextwaiting)) {
- if (*th == self) {
- *th = self->p_nextwaiting;
- break;
- }
- }
- }
- __pthread_do_exit(PTHREAD_CANCELED, CURRENT_STACK_FRAME);
- }
- }
-}
-
-int __old_sem_trywait(old_sem_t * sem);
-int __old_sem_trywait(old_sem_t * sem)
-{
- long oldstatus, newstatus;
-
- do {
- oldstatus = sem->sem_status;
- if ((oldstatus & 1) == 0 || (oldstatus == 1)) {
- errno = EAGAIN;
- return -1;
- }
- newstatus = oldstatus - 2;
- }
- while (! sem_compare_and_swap(sem, oldstatus, newstatus));
- return 0;
-}
-
-int __old_sem_post(old_sem_t * sem);
-int __old_sem_post(old_sem_t * sem)
-{
- long oldstatus, newstatus;
-
- do {
- oldstatus = sem->sem_status;
- if ((oldstatus & 1) == 0)
- newstatus = 3;
- else {
- if (oldstatus >= SEM_VALUE_MAX) {
- /* Overflow */
- errno = ERANGE;
- return -1;
- }
- newstatus = oldstatus + 2;
- }
- }
- while (! sem_compare_and_swap(sem, oldstatus, newstatus));
- if ((oldstatus & 1) == 0)
- sem_restart_list((pthread_descr) oldstatus);
- return 0;
-}
-
-int __old_sem_getvalue(old_sem_t * sem, int * sval);
-int __old_sem_getvalue(old_sem_t * sem, int * sval)
-{
- long status = sem->sem_status;
- if (status & 1)
- *sval = (int)((unsigned long) status >> 1);
- else
- *sval = 0;
- return 0;
-}
-
-int __old_sem_destroy(old_sem_t * sem);
-int __old_sem_destroy(old_sem_t * sem)
-{
- if ((sem->sem_status & 1) == 0) {
- errno = EBUSY;
- return -1;
- }
- return 0;
-}
-
-/* Auxiliary function for restarting all threads on a waiting list,
- in priority order. */
-
-static void sem_restart_list(pthread_descr waiting)
-{
- pthread_descr th, towake, *p;
-
- /* Sort list of waiting threads by decreasing priority (insertion sort) */
- towake = NULL;
- while (waiting != (pthread_descr) 1) {
- th = waiting;
- waiting = waiting->p_nextwaiting;
- p = &towake;
- while (*p != NULL && th->p_priority < (*p)->p_priority)
- p = &((*p)->p_nextwaiting);
- th->p_nextwaiting = *p;
- *p = th;
- }
- /* Wake up threads in priority order */
- while (towake != NULL) {
- th = towake;
- towake = towake->p_nextwaiting;
- th->p_nextwaiting = NULL;
- restart(th);
- }
-}
-
-#if defined __PIC__ && defined DO_VERSIONING
-symbol_version (__old_sem_init, sem_init, GLIBC_2.0);
-symbol_version (__old_sem_wait, sem_wait, GLIBC_2.0);
-symbol_version (__old_sem_trywait, sem_trywait, GLIBC_2.0);
-symbol_version (__old_sem_post, sem_post, GLIBC_2.0);
-symbol_version (__old_sem_getvalue, sem_getvalue, GLIBC_2.0);
-symbol_version (__old_sem_destroy, sem_destroy, GLIBC_2.0);
-#endif
-
diff --git a/libpthread/linuxthreads.old/semaphore.c b/libpthread/linuxthreads.old/semaphore.c
index 0811e1707..9025dfee6 100644
--- a/libpthread/linuxthreads.old/semaphore.c
+++ b/libpthread/linuxthreads.old/semaphore.c
@@ -24,8 +24,7 @@
#include "restart.h"
#include "queue.h"
-int __new_sem_init(sem_t *sem, int pshared, unsigned int value);
-int __new_sem_init(sem_t *sem, int pshared, unsigned int value)
+int sem_init(sem_t *sem, int pshared, unsigned int value)
{
if (value > SEM_VALUE_MAX) {
errno = EINVAL;
@@ -42,7 +41,7 @@ int __new_sem_init(sem_t *sem, int pshared, unsigned int value)
}
/* Function called by pthread_cancel to remove the thread from
- waiting inside __new_sem_wait. */
+ waiting inside sem_wait. */
static int new_sem_extricate_func(void *obj, pthread_descr th)
{
@@ -57,8 +56,7 @@ static int new_sem_extricate_func(void *obj, pthread_descr th)
return did_remove;
}
-int __new_sem_wait(sem_t * sem);
-int __new_sem_wait(sem_t * sem)
+int sem_wait(sem_t * sem)
{
volatile pthread_descr self = thread_self();
pthread_extricate_if extr;
@@ -120,8 +118,7 @@ int __new_sem_wait(sem_t * sem)
return 0;
}
-int __new_sem_trywait(sem_t * sem);
-int __new_sem_trywait(sem_t * sem)
+int sem_trywait(sem_t * sem)
{
int retval;
@@ -137,8 +134,7 @@ int __new_sem_trywait(sem_t * sem)
return retval;
}
-int __new_sem_post(sem_t * sem);
-int __new_sem_post(sem_t * sem)
+int sem_post(sem_t * sem)
{
pthread_descr self = thread_self();
pthread_descr th;
@@ -179,15 +175,13 @@ int __new_sem_post(sem_t * sem)
return 0;
}
-int __new_sem_getvalue(sem_t * sem, int * sval);
-int __new_sem_getvalue(sem_t * sem, int * sval)
+int sem_getvalue(sem_t * sem, int * sval)
{
*sval = sem->__sem_value;
return 0;
}
-int __new_sem_destroy(sem_t * sem);
-int __new_sem_destroy(sem_t * sem)
+int sem_destroy(sem_t * sem)
{
if (sem->__sem_waiting != NULL) {
__set_errno (EBUSY);
@@ -303,12 +297,3 @@ int sem_timedwait(sem_t *sem, const struct timespec *abstime)
/* We got the semaphore */
return 0;
}
-
-
-weak_alias (__new_sem_init, sem_init)
-weak_alias (__new_sem_wait, sem_wait)
-weak_alias (__new_sem_trywait, sem_trywait)
-weak_alias (__new_sem_post, sem_post)
-weak_alias (__new_sem_getvalue, sem_getvalue)
-weak_alias (__new_sem_destroy, sem_destroy)
-