diff options
| author | proven <proven@NetBSD.org> | 1994-02-07 22:02:26 +0000 |
|---|---|---|
| committer | proven <proven@NetBSD.org> | 1994-02-07 22:02:26 +0000 |
| commit | 0ddc616639d6536ea4ec43cb1c482f1ab9cc25a4 (patch) | |
| tree | 536eb985a4fff1b2f88cdf7fc76e1e4cebd3b262 /lib/libpthread | |
| parent | 21f4b3b04c1e5cb64e95a000a1ea81a6cfaf9502 (diff) | |
RCS ids added.
pthread_once() defines moved to separate header file.
Diffstat (limited to 'lib/libpthread')
| -rw-r--r-- | lib/libpthread/include/Makefile.inc | 2 | ||||
| -rw-r--r-- | lib/libpthread/include/cond.h | 2 | ||||
| -rw-r--r-- | lib/libpthread/include/fd.h | 4 | ||||
| -rw-r--r-- | lib/libpthread/include/fd_pipe.h | 2 | ||||
| -rw-r--r-- | lib/libpthread/include/kernel.h | 4 | ||||
| -rw-r--r-- | lib/libpthread/include/mutex.h | 4 | ||||
| -rw-r--r-- | lib/libpthread/include/posix.h | 51 | ||||
| -rw-r--r-- | lib/libpthread/include/pthread.h | 42 | ||||
| -rw-r--r-- | lib/libpthread/include/pthread_attr.h | 2 | ||||
| -rw-r--r-- | lib/libpthread/include/pthread_once.h | 53 | ||||
| -rw-r--r-- | lib/libpthread/include/queue.h | 2 | ||||
| -rw-r--r-- | lib/libpthread/include/stdio.h | 354 | ||||
| -rw-r--r-- | lib/libpthread/include/util.h | 14 |
13 files changed, 482 insertions, 54 deletions
diff --git a/lib/libpthread/include/Makefile.inc b/lib/libpthread/include/Makefile.inc index 3317d565155..77d9812781b 100644 --- a/lib/libpthread/include/Makefile.inc +++ b/lib/libpthread/include/Makefile.inc @@ -7,7 +7,7 @@ FILES= cond.h copyright.h fd.h fd_pipe.h kernel.h mutex.h posix.h \ - pthread.h pthread_attr.h queue.h util.h engine.h + pthread.h pthread_attr.h queue.h util.h engine.h pthread_once.h realinstall: if [ ! -d ${DESTDIR}/usr/include/pthread ]; then \ diff --git a/lib/libpthread/include/cond.h b/lib/libpthread/include/cond.h index 82c064eac02..aa64bb0ec33 100644 --- a/lib/libpthread/include/cond.h +++ b/lib/libpthread/include/cond.h @@ -29,6 +29,8 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * + * $Id: cond.h,v 1.3 1994/02/07 22:02:28 proven Exp $ $provenid: cond.h,v 1.17 1994/02/07 03:31:53 proven Exp $ + * * Description : mutex header. * * 1.00 93/10/30 proven diff --git a/lib/libpthread/include/fd.h b/lib/libpthread/include/fd.h index 9ce728a6f45..e6ab2475b18 100644 --- a/lib/libpthread/include/fd.h +++ b/lib/libpthread/include/fd.h @@ -29,6 +29,8 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * + * $Id: fd.h,v 1.3 1994/02/07 22:02:29 proven Exp $ $provenid: fd.h,v 1.17 1994/02/07 03:31:54 proven Exp $ + * * Description : Basic fd header. * * 1.00 93/08/14 proven @@ -58,9 +60,9 @@ struct fd_ops { int (*read)(); int (*close)(); int (*fcntl)(); - int (*writev)(); int (*readv)(); + int (*seek)(); }; union fd_data { diff --git a/lib/libpthread/include/fd_pipe.h b/lib/libpthread/include/fd_pipe.h index 1ac1471d1a8..59aa20de554 100644 --- a/lib/libpthread/include/fd_pipe.h +++ b/lib/libpthread/include/fd_pipe.h @@ -29,6 +29,8 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * + * $Id: fd_pipe.h,v 1.3 1994/02/07 22:02:29 proven Exp $ $provenid: fd_pipe.h,v 1.17 1994/02/07 03:31:56 proven Exp $ + * * Description : The new fast ITC pipe header. * * 1.00 93/08/14 proven diff --git a/lib/libpthread/include/kernel.h b/lib/libpthread/include/kernel.h index 53e104e07e6..e0c2d776641 100644 --- a/lib/libpthread/include/kernel.h +++ b/lib/libpthread/include/kernel.h @@ -29,12 +29,14 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * + * $Id: kernel.h,v 1.3 1994/02/07 22:02:30 proven Exp $ $provenid: kernel.h,v 1.17 1994/02/07 03:31:57 proven Exp $ + * * Description : mutex header. * * 1.00 93/07/22 proven * -Started coding this file. */ - + /* * Defines only for the pthread user kernel. */ diff --git a/lib/libpthread/include/mutex.h b/lib/libpthread/include/mutex.h index 2afc727219d..885b927e5ee 100644 --- a/lib/libpthread/include/mutex.h +++ b/lib/libpthread/include/mutex.h @@ -29,12 +29,14 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * + * $Id: mutex.h,v 1.3 1994/02/07 22:02:31 proven Exp $ $provenid: mutex.h,v 1.17 1994/02/07 03:31:59 proven Exp $ + * * Description : mutex header. * * 1.00 93/07/20 proven * -Started coding this file. */ - + /* * New mutex structures */ diff --git a/lib/libpthread/include/posix.h b/lib/libpthread/include/posix.h index 7a285273fa3..a393f3207f4 100644 --- a/lib/libpthread/include/posix.h +++ b/lib/libpthread/include/posix.h @@ -1,54 +1,21 @@ /* ==== posix.h ============================================================ - * Copyright (c) 1993 by Chris Provenzano, proven@mit.edu - * All rights reserved. + * Copyright (c) 1993 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. - * 4. The name of Chris Provenzano may not be used to endorse or promote - * products derived from this software without specific prior written - * permission. + * Description : Convert an Ultrix-4.2 system to a more or less POSIX system. * - * 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 : Convert a system to a more or less POSIX system. + * $Id: posix.h,v 1.3 1994/02/07 22:02:32 proven Exp $ $provenid: posix-netbsd-0.9.h,v 1.17 1994/02/07 03:32:24 proven Exp $ * * 1.00 93/07/20 proven * -Started coding this file. */ -#ifndef O_NONBLOCK -#ifdef FNDELAY -#define O_NONBLOCK FNDELAY -#endif -#endif +#ifndef _PTHREAD_POSIX_H_ +#define _PTHREAD_POSIX_H_ -#ifndef O_ACCMODE -#define O_ACCMODE (O_RDONLY|O_RDWR|O_WRONLY) -#endif +#include <sys/cdefs.h> -#ifndef S_ISREG -#define S_ISREG(x) ((x & S_IFMT) == S_IFREG) -#endif - -#ifndef __ibm032__ +/* Make sure we have size_t defined */ #include <stdlib.h> +#include <stdarg.h> + #endif diff --git a/lib/libpthread/include/pthread.h b/lib/libpthread/include/pthread.h index 1652b42ab5b..3675be7df20 100644 --- a/lib/libpthread/include/pthread.h +++ b/lib/libpthread/include/pthread.h @@ -29,12 +29,14 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * + * $Id: pthread.h,v 1.4 1994/02/07 22:02:33 proven Exp $ $provenid: pthread.h,v 1.17 1994/02/07 03:32:00 proven Exp $ + * * Description : Basic pthread header. * * 1.00 93/07/20 proven * -Started coding this file. */ - + #include <pthread/engine.h> #include <pthread/kernel.h> #include <pthread/queue.h> @@ -43,10 +45,12 @@ #include <pthread/fd.h> #include <pthread/util.h> -/* #include <pthread/stdio.h> Because I'm a moron -- proven */ #include <errno.h> -/* More includes, that need size_t or NULL */ +/* More includes */ +#include <pthread/pthread_once.h> + +/* More includes, that need size_t */ #include <pthread/pthread_attr.h> enum pthread_state { @@ -57,30 +61,51 @@ enum pthread_state { PS_FDLW_WAIT, PS_FDR_WAIT, PS_FDW_WAIT, + PS_SLEEP_WAIT, + PS_JOIN, PS_DEAD }; +#define PF_DETACHED 0x00000001 + struct pthread { struct machdep_pthread machdep_data; - struct pthread_queue *queue; enum pthread_state state; pthread_attr_t attr; + /* Other flags */ + int flags; + + /* Time until timeout */ + int time_sec; + int time_usec; + + /* Join queue for waiting threads */ + struct pthread_queue join_queue; + + /* Queue thread is waiting on, (mutexes, cond. etc.) */ + struct pthread_queue *queue; + /* * Thread implementations are just multiple queue type implemenations, * Below are the various link lists currently necessary * It is possible for a thread to be on multiple, or even all the * queues at once, much care must be taken during queue manipulation. + * + * The pthread structure must be locked before you can even look at + * the link lists. */ + struct pthread *pll; /* ALL threads, in any state */ - /* struct pthread *rll; /* Current run queue, before resced */ + /* struct pthread *rll; Current run queue, before resced */ + struct pthread *sll; /* For sleeping threads */ struct pthread *next; /* Standard for mutexes, etc ... */ - struct pthread *s_next; /* For sleeping threads */ - /* struct pthread *fd_next; /* For kernel fd operations */ + /* struct pthread *fd_next; For kernel fd operations */ int fd; /* Used when thread waiting on fd */ semaphore lock; + void *ret; int error; }; @@ -102,11 +127,14 @@ extern struct fd_table_entry *fd_table[]; __BEGIN_DECLS +void pthread_init __P((void)); int pthread_create __P((pthread_t *, const pthread_attr_t *, void * (*start_routine)(void *), void *)); void pthread_exit __P((void *)); pthread_t pthread_self __P((void)); int pthread_equal __P((pthread_t, pthread_t)); +int pthread_join __P((pthread_t, void **)); +int pthread_detach __P((pthread_t)); #if defined(PTHREAD_KERNEL) diff --git a/lib/libpthread/include/pthread_attr.h b/lib/libpthread/include/pthread_attr.h index ba64d25f325..f4718e1def5 100644 --- a/lib/libpthread/include/pthread_attr.h +++ b/lib/libpthread/include/pthread_attr.h @@ -29,6 +29,8 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * + * $Id: pthread_attr.h,v 1.3 1994/02/07 22:02:34 proven Exp $ $provenid: pthread_attr.h,v 1.17 1994/02/07 03:32:02 proven Exp $ + * * Description : Basic pthread attributes header. * * 1.00 93/11/03 proven diff --git a/lib/libpthread/include/pthread_once.h b/lib/libpthread/include/pthread_once.h new file mode 100644 index 00000000000..aeb14e35f6a --- /dev/null +++ b/lib/libpthread/include/pthread_once.h @@ -0,0 +1,53 @@ +/* ==== 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 1994/02/07 22:02:35 proven Exp $ $provenid: pthread_once.h,v 1.17 1994/02/07 03:32:04 proven Exp $ + * + * Description : mutex header. + * + * 1.00 93/12/12 proven + * -Started coding this file. + */ + +/* New pthread_once structures */ +typedef int pthread_once_t; + +/* Static pthread_once_t initialization value. */ +#define PTHREAD_ONCE_INIT 0 + +/* New functions */ + +__BEGIN_DECLS + +int pthread_once __P((pthread_once_t *, void (*init_routine)(void))); + +__END_DECLS + diff --git a/lib/libpthread/include/queue.h b/lib/libpthread/include/queue.h index 687df490712..367e26be717 100644 --- a/lib/libpthread/include/queue.h +++ b/lib/libpthread/include/queue.h @@ -29,6 +29,8 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * + * $Id: queue.h,v 1.3 1994/02/07 22:02:36 proven Exp $ $provenid: queue.h,v 1.17 1994/02/07 03:39:52 proven Exp $ + * * Description : mutex header. * * 1.00 93/07/20 proven diff --git a/lib/libpthread/include/stdio.h b/lib/libpthread/include/stdio.h new file mode 100644 index 00000000000..f97291e72e5 --- /dev/null +++ b/lib/libpthread/include/stdio.h @@ -0,0 +1,354 @@ +/* ==== stdio.h ============================================================ + * Copyright (c) 1990 The Regents of the University of California. + * Copyright (c) 1993 by Chris Provenzano, proven@mit.edu + * All rights reserved. + * + * This code is derived from software contributed to Berkeley by + * Chris Torek. + * + * 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. + * + * from: @(#)stdio.h 5.17 (Berkeley) 6/3/91 + * $Id: stdio.h,v 1.1 1994/02/07 22:02:37 proven Exp $ $provenid: stdio.h,v 1.18 1994/02/07 03:32:06 proven Exp $ + */ + +#ifndef _STDIO_H_ +#define _STDIO_H_ + +#include <sys/cdefs.h> +#include <pthread/posix.h> + +#ifndef NULL +#define NULL 0 +#endif + +typedef long fpos_t; /* Must match off_t <sys/types.h> */ + +#define _FSTDIO /* Define for new stdio with functions. */ + +/* + * NB: to fit things in six character monocase externals, the stdio + * code uses the prefix `__s' for stdio objects, typically followed + * by a three-character attempt at a mnemonic. + */ + +/* stdio buffers */ +struct __sbuf { + unsigned char *_base; + int _size; +}; + +/* + * stdio state variables. + * + * The following always hold: + * + * if (_flags&(__SLBF|__SWR)) == (__SLBF|__SWR), + * _lbfsize is -_bf._size, else _lbfsize is 0 + * if _flags&__SRD, _w is 0 + * if _flags&__SWR, _r is 0 + * + * This ensures that the getc and putc macros (or inline functions) never + * try to write or read from a file that is in `read' or `write' mode. + * (Moreover, they can, and do, automatically switch from read mode to + * write mode, and back, on "r+" and "w+" files.) + * + * _lbfsize is used only to make the inline line-buffered output stream + * code as compact as possible. + * + * _ub, _up, and _ur are used when ungetc() pushes back more characters + * than fit in the current _bf, or when ungetc() pushes back a character + * that does not match the previous one in _bf. When this happens, + * _ub._base becomes non-nil (i.e., a stream has ungetc() data iff + * _ub._base!=NULL) and _up and _ur save the current values of _p and _r. + */ +typedef struct __sFILE { + unsigned char *_p; /* current position in (some) buffer */ + int _r; /* read space left for getc() */ + int _w; /* write space left for putc() */ + short _flags; /* flags, below; this FILE is free if 0 */ + short _file; /* fileno, if Unix descriptor, else -1 */ + struct __sbuf _bf; /* the buffer (at least 1 byte, if !NULL) */ + int _lbfsize; /* 0 or -_bf._size, for inline putc */ + + /* separate buffer for long sequences of ungetc() */ + struct __sbuf _ub; /* ungetc buffer */ + unsigned char *_up; /* saved _p when _p is doing ungetc data */ + int _ur; /* saved _r when _r is counting ungetc data */ + + /* tricks to meet minimum requirements even when malloc() fails */ + unsigned char _ubuf[3]; /* guarantee an ungetc() buffer */ + unsigned char _nbuf[1]; /* guarantee a getc() buffer */ + + /* separate buffer for fgetline() when line crosses buffer boundary */ + struct __sbuf _lb; /* buffer for fgetline() */ + + /* Unix stdio files get aligned to block boundaries on fseek() */ + int _blksize; /* stat.st_blksize (may be != _bf._size) */ + int _offset; /* current lseek offset */ +} FILE; + +__BEGIN_DECLS +extern FILE __sF[]; +__END_DECLS + +#define __SLBF 0x0001 /* line buffered */ +#define __SNBF 0x0002 /* unbuffered */ +#define __SRD 0x0004 /* OK to read */ +#define __SWR 0x0008 /* OK to write */ + /* RD and WR are never simultaneously asserted */ +#define __SRW 0x0010 /* open for reading & writing */ +#define __SEOF 0x0020 /* found EOF */ +#define __SERR 0x0040 /* found error */ +#define __SMBF 0x0080 /* _buf is from malloc */ +#define __SAPP 0x0100 /* fdopen()ed in append mode */ +#define __SSTR 0x0200 /* this is an sprintf/snprintf string */ +#define __SOPT 0x0400 /* do fseek() optimisation */ +#define __SNPT 0x0800 /* do not do fseek() optimisation */ +#define __SOFF 0x1000 /* set iff _offset is in fact correct */ +#define __SMOD 0x2000 /* true => fgetline modified _p text */ + +/* + * The following three definitions are for ANSI C, which took them + * from System V, which brilliantly took internal interface macros and + * made them official arguments to setvbuf(), without renaming them. + * Hence, these ugly _IOxxx names are *supposed* to appear in user code. + * + * Although numbered as their counterparts above, the implementation + * does not rely on this. + */ +#define _IOFBF 0 /* setvbuf should set fully buffered */ +#define _IOLBF 1 /* setvbuf should set line buffered */ +#define _IONBF 2 /* setvbuf should set unbuffered */ + +#define BUFSIZ 1024 /* size of buffer used by setbuf */ +#define EOF (-1) + +/* + * FOPEN_MAX is a minimum maximum, and should be the number of descriptors + * that the kernel can provide without allocation of a resource that can + * fail without the process sleeping. Do not use this for anything. + */ +#define FOPEN_MAX 20 /* must be <= OPEN_MAX <sys/syslimits.h> */ +#define FILENAME_MAX 1024 /* must be <= PATH_MAX <sys/syslimits.h> */ + +/* System V/ANSI C; this is the wrong way to do this, do *not* use these. */ +#ifndef _ANSI_SOURCE +#define P_tmpdir "/var/tmp/" +#endif +#define L_tmpnam 1024 /* XXX must be == PATH_MAX */ +#ifndef TMP_MAX +#define TMP_MAX 308915776 +#endif + +#ifndef SEEK_SET +#define SEEK_SET 0 /* set file offset to offset */ +#endif +#ifndef SEEK_CUR +#define SEEK_CUR 1 /* set file offset to current plus offset */ +#endif +#ifndef SEEK_END +#define SEEK_END 2 /* set file offset to EOF plus offset */ +#endif + +#define stdin (&__sF[0]) +#define stdout (&__sF[1]) +#define stderr (&__sF[2]) + +/* + * Functions defined in ANSI C standard. + */ +__BEGIN_DECLS +void clearerr __P((FILE *)); +int fclose __P((FILE *)); +int feof __P((FILE *)); +int ferror __P((FILE *)); +int fflush __P((FILE *)); +int fgetc __P((FILE *)); +int fgetpos __P((FILE *, fpos_t *)); +char * fgets __P((char *, size_t, FILE *)); +FILE * fopen __P((const char *, const char *)); +int fprintf __P((FILE *, const char *, ...)); +int fputc __P((int, FILE *)); +int fputs __P((const char *, FILE *)); +size_t fread __P((void *, size_t, size_t, FILE *)); +FILE * freopen __P((const char *, const char *, FILE *)); +int fscanf __P((FILE *, const char *, ...)); +int fseek __P((FILE *, long, int)); +int fsetpos __P((FILE *, const fpos_t *)); +long ftell __P((const FILE *)); +size_t fwrite __P((const void *, size_t, size_t, FILE *)); +int getc __P((FILE *)); +int getchar __P((void)); +char * gets __P((char *)); + +#if !defined(_ANSI_SOURCE) && !defined(_POSIX_SOURCE) +extern int sys_nerr; /* perror(3) external variables */ +extern char *sys_errlist[]; +#endif + +void perror __P((const char *)); +int printf __P((const char *, ...)); +int putc __P((int, FILE *)); +int putchar __P((int)); +int puts __P((const char *)); +int remove __P((const char *)); +int rename __P((const char *, const char *)); +void rewind __P((FILE *)); +int scanf __P((const char *, ...)); +void setbuf __P((FILE *, char *)); +int setvbuf __P((FILE *, char *, int, size_t)); +int sprintf __P((char *, const char *, ...)); +int sscanf __P((const char *, const char *, ...)); +FILE *tmpfile __P((void)); +char *tmpnam __P((char *)); +int ungetc __P((int, FILE *)); +int vfprintf __P((FILE *, const char *, va_list)); +int vprintf __P((const char *, va_list)); +int vsprintf __P((char *, const char *, va_list)); +__END_DECLS + +/* + * Functions defined in POSIX 1003.1. + */ +#ifndef _ANSI_SOURCE +#define L_ctermid 1024 /* size for ctermid(); PATH_MAX */ +#define L_cuserid 9 /* size for cuserid(); UT_NAMESIZE + 1 */ + +__BEGIN_DECLS +char *ctermid __P((char *)); +char *cuserid __P((char *)); +FILE *fdopen __P((int, const char *)); +int fileno __P((FILE *)); +__END_DECLS +#endif /* not ANSI */ + +/* + * Routines that are purely local. + */ +#if !defined (_ANSI_SOURCE) && !defined(_POSIX_SOURCE) +__BEGIN_DECLS +char *fgetline __P((FILE *, size_t *)); +int fpurge __P((FILE *)); +int getw __P((FILE *)); +int pclose __P((FILE *)); +FILE *popen __P((const char *, const char *)); +int putw __P((int, FILE *)); +void setbuffer __P((FILE *, char *, int)); +int setlinebuf __P((FILE *)); +char *tempnam __P((const char *, const char *)); +int snprintf __P((char *, size_t, const char *, ...)); +int vsnprintf __P((char *, size_t, const char *, va_list)); +int vscanf __P((const char *, va_list)); +int vsscanf __P((const char *, const char *, va_list)); +__END_DECLS + +/* + * This is a #define because the function is used internally and + * (unlike vfscanf) the name __svfscanf is guaranteed not to collide + * with a user function when _ANSI_SOURCE or _POSIX_SOURCE is defined. + */ +#define vfscanf __svfscanf + +/* + * Stdio function-access interface. + */ +__BEGIN_DECLS +FILE *funopen __P((const void *, + int (*)(void *, char *, int), + int (*)(void *, const char *, int), + fpos_t (*)(void *, fpos_t, int), + int (*)(void *))); +__END_DECLS +#define fropen(cookie, fn) funopen(cookie, fn, 0, 0, 0) +#define fwopen(cookie, fn) funopen(cookie, 0, fn, 0, 0) +#endif /* !_ANSI_SOURCE && !_POSIX_SOURCE */ + +/* + * Functions internal to the implementation. + */ +__BEGIN_DECLS +int __srget __P((FILE *)); +int __svfscanf __P((FILE *, const char *, va_list)); +int __swbuf __P((int, FILE *)); +__END_DECLS + +/* + * The __sfoo macros are here so that we can + * define function versions in the C library. + */ +#define __sgetc(p) (--(p)->_r < 0 ? __srget(p) : (int)(*(p)->_p++)) +static __inline int __getc(FILE *_p) +{ + int ret; + flockfile(_p); + ret = __sgetc(_p); + funlockfile(_p); + return(ret); +} + +#define getc(fp) __gets(fp) +#define getchar() getc(stdin) +#define getc_unlocked(fp) __sgetc(fp) +#define getchar_unlocked() getc_unlocked(stdin) + +static __inline int __sputc(int _c, FILE *_p) +{ + if (--_p->_w >= 0 || (_p->_w >= _p->_lbfsize && (char)_c != '\n')) + return (*_p->_p++ = _c); + else + return (__swbuf(_c, _p)); +} + +static __inline int __putc(int _c, FILE *_p) +{ + int ret; + flockfile(_p); + ret = __sputc(_c, _p); + funlockfile(_p); + return(ret); +} + +#define putc(x, fp) __putc(x, fp); +#define putchar(x) putc(x, stdout) +#define putc_unlocked(x, fp) __sputc(x, fp) +#define putchar_unlocked(x) putc_unlocked(x, stdout) + +#define __sfeof(p) (((p)->_flags & __SEOF) != 0) +#define __sferror(p) (((p)->_flags & __SERR) != 0) +#define __sfileno(p) ((p)->_file) + +#define feof(p) __sfeof(p) +#define ferror(p) __sferror(p) + +#ifndef _ANSI_SOURCE +#define fileno(p) __sfileno(p) +#endif + +#endif diff --git a/lib/libpthread/include/util.h b/lib/libpthread/include/util.h index 05e659a0f5a..bdd9106efef 100644 --- a/lib/libpthread/include/util.h +++ b/lib/libpthread/include/util.h @@ -1,5 +1,5 @@ /* ==== util.h ============================================================ - * Copyright (c) 1991, 1992, 1993 by Chris Provenzano, proven@mit.edu + * 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 @@ -29,6 +29,8 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * + * $Id: util.h,v 1.3 1994/02/07 22:02:38 proven Exp $ $provenid: util.h,v 1.15 1994/02/07 03:32:07 proven Exp $ + * * Description : Header file for generic utility functions. * * 91/08/31 proven - Added exchange. @@ -39,10 +41,16 @@ * 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 @@ -75,3 +83,7 @@ typedef enum Boolean { #define DEBUG2(s) #define DEBUG3(s) #endif + +#endif + +#endif |
