summaryrefslogtreecommitdiff
path: root/mit-pthreads/lib/libpthreadutil
diff options
context:
space:
mode:
Diffstat (limited to 'mit-pthreads/lib/libpthreadutil')
-rw-r--r--mit-pthreads/lib/libpthreadutil/.cvsignore1
-rwxr-xr-xmit-pthreads/lib/libpthreadutil/Makefile.in65
-rwxr-xr-xmit-pthreads/lib/libpthreadutil/pthread_atexit.c135
-rwxr-xr-xmit-pthreads/lib/libpthreadutil/pthread_tad.c170
-rwxr-xr-xmit-pthreads/lib/libpthreadutil/pthreadutil.h75
5 files changed, 0 insertions, 446 deletions
diff --git a/mit-pthreads/lib/libpthreadutil/.cvsignore b/mit-pthreads/lib/libpthreadutil/.cvsignore
deleted file mode 100644
index f3c7a7c5da6..00000000000
--- a/mit-pthreads/lib/libpthreadutil/.cvsignore
+++ /dev/null
@@ -1 +0,0 @@
-Makefile
diff --git a/mit-pthreads/lib/libpthreadutil/Makefile.in b/mit-pthreads/lib/libpthreadutil/Makefile.in
deleted file mode 100755
index 94034f426b3..00000000000
--- a/mit-pthreads/lib/libpthreadutil/Makefile.in
+++ /dev/null
@@ -1,65 +0,0 @@
-# === makefile ============================================================
-# Copyright (c) 1993 Chris Provenzano, proven@athena.mit.edu
-#
-# Description: This file is for creating the test programs for libpthread.a
-#
-# 1.00 93/08/03 proven
-# -Initial cut for pthreads.
-#
-
-srctop = @srctop@
-srcdir = @srctop@/lib/libpthreadutil
-VPATH = @srctop@/lib/libpthreadutil
-prefix= @prefix@
-exec_prefix= @exec_prefix@
-
-INSTALL_PATH = @exec_prefix@
- BINDIR = $(INSTALL_PATH)/bin
- LIBDIR = $(INSTALL_PATH)/lib
- MANDIR = $(INSTALL_PATH)/man
- INCDIR = $(INSTALL_PATH)/include
-
- CC = ../../pgcc -notinstalled
- CDEBUGFLAGS = @CFLAGS@
- CFLAGS = $(CDEBUGFLAGS) $(INCLUDES) $(ADDL_CFLAGS) -DSRCDIR=\"$(srcdir)\"
- RANLIB = @RANLIB@
-
- OBJS = pthread_tad.o pthread_atexit.o
- LIBRARY = libpthreadutil.a
- HEADERS = pthreadutil.h
-
-################################################################################
-#
-all : $(LIBRARY)
-
-clean:
- rm -f *.o $(TESTS) $(BENCHMARKS) a.out core maketmp makeout
-
-depend:
- sed '/\#\#\# Dependencies/q' < Makefile > maketmp
- (for i in $(CSRC);do $(CPP) -M $$i;done) >> maketmp
- cp maketmp Makefile
-
-install: $(LIBRARY)
- install $(LIBRARY) $(LIBDIR)
- for x in $(HEADERS); \
- do cp $(srcdir)/$$x $(INCDIR); \
- done
-
-realclean: clean
- rm -f Makefile
-
-Makefile: Makefile.in
- (cd ../.. ; sh config.status)
-
-.c.o:
- $(CC) $(CFLAGS) -c $<
-
-$(LIBRARY) : ${OBJS}
- ar r new.a ${OBJS} && \
- $(RANLIB) new.a && \
- mv -f new.a $(LIBRARY)
-
-################################################################################
-### Do not remove the following line. It is for depend #########################
-### Dependencies:
diff --git a/mit-pthreads/lib/libpthreadutil/pthread_atexit.c b/mit-pthreads/lib/libpthreadutil/pthread_atexit.c
deleted file mode 100755
index f244fbfb0c8..00000000000
--- a/mit-pthreads/lib/libpthreadutil/pthread_atexit.c
+++ /dev/null
@@ -1,135 +0,0 @@
-/* ==== pthread_atexit.c =====================================================
- * Copyright (c) 1994 by Chris Provenzano, proven@mit.edu
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. All advertising materials mentioning features or use of this software
- * must display the following acknowledgement:
- * This product includes software developed by Chris Provenzano.
- * 4. The name of Chris Provenzano may not be used to endorse or promote
- * products derived from this software without specific prior written
- * permission.
- *
- * THIS SOFTWARE IS PROVIDED BY CHRIS PROVENZANO ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL CHRIS PROVENZANO BE LIABLE FOR ANY
- * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
- * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
- * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- *
- * Description : Pthread attribute functions.
- *
- * 1.20 94/02/13 proven
- * -Started coding this file.
- */
-
-#ifndef lint
-static const char rcsid[] = "$Id$";
-#endif
-
-#define PTHREAD_KERNEL
-
-#include <errno.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include "pthreadutil.h"
-
-static int pthread_atexit_inited = 0;
-static pthread_key_t pthread_atexit_key;
-static pthread_mutex_t pthread_atexit_mutex = PTHREAD_MUTEX_INITIALIZER;
-
-/* ==========================================================================
- * pthread_atexit_done()
- */
-static void pthread_atexit_done(void * arg)
-{
- pthread_atexit_t id, id_next;
-
- for (id = arg; id; id = id_next) {
- id_next = id->next;
- id->rtn(id->arg);
- free(id);
- }
-}
-
-/* ==========================================================================
- * pthread_atexit_add()
- */
-int pthread_atexit_add(pthread_atexit_t *id, void (*rtn)(void *), void * arg)
-{
- int ret;
-
- if (ret = pthread_mutex_lock(&pthread_atexit_mutex)) {
- return(ret);
- }
- if (!pthread_atexit_inited) {
- if (ret = pthread_key_create(&pthread_atexit_key, pthread_atexit_done)){
- pthread_mutex_unlock(&pthread_atexit_mutex);
- return(ret);
- }
- pthread_atexit_inited++;
- }
- pthread_mutex_unlock(&pthread_atexit_mutex);
-
- if ((*id) = (pthread_atexit_t)malloc(sizeof(struct pthread_atexit))) {
- if ((*id)->next = pthread_getspecific(pthread_atexit_key)) {
- (*id)->next->prev = (*id);
- }
- pthread_setspecific(pthread_atexit_key, (void *)*id);
- (*id)->prev = NULL;
- (*id)->rtn = rtn;
- (*id)->arg = arg;
- return(OK);
- }
- return(ENOMEM);
-}
-
-/* ==========================================================================
- * pthread_atexit_remove()
- */
-int pthread_atexit_remove(pthread_atexit_t * id, int execute)
-{
- pthread_atexit_t old;
-
- if (old = pthread_getspecific(pthread_atexit_key)) {
- if (old == *id) {
- old = old->next;
- old->prev = NULL;
- pthread_setspecific(pthread_atexit_key, old);
- } else {
- if ((*id)->next) {
- (*id)->next->prev = (*id)->prev;
- }
- (*id)->prev->next = (*id)->next;
- }
- if (execute) {
- (*id)->rtn((*id)->arg);
- }
- free((*id));
- return(OK);
- }
- return(EINVAL);
-}
-
-/* ==========================================================================
- * A few non void functions that are often used as void functions
- */
-void fflush_nrv(void * fp) { fflush((FILE *)fp); }
-void fclose_nrv(void * fp) { fclose((FILE *)fp); }
-
-void pthread_attr_destroy_nrv(void * attr)
-{
- pthread_attr_destroy((pthread_attr_t *)attr);
-}
diff --git a/mit-pthreads/lib/libpthreadutil/pthread_tad.c b/mit-pthreads/lib/libpthreadutil/pthread_tad.c
deleted file mode 100755
index a59fd9b87bf..00000000000
--- a/mit-pthreads/lib/libpthreadutil/pthread_tad.c
+++ /dev/null
@@ -1,170 +0,0 @@
-/* ==== pthread_tad.c =========================================================
- * Copyright (c) 1995 by Chris Provenzano, proven@athena.mit.edu
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. All advertising materials mentioning features or use of this software
- * must display the following acknowledgement:
- * This product includes software developed by Chris Provenzano,
- * and its contributors.
- * 4. Neither the name of Chris Provenzano, nor the names of
- * its contributors may be used to endorse or promote products derived
- * from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY CHRIS PROVENZANO, AND CONTRIBUTORS
- * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
- * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
- *
- */
-
-#ifndef lint
-static char copyright[] =
- "@(#) Copyright (c) 1995 Chris Provenzano.\nAll rights reserved.\n";
-#endif /* not lint */
-
-/* tad = thread allocation domain */
-#define PTHREAD_KERNEL
-
-#include "pthreadutil.h"
-#include <stdio.h>
-#include <errno.h>
-
-int pthread_tad_count(pthread_tad_t * tad)
-{
- int ret;
-
- pthread_mutex_lock(&tad->mutex);
- ret = tad->count_current;
- pthread_mutex_unlock(&tad->mutex);
- return(ret);
-}
-
-static void pthread_tad_done(void * arg)
-{
- pthread_tad_t * tad = arg;
- pthread_mutex_lock(&tad->mutex);
- --tad->count_current;
-/* if (--tad->count_current < tad->count_max) */
- pthread_cond_broadcast(&tad->cond);
- pthread_mutex_unlock(&tad->mutex);
-}
-
-#ifndef PTHREAD_KERNEL
-struct tad_start {
- pthread_tad_t * tad;
- void * (*routine)();
- void * arg;
-};
-
-static void * pthread_tad_start(struct tad_start * tad_start)
-{
- void * (*routine)() = tad_start->routine;
- void * arg = tad_start->arg;
-
- pthread_mutex_lock(&tad_start->tad->mutex);
- pthread_cleanup_push(pthread_tad_done, tad_start->tad);
- pthread_mutex_unlock(&tad_start->tad->mutex);
- free(tad_start);
- return(routine(arg));
-}
-#else
-static void * pthread_tad_start(void * tad_start_arg)
-{
- pthread_tad_t * tad = tad_start_arg;
- void * (*routine)() = tad->routine;
- void * arg = tad->arg;
-
- tad->count_current++;
- pthread_cleanup_push(pthread_tad_done, tad);
- pthread_mutex_unlock(&tad->mutex);
- return(routine(arg));
-}
-#endif
-
-int pthread_tad_create(pthread_tad_t * tad, pthread_t *thread_id,
- pthread_attr_t *attr, void * (*routine)(), void * arg)
-{
-#ifndef PTHREAD_KERNEL
- struct tad_start tad;
-#endif
- int ret;
-
- pthread_mutex_lock(&tad->mutex);
- while (tad->count_max && (tad->count_current > tad->count_max))
- pthread_cond_wait(&tad->cond, &tad->mutex);
-
-#ifndef PTHREAD_KERNEL
- if ((tad_start = malloc(sizeof(struct tad_start))) == NULL) {
- pthread_mutex_unlock(&tad->mutex);
- return(ENOMEM);
- }
- tad_start->routine = routine;
- tad_start->arg = arg;
- tad_start->tad = tad;
- if ((ret = pthread_create(thread_id, attr,
- pthread_tad_start, tad_start)) == OK)
- tad->count_current++;
- pthread_mutex_unlock(&tad->mutex);
-#else
- tad->routine = routine;
- tad->arg = arg;
- if (ret = pthread_create(thread_id, attr, pthread_tad_start, tad))
- pthread_mutex_unlock(&tad->mutex);
-#endif
- return(ret);
-}
-
-int pthread_tad_wait(pthread_tad_t * tad, unsigned int count)
-{
- if ((tad->count_max) && (tad->count_max < count)) {
- return(EINVAL);
- }
- pthread_mutex_lock(&tad->mutex);
- while (tad->count_current > count)
- pthread_cond_wait(&tad->cond, &tad->mutex);
- pthread_mutex_unlock(&tad->mutex);
- return(OK);
-}
-
-int pthread_tad_init(pthread_tad_t * tad, unsigned int max_count)
-{
- int ret;
-
- if ((ret = pthread_mutex_init(&tad->mutex, NULL)) == OK) {
- if (ret = pthread_cond_init(&tad->cond, NULL)) {
- pthread_mutex_destroy(&tad->mutex);
- } else {
- tad->count_max = max_count;
- tad->count_current = 0;
- }
- }
- return(ret);
-}
-
-/* User is responsible to make sure their are no threads running */
-int pthread_tad_destroy(pthread_tad_t * tad)
-{
- int ret;
-
- if ((ret = pthread_mutex_destroy(&tad->mutex)) == OK) {
- ret = pthread_cond_destroy(&tad->cond);
- } else {
- pthread_cond_destroy(&tad->cond);
- }
- tad->count_max = NOTOK;
- return(ret);
-}
diff --git a/mit-pthreads/lib/libpthreadutil/pthreadutil.h b/mit-pthreads/lib/libpthreadutil/pthreadutil.h
deleted file mode 100755
index 0d8e6a6ef5f..00000000000
--- a/mit-pthreads/lib/libpthreadutil/pthreadutil.h
+++ /dev/null
@@ -1,75 +0,0 @@
-/* ==== pthread_tad.h ========================================================
- * Copyright (c) 1995 by Chris Provenzano, proven@athena.mit.edu
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. All advertising materials mentioning features or use of this software
- * must display the following acknowledgement:
- * This product includes software developed by Chris Provenzano,
- * and its contributors.
- * 4. Neither the name of Chris Provenzano, nor the names of
- * its contributors may be used to endorse or promote products derived
- * from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY CHRIS PROVENZANO, AND CONTRIBUTORS
- * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
- * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
- *
- */
-
-#include <pthread.h>
-#include <sys/cdefs.h>
-
-typedef struct pthread_tad_t {
- pthread_mutex_t mutex;
- pthread_cond_t cond;
- unsigned int count_current;
- unsigned int count_max;
- void * arg;
- void * (*routine)();
-} pthread_tad_t;
-
-typedef struct pthread_atexit {
- struct pthread_atexit * next;
- struct pthread_atexit * prev;
- void (*rtn)(void *);
- void * arg;
-} * pthread_atexit_t;
-
-/*
- * New functions
- */
-
-__BEGIN_DECLS
-
-int pthread_tad_count __P_((pthread_tad_t *));
-int pthread_tad_create __P_((pthread_tad_t *, pthread_t *, pthread_attr_t *,
- void *(*routine)(), void *));
-int pthread_tad_wait __P_((pthread_tad_t *, unsigned int));
-int pthread_tad_init __P_((pthread_tad_t *, unsigned int));
-int pthread_tad_destroy __P_((pthread_tad_t *));
-
-int pthread_atexit_add __P_((pthread_atexit_t *, void (*)(void *), void *));
-int pthread_atexit_remove __P_((pthread_atexit_t *, int));
-
-
-void fclose_nrv __P_((void *));
-void fflush_nrv __P_((void *));
-void pthread_attr_destroy_nrv __P_((void *));
-
-__END_DECLS
-