diff options
Diffstat (limited to 'lib/libpthread/include/pthread')
23 files changed, 1514 insertions, 0 deletions
diff --git a/lib/libpthread/include/pthread/ac-types.h b/lib/libpthread/include/pthread/ac-types.h new file mode 100755 index 00000000000..f21fc6806e4 --- /dev/null +++ b/lib/libpthread/include/pthread/ac-types.h @@ -0,0 +1,11 @@ +#ifndef pthread_size_t +#define pthread_ipaddr_type unsigned long +#define pthread_ipport_type unsigned short +#define pthread_clock_t long +#define pthread_size_t unsigned int +#define pthread_ssize_t int +#define pthread_time_t long +#define pthread_fpos_t long +#define pthread_off_t long +#define pthread_va_list void * +#endif diff --git a/lib/libpthread/include/pthread/cleanup.h b/lib/libpthread/include/pthread/cleanup.h new file mode 100755 index 00000000000..720f2d55445 --- /dev/null +++ b/lib/libpthread/include/pthread/cleanup.h @@ -0,0 +1,59 @@ +/* ==== cleanup.h ============================================================ + * 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. + * + * $Id: cleanup.h,v 1.1 1998/07/21 13:19:11 peter Exp $ + * + * Description : cleanup header. + * + * 1.20 94/02/13 proven + * -Started coding this file. + */ + +/* + * New cleanup structures + */ +struct pthread_cleanup { + struct pthread_cleanup *next; + void (*routine)(); + void *routine_arg; +}; + +/* + * New functions + */ + +__BEGIN_DECLS + +int pthread_cleanup_push __P_((void (*routine)(void *), void *routine_arg)); +void pthread_cleanup_pop __P_((int execute)); + +__END_DECLS + diff --git a/lib/libpthread/include/pthread/cond.h b/lib/libpthread/include/pthread/cond.h new file mode 100755 index 00000000000..28c283b75f4 --- /dev/null +++ b/lib/libpthread/include/pthread/cond.h @@ -0,0 +1,100 @@ +/* ==== cond.h ============================================================ + * Copyright (c) 1993 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. + * + * $Id: cond.h,v 1.1 1998/07/21 13:19:11 peter Exp $ + * + * Description : Condition variable header. + * + * 1.00 93/10/30 proven + * -Started coding this file. + */ + +#include <timers.h> + +/* + * New cond structures + */ +enum pthread_condtype { + COND_TYPE_FAST, + COND_TYPE_STATIC_FAST, + COND_TYPE_COUNTING_FAST, /* Used with MUTEX_TYPE_COUNTING_FAST */ + COND_TYPE_METERED, + COND_TYPE_DEBUG, /* Debug conds will have lots of options */ + COND_TYPE_MAX +}; + +#define PTHREAD_CONDTYPE_FAST 1 +#define PTHREAD_CONDTYPE_DEBUG 4 +#define PTHREAD_CONDTYPE_RECURSIVE 2 + +typedef struct pthread_cond { + enum pthread_condtype c_type; + struct pthread_queue c_queue; + semaphore c_lock; + void * c_data; + long c_flags; +} pthread_cond_t; + +typedef struct pthread_condattr { + enum pthread_condtype c_type; + long c_flags; +} pthread_condattr_t; + +/* + * Flags for conds. + */ +#define COND_FLAGS_PRIVATE 0x01 +#define COND_FLAGS_INITED 0x02 +#define COND_FLAGS_BUSY 0x04 + +/* + * Static cond initialization values. + */ +#define PTHREAD_COND_INITIALIZER \ +{ COND_TYPE_STATIC_FAST, PTHREAD_QUEUE_INITIALIZER, \ + SEMAPHORE_CLEAR, NULL, COND_FLAGS_INITED } + +/* + * New functions + */ + +__BEGIN_DECLS + +int pthread_cond_init __P_((pthread_cond_t *, const pthread_condattr_t *)); +int pthread_cond_timedwait __P_((pthread_cond_t *, pthread_mutex_t *, + const struct timespec * abstime)); +int pthread_cond_wait __P_((pthread_cond_t *, pthread_mutex_t *)); +int pthread_cond_signal __P_((pthread_cond_t *)); +int pthread_cond_broadcast __P_((pthread_cond_t *)); +int pthread_cond_destroy __P_((pthread_cond_t *)); + +__END_DECLS + diff --git a/lib/libpthread/include/pthread/config.h b/lib/libpthread/include/pthread/config.h new file mode 100755 index 00000000000..d944b14a8c6 --- /dev/null +++ b/lib/libpthread/include/pthread/config.h @@ -0,0 +1,4 @@ +#ifndef _SYS___CONFIG_H_ +#define _SYS___CONFIG_H_ +#define _OS_HAS_TIMESPEC 1 +#endif diff --git a/lib/libpthread/include/pthread/debug_out.h b/lib/libpthread/include/pthread/debug_out.h new file mode 100755 index 00000000000..6968c5ea90e --- /dev/null +++ b/lib/libpthread/include/pthread/debug_out.h @@ -0,0 +1,44 @@ +/* debug_out.h - macros to use for debugging prints in places where calls + to printf() and gang are ill-advised. */ + +#ifdef PTHREAD_DEBUGGING +#define PTHREAD_DEBUG_WriteStr(S) (void)machdep_sys_write(2,S,strlen(S)) +#define PTHREAD_DEBUG_WriteInt32Hex(X) \ + { char _xbuf[8]; int _temp = (int)(X), _temp2; \ + _temp2 = ((_temp>>28)&0xf); \ + _xbuf[0] = (_temp2<10)? (_temp2+'0'): ((_temp2-10)+'a'); \ + _temp2 = ((_temp>>24)&0xf); \ + _xbuf[1] = (_temp2<10)? (_temp2+'0'): ((_temp2-10)+'a'); \ + _temp2 = ((_temp>>20)&0xf); \ + _xbuf[2] = (_temp2<10)? (_temp2+'0'): ((_temp2-10)+'a'); \ + _temp2 = ((_temp>>16)&0xf); \ + _xbuf[3] = (_temp2<10)? (_temp2+'0'): ((_temp2-10)+'a'); \ + _temp2 = ((_temp>>12)&0xf); \ + _xbuf[4] = (_temp2<10)? (_temp2+'0'): ((_temp2-10)+'a'); \ + _temp2 = ((_temp>>8)&0xf); \ + _xbuf[5] = (_temp2<10)? (_temp2+'0'): ((_temp2-10)+'a'); \ + _temp2 = ((_temp>>4)&0xf); \ + _xbuf[6] = (_temp2<10)? (_temp2+'0'): ((_temp2-10)+'a'); \ + _temp2 = (_temp&0xf); \ + _xbuf[7] = (_temp2<10)? (_temp2+'0'): ((_temp2-10)+'a'); \ + (void)machdep_sys_write(2,_xbuf,8); \ + } +#ifdef __alpha +#define PTHREAD_DEBUG_WriteInt64Hex(X) \ + { long _tempX = (long)(X),_tempY; \ + _tempY=((_tempX>>32)&0xffffffff); \ + PTHREAD_DEBUG_WriteInt32Hex(_tempY); \ + _tempY=(_tempX&0xffffffff); \ + PTHREAD_DEBUG_WriteInt32Hex(_tempY); \ + } +#define PTHREAD_DEBUG_WritePointer(X) PTHREAD_DEBUG_WriteInt64Hex(X) +#else +#define PTHREAD_DEBUG_WriteInt64Hex(X) PTHREAD_DEBUG_WriteInt32Hex(X) +#define PTHREAD_DEBUG_WritePointer(X) PTHREAD_DEBUG_WriteInt32Hex(X) +#endif /* __alpha */ +#else /* ! PTHREAD_DEBUGGING */ +#define PTHREAD_DEBUG_WriteStr(S) +#define PTHREAD_DEBUG_WriteInt32Hex(X) +#define PTHREAD_DEBUG_WriteInt64HeX(X) +#define PTHREAD_DEBUG_WritePointer(X) +#endif /* PTHREAD_DEBUGGING */ diff --git a/lib/libpthread/include/pthread/fd.h b/lib/libpthread/include/pthread/fd.h new file mode 100755 index 00000000000..28e55935812 --- /dev/null +++ b/lib/libpthread/include/pthread/fd.h @@ -0,0 +1,122 @@ +/* ==== fd.h ============================================================ + * Copyright (c) 1993, 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. + * + * $Id: fd.h,v 1.1 1998/07/21 13:19:11 peter Exp $ + * + * Description : Basic fd header. + * + * 1.00 93/08/14 proven + * -Started coding this file. + * + * 1.01 93/11/13 proven + * -The functions readv() and writev() added + */ + +/* + * New pthread types. + */ +enum fd_type { + FD_NT, /* Not tested */ + FD_NIU, /* Known to be not in use */ + FD_HALF_DUPLEX, /* Files, and seeking devices */ + FD_FULL_DUPLEX, /* pipes, sockets, drivers, ... */ + FD_TEST_HALF_DUPLEX, /* Redo machdep_sys_fcntl */ + FD_TEST_FULL_DUPLEX /* Redo machdep_sys_fcntl */ +}; + + +#define FD_READ 0x1 +#define FD_WRITE 0x2 +#define FD_RDWR (FD_READ | FD_WRITE) + +union fd_data { + void *ptr; + int i; +}; + +struct timespec; +struct iovec; +struct fd_ops { + pthread_ssize_t (*write) __P_((union fd_data, int, const void *, + size_t, struct timespec *)); + pthread_ssize_t (*read) __P_((union fd_data, int, void *, size_t, + struct timespec *)); + int (*close)(); + int (*fcntl)(); + int (*writev) __P_((union fd_data, int, + const struct iovec *, + int, struct timespec *)); + int (*readv) __P_((union fd_data, int, + const struct iovec *, + int, struct timespec *)); + off_t (*seek)(); + int use_kfds; +}; + +struct fd_table_entry { + struct pthread_queue r_queue; + struct pthread_queue w_queue; + struct pthread *r_owner; + struct pthread *w_owner; + pthread_mutex_t mutex; + struct fd_table_entry *next; + struct fd_ops *ops; + enum fd_type type; + int r_lockcount; /* Count for FILE read locks */ + int w_lockcount; /* Count for FILE write locks */ + int count; + + /* data that needs to be passed to the type dependent fd */ + int flags; + union fd_data fd; +}; + +/* + * Globals + */ +#if defined(PTHREAD_KERNEL) + +extern struct fd_table_entry **fd_table; +extern int dtablesize; + +#endif + +/* + * New functions + */ + +__BEGIN_DECLS + +#if defined(PTHREAD_KERNEL) + +#endif + +__END_DECLS diff --git a/lib/libpthread/include/pthread/fd_pipe.h b/lib/libpthread/include/pthread/fd_pipe.h new file mode 100755 index 00000000000..1561eeb6a7e --- /dev/null +++ b/lib/libpthread/include/pthread/fd_pipe.h @@ -0,0 +1,54 @@ +/* ==== fd_pipe.h ============================================================ + * Copyright (c) 1993 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. + * + * $Id: fd_pipe.h,v 1.1 1998/07/21 13:19:11 peter Exp $ + * + * Description : The new fast ITC pipe header. + * + * 1.00 93/08/14 proven + * -Started coding this file. + */ + +struct __pipe { + semaphore lock; + char * buf; + int size; + int flags; + int count; + int offset; + struct pthread * wait; + char * wait_buf; + size_t wait_size; +}; + +#define RD_CLOSED 0x01 +#define WR_CLOSED 0x02 + diff --git a/lib/libpthread/include/pthread/kernel.h b/lib/libpthread/include/pthread/kernel.h new file mode 100755 index 00000000000..71518becced --- /dev/null +++ b/lib/libpthread/include/pthread/kernel.h @@ -0,0 +1,71 @@ +/* ==== kernel.h ============================================================ + * Copyright (c) 1993 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. + * + * $Id: kernel.h,v 1.1 1998/07/21 13:19:11 peter Exp $ + * + * Description : mutex header. + * + * 1.00 93/07/22 proven + * -Started coding this file. + */ + +/* + * Defines only for the pthread user kernel. + */ +#if defined(PTHREAD_KERNEL) + +#ifdef __GNUC__ +#include <assert.h> +#endif +#ifdef __ASSERT_FUNCTION +#define PANIC() panic_kernel( __FILE__, __LINE__, __ASSERT_FUNCTION ) +#else +#define PANIC() panic_kernel( __FILE__, __LINE__, (const char *)0 ) +#endif + + +/* Time each rr thread gets */ +#define PTHREAD_RR_TIMEOUT 100000000 + +/* Set the errno value */ +#define SET_ERRNO(x) \ +{ \ + if (!pthread_run->error_p) { \ + pthread_run->error_p = &pthread_run->error; \ + } \ + (*(pthread_run->error_p)) = x; \ +} + +/* Globals only the internals should see */ +extern struct pthread_prio_queue * pthread_current_prio_queue; +extern volatile int pthread_kernel_lock; + +#endif diff --git a/lib/libpthread/include/pthread/kthread.h b/lib/libpthread/include/pthread/kthread.h new file mode 100755 index 00000000000..e9eed520ae9 --- /dev/null +++ b/lib/libpthread/include/pthread/kthread.h @@ -0,0 +1,67 @@ +/* ==== kthread.h ============================================================ + * Copyright (c) 1993, 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. + * + * $Id: kthread.h,v 1.1 1998/07/21 13:19:11 peter Exp $ + * + * Description : Basic pthread header. + * + * 1.00 93/07/20 proven + * -Started coding this file. + * + * 1.32 94/05/25 proven + * -Started adding kernel thread support + */ + +#ifndef _KTHREAD_H_ +#define _KTHREAD_H_ + +enum kthread_state { + KS_RUNNING, + KS_DEAD, +}; + +struct kthread { + enum kthread_state state; + + struct pthread_queue pthread_current_queue; + struct pthread * pthread_link_list; + struct pthread * pthread_run; + + semaphore lock; + +}; + +/* + * Globals + */ +extern struct kthread * kthread_link_list; + +#endif diff --git a/lib/libpthread/include/pthread/mutex.h b/lib/libpthread/include/pthread/mutex.h new file mode 100755 index 00000000000..273ae461e69 --- /dev/null +++ b/lib/libpthread/include/pthread/mutex.h @@ -0,0 +1,102 @@ +/* ==== mutex.h ============================================================ + * Copyright (c) 1993 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. + * + * $Id: mutex.h,v 1.1 1998/07/21 13:19:11 peter Exp $ + * + * Description : mutex header. + * + * 1.00 93/07/20 proven + * -Started coding this file. + */ + +/* + * New mutex structures + */ +enum pthread_mutextype { + MUTEX_TYPE_STATIC_FAST = 0, + MUTEX_TYPE_FAST = 1, + MUTEX_TYPE_COUNTING_FAST = 2, /* Recursive */ + MUTEX_TYPE_METERED = 3, + MUTEX_TYPE_DEBUG = 4, /* This will have lots of options */ + MUTEX_TYPE_MAX +}; + +#define PTHREAD_MUTEXTYPE_FAST 1 +#define PTHREAD_MUTEXTYPE_DEBUG 4 +#define PTHREAD_MUTEXTYPE_RECURSIVE 2 + +union pthread_mutex_data { + void * m_ptr; + int m_count; +}; + +typedef struct pthread_mutex { + enum pthread_mutextype m_type; + struct pthread_queue m_queue; + struct pthread * m_owner; + semaphore m_lock; + union pthread_mutex_data m_data; + long m_flags; +} pthread_mutex_t; + +typedef struct pthread_mutexattr { + enum pthread_mutextype m_type; + long m_flags; +} pthread_mutexattr_t; + +/* + * Flags for mutexes. + */ +#define MUTEX_FLAGS_PRIVATE 0x01 +#define MUTEX_FLAGS_INITED 0x02 +#define MUTEX_FLAGS_BUSY 0x04 + +/* + * Static mutex initialization values. + */ +#define PTHREAD_MUTEX_INITIALIZER \ +{ MUTEX_TYPE_STATIC_FAST, PTHREAD_QUEUE_INITIALIZER, \ + NULL, SEMAPHORE_CLEAR, { NULL }, MUTEX_FLAGS_INITED } + +/* + * New functions + */ + +__BEGIN_DECLS + +int pthread_mutex_init __P_((pthread_mutex_t *, const pthread_mutexattr_t *)); +int pthread_mutex_lock __P_((pthread_mutex_t *)); +int pthread_mutex_unlock __P_((pthread_mutex_t *)); +int pthread_mutex_trylock __P_((pthread_mutex_t *)); +int pthread_mutex_destroy __P_((pthread_mutex_t *)); + +__END_DECLS + diff --git a/lib/libpthread/include/pthread/paths.h b/lib/libpthread/include/pthread/paths.h new file mode 100755 index 00000000000..3d695546bc3 --- /dev/null +++ b/lib/libpthread/include/pthread/paths.h @@ -0,0 +1,12 @@ +#ifndef _SYS___PATHS_H_ +#define _SYS___PATHS_H_ +#define _PATH_PTY "/devices/pseudo/" +#define _PATH_TZDIR "/usr/share/lib/zoneinfo" +#define _PATH_TZFILE "/usr/share/lib/zoneinfo/localtime" +#define _PATH_RESCONF "/etc/resolv.conf" +#define _PATH_HOSTS "/etc/hosts" +#define _PATH_NETWORKS "/etc/networks" +#define _PATH_PROTOCOLS "/etc/protocols" +#define _PATH_SERVICES "/etc/services" +#define _PATH_BSHELL "/bin/sh" +#endif diff --git a/lib/libpthread/include/pthread/prio_queue.h b/lib/libpthread/include/pthread/prio_queue.h new file mode 100755 index 00000000000..d9c84ad25ed --- /dev/null +++ b/lib/libpthread/include/pthread/prio_queue.h @@ -0,0 +1,78 @@ +/* ==== priority.h ========================================================== + * 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. + * + * $Id: prio_queue.h,v 1.1 1998/07/21 13:19:12 peter Exp $ + * + * Description : Priority functions. + * + * 1.00 94/09/19 proven + * -Started coding this file. + */ + +#ifndef _PTHREAD_PRIO_QUEUE_H_ +#define _PTHREAD_PRIO_QUEUE_H_ + +/* + * Static queue initialization values. + */ +#define PTHREAD_DEFAULT_PRIORITY 64 +#define PTHREAD_MAX_PRIORITY 126 +#define PTHREAD_MIN_PRIORITY 0 + +/* + * New prio_queue structures + */ +struct pthread_prio_level { + struct pthread * first; + struct pthread * last; +}; + +struct pthread_prio_queue { + void * data; + struct pthread * next; + struct pthread_prio_level level[PTHREAD_MAX_PRIORITY + 1]; +}; + +/* + * New functions + */ + +__BEGIN_DECLS + +void pthread_prio_queue_init __P_((struct pthread_prio_queue *)); +void pthread_prio_queue_enq __P_((struct pthread_prio_queue *, + struct pthread *)); +struct pthread *pthread_prio_queue_deq + __P_((struct pthread_prio_queue *)); + +__END_DECLS + +#endif diff --git a/lib/libpthread/include/pthread/pthread_attr.h b/lib/libpthread/include/pthread/pthread_attr.h new file mode 100755 index 00000000000..2602c1fa9c2 --- /dev/null +++ b/lib/libpthread/include/pthread/pthread_attr.h @@ -0,0 +1,122 @@ +/* ==== pthread_attr.h ======================================================== + * Copyright (c) 1993 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. + * + * $Id: pthread_attr.h,v 1.1 1998/07/21 13:19:12 peter Exp $ + * + * Description : Basic pthread attributes header. + * + * 1.00 93/11/03 proven + * -Started coding this file. + */ + +#define _POSIX_THREAD_ATTR_STACKSIZE + +#define PTHREAD_STACK_DEFAULT 65536 + +/* flags */ +#define PTHREAD_DETACHED 0x1 +#define PTHREAD_SCOPE_SYSTEM 0x2 +#define PTHREAD_INHERIT_SCHED 0x4 +#define PTHREAD_NOFLOAT 0x8 + +#define PTHREAD_CREATE_DETACHED PTHREAD_DETACHED +#define PTHREAD_CREATE_JOINABLE 0 +#define PTHREAD_SCOPE_PROCESS 0 +#define PTHREAD_EXPLICIT_SCHED 0 + +/* + * New pthread attribute types. + */ +enum schedparam_policy { + SCHED_RR, + SCHED_IO, + SCHED_FIFO, + SCHED_OTHER +}; + +struct pthread_attr { + enum schedparam_policy schedparam_policy; + int sched_priority; + + int flags; + void * arg_attr; + void (*cleanup_attr)(); + void * stackaddr_attr; + size_t stacksize_attr; +}; + +struct sched_param { + int sched_priority; + void * no_data; +}; + +/* + * New functions + */ + +__BEGIN_DECLS + +#if defined(DCE_COMPAT) + +typedef struct pthread_attr * pthread_attr_t; + +int pthread_attr_create __P_((pthread_attr_t *)); +int pthread_attr_delete __P_((pthread_attr_t *)); + +#else + +typedef struct pthread_attr pthread_attr_t; + +int pthread_attr_init __P_((pthread_attr_t *)); +int pthread_attr_destroy __P_((pthread_attr_t *)); +int pthread_attr_setstacksize __P_((pthread_attr_t *, size_t)); +int pthread_attr_getstacksize __P_((pthread_attr_t *, size_t *)); +int pthread_attr_setstackaddr __P_((pthread_attr_t *, void *)); +int pthread_attr_getstackaddr __P_((pthread_attr_t *, void **)); +int pthread_attr_setdetachstate __P_((pthread_attr_t *, int )); +int pthread_attr_getdetachstate __P_((pthread_attr_t *, int *)); +int pthread_attr_setscope __P_((pthread_attr_t *, int )); +int pthread_attr_getscope __P_((pthread_attr_t *, int *)); +int pthread_attr_setinheritsched __P_((pthread_attr_t *, int )); +int pthread_attr_getinheritsched __P_((pthread_attr_t *, int *)); +int pthread_attr_setschedpolicy __P_((pthread_attr_t *, int )); +int pthread_attr_getschedpolicy __P_((pthread_attr_t *, int *)); +int pthread_attr_setschedparam __P_((pthread_attr_t *, struct sched_param *)); +int pthread_attr_getschedparam __P_((pthread_attr_t *, struct sched_param *)); + +int pthread_attr_setfloatstate __P_((pthread_attr_t *, int )); +int pthread_attr_getfloatstate __P_((pthread_attr_t *, int *)); +int pthread_attr_setcleanup __P_((pthread_attr_t *, void (*routine)(void *), + void *)); + +#endif + +__END_DECLS diff --git a/lib/libpthread/include/pthread/pthread_once.h b/lib/libpthread/include/pthread/pthread_once.h new file mode 100755 index 00000000000..a9395c0f7fe --- /dev/null +++ b/lib/libpthread/include/pthread/pthread_once.h @@ -0,0 +1,58 @@ +/* ==== pthread_once.h ======================================================== + * Copyright (c) 1993 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. + * + * $Id: pthread_once.h,v 1.1 1998/07/21 13:19:12 peter Exp $ + * + * Description : mutex header. + * + * 1.00 93/12/12 proven + * -Started coding this file. + */ + +/* New pthread_once structures */ +typedef struct pthread_once { + int state; + pthread_mutex_t mutex; +} pthread_once_t; + +/* Static pthread_once_t initialization value. */ +#define PTHREAD_NEEDS_INIT 0 +#define PTHREAD_DONE_INIT 1 +#define PTHREAD_ONCE_INIT { PTHREAD_NEEDS_INIT, PTHREAD_MUTEX_INITIALIZER } + +/* New functions */ + +__BEGIN_DECLS + +int pthread_once __P_((pthread_once_t *, void (*init_routine)(void))); + +__END_DECLS + diff --git a/lib/libpthread/include/pthread/queue.h b/lib/libpthread/include/pthread/queue.h new file mode 100755 index 00000000000..0d7d2d219e3 --- /dev/null +++ b/lib/libpthread/include/pthread/queue.h @@ -0,0 +1,67 @@ +/* ==== queue.h ============================================================ + * Copyright (c) 1993 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. + * + * $Id: queue.h,v 1.1 1998/07/21 13:19:12 peter Exp $ + * + * Description : mutex header. + * + * 1.00 93/07/20 proven + * -Started coding this file. + */ + +/* + * New queue structures + */ +struct pthread_queue { + struct pthread *q_next; + struct pthread *q_last; + void *q_data; +}; + +/* + * Static queue initialization values. + */ +#define PTHREAD_QUEUE_INITIALIZER { NULL, NULL, NULL } + +/* + * New functions + * Should make pthread_queue_get a macro + */ + +__BEGIN_DECLS + +void pthread_queue_init __P_((struct pthread_queue *)); +void pthread_queue_enq __P_((struct pthread_queue *, struct pthread *)); +int pthread_queue_remove __P_((struct pthread_queue *, struct pthread *)); +struct pthread *pthread_queue_get __P_((struct pthread_queue *)); +struct pthread *pthread_queue_deq __P_((struct pthread_queue *)); + +__END_DECLS diff --git a/lib/libpthread/include/pthread/sleep.h b/lib/libpthread/include/pthread/sleep.h new file mode 100755 index 00000000000..9f8f2dccd95 --- /dev/null +++ b/lib/libpthread/include/pthread/sleep.h @@ -0,0 +1,63 @@ +/* ==== sleep.h ============================================================ + * 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. + * + * $Id: sleep.h,v 1.1 1998/07/21 13:19:12 peter Exp $ + * + * Description : sleep header. + * + * 1.00 94/06/04 proven + * -Started coding this file. + */ + +#if defined(PTHREAD_KERNEL) + +#include <timers.h> + +/* + * New functions + */ +static inline int machdep_gettimeofday(struct timespec * current_time) +{ + struct timeval current_real_time; + int ret; + + ret = gettimeofday(¤t_real_time, NULL); + TIMEVAL_TO_TIMESPEC((¤t_real_time), current_time); + return(ret); +} + +__BEGIN_DECLS + +void sleep_schedule __P_((struct timespec *, struct timespec *)); + +__END_DECLS + +#endif diff --git a/lib/libpthread/include/pthread/specific.h b/lib/libpthread/include/pthread/specific.h new file mode 100755 index 00000000000..6757ceeb08e --- /dev/null +++ b/lib/libpthread/include/pthread/specific.h @@ -0,0 +1,66 @@ +/* ==== specific.h ======================================================== + * 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. + * + * $Id: specific.h,v 1.1 1998/07/21 13:19:12 peter Exp $ + * + * Description : Thread specific data management header. + * + * 1.20 94/03/30 proven + * -Started coding this file. + */ + +#define PTHREAD_DATAKEYS_MAX 256 +#define _POSIX_THREAD_DESTRUTOR_ITERATIONS 4 + +/* + * New thread specific key type. + */ +struct pthread_key { + pthread_mutex_t mutex; + long count; + void (*destructor)(); +}; + +typedef int pthread_key_t; + +/* + * New functions + */ + +__BEGIN_DECLS + +int pthread_key_create __P_((pthread_key_t *, void (*routine)(void *))); +int pthread_setspecific __P_((pthread_key_t, const void *)); +void *pthread_getspecific __P_((pthread_key_t)); +int pthread_key_delete __P_((pthread_key_t)); + +__END_DECLS + diff --git a/lib/libpthread/include/pthread/state.def b/lib/libpthread/include/pthread/state.def new file mode 100755 index 00000000000..c62d102a9f0 --- /dev/null +++ b/lib/libpthread/include/pthread/state.def @@ -0,0 +1,64 @@ +/* This file defines the states that a given thread can be in. + + The funky macro use here is so that this one header file can also + define the corresponding state names, so that the two lists can't + get inconsistent within a given source tree. */ + +/* The thread is runnable. */ +__pthread_defstate (PS_RUNNING, "running") + +/* + * The rest of the states are where the thread is waiting on some event. + * Someday maybe the "data" field will point to the object being waited for. + */ + +/* Waiting for a mutex (pthread_mutex_lock()). */ +__pthread_defstate (PS_MUTEX_WAIT, "mutex") + +/* Waiting on a condition variable + (pthread_cond_wait(), or pthread_cond_timedwait()). */ +__pthread_defstate (PS_COND_WAIT, "cond") + +/* + * File descriptor stuff. + * + * File descriptors have a special lock. If it is a FULL_DUPLEX fd such as + * a socket or fifo then it has two mutexes, one for reads and one for writes. + * Some routines will even try to get both. It will always try to get the + * read lock first before tring to get the write. All other fds only have + * one mutex which all calls will get. It is displayed as if it is a read lock. + */ +/* Waiting on a fd read lock (fd_lock()) */ +__pthread_defstate (PS_FDLR_WAIT, "fdlr") + +/* Waiting on a fd write lock (fd_lock()) */ +__pthread_defstate (PS_FDLW_WAIT, "fdlw") + +/* Waiting for the kernel fd to have data to read, + (read(), readv(), recv(), recvfrom(), and recvmsg()). */ +__pthread_defstate (PS_FDR_WAIT, "fdr") /* Waiting on a kernel read */ + +/* Waiting for the kernel fd to allow a write + (write(), writev(), send(), sendto(), sendmsg()) */ +__pthread_defstate (PS_FDW_WAIT, "fdw") + +/* Waiting for several fds in a select() */ +__pthread_defstate (PS_SELECT_WAIT, "select") + +/* Waiting on a sleep (sleep(), usleep() or nanosleep()). */ +__pthread_defstate (PS_SLEEP_WAIT, "sleep") + +/* Waiting for a child to die (wait(), waitpid(), wait3(), or wait4()). */ +__pthread_defstate (PS_WAIT_WAIT, "wait") + +/* Waiting on some set of signals (sigwait()) */ +__pthread_defstate (PS_SIGWAIT, "sig") + +/* Waiting for a thread to die (pthread_join()) */ +__pthread_defstate (PS_JOIN, "join") + +/* Waiting for some thread to join with me or detach me */ +__pthread_defstate (PS_DEAD, "dead") + +/* Waiting for some thread to create me */ +__pthread_defstate (PS_UNALLOCED, "unallocated") diff --git a/lib/libpthread/include/pthread/types.h b/lib/libpthread/include/pthread/types.h new file mode 100755 index 00000000000..7fdf001a0bc --- /dev/null +++ b/lib/libpthread/include/pthread/types.h @@ -0,0 +1,46 @@ +#ifndef pthread_types_h +#define pthread_types_h + +#include <pthread/xtypes.h> +#include <pthread/ac-types.h> + +#if !defined (pthread_va_list) && defined (__NetBSD__) +#include <stdarg.h> +#define pthread_va_list _BSD_VA_LIST_ +#endif + +#if !defined (pthread_va_list) && defined (__GNUC__) +#define __need_va_list +#include <stdarg.h> +#define pthread_va_list __gnuc_va_list +#endif /* pthread_va_list, __GNUC__ */ + +/* OSF/1 does it this way. */ +#if !defined (pthread_va_list) && defined (pthread_have_va_list_h) +#ifndef _VA_LIST +#define _HIDDEN_VA_LIST +#include <va_list.h> +#define pthread_va_list __va_list +#else +/* va_list has already been defined */ +#define pthread_va_list va_list +#endif +#endif + +/* If all else fails... */ +#ifndef pthread_va_list +#include <stdarg.h> +#define pthread_va_list va_list +#endif + +#if defined(__STDC__) || defined(__GNUC__) +#ifndef __P_ +#define __P_(protos) protos +#endif +#else +#ifndef __P_ +#define __P_(protos) +#endif +#endif + +#endif /* pthread_types_h */ diff --git a/lib/libpthread/include/pthread/unistd.h b/lib/libpthread/include/pthread/unistd.h new file mode 100755 index 00000000000..3cb07533114 --- /dev/null +++ b/lib/libpthread/include/pthread/unistd.h @@ -0,0 +1,159 @@ +/*- + * Copyright (c) 1991 The Regents of the University of California. + * 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 the University of + * California, Berkeley and its contributors. + * 4. Neither the name of the University 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 THE REGENTS 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. + * + * @(#)unistd.h 5.13 (Berkeley) 6/17/91 + */ + +#include <sys/cdefs.h> + +__BEGIN_DECLS +void _exit __P_((int)); +int access __P_((const char *, int)); +int chdir __P_((const char *)); +int chown __P_((const char *, uid_t, gid_t)); +int close __P_((int)); +int dup __P_((int)); +int dup2 __P_((int, int)); +int execve __P_((const char *, char * const *, char * const *)); +pid_t fork __P_((void)); +int isatty __P_((int)); +int link __P_((const char *, const char *)); +off_t lseek __P_((int, off_t, int)); +int pipe __P_((int *)); +ssize_t read __P_((int, void *, size_t)); +u_int sleep __P_((u_int)); +char *ttyname __P_((int)); +int unlink __P_((const char *)); +ssize_t write __P_((int, const void *, size_t)); + +/* Not implemented for threads yet */ +u_int alarm __P_((u_int)); +char *cuserid __P_((char *)); +int execl __P_((const char *, const char *, ...)); +int execle __P_((const char *, const char *, ...)); +int execlp __P_((const char *, const char *, ...)); +int execv __P_((const char *, char * const *)); +int execvp __P_((const char *, char * const *)); +long fpathconf __P_((int, int)); /* not yet */ +char *getcwd __P_((char *, size_t)); +gid_t getegid __P_((void)); +uid_t geteuid __P_((void)); +gid_t getgid __P_((void)); +int getgroups __P_((int, int *)); /* XXX (gid_t *) */ +char *getlogin __P_((void)); +pid_t getpgrp __P_((void)); +pid_t getpid __P_((void)); +pid_t getppid __P_((void)); +uid_t getuid __P_((void)); +long pathconf __P_((const char *, int)); /* not yet */ +int pause __P_((void)); +int rmdir __P_((const char *)); +int setgid __P_((gid_t)); +int setpgid __P_((pid_t, pid_t)); +pid_t setsid __P_((void)); +int setuid __P_((uid_t)); +long sysconf __P_((int)); /* not yet */ +pid_t tcgetpgrp __P_((int)); +int tcsetpgrp __P_((int, pid_t)); + +#ifndef _POSIX_SOURCE + +int acct __P_((const char *)); +int async_daemon __P_((void)); +char *brk __P_((const char *)); +int chflags __P_((const char *, long)); +int chroot __P_((const char *)); +char *crypt __P_((const char *, const char *)); +int des_cipher __P_((const char *, char *, long, int)); +int des_setkey __P_((const char *key)); +int encrypt __P_((char *, int)); +void endusershell __P_((void)); +int exect __P_((const char *, char * const *, char * const *)); +int fchdir __P_((int)); +int fchflags __P_((int, long)); +int fchown __P_((int, uid_t, gid_t)); +int fsync __P_((int)); +int ftruncate __P_((int, off_t)); +int getdtablesize __P_((void)); +long gethostid __P_((void)); +int gethostname __P_((char *, int)); +mode_t getmode __P_((const void *, mode_t)); +int getpagesize __P_((void)); +char *getpass __P_((const char *)); +char *getusershell __P_((void)); +char *getwd __P_((char *)); /* obsoleted by getcwd() */ +int initgroups __P_((const char *, int)); +int mknod __P_((const char *, mode_t, dev_t)); +int mkstemp __P_((char *)); +char *mktemp __P_((char *)); +int nfssvc __P_((int)); +int nice __P_((int)); +void psignal __P_((u_int, const char *)); +extern char *sys_siglist[]; +int profil __P_((char *, int, int, int)); +int rcmd __P_((char **, int, const char *, + const char *, const char *, int *)); +char *re_comp __P_((const char *)); +int re_exec __P_((const char *)); +int readlink __P_((const char *, char *, int)); +int reboot __P_((int)); +int revoke __P_((const char *)); +int rresvport __P_((int *)); +int ruserok __P_((const char *, int, const char *, const char *)); +char *sbrk __P_((int)); +int setegid __P_((gid_t)); +int seteuid __P_((uid_t)); +int setgroups __P_((int, const int *)); +void sethostid __P_((long)); +int sethostname __P_((const char *, int)); +int setkey __P_((const char *)); +int setlogin __P_((const char *)); +void *setmode __P_((const char *)); +int setpgrp __P_((pid_t pid, pid_t pgrp)); /* obsoleted by setpgid() */ +int setregid __P_((int, int)); +int setreuid __P_((int, int)); +int setrgid __P_((gid_t)); +int setruid __P_((uid_t)); +void setusershell __P_((void)); +int swapon __P_((const char *)); +int symlink __P_((const char *, const char *)); +void sync __P_((void)); +int syscall __P_((int, ...)); +int truncate __P_((const char *, off_t)); +int ttyslot __P_((void)); +u_int ualarm __P_((u_int, u_int)); +void usleep __P_((u_int)); +int vfork __P_((void)); + +#endif /* !_POSIX_SOURCE */ +__END_DECLS + diff --git a/lib/libpthread/include/pthread/util.h b/lib/libpthread/include/pthread/util.h new file mode 100755 index 00000000000..c9ff1dbcabd --- /dev/null +++ b/lib/libpthread/include/pthread/util.h @@ -0,0 +1,89 @@ +/* ==== util.h ============================================================ + * Copyright (c) 1991, 1992, 1993 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. + * + * $Id: util.h,v 1.1 1998/07/21 13:19:12 peter Exp $ + * + * Description : Header file for generic utility functions. + * + * 91/08/31 proven - Added exchange. + * Exchange any two objects of any size in any table. + * + * 91/10/06 proven - Cleaned out all the old junk. + * + * 91/03/06 proven - Added getint. + */ + +#ifndef _PTHREAD_UTIL_H +#define _PTHREAD_UTIL_H + +#ifndef NULL +#define NULL 0 +#endif + +/* Stuff only pthread internals really uses */ +#if defined(PTHREAD_KERNEL) + +#undef FALSE +#undef TRUE + +typedef enum Boolean { + FALSE, + TRUE +} Boolean; + +#define OK 0 +#define NUL '\0' +#define NOTOK -1 + +#if ! defined(min) +#define min(a,b) (((a)<(b))?(a):(b)) +#define max(a,b) (((a)>(b))?(a):(b)) +#endif + +/* Alingn the size to the next multiple of 4 bytes */ +#define ALIGN4(size) ((size + 3) & ~3) +#define ALIGN8(size) ((size + 7) & ~7) + +#ifdef DEBUG +#define DEBUG0(s) printf(s) +#define DEBUG1(s,a) printf(s,a) +#define DEBUG2(s,a,b) printf(s,a,b) +#define DEBUG3(s,a,b,c) printf(s,a,b,c) +#else +#define DEBUG0(s) +#define DEBUG1(s) +#define DEBUG2(s) +#define DEBUG3(s) +#endif + +#endif + +#endif diff --git a/lib/libpthread/include/pthread/version.h b/lib/libpthread/include/pthread/version.h new file mode 100755 index 00000000000..ae0cbc6f4cb --- /dev/null +++ b/lib/libpthread/include/pthread/version.h @@ -0,0 +1,43 @@ +/* ==== version.h ============================================================ + * 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. + * + * $Id: version.h,v 1.1 1998/07/21 13:19:12 peter Exp $ + * + * Description : Header file for programs that what to KNOW the version. + * + * 94/08/24 proven - Added this file for pthreads. + */ + +#ifndef _PTHREAD_VERSION_H +#define _PTHREAD_VERSION_H 1 +#define _PTHREAD_VERSION_M 60 +#define _PTHREAD_VERSION_P 0 +#endif diff --git a/lib/libpthread/include/pthread/xtypes.h b/lib/libpthread/include/pthread/xtypes.h new file mode 100755 index 00000000000..4dcc4f04f8c --- /dev/null +++ b/lib/libpthread/include/pthread/xtypes.h @@ -0,0 +1,13 @@ +/* If you need any special typedefs for function pointers &c to try + testing for in configure.in, define them here. */ + +/* According to ANSI, two struct types in the same module are not + compatible types. So there's no way to define a type for + pthread_sigset_t that's compatible with sigset_t when they're + structure types, if we assume we can't pull in a __sigset_t or + something by itself from system header files. + + Since that was my main reason for creating this file, there isn't + anything here now. If after working on this code a bit longer we + don't find anything else to put here, this file should just go + away. */ |