diff options
Diffstat (limited to 'lib')
229 files changed, 0 insertions, 28421 deletions
diff --git a/lib/csu/amd64/Makefile b/lib/csu/amd64/Makefile deleted file mode 100644 index ae195e85dfc3e..0000000000000 --- a/lib/csu/amd64/Makefile +++ /dev/null @@ -1,28 +0,0 @@ -# -# $Id: Makefile,v 1.2 1998/09/07 23:31:59 jdp Exp $ -# - -SRCS= crt1.c crtbegin.c crtend.c crti.S crtn.S -OBJS= ${SRCS:N*.h:R:S/$/.o/g} -OBJS+= gcrt1.o -SOBJS= crtbegin.So crtend.So -CFLAGS+= -elf -CFLAGS+= -Wall -Wno-unused -LDFLAGS+= -elf -NOMAN= true -NOPIC= true -NOPROFILE= true -INTERNALLIB= true - -all: ${OBJS} ${SOBJS} - -gcrt1.o: crt1.c - ${CC} ${CFLAGS} -DGCRT -c -o gcrt1.o ${.CURDIR}/crt1.c - -realinstall: -.for file in ${OBJS} ${SOBJS} - ${INSTALL} ${COPY} -o ${LIBOWN} -g ${LIBGRP} -m ${LIBMODE} \ - ${file} ${DESTDIR}${LIBDIR}/${file:S/.So$/S.o/} -.endfor - -.include <bsd.lib.mk> diff --git a/lib/csu/amd64/crt1.c b/lib/csu/amd64/crt1.c deleted file mode 100644 index d1dd43d0c361b..0000000000000 --- a/lib/csu/amd64/crt1.c +++ /dev/null @@ -1,102 +0,0 @@ -/*- - * Copyright 1996-1998 John D. Polstra. - * 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. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 AUTHOR 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: crt1.c,v 1.2 1998/09/07 23:31:59 jdp Exp $ - */ - -#ifndef __GNUC__ -#error "GCC is needed to compile this file" -#endif - -#include <stddef.h> -#include <stdlib.h> - -typedef void (*fptr)(void); - -extern void _fini(void); -extern void _init(void); -extern int main(int, char **, char **); - -#ifdef GCRT -extern void _mcleanup(void); -extern void monstartup(void *, void *); -extern int eprol; -extern int etext; -#endif - -extern int _DYNAMIC; -#pragma weak _DYNAMIC - -#ifdef __i386__ -#define get_rtld_cleanup() \ - ({ fptr __value; \ - __asm__("movl %%edx,%0" : "=rm"(__value)); \ - __value; }) -#else -#error "This file only supports the i386 architecture" -#endif - -char **environ; -char *__progname = ""; - -void -_start(char *arguments, ...) -{ - fptr rtld_cleanup; - int argc; - char **argv; - char **env; - - rtld_cleanup = get_rtld_cleanup(); - argv = &arguments; - argc = * (int *) (argv - 1); - env = argv + argc + 1; - environ = env; - if(argc > 0 && argv[0] != NULL) { - char *s; - __progname = argv[0]; - for (s = __progname; *s != '\0'; s++) - if (*s == '/') - __progname = s + 1; - } - - if(&_DYNAMIC != NULL) - atexit(rtld_cleanup); - -#ifdef GCRT - atexit(_mcleanup); -#endif - atexit(_fini); -#ifdef GCRT - monstartup(&eprol, &etext); -#endif - _init(); - exit( main(argc, argv, env) ); -} - -#ifdef GCRT -__asm__(".text"); -__asm__("eprol:"); -__asm__(".previous"); -#endif diff --git a/lib/csu/amd64/crti.S b/lib/csu/amd64/crti.S deleted file mode 100644 index 94e947d1d0796..0000000000000 --- a/lib/csu/amd64/crti.S +++ /dev/null @@ -1,38 +0,0 @@ -/*- - * Copyright 1996-1998 John D. Polstra. - * 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. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 AUTHOR 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: crti.S,v 1.2 1997/08/28 00:27:08 jdp Exp $ - */ - - .section .init,"ax",@progbits - .align 4 - .globl _init - .type _init,@function -_init: - - .section .fini,"ax",@progbits - .align 4 - .globl _fini - .type _fini,@function -_fini: diff --git a/lib/csu/amd64/crtn.S b/lib/csu/amd64/crtn.S deleted file mode 100644 index 8f280b26fd351..0000000000000 --- a/lib/csu/amd64/crtn.S +++ /dev/null @@ -1,32 +0,0 @@ -/*- - * Copyright 1996-1998 John D. Polstra. - * 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. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 AUTHOR 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: crtn.S,v 1.2 1997/08/28 00:27:09 jdp Exp $ - */ - - .section .init,"ax",@progbits - ret - - .section .fini,"ax",@progbits - ret diff --git a/lib/csu/common/crtbegin.c b/lib/csu/common/crtbegin.c deleted file mode 100644 index 9970d85196ba3..0000000000000 --- a/lib/csu/common/crtbegin.c +++ /dev/null @@ -1,61 +0,0 @@ -/*- - * Copyright 1996-1998 John D. Polstra. - * 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. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 AUTHOR 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: crtbegin.c,v 1.3 1996/04/12 02:24:35 jdp Exp $ - */ - -typedef void (*fptr)(void); - -static fptr ctor_list[1] __attribute__((section(".ctors"))) = { (fptr) -1 }; -static fptr dtor_list[1] __attribute__((section(".dtors"))) = { (fptr) -1 }; - -static void -do_ctors(void) -{ - fptr *fpp; - - for(fpp = ctor_list + 1; *fpp != 0; ++fpp) - (**fpp)(); -} - -static void -do_dtors(void) -{ - fptr *fpp; - - for(fpp = dtor_list + 1; *fpp != 0; ++fpp) - ; - while(--fpp > dtor_list) - (**fpp)(); -} - -static void -function_skeleton(void) -{ - __asm__(".section .init,\"ax\",@progbits"); - do_ctors(); - __asm__(".section .fini,\"ax\",@progbits"); - do_dtors(); - __asm__(".text"); -} diff --git a/lib/csu/common/crtend.c b/lib/csu/common/crtend.c deleted file mode 100644 index e1f22935616fd..0000000000000 --- a/lib/csu/common/crtend.c +++ /dev/null @@ -1,31 +0,0 @@ -/*- - * Copyright 1996-1998 John D. Polstra. - * 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. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 AUTHOR 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: crtend.c,v 1.3 1996/04/12 02:24:36 jdp Exp $ - */ - -typedef void (*fptr)(void); - -static fptr ctor_end[1] __attribute__((section(".ctors"))) = { 0 }; -static fptr dtor_end[1] __attribute__((section(".dtors"))) = { 0 }; diff --git a/lib/libc/amd64/SYS.h b/lib/libc/amd64/SYS.h deleted file mode 100644 index f11fa86128898..0000000000000 --- a/lib/libc/amd64/SYS.h +++ /dev/null @@ -1,92 +0,0 @@ -/*- - * Copyright (c) 1990 The Regents of the University of California. - * All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * William Jolitz. - * - * 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: @(#)SYS.h 5.5 (Berkeley) 5/7/91 - * - * $Id: SYS.h,v 1.11 1997/04/19 17:05:30 bde Exp $ - */ - -#include <sys/syscall.h> -#include "DEFS.h" - -#define SYSCALL(x) 2: PIC_PROLOGUE; jmp PIC_PLT(HIDENAME(cerror)); \ - ENTRY(__CONCAT(_,x)); \ - .weak CNAME(x); \ - .set CNAME(x),CNAME(__CONCAT(_,x)); \ - lea __CONCAT(SYS_,x),%eax; KERNCALL; jb 2b -#define RSYSCALL(x) SYSCALL(x); ret - -#define PSEUDO(x,y) ENTRY(__CONCAT(_,x)); \ - .weak CNAME(x); \ - .set CNAME(x),CNAME(__CONCAT(_,x)); \ - lea __CONCAT(SYS_,y), %eax; KERNCALL; ret -/* gas messes up offset -- although we don't currently need it, do for BCS */ -#define LCALL(x,y) .byte 0x9a ; .long y; .word x - -/* - * Design note: - * - * The macros PSYSCALL() and PRSYSCALL() are intended for use where a - * syscall needs to be renamed in the threaded library. When building - * a normal library, they default to the traditional SYSCALL() and - * RSYSCALL(). This avoids the need to #ifdef _THREAD_SAFE everywhere - * that the renamed function needs to be called. - */ -#ifdef _THREAD_SAFE -/* - * For the thread_safe versions, we prepend _thread_sys_ to the function - * name so that the 'C' wrapper can go around the real name. - */ -#define PSYSCALL(x) 2: PIC_PROLOGUE; jmp PIC_PLT(HIDENAME(cerror)); \ - ENTRY(__CONCAT(_thread_sys_,x)); \ - lea __CONCAT(SYS_,x),%eax; KERNCALL; jb 2b -#define PRSYSCALL(x) PSYSCALL(x); ret -#define PPSEUDO(x,y) ENTRY(__CONCAT(_thread_sys_,x)); \ - lea __CONCAT(SYS_,y), %eax; KERNCALL; ret -#else -/* - * The non-threaded library defaults to traditional syscalls where - * the function name matches the syscall name. - */ -#define PSYSCALL(x) SYSCALL(x) -#define PRSYSCALL(x) RSYSCALL(x) -#define PPSEUDO(x,y) PSEUDO(x,y) -#endif - -#ifdef __ELF__ -#define KERNCALL int $0x80 /* Faster */ -#else -#define KERNCALL LCALL(7,0) /* The old way */ -#endif diff --git a/lib/libc/amd64/gen/Makefile.inc b/lib/libc/amd64/gen/Makefile.inc deleted file mode 100644 index 5932d08f275d0..0000000000000 --- a/lib/libc/amd64/gen/Makefile.inc +++ /dev/null @@ -1,5 +0,0 @@ -# @(#)Makefile.inc 8.1 (Berkeley) 6/4/93 -# $Id: Makefile.inc,v 1.8 1997/02/22 14:58:33 peter Exp $ - -SRCS+= _setjmp.S alloca.S fabs.S frexp.c infinity.c isinf.c ldexp.c modf.S \ - setjmp.S sigsetjmp.S diff --git a/lib/libc/amd64/gen/_setjmp.S b/lib/libc/amd64/gen/_setjmp.S deleted file mode 100644 index 4f1d2c7c15a26..0000000000000 --- a/lib/libc/amd64/gen/_setjmp.S +++ /dev/null @@ -1,84 +0,0 @@ -/*- - * Copyright (c) 1990 The Regents of the University of California. - * All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * William Jolitz. - * - * 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. - * - * $Id: _setjmp.S,v 1.6 1997/02/22 14:58:34 peter Exp $ - */ - -#if defined(LIBC_RCS) && !defined(lint) - .text - .asciz "$Id: _setjmp.S,v 1.6 1997/02/22 14:58:34 peter Exp $" -#endif /* LIBC_RCS and not lint */ - -/* - * C library -- _setjmp, _longjmp - * - * _longjmp(a,v) - * will generate a "return(v)" from the last call to - * _setjmp(a) - * by restoring registers from the environment 'a'. - * The previous signal state is NOT restored. - */ - -#include "DEFS.h" - -ENTRY(_setjmp) - movl 4(%esp),%eax - movl 0(%esp),%edx - movl %edx, 0(%eax) /* rta */ - movl %ebx, 4(%eax) - movl %esp, 8(%eax) - movl %ebp,12(%eax) - movl %esi,16(%eax) - movl %edi,20(%eax) - fnstcw 28(%eax) - xorl %eax,%eax - ret - -ENTRY(_longjmp) - movl 4(%esp),%edx - movl 8(%esp),%eax - movl 0(%edx),%ecx - movl 4(%edx),%ebx - movl 8(%edx),%esp - movl 12(%edx),%ebp - movl 16(%edx),%esi - movl 20(%edx),%edi - fninit - fldcw 28(%edx) - testl %eax,%eax - jnz 1f - incl %eax -1: movl %ecx,0(%esp) - ret diff --git a/lib/libc/amd64/gen/frexp.c b/lib/libc/amd64/gen/frexp.c deleted file mode 100644 index aba48025ff5a9..0000000000000 --- a/lib/libc/amd64/gen/frexp.c +++ /dev/null @@ -1,67 +0,0 @@ -/*- - * Copyright (c) 1991, 1993 - * 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. - * - * $Id$ - */ - -#if defined(LIBC_RCS) && !defined(lint) -static const char rcsid[] = "$Id$"; -#endif /* LIBC_RCS and not lint */ - -#include <sys/types.h> -#include <math.h> - -double -frexp(value, eptr) - double value; - int *eptr; -{ - union { - double v; - struct { - u_int u_mant2 : 32; - u_int u_mant1 : 20; - u_int u_exp : 11; - u_int u_sign : 1; - } s; - } u; - - if (value) { - u.v = value; - *eptr = u.s.u_exp - 1022; - u.s.u_exp = 1022; - return(u.v); - } else { - *eptr = 0; - return((double)0); - } -} diff --git a/lib/libc/amd64/gen/infinity.c b/lib/libc/amd64/gen/infinity.c deleted file mode 100644 index e46f676a3f6df..0000000000000 --- a/lib/libc/amd64/gen/infinity.c +++ /dev/null @@ -1,9 +0,0 @@ -/* - * infinity.c - * $Id$ - */ - -#include <math.h> - -/* bytes for +Infinity on a 387 */ -char __infinity[] = { 0, 0, 0, 0, 0, 0, 0xf0, 0x7f }; diff --git a/lib/libc/amd64/gen/isinf.c b/lib/libc/amd64/gen/isinf.c deleted file mode 100644 index a796dcf90697c..0000000000000 --- a/lib/libc/amd64/gen/isinf.c +++ /dev/null @@ -1,68 +0,0 @@ -/*- - * Copyright (c) 1991, 1993 - * 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. - * - * $Id$ - */ - -#if defined(LIBC_RCS) && !defined(lint) -static const char rcsid[] = "$Id$"; -#endif /* LIBC_RCS and not lint */ - -#include <sys/types.h> - -int -isnan(d) - double d; -{ - register struct IEEEdp { - u_int manl : 32; - u_int manh : 20; - u_int exp : 11; - u_int sign : 1; - } *p = (struct IEEEdp *)&d; - - return(p->exp == 2047 && (p->manh || p->manl)); -} - -int -isinf(d) - double d; -{ - register struct IEEEdp { - u_int manl : 32; - u_int manh : 20; - u_int exp : 11; - u_int sign : 1; - } *p = (struct IEEEdp *)&d; - - return(p->exp == 2047 && !p->manh && !p->manl); -} diff --git a/lib/libc/amd64/gen/ldexp.c b/lib/libc/amd64/gen/ldexp.c deleted file mode 100644 index 8b63f528dc8c2..0000000000000 --- a/lib/libc/amd64/gen/ldexp.c +++ /dev/null @@ -1,74 +0,0 @@ -/*- - * Copyright (c) 1990, 1993 - * The Regents of the University of California. All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * Sean Eric Fagan. - * - * 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. - * - * $Id$ - */ - -#if defined(LIBC_RCS) && !defined(lint) -static const char rcsid[] = "$Id$"; -#endif /* LIBC_RCS and not lint */ - -/* - * ldexp(value, exp): return value * (2 ** exp). - * - * Written by Sean Eric Fagan (sef@kithrup.COM) - * Sun Mar 11 20:27:09 PST 1990 - */ - -/* - * We do the conversion in C to let gcc optimize it away, if possible. - * The "fxch ; fstp" stuff is because value is still on the stack - * (stupid 8087!). - */ -double -ldexp (double value, int exp) -{ - double temp, texp, temp2; - texp = exp; -#ifdef __GNUC__ -#if __GNUC__ >= 2 - asm ("fscale " - : "=u" (temp2), "=t" (temp) - : "0" (texp), "1" (value)); -#else - asm ("fscale ; fxch %%st(1) ; fstp%L1 %1 " - : "=f" (temp), "=0" (temp2) - : "0" (texp), "f" (value)); -#endif -#else -error unknown asm -#endif - return (temp); -} diff --git a/lib/libc/amd64/gen/setjmp.S b/lib/libc/amd64/gen/setjmp.S deleted file mode 100644 index 24884b19ebb30..0000000000000 --- a/lib/libc/amd64/gen/setjmp.S +++ /dev/null @@ -1,105 +0,0 @@ -/*- - * Copyright (c) 1990 The Regents of the University of California. - * All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * William Jolitz. - * - * 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. - * - * $Id: setjmp.S,v 1.7 1997/02/22 14:58:41 peter Exp $ - */ - -#if defined(LIBC_RCS) && !defined(lint) - .text - .asciz "$Id: setjmp.S,v 1.7 1997/02/22 14:58:41 peter Exp $" -#endif /* LIBC_RCS and not lint */ - -/* - * C library -- _setjmp, _longjmp - * - * longjmp(a,v) - * will generate a "return(v)" from the last call to - * setjmp(a) - * by restoring registers from the environment 'a'. - * The previous signal state is restored. - */ - -#include "DEFS.h" -#include "SYS.h" - -ENTRY(setjmp) - PIC_PROLOGUE - pushl $0 -#ifdef _THREAD_SAFE - call PIC_PLT(CNAME(_thread_sys_sigblock)) -#else - call PIC_PLT(CNAME(sigblock)) -#endif - popl %edx - PIC_EPILOGUE - movl 4(%esp),%ecx - movl 0(%esp),%edx - movl %edx, 0(%ecx) - movl %ebx, 4(%ecx) - movl %esp, 8(%ecx) - movl %ebp,12(%ecx) - movl %esi,16(%ecx) - movl %edi,20(%ecx) - movl %eax,24(%ecx) - fnstcw 28(%ecx) - xorl %eax,%eax - ret - -ENTRY(longjmp) - movl 4(%esp),%edx - PIC_PROLOGUE - pushl 24(%edx) -#ifdef _THREAD_SAFE - call PIC_PLT(CNAME(_thread_sys_sigsetmask)) -#else - call PIC_PLT(CNAME(sigsetmask)) /* XXX this is not reentrant */ -#endif - popl %eax - PIC_EPILOGUE - movl 4(%esp),%edx - movl 8(%esp),%eax - movl 0(%edx),%ecx - movl 4(%edx),%ebx - movl 8(%edx),%esp - movl 12(%edx),%ebp - movl 16(%edx),%esi - movl 20(%edx),%edi - fninit - fldcw 28(%edx) - testl %eax,%eax - jnz 1f - incl %eax -1: movl %ecx,0(%esp) - ret diff --git a/lib/libc/amd64/gen/sigsetjmp.S b/lib/libc/amd64/gen/sigsetjmp.S deleted file mode 100644 index 8e4929494bf7c..0000000000000 --- a/lib/libc/amd64/gen/sigsetjmp.S +++ /dev/null @@ -1,117 +0,0 @@ -/*- - * Copyright (c) 1990 The Regents of the University of California. - * All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * William Jolitz. - * - * 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. - * - * $Id: sigsetjmp.S,v 1.10 1997/02/22 14:58:43 peter Exp $ - */ - -#if defined(LIBC_RCS) && !defined(lint) - .text - .asciz "$Id: sigsetjmp.S,v 1.10 1997/02/22 14:58:43 peter Exp $" -#endif /* LIBC_RCS and not lint */ - -#include "DEFS.h" -#include "SYS.h" - -/*- - * TODO: - * Rename sigsetjmp to __sigsetjmp and siglongjmp to __siglongjmp, - * remove the other *jmp functions and define everything in terms - * of the renamed functions. This requires compiler support for - * the renamed functions (introduced in gcc-2.5.3; previous versions - * only supported *jmp with 0 or 1 leading underscores). - * - * Use sigprocmask() instead of sigblock() and sigsetmask(), and - * check for and handle errors. - * - * Restore _all_ the registers and the signal mask atomically. Can - * use sigreturn() if sigreturn() works. - */ - -ENTRY(sigsetjmp) - movl 8(%esp),%eax - movl 4(%esp),%ecx - movl %eax,32(%ecx) - testl %eax,%eax - jz 2f - PIC_PROLOGUE - pushl $0 -#ifdef _THREAD_SAFE - call PIC_PLT(CNAME(_thread_sys_sigblock)) -#else - call PIC_PLT(CNAME(sigblock)) -#endif - addl $4,%esp - PIC_EPILOGUE - movl 4(%esp),%ecx - movl %eax,24(%ecx) -2: movl 0(%esp),%edx - movl %edx, 0(%ecx) - movl %ebx, 4(%ecx) - movl %esp, 8(%ecx) - movl %ebp,12(%ecx) - movl %esi,16(%ecx) - movl %edi,20(%ecx) - fnstcw 28(%ecx) - xorl %eax,%eax - ret - -ENTRY(siglongjmp) - movl 4(%esp),%edx - cmpl $0,32(%edx) - jz 2f - PIC_PROLOGUE - pushl 24(%edx) -#ifdef _THREAD_SAFE - call PIC_PLT(CNAME(_thread_sys_sigsetmask)) -#else - call PIC_PLT(CNAME(sigsetmask)) -#endif - addl $4,%esp - PIC_EPILOGUE -2: movl 4(%esp),%edx - movl 8(%esp),%eax - movl 0(%edx),%ecx - movl 4(%edx),%ebx - movl 8(%edx),%esp - movl 12(%edx),%ebp - movl 16(%edx),%esi - movl 20(%edx),%edi - fninit - fldcw 28(%edx) - testl %eax,%eax - jnz 1f - incl %eax -1: movl %ecx,0(%esp) - ret diff --git a/lib/libc/amd64/net/Makefile.inc b/lib/libc/amd64/net/Makefile.inc deleted file mode 100644 index dff7fd1066b7a..0000000000000 --- a/lib/libc/amd64/net/Makefile.inc +++ /dev/null @@ -1,4 +0,0 @@ -# @(#)Makefile.inc 8.1 (Berkeley) 6/4/93 -# $Id$ - -SRCS+= htonl.S htons.S ntohl.S ntohs.S diff --git a/lib/libc/amd64/net/htonl.S b/lib/libc/amd64/net/htonl.S deleted file mode 100644 index 095c40a6fa731..0000000000000 --- a/lib/libc/amd64/net/htonl.S +++ /dev/null @@ -1,53 +0,0 @@ -/*- - * Copyright (c) 1990 The Regents of the University of California. - * All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * William Jolitz. - * - * 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. - * - * $Id$ - */ - -#if defined(LIBC_RCS) && !defined(lint) - .text - .asciz "$Id$" -#endif /* LIBC_RCS and not lint */ - -/* netorder = htonl(hostorder) */ - -#include "DEFS.h" - -ENTRY(htonl) - movl 4(%esp),%eax - xchgb %al,%ah - roll $16,%eax - xchgb %al,%ah - ret diff --git a/lib/libc/amd64/net/htons.S b/lib/libc/amd64/net/htons.S deleted file mode 100644 index 238dfc24d36b0..0000000000000 --- a/lib/libc/amd64/net/htons.S +++ /dev/null @@ -1,51 +0,0 @@ -/*- - * Copyright (c) 1990 The Regents of the University of California. - * All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * William Jolitz. - * - * 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. - * - * $Id$ - */ - -#if defined(LIBC_RCS) && !defined(lint) - .text - .asciz "$Id$" -#endif /* LIBC_RCS and not lint */ - -/* netorder = htons(hostorder) */ - -#include "DEFS.h" - -ENTRY(htons) - movzwl 4(%esp),%eax - xchgb %al,%ah - ret diff --git a/lib/libc/amd64/net/ntohl.S b/lib/libc/amd64/net/ntohl.S deleted file mode 100644 index 5af5008c437bd..0000000000000 --- a/lib/libc/amd64/net/ntohl.S +++ /dev/null @@ -1,53 +0,0 @@ -/*- - * Copyright (c) 1990 The Regents of the University of California. - * All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * William Jolitz. - * - * 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. - * - * $Id$ - */ - -#if defined(LIBC_RCS) && !defined(lint) - .text - .asciz "$Id$" -#endif /* LIBC_RCS and not lint */ - -/* hostorder = ntohl(netorder) */ - -#include "DEFS.h" - -ENTRY(ntohl) - movl 4(%esp),%eax - xchgb %al,%ah - roll $16,%eax - xchgb %al,%ah - ret diff --git a/lib/libc/amd64/net/ntohs.S b/lib/libc/amd64/net/ntohs.S deleted file mode 100644 index 4bed4a2c19c8f..0000000000000 --- a/lib/libc/amd64/net/ntohs.S +++ /dev/null @@ -1,51 +0,0 @@ -/*- - * Copyright (c) 1990 The Regents of the University of California. - * All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * William Jolitz. - * - * 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. - * - * $Id$ - */ - -#if defined(LIBC_RCS) && !defined(lint) - .text - .asciz "$Id$" -#endif /* LIBC_RCS and not lint */ - -/* hostorder = ntohs(netorder) */ - -#include "DEFS.h" - -ENTRY(ntohs) - movzwl 4(%esp),%eax - xchgb %al,%ah - ret diff --git a/lib/libc/amd64/sys/Makefile.inc b/lib/libc/amd64/sys/Makefile.inc deleted file mode 100644 index 9446251f98a67..0000000000000 --- a/lib/libc/amd64/sys/Makefile.inc +++ /dev/null @@ -1,29 +0,0 @@ -# from: Makefile.inc,v 1.1 1993/09/03 19:04:23 jtc Exp -# $Id: Makefile.inc,v 1.11 1998/07/28 03:33:17 jlemon Exp $ - -SRCS+= i386_get_ioperm.c i386_get_ldt.c i386_set_ioperm.c i386_set_ldt.c \ - i386_vm86.c - -MDASM= Ovfork.S brk.S cerror.S exect.S fork.S pipe.S \ - ptrace.S reboot.S rfork.S sbrk.S setlogin.S sigpending.S \ - sigprocmask.S sigreturn.S sigsuspend.S syscall.S - -# Don't generate default code for these syscalls: -NOASM= __semctl.o break.o exit.o ftruncate.o getdomainname.o getlogin.o \ - lseek.o mlockall.o mmap.o msgctl.o msgget.o msgrcv.o msgsnd.o \ - munlockall.o openbsd_poll.o semconfig.o semget.o semop.o \ - setdomainname.o shmat.o shmctl.o shmdt.o shmget.o sstk.o \ - thr_sleep.o thr_wakeup.o truncate.o uname.o vfork.o yield.o - -PSEUDO= _getlogin.o - -# Pseudo syscalls that are renamed as _thread_sys_{pseudo} when -# building libc_r. -PSEUDOR= _exit.o - -.if ${LIB} == "c" -MAN2+= i386_get_ioperm.2 i386_get_ldt.2 i386_vm86.2 - -MLINKS+=i386_get_ioperm.2 i386_set_ioperm.2 -MLINKS+=i386_get_ldt.2 i386_set_ldt.2 -.endif diff --git a/lib/libc/amd64/sys/brk.S b/lib/libc/amd64/sys/brk.S deleted file mode 100644 index 4fdf0c637146a..0000000000000 --- a/lib/libc/amd64/sys/brk.S +++ /dev/null @@ -1,91 +0,0 @@ -/*- - * Copyright (c) 1990 The Regents of the University of California. - * All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * William Jolitz. - * - * 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. - * - * $Id$ - */ - -#if defined(SYSLIBC_RCS) && !defined(lint) - .text - .asciz "$Id$" -#endif /* SYSLIBC_RCS and not lint */ - -#include "SYS.h" - - .globl HIDENAME(curbrk) - .globl HIDENAME(minbrk) -ENTRY(_brk) - jmp ok - -ENTRY(brk) -#ifdef PIC - movl 4(%esp),%eax - PIC_PROLOGUE - movl PIC_GOT(HIDENAME(curbrk)),%edx # set up GOT addressing - movl PIC_GOT(HIDENAME(minbrk)),%ecx # - PIC_EPILOGUE - cmpl %eax,(%ecx) - jbe ok - movl (%ecx),%eax - movl %eax,4(%esp) -ok: - lea SYS_break,%eax - KERNCALL - jb err - movl 4(%esp),%eax - movl %eax,(%edx) - movl $0,%eax - ret -err: - PIC_PROLOGUE - jmp PIC_PLT(HIDENAME(cerror)) - -#else - - movl 4(%esp),%eax - cmpl %eax,HIDENAME(minbrk) - jbe ok - movl HIDENAME(minbrk),%eax - movl %eax,4(%esp) -ok: - lea SYS_break,%eax - KERNCALL - jb err - movl 4(%esp),%eax - movl %eax,HIDENAME(curbrk) - movl $0,%eax - ret -err: - jmp HIDENAME(cerror) -#endif diff --git a/lib/libc/amd64/sys/cerror.S b/lib/libc/amd64/sys/cerror.S deleted file mode 100644 index d3e74eb9141c5..0000000000000 --- a/lib/libc/amd64/sys/cerror.S +++ /dev/null @@ -1,70 +0,0 @@ -/*- - * Copyright (c) 1990 The Regents of the University of California. - * All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * William Jolitz. - * - * 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. - * - * $Id: cerror.S,v 1.8 1997/02/22 14:59:29 peter Exp $ - */ - -#if defined(SYSLIBC_RCS) && !defined(lint) - .text - .asciz "$Id: cerror.S,v 1.8 1997/02/22 14:59:29 peter Exp $" -#endif /* SYSLIBC_RCS and not lint */ - -#include "SYS.h" - - .globl HIDENAME(cerror) - - /* - * The __error() function is thread aware. For non-threaded - * programs and the initial threaded in threaded programs, - * it returns a pointer to the global errno variable. - */ - .globl CNAME(__error) - .type CNAME(__error),@function -HIDENAME(cerror): - pushl %eax -#ifdef PIC - /* The caller must execute the PIC prologue before jumping to cerror. */ - call PIC_PLT(CNAME(__error)) - popl %ecx - PIC_EPILOGUE -#else - call CNAME(__error) - popl %ecx -#endif - movl %ecx,(%eax) - movl $-1,%eax - movl $-1,%edx - ret - diff --git a/lib/libc/amd64/sys/exect.S b/lib/libc/amd64/sys/exect.S deleted file mode 100644 index af0d2ee391a39..0000000000000 --- a/lib/libc/amd64/sys/exect.S +++ /dev/null @@ -1,56 +0,0 @@ -/*- - * Copyright (c) 1990 The Regents of the University of California. - * All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * William Jolitz. - * - * 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. - * - * $Id$ - */ - -#if defined(SYSLIBC_RCS) && !defined(lint) - .text - .asciz "$Id$" -#endif /* SYSLIBC_RCS and not lint */ - -#include "SYS.h" -#include <machine/psl.h> - -ENTRY(exect) - lea SYS_execve,%eax - pushf - popl %edx - orl $ PSL_T,%edx - pushl %edx - popf - KERNCALL - PIC_PROLOGUE - jmp PIC_PLT(HIDENAME(cerror)) /* exect(file, argv, env); */ diff --git a/lib/libc/amd64/sys/pipe.S b/lib/libc/amd64/sys/pipe.S deleted file mode 100644 index 637b86f9f0b1c..0000000000000 --- a/lib/libc/amd64/sys/pipe.S +++ /dev/null @@ -1,51 +0,0 @@ -/*- - * Copyright (c) 1990 The Regents of the University of California. - * All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * William Jolitz. - * - * 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. - * - * $Id$ - */ - -#if defined(SYSLIBC_RCS) && !defined(lint) - .text - .asciz "$Id$" -#endif /* SYSLIBC_RCS and not lint */ - -#include "SYS.h" - -PSYSCALL(pipe) - movl 4(%esp),%ecx - movl %eax,(%ecx) - movl %edx,4(%ecx) - movl $0,%eax - ret diff --git a/lib/libc/amd64/sys/ptrace.S b/lib/libc/amd64/sys/ptrace.S deleted file mode 100644 index 018a02cf94edb..0000000000000 --- a/lib/libc/amd64/sys/ptrace.S +++ /dev/null @@ -1,62 +0,0 @@ -/*- - * Copyright (c) 1990 The Regents of the University of California. - * All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * William Jolitz. - * - * 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. - * - * $Id$ - */ - -#if defined(SYSLIBC_RCS) && !defined(lint) - .text - .asciz "$Id$" -#endif /* SYSLIBC_RCS and not lint */ - -#include "SYS.h" - -ENTRY(ptrace) - xorl %eax,%eax -#ifdef PIC - PIC_PROLOGUE - movl PIC_GOT(CNAME(errno)),%edx - movl %eax,(%edx) - PIC_EPILOGUE -#else - movl %eax,CNAME(errno) -#endif - lea SYS_ptrace,%eax - KERNCALL - jb err - ret -err: - PIC_PROLOGUE - jmp PIC_PLT(HIDENAME(cerror)) diff --git a/lib/libc/amd64/sys/reboot.S b/lib/libc/amd64/sys/reboot.S deleted file mode 100644 index 70049b249b1df..0000000000000 --- a/lib/libc/amd64/sys/reboot.S +++ /dev/null @@ -1,47 +0,0 @@ -/*- - * Copyright (c) 1990 The Regents of the University of California. - * All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * William Jolitz. - * - * 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. - * - * $Id$ - */ - -#if defined(SYSLIBC_RCS) && !defined(lint) - .text - .asciz "$Id$" -#endif /* SYSLIBC_RCS and not lint */ - -#include "SYS.h" - -SYSCALL(reboot) - iret diff --git a/lib/libc/amd64/sys/sbrk.S b/lib/libc/amd64/sys/sbrk.S deleted file mode 100644 index a3afd89079009..0000000000000 --- a/lib/libc/amd64/sys/sbrk.S +++ /dev/null @@ -1,95 +0,0 @@ -/*- - * Copyright (c) 1990 The Regents of the University of California. - * All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * William Jolitz. - * - * 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. - * - * $Id$ - */ - -#if defined(SYSLIBC_RCS) && !defined(lint) - .text - .asciz "$Id$" -#endif /* SYSLIBC_RCS and not lint */ - -#include "SYS.h" - - .globl CNAME(end) - .globl HIDENAME(minbrk) - .globl HIDENAME(curbrk) - - .data -HIDENAME(minbrk): .long CNAME(end) -HIDENAME(curbrk): .long CNAME(end) - .text - -ENTRY(sbrk) -#ifdef PIC - movl 4(%esp),%ecx - PIC_PROLOGUE - movl PIC_GOT(HIDENAME(curbrk)),%edx - movl (%edx),%eax - PIC_EPILOGUE - testl %ecx,%ecx - jz back - addl %eax,4(%esp) - lea SYS_break,%eax - KERNCALL - jb err - PIC_PROLOGUE - movl PIC_GOT(HIDENAME(curbrk)),%edx - movl (%edx),%eax - addl %ecx,(%edx) - PIC_EPILOGUE -back: - ret -err: - PIC_PROLOGUE - jmp PIC_PLT(HIDENAME(cerror)) - -#else /* !PIC */ - - movl 4(%esp),%ecx - movl HIDENAME(curbrk),%eax - testl %ecx,%ecx - jz back - addl %eax,4(%esp) - lea SYS_break,%eax - KERNCALL - jb err - movl HIDENAME(curbrk),%eax - addl %ecx,HIDENAME(curbrk) -back: - ret -err: - jmp HIDENAME(cerror) -#endif /* PIC */ diff --git a/lib/libc/amd64/sys/setlogin.S b/lib/libc/amd64/sys/setlogin.S deleted file mode 100644 index 7bcf3bd886b34..0000000000000 --- a/lib/libc/amd64/sys/setlogin.S +++ /dev/null @@ -1,59 +0,0 @@ -/*- - * Copyright (c) 1991 The Regents of the University of California. - * All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * William Jolitz. - * - * 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. - * - * $Id$ - */ - -#if defined(LIBC_RCS) && !defined(lint) - .text - .asciz "$Id$" -#endif /* LIBC_RCS and not lint */ - -#include "SYS.h" - -.globl CNAME(_logname_valid) /* in getlogin() */ - -SYSCALL(setlogin) -#ifdef PIC - PIC_PROLOGUE - pushl %eax - movl PIC_GOT(CNAME(_logname_valid)),%eax - movl $0,(%eax) - popl %eax - PIC_EPILOGUE -#else - movl $0,CNAME(_logname_valid) -#endif - ret /* setlogin(name) */ diff --git a/lib/libc/amd64/sys/sigreturn.S b/lib/libc/amd64/sys/sigreturn.S deleted file mode 100644 index 65deb40ab6675..0000000000000 --- a/lib/libc/amd64/sys/sigreturn.S +++ /dev/null @@ -1,52 +0,0 @@ -/*- - * Copyright (c) 1990 The Regents of the University of California. - * All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * William Jolitz. - * - * 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. - * - * $Id$ - */ - -#if defined(SYSLIBC_RCS) && !defined(lint) - .text - .asciz "$Id$" -#endif /* SYSLIBC_RCS and not lint */ - -#include "SYS.h" - -/* - * NOTE: If the profiling ENTRY() code ever changes any registers, they - * must be saved. On FreeBSD, this is not the case. - */ - -PSYSCALL(sigreturn) - ret diff --git a/lib/libc/amd64/sys/vfork.S b/lib/libc/amd64/sys/vfork.S deleted file mode 100644 index 6a1d5b9aa86d0..0000000000000 --- a/lib/libc/amd64/sys/vfork.S +++ /dev/null @@ -1,72 +0,0 @@ -/*- - * Copyright (c) 1990 The Regents of the University of California. - * All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * William Jolitz. - * - * 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. - * - * $Id: Ovfork.S,v 1.9 1998/09/13 20:32:45 luoqi Exp $ - */ - -#if defined(SYSLIBC_RCS) && !defined(lint) - .text - .asciz "$Id: Ovfork.S,v 1.9 1998/09/13 20:32:45 luoqi Exp $" -#endif /* SYSLIBC_RCS and not lint */ - -#include "DEFS.h" -#include "SYS.h" - -/* - * pid = vfork(); - * - * %edx == 0 in parent process, %edx == 1 in child process. - * %eax == pid of child in parent, %eax == pid of parent in child. - * - */ - -#ifdef _THREAD_SAFE -ENTRY(_thread_sys_vfork) -#else -ENTRY(vfork) -#endif - popl %ecx /* my rta into ecx */ - lea SYS_vfork,%eax - KERNCALL - jb 2f - cmpl $0,%edx /* parent process? */ - je 1f /* yes */ - movl $0,%eax -1: - jmp %ecx -2: - pushl %ecx - PIC_PROLOGUE - jmp PIC_PLT(HIDENAME(cerror)) diff --git a/lib/libc/gen/__xuname.c b/lib/libc/gen/__xuname.c deleted file mode 100644 index 25431d4f9a9b7..0000000000000 --- a/lib/libc/gen/__xuname.c +++ /dev/null @@ -1,125 +0,0 @@ -/*- - * Copyright (c) 1994 - * 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. - */ - -#if defined(LIBC_SCCS) && !defined(lint) -/*static char sccsid[] = "From: @(#)uname.c 8.1 (Berkeley) 1/4/94";*/ -static const char rcsid[] = - "$Id$"; -#endif /* LIBC_SCCS and not lint */ - -#include <sys/param.h> -#include <sys/sysctl.h> -#include <sys/utsname.h> -#include <errno.h> - -int -uname(name) - struct utsname *name; -{ - int mib[2], rval; - size_t len; - char *p; - int oerrno; - - rval = 0; - - mib[0] = CTL_KERN; - mib[1] = KERN_OSTYPE; - len = sizeof(name->sysname); - oerrno = errno; - if (sysctl(mib, 2, &name->sysname, &len, NULL, 0) == -1) { - if(errno == ENOMEM) - errno = oerrno; - else - rval = -1; - } - name->sysname[sizeof(name->sysname) - 1] = '\0'; - - mib[0] = CTL_KERN; - mib[1] = KERN_HOSTNAME; - len = sizeof(name->nodename); - oerrno = errno; - if (sysctl(mib, 2, &name->nodename, &len, NULL, 0) == -1) { - if(errno == ENOMEM) - errno = oerrno; - else - rval = -1; - } - name->nodename[sizeof(name->nodename) - 1] = '\0'; - - mib[0] = CTL_KERN; - mib[1] = KERN_OSRELEASE; - len = sizeof(name->release); - oerrno = errno; - if (sysctl(mib, 2, &name->release, &len, NULL, 0) == -1) { - if(errno == ENOMEM) - errno = oerrno; - else - rval = -1; - } - name->release[sizeof(name->release) - 1] = '\0'; - - /* The version may have newlines in it, turn them into spaces. */ - mib[0] = CTL_KERN; - mib[1] = KERN_VERSION; - len = sizeof(name->version); - oerrno = errno; - if (sysctl(mib, 2, &name->version, &len, NULL, 0) == -1) { - if (errno == ENOMEM) - errno = oerrno; - else - rval = -1; - } - name->version[sizeof(name->version) - 1] = '\0'; - for (p = name->version; len--; ++p) { - if (*p == '\n' || *p == '\t') { - if (len > 1) - *p = ' '; - else - *p = '\0'; - } - } - - mib[0] = CTL_HW; - mib[1] = HW_MACHINE; - len = sizeof(name->machine); - oerrno = errno; - if (sysctl(mib, 2, &name->machine, &len, NULL, 0) == -1) { - if (errno == ENOMEM) - errno = oerrno; - else - rval = -1; - } - name->machine[sizeof(name->machine) - 1] = '\0'; - return (rval); -} diff --git a/lib/libc/gen/fts-compat.c b/lib/libc/gen/fts-compat.c deleted file mode 100644 index da88ed1394601..0000000000000 --- a/lib/libc/gen/fts-compat.c +++ /dev/null @@ -1,1040 +0,0 @@ -/* $OpenBSD: fts.c,v 1.9 1997/08/02 00:13:49 millert Exp $ */ - -/*- - * Copyright (c) 1990, 1993, 1994 - * 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. - */ - -#if defined(LIBC_SCCS) && !defined(lint) -static char sccsid[] = "@(#)fts.c 8.6 (Berkeley) 8/14/94"; -#endif /* LIBC_SCCS and not lint */ - -#include <sys/param.h> -#include <sys/stat.h> - -#include <dirent.h> -#include <errno.h> -#include <fcntl.h> -#include <fts.h> -#include <stdlib.h> -#include <string.h> -#include <unistd.h> - -static FTSENT *fts_alloc __P((FTS *, char *, int)); -static FTSENT *fts_build __P((FTS *, int)); -static void fts_lfree __P((FTSENT *)); -static void fts_load __P((FTS *, FTSENT *)); -static size_t fts_maxarglen __P((char * const *)); -static void fts_padjust __P((FTS *, void *)); -static int fts_palloc __P((FTS *, size_t)); -static FTSENT *fts_sort __P((FTS *, FTSENT *, int)); -static u_short fts_stat __P((FTS *, FTSENT *, int)); -static int fts_safe_changedir __P((FTS *, FTSENT *, int)); - -#define ISDOT(a) (a[0] == '.' && (!a[1] || (a[1] == '.' && !a[2]))) - -#define CLR(opt) (sp->fts_options &= ~(opt)) -#define ISSET(opt) (sp->fts_options & (opt)) -#define SET(opt) (sp->fts_options |= (opt)) - -#define CHDIR(sp, path) (!ISSET(FTS_NOCHDIR) && chdir(path)) -#define FCHDIR(sp, fd) (!ISSET(FTS_NOCHDIR) && fchdir(fd)) - -/* fts_build flags */ -#define BCHILD 1 /* fts_children */ -#define BNAMES 2 /* fts_children, names only */ -#define BREAD 3 /* fts_read */ - -FTS * -fts_open(argv, options, compar) - char * const *argv; - register int options; - int (*compar) __P((const FTSENT **, const FTSENT **)); -{ - register FTS *sp; - register FTSENT *p, *root; - register int nitems; - FTSENT *parent, *tmp; - int len; - - /* Options check. */ - if (options & ~FTS_OPTIONMASK) { - errno = EINVAL; - return (NULL); - } - - /* Allocate/initialize the stream */ - if ((sp = malloc((u_int)sizeof(FTS))) == NULL) - return (NULL); - memset(sp, 0, sizeof(FTS)); - sp->fts_compar = compar; - sp->fts_options = options; - - /* Logical walks turn on NOCHDIR; symbolic links are too hard. */ - if (ISSET(FTS_LOGICAL)) - SET(FTS_NOCHDIR); - - /* - * Start out with 1K of path space, and enough, in any case, - * to hold the user's paths. - */ - if (fts_palloc(sp, MAX(fts_maxarglen(argv), MAXPATHLEN))) - goto mem1; - - /* Allocate/initialize root's parent. */ - if ((parent = fts_alloc(sp, "", 0)) == NULL) - goto mem2; - parent->fts_level = FTS_ROOTPARENTLEVEL; - - /* Allocate/initialize root(s). */ - for (root = NULL, nitems = 0; *argv; ++argv, ++nitems) { - /* Don't allow zero-length paths. */ - if ((len = strlen(*argv)) == 0) { - errno = ENOENT; - goto mem3; - } - - p = fts_alloc(sp, *argv, len); - p->fts_level = FTS_ROOTLEVEL; - p->fts_parent = parent; - p->fts_accpath = p->fts_name; - p->fts_info = fts_stat(sp, p, ISSET(FTS_COMFOLLOW)); - - /* Command-line "." and ".." are real directories. */ - if (p->fts_info == FTS_DOT) - p->fts_info = FTS_D; - - /* - * If comparison routine supplied, traverse in sorted - * order; otherwise traverse in the order specified. - */ - if (compar) { - p->fts_link = root; - root = p; - } else { - p->fts_link = NULL; - if (root == NULL) - tmp = root = p; - else { - tmp->fts_link = p; - tmp = p; - } - } - } - if (compar && nitems > 1) - root = fts_sort(sp, root, nitems); - - /* - * Allocate a dummy pointer and make fts_read think that we've just - * finished the node before the root(s); set p->fts_info to FTS_INIT - * so that everything about the "current" node is ignored. - */ - if ((sp->fts_cur = fts_alloc(sp, "", 0)) == NULL) - goto mem3; - sp->fts_cur->fts_link = root; - sp->fts_cur->fts_info = FTS_INIT; - - /* - * If using chdir(2), grab a file descriptor pointing to dot to insure - * that we can get back here; this could be avoided for some paths, - * but almost certainly not worth the effort. Slashes, symbolic links, - * and ".." are all fairly nasty problems. Note, if we can't get the - * descriptor we run anyway, just more slowly. - */ - if (!ISSET(FTS_NOCHDIR) && (sp->fts_rfd = open(".", O_RDONLY, 0)) < 0) - SET(FTS_NOCHDIR); - - return (sp); - -mem3: fts_lfree(root); - free(parent); -mem2: free(sp->fts_path); -mem1: free(sp); - return (NULL); -} - -static void -fts_load(sp, p) - FTS *sp; - register FTSENT *p; -{ - register int len; - register char *cp; - - /* - * Load the stream structure for the next traversal. Since we don't - * actually enter the directory until after the preorder visit, set - * the fts_accpath field specially so the chdir gets done to the right - * place and the user can access the first node. From fts_open it's - * known that the path will fit. - */ - len = p->fts_pathlen = p->fts_namelen; - memmove(sp->fts_path, p->fts_name, len + 1); - if ((cp = strrchr(p->fts_name, '/')) && (cp != p->fts_name || cp[1])) { - len = strlen(++cp); - memmove(p->fts_name, cp, len + 1); - p->fts_namelen = len; - } - p->fts_accpath = p->fts_path = sp->fts_path; - sp->fts_dev = p->fts_dev; -} - -int -fts_close(sp) - FTS *sp; -{ - register FTSENT *freep, *p; - int saved_errno; - - /* - * This still works if we haven't read anything -- the dummy structure - * points to the root list, so we step through to the end of the root - * list which has a valid parent pointer. - */ - if (sp->fts_cur) { - for (p = sp->fts_cur; p->fts_level >= FTS_ROOTLEVEL;) { - freep = p; - p = p->fts_link ? p->fts_link : p->fts_parent; - free(freep); - } - free(p); - } - - /* Free up child linked list, sort array, path buffer. */ - if (sp->fts_child) - fts_lfree(sp->fts_child); - if (sp->fts_array) - free(sp->fts_array); - free(sp->fts_path); - - /* Return to original directory, save errno if necessary. */ - if (!ISSET(FTS_NOCHDIR)) { - saved_errno = fchdir(sp->fts_rfd) ? errno : 0; - (void)close(sp->fts_rfd); - } - - /* Set errno and return. */ - if (!ISSET(FTS_NOCHDIR) && saved_errno) { - /* Free up the stream pointer. */ - free(sp); - errno = saved_errno; - return (-1); - } - /* Free up the stream pointer. */ - free(sp); - return (0); -} - -/* - * Special case of "/" at the end of the path so that slashes aren't - * appended which would cause paths to be written as "....//foo". - */ -#define NAPPEND(p) \ - (p->fts_path[p->fts_pathlen - 1] == '/' \ - ? p->fts_pathlen - 1 : p->fts_pathlen) - -FTSENT * -fts_read(sp) - register FTS *sp; -{ - register FTSENT *p, *tmp; - register int instr; - register char *t; - int saved_errno; - - /* If finished or unrecoverable error, return NULL. */ - if (sp->fts_cur == NULL || ISSET(FTS_STOP)) - return (NULL); - - /* Set current node pointer. */ - p = sp->fts_cur; - - /* Save and zero out user instructions. */ - instr = p->fts_instr; - p->fts_instr = FTS_NOINSTR; - - /* Any type of file may be re-visited; re-stat and re-turn. */ - if (instr == FTS_AGAIN) { - p->fts_info = fts_stat(sp, p, 0); - return (p); - } - - /* - * Following a symlink -- SLNONE test allows application to see - * SLNONE and recover. If indirecting through a symlink, have - * keep a pointer to current location. If unable to get that - * pointer, follow fails. - */ - if (instr == FTS_FOLLOW && - (p->fts_info == FTS_SL || p->fts_info == FTS_SLNONE)) { - p->fts_info = fts_stat(sp, p, 1); - if (p->fts_info == FTS_D && !ISSET(FTS_NOCHDIR)) - if ((p->fts_symfd = open(".", O_RDONLY, 0)) < 0) { - p->fts_errno = errno; - p->fts_info = FTS_ERR; - } else - p->fts_flags |= FTS_SYMFOLLOW; - return (p); - } - - /* Directory in pre-order. */ - if (p->fts_info == FTS_D) { - /* If skipped or crossed mount point, do post-order visit. */ - if (instr == FTS_SKIP || - (ISSET(FTS_XDEV) && p->fts_dev != sp->fts_dev)) { - if (p->fts_flags & FTS_SYMFOLLOW) - (void)close(p->fts_symfd); - if (sp->fts_child) { - fts_lfree(sp->fts_child); - sp->fts_child = NULL; - } - p->fts_info = FTS_DP; - return (p); - } - - /* Rebuild if only read the names and now traversing. */ - if (sp->fts_child && ISSET(FTS_NAMEONLY)) { - CLR(FTS_NAMEONLY); - fts_lfree(sp->fts_child); - sp->fts_child = NULL; - } - - /* - * Cd to the subdirectory. - * - * If have already read and now fail to chdir, whack the list - * to make the names come out right, and set the parent errno - * so the application will eventually get an error condition. - * Set the FTS_DONTCHDIR flag so that when we logically change - * directories back to the parent we don't do a chdir. - * - * If haven't read do so. If the read fails, fts_build sets - * FTS_STOP or the fts_info field of the node. - */ - if (sp->fts_child) { - if (fts_safe_changedir(sp, p, -1)) { - p->fts_errno = errno; - p->fts_flags |= FTS_DONTCHDIR; - for (p = sp->fts_child; p; p = p->fts_link) - p->fts_accpath = - p->fts_parent->fts_accpath; - } - } else if ((sp->fts_child = fts_build(sp, BREAD)) == NULL) { - if (ISSET(FTS_STOP)) - return (NULL); - return (p); - } - p = sp->fts_child; - sp->fts_child = NULL; - goto name; - } - - /* Move to the next node on this level. */ -next: tmp = p; - if ((p = p->fts_link)) { - free(tmp); - - /* - * If reached the top, return to the original directory, and - * load the paths for the next root. - */ - if (p->fts_level == FTS_ROOTLEVEL) { - if (FCHDIR(sp, sp->fts_rfd)) { - SET(FTS_STOP); - return (NULL); - } - fts_load(sp, p); - return (sp->fts_cur = p); - } - - /* - * User may have called fts_set on the node. If skipped, - * ignore. If followed, get a file descriptor so we can - * get back if necessary. - */ - if (p->fts_instr == FTS_SKIP) - goto next; - if (p->fts_instr == FTS_FOLLOW) { - p->fts_info = fts_stat(sp, p, 1); - if (p->fts_info == FTS_D && !ISSET(FTS_NOCHDIR)) - if ((p->fts_symfd = - open(".", O_RDONLY, 0)) < 0) { - p->fts_errno = errno; - p->fts_info = FTS_ERR; - } else - p->fts_flags |= FTS_SYMFOLLOW; - p->fts_instr = FTS_NOINSTR; - } - -name: t = sp->fts_path + NAPPEND(p->fts_parent); - *t++ = '/'; - memmove(t, p->fts_name, p->fts_namelen + 1); - return (sp->fts_cur = p); - } - - /* Move up to the parent node. */ - p = tmp->fts_parent; - free(tmp); - - if (p->fts_level == FTS_ROOTPARENTLEVEL) { - /* - * Done; free everything up and set errno to 0 so the user - * can distinguish between error and EOF. - */ - free(p); - errno = 0; - return (sp->fts_cur = NULL); - } - - /* Nul terminate the pathname. */ - sp->fts_path[p->fts_pathlen] = '\0'; - - /* - * Return to the parent directory. If at a root node or came through - * a symlink, go back through the file descriptor. Otherwise, cd up - * one directory. - */ - if (p->fts_level == FTS_ROOTLEVEL) { - if (FCHDIR(sp, sp->fts_rfd)) { - SET(FTS_STOP); - return (NULL); - } - } else if (p->fts_flags & FTS_SYMFOLLOW) { - if (FCHDIR(sp, p->fts_symfd)) { - saved_errno = errno; - (void)close(p->fts_symfd); - errno = saved_errno; - SET(FTS_STOP); - return (NULL); - } - (void)close(p->fts_symfd); - } else if (!(p->fts_flags & FTS_DONTCHDIR)) { - if (CHDIR(sp, "..")) { - SET(FTS_STOP); - return (NULL); - } - } - p->fts_info = p->fts_errno ? FTS_ERR : FTS_DP; - return (sp->fts_cur = p); -} - -/* - * Fts_set takes the stream as an argument although it's not used in this - * implementation; it would be necessary if anyone wanted to add global - * semantics to fts using fts_set. An error return is allowed for similar - * reasons. - */ -/* ARGSUSED */ -int -fts_set(sp, p, instr) - FTS *sp; - FTSENT *p; - int instr; -{ - if (instr && instr != FTS_AGAIN && instr != FTS_FOLLOW && - instr != FTS_NOINSTR && instr != FTS_SKIP) { - errno = EINVAL; - return (1); - } - p->fts_instr = instr; - return (0); -} - -FTSENT * -fts_children(sp, instr) - register FTS *sp; - int instr; -{ - register FTSENT *p; - int fd; - - if (instr && instr != FTS_NAMEONLY) { - errno = EINVAL; - return (NULL); - } - - /* Set current node pointer. */ - p = sp->fts_cur; - - /* - * Errno set to 0 so user can distinguish empty directory from - * an error. - */ - errno = 0; - - /* Fatal errors stop here. */ - if (ISSET(FTS_STOP)) - return (NULL); - - /* Return logical hierarchy of user's arguments. */ - if (p->fts_info == FTS_INIT) - return (p->fts_link); - - /* - * If not a directory being visited in pre-order, stop here. Could - * allow FTS_DNR, assuming the user has fixed the problem, but the - * same effect is available with FTS_AGAIN. - */ - if (p->fts_info != FTS_D /* && p->fts_info != FTS_DNR */) - return (NULL); - - /* Free up any previous child list. */ - if (sp->fts_child) - fts_lfree(sp->fts_child); - - if (instr == FTS_NAMEONLY) { - SET(FTS_NAMEONLY); - instr = BNAMES; - } else - instr = BCHILD; - - /* - * If using chdir on a relative path and called BEFORE fts_read does - * its chdir to the root of a traversal, we can lose -- we need to - * chdir into the subdirectory, and we don't know where the current - * directory is, so we can't get back so that the upcoming chdir by - * fts_read will work. - */ - if (p->fts_level != FTS_ROOTLEVEL || p->fts_accpath[0] == '/' || - ISSET(FTS_NOCHDIR)) - return (sp->fts_child = fts_build(sp, instr)); - - if ((fd = open(".", O_RDONLY, 0)) < 0) - return (NULL); - sp->fts_child = fts_build(sp, instr); - if (fchdir(fd)) - return (NULL); - (void)close(fd); - return (sp->fts_child); -} - -/* - * This is the tricky part -- do not casually change *anything* in here. The - * idea is to build the linked list of entries that are used by fts_children - * and fts_read. There are lots of special cases. - * - * The real slowdown in walking the tree is the stat calls. If FTS_NOSTAT is - * set and it's a physical walk (so that symbolic links can't be directories), - * we can do things quickly. First, if it's a 4.4BSD file system, the type - * of the file is in the directory entry. Otherwise, we assume that the number - * of subdirectories in a node is equal to the number of links to the parent. - * The former skips all stat calls. The latter skips stat calls in any leaf - * directories and for any files after the subdirectories in the directory have - * been found, cutting the stat calls by about 2/3. - */ -static FTSENT * -fts_build(sp, type) - register FTS *sp; - int type; -{ - register struct dirent *dp; - register FTSENT *p, *head; - register int nitems; - FTSENT *cur, *tail; - DIR *dirp; - void *adjaddr; - int cderrno, descend, len, level, maxlen, nlinks, oflag, saved_errno; - char *cp; - - /* Set current node pointer. */ - cur = sp->fts_cur; - - /* - * Open the directory for reading. If this fails, we're done. - * If being called from fts_read, set the fts_info field. - */ -#ifdef FTS_WHITEOUT - if (ISSET(FTS_WHITEOUT)) - oflag = DTF_NODUP|DTF_REWIND; - else - oflag = DTF_HIDEW|DTF_NODUP|DTF_REWIND; -#else -#define __opendir2(path, flag) opendir(path) -#endif - if ((dirp = __opendir2(cur->fts_accpath, oflag)) == NULL) { - if (type == BREAD) { - cur->fts_info = FTS_DNR; - cur->fts_errno = errno; - } - return (NULL); - } - - /* - * Nlinks is the number of possible entries of type directory in the - * directory if we're cheating on stat calls, 0 if we're not doing - * any stat calls at all, -1 if we're doing stats on everything. - */ - if (type == BNAMES) - nlinks = 0; - else if (ISSET(FTS_NOSTAT) && ISSET(FTS_PHYSICAL)) - nlinks = cur->fts_nlink - (ISSET(FTS_SEEDOT) ? 0 : 2); - else - nlinks = -1; - -#ifdef notdef - (void)printf("nlinks == %d (cur: %d)\n", nlinks, cur->fts_nlink); - (void)printf("NOSTAT %d PHYSICAL %d SEEDOT %d\n", - ISSET(FTS_NOSTAT), ISSET(FTS_PHYSICAL), ISSET(FTS_SEEDOT)); -#endif - /* - * If we're going to need to stat anything or we want to descend - * and stay in the directory, chdir. If this fails we keep going, - * but set a flag so we don't chdir after the post-order visit. - * We won't be able to stat anything, but we can still return the - * names themselves. Note, that since fts_read won't be able to - * chdir into the directory, it will have to return different path - * names than before, i.e. "a/b" instead of "b". Since the node - * has already been visited in pre-order, have to wait until the - * post-order visit to return the error. There is a special case - * here, if there was nothing to stat then it's not an error to - * not be able to stat. This is all fairly nasty. If a program - * needed sorted entries or stat information, they had better be - * checking FTS_NS on the returned nodes. - */ - cderrno = 0; - if (nlinks || type == BREAD) - if (fts_safe_changedir(sp, cur, dirfd(dirp))) { - if (nlinks && type == BREAD) - cur->fts_errno = errno; - cur->fts_flags |= FTS_DONTCHDIR; - descend = 0; - cderrno = errno; - (void)closedir(dirp); - dirp = NULL; - } else - descend = 1; - else - descend = 0; - - /* - * Figure out the max file name length that can be stored in the - * current path -- the inner loop allocates more path as necessary. - * We really wouldn't have to do the maxlen calculations here, we - * could do them in fts_read before returning the path, but it's a - * lot easier here since the length is part of the dirent structure. - * - * If not changing directories set a pointer so that can just append - * each new name into the path. - */ - maxlen = sp->fts_pathlen - cur->fts_pathlen - 1; - len = NAPPEND(cur); - if (ISSET(FTS_NOCHDIR)) { - cp = sp->fts_path + len; - *cp++ = '/'; - } - - level = cur->fts_level + 1; - - /* Read the directory, attaching each entry to the `link' pointer. */ - adjaddr = NULL; - for (head = tail = NULL, nitems = 0; dirp && (dp = readdir(dirp));) { - if (!ISSET(FTS_SEEDOT) && ISDOT(dp->d_name)) - continue; - - if ((p = fts_alloc(sp, dp->d_name, (int)dp->d_namlen)) == NULL) - goto mem1; - if (dp->d_namlen > maxlen) { - if (fts_palloc(sp, (size_t)dp->d_namlen)) { - /* - * No more memory for path or structures. Save - * errno, free up the current structure and the - * structures already allocated. - */ -mem1: saved_errno = errno; - if (p) - free(p); - fts_lfree(head); - (void)closedir(dirp); - errno = saved_errno; - cur->fts_info = FTS_ERR; - SET(FTS_STOP); - return (NULL); - } - adjaddr = sp->fts_path; - maxlen = sp->fts_pathlen - sp->fts_cur->fts_pathlen - 1; - } - - p->fts_pathlen = len + dp->d_namlen + 1; - p->fts_parent = sp->fts_cur; - p->fts_level = level; - -#ifdef FTS_WHITEOUT - if (dp->d_type == DT_WHT) - p->fts_flags |= FTS_ISW; -#endif - - if (cderrno) { - if (nlinks) { - p->fts_info = FTS_NS; - p->fts_errno = cderrno; - } else - p->fts_info = FTS_NSOK; - p->fts_accpath = cur->fts_accpath; - } else if (nlinks == 0 -#ifdef DT_DIR - || (nlinks > 0 && - dp->d_type != DT_DIR && dp->d_type != DT_UNKNOWN) -#endif - ) { - p->fts_accpath = - ISSET(FTS_NOCHDIR) ? p->fts_path : p->fts_name; - p->fts_info = FTS_NSOK; - } else { - /* Build a file name for fts_stat to stat. */ - if (ISSET(FTS_NOCHDIR)) { - p->fts_accpath = p->fts_path; - memmove(cp, p->fts_name, p->fts_namelen + 1); - } else - p->fts_accpath = p->fts_name; - /* Stat it. */ - p->fts_info = fts_stat(sp, p, 0); - - /* Decrement link count if applicable. */ - if (nlinks > 0 && (p->fts_info == FTS_D || - p->fts_info == FTS_DC || p->fts_info == FTS_DOT)) - --nlinks; - } - - /* We walk in directory order so "ls -f" doesn't get upset. */ - p->fts_link = NULL; - if (head == NULL) - head = tail = p; - else { - tail->fts_link = p; - tail = p; - } - ++nitems; - } - if (dirp) - (void)closedir(dirp); - - /* - * If had to realloc the path, adjust the addresses for the rest - * of the tree. - */ - if (adjaddr) - fts_padjust(sp, adjaddr); - - /* - * If not changing directories, reset the path back to original - * state. - */ - if (ISSET(FTS_NOCHDIR)) { - if (len == sp->fts_pathlen) - --cp; - *cp = '\0'; - } - - /* - * If descended after called from fts_children or after called from - * fts_read and nothing found, get back. At the root level we use - * the saved fd; if one of fts_open()'s arguments is a relative path - * to an empty directory, we wind up here with no other way back. If - * can't get back, we're done. - */ - if (descend && (type == BCHILD || !nitems) && - (cur->fts_level == FTS_ROOTLEVEL ? - FCHDIR(sp, sp->fts_rfd) : CHDIR(sp, ".."))) { - cur->fts_info = FTS_ERR; - SET(FTS_STOP); - return (NULL); - } - - /* If didn't find anything, return NULL. */ - if (!nitems) { - if (type == BREAD) - cur->fts_info = FTS_DP; - return (NULL); - } - - /* Sort the entries. */ - if (sp->fts_compar && nitems > 1) - head = fts_sort(sp, head, nitems); - return (head); -} - -static u_short -fts_stat(sp, p, follow) - FTS *sp; - register FTSENT *p; - int follow; -{ - register FTSENT *t; - register dev_t dev; - register ino_t ino; - struct stat *sbp, sb; - int saved_errno; - - /* If user needs stat info, stat buffer already allocated. */ - sbp = ISSET(FTS_NOSTAT) ? &sb : p->fts_statp; - -#ifdef FTS_WHITEOUT - /* check for whiteout */ - if (p->fts_flags & FTS_ISW) { - if (sbp != &sb) { - memset(sbp, '\0', sizeof (*sbp)); - sbp->st_mode = S_IFWHT; - } - return (FTS_W); - } -#endif - - /* - * If doing a logical walk, or application requested FTS_FOLLOW, do - * a stat(2). If that fails, check for a non-existent symlink. If - * fail, set the errno from the stat call. - */ - if (ISSET(FTS_LOGICAL) || follow) { - if (stat(p->fts_accpath, sbp)) { - saved_errno = errno; - if (!lstat(p->fts_accpath, sbp)) { - errno = 0; - return (FTS_SLNONE); - } - p->fts_errno = saved_errno; - goto err; - } - } else if (lstat(p->fts_accpath, sbp)) { - p->fts_errno = errno; -err: memset(sbp, 0, sizeof(struct stat)); - return (FTS_NS); - } - - if (S_ISDIR(sbp->st_mode)) { - /* - * Set the device/inode. Used to find cycles and check for - * crossing mount points. Also remember the link count, used - * in fts_build to limit the number of stat calls. It is - * understood that these fields are only referenced if fts_info - * is set to FTS_D. - */ - dev = p->fts_dev = sbp->st_dev; - ino = p->fts_ino = sbp->st_ino; - p->fts_nlink = sbp->st_nlink; - - if (ISDOT(p->fts_name)) - return (FTS_DOT); - - /* - * Cycle detection is done by brute force when the directory - * is first encountered. If the tree gets deep enough or the - * number of symbolic links to directories is high enough, - * something faster might be worthwhile. - */ - for (t = p->fts_parent; - t->fts_level >= FTS_ROOTLEVEL; t = t->fts_parent) - if (ino == t->fts_ino && dev == t->fts_dev) { - p->fts_cycle = t; - return (FTS_DC); - } - return (FTS_D); - } - if (S_ISLNK(sbp->st_mode)) - return (FTS_SL); - if (S_ISREG(sbp->st_mode)) - return (FTS_F); - return (FTS_DEFAULT); -} - -static FTSENT * -fts_sort(sp, head, nitems) - FTS *sp; - FTSENT *head; - register int nitems; -{ - register FTSENT **ap, *p; - - /* - * Construct an array of pointers to the structures and call qsort(3). - * Reassemble the array in the order returned by qsort. If unable to - * sort for memory reasons, return the directory entries in their - * current order. Allocate enough space for the current needs plus - * 40 so don't realloc one entry at a time. - */ - if (nitems > sp->fts_nitems) { - sp->fts_nitems = nitems + 40; - if ((sp->fts_array = reallocf(sp->fts_array, - (size_t)(sp->fts_nitems * sizeof(FTSENT *)))) == NULL) { - sp->fts_nitems = 0; - return (head); - } - } - for (ap = sp->fts_array, p = head; p; p = p->fts_link) - *ap++ = p; - qsort((void *)sp->fts_array, nitems, sizeof(FTSENT *), sp->fts_compar); - for (head = *(ap = sp->fts_array); --nitems; ++ap) - ap[0]->fts_link = ap[1]; - ap[0]->fts_link = NULL; - return (head); -} - -static FTSENT * -fts_alloc(sp, name, namelen) - FTS *sp; - char *name; - register int namelen; -{ - register FTSENT *p; - size_t len; - - /* - * The file name is a variable length array and no stat structure is - * necessary if the user has set the nostat bit. Allocate the FTSENT - * structure, the file name and the stat structure in one chunk, but - * be careful that the stat structure is reasonably aligned. Since the - * fts_name field is declared to be of size 1, the fts_name pointer is - * namelen + 2 before the first possible address of the stat structure. - */ - len = sizeof(FTSENT) + namelen; - if (!ISSET(FTS_NOSTAT)) - len += sizeof(struct stat) + ALIGNBYTES; - if ((p = malloc(len)) == NULL) - return (NULL); - - /* Copy the name plus the trailing NULL. */ - memmove(p->fts_name, name, namelen + 1); - - if (!ISSET(FTS_NOSTAT)) - p->fts_statp = (struct stat *)ALIGN(p->fts_name + namelen + 2); - p->fts_namelen = namelen; - p->fts_path = sp->fts_path; - p->fts_errno = 0; - p->fts_flags = 0; - p->fts_instr = FTS_NOINSTR; - p->fts_number = 0; - p->fts_pointer = NULL; - return (p); -} - -static void -fts_lfree(head) - register FTSENT *head; -{ - register FTSENT *p; - - /* Free a linked list of structures. */ - while ((p = head)) { - head = head->fts_link; - free(p); - } -} - -/* - * Allow essentially unlimited paths; find, rm, ls should all work on any tree. - * Most systems will allow creation of paths much longer than MAXPATHLEN, even - * though the kernel won't resolve them. Add the size (not just what's needed) - * plus 256 bytes so don't realloc the path 2 bytes at a time. - */ -static int -fts_palloc(sp, more) - FTS *sp; - size_t more; -{ - sp->fts_pathlen += more + 256; - sp->fts_path = reallocf(sp->fts_path, (size_t)sp->fts_pathlen); - return (sp->fts_path == NULL); -} - -/* - * When the path is realloc'd, have to fix all of the pointers in structures - * already returned. - */ -static void -fts_padjust(sp, addr) - FTS *sp; - void *addr; -{ - FTSENT *p; - -#define ADJUST(p) { \ - (p)->fts_accpath = \ - (char *)addr + ((p)->fts_accpath - (p)->fts_path); \ - (p)->fts_path = addr; \ -} - /* Adjust the current set of children. */ - for (p = sp->fts_child; p; p = p->fts_link) - ADJUST(p); - - /* Adjust the rest of the tree. */ - for (p = sp->fts_cur; p->fts_level >= FTS_ROOTLEVEL;) { - ADJUST(p); - p = p->fts_link ? p->fts_link : p->fts_parent; - } -} - -static size_t -fts_maxarglen(argv) - char * const *argv; -{ - size_t len, max; - - for (max = 0; *argv; ++argv) - if ((len = strlen(*argv)) > max) - max = len; - return (max); -} - -/* - * Change to dir specified by fd or p->fts_accpath without getting - * tricked by someone changing the world out from underneath us. - * Assumes p->fts_dev and p->fts_ino are filled in. - */ -static int -fts_safe_changedir(sp, p, fd) - FTS *sp; - FTSENT *p; - int fd; -{ - int ret, oerrno, newfd; - struct stat sb; - - newfd = fd; - if (ISSET(FTS_NOCHDIR)) - return (0); - if (fd < 0 && (newfd = open(p->fts_accpath, O_RDONLY, 0)) < 0) - return (-1); - if (fstat(newfd, &sb)) { - ret = -1; - goto bail; - } - if (p->fts_dev != sb.st_dev || p->fts_ino != sb.st_ino) { - errno = ENOENT; /* disinformation */ - ret = -1; - goto bail; - } - ret = fchdir(newfd); -bail: - oerrno = errno; - if (fd < 0) - (void)close(newfd); - errno = oerrno; - return (ret); -} diff --git a/lib/libc/gen/fts-compat.h b/lib/libc/gen/fts-compat.h deleted file mode 100644 index 4fa4a3aa0ded9..0000000000000 --- a/lib/libc/gen/fts-compat.h +++ /dev/null @@ -1,128 +0,0 @@ -/* - * Copyright (c) 1989, 1993 - * 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. - * - * @(#)fts.h 8.3 (Berkeley) 8/14/94 - */ - -#ifndef _FTS_H_ -#define _FTS_H_ - -typedef struct { - struct _ftsent *fts_cur; /* current node */ - struct _ftsent *fts_child; /* linked list of children */ - struct _ftsent **fts_array; /* sort array */ - dev_t fts_dev; /* starting device # */ - char *fts_path; /* path for this descent */ - int fts_rfd; /* fd for root */ - int fts_pathlen; /* sizeof(path) */ - int fts_nitems; /* elements in the sort array */ - int (*fts_compar)(); /* compare function */ - -#define FTS_COMFOLLOW 0x001 /* follow command line symlinks */ -#define FTS_LOGICAL 0x002 /* logical walk */ -#define FTS_NOCHDIR 0x004 /* don't change directories */ -#define FTS_NOSTAT 0x008 /* don't get stat info */ -#define FTS_PHYSICAL 0x010 /* physical walk */ -#define FTS_SEEDOT 0x020 /* return dot and dot-dot */ -#define FTS_XDEV 0x040 /* don't cross devices */ -#define FTS_WHITEOUT 0x080 /* return whiteout information */ -#define FTS_OPTIONMASK 0x0ff /* valid user option mask */ - -#define FTS_NAMEONLY 0x100 /* (private) child names only */ -#define FTS_STOP 0x200 /* (private) unrecoverable error */ - int fts_options; /* fts_open options, global flags */ -} FTS; - -typedef struct _ftsent { - struct _ftsent *fts_cycle; /* cycle node */ - struct _ftsent *fts_parent; /* parent directory */ - struct _ftsent *fts_link; /* next file in directory */ - long fts_number; /* local numeric value */ - void *fts_pointer; /* local address value */ - char *fts_accpath; /* access path */ - char *fts_path; /* root path */ - int fts_errno; /* errno for this node */ - int fts_symfd; /* fd for symlink */ - u_short fts_pathlen; /* strlen(fts_path) */ - u_short fts_namelen; /* strlen(fts_name) */ - - ino_t fts_ino; /* inode */ - dev_t fts_dev; /* device */ - nlink_t fts_nlink; /* link count */ - -#define FTS_ROOTPARENTLEVEL -1 -#define FTS_ROOTLEVEL 0 - short fts_level; /* depth (-1 to N) */ - -#define FTS_D 1 /* preorder directory */ -#define FTS_DC 2 /* directory that causes cycles */ -#define FTS_DEFAULT 3 /* none of the above */ -#define FTS_DNR 4 /* unreadable directory */ -#define FTS_DOT 5 /* dot or dot-dot */ -#define FTS_DP 6 /* postorder directory */ -#define FTS_ERR 7 /* error; errno is set */ -#define FTS_F 8 /* regular file */ -#define FTS_INIT 9 /* initialized only */ -#define FTS_NS 10 /* stat(2) failed */ -#define FTS_NSOK 11 /* no stat(2) requested */ -#define FTS_SL 12 /* symbolic link */ -#define FTS_SLNONE 13 /* symbolic link without target */ -#define FTS_W 14 /* whiteout object */ - u_short fts_info; /* user flags for FTSENT structure */ - -#define FTS_DONTCHDIR 0x01 /* don't chdir .. to the parent */ -#define FTS_SYMFOLLOW 0x02 /* followed a symlink to get here */ -#define FTS_ISW 0x04 /* this is a whiteout object */ - u_short fts_flags; /* private flags for FTSENT structure */ - -#define FTS_AGAIN 1 /* read node again */ -#define FTS_FOLLOW 2 /* follow symbolic link */ -#define FTS_NOINSTR 3 /* no instructions */ -#define FTS_SKIP 4 /* discard node */ - u_short fts_instr; /* fts_set() instructions */ - - struct stat *fts_statp; /* stat(2) information */ - char fts_name[1]; /* file name */ -} FTSENT; - -#include <sys/cdefs.h> - -__BEGIN_DECLS -FTSENT *fts_children __P((FTS *, int)); -int fts_close __P((FTS *)); -FTS *fts_open __P((char * const *, int, - int (*)(const FTSENT **, const FTSENT **))); -FTSENT *fts_read __P((FTS *)); -int fts_set __P((FTS *, FTSENT *, int)); -__END_DECLS - -#endif /* !_FTS_H_ */ diff --git a/lib/libc/gen/pw_scan.c b/lib/libc/gen/pw_scan.c deleted file mode 100644 index d4747867c94ab..0000000000000 --- a/lib/libc/gen/pw_scan.c +++ /dev/null @@ -1,144 +0,0 @@ -/*- - * Copyright (c) 1990, 1993, 1994 - * 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. - */ - -#ifndef lint -#if 0 -static char sccsid[] = "@(#)pw_scan.c 8.3 (Berkeley) 4/2/94"; -#endif -static const char rcsid[] = - "$Id$"; -#endif /* not lint */ - -/* - * This module is used to "verify" password entries by chpass(1) and - * pwd_mkdb(8). - */ - -#include <sys/param.h> - -#include <err.h> -#include <fcntl.h> -#include <pwd.h> -#include <stdio.h> -#include <string.h> -#include <stdlib.h> -#include <unistd.h> - -#include "pw_scan.h" - -int -pw_scan(bp, pw) - char *bp; - struct passwd *pw; -{ - long id; - int root; - char *p, *sh; - - pw->pw_fields = 0; - if (!(pw->pw_name = strsep(&bp, ":"))) /* login */ - goto fmt; - root = !strcmp(pw->pw_name, "root"); - if(pw->pw_name[0] && (pw->pw_name[0] != '+' || pw->pw_name[1] == '\0')) - pw->pw_fields |= _PWF_NAME; - - if (!(pw->pw_passwd = strsep(&bp, ":"))) /* passwd */ - goto fmt; - if(pw->pw_passwd[0]) pw->pw_fields |= _PWF_PASSWD; - - if (!(p = strsep(&bp, ":"))) /* uid */ - goto fmt; - if(p[0]) pw->pw_fields |= _PWF_UID; - id = atol(p); - if (root && id) { - warnx("root uid should be 0"); - return (0); - } - if (id > USHRT_MAX) { - warnx("%s > max uid value (%d)", p, USHRT_MAX); - /*return (0);*/ /* THIS SHOULD NOT BE FATAL! */ - } - pw->pw_uid = id; - - if (!(p = strsep(&bp, ":"))) /* gid */ - goto fmt; - if(p[0]) pw->pw_fields |= _PWF_GID; - id = atol(p); - if (id > USHRT_MAX) { - warnx("%s > max gid value (%d)", p, USHRT_MAX); - /* return (0); This should not be fatal! */ - } - pw->pw_gid = id; - - pw->pw_class = strsep(&bp, ":"); /* class */ - if(pw->pw_class[0]) pw->pw_fields |= _PWF_CLASS; - - if (!(p = strsep(&bp, ":"))) /* change */ - goto fmt; - if(p[0]) pw->pw_fields |= _PWF_CHANGE; - pw->pw_change = atol(p); - - if (!(p = strsep(&bp, ":"))) /* expire */ - goto fmt; - if(p[0]) pw->pw_fields |= _PWF_EXPIRE; - pw->pw_expire = atol(p); - - if (!(pw->pw_gecos = strsep(&bp, ":"))) /* gecos */ - goto fmt; - if(pw->pw_gecos[0]) pw->pw_fields |= _PWF_GECOS; - - if (!(pw->pw_dir = strsep(&bp, ":"))) /* directory */ - goto fmt; - if(pw->pw_dir[0]) pw->pw_fields |= _PWF_DIR; - - if (!(pw->pw_shell = strsep(&bp, ":"))) /* shell */ - goto fmt; - - p = pw->pw_shell; - if (root && *p) /* empty == /bin/sh */ - for (setusershell();;) { - if (!(sh = getusershell())) { - warnx("warning, unknown root shell"); - break; - } - if (!strcmp(p, sh)) - break; - } - if(p[0]) pw->pw_fields |= _PWF_SHELL; - - if ((p = strsep(&bp, ":"))) { /* too many */ -fmt: warnx("corrupted entry"); - return (0); - } - return (1); -} diff --git a/lib/libc/gen/pw_scan.h b/lib/libc/gen/pw_scan.h deleted file mode 100644 index d1d4bc1ef6312..0000000000000 --- a/lib/libc/gen/pw_scan.h +++ /dev/null @@ -1,36 +0,0 @@ -/*- - * Copyright (c) 1994 - * 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. - * - * @(#)pw_scan.h 8.1 (Berkeley) 4/1/94 - */ - -extern int pw_scan __P((char *, struct passwd *)); diff --git a/lib/libc/gen/setflags.c b/lib/libc/gen/setflags.c deleted file mode 100644 index 1f22f5a8ad963..0000000000000 --- a/lib/libc/gen/setflags.c +++ /dev/null @@ -1,174 +0,0 @@ -/*- - * Copyright (c) 1993 - * 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. - */ - -#ifndef lint -#if 0 -static char sccsid[] = "@(#)stat_flags.c 8.1 (Berkeley) 5/31/93"; -#else -static const char rcsid[] = - "$Id: stat_flags.c,v 1.8 1997/08/07 22:28:25 steve Exp $"; -#endif -#endif /* not lint */ - -#include <sys/types.h> -#include <sys/stat.h> - -#include <stddef.h> -#include <string.h> - -#define SAPPEND(s) { \ - if (prefix != NULL) \ - (void)strcat(string, prefix); \ - (void)strcat(string, s); \ - prefix = ","; \ -} - -/* - * flags_to_string -- - * Convert stat flags to a comma-separated string. If no flags - * are set, return the default string. - */ -char * -flags_to_string(flags, def) - u_long flags; - char *def; -{ - static char string[128]; - char *prefix; - - string[0] = '\0'; - prefix = NULL; - if (flags & UF_APPEND) - SAPPEND("uappnd"); - if (flags & UF_IMMUTABLE) - SAPPEND("uchg"); -#ifdef UF_NOUNLINK - if (flags & UF_NOUNLINK) - SAPPEND("uunlnk"); -#endif - if (flags & UF_NODUMP) - SAPPEND("nodump"); - if (flags & UF_OPAQUE) - SAPPEND("opaque"); - if (flags & SF_APPEND) - SAPPEND("sappnd"); - if (flags & SF_ARCHIVED) - SAPPEND("arch"); - if (flags & SF_IMMUTABLE) - SAPPEND("schg"); -#ifdef SF_NOUNLINK - if (flags & SF_NOUNLINK) - SAPPEND("sunlnk"); -#endif - return (prefix == NULL && def != NULL ? def : string); -} - -#define TEST(a, b, f) { \ - if (!memcmp(a, b, sizeof(b))) { \ - if (clear) { \ - if (clrp) \ - *clrp |= (f); \ - } else if (setp) \ - *setp |= (f); \ - break; \ - } \ -} - -/* - * string_to_flags -- - * Take string of arguments and return stat flags. Return 0 on - * success, 1 on failure. On failure, stringp is set to point - * to the offending token. - */ -int -string_to_flags(stringp, setp, clrp) - char **stringp; - u_long *setp, *clrp; -{ - int clear; - char *string, *p; - - clear = 0; - if (setp) - *setp = 0; - if (clrp) - *clrp = 0; - string = *stringp; - while ((p = strsep(&string, "\t ,")) != NULL) { - *stringp = p; - if (*p == '\0') - continue; - if (p[0] == 'n' && p[1] == 'o') { - clear = 1; - p += 2; - } - switch (p[0]) { - case 'a': - TEST(p, "arch", SF_ARCHIVED); - TEST(p, "archived", SF_ARCHIVED); - return (1); - case 'd': - clear = !clear; - TEST(p, "dump", UF_NODUMP); - return (1); - case 'o': - TEST(p, "opaque", UF_OPAQUE); - return (1); - case 's': - TEST(p, "sappnd", SF_APPEND); - TEST(p, "sappend", SF_APPEND); - TEST(p, "schg", SF_IMMUTABLE); - TEST(p, "schange", SF_IMMUTABLE); - TEST(p, "simmutable", SF_IMMUTABLE); -#ifdef SF_NOUNLINK - TEST(p, "sunlnk", SF_NOUNLINK); - TEST(p, "sunlink", SF_NOUNLINK); -#endif - return (1); - case 'u': - TEST(p, "uappnd", UF_APPEND); - TEST(p, "uappend", UF_APPEND); - TEST(p, "uchg", UF_IMMUTABLE); - TEST(p, "uchange", UF_IMMUTABLE); - TEST(p, "uimmutable", UF_IMMUTABLE); -#ifdef UF_NOUNLINK - TEST(p, "uunlnk", UF_NOUNLINK); - TEST(p, "uunlink", UF_NOUNLINK); -#endif - /* FALLTHROUGH */ - default: - return (1); - } - } - return (0); -} diff --git a/lib/libc/gen/setflagsbyname.c b/lib/libc/gen/setflagsbyname.c deleted file mode 100644 index 1f22f5a8ad963..0000000000000 --- a/lib/libc/gen/setflagsbyname.c +++ /dev/null @@ -1,174 +0,0 @@ -/*- - * Copyright (c) 1993 - * 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. - */ - -#ifndef lint -#if 0 -static char sccsid[] = "@(#)stat_flags.c 8.1 (Berkeley) 5/31/93"; -#else -static const char rcsid[] = - "$Id: stat_flags.c,v 1.8 1997/08/07 22:28:25 steve Exp $"; -#endif -#endif /* not lint */ - -#include <sys/types.h> -#include <sys/stat.h> - -#include <stddef.h> -#include <string.h> - -#define SAPPEND(s) { \ - if (prefix != NULL) \ - (void)strcat(string, prefix); \ - (void)strcat(string, s); \ - prefix = ","; \ -} - -/* - * flags_to_string -- - * Convert stat flags to a comma-separated string. If no flags - * are set, return the default string. - */ -char * -flags_to_string(flags, def) - u_long flags; - char *def; -{ - static char string[128]; - char *prefix; - - string[0] = '\0'; - prefix = NULL; - if (flags & UF_APPEND) - SAPPEND("uappnd"); - if (flags & UF_IMMUTABLE) - SAPPEND("uchg"); -#ifdef UF_NOUNLINK - if (flags & UF_NOUNLINK) - SAPPEND("uunlnk"); -#endif - if (flags & UF_NODUMP) - SAPPEND("nodump"); - if (flags & UF_OPAQUE) - SAPPEND("opaque"); - if (flags & SF_APPEND) - SAPPEND("sappnd"); - if (flags & SF_ARCHIVED) - SAPPEND("arch"); - if (flags & SF_IMMUTABLE) - SAPPEND("schg"); -#ifdef SF_NOUNLINK - if (flags & SF_NOUNLINK) - SAPPEND("sunlnk"); -#endif - return (prefix == NULL && def != NULL ? def : string); -} - -#define TEST(a, b, f) { \ - if (!memcmp(a, b, sizeof(b))) { \ - if (clear) { \ - if (clrp) \ - *clrp |= (f); \ - } else if (setp) \ - *setp |= (f); \ - break; \ - } \ -} - -/* - * string_to_flags -- - * Take string of arguments and return stat flags. Return 0 on - * success, 1 on failure. On failure, stringp is set to point - * to the offending token. - */ -int -string_to_flags(stringp, setp, clrp) - char **stringp; - u_long *setp, *clrp; -{ - int clear; - char *string, *p; - - clear = 0; - if (setp) - *setp = 0; - if (clrp) - *clrp = 0; - string = *stringp; - while ((p = strsep(&string, "\t ,")) != NULL) { - *stringp = p; - if (*p == '\0') - continue; - if (p[0] == 'n' && p[1] == 'o') { - clear = 1; - p += 2; - } - switch (p[0]) { - case 'a': - TEST(p, "arch", SF_ARCHIVED); - TEST(p, "archived", SF_ARCHIVED); - return (1); - case 'd': - clear = !clear; - TEST(p, "dump", UF_NODUMP); - return (1); - case 'o': - TEST(p, "opaque", UF_OPAQUE); - return (1); - case 's': - TEST(p, "sappnd", SF_APPEND); - TEST(p, "sappend", SF_APPEND); - TEST(p, "schg", SF_IMMUTABLE); - TEST(p, "schange", SF_IMMUTABLE); - TEST(p, "simmutable", SF_IMMUTABLE); -#ifdef SF_NOUNLINK - TEST(p, "sunlnk", SF_NOUNLINK); - TEST(p, "sunlink", SF_NOUNLINK); -#endif - return (1); - case 'u': - TEST(p, "uappnd", UF_APPEND); - TEST(p, "uappend", UF_APPEND); - TEST(p, "uchg", UF_IMMUTABLE); - TEST(p, "uchange", UF_IMMUTABLE); - TEST(p, "uimmutable", UF_IMMUTABLE); -#ifdef UF_NOUNLINK - TEST(p, "uunlnk", UF_NOUNLINK); - TEST(p, "uunlink", UF_NOUNLINK); -#endif - /* FALLTHROUGH */ - default: - return (1); - } - } - return (0); -} diff --git a/lib/libc/gen/setproctitle.3 b/lib/libc/gen/setproctitle.3 deleted file mode 100644 index 25e91621deb88..0000000000000 --- a/lib/libc/gen/setproctitle.3 +++ /dev/null @@ -1,113 +0,0 @@ -.\" Copyright (c) 1995 Peter Wemm <peter@freebsd.org> -.\" All rights reserved. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, is permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice immediately at the beginning of the file, without modification, -.\" 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. This work was done expressly for inclusion into FreeBSD. Other use -.\" is permitted provided this notation is included. -.\" 4. Absolutely no warranty of function or purpose is made by the author -.\" Peter Wemm. -.\" 5. Modifications may be freely made to this file providing the above -.\" conditions are met. -.\" -.\" $Id: setproctitle.3,v 1.9 1997/05/11 08:50:33 davidn Exp $ -.\" -.\" The following requests are required for all man pages. -.Dd December 16, 1995 -.Os FreeBSD -.Dt SETPROCTITLE 3 -.Sh NAME -.Nm setproctitle -.Nd set the process title for -.Xr ps 1 -.Sh SYNOPSIS -.Fd #include <sys/types.h> -.Fd #include <libutil.h> -.Ft void -.Fn setproctitle "const char *fmt" "..." -.Pp -Link with -.Va -lutil -on the -.Xr cc 1 -command line. -.Sh DESCRIPTION -The -.Fn setproctitle -library routine sets the process title that appears on the -.Xr ps 1 -command. -.Pp -The title is set from the executable's name, followed by the -result of a -.Xr printf 3 -style expansion of the arguments as specified by the -.Va fmt -argument. -.Pp -If -.Va fmt -is NULL, the process title is reset to simply the name of the executable. -.\" The following requests should be uncommented and used where appropriate. -.\" This next request is for sections 2 and 3 function return values only. -.\" .Sh RETURN VALUES -.\" This next request is for sections 1, 6, 7 & 8 only -.\" .Sh ENVIRONMENT -.\" .Sh FILES -.Sh EXAMPLES -To set the title on a daemon to indicate its activity: -.Bd -literal -offset indent -setproctitle("talking to %s", inet_ntoa(addr)); -.Ed -.\" This next request is for sections 1, 6, 7 & 8 only -.\" (command return values (to shell) and fprintf/stderr type diagnostics) -.\" .Sh DIAGNOSTICS -.\" The next request is for sections 2 and 3 error and signal handling only. -.\" .Sh ERRORS -.Sh SEE ALSO -.Xr ps 1 , -.Xr w 1 , -.Xr kvm 3 , -.Xr kvm_getargv 3 , -.Xr printf 3 -.Sh STANDARDS -.Fn setproctitle -is implicitly non-standard. Other methods of causing the -.Xr ps 1 -command line to change, including copying over the argv[0] string are -also implicitly non-portable. It is preferable to use an operating system -supplied -.Fn setproctitle -if present. -.Pp -Unfortunately, it is possible that there are other calling conventions -to other versions of -.Fn setproctitle , -although none have been found by the author as yet. This is believed to be -the predominant convention. -.Pp -It is thought that the implementation is compatible with other systems, -including -.Tn NetBSD -and -.Tn BSD/OS . -.Sh HISTORY -.Fn setproctitle -first appeared in -.Fx 2.2 . -Other operating systems have -similar functions. -.Sh AUTHORS -.An Peter Wemm Aq peter@FreeBSD.org -stole the idea from the -.Sy "Sendmail 8.7.3" -source code by -.An Eric Allman Aq eric@sendmail.org . -.\" .Sh BUGS diff --git a/lib/libc/gen/setproctitle.c b/lib/libc/gen/setproctitle.c deleted file mode 100644 index 3bce42074da8f..0000000000000 --- a/lib/libc/gen/setproctitle.c +++ /dev/null @@ -1,126 +0,0 @@ -/* - * Copyright (c) 1995 Peter Wemm <peter@freebsd.org> - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, is permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice immediately at the beginning of the file, without modification, - * 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. Absolutely no warranty of function or purpose is made by the author - * Peter Wemm. - * - * $Id: setproctitle.c,v 1.7 1998/04/28 07:02:33 dg Exp $ - */ - -#include <sys/types.h> -#include <sys/param.h> -#include <sys/exec.h> -#include <sys/sysctl.h> - -#include <vm/vm.h> -#include <vm/vm_param.h> -#include <vm/pmap.h> - -#include <stdio.h> -#include <string.h> -#include <stdlib.h> - -/* - * Older FreeBSD 2.0, 2.1 and 2.2 had different ps_strings structures and - * in different locations. - * 1: old_ps_strings at the very top of the stack. - * 2: old_ps_strings at SPARE_USRSPACE below the top of the stack. - * 3: ps_strings at the very top of the stack. - * This attempts to support a kernel built in the #2 and #3 era. - */ - -struct old_ps_strings { - char *old_ps_argvstr; - int old_ps_nargvstr; - char *old_ps_envstr; - int old_ps_nenvstr; -}; -#define OLD_PS_STRINGS ((struct old_ps_strings *) \ - (USRSTACK - SPARE_USRSPACE - sizeof(struct old_ps_strings))) - -#if defined(__STDC__) /* from other parts of sendmail */ -#include <stdarg.h> -#else -#include <varargs.h> -#endif - - -#define SPT_BUFSIZE 2048 /* from other parts of sendmail */ -extern char * __progname; /* is this defined in a .h anywhere? */ - -static struct ps_strings *ps_strings; - -void -#if defined(__STDC__) -setproctitle(const char *fmt, ...) -#else -setproctitle(fmt, va_alist) - const char *fmt; - va_dcl -#endif -{ - static char buf[SPT_BUFSIZE]; - static char *ps_argv[2]; - va_list ap; - size_t len; - unsigned long ul_ps_strings; - -#if defined(__STDC__) - va_start(ap, fmt); -#else - va_start(ap); -#endif - - buf[sizeof(buf) - 1] = '\0'; - if (fmt) { - - /* print program name heading for grep */ - (void) snprintf(buf, sizeof(buf) - 1, "%s: ", __progname); - - /* - * can't use return from sprintf, as that is the count of how - * much it wanted to write, not how much it actually did. - */ - - len = strlen(buf); - - /* print the argument string */ - (void) vsnprintf(buf + len, sizeof(buf) - 1 - len, fmt, ap); - } else { - /* Idea from NetBSD - reset the title on fmt == NULL */ - strncpy(buf, __progname, sizeof(buf) - 1); - } - - va_end(ap); - - if (ps_strings == NULL) { - len = sizeof(ul_ps_strings); - if (sysctlbyname("kern.ps_strings", &ul_ps_strings, &len, NULL, - 0) == -1) - ul_ps_strings = PS_STRINGS; - ps_strings = (struct ps_strings *)ul_ps_strings; - } - - /* PS_STRINGS points to zeroed memory on a style #2 kernel */ - if (ps_strings->ps_argvstr) { - /* style #3 */ - ps_argv[0] = buf; - ps_argv[1] = NULL; - ps_strings->ps_nargvstr = 1; - ps_strings->ps_argvstr = ps_argv; - } else { - /* style #2 */ - OLD_PS_STRINGS->old_ps_nargvstr = 1; - OLD_PS_STRINGS->old_ps_argvstr = buf; - } -} diff --git a/lib/libc/gen/strtofflags.c b/lib/libc/gen/strtofflags.c deleted file mode 100644 index 1f22f5a8ad963..0000000000000 --- a/lib/libc/gen/strtofflags.c +++ /dev/null @@ -1,174 +0,0 @@ -/*- - * Copyright (c) 1993 - * 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. - */ - -#ifndef lint -#if 0 -static char sccsid[] = "@(#)stat_flags.c 8.1 (Berkeley) 5/31/93"; -#else -static const char rcsid[] = - "$Id: stat_flags.c,v 1.8 1997/08/07 22:28:25 steve Exp $"; -#endif -#endif /* not lint */ - -#include <sys/types.h> -#include <sys/stat.h> - -#include <stddef.h> -#include <string.h> - -#define SAPPEND(s) { \ - if (prefix != NULL) \ - (void)strcat(string, prefix); \ - (void)strcat(string, s); \ - prefix = ","; \ -} - -/* - * flags_to_string -- - * Convert stat flags to a comma-separated string. If no flags - * are set, return the default string. - */ -char * -flags_to_string(flags, def) - u_long flags; - char *def; -{ - static char string[128]; - char *prefix; - - string[0] = '\0'; - prefix = NULL; - if (flags & UF_APPEND) - SAPPEND("uappnd"); - if (flags & UF_IMMUTABLE) - SAPPEND("uchg"); -#ifdef UF_NOUNLINK - if (flags & UF_NOUNLINK) - SAPPEND("uunlnk"); -#endif - if (flags & UF_NODUMP) - SAPPEND("nodump"); - if (flags & UF_OPAQUE) - SAPPEND("opaque"); - if (flags & SF_APPEND) - SAPPEND("sappnd"); - if (flags & SF_ARCHIVED) - SAPPEND("arch"); - if (flags & SF_IMMUTABLE) - SAPPEND("schg"); -#ifdef SF_NOUNLINK - if (flags & SF_NOUNLINK) - SAPPEND("sunlnk"); -#endif - return (prefix == NULL && def != NULL ? def : string); -} - -#define TEST(a, b, f) { \ - if (!memcmp(a, b, sizeof(b))) { \ - if (clear) { \ - if (clrp) \ - *clrp |= (f); \ - } else if (setp) \ - *setp |= (f); \ - break; \ - } \ -} - -/* - * string_to_flags -- - * Take string of arguments and return stat flags. Return 0 on - * success, 1 on failure. On failure, stringp is set to point - * to the offending token. - */ -int -string_to_flags(stringp, setp, clrp) - char **stringp; - u_long *setp, *clrp; -{ - int clear; - char *string, *p; - - clear = 0; - if (setp) - *setp = 0; - if (clrp) - *clrp = 0; - string = *stringp; - while ((p = strsep(&string, "\t ,")) != NULL) { - *stringp = p; - if (*p == '\0') - continue; - if (p[0] == 'n' && p[1] == 'o') { - clear = 1; - p += 2; - } - switch (p[0]) { - case 'a': - TEST(p, "arch", SF_ARCHIVED); - TEST(p, "archived", SF_ARCHIVED); - return (1); - case 'd': - clear = !clear; - TEST(p, "dump", UF_NODUMP); - return (1); - case 'o': - TEST(p, "opaque", UF_OPAQUE); - return (1); - case 's': - TEST(p, "sappnd", SF_APPEND); - TEST(p, "sappend", SF_APPEND); - TEST(p, "schg", SF_IMMUTABLE); - TEST(p, "schange", SF_IMMUTABLE); - TEST(p, "simmutable", SF_IMMUTABLE); -#ifdef SF_NOUNLINK - TEST(p, "sunlnk", SF_NOUNLINK); - TEST(p, "sunlink", SF_NOUNLINK); -#endif - return (1); - case 'u': - TEST(p, "uappnd", UF_APPEND); - TEST(p, "uappend", UF_APPEND); - TEST(p, "uchg", UF_IMMUTABLE); - TEST(p, "uchange", UF_IMMUTABLE); - TEST(p, "uimmutable", UF_IMMUTABLE); -#ifdef UF_NOUNLINK - TEST(p, "uunlnk", UF_NOUNLINK); - TEST(p, "uunlink", UF_NOUNLINK); -#endif - /* FALLTHROUGH */ - default: - return (1); - } - } - return (0); -} diff --git a/lib/libc/locale/euc.5 b/lib/libc/locale/euc.5 deleted file mode 100644 index ffcf6d8e04785..0000000000000 --- a/lib/libc/locale/euc.5 +++ /dev/null @@ -1,241 +0,0 @@ -.\" Copyright (c) 1993 -.\" The Regents of the University of California. All rights reserved. -.\" -.\" This code is derived from software contributed to Berkeley by -.\" Paul Borman at Krystal Technologies. -.\" -.\" 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. -.\" -.\" @(#)euc.4 8.1 (Berkeley) 6/4/93 -.\" -.Dd June 4, 1993 -.Dt EUC 4 -.Os -.Sh NAME -.Nm euc -.Nd EUC encoding of runes -.Sh SYNOPSIS -.Nm ENCODING -.Qq EUC -.Pp -.Nm VARIABLE -.Ar len1 -.Ar mask1 -.Ar len2 -.Ar mask2 -.Ar len3 -.Ar mask3 -.Ar len4 -.Ar mask4 -.Ar mask -.Sh DESCRIPTION -The -.Nm EUC -encoding is provided for compatibility with -.Ux -based systems. -See -.Xr mklocale 1 -for a complete description of the -.Ev LC_CTYPE -source file format. -.Pp -.Nm EUC -implements a system of 4 multibyte codesets. -A multibyte character in the first codeset consists of -.Ar len1 -bytes starting with a byte in the range of 0x00 to 0x7f. -To allow use of ASCII, -.Ar len1 -is always 1. -A multibyte character in the second codeset consists of -.Ar len2 -bytes starting with a byte in the range of 0x80-0xff excluding 0x8e and 0x8f. -A multibyte character in the third codeset consists of -.Ar len3 -bytes starting with the byte 0x8e. -A multibyte character in the fourth codeset consists of -.Ar len4 -bytes starting with the byte 0x8f. -.Pp -The -.Ev rune_t -encoding of -.Nm EUC -multibyte characters is dependent on the -.Ar len -and -.Ar mask -arguments. -First, the bytes are moved into a -.Ev rune_t -as follows: -.Bd -literal -byte0 << ((\fIlen\fPN-1) * 8) | byte1 << ((\fIlen\fPN-2) * 8) | ... | byte\fIlen\fPN-1 -.Ed -.Pp -The result is then ANDed with -.Ar ~mask -and ORed with -.Ar maskN . -Codesets 2 and 3 are special in that the leading byte (0x8e or 0x8f) is -first removed and the -.Ar lenN -argument is reduced by 1. -.Pp -For example, the Japanese locale has the following -.Ev VARIABLE -line: -.Bd -literal -VARIABLE 1 0x0000 2 0x8080 2 0x0080 3 0x8000 0x8080 -.Ed -.Pp -Codeset 1 consists of the values 0x0000 - 0x007f. -.Pp -Codeset 2 consists of the values who have the bits 0x8080 set. -.Pp -Codeset 3 consists of the values 0x0080 - 0x00ff. -.Pp -Codeset 4 consists of the values 0x8000 - 0xff7f excluding the values -which have the 0x0080 bit set. -.Pp -Notice that the global -.Ar mask -is set to 0x8080, this implies that from those 2 bits the codeset can -be determined. -.Sh "EXAMPLE - Japanese Locale" -This is a complete example of an -.Ev LC_CTYPE -source file for the Japanese locale -.Bd -literal -/* - * Japanese LOCALE_CTYPE definitions using EUC of JIS character sets - */ - -ENCODING "EUC" - -/* JIS JIS JIS */ -/* X201 X208 X201 */ -/* 00-7f 84-fe */ - -VARIABLE 1 0x0000 2 0x8080 2 0x0080 3 0x8000 0x8080 - -/* - * Code Set 1 - */ -ALPHA 'A' - 'Z' 'a' - 'z' -CONTROL 0x00 - 0x1f 0x7f -DIGIT '0' - '9' -GRAPH 0x21 - 0x7e -LOWER 'a' - 'z' -PUNCT 0x21 - 0x2f 0x3a - 0x40 0x5b - 0x60 0x7b - 0x7e -SPACE 0x09 - 0x0d 0x20 -UPPER 'A' - 'Z' -XDIGIT 'a' - 'f' 'A' - 'F' -BLANK ' ' '\t' -PRINT 0x20 - 0x7e - -MAPLOWER < 'A' - 'Z' : 'a' > < 'a' - 'z' : 'a' > -MAPUPPER < 'A' - 'Z' : 'A' > < 'a' - 'z' : 'A' > -TODIGIT < '0' - '9' : 0 > -TODIGIT < 'A' - 'F' : 10 > < 'a' - 'f' : 10 > - -/* - * Code Set 2 - */ - -SPACE 0xa1a1 -PHONOGRAM 0xa1bc -SPECIAL 0xa1a2 - 0xa1fe -PUNCT 0xa1a2 - 0xa1f8 /* A few too many in here... */ - -SPECIAL 0xa2a1 - 0xa2ae 0xa2ba - 0xa2c1 0xa2ca - 0xa2d0 0xa2dc - 0xa2ea -SPECIAL 0xa2f2 - 0xa2f9 0xa2fe - -DIGIT 0xa3b0 - 0xa3b9 -UPPER 0xa3c1 - 0xa3da /* Romaji */ -LOWER 0xa3e1 - 0xa3fa /* Romaji */ -MAPLOWER < 0xa3c1 - 0xa3da : 0xa3e1 > /* English */ -MAPLOWER < 0xa3e1 - 0xa3fa : 0xa3e1 > /* English */ -MAPUPPER < 0xa3c1 - 0xa3da : 0xa3c1 > -MAPUPPER < 0xa3e1 - 0xa3fa : 0xa3c1 > - -XDIGIT 0xa3c1 - 0xa3c6 0xa3e1 - 0xa3e6 - -TODIGIT < 0xa3b0 - 0xa3b9 : 0 > -TODIGIT < 0xa3c1 - 0xa3c6 : 10 > < 0xa3e1 - 0xa3e6 : 10 > - -PHONOGRAM 0xa4a1 - 0xa4f3 -PHONOGRAM 0xa5a1 - 0xa5f6 - -UPPER 0xa6a1 - 0xa6b8 /* Greek */ -LOWER 0xa6c1 - 0xa6d8 /* Greek */ -MAPLOWER < 0xa6a1 - 0xa6b8 : 0xa6c1 > < 0xa6c1 - 0xa6d8 : 0xa6c1 > -MAPUPPER < 0xa6a1 - 0xa6b8 : 0xa6a1 > < 0xa6c1 - 0xa6d8 : 0xa6a1 > - -UPPER 0xa7a1 - 0xa7c1 /* Cyrillic */ -LOWER 0xa7d1 - 0xa7f1 /* Cyrillic */ -MAPLOWER < 0xa7a1 - 0xa7c1 : 0xa7d1 > < 0xa7d1 - 0xa7f1 : 0xa7d1 > -MAPUPPER < 0xa7a1 - 0xa7c1 : 0xa7a1 > < 0xa7d1 - 0xa7f1 : 0xa7a1 > - -SPECIAL 0xa8a1 - 0xa8c0 - -IDEOGRAM 0xb0a1 - 0xb0fe 0xb1a1 - 0xb1fe 0xb2a1 - 0xb2fe -IDEOGRAM 0xb3a1 - 0xb3fe 0xb4a1 - 0xb4fe 0xb5a1 - 0xb5fe -IDEOGRAM 0xb6a1 - 0xb6fe 0xb7a1 - 0xb7fe 0xb8a1 - 0xb8fe -IDEOGRAM 0xb9a1 - 0xb9fe 0xbaa1 - 0xbafe 0xbba1 - 0xbbfe -IDEOGRAM 0xbca1 - 0xbcfe 0xbda1 - 0xbdfe 0xbea1 - 0xbefe -IDEOGRAM 0xbfa1 - 0xbffe 0xc0a1 - 0xc0fe 0xc1a1 - 0xc1fe -IDEOGRAM 0xc2a1 - 0xc2fe 0xc3a1 - 0xc3fe 0xc4a1 - 0xc4fe -IDEOGRAM 0xc5a1 - 0xc5fe 0xc6a1 - 0xc6fe 0xc7a1 - 0xc7fe -IDEOGRAM 0xc8a1 - 0xc8fe 0xc9a1 - 0xc9fe 0xcaa1 - 0xcafe -IDEOGRAM 0xcba1 - 0xcbfe 0xcca1 - 0xccfe 0xcda1 - 0xcdfe -IDEOGRAM 0xcea1 - 0xcefe 0xcfa1 - 0xcfd3 0xd0a1 - 0xd0fe -IDEOGRAM 0xd1a1 - 0xd1fe 0xd2a1 - 0xd2fe 0xd3a1 - 0xd3fe -IDEOGRAM 0xd4a1 - 0xd4fe 0xd5a1 - 0xd5fe 0xd6a1 - 0xd6fe -IDEOGRAM 0xd7a1 - 0xd7fe 0xd8a1 - 0xd8fe 0xd9a1 - 0xd9fe -IDEOGRAM 0xdaa1 - 0xdafe 0xdba1 - 0xdbfe 0xdca1 - 0xdcfe -IDEOGRAM 0xdda1 - 0xddfe 0xdea1 - 0xdefe 0xdfa1 - 0xdffe -IDEOGRAM 0xe0a1 - 0xe0fe 0xe1a1 - 0xe1fe 0xe2a1 - 0xe2fe -IDEOGRAM 0xe3a1 - 0xe3fe 0xe4a1 - 0xe4fe 0xe5a1 - 0xe5fe -IDEOGRAM 0xe6a1 - 0xe6fe 0xe7a1 - 0xe7fe 0xe8a1 - 0xe8fe -IDEOGRAM 0xe9a1 - 0xe9fe 0xeaa1 - 0xeafe 0xeba1 - 0xebfe -IDEOGRAM 0xeca1 - 0xecfe 0xeda1 - 0xedfe 0xeea1 - 0xeefe -IDEOGRAM 0xefa1 - 0xeffe 0xf0a1 - 0xf0fe 0xf1a1 - 0xf1fe -IDEOGRAM 0xf2a1 - 0xf2fe 0xf3a1 - 0xf3fe 0xf4a1 - 0xf4a4 -/* - * This is for Code Set 3, half-width kana - */ -SPECIAL 0xa1 - 0xdf -PHONOGRAM 0xa1 - 0xdf -CONTROL 0x84 - 0x97 0x9b - 0x9f 0xe0 - 0xfe -.Ed -.Sh "SEE ALSO" -.Xr mklocale 1 , -.Xr setlocale 3 diff --git a/lib/libc/locale/utf2.5 b/lib/libc/locale/utf2.5 deleted file mode 100644 index e8fe7c8696477..0000000000000 --- a/lib/libc/locale/utf2.5 +++ /dev/null @@ -1,87 +0,0 @@ -.\" Copyright (c) 1993 -.\" The Regents of the University of California. All rights reserved. -.\" -.\" This code is derived from software contributed to Berkeley by -.\" Paul Borman at Krystal Technologies. -.\" -.\" 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. -.\" -.\" @(#)utf2.4 8.1 (Berkeley) 6/4/93 -.\" -.Dd June 4, 1993 -.Dt UTF2 4 -.Os -.Sh NAME -.Nm utf2 -.Nd "Universal character set Transformation Format encoding of runes -.Sh SYNOPSIS -.Nm ENCODING -.Qq UTF2 -.Sh DESCRIPTION -The -.Nm UTF2 -encoding is based on a proposed X-Open multibyte -\s-1FSS-UCS-TF\s+1 (File System Safe Universal Character Set Transformation Format) encoding as used in -.Nm Plan 9 from Bell Labs. -Although it is capable of representing more than 16 bits, -the current implementation is limited to 16 bits as defined by the -Unicode Standard. -.Pp -.Nm UTF2 -representation is backwards compatible with ASCII, so 0x00-0x7f refer to the -ASCII character set. The multibyte encoding of runes between 0x0080 and 0xffff -consist entirely of bytes whose high order bit is set. The actual -encoding is represented by the following table: -.Bd -literal -[0x0000 - 0x007f] [00000000.0bbbbbbb] -> 0bbbbbbb -[0x0080 - 0x07ff] [00000bbb.bbbbbbbb] -> 110bbbbb, 10bbbbbb -[0x0800 - 0xffff] [bbbbbbbb.bbbbbbbb] -> 1110bbbb, 10bbbbbb, 10bbbbbb -.Ed -.Pp -If more than a single representation of a value exists (for example, -0x00; 0xC0 0x80; 0xE0 0x80 0x80) the shortest representation is always -used (but the longer ones will be correctly decoded). -.Pp -The final three encodings provided by X-Open: -.Bd -literal -[00000000.000bbbbb.bbbbbbbb.bbbbbbbb] -> - 11110bbb, 10bbbbbb, 10bbbbbb, 10bbbbbb - -[000000bb.bbbbbbbb.bbbbbbbb.bbbbbbbb] -> - 111110bb, 10bbbbbb, 10bbbbbb, 10bbbbbb, 10bbbbbb - -[0bbbbbbb.bbbbbbbb.bbbbbbbb.bbbbbbbb] -> - 1111110b, 10bbbbbb, 10bbbbbb, 10bbbbbb, 10bbbbbb, 10bbbbbb -.Ed -.Pp -which provides for the entire proposed ISO-10646 31 bit standard are currently -not implemented. -.Sh "SEE ALSO" -.Xr mklocale 1 , -.Xr setlocale 3 diff --git a/lib/libc/stdlib/strtoll.c b/lib/libc/stdlib/strtoll.c deleted file mode 100644 index f84e030531bbf..0000000000000 --- a/lib/libc/stdlib/strtoll.c +++ /dev/null @@ -1,138 +0,0 @@ -/*- - * Copyright (c) 1992, 1993 - * 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. - */ - -#if defined(LIBC_SCCS) && !defined(lint) -static char sccsid[] = "@(#)strtoq.c 8.1 (Berkeley) 6/4/93"; -#endif /* LIBC_SCCS and not lint */ - -#include <sys/types.h> - -#include <limits.h> -#include <errno.h> -#include <ctype.h> -#include <stdlib.h> - -/* - * Convert a string to a quad integer. - * - * Ignores `locale' stuff. Assumes that the upper and lower case - * alphabets and digits are each contiguous. - */ -quad_t -strtoq(nptr, endptr, base) - const char *nptr; - char **endptr; - register int base; -{ - register const char *s; - register u_quad_t acc; - register unsigned char c; - register u_quad_t qbase, cutoff; - register int neg, any, cutlim; - - /* - * Skip white space and pick up leading +/- sign if any. - * If base is 0, allow 0x for hex and 0 for octal, else - * assume decimal; if base is already 16, allow 0x. - */ - s = nptr; - do { - c = *s++; - } while (isspace(c)); - if (c == '-') { - neg = 1; - c = *s++; - } else { - neg = 0; - if (c == '+') - c = *s++; - } - if ((base == 0 || base == 16) && - c == '0' && (*s == 'x' || *s == 'X')) { - c = s[1]; - s += 2; - base = 16; - } - if (base == 0) - base = c == '0' ? 8 : 10; - - /* - * Compute the cutoff value between legal numbers and illegal - * numbers. That is the largest legal value, divided by the - * base. An input number that is greater than this value, if - * followed by a legal input character, is too big. One that - * is equal to this value may be valid or not; the limit - * between valid and invalid numbers is then based on the last - * digit. For instance, if the range for quads is - * [-9223372036854775808..9223372036854775807] and the input base - * is 10, cutoff will be set to 922337203685477580 and cutlim to - * either 7 (neg==0) or 8 (neg==1), meaning that if we have - * accumulated a value > 922337203685477580, or equal but the - * next digit is > 7 (or 8), the number is too big, and we will - * return a range error. - * - * Set any if any `digits' consumed; make it negative to indicate - * overflow. - */ - qbase = (unsigned)base; - cutoff = neg ? (u_quad_t)-(QUAD_MIN + QUAD_MAX) + QUAD_MAX : QUAD_MAX; - cutlim = cutoff % qbase; - cutoff /= qbase; - for (acc = 0, any = 0;; c = *s++) { - if (!isascii(c)) - break; - if (isdigit(c)) - c -= '0'; - else if (isalpha(c)) - c -= isupper(c) ? 'A' - 10 : 'a' - 10; - else - break; - if (c >= base) - break; - if (any < 0 || acc > cutoff || (acc == cutoff && c > cutlim)) - any = -1; - else { - any = 1; - acc *= qbase; - acc += c; - } - } - if (any < 0) { - acc = neg ? QUAD_MIN : QUAD_MAX; - errno = ERANGE; - } else if (neg) - acc = -acc; - if (endptr != 0) - *endptr = (char *)(any ? s - 1 : nptr); - return (acc); -} diff --git a/lib/libc/stdlib/strtoull.c b/lib/libc/stdlib/strtoull.c deleted file mode 100644 index 7656a3c53b148..0000000000000 --- a/lib/libc/stdlib/strtoull.c +++ /dev/null @@ -1,116 +0,0 @@ -/*- - * Copyright (c) 1992, 1993 - * 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. - */ - -#if defined(LIBC_SCCS) && !defined(lint) -static char sccsid[] = "@(#)strtouq.c 8.1 (Berkeley) 6/4/93"; -#endif /* LIBC_SCCS and not lint */ - -#include <sys/types.h> - -#include <limits.h> -#include <errno.h> -#include <ctype.h> -#include <stdlib.h> - -/* - * Convert a string to an unsigned quad integer. - * - * Ignores `locale' stuff. Assumes that the upper and lower case - * alphabets and digits are each contiguous. - */ -u_quad_t -strtouq(nptr, endptr, base) - const char *nptr; - char **endptr; - register int base; -{ - register const char *s = nptr; - register u_quad_t acc; - register unsigned char c; - register u_quad_t qbase, cutoff; - register int neg, any, cutlim; - - /* - * See strtoq for comments as to the logic used. - */ - s = nptr; - do { - c = *s++; - } while (isspace(c)); - if (c == '-') { - neg = 1; - c = *s++; - } else { - neg = 0; - if (c == '+') - c = *s++; - } - if ((base == 0 || base == 16) && - c == '0' && (*s == 'x' || *s == 'X')) { - c = s[1]; - s += 2; - base = 16; - } - if (base == 0) - base = c == '0' ? 8 : 10; - qbase = (unsigned)base; - cutoff = (u_quad_t)UQUAD_MAX / qbase; - cutlim = (u_quad_t)UQUAD_MAX % qbase; - for (acc = 0, any = 0;; c = *s++) { - if (!isascii(c)) - break; - if (isdigit(c)) - c -= '0'; - else if (isalpha(c)) - c -= isupper(c) ? 'A' - 10 : 'a' - 10; - else - break; - if (c >= base) - break; - if (any < 0 || acc > cutoff || (acc == cutoff && c > cutlim)) - any = -1; - else { - any = 1; - acc *= qbase; - acc += c; - } - } - if (any < 0) { - acc = UQUAD_MAX; - errno = ERANGE; - } else if (neg) - acc = -acc; - if (endptr != 0) - *endptr = (char *)(any ? s - 1 : nptr); - return (acc); -} diff --git a/lib/libc_r/arch/amd64/_atomic_lock.S b/lib/libc_r/arch/amd64/_atomic_lock.S deleted file mode 100644 index e0ef0eb6244f5..0000000000000 --- a/lib/libc_r/arch/amd64/_atomic_lock.S +++ /dev/null @@ -1,45 +0,0 @@ -/* - * Copyright (c) 1995-1998 John Birrell <jb@cimlogic.com.au>. - * All rights reserved. - * copyright Douglas Santry 1996 - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the above copyright is retained - * in the source form. - * - * THIS SOFTWARE IS PROVIDED BY Douglas Santry 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 Douglas Santry 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. - * - * $Id: _atomic_lock.S,v 1.1 1998/04/29 09:36:03 jb Exp $ - * - */ - -#if defined(LIBC_RCS) && !defined(lint) - .text - .asciz "$Id: _atomic_lock.S,v 1.1 1998/04/29 09:36:03 jb Exp $" -#endif /* LIBC_RCS and not lint */ - -#include "DEFS.h" - -/* - * Atomicly lock a location with an identifier provided the location - * is not currently locked. - * - * long _atomic_lock(long *); - * eax will contain the return value (zero if lock obtained). - */ -ENTRY(_atomic_lock) - movl 4(%esp), %ecx - movl $1, %eax - xchg %eax, (%ecx) - ret - diff --git a/lib/libkse/Makefile b/lib/libkse/Makefile deleted file mode 100644 index 806cd10b5fa5a..0000000000000 --- a/lib/libkse/Makefile +++ /dev/null @@ -1,39 +0,0 @@ -# $Id: Makefile,v 1.13 1998/06/14 11:25:44 peter Exp $ -# -# All library objects contain rcsid strings by default; they may be -# excluded as a space-saving measure. To produce a library that does -# not contain these strings, delete -DLIBC_RCS and -DSYSLIBC_RCS -# from CFLAGS below. To remove these strings from just the system call -# stubs, remove just -DSYSLIBC_RCS from CFLAGS. -LIB=c_r -SHLIB_MAJOR= 3 -SHLIB_MINOR= 0 -CFLAGS+=-DLIBC_RCS -DSYSLIBC_RCS -I${.CURDIR}/../libc/include -CFLAGS+=-DPTHREAD_KERNEL -D_THREAD_SAFE -DNOPOLL -I${.CURDIR}/uthread - -# Uncomment this if you want libc_r to contain debug information for -# thread locking. -# CFLAGS+=-D_LOCK_DEBUG - -AINC= -I${.CURDIR}/../libc/${MACHINE_ARCH} -I${.CURDIR}/uthread -PRECIOUSLIB= yes - -# -# This is a list of syscalls that are renamed as _thread_sys_{syscall} -# so that libc_r can provide replacement functions. -# -HIDDEN_SYSCALLS= accept.o bind.o close.o connect.o dup.o dup2.o \ - execve.o fchflags.o fchmod.o fchown.o fcntl.o \ - flock.o fpathconf.o fstat.o fstatfs.o fsync.o getdirentries.o \ - getpeername.o getsockname.o getsockopt.o ioctl.o listen.o \ - nanosleep.o nfssvc.o open.o poll.o read.o readv.o recvfrom.o \ - recvmsg.o sched_yield.o select.o sendmsg.o sendto.o \ - setsockopt.o shutdown.o sigaction.o sigaltstack.o \ - signanosleep.o socket.o socketpair.o wait4.o write.o writev.o - -.include "${.CURDIR}/../libc/Makefile.inc" -.include "${.CURDIR}/man/Makefile.inc" -.include "${.CURDIR}/uthread/Makefile.inc" -.include "${.CURDIR}/sys/Makefile.inc" - -.include <bsd.lib.mk> diff --git a/lib/libkse/sys/Makefile.inc b/lib/libkse/sys/Makefile.inc deleted file mode 100644 index 50952cdfad1a4..0000000000000 --- a/lib/libkse/sys/Makefile.inc +++ /dev/null @@ -1,6 +0,0 @@ -# $Id: Makefile.inc,v 1.8 1998/04/29 11:03:34 jb Exp $ - -.PATH: ${.CURDIR}/sys ${.CURDIR}/arch/${MACHINE_ARCH} - -SRCS+= uthread_error.c _atomic_lock.S - diff --git a/lib/libkse/sys/thr_error.c b/lib/libkse/sys/thr_error.c deleted file mode 100644 index 545dfb06652c4..0000000000000 --- a/lib/libkse/sys/thr_error.c +++ /dev/null @@ -1,50 +0,0 @@ -/* - * Copyright (c) 1995 John Birrell <jb@cimlogic.com.au>. - * 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 John Birrell - * and Chris Provenzano. - * 4. Neither the name of the author nor the names of any co-contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY JOHN BIRRELL 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. - * - */ -#ifdef _THREAD_SAFE -#include <pthread.h> -#include "pthread_private.h" -extern int errno; - -int * __error() -{ - int *p_errno; - if (_thread_run == _thread_initial) { - p_errno = &errno; - } else { - p_errno = &_thread_run->error; - } - return(p_errno); -} -#endif diff --git a/lib/libkse/test/Makefile b/lib/libkse/test/Makefile deleted file mode 100644 index adf1673639772..0000000000000 --- a/lib/libkse/test/Makefile +++ /dev/null @@ -1,8 +0,0 @@ -# $Id: Makefile,v 1.1 1998/08/25 12:33:22 jb Exp $ -# -# Tests for libc_r functionality. -# - -SUBDIR= sigsuspend sigwait - -.include <bsd.subdir.mk> diff --git a/lib/libkse/thread/Makefile.inc b/lib/libkse/thread/Makefile.inc deleted file mode 100644 index 004982a8b6bcd..0000000000000 --- a/lib/libkse/thread/Makefile.inc +++ /dev/null @@ -1,99 +0,0 @@ -# $Id: Makefile.inc,v 1.15 1998/09/12 22:03:20 dt Exp $ - -# uthread sources -.PATH: ${.CURDIR}/uthread - -SRCS+= \ - uthread_accept.c \ - uthread_attr_destroy.c \ - uthread_attr_init.c \ - uthread_attr_getdetachstate.c \ - uthread_attr_getstackaddr.c \ - uthread_attr_getstacksize.c \ - uthread_attr_setcreatesuspend_np.c \ - uthread_attr_setdetachstate.c \ - uthread_attr_setstackaddr.c \ - uthread_attr_setstacksize.c \ - uthread_autoinit.cc \ - uthread_bind.c \ - uthread_clean.c \ - uthread_close.c \ - uthread_cond.c \ - uthread_condattr_destroy.c \ - uthread_condattr_init.c \ - uthread_connect.c \ - uthread_create.c \ - uthread_detach.c \ - uthread_dup.c \ - uthread_dup2.c \ - uthread_equal.c \ - uthread_execve.c \ - uthread_exit.c \ - uthread_fchmod.c \ - uthread_fchown.c \ - uthread_fcntl.c \ - uthread_fd.c \ - uthread_file.c \ - uthread_find_thread.c \ - uthread_flock.c \ - uthread_fork.c \ - uthread_fstat.c \ - uthread_fstatfs.c \ - uthread_fsync.c \ - uthread_gc.c \ - uthread_getdirentries.c \ - uthread_getpeername.c \ - uthread_getprio.c \ - uthread_getsockname.c \ - uthread_getsockopt.c \ - uthread_info.c \ - uthread_init.c \ - uthread_ioctl.c \ - uthread_join.c \ - uthread_kern.c \ - uthread_kill.c \ - uthread_listen.c \ - uthread_mattr_init.c \ - uthread_mattr_kind_np.c \ - uthread_multi_np.c \ - uthread_mutex.c \ - uthread_mutexattr_destroy.c \ - uthread_nanosleep.c \ - uthread_once.c \ - uthread_open.c \ - uthread_pipe.c \ - uthread_queue.c \ - uthread_read.c \ - uthread_readv.c \ - uthread_recvfrom.c \ - uthread_recvmsg.c \ - uthread_resume_np.c \ - uthread_rwlock.c \ - uthread_rwlockattr.c \ - uthread_select.c \ - uthread_self.c \ - uthread_sendmsg.c \ - uthread_sendto.c \ - uthread_seterrno.c \ - uthread_setprio.c \ - uthread_setsockopt.c \ - uthread_shutdown.c \ - uthread_sig.c \ - uthread_sigaction.c \ - uthread_sigblock.c \ - uthread_sigmask.c \ - uthread_sigprocmask.c \ - uthread_sigsetmask.c \ - uthread_sigsuspend.c \ - uthread_sigwait.c \ - uthread_single_np.c \ - uthread_socket.c \ - uthread_socketpair.c \ - uthread_spec.c \ - uthread_spinlock.c \ - uthread_suspend_np.c \ - uthread_vfork.c \ - uthread_wait4.c \ - uthread_write.c \ - uthread_writev.c \ - uthread_yield.c diff --git a/lib/libkse/thread/thr_attr_destroy.c b/lib/libkse/thread/thr_attr_destroy.c deleted file mode 100644 index 1f4b2c8523c33..0000000000000 --- a/lib/libkse/thread/thr_attr_destroy.c +++ /dev/null @@ -1,60 +0,0 @@ -/* - * Copyright (c) 1996 John Birrell <jb@cimlogic.com.au>. - * 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 John Birrell. - * 4. Neither the name of the author nor the names of any co-contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY JOHN BIRRELL 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 <stdlib.h> -#include <errno.h> -#ifdef _THREAD_SAFE -#include <pthread.h> -#include "pthread_private.h" - -int pthread_attr_destroy(pthread_attr_t *attr) -{ - int ret; - - /* Check for invalid arguments: */ - if (attr == NULL || *attr == NULL) - /* Invalid argument: */ - ret = EINVAL; - else { - /* Free the memory allocated to the attribute object: */ - free(*attr); - - /* - * Leave the attribute pointer NULL now that the memory - * has been freed: - */ - *attr = NULL; - ret = 0; - } - return(ret); -} -#endif diff --git a/lib/libkse/thread/thr_attr_getdetachstate.c b/lib/libkse/thread/thr_attr_getdetachstate.c deleted file mode 100644 index 4715cb6f24244..0000000000000 --- a/lib/libkse/thread/thr_attr_getdetachstate.c +++ /dev/null @@ -1,57 +0,0 @@ -/* - * Copyright (c) 1997 John Birrell <jb@cimlogic.com.au>. - * 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 John Birrell. - * 4. Neither the name of the author nor the names of any co-contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY JOHN BIRRELL 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 <errno.h> -#ifdef _THREAD_SAFE -#include <pthread.h> -#include "pthread_private.h" - -int pthread_attr_getdetachstate(pthread_attr_t *attr, int *detachstate) -{ - int ret; - - /* Check for invalid arguments: */ - if (attr == NULL || *attr == NULL || detachstate == NULL) - ret = EINVAL; - else { - /* Check if the detached flag is set: */ - if ((*attr)->flags & PTHREAD_DETACHED) - /* Return detached: */ - *detachstate = PTHREAD_CREATE_DETACHED; - else - /* Return joinable: */ - *detachstate = PTHREAD_CREATE_JOINABLE; - ret = 0; - } - return(ret); -} -#endif diff --git a/lib/libkse/thread/thr_attr_getstackaddr.c b/lib/libkse/thread/thr_attr_getstackaddr.c deleted file mode 100644 index 1850a324c611f..0000000000000 --- a/lib/libkse/thread/thr_attr_getstackaddr.c +++ /dev/null @@ -1,52 +0,0 @@ -/* - * Copyright (c) 1997 John Birrell <jb@cimlogic.com.au>. - * 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 John Birrell. - * 4. Neither the name of the author nor the names of any co-contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY JOHN BIRRELL 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 <errno.h> -#ifdef _THREAD_SAFE -#include <pthread.h> -#include "pthread_private.h" - -int pthread_attr_getstackaddr(pthread_attr_t *attr, void **stackaddr) -{ - int ret; - - /* Check for invalid arguments: */ - if (attr == NULL || *attr == NULL || stackaddr == NULL) - ret = EINVAL; - else { - /* Return the stack address: */ - *stackaddr = (*attr)->stackaddr_attr; - ret = 0; - } - return(ret); -} -#endif diff --git a/lib/libkse/thread/thr_attr_getstacksize.c b/lib/libkse/thread/thr_attr_getstacksize.c deleted file mode 100644 index de81106083d49..0000000000000 --- a/lib/libkse/thread/thr_attr_getstacksize.c +++ /dev/null @@ -1,52 +0,0 @@ -/* - * Copyright (c) 1997 John Birrell <jb@cimlogic.com.au>. - * 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 John Birrell. - * 4. Neither the name of the author nor the names of any co-contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY JOHN BIRRELL 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 <errno.h> -#ifdef _THREAD_SAFE -#include <pthread.h> -#include "pthread_private.h" - -int pthread_attr_getstacksize(pthread_attr_t *attr, size_t *stacksize) -{ - int ret; - - /* Check for invalid arguments: */ - if (attr == NULL || *attr == NULL || stacksize == NULL) - ret = EINVAL; - else { - /* Return the stack size: */ - *stacksize = (*attr)->stacksize_attr; - ret = 0; - } - return(ret); -} -#endif diff --git a/lib/libkse/thread/thr_attr_init.c b/lib/libkse/thread/thr_attr_init.c deleted file mode 100644 index c64e29fed11cc..0000000000000 --- a/lib/libkse/thread/thr_attr_init.c +++ /dev/null @@ -1,59 +0,0 @@ -/* - * Copyright (c) 1996 John Birrell <jb@cimlogic.com.au>. - * 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 John Birrell. - * 4. Neither the name of the author nor the names of any co-contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY JOHN BIRRELL 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 <string.h> -#include <stdlib.h> -#include <errno.h> -#ifdef _THREAD_SAFE -#include <pthread.h> -#include "pthread_private.h" - -int pthread_attr_init(pthread_attr_t *attr) -{ - int ret; - pthread_attr_t pattr; - - /* Allocate memory for the attribute object: */ - if ((pattr = (pthread_attr_t) malloc(sizeof(struct pthread_attr))) == NULL) - /* Insufficient memory: */ - ret = ENOMEM; - else { - /* Initialise the attribute object with the defaults: */ - memcpy(pattr, &pthread_attr_default, sizeof(struct pthread_attr)); - - /* Return a pointer to the attribute object: */ - *attr = pattr; - ret = 0; - } - return(ret); -} -#endif diff --git a/lib/libkse/thread/thr_attr_setcreatesuspend_np.c b/lib/libkse/thread/thr_attr_setcreatesuspend_np.c deleted file mode 100644 index afe6b23c3cb27..0000000000000 --- a/lib/libkse/thread/thr_attr_setcreatesuspend_np.c +++ /dev/null @@ -1,51 +0,0 @@ -/* - * Copyright (c) 1995 John Birrell <jb@cimlogic.com.au>. - * 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 John Birrell. - * 4. Neither the name of the author nor the names of any co-contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY JOHN BIRRELL 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 <errno.h> -#ifdef _THREAD_SAFE -#include <pthread.h> -#include "pthread_private.h" - -int -pthread_attr_setcreatesuspend_np(pthread_attr_t *attr) -{ - int ret; - if (attr == NULL || *attr == NULL) { - errno = EINVAL; - ret = -1; - } else { - (*attr)->suspend = PTHREAD_CREATE_SUSPENDED; - ret = 0; - } - return(ret); -} -#endif diff --git a/lib/libkse/thread/thr_attr_setdetachstate.c b/lib/libkse/thread/thr_attr_setdetachstate.c deleted file mode 100644 index 6ec0dbc1c585d..0000000000000 --- a/lib/libkse/thread/thr_attr_setdetachstate.c +++ /dev/null @@ -1,59 +0,0 @@ -/* - * Copyright (c) 1997 John Birrell <jb@cimlogic.com.au>. - * 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 John Birrell. - * 4. Neither the name of the author nor the names of any co-contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY JOHN BIRRELL 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 <errno.h> -#ifdef _THREAD_SAFE -#include <pthread.h> -#include "pthread_private.h" - -int pthread_attr_setdetachstate(pthread_attr_t *attr, int detachstate) -{ - int ret; - - /* Check for invalid arguments: */ - if (attr == NULL || *attr == NULL || - (detachstate != PTHREAD_CREATE_DETACHED && - detachstate != PTHREAD_CREATE_JOINABLE)) - ret = EINVAL; - else { - /* Check if detached state: */ - if (detachstate == PTHREAD_CREATE_DETACHED) - /* Set the detached flag: */ - (*attr)->flags |= PTHREAD_DETACHED; - else - /* Reset the detached flag: */ - (*attr)->flags &= ~PTHREAD_DETACHED; - ret = 0; - } - return(ret); -} -#endif diff --git a/lib/libkse/thread/thr_attr_setstackaddr.c b/lib/libkse/thread/thr_attr_setstackaddr.c deleted file mode 100644 index ce54915d096d2..0000000000000 --- a/lib/libkse/thread/thr_attr_setstackaddr.c +++ /dev/null @@ -1,52 +0,0 @@ -/* - * Copyright (c) 1997 John Birrell <jb@cimlogic.com.au>. - * 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 John Birrell. - * 4. Neither the name of the author nor the names of any co-contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY JOHN BIRRELL 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 <errno.h> -#ifdef _THREAD_SAFE -#include <pthread.h> -#include "pthread_private.h" - -int pthread_attr_setstackaddr(pthread_attr_t *attr, void *stackaddr) -{ - int ret; - - /* Check for invalid arguments: */ - if (attr == NULL || *attr == NULL || stackaddr == NULL) - ret = EINVAL; - else { - /* Save the stack address: */ - (*attr)->stackaddr_attr = stackaddr; - ret = 0; - } - return(ret); -} -#endif diff --git a/lib/libkse/thread/thr_attr_setstacksize.c b/lib/libkse/thread/thr_attr_setstacksize.c deleted file mode 100644 index 94e575e0ddedf..0000000000000 --- a/lib/libkse/thread/thr_attr_setstacksize.c +++ /dev/null @@ -1,52 +0,0 @@ -/* - * Copyright (c) 1996 John Birrell <jb@cimlogic.com.au>. - * 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 John Birrell. - * 4. Neither the name of the author nor the names of any co-contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY JOHN BIRRELL 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 <errno.h> -#ifdef _THREAD_SAFE -#include <pthread.h> -#include "pthread_private.h" - -int pthread_attr_setstacksize(pthread_attr_t *attr, size_t stacksize) -{ - int ret; - - /* Check for invalid arguments: */ - if (attr == NULL || *attr == NULL || stacksize < PTHREAD_STACK_MIN) - ret = EINVAL; - else { - /* Save the stack size: */ - (*attr)->stacksize_attr = stacksize; - ret = 0; - } - return(ret); -} -#endif diff --git a/lib/libkse/thread/thr_clean.c b/lib/libkse/thread/thr_clean.c deleted file mode 100644 index 9319f85efbea0..0000000000000 --- a/lib/libkse/thread/thr_clean.c +++ /dev/null @@ -1,68 +0,0 @@ -/* - * Copyright (c) 1995 John Birrell <jb@cimlogic.com.au>. - * 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 John Birrell. - * 4. Neither the name of the author nor the names of any co-contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY JOHN BIRRELL 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 <signal.h> -#include <errno.h> -#include <stdlib.h> -#ifdef _THREAD_SAFE -#include <pthread.h> -#include "pthread_private.h" - -void -pthread_cleanup_push(void (*routine) (void *), void *routine_arg) -{ - struct pthread_cleanup *new; - - if ((new = (struct pthread_cleanup *) malloc(sizeof(struct pthread_cleanup))) != NULL) { - new->routine = routine; - new->routine_arg = routine_arg; - new->next = _thread_run->cleanup; - - _thread_run->cleanup = new; - } -} - -void -pthread_cleanup_pop(int execute) -{ - struct pthread_cleanup *old; - - if ((old = _thread_run->cleanup) != NULL) { - _thread_run->cleanup = old->next; - if (execute) { - old->routine(old->routine_arg); - } - free(old); - } -} - -#endif diff --git a/lib/libkse/thread/thr_close.c b/lib/libkse/thread/thr_close.c deleted file mode 100644 index 7e21853223e86..0000000000000 --- a/lib/libkse/thread/thr_close.c +++ /dev/null @@ -1,89 +0,0 @@ -/* - * Copyright (c) 1995-1998 John Birrell <jb@cimlogic.com.au> - * 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 John Birrell. - * 4. Neither the name of the author nor the names of any co-contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY JOHN BIRRELL 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 <stdlib.h> -#include <unistd.h> -#include <fcntl.h> -#include <sys/stat.h> -#ifdef _THREAD_SAFE -#include <pthread.h> -#include "pthread_private.h" - -int -close(int fd) -{ - int flags; - int ret; - int status; - struct stat sb; - - /* Lock the file descriptor while the file is closed: */ - if ((ret = _FD_LOCK(fd, FD_RDWR, NULL)) == 0) { - /* Get file descriptor status. */ - _thread_sys_fstat(fd, &sb); - - /* - * Check if the file should be left as blocking. - * - * This is so that the file descriptors shared with a parent - * process aren't left set to non-blocking if the child - * closes them prior to exit. An example where this causes - * problems with /bin/sh is when a child closes stdin. - * - * Setting a file as blocking causes problems if a threaded - * parent accesses the file descriptor before the child exits. - * Once the threaded parent receives a SIGCHLD then it resets - * all of its files to non-blocking, and so it is then safe - * to access them. - * - * Pipes are not set to blocking when they are closed, as - * the parent and child will normally close the file - * descriptor of the end of the pipe that they are not - * using, which would then cause any reads to block - * indefinitely. - */ - if ((S_ISREG(sb.st_mode) || S_ISCHR(sb.st_mode)) && (_thread_fd_table[fd]->flags & O_NONBLOCK) == 0) { - /* Get the current flags: */ - flags = _thread_sys_fcntl(fd, F_GETFL, NULL); - /* Clear the nonblocking file descriptor flag: */ - _thread_sys_fcntl(fd, F_SETFL, flags & ~O_NONBLOCK); - } - - /* Close the file descriptor: */ - ret = _thread_sys_close(fd); - - free(_thread_fd_table[fd]); - _thread_fd_table[fd] = NULL; - } - return (ret); -} -#endif diff --git a/lib/libkse/thread/thr_cond.c b/lib/libkse/thread/thr_cond.c deleted file mode 100644 index a085ea60fa899..0000000000000 --- a/lib/libkse/thread/thr_cond.c +++ /dev/null @@ -1,353 +0,0 @@ -/* - * Copyright (c) 1995 John Birrell <jb@cimlogic.com.au>. - * 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 John Birrell. - * 4. Neither the name of the author nor the names of any co-contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY JOHN BIRRELL 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 <stdlib.h> -#include <errno.h> -#include <string.h> -#ifdef _THREAD_SAFE -#include <pthread.h> -#include "pthread_private.h" - -int -pthread_cond_init(pthread_cond_t * cond, const pthread_condattr_t * cond_attr) -{ - enum pthread_cond_type type; - pthread_cond_t pcond; - int rval = 0; - - if (cond == NULL) - rval = EINVAL; - else { - /* - * Check if a pointer to a condition variable attribute - * structure was passed by the caller: - */ - if (cond_attr != NULL && *cond_attr != NULL) { - /* Default to a fast condition variable: */ - type = (*cond_attr)->c_type; - } else { - /* Default to a fast condition variable: */ - type = COND_TYPE_FAST; - } - - /* Process according to condition variable type: */ - switch (type) { - /* Fast condition variable: */ - case COND_TYPE_FAST: - /* Nothing to do here. */ - break; - - /* Trap invalid condition variable types: */ - default: - /* Return an invalid argument error: */ - rval = EINVAL; - break; - } - - /* Check for no errors: */ - if (rval == 0) { - if ((pcond = (pthread_cond_t) - malloc(sizeof(struct pthread_cond))) == NULL) { - rval = ENOMEM; - } else { - /* - * Initialise the condition variable - * structure: - */ - _thread_queue_init(&pcond->c_queue); - pcond->c_flags |= COND_FLAGS_INITED; - pcond->c_type = type; - memset(&pcond->lock,0,sizeof(pcond->lock)); - *cond = pcond; - } - } - } - /* Return the completion status: */ - return (rval); -} - -int -pthread_cond_destroy(pthread_cond_t * cond) -{ - int rval = 0; - - if (cond == NULL || *cond == NULL) - rval = EINVAL; - else { - /* Lock the condition variable structure: */ - _SPINLOCK(&(*cond)->lock); - - /* - * Free the memory allocated for the condition - * variable structure: - */ - free(*cond); - - /* - * NULL the caller's pointer now that the condition - * variable has been destroyed: - */ - *cond = NULL; - } - /* Return the completion status: */ - return (rval); -} - -int -pthread_cond_wait(pthread_cond_t * cond, pthread_mutex_t * mutex) -{ - int rval = 0; - int status; - - if (cond == NULL) - rval = EINVAL; - - /* - * If the condition variable is statically initialized, - * perform the dynamic initialization: - */ - else if (*cond != NULL || - (rval = pthread_cond_init(cond,NULL)) == 0) { - /* Lock the condition variable structure: */ - _SPINLOCK(&(*cond)->lock); - - /* Process according to condition variable type: */ - switch ((*cond)->c_type) { - /* Fast condition variable: */ - case COND_TYPE_FAST: - /* Wait forever: */ - _thread_run->wakeup_time.tv_sec = -1; - - /* - * Queue the running thread for the condition - * variable: - */ - _thread_queue_enq(&(*cond)->c_queue, _thread_run); - - /* Unlock the mutex: */ - if ((rval = pthread_mutex_unlock(mutex)) != 0) { - /* - * Cannot unlock the mutex, so remove the - * running thread from the condition - * variable queue: - */ - _thread_queue_deq(&(*cond)->c_queue); - - /* Unlock the condition variable structure: */ - _SPINUNLOCK(&(*cond)->lock); - } else { - /* Schedule the next thread: */ - _thread_kern_sched_state_unlock(PS_COND_WAIT, - &(*cond)->lock, __FILE__, __LINE__); - - /* Lock the mutex: */ - rval = pthread_mutex_lock(mutex); - } - break; - - /* Trap invalid condition variable types: */ - default: - /* Unlock the condition variable structure: */ - _SPINUNLOCK(&(*cond)->lock); - - /* Return an invalid argument error: */ - rval = EINVAL; - break; - } - - } - - /* Return the completion status: */ - return (rval); -} - -int -pthread_cond_timedwait(pthread_cond_t * cond, pthread_mutex_t * mutex, - const struct timespec * abstime) -{ - int rval = 0; - int status; - - if (cond == NULL) - rval = EINVAL; - - /* - * If the condition variable is statically initialized, - * perform the dynamic initialization: - */ - else if (*cond != NULL || - (rval = pthread_cond_init(cond,NULL)) == 0) { - /* Lock the condition variable structure: */ - _SPINLOCK(&(*cond)->lock); - - /* Process according to condition variable type: */ - switch ((*cond)->c_type) { - /* Fast condition variable: */ - case COND_TYPE_FAST: - /* Set the wakeup time: */ - _thread_run->wakeup_time.tv_sec = abstime->tv_sec; - _thread_run->wakeup_time.tv_nsec = abstime->tv_nsec; - - /* Reset the timeout flag: */ - _thread_run->timeout = 0; - - /* - * Queue the running thread for the condition - * variable: - */ - _thread_queue_enq(&(*cond)->c_queue, _thread_run); - - /* Unlock the mutex: */ - if ((rval = pthread_mutex_unlock(mutex)) != 0) { - /* - * Cannot unlock the mutex, so remove the - * running thread from the condition - * variable queue: - */ - _thread_queue_deq(&(*cond)->c_queue); - - /* Unlock the condition variable structure: */ - _SPINUNLOCK(&(*cond)->lock); - } else { - /* Schedule the next thread: */ - _thread_kern_sched_state_unlock(PS_COND_WAIT, - &(*cond)->lock, __FILE__, __LINE__); - - /* Lock the mutex: */ - if ((rval = pthread_mutex_lock(mutex)) != 0) { - } - /* Check if the wait timed out: */ - else if (_thread_run->timeout) { - /* Return a timeout error: */ - rval = ETIMEDOUT; - } - } - break; - - /* Trap invalid condition variable types: */ - default: - /* Unlock the condition variable structure: */ - _SPINUNLOCK(&(*cond)->lock); - - /* Return an invalid argument error: */ - rval = EINVAL; - break; - } - - } - - /* Return the completion status: */ - return (rval); -} - -int -pthread_cond_signal(pthread_cond_t * cond) -{ - int rval = 0; - int status; - pthread_t pthread; - - if (cond == NULL || *cond == NULL) - rval = EINVAL; - else { - /* Lock the condition variable structure: */ - _SPINLOCK(&(*cond)->lock); - - /* Process according to condition variable type: */ - switch ((*cond)->c_type) { - /* Fast condition variable: */ - case COND_TYPE_FAST: - /* Bring the next thread off the condition queue: */ - if ((pthread = _thread_queue_deq(&(*cond)->c_queue)) != NULL) { - /* Allow the thread to run: */ - PTHREAD_NEW_STATE(pthread,PS_RUNNING); - } - break; - - /* Trap invalid condition variable types: */ - default: - /* Return an invalid argument error: */ - rval = EINVAL; - break; - } - - /* Unlock the condition variable structure: */ - _SPINUNLOCK(&(*cond)->lock); - } - - /* Return the completion status: */ - return (rval); -} - -int -pthread_cond_broadcast(pthread_cond_t * cond) -{ - int rval = 0; - int status; - pthread_t pthread; - - if (cond == NULL || *cond == NULL) - rval = EINVAL; - else { - /* Lock the condition variable structure: */ - _SPINLOCK(&(*cond)->lock); - - /* Process according to condition variable type: */ - switch ((*cond)->c_type) { - /* Fast condition variable: */ - case COND_TYPE_FAST: - /* - * Enter a loop to bring all threads off the - * condition queue: - */ - while ((pthread = - _thread_queue_deq(&(*cond)->c_queue)) != NULL) { - /* Allow the thread to run: */ - PTHREAD_NEW_STATE(pthread,PS_RUNNING); - } - break; - - /* Trap invalid condition variable types: */ - default: - /* Return an invalid argument error: */ - rval = EINVAL; - break; - } - - /* Unlock the condition variable structure: */ - _SPINUNLOCK(&(*cond)->lock); - } - - /* Return the completion status: */ - return (rval); -} -#endif diff --git a/lib/libkse/thread/thr_condattr_destroy.c b/lib/libkse/thread/thr_condattr_destroy.c deleted file mode 100644 index 4179970ad9db8..0000000000000 --- a/lib/libkse/thread/thr_condattr_destroy.c +++ /dev/null @@ -1,51 +0,0 @@ -/* - * Copyright (c) 1997 John Birrell <jb@cimlogic.com.au>. - * 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 John Birrell. - * 4. Neither the name of the author nor the names of any co-contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY JOHN BIRRELL 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 <stdlib.h> -#include <errno.h> -#ifdef _THREAD_SAFE -#include <pthread.h> -#include "pthread_private.h" - -int pthread_condattr_destroy(pthread_condattr_t *attr) -{ - int ret; - if (attr == NULL || *attr == NULL) { - ret = EINVAL; - } else { - free(*attr); - *attr = NULL; - ret = 0; - } - return(ret); -} -#endif diff --git a/lib/libkse/thread/thr_condattr_init.c b/lib/libkse/thread/thr_condattr_init.c deleted file mode 100644 index c87323dc1978d..0000000000000 --- a/lib/libkse/thread/thr_condattr_init.c +++ /dev/null @@ -1,57 +0,0 @@ -/* - * Copyright (c) 1997 John Birrell <jb@cimlogic.com.au> - * 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 John Birrell. - * 4. Neither the name of the author nor the names of any co-contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY JOHN BIRRELL 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 <string.h> -#include <stdlib.h> -#include <errno.h> -#ifdef _THREAD_SAFE -#include <pthread.h> -#include "pthread_private.h" - -int -pthread_condattr_init(pthread_condattr_t *attr) -{ - int ret; - pthread_condattr_t pattr; - - if ((pattr = (pthread_condattr_t) - malloc(sizeof(struct pthread_cond_attr))) == NULL) { - ret = ENOMEM; - } else { - memcpy(pattr, &pthread_condattr_default, - sizeof(struct pthread_cond_attr)); - *attr = pattr; - ret = 0; - } - return(ret); -} -#endif diff --git a/lib/libkse/thread/thr_create.c b/lib/libkse/thread/thr_create.c deleted file mode 100644 index 416946131add2..0000000000000 --- a/lib/libkse/thread/thr_create.c +++ /dev/null @@ -1,235 +0,0 @@ -/* - * Copyright (c) 1995-1998 John Birrell <jb@cimlogic.com.au> - * 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 John Birrell. - * 4. Neither the name of the author nor the names of any co-contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY JOHN BIRRELL 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 <errno.h> -#include <stdlib.h> -#include <string.h> -#include <fcntl.h> -#include <unistd.h> -#include <sys/time.h> -#ifdef _THREAD_SAFE -#include <machine/reg.h> -#include <pthread.h> -#include "pthread_private.h" -#include "libc_private.h" - -int -pthread_create(pthread_t * thread, const pthread_attr_t * attr, - void *(*start_routine) (void *), void *arg) -{ - int f_gc = 0; - int i; - int ret = 0; - int status; - pthread_t gc_thread; - pthread_t new_thread; - pthread_attr_t pattr; - void *stack; - - /* - * Locking functions in libc are required when there are - * threads other than the initial thread. - */ - __isthreaded = 1; - - /* Allocate memory for the thread structure: */ - if ((new_thread = (pthread_t) malloc(sizeof(struct pthread))) == NULL) { - /* Insufficient memory to create a thread: */ - ret = EAGAIN; - } else { - /* Check if default thread attributes are required: */ - if (attr == NULL || *attr == NULL) { - /* Use the default thread attributes: */ - pattr = &pthread_attr_default; - } else { - pattr = *attr; - } - /* Check if a stack was specified in the thread attributes: */ - if ((stack = pattr->stackaddr_attr) != NULL) { - } - /* Allocate memory for the stack: */ - else if ((stack = (void *) malloc(pattr->stacksize_attr)) == NULL) { - /* Insufficient memory to create a thread: */ - ret = EAGAIN; - free(new_thread); - } - /* Check for errors: */ - if (ret != 0) { - } else { - /* Initialise the thread structure: */ - memset(new_thread, 0, sizeof(struct pthread)); - new_thread->slice_usec = -1; - new_thread->sig_saved = 0; - new_thread->stack = stack; - new_thread->start_routine = start_routine; - new_thread->arg = arg; - - /* - * Write a magic value to the thread structure - * to help identify valid ones: - */ - new_thread->magic = PTHREAD_MAGIC; - - if (pattr->suspend == PTHREAD_CREATE_SUSPENDED) { - PTHREAD_NEW_STATE(new_thread,PS_SUSPENDED); - } else { - PTHREAD_NEW_STATE(new_thread,PS_RUNNING); - } - - /* Initialise the thread for signals: */ - new_thread->sigmask = _thread_run->sigmask; - - /* Initialise the jump buffer: */ - setjmp(new_thread->saved_jmp_buf); - - /* - * Set up new stack frame so that it looks like it - * returned from a longjmp() to the beginning of - * _thread_start(). - */ -#if defined(__FreeBSD__) -#if defined(__alpha__) - new_thread->saved_jmp_buf[0]._jb[2] = (long) _thread_start; - new_thread->saved_jmp_buf[0]._jb[4 + R_RA] = 0; - new_thread->saved_jmp_buf[0]._jb[4 + R_T12] = (long) _thread_start; -#else - new_thread->saved_jmp_buf[0]._jb[0] = (long) _thread_start; -#endif -#elif defined(__NetBSD__) -#if defined(__alpha__) - new_thread->saved_jmp_buf[2] = (long) _thread_start; - new_thread->saved_jmp_buf[4 + R_RA] = 0; - new_thread->saved_jmp_buf[4 + R_T12] = (long) _thread_start; -#else - new_thread->saved_jmp_buf[0] = (long) _thread_start; -#endif -#else -#error "Don't recognize this operating system!" -#endif - - /* The stack starts high and builds down: */ -#if defined(__FreeBSD__) -#if defined(__alpha__) - new_thread->saved_jmp_buf[0]._jb[4 + R_SP] = (long) new_thread->stack + pattr->stacksize_attr - sizeof(double); -#else - new_thread->saved_jmp_buf[0]._jb[2] = (int) (new_thread->stack + pattr->stacksize_attr - sizeof(double)); -#endif -#elif defined(__NetBSD__) -#if defined(__alpha__) - new_thread->saved_jmp_buf[4 + R_SP] = (long) new_thread->stack + pattr->stacksize_attr - sizeof(double); -#else - new_thread->saved_jmp_buf[2] = (long) new_thread->stack + pattr->stacksize_attr - sizeof(double); -#endif -#else -#error "Don't recognize this operating system!" -#endif - - /* Copy the thread attributes: */ - memcpy(&new_thread->attr, pattr, sizeof(struct pthread_attr)); - - /* - * Check if this thread is to inherit the scheduling - * attributes from its parent: - */ - if (new_thread->attr.flags & PTHREAD_INHERIT_SCHED) { - /* Copy the scheduling attributes: */ - new_thread->pthread_priority = _thread_run->pthread_priority; - new_thread->attr.prio = _thread_run->pthread_priority; - new_thread->attr.schedparam_policy = _thread_run->attr.schedparam_policy; - } else { - /* - * Use just the thread priority, leaving the - * other scheduling attributes as their - * default values: - */ - new_thread->pthread_priority = new_thread->attr.prio; - } - - /* Initialise the join queue for the new thread: */ - _thread_queue_init(&(new_thread->join_queue)); - - /* Initialise hooks in the thread structure: */ - new_thread->specific_data = NULL; - new_thread->cleanup = NULL; - new_thread->queue = NULL; - new_thread->qnxt = NULL; - new_thread->flags = 0; - - /* Lock the thread list: */ - _lock_thread_list(); - - /* - * Check if the garbage collector thread - * needs to be started. - */ - f_gc = (_thread_link_list == _thread_initial); - - /* Add the thread to the linked list of all threads: */ - new_thread->nxt = _thread_link_list; - _thread_link_list = new_thread; - - /* Unlock the thread list: */ - _unlock_thread_list(); - - /* Return a pointer to the thread structure: */ - (*thread) = new_thread; - - /* Schedule the new user thread: */ - _thread_kern_sched(NULL); - - /* - * Start a garbage collector thread - * if necessary. - */ - if (f_gc && pthread_create(&gc_thread,NULL, - _thread_gc,NULL) != 0) - PANIC("Can't create gc thread"); - } - } - - /* Return the status: */ - return (ret); -} - -void -_thread_start(void) -{ - /* We just left the scheduler via longjmp: */ - _thread_kern_in_sched = 0; - - /* Run the current thread's start routine with argument: */ - pthread_exit(_thread_run->start_routine(_thread_run->arg)); - - /* This point should never be reached. */ - PANIC("Thread has resumed after exit"); -} -#endif diff --git a/lib/libkse/thread/thr_detach.c b/lib/libkse/thread/thr_detach.c deleted file mode 100644 index da456bfbab90d..0000000000000 --- a/lib/libkse/thread/thr_detach.c +++ /dev/null @@ -1,67 +0,0 @@ -/* - * Copyright (c) 1995 John Birrell <jb@cimlogic.com.au>. - * 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 John Birrell. - * 4. Neither the name of the author nor the names of any co-contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY JOHN BIRRELL 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 <errno.h> -#ifdef _THREAD_SAFE -#include <pthread.h> -#include "pthread_private.h" - -int -pthread_detach(pthread_t pthread) -{ - int rval = 0; - int status; - pthread_t next_thread; - - /* Check for invalid calling parameters: */ - if (pthread == NULL || pthread->magic != PTHREAD_MAGIC) - /* Return an invalid argument error: */ - rval = EINVAL; - - /* Check if the thread has not been detached: */ - else if ((pthread->attr.flags & PTHREAD_DETACHED) == 0) { - /* Flag the thread as detached: */ - pthread->attr.flags |= PTHREAD_DETACHED; - - /* Enter a loop to bring all threads off the join queue: */ - while ((next_thread = _thread_queue_deq(&pthread->join_queue)) != NULL) { - /* Make the thread run: */ - PTHREAD_NEW_STATE(next_thread,PS_RUNNING); - } - } else - /* Return an error: */ - rval = EINVAL; - - /* Return the completion status: */ - return (rval); -} -#endif diff --git a/lib/libkse/thread/thr_equal.c b/lib/libkse/thread/thr_equal.c deleted file mode 100644 index 99ffb5d8b7d7c..0000000000000 --- a/lib/libkse/thread/thr_equal.c +++ /dev/null @@ -1,43 +0,0 @@ -/* - * Copyright (c) 1995 John Birrell <jb@cimlogic.com.au>. - * 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 John Birrell. - * 4. Neither the name of the author nor the names of any co-contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY JOHN BIRRELL 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. - * - */ -#ifdef _THREAD_SAFE -#include <pthread.h> -#include "pthread_private.h" - -int -pthread_equal(pthread_t t1, pthread_t t2) -{ - /* Compare the two thread pointers: */ - return (t1 == t2); -} -#endif diff --git a/lib/libkse/thread/thr_exit.c b/lib/libkse/thread/thr_exit.c deleted file mode 100644 index a5fc4001e4143..0000000000000 --- a/lib/libkse/thread/thr_exit.c +++ /dev/null @@ -1,164 +0,0 @@ -/* - * Copyright (c) 1995-1998 John Birrell <jb@cimlogic.com.au> - * 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 John Birrell. - * 4. Neither the name of the author nor the names of any co-contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY JOHN BIRRELL 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 <errno.h> -#include <unistd.h> -#include <fcntl.h> -#include <string.h> -#ifdef _THREAD_SAFE -#include <pthread.h> -#include "pthread_private.h" - -void _exit(int status) -{ - int flags; - int i; - struct itimerval itimer; - - /* Disable the interval timer: */ - itimer.it_interval.tv_sec = 0; - itimer.it_interval.tv_usec = 0; - itimer.it_value.tv_sec = 0; - itimer.it_value.tv_usec = 0; - setitimer(ITIMER_VIRTUAL, &itimer, NULL); - - /* Close the pthread kernel pipe: */ - _thread_sys_close(_thread_kern_pipe[0]); - _thread_sys_close(_thread_kern_pipe[1]); - - /* - * Enter a loop to set all file descriptors to blocking - * if they were not created as non-blocking: - */ - for (i = 0; i < _thread_dtablesize; i++) { - /* Check if this file descriptor is in use: */ - if (_thread_fd_table[i] != NULL && - !(_thread_fd_table[i]->flags & O_NONBLOCK)) { - /* Get the current flags: */ - flags = _thread_sys_fcntl(i, F_GETFL, NULL); - /* Clear the nonblocking file descriptor flag: */ - _thread_sys_fcntl(i, F_SETFL, flags & ~O_NONBLOCK); - } - } - - /* Call the _exit syscall: */ - _thread_sys__exit(status); -} - -void -_thread_exit(char *fname, int lineno, char *string) -{ - char s[256]; - - /* Prepare an error message string: */ - strcpy(s, "Fatal error '"); - strcat(s, string); - strcat(s, "' at line ? "); - strcat(s, "in file "); - strcat(s, fname); - strcat(s, " (errno = ?"); - strcat(s, ")\n"); - - /* Write the string to the standard error file descriptor: */ - _thread_sys_write(2, s, strlen(s)); - - /* Force this process to exit: */ - _exit(1); -} - -void -pthread_exit(void *status) -{ - int sig; - long l; - pthread_t pthread; - - /* Check if this thread is already in the process of exiting: */ - if ((_thread_run->flags & PTHREAD_EXITING) != 0) { - char msg[128]; - snprintf(msg,"Thread %p has called pthread_exit() from a destructor. POSIX 1003.1 1996 s16.2.5.2 does not allow this!",_thread_run); - PANIC(msg); - } - - /* Flag this thread as exiting: */ - _thread_run->flags |= PTHREAD_EXITING; - - /* Save the return value: */ - _thread_run->ret = status; - - while (_thread_run->cleanup != NULL) { - pthread_cleanup_pop(1); - } - - if (_thread_run->attr.cleanup_attr != NULL) { - _thread_run->attr.cleanup_attr(_thread_run->attr.arg_attr); - } - /* Check if there is thread specific data: */ - if (_thread_run->specific_data != NULL) { - /* Run the thread-specific data destructors: */ - _thread_cleanupspecific(); - } - /* Check if there are any threads joined to this one: */ - while ((pthread = _thread_queue_deq(&(_thread_run->join_queue))) != NULL) { - /* Wake the joined thread and let it detach this thread: */ - PTHREAD_NEW_STATE(pthread,PS_RUNNING); - } - - /* - * Lock the garbage collector mutex to ensure that the garbage - * collector is not using the dead thread list. - */ - if (pthread_mutex_lock(&_gc_mutex) != 0) - PANIC("Cannot lock gc mutex"); - - /* Add this thread to the list of dead threads. */ - _thread_run->nxt_dead = _thread_dead; - _thread_dead = _thread_run; - - /* - * Signal the garbage collector thread that there is something - * to clean up. - */ - if (pthread_cond_signal(&_gc_cond) != 0) - PANIC("Cannot signal gc cond"); - - /* Unlock the garbage collector mutex: */ - if (pthread_mutex_unlock(&_gc_mutex) != 0) - PANIC("Cannot lock gc mutex"); - - /* This this thread will never be re-scheduled. */ - _thread_kern_sched_state(PS_DEAD, __FILE__, __LINE__); - - /* This point should not be reached. */ - PANIC("Dead thread has resumed"); -} -#endif diff --git a/lib/libkse/thread/thr_fcntl.c b/lib/libkse/thread/thr_fcntl.c deleted file mode 100644 index 6ea013afe5d77..0000000000000 --- a/lib/libkse/thread/thr_fcntl.c +++ /dev/null @@ -1,141 +0,0 @@ -/* - * Copyright (c) 1995-1998 John Birrell <jb@cimlogic.com.au> - * 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 John Birrell. - * 4. Neither the name of the author nor the names of any co-contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY JOHN BIRRELL 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 <stdarg.h> -#include <unistd.h> -#include <fcntl.h> -#ifdef _THREAD_SAFE -#include <pthread.h> -#include "pthread_private.h" - -int -fcntl(int fd, int cmd,...) -{ - int flags = 0; - int nonblock; - int oldfd; - int ret; - va_list ap; - - /* Lock the file descriptor: */ - if ((ret = _FD_LOCK(fd, FD_RDWR, NULL)) == 0) { - /* Initialise the variable argument list: */ - va_start(ap, cmd); - - /* Process according to file control command type: */ - switch (cmd) { - /* Duplicate a file descriptor: */ - case F_DUPFD: - /* - * Get the file descriptor that the caller wants to - * use: - */ - oldfd = va_arg(ap, int); - - /* Initialise the file descriptor table entry: */ - if ((ret = _thread_sys_fcntl(fd, cmd, oldfd)) < 0) { - } - /* Initialise the file descriptor table entry: */ - else if (_thread_fd_table_init(ret) != 0) { - /* Quietly close the file: */ - _thread_sys_close(ret); - - /* Reset the file descriptor: */ - ret = -1; - } else { - /* - * Save the file open flags so that they can - * be checked later: - */ - _thread_fd_table[ret]->flags = _thread_fd_table[fd]->flags; - } - break; - case F_SETFD: - flags = va_arg(ap, int); - ret = _thread_sys_fcntl(fd, cmd, flags); - break; - case F_GETFD: - ret = _thread_sys_fcntl(fd, cmd, 0); - break; - case F_GETFL: - ret = _thread_fd_table[fd]->flags; - break; - case F_SETFL: - /* - * Get the file descriptor flags passed by the - * caller: - */ - flags = va_arg(ap, int); - - /* - * Check if the user wants a non-blocking file - * descriptor: - */ - nonblock = flags & O_NONBLOCK; - - /* Set the file descriptor flags: */ - if ((ret = _thread_sys_fcntl(fd, cmd, flags | O_NONBLOCK)) != 0) { - - /* Get the flags so that we behave like the kernel: */ - } else if ((flags = _thread_sys_fcntl(fd, - F_GETFL, 0)) == -1) { - /* Error getting flags: */ - ret = -1; - - /* - * Check if the file descriptor is non-blocking - * with respect to the user: - */ - } else if (nonblock) - /* A non-blocking descriptor: */ - _thread_fd_table[fd]->flags = flags | O_NONBLOCK; - else - /* Save the flags: */ - _thread_fd_table[fd]->flags = flags & ~O_NONBLOCK; - break; - default: - /* Might want to make va_arg use a union */ - ret = _thread_sys_fcntl(fd, cmd, va_arg(ap, void *)); - break; - } - - /* Free variable arguments: */ - va_end(ap); - - /* Unlock the file descriptor: */ - _FD_UNLOCK(fd, FD_RDWR); - } - - /* Return the completion status: */ - return (ret); -} -#endif diff --git a/lib/libkse/thread/thr_find_thread.c b/lib/libkse/thread/thr_find_thread.c deleted file mode 100644 index e4a59a0d83f61..0000000000000 --- a/lib/libkse/thread/thr_find_thread.c +++ /dev/null @@ -1,102 +0,0 @@ -/* - * Copyright (c) 1998 John Birrell <jb@cimlogic.com.au>. - * 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 John Birrell. - * 4. Neither the name of the author nor the names of any co-contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY JOHN BIRRELL 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 <errno.h> -#ifdef _THREAD_SAFE -#include <pthread.h> -#include "pthread_private.h" - -/* Find a thread in the linked list of active threads: */ -int -_find_thread(pthread_t pthread) -{ - pthread_t pthread1; - - /* Check if the caller has specified an invalid thread: */ - if (pthread == NULL || pthread->magic != PTHREAD_MAGIC) - /* Invalid thread: */ - return(EINVAL); - - /* Lock the thread list: */ - _lock_thread_list(); - - /* Point to the first thread in the list: */ - pthread1 = _thread_link_list; - - /* Search for the thread to join to: */ - while (pthread1 != NULL && pthread1 != pthread) { - /* Point to the next thread: */ - pthread1 = pthread1->nxt; - } - - /* Unlock the thread list: */ - _unlock_thread_list(); - - /* Return zero if the thread exists: */ - return ((pthread1 != NULL) ? 0:ESRCH); -} - -/* Find a thread in the linked list of dead threads: */ -int -_find_dead_thread(pthread_t pthread) -{ - pthread_t pthread1; - - /* Check if the caller has specified an invalid thread: */ - if (pthread == NULL || pthread->magic != PTHREAD_MAGIC) - /* Invalid thread: */ - return(EINVAL); - - /* - * Lock the garbage collector mutex to ensure that the garbage - * collector is not using the dead thread list. - */ - if (pthread_mutex_lock(&_gc_mutex) != 0) - PANIC("Cannot lock gc mutex"); - - /* Point to the first thread in the list: */ - pthread1 = _thread_dead; - - /* Search for the thread to join to: */ - while (pthread1 != NULL && pthread1 != pthread) { - /* Point to the next thread: */ - pthread1 = pthread1->nxt_dead; - } - - /* Unlock the garbage collector mutex: */ - if (pthread_mutex_unlock(&_gc_mutex) != 0) - PANIC("Cannot lock gc mutex"); - - /* Return zero if the thread exists: */ - return ((pthread1 != NULL) ? 0:ESRCH); -} -#endif diff --git a/lib/libkse/thread/thr_fork.c b/lib/libkse/thread/thr_fork.c deleted file mode 100644 index 960c1dea7da35..0000000000000 --- a/lib/libkse/thread/thr_fork.c +++ /dev/null @@ -1,131 +0,0 @@ -/* - * Copyright (c) 1995-1998 John Birrell <jb@cimlogic.com.au> - * 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 John Birrell. - * 4. Neither the name of the author nor the names of any co-contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY JOHN BIRRELL 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 <errno.h> -#include <string.h> -#include <unistd.h> -#include <fcntl.h> -#ifdef _THREAD_SAFE -#include <pthread.h> -#include "pthread_private.h" - -pid_t -fork(void) -{ - int flags; - pid_t ret; - pthread_t pthread; - pthread_t pthread_next; - - /* Lock the thread list: */ - _lock_thread_list(); - - /* Fork a new process: */ - if ((ret = _thread_sys_fork()) != 0) { - /* Parent process or error. Nothing to do here. */ - } else { - /* Close the pthread kernel pipe: */ - _thread_sys_close(_thread_kern_pipe[0]); - _thread_sys_close(_thread_kern_pipe[1]); - - /* Reset signals pending for the running thread: */ - _thread_run->sigpend = 0; - - /* - * Create a pipe that is written to by the signal handler to - * prevent signals being missed in calls to - * _thread_sys_select: - */ - if (_thread_sys_pipe(_thread_kern_pipe) != 0) { - /* Cannot create pipe, so abort: */ - PANIC("Cannot create pthread kernel pipe for forked process"); - } - /* Get the flags for the read pipe: */ - else if ((flags = _thread_sys_fcntl(_thread_kern_pipe[0], F_GETFL, NULL)) == -1) { - /* Abort this application: */ - abort(); - } - /* Make the read pipe non-blocking: */ - else if (_thread_sys_fcntl(_thread_kern_pipe[0], F_SETFL, flags | O_NONBLOCK) == -1) { - /* Abort this application: */ - abort(); - } - /* Get the flags for the write pipe: */ - else if ((flags = _thread_sys_fcntl(_thread_kern_pipe[1], F_GETFL, NULL)) == -1) { - /* Abort this application: */ - abort(); - } - /* Make the write pipe non-blocking: */ - else if (_thread_sys_fcntl(_thread_kern_pipe[1], F_SETFL, flags | O_NONBLOCK) == -1) { - /* Abort this application: */ - abort(); - } else { - /* Point to the first thread in the list: */ - pthread = _thread_link_list; - - /* - * Enter a loop to remove all threads other than - * the running thread from the thread list: - */ - while (pthread != NULL) { - pthread_next = pthread->nxt; - if (pthread == _thread_run) { - _thread_link_list = pthread; - pthread->nxt = NULL; - } else { - if (pthread->attr.stackaddr_attr == - NULL && pthread->stack != NULL) - /* - * Free the stack of the - * dead thread: - */ - free(pthread->stack); - - if (pthread->specific_data != NULL) - free(pthread->specific_data); - - free(pthread); - } - - /* Point to the next thread: */ - pthread = pthread_next; - } - } - } - - /* Unock the thread list: */ - _unlock_thread_list(); - - /* Return the process ID: */ - return (ret); -} -#endif diff --git a/lib/libkse/thread/thr_fsync.c b/lib/libkse/thread/thr_fsync.c deleted file mode 100644 index 9141d47119ea4..0000000000000 --- a/lib/libkse/thread/thr_fsync.c +++ /dev/null @@ -1,49 +0,0 @@ -/* - * Copyright (c) 1995-1998 John Birrell <jb@cimlogic.com.au> - * 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 John Birrell. - * 4. Neither the name of the author nor the names of any co-contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY JOHN BIRRELL 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 <unistd.h> -#ifdef _THREAD_SAFE -#include <pthread.h> -#include "pthread_private.h" - -int -fsync(int fd) -{ - int ret; - - if ((ret = _FD_LOCK(fd, FD_RDWR, NULL)) == 0) { - ret = _thread_sys_fsync(fd); - _FD_UNLOCK(fd, FD_RDWR); - } - return (ret); -} -#endif diff --git a/lib/libkse/thread/thr_getprio.c b/lib/libkse/thread/thr_getprio.c deleted file mode 100644 index 708b8f1adf75a..0000000000000 --- a/lib/libkse/thread/thr_getprio.c +++ /dev/null @@ -1,56 +0,0 @@ -/* - * Copyright (c) 1995 John Birrell <jb@cimlogic.com.au>. - * 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 John Birrell. - * 4. Neither the name of the author nor the names of any co-contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY JOHN BIRRELL 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 <errno.h> -#ifdef _THREAD_SAFE -#include <pthread.h> -#include "pthread_private.h" - -int -pthread_getprio(pthread_t pthread) -{ - int ret; - - /* Find the thread in the list of active threads: */ - if ((ret = _find_thread(pthread)) == 0) - /* Get the thread priority: */ - ret = pthread->pthread_priority; - else { - /* Invalid thread: */ - errno = ret; - ret = -1; - } - - /* Return the thread priority or an error status: */ - return (ret); -} -#endif diff --git a/lib/libkse/thread/thr_info.c b/lib/libkse/thread/thr_info.c deleted file mode 100644 index f66dd2d6ddcf4..0000000000000 --- a/lib/libkse/thread/thr_info.c +++ /dev/null @@ -1,237 +0,0 @@ -/* - * Copyright (c) 1995-1998 John Birrell <jb@cimlogic.com.au> - * 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 John Birrell. - * 4. Neither the name of the author nor the names of any co-contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY JOHN BIRRELL 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 <stdio.h> -#include <fcntl.h> -#include <string.h> -#include <unistd.h> -#ifdef _THREAD_SAFE -#include <pthread.h> -#include <errno.h> -#include "pthread_private.h" - -struct s_thread_info { - enum pthread_state state; - char *name; -}; - -/* Static variables: */ -static const struct s_thread_info thread_info[] = { - {PS_RUNNING , "Running"}, - {PS_SIGTHREAD , "Waiting on signal thread"}, - {PS_MUTEX_WAIT , "Waiting on a mutex"}, - {PS_COND_WAIT , "Waiting on a condition variable"}, - {PS_FDLR_WAIT , "Waiting for a file read lock"}, - {PS_FDLW_WAIT , "Waiting for a file write lock"}, - {PS_FDR_WAIT , "Waiting for read"}, - {PS_FDW_WAIT , "Waiting for write"}, - {PS_FILE_WAIT , "Waiting for FILE lock"}, - {PS_SELECT_WAIT , "Waiting on select"}, - {PS_SLEEP_WAIT , "Sleeping"}, - {PS_WAIT_WAIT , "Waiting process"}, - {PS_SIGSUSPEND , "Suspended, waiting for a signal"}, - {PS_SIGWAIT , "Waiting for a signal"}, - {PS_JOIN , "Waiting to join"}, - {PS_SUSPENDED , "Suspended"}, - {PS_DEAD , "Dead"}, - {PS_STATE_MAX , "Not a real state!"} -}; - -void -_thread_dump_info(void) -{ - char s[512]; - int fd; - int i; - int j; - pthread_t pthread; - char tmpfile[128]; - - for (i = 0; i < 100000; i++) { - snprintf(tmpfile, sizeof(tmpfile), "/tmp/uthread.dump.%u.%i", - getpid(), i); - /* Open the dump file for append and create it if necessary: */ - if ((fd = _thread_sys_open(tmpfile, O_RDWR | O_CREAT | O_EXCL, - 0666)) < 0) { - /* Can't open the dump file. */ - if (errno == EEXIST) - continue; - /* - * We only need to continue in case of - * EEXIT error. Most other error - * codes means that we will fail all - * the times. - */ - return; - } else { - break; - } - } - if (i==100000) { - /* all 100000 possibilities are in use :( */ - return; - } else { - /* Output a header for active threads: */ - strcpy(s, "\n\n=============\nACTIVE THREADS\n\n"); - _thread_sys_write(fd, s, strlen(s)); - - /* Enter a loop to report each thread in the global list: */ - for (pthread = _thread_link_list; pthread != NULL; - pthread = pthread->nxt) { - /* Find the state: */ - for (j = 0; j < (sizeof(thread_info) / - sizeof(struct s_thread_info)) - 1; j++) - if (thread_info[j].state == pthread->state) - break; - /* Output a record for the current thread: */ - snprintf(s, sizeof(s), - "--------------------\nThread %p (%s) prio %3d state %s [%s:%d]\n", - pthread, (pthread->name == NULL) ? - "":pthread->name, pthread->pthread_priority, - thread_info[j].name, - pthread->fname,pthread->lineno); - _thread_sys_write(fd, s, strlen(s)); - - /* Check if this is the running thread: */ - if (pthread == _thread_run) { - /* Output a record for the running thread: */ - strcpy(s, "This is the running thread\n"); - _thread_sys_write(fd, s, strlen(s)); - } - /* Check if this is the initial thread: */ - if (pthread == _thread_initial) { - /* Output a record for the initial thread: */ - strcpy(s, "This is the initial thread\n"); - _thread_sys_write(fd, s, strlen(s)); - } - /* Process according to thread state: */ - switch (pthread->state) { - /* File descriptor read lock wait: */ - case PS_FDLR_WAIT: - case PS_FDLW_WAIT: - case PS_FDR_WAIT: - case PS_FDW_WAIT: - /* Write the lock details: */ - snprintf(s, sizeof(s), "fd %d[%s:%d]", - pthread->data.fd.fd, - pthread->data.fd.fname, - pthread->data.fd.branch); - _thread_sys_write(fd, s, strlen(s)); - snprintf(s, sizeof(s), "owner %pr/%pw\n", - _thread_fd_table[pthread->data.fd.fd]->r_owner, - _thread_fd_table[pthread->data.fd.fd]->w_owner); - _thread_sys_write(fd, s, strlen(s)); - break; - case PS_SIGWAIT: - snprintf(s, sizeof(s), "sigmask 0x%08lx\n", - (unsigned long)pthread->sigmask); - _thread_sys_write(fd, s, strlen(s)); - break; - - /* - * Trap other states that are not explicitly - * coded to dump information: - */ - default: - /* Nothing to do here. */ - break; - } - } - - /* Check if there are no dead threads: */ - if (_thread_dead == NULL) { - /* Output a record: */ - strcpy(s, "\n\nTHERE ARE NO DEAD THREADS\n"); - _thread_sys_write(fd, s, strlen(s)); - } else { - /* Output a header for dead threads: */ - strcpy(s, "\n\nDEAD THREADS\n\n"); - _thread_sys_write(fd, s, strlen(s)); - - /* - * Enter a loop to report each thread in the global - * dead thread list: - */ - for (pthread = _thread_dead; pthread != NULL; - pthread = pthread->nxt_dead) { - /* Output a record for the current thread: */ - snprintf(s, sizeof(s), - "Thread %p prio %3d [%s:%d]\n", - pthread, pthread->pthread_priority, - pthread->fname,pthread->lineno); - _thread_sys_write(fd, s, strlen(s)); - } - } - - /* Output a header for file descriptors: */ - snprintf(s, sizeof(s), "\n\n=============\nFILE DESCRIPTOR TABLE (table size %d)\n\n",_thread_dtablesize); - _thread_sys_write(fd, s, strlen(s)); - - /* Enter a loop to report file descriptor lock usage: */ - for (i = 0; i < _thread_dtablesize; i++) { - /* - * Check if memory is allocated for this file - * descriptor: - */ - if (_thread_fd_table[i] != NULL) { - /* Report the file descriptor lock status: */ - snprintf(s, sizeof(s), - "fd[%3d] read owner %p count %d [%s:%d]\n write owner %p count %d [%s:%d]\n", - i, - _thread_fd_table[i]->r_owner, - _thread_fd_table[i]->r_lockcount, - _thread_fd_table[i]->r_fname, - _thread_fd_table[i]->r_lineno, - _thread_fd_table[i]->w_owner, - _thread_fd_table[i]->w_lockcount, - _thread_fd_table[i]->w_fname, - _thread_fd_table[i]->w_lineno); - _thread_sys_write(fd, s, strlen(s)); - } - } - - /* Close the dump file: */ - _thread_sys_close(fd); - } - return; -} - -/* Set the thread name for debug: */ -void -pthread_set_name_np(pthread_t thread, char *name) -{ - /* Check if the caller has specified a valid thread: */ - if (thread != NULL && thread->magic == PTHREAD_MAGIC) - thread->name = strdup(name); - return; -} -#endif diff --git a/lib/libkse/thread/thr_init.c b/lib/libkse/thread/thr_init.c deleted file mode 100644 index 50f3bef8973a7..0000000000000 --- a/lib/libkse/thread/thr_init.c +++ /dev/null @@ -1,284 +0,0 @@ -/* - * Copyright (c) 1995-1998 John Birrell <jb@cimlogic.com.au> - * 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 John Birrell. - * 4. Neither the name of the author nor the names of any co-contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY JOHN BIRRELL 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. - * - */ - -/* Allocate space for global thread variables here: */ -#define GLOBAL_PTHREAD_PRIVATE - -#include <errno.h> -#include <stdlib.h> -#include <string.h> -#include <fcntl.h> -#include <paths.h> -#include <unistd.h> -#include <sys/time.h> -#include <sys/ttycom.h> -#ifdef _THREAD_SAFE -#include <machine/reg.h> -#include <pthread.h> -#include "pthread_private.h" - -#ifdef GCC_2_8_MADE_THREAD_AWARE -typedef void *** (*dynamic_handler_allocator)(); -extern void __set_dynamic_handler_allocator(dynamic_handler_allocator); - -static pthread_key_t except_head_key; - -typedef struct { - void **__dynamic_handler_chain; - void *top_elt[2]; -} except_struct; - -static void ***dynamic_allocator_handler_fn() -{ - except_struct *dh = (except_struct *)pthread_getspecific(except_head_key); - - if(dh == NULL) { - dh = (except_struct *)malloc( sizeof(except_struct) ); - memset(dh, '\0', sizeof(except_struct)); - dh->__dynamic_handler_chain= dh->top_elt; - pthread_setspecific(except_head_key, (void *)dh); - } - return &dh->__dynamic_handler_chain; -} -#endif /* GCC_2_8_MADE_THREAD_AWARE */ - -/* - * Threaded process initialization - */ -void -_thread_init(void) -{ - int fd; - int flags; - int i; - struct sigaction act; - - /* Check if this function has already been called: */ - if (_thread_initial) - /* Only initialise the threaded application once. */ - return; - - /* - * Check for the special case of this process running as - * or in place of init as pid = 1: - */ - if (getpid() == 1) { - /* - * Setup a new session for this process which is - * assumed to be running as root. - */ - if (setsid() == -1) - PANIC("Can't set session ID"); - if (revoke(_PATH_CONSOLE) != 0) - PANIC("Can't revoke console"); - if ((fd = _thread_sys_open(_PATH_CONSOLE, O_RDWR)) < 0) - PANIC("Can't open console"); - if (setlogin("root") == -1) - PANIC("Can't set login to root"); - if (_thread_sys_ioctl(fd,TIOCSCTTY, (char *) NULL) == -1) - PANIC("Can't set controlling terminal"); - if (_thread_sys_dup2(fd,0) == -1 || - _thread_sys_dup2(fd,1) == -1 || - _thread_sys_dup2(fd,2) == -1) - PANIC("Can't dup2"); - } - - /* Get the standard I/O flags before messing with them : */ - for (i = 0; i < 3; i++) - if ((_pthread_stdio_flags[i] = - _thread_sys_fcntl(i,F_GETFL, NULL)) == -1) - PANIC("Cannot get stdio flags"); - - /* - * Create a pipe that is written to by the signal handler to prevent - * signals being missed in calls to _select: - */ - if (_thread_sys_pipe(_thread_kern_pipe) != 0) { - /* Cannot create pipe, so abort: */ - PANIC("Cannot create kernel pipe"); - } - /* Get the flags for the read pipe: */ - else if ((flags = _thread_sys_fcntl(_thread_kern_pipe[0], F_GETFL, NULL)) == -1) { - /* Abort this application: */ - PANIC("Cannot get kernel read pipe flags"); - } - /* Make the read pipe non-blocking: */ - else if (_thread_sys_fcntl(_thread_kern_pipe[0], F_SETFL, flags | O_NONBLOCK) == -1) { - /* Abort this application: */ - PANIC("Cannot make kernel read pipe non-blocking"); - } - /* Get the flags for the write pipe: */ - else if ((flags = _thread_sys_fcntl(_thread_kern_pipe[1], F_GETFL, NULL)) == -1) { - /* Abort this application: */ - PANIC("Cannot get kernel write pipe flags"); - } - /* Make the write pipe non-blocking: */ - else if (_thread_sys_fcntl(_thread_kern_pipe[1], F_SETFL, flags | O_NONBLOCK) == -1) { - /* Abort this application: */ - PANIC("Cannot get kernel write pipe flags"); - } - /* Allocate memory for the thread structure of the initial thread: */ - else if ((_thread_initial = (pthread_t) malloc(sizeof(struct pthread))) == NULL) { - /* - * Insufficient memory to initialise this application, so - * abort: - */ - PANIC("Cannot allocate memory for initial thread"); - } else { - /* Zero the global kernel thread structure: */ - memset(&_thread_kern_thread, 0, sizeof(struct pthread)); - memset(_thread_initial, 0, sizeof(struct pthread)); - - /* Default the priority of the initial thread: */ - _thread_initial->pthread_priority = PTHREAD_DEFAULT_PRIORITY; - - /* Initialise the state of the initial thread: */ - _thread_initial->state = PS_RUNNING; - - /* Initialise the queue: */ - _thread_queue_init(&(_thread_initial->join_queue)); - - /* Initialise the rest of the fields: */ - _thread_initial->specific_data = NULL; - _thread_initial->cleanup = NULL; - _thread_initial->queue = NULL; - _thread_initial->qnxt = NULL; - _thread_initial->nxt = NULL; - _thread_initial->flags = 0; - _thread_initial->error = 0; - _thread_link_list = _thread_initial; - _thread_run = _thread_initial; - - /* Initialise the global signal action structure: */ - sigfillset(&act.sa_mask); - act.sa_handler = (void (*) ()) _thread_sig_handler; - act.sa_flags = 0; - - /* Enter a loop to get the existing signal status: */ - for (i = 1; i < NSIG; i++) { - /* Check for signals which cannot be trapped: */ - if (i == SIGKILL || i == SIGSTOP) { - } - - /* Get the signal handler details: */ - else if (_thread_sys_sigaction(i, NULL, - &_thread_sigact[i - 1]) != 0) { - /* - * Abort this process if signal - * initialisation fails: - */ - PANIC("Cannot read signal handler info"); - } - } - - /* - * Install the signal handler for the most important - * signals that the user-thread kernel needs. Actually - * SIGINFO isn't really needed, but it is nice to have. - */ - if (_thread_sys_sigaction(SIGVTALRM, &act, NULL) != 0 || - _thread_sys_sigaction(SIGINFO , &act, NULL) != 0 || - _thread_sys_sigaction(SIGCHLD , &act, NULL) != 0) { - /* - * Abort this process if signal initialisation fails: - */ - PANIC("Cannot initialise signal handler"); - } - - /* Get the table size: */ - if ((_thread_dtablesize = getdtablesize()) < 0) { - /* - * Cannot get the system defined table size, so abort - * this process. - */ - PANIC("Cannot get dtablesize"); - } - /* Allocate memory for the file descriptor table: */ - if ((_thread_fd_table = (struct fd_table_entry **) malloc(sizeof(struct fd_table_entry *) * _thread_dtablesize)) == NULL) { - /* - * Cannot allocate memory for the file descriptor - * table, so abort this process. - */ - PANIC("Cannot allocate memory for file descriptor table"); - } else { - /* - * Enter a loop to initialise the file descriptor - * table: - */ - for (i = 0; i < _thread_dtablesize; i++) { - /* Initialise the file descriptor table: */ - _thread_fd_table[i] = NULL; - } - } - } - -#ifdef GCC_2_8_MADE_THREAD_AWARE - /* Create the thread-specific data for the exception linked list. */ - if(pthread_key_create(&except_head_key, NULL) != 0) - PANIC("Failed to create thread specific execption head"); - - /* Setup the gcc exception handler per thread. */ - __set_dynamic_handler_allocator( dynamic_allocator_handler_fn ); -#endif /* GCC_2_8_MADE_THREAD_AWARE */ - - /* Initialise the garbage collector mutex and condition variable. */ - if (pthread_mutex_init(&_gc_mutex,NULL) != 0 || - pthread_cond_init(&_gc_cond,NULL) != 0) - PANIC("Failed to initialise garbage collector mutex or condvar"); - - return; -} - -/* - * Special start up code for NetBSD/Alpha - */ -#if defined(__NetBSD__) && defined(__alpha__) -int -main(int argc, char *argv[], char *env); - -int -_thread_main(int argc, char *argv[], char *env) -{ - _thread_init(); - return (main(argc, argv, env)); -} -#endif -#else -/* - * A stub for non-threaded programs. - */ -void -_thread_init(void) -{ -} -#endif diff --git a/lib/libkse/thread/thr_join.c b/lib/libkse/thread/thr_join.c deleted file mode 100644 index 2043b76f5d241..0000000000000 --- a/lib/libkse/thread/thr_join.c +++ /dev/null @@ -1,98 +0,0 @@ -/* - * Copyright (c) 1995 John Birrell <jb@cimlogic.com.au>. - * 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 John Birrell. - * 4. Neither the name of the author nor the names of any co-contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY JOHN BIRRELL 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 <errno.h> -#ifdef _THREAD_SAFE -#include <pthread.h> -#include "pthread_private.h" - -int -pthread_join(pthread_t pthread, void **thread_return) -{ - int ret = 0; - pthread_t pthread1 = NULL; - - /* Check if the caller has specified an invalid thread: */ - if (pthread == NULL || pthread->magic != PTHREAD_MAGIC) - /* Invalid thread: */ - return(EINVAL); - - /* Check if the caller has specified itself: */ - if (pthread == _thread_run) - /* Avoid a deadlock condition: */ - return(EDEADLK); - - /* - * Find the thread in the list of active threads or in the - * list of dead threads: - */ - if (_find_thread(pthread) == 0 || - _find_dead_thread(pthread) == 0) - pthread1 = pthread; - - if (pthread1 == NULL) - /* Return an error: */ - ret = ESRCH; - - /* Check if this thread has been detached: */ - else if ((pthread->attr.flags & PTHREAD_DETACHED) != 0) - /* Return an error: */ - ret = ESRCH; - - /* Check if the thread is not dead: */ - else if (pthread->state != PS_DEAD) { - /* Add the running thread to the join queue: */ - _thread_queue_enq(&(pthread->join_queue), _thread_run); - - /* Schedule the next thread: */ - _thread_kern_sched_state(PS_JOIN, __FILE__, __LINE__); - - /* Check if the thread is not detached: */ - if ((pthread->attr.flags & PTHREAD_DETACHED) == 0) { - /* Check if the return value is required: */ - if (thread_return) - /* Return the thread's return value: */ - *thread_return = pthread->ret; - } - else - /* Return an error: */ - ret = ESRCH; - - /* Check if the return value is required: */ - } else if (thread_return != NULL) - /* Return the thread's return value: */ - *thread_return = pthread->ret; - - /* Return the completion status: */ - return (ret); -} -#endif diff --git a/lib/libkse/thread/thr_kern.c b/lib/libkse/thread/thr_kern.c deleted file mode 100644 index 3a6966bad5bf3..0000000000000 --- a/lib/libkse/thread/thr_kern.c +++ /dev/null @@ -1,1323 +0,0 @@ -/* - * Copyright (c) 1995-1998 John Birrell <jb@cimlogic.com.au> - * 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 John Birrell. - * 4. Neither the name of the author nor the names of any co-contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY JOHN BIRRELL 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. - * - * $Id: uthread_kern.c,v 1.14 1998/10/09 19:01:30 dt Exp $ - * - */ -#include <errno.h> -#include <stdlib.h> -#include <stdarg.h> -#include <string.h> -#include <unistd.h> -#include <setjmp.h> -#include <sys/types.h> -#include <sys/stat.h> -#include <sys/time.h> -#include <sys/socket.h> -#include <sys/uio.h> -#include <sys/syscall.h> -#include <fcntl.h> -#ifdef _THREAD_SAFE -#include <pthread.h> -#include "pthread_private.h" - -/* Static function prototype definitions: */ -static void -_thread_kern_select(int wait_reqd); - -void -_thread_kern_sched(struct sigcontext * scp) -{ -#ifndef __alpha__ - char *fdata; -#endif - int prio = -1; - pthread_t pthread; - pthread_t pthread_h = NULL; - pthread_t pthread_s = NULL; - struct itimerval itimer; - struct timespec ts; - struct timespec ts1; - struct timeval tv; - struct timeval tv1; - - /* - * Flag the pthread kernel as executing scheduler code - * to avoid a scheduler signal from interrupting this - * execution and calling the scheduler again. - */ - _thread_kern_in_sched = 1; - - /* Check if this function was called from the signal handler: */ - if (scp != NULL) { - /* - * Copy the signal context to the current thread's jump - * buffer: - */ - memcpy(&_thread_run->saved_sigcontext, scp, sizeof(_thread_run->saved_sigcontext)); - -#ifndef __alpha__ - /* Point to the floating point data in the running thread: */ - fdata = _thread_run->saved_fp; - - /* Save the floating point data: */ -__asm__("fnsave %0": :"m"(*fdata)); -#endif - - /* Flag the signal context as the last state saved: */ - _thread_run->sig_saved = 1; - } - /* Save the state of the current thread: */ - else if (setjmp(_thread_run->saved_jmp_buf) != 0) { - /* - * This point is reached when a longjmp() is called to - * restore the state of a thread. - * - * This is the normal way out of the scheduler. - */ - _thread_kern_in_sched = 0; - - /* - * There might be pending signals for this thread, so - * dispatch any that aren't blocked: - */ - _dispatch_signals(); - return; - } else - /* Flag the jump buffer was the last state saved: */ - _thread_run->sig_saved = 0; - - /* - * Enter a the scheduling loop that finds the next thread that is - * ready to run. This loop completes when there are no more threads - * in the global list or when a thread has its state restored by - * either a sigreturn (if the state was saved as a sigcontext) or a - * longjmp (if the state was saved by a setjmp). - */ - while (_thread_link_list != NULL) { - /* Get the current time of day: */ - gettimeofday(&tv, NULL); - TIMEVAL_TO_TIMESPEC(&tv, &ts); - - /* - * Poll file descriptors to update the state of threads - * waiting on file I/O where data may be available: - */ - _thread_kern_select(0); - - /* - * Enter a loop to look for sleeping threads that are ready: - */ - for (pthread = _thread_link_list; pthread != NULL; - pthread = pthread->nxt) { - /* Check if this thread is to timeout: */ - if (pthread->state == PS_COND_WAIT || - pthread->state == PS_SLEEP_WAIT || - pthread->state == PS_FDR_WAIT || - pthread->state == PS_FDW_WAIT || - pthread->state == PS_SELECT_WAIT) { - /* Check if this thread is to wait forever: */ - if (pthread->wakeup_time.tv_sec == -1) { - } - /* - * Check if this thread is to wakeup - * immediately or if it is past its wakeup - * time: - */ - else if ((pthread->wakeup_time.tv_sec == 0 && - pthread->wakeup_time.tv_nsec == 0) || - (ts.tv_sec > pthread->wakeup_time.tv_sec) || - ((ts.tv_sec == pthread->wakeup_time.tv_sec) && - (ts.tv_nsec >= pthread->wakeup_time.tv_nsec))) { - /* - * Check if this thread is waiting on - * select: - */ - if (pthread->state == PS_SELECT_WAIT) { - /* - * The select has timed out, - * so zero the file - * descriptor sets: - */ - FD_ZERO(&pthread->data.select_data->readfds); - FD_ZERO(&pthread->data.select_data->writefds); - FD_ZERO(&pthread->data.select_data->exceptfds); - pthread->data.select_data->nfds = 0; - } - /* - * Return an error as an interrupted - * wait: - */ - _thread_seterrno(pthread, EINTR); - - /* - * Flag the timeout in the thread - * structure: - */ - pthread->timeout = 1; - - /* - * Change the threads state to allow - * it to be restarted: - */ - PTHREAD_NEW_STATE(pthread,PS_RUNNING); - } - } - } - - /* Check if there is a current thread: */ - if (_thread_run != &_thread_kern_thread) { - /* - * Save the current time as the time that the thread - * became inactive: - */ - _thread_run->last_inactive.tv_sec = tv.tv_sec; - _thread_run->last_inactive.tv_usec = tv.tv_usec; - - /* - * Accumulate the number of microseconds that this - * thread has run for: - */ - if (_thread_run->slice_usec != -1) { - _thread_run->slice_usec += (_thread_run->last_inactive.tv_sec - - _thread_run->last_active.tv_sec) * 1000000 + - _thread_run->last_inactive.tv_usec - - _thread_run->last_active.tv_usec; - } - - /* - * Check if this thread has reached its allocated - * time slice period: - */ - if (_thread_run->slice_usec > TIMESLICE_USEC) { - /* - * Flag the allocated time slice period as - * up: - */ - _thread_run->slice_usec = -1; - } - } - /* Check if an incremental priority update is required: */ - if (((tv.tv_sec - kern_inc_prio_time.tv_sec) * 1000000 + - tv.tv_usec - kern_inc_prio_time.tv_usec) > INC_PRIO_USEC) { - /* - * Enter a loop to look for run-enabled threads that - * have not run since the last time that an - * incremental priority update was performed: - */ - for (pthread = _thread_link_list; pthread != NULL; pthread = pthread->nxt) { - /* Check if this thread is unable to run: */ - if (pthread->state != PS_RUNNING) { - } - /* - * Check if the last time that this thread - * was run (as indicated by the last time it - * became inactive) is before the time that - * the last incremental priority check was - * made: - */ - else if (timercmp(&pthread->last_inactive, &kern_inc_prio_time, <)) { - /* - * Increment the incremental priority - * for this thread in the hope that - * it will eventually get a chance to - * run: - */ - (pthread->inc_prio)++; - } - } - - /* Save the new incremental priority update time: */ - kern_inc_prio_time.tv_sec = tv.tv_sec; - kern_inc_prio_time.tv_usec = tv.tv_usec; - } - /* - * Enter a loop to look for the first thread of the highest - * priority that is ready to run: - */ - for (pthread = _thread_link_list; pthread != NULL; pthread = pthread->nxt) { - /* Check if the current thread is unable to run: */ - if (pthread->state != PS_RUNNING) { - } - /* - * Check if no run-enabled thread has been seen or if - * the current thread has a priority higher than the - * highest seen so far: - */ - else if (pthread_h == NULL || (pthread->pthread_priority + pthread->inc_prio) > prio) { - /* - * Save this thread as the highest priority - * thread seen so far: - */ - pthread_h = pthread; - prio = pthread->pthread_priority + pthread->inc_prio; - } - } - - /* - * Enter a loop to look for a thread that: 1. Is run-enabled. - * 2. Has the required agregate priority. 3. Has not been - * allocated its allocated time slice. 4. Became inactive - * least recently. - */ - for (pthread = _thread_link_list; pthread != NULL; pthread = pthread->nxt) { - /* Check if the current thread is unable to run: */ - if (pthread->state != PS_RUNNING) { - /* Ignore threads that are not ready to run. */ - } - - /* - * Check if the current thread as an agregate - * priority not equal to the highest priority found - * above: - */ - else if ((pthread->pthread_priority + pthread->inc_prio) != prio) { - /* - * Ignore threads which have lower agregate - * priority. - */ - } - - /* - * Check if the current thread reached its time slice - * allocation last time it ran (or if it has not run - * yet): - */ - else if (pthread->slice_usec == -1) { - } - - /* - * Check if an eligible thread has not been found - * yet, or if the current thread has an inactive time - * earlier than the last one seen: - */ - else if (pthread_s == NULL || timercmp(&pthread->last_inactive, &tv1, <)) { - /* - * Save the pointer to the current thread as - * the most eligible thread seen so far: - */ - pthread_s = pthread; - - /* - * Save the time that the selected thread - * became inactive: - */ - tv1.tv_sec = pthread->last_inactive.tv_sec; - tv1.tv_usec = pthread->last_inactive.tv_usec; - } - } - - /* - * Check if no thread was selected according to incomplete - * time slice allocation: - */ - if (pthread_s == NULL) { - /* - * Enter a loop to look for any other thread that: 1. - * Is run-enabled. 2. Has the required agregate - * priority. 3. Became inactive least recently. - */ - for (pthread = _thread_link_list; pthread != NULL; pthread = pthread->nxt) { - /* - * Check if the current thread is unable to - * run: - */ - if (pthread->state != PS_RUNNING) { - /* - * Ignore threads that are not ready - * to run. - */ - } - /* - * Check if the current thread as an agregate - * priority not equal to the highest priority - * found above: - */ - else if ((pthread->pthread_priority + pthread->inc_prio) != prio) { - /* - * Ignore threads which have lower - * agregate priority. - */ - } - /* - * Check if an eligible thread has not been - * found yet, or if the current thread has an - * inactive time earlier than the last one - * seen: - */ - else if (pthread_s == NULL || timercmp(&pthread->last_inactive, &tv1, <)) { - /* - * Save the pointer to the current - * thread as the most eligible thread - * seen so far: - */ - pthread_s = pthread; - - /* - * Save the time that the selected - * thread became inactive: - */ - tv1.tv_sec = pthread->last_inactive.tv_sec; - tv1.tv_usec = pthread->last_inactive.tv_usec; - } - } - } - /* Check if there are no threads ready to run: */ - if (pthread_s == NULL) { - /* - * Lock the pthread kernel by changing the pointer to - * the running thread to point to the global kernel - * thread structure: - */ - _thread_run = &_thread_kern_thread; - - /* - * There are no threads ready to run, so wait until - * something happens that changes this condition: - */ - _thread_kern_select(1); - } else { - /* Make the selected thread the current thread: */ - _thread_run = pthread_s; - - /* - * Save the current time as the time that the thread - * became active: - */ - _thread_run->last_active.tv_sec = tv.tv_sec; - _thread_run->last_active.tv_usec = tv.tv_usec; - - /* - * Check if this thread is running for the first time - * or running again after using its full time slice - * allocation: - */ - if (_thread_run->slice_usec == -1) { - /* Reset the accumulated time slice period: */ - _thread_run->slice_usec = 0; - } - /* - * Reset the incremental priority now that this - * thread has been given the chance to run: - */ - _thread_run->inc_prio = 0; - - /* Check if there is more than one thread: */ - if (_thread_run != _thread_link_list || _thread_run->nxt != NULL) { - /* - * Define the maximum time before a SIGVTALRM - * is required: - */ - itimer.it_value.tv_sec = 0; - itimer.it_value.tv_usec = TIMESLICE_USEC; - - /* - * The interval timer is not reloaded when it - * times out. The interval time needs to be - * calculated every time. - */ - itimer.it_interval.tv_sec = 0; - itimer.it_interval.tv_usec = 0; - - /* - * Enter a loop to look for threads waiting - * for a time: - */ - for (pthread = _thread_link_list; pthread != NULL; pthread = pthread->nxt) { - /* - * Check if this thread is to - * timeout: - */ - if (pthread->state == PS_COND_WAIT || - pthread->state == PS_SLEEP_WAIT || - pthread->state == PS_FDR_WAIT || - pthread->state == PS_FDW_WAIT || - pthread->state == PS_SELECT_WAIT) { - /* - * Check if this thread is to - * wait forever: - */ - if (pthread->wakeup_time.tv_sec == -1) { - } - /* - * Check if this thread is to - * wakeup immediately: - */ - else if (pthread->wakeup_time.tv_sec == 0 && - pthread->wakeup_time.tv_nsec == 0) { - } - /* - * Check if the current time - * is after the wakeup time: - */ - else if ((ts.tv_sec > pthread->wakeup_time.tv_sec) || - ((ts.tv_sec == pthread->wakeup_time.tv_sec) && - (ts.tv_nsec > pthread->wakeup_time.tv_nsec))) { - } else { - /* - * Calculate the time - * until this thread - * is ready, allowing - * for the clock - * resolution: - */ - ts1.tv_sec = pthread->wakeup_time.tv_sec - ts.tv_sec; - ts1.tv_nsec = pthread->wakeup_time.tv_nsec - ts.tv_nsec + - CLOCK_RES_NSEC; - - /* - * Check for - * underflow of the - * nanosecond field: - */ - if (ts1.tv_nsec < 0) { - /* - * Allow for - * the - * underflow - * of the - * nanosecond - * field: - */ - ts1.tv_sec--; - ts1.tv_nsec += 1000000000; - } - /* - * Check for overflow - * of the nanosecond - * field: - */ - if (ts1.tv_nsec >= 1000000000) { - /* - * Allow for - * the - * overflow - * of the - * nanosecond - * field: - */ - ts1.tv_sec++; - ts1.tv_nsec -= 1000000000; - } - /* - * Convert the - * timespec structure - * to a timeval - * structure: - */ - TIMESPEC_TO_TIMEVAL(&tv, &ts1); - - /* - * Check if the - * thread will be - * ready sooner than - * the earliest one - * found so far: - */ - if (timercmp(&tv, &itimer.it_value, <)) { - /* - * Update the - * time - * value: - */ - itimer.it_value.tv_sec = tv.tv_sec; - itimer.it_value.tv_usec = tv.tv_usec; - } - } - } - } - - /* - * Start the interval timer for the - * calculated time interval: - */ - if (setitimer(ITIMER_VIRTUAL, &itimer, NULL) != 0) { - /* - * Cannot initialise the timer, so - * abort this process: - */ - PANIC("Cannot set virtual timer"); - } - } - /* Check if a signal context was saved: */ - if (_thread_run->sig_saved == 1) { -#ifndef __alpha__ - /* - * Point to the floating point data in the - * running thread: - */ - fdata = _thread_run->saved_fp; - - /* Restore the floating point state: */ - __asm__("frstor %0": :"m"(*fdata)); -#endif - - /* - * Do a sigreturn to restart the thread that - * was interrupted by a signal: - */ - _thread_kern_in_sched = 0; - _thread_sys_sigreturn(&_thread_run->saved_sigcontext); - } else - /* - * Do a longjmp to restart the thread that - * was context switched out (by a longjmp to - * a different thread): - */ - longjmp(_thread_run->saved_jmp_buf, 1); - - /* This point should not be reached. */ - PANIC("Thread has returned from sigreturn or longjmp"); - } - } - - /* There are no more threads, so exit this process: */ - exit(0); -} - -void -_thread_kern_sched_state(enum pthread_state state, char *fname, int lineno) -{ - /* Change the state of the current thread: */ - _thread_run->state = state; - _thread_run->fname = fname; - _thread_run->lineno = lineno; - - /* Schedule the next thread that is ready: */ - _thread_kern_sched(NULL); - return; -} - -void -_thread_kern_sched_state_unlock(enum pthread_state state, - spinlock_t *lock, char *fname, int lineno) -{ - /* Change the state of the current thread: */ - _thread_run->state = state; - _thread_run->fname = fname; - _thread_run->lineno = lineno; - - _SPINUNLOCK(lock); - - /* Schedule the next thread that is ready: */ - _thread_kern_sched(NULL); - return; -} - -static void -_thread_kern_select(int wait_reqd) -{ - char bufr[128]; - fd_set fd_set_except; - fd_set fd_set_read; - fd_set fd_set_write; - int count = 0; - int count_dec; - int found_one; - int i; - int nfds = -1; - int settimeout; - pthread_t pthread; - ssize_t num; - struct timespec ts; - struct timespec ts1; - struct timeval *p_tv; - struct timeval tv; - struct timeval tv1; - - /* Zero the file descriptor sets: */ - FD_ZERO(&fd_set_read); - FD_ZERO(&fd_set_write); - FD_ZERO(&fd_set_except); - - /* Check if the caller wants to wait: */ - if (wait_reqd) { - /* - * Add the pthread kernel pipe file descriptor to the read - * set: - */ - FD_SET(_thread_kern_pipe[0], &fd_set_read); - nfds = _thread_kern_pipe[0]; - - /* Get the current time of day: */ - gettimeofday(&tv, NULL); - TIMEVAL_TO_TIMESPEC(&tv, &ts); - } - /* Initialise the time value structure: */ - tv.tv_sec = 0; - tv.tv_usec = 0; - - /* - * Enter a loop to process threads waiting on either file descriptors - * or times: - */ - for (pthread = _thread_link_list; pthread != NULL; pthread = pthread->nxt) { - /* Assume that this state does not time out: */ - settimeout = 0; - - /* Process according to thread state: */ - switch (pthread->state) { - /* - * States which do not depend on file descriptor I/O - * operations or timeouts: - */ - case PS_DEAD: - case PS_FDLR_WAIT: - case PS_FDLW_WAIT: - case PS_FILE_WAIT: - case PS_JOIN: - case PS_MUTEX_WAIT: - case PS_RUNNING: - case PS_SIGTHREAD: - case PS_SIGWAIT: - case PS_STATE_MAX: - case PS_WAIT_WAIT: - case PS_SUSPENDED: - /* Nothing to do here. */ - break; - - /* File descriptor read wait: */ - case PS_FDR_WAIT: - /* Add the file descriptor to the read set: */ - FD_SET(pthread->data.fd.fd, &fd_set_read); - - /* - * Check if this file descriptor is greater than any - * of those seen so far: - */ - if (pthread->data.fd.fd > nfds) { - /* Remember this file descriptor: */ - nfds = pthread->data.fd.fd; - } - /* Increment the file descriptor count: */ - count++; - - /* This state can time out: */ - settimeout = 1; - break; - - /* File descriptor write wait: */ - case PS_FDW_WAIT: - /* Add the file descriptor to the write set: */ - FD_SET(pthread->data.fd.fd, &fd_set_write); - - /* - * Check if this file descriptor is greater than any - * of those seen so far: - */ - if (pthread->data.fd.fd > nfds) { - /* Remember this file descriptor: */ - nfds = pthread->data.fd.fd; - } - /* Increment the file descriptor count: */ - count++; - - /* This state can time out: */ - settimeout = 1; - break; - - /* States that time out: */ - case PS_SLEEP_WAIT: - case PS_COND_WAIT: - /* Flag a timeout as required: */ - settimeout = 1; - break; - - /* Select wait: */ - case PS_SELECT_WAIT: - /* - * Enter a loop to process each file descriptor in - * the thread-specific file descriptor sets: - */ - for (i = 0; i < pthread->data.select_data->nfds; i++) { - /* - * Check if this file descriptor is set for - * exceptions: - */ - if (FD_ISSET(i, &pthread->data.select_data->exceptfds)) { - /* - * Add the file descriptor to the - * exception set: - */ - FD_SET(i, &fd_set_except); - - /* - * Increment the file descriptor - * count: - */ - count++; - - /* - * Check if this file descriptor is - * greater than any of those seen so - * far: - */ - if (i > nfds) { - /* - * Remember this file - * descriptor: - */ - nfds = i; - } - } - /* - * Check if this file descriptor is set for - * write: - */ - if (FD_ISSET(i, &pthread->data.select_data->writefds)) { - /* - * Add the file descriptor to the - * write set: - */ - FD_SET(i, &fd_set_write); - - /* - * Increment the file descriptor - * count: - */ - count++; - - /* - * Check if this file descriptor is - * greater than any of those seen so - * far: - */ - if (i > nfds) { - /* - * Remember this file - * descriptor: - */ - nfds = i; - } - } - /* - * Check if this file descriptor is set for - * read: - */ - if (FD_ISSET(i, &pthread->data.select_data->readfds)) { - /* - * Add the file descriptor to the - * read set: - */ - FD_SET(i, &fd_set_read); - - /* - * Increment the file descriptor - * count: - */ - count++; - - /* - * Check if this file descriptor is - * greater than any of those seen so - * far: - */ - if (i > nfds) { - /* - * Remember this file - * descriptor: - */ - nfds = i; - } - } - } - - /* This state can time out: */ - settimeout = 1; - break; - } - - /* - * Check if the caller wants to wait and if the thread state - * is one that times out: - */ - if (wait_reqd && settimeout) { - /* Check if this thread wants to wait forever: */ - if (pthread->wakeup_time.tv_sec == -1) { - } - /* Check if this thread doesn't want to wait at all: */ - else if (pthread->wakeup_time.tv_sec == 0 && - pthread->wakeup_time.tv_nsec == 0) { - /* Override the caller's request to wait: */ - wait_reqd = 0; - } else { - /* - * Calculate the time until this thread is - * ready, allowing for the clock resolution: - */ - ts1.tv_sec = pthread->wakeup_time.tv_sec - ts.tv_sec; - ts1.tv_nsec = pthread->wakeup_time.tv_nsec - ts.tv_nsec + - CLOCK_RES_NSEC; - - /* - * Check for underflow of the nanosecond - * field: - */ - if (ts1.tv_nsec < 0) { - /* - * Allow for the underflow of the - * nanosecond field: - */ - ts1.tv_sec--; - ts1.tv_nsec += 1000000000; - } - /* - * Check for overflow of the nanosecond - * field: - */ - if (ts1.tv_nsec >= 1000000000) { - /* - * Allow for the overflow of the - * nanosecond field: - */ - ts1.tv_sec++; - ts1.tv_nsec -= 1000000000; - } - /* - * Convert the timespec structure to a - * timeval structure: - */ - TIMESPEC_TO_TIMEVAL(&tv1, &ts1); - - /* - * Check if no time value has been found yet, - * or if the thread will be ready sooner that - * the earliest one found so far: - */ - if ((tv.tv_sec == 0 && tv.tv_usec == 0) || timercmp(&tv1, &tv, <)) { - /* Update the time value: */ - tv.tv_sec = tv1.tv_sec; - tv.tv_usec = tv1.tv_usec; - } - } - } - } - - /* Check if the caller wants to wait: */ - if (wait_reqd) { - /* Check if no threads were found with timeouts: */ - if (tv.tv_sec == 0 && tv.tv_usec == 0) { - /* Wait forever: */ - p_tv = NULL; - } else { - /* - * Point to the time value structure which contains - * the earliest time that a thread will be ready: - */ - p_tv = &tv; - } - - /* - * Flag the pthread kernel as in a select. This is to avoid - * the window between the next statement that unblocks - * signals and the select statement which follows. - */ - _thread_kern_in_select = 1; - - /* - * Wait for a file descriptor to be ready for read, write, or - * an exception, or a timeout to occur: - */ - count = _thread_sys_select(nfds + 1, &fd_set_read, &fd_set_write, &fd_set_except, p_tv); - - /* Reset the kernel in select flag: */ - _thread_kern_in_select = 0; - - /* - * Check if it is possible that there are bytes in the kernel - * read pipe waiting to be read: - */ - if (count < 0 || FD_ISSET(_thread_kern_pipe[0], &fd_set_read)) { - /* - * Check if the kernel read pipe was included in the - * count: - */ - if (count > 0) { - /* - * Remove the kernel read pipe from the - * count: - */ - FD_CLR(_thread_kern_pipe[0], &fd_set_read); - - /* Decrement the count of file descriptors: */ - count--; - } - /* - * Enter a loop to read (and trash) bytes from the - * pthread kernel pipe: - */ - while ((num = _thread_sys_read(_thread_kern_pipe[0], bufr, sizeof(bufr))) > 0) { - /* - * The buffer read contains one byte per - * signal and each byte is the signal number. - * This data is not used, but the fact that - * the signal handler wrote to the pipe *is* - * used to cause the _select call - * to complete if the signal occurred between - * the time when signals were unblocked and - * the _select select call being - * made. - */ - } - } - } - /* Check if there are file descriptors to poll: */ - else if (count > 0) { - /* - * Point to the time value structure which has been zeroed so - * that the call to _select will not wait: - */ - p_tv = &tv; - - /* Poll file descrptors without wait: */ - count = _thread_sys_select(nfds + 1, &fd_set_read, &fd_set_write, &fd_set_except, p_tv); - } - - /* - * Check if any file descriptors are ready: - */ - if (count > 0) { - /* - * Enter a loop to look for threads waiting on file - * descriptors that are flagged as available by the - * _select syscall: - */ - for (pthread = _thread_link_list; pthread != NULL; pthread = pthread->nxt) { - /* Process according to thread state: */ - switch (pthread->state) { - /* - * States which do not depend on file - * descriptor I/O operations: - */ - case PS_RUNNING: - case PS_COND_WAIT: - case PS_DEAD: - case PS_FDLR_WAIT: - case PS_FDLW_WAIT: - case PS_FILE_WAIT: - case PS_JOIN: - case PS_MUTEX_WAIT: - case PS_SIGWAIT: - case PS_SLEEP_WAIT: - case PS_WAIT_WAIT: - case PS_SIGTHREAD: - case PS_STATE_MAX: - case PS_SUSPENDED: - /* Nothing to do here. */ - break; - - /* File descriptor read wait: */ - case PS_FDR_WAIT: - /* - * Check if the file descriptor is available - * for read: - */ - if (FD_ISSET(pthread->data.fd.fd, &fd_set_read)) { - /* - * Change the thread state to allow - * it to read from the file when it - * is scheduled next: - */ - pthread->state = PS_RUNNING; - } - break; - - /* File descriptor write wait: */ - case PS_FDW_WAIT: - /* - * Check if the file descriptor is available - * for write: - */ - if (FD_ISSET(pthread->data.fd.fd, &fd_set_write)) { - /* - * Change the thread state to allow - * it to write to the file when it is - * scheduled next: - */ - pthread->state = PS_RUNNING; - } - break; - - /* Select wait: */ - case PS_SELECT_WAIT: - /* - * Reset the flag that indicates if a file - * descriptor is ready for some type of - * operation: - */ - count_dec = 0; - - /* - * Enter a loop to search though the - * thread-specific select file descriptors - * for the first descriptor that is ready: - */ - for (i = 0; i < pthread->data.select_data->nfds && count_dec == 0; i++) { - /* - * Check if this file descriptor does - * not have an exception: - */ - if (FD_ISSET(i, &pthread->data.select_data->exceptfds) && FD_ISSET(i, &fd_set_except)) { - /* - * Flag this file descriptor - * as ready: - */ - count_dec = 1; - } - /* - * Check if this file descriptor is - * not ready for write: - */ - if (FD_ISSET(i, &pthread->data.select_data->writefds) && FD_ISSET(i, &fd_set_write)) { - /* - * Flag this file descriptor - * as ready: - */ - count_dec = 1; - } - /* - * Check if this file descriptor is - * not ready for read: - */ - if (FD_ISSET(i, &pthread->data.select_data->readfds) && FD_ISSET(i, &fd_set_read)) { - /* - * Flag this file descriptor - * as ready: - */ - count_dec = 1; - } - } - - /* - * Check if any file descriptors are ready - * for the current thread: - */ - if (count_dec) { - /* - * Reset the count of file - * descriptors that are ready for - * this thread: - */ - found_one = 0; - - /* - * Enter a loop to search though the - * thread-specific select file - * descriptors: - */ - for (i = 0; i < pthread->data.select_data->nfds; i++) { - /* - * Reset the count of - * operations for which the - * current file descriptor is - * ready: - */ - count_dec = 0; - - /* - * Check if this file - * descriptor is selected for - * exceptions: - */ - if (FD_ISSET(i, &pthread->data.select_data->exceptfds)) { - /* - * Check if this file - * descriptor has an - * exception: - */ - if (FD_ISSET(i, &fd_set_except)) { - /* - * Increment - * the count - * for this - * file: - */ - count_dec++; - } else { - /* - * Clear the - * file - * descriptor - * in the - * thread-spec - * ific file - * descriptor - * set: - */ - FD_CLR(i, &pthread->data.select_data->exceptfds); - } - } - /* - * Check if this file - * descriptor is selected for - * write: - */ - if (FD_ISSET(i, &pthread->data.select_data->writefds)) { - /* - * Check if this file - * descriptor is - * ready for write: - */ - if (FD_ISSET(i, &fd_set_write)) { - /* - * Increment - * the count - * for this - * file: - */ - count_dec++; - } else { - /* - * Clear the - * file - * descriptor - * in the - * thread-spec - * ific file - * descriptor - * set: - */ - FD_CLR(i, &pthread->data.select_data->writefds); - } - } - /* - * Check if this file - * descriptor is selected for - * read: - */ - if (FD_ISSET(i, &pthread->data.select_data->readfds)) { - /* - * Check if this file - * descriptor is - * ready for read: - */ - if (FD_ISSET(i, &fd_set_read)) { - /* - * Increment - * the count - * for this - * file: - */ - count_dec++; - } else { - /* - * Clear the - * file - * descriptor - * in the - * thread-spec - * ific file - * descriptor - * set: - */ - FD_CLR(i, &pthread->data.select_data->readfds); - } - } - /* - * Check if the current file - * descriptor is ready for - * any one of the operations: - */ - if (count_dec > 0) { - /* - * Increment the - * count of file - * descriptors that - * are ready for the - * current thread: - */ - found_one++; - } - } - - /* - * Return the number of file - * descriptors that are ready: - */ - pthread->data.select_data->nfds = found_one; - - /* - * Change the state of the current - * thread to run: - */ - pthread->state = PS_RUNNING; - } - break; - } - } - } - - /* Nothing to return. */ - return; -} - -void -_thread_kern_set_timeout(struct timespec * timeout) -{ - struct timespec current_time; - struct timeval tv; - - /* Reset the timeout flag for the running thread: */ - _thread_run->timeout = 0; - - /* Check if the thread is to wait forever: */ - if (timeout == NULL) { - /* - * Set the wakeup time to something that can be recognised as - * different to an actual time of day: - */ - _thread_run->wakeup_time.tv_sec = -1; - _thread_run->wakeup_time.tv_nsec = -1; - } - /* Check if no waiting is required: */ - else if (timeout->tv_sec == 0 && timeout->tv_nsec == 0) { - /* Set the wake up time to 'immediately': */ - _thread_run->wakeup_time.tv_sec = 0; - _thread_run->wakeup_time.tv_nsec = 0; - } else { - /* Get the current time: */ - gettimeofday(&tv, NULL); - TIMEVAL_TO_TIMESPEC(&tv, ¤t_time); - - /* Calculate the time for the current thread to wake up: */ - _thread_run->wakeup_time.tv_sec = current_time.tv_sec + timeout->tv_sec; - _thread_run->wakeup_time.tv_nsec = current_time.tv_nsec + timeout->tv_nsec; - - /* Check if the nanosecond field needs to wrap: */ - if (_thread_run->wakeup_time.tv_nsec >= 1000000000) { - /* Wrap the nanosecond field: */ - _thread_run->wakeup_time.tv_sec += 1; - _thread_run->wakeup_time.tv_nsec -= 1000000000; - } - } - return; -} -#endif diff --git a/lib/libkse/thread/thr_kill.c b/lib/libkse/thread/thr_kill.c deleted file mode 100644 index 7572c05faff73..0000000000000 --- a/lib/libkse/thread/thr_kill.c +++ /dev/null @@ -1,116 +0,0 @@ -/* - * Copyright (c) 1997 John Birrell <jb@cimlogic.com.au>. - * 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 John Birrell. - * 4. Neither the name of the author nor the names of any co-contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY JOHN BIRRELL 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 <errno.h> -#include <signal.h> -#ifdef _THREAD_SAFE -#include <pthread.h> -#include "pthread_private.h" - -int -pthread_kill(pthread_t pthread, int sig) -{ - int ret; - - /* Check for invalid signal numbers: */ - if (sig < 0 || sig >= NSIG) - /* Invalid signal: */ - ret = EINVAL; - - /* Ignored signals get dropped on the floor. */ - else if (_thread_sigact[sig - 1].sa_handler == SIG_IGN) - ret = 0; - - /* Find the thread in the list of active threads: */ - else if ((ret = _find_thread(pthread)) == 0) { - switch (pthread->state) { - case PS_SIGSUSPEND: - /* - * Only wake up the thread if the signal is unblocked - * and there is a handler installed for the signal. - */ - if (!sigismember(&pthread->sigmask, sig) && - _thread_sigact[sig - 1].sa_handler != SIG_DFL) { - /* Change the state of the thread to run: */ - PTHREAD_NEW_STATE(pthread,PS_RUNNING); - - /* Return the signal number: */ - pthread->signo = sig; - } - /* Increment the pending signal count: */ - sigaddset(&pthread->sigpend,sig); - break; - - case PS_SIGWAIT: - /* Wake up the thread if the signal is blocked. */ - if (sigismember(pthread->data.sigwait, sig)) { - /* Change the state of the thread to run: */ - PTHREAD_NEW_STATE(pthread,PS_RUNNING); - - /* Return the signal number: */ - pthread->signo = sig; - } else - /* Increment the pending signal count. */ - sigaddset(&pthread->sigpend,sig); - break; - - case PS_SELECT_WAIT: - case PS_FDR_WAIT: - case PS_FDW_WAIT: - case PS_SLEEP_WAIT: - if (!sigismember(&pthread->sigmask, sig) && - (_thread_sigact[sig - 1].sa_handler != SIG_IGN)) { - /* Flag the operation as interrupted: */ - pthread->interrupted = 1; - - /* Change the state of the thread to run: */ - PTHREAD_NEW_STATE(pthread,PS_RUNNING); - - /* Return the signal number: */ - pthread->signo = sig; - } else { - /* Increment the pending signal count: */ - sigaddset(&pthread->sigpend,sig); - } - break; - - default: - /* Increment the pending signal count: */ - sigaddset(&pthread->sigpend,sig); - break; - } - } - - /* Return the completion status: */ - return (ret); -} -#endif diff --git a/lib/libkse/thread/thr_mattr_init.c b/lib/libkse/thread/thr_mattr_init.c deleted file mode 100644 index 73226a6b4714b..0000000000000 --- a/lib/libkse/thread/thr_mattr_init.c +++ /dev/null @@ -1,57 +0,0 @@ -/* - * Copyright (c) 1996 Jeffrey Hsu <hsu@freebsd.org>. - * 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 John Birrell. - * 4. Neither the name of the author nor the names of any co-contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY JOHN BIRRELL 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 <string.h> -#include <stdlib.h> -#include <errno.h> -#ifdef _THREAD_SAFE -#include <pthread.h> -#include "pthread_private.h" - -int -pthread_mutexattr_init(pthread_mutexattr_t *attr) -{ - int ret; - pthread_mutexattr_t pattr; - - if ((pattr = (pthread_mutexattr_t) - malloc(sizeof(struct pthread_mutex_attr))) == NULL) { - ret = ENOMEM; - } else { - memcpy(pattr, &pthread_mutexattr_default, - sizeof(struct pthread_mutex_attr)); - *attr = pattr; - ret = 0; - } - return(ret); -} -#endif diff --git a/lib/libkse/thread/thr_mattr_kind_np.c b/lib/libkse/thread/thr_mattr_kind_np.c deleted file mode 100644 index c145a1f899277..0000000000000 --- a/lib/libkse/thread/thr_mattr_kind_np.c +++ /dev/null @@ -1,78 +0,0 @@ -/* - * Copyright (c) 1996 Jeffrey Hsu <hsu@freebsd.org>. - * 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 John Birrell. - * 4. Neither the name of the author nor the names of any co-contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY JOHN BIRRELL 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 <errno.h> -#ifdef _THREAD_SAFE -#include <pthread.h> -#include "pthread_private.h" - -int -pthread_mutexattr_setkind_np(pthread_mutexattr_t *attr, int kind) -{ - int ret; - if (attr == NULL || *attr == NULL) { - errno = EINVAL; - ret = -1; - } else { - (*attr)->m_type = kind; - ret = 0; - } - return(ret); -} - -int -pthread_mutexattr_getkind_np(pthread_mutexattr_t attr) -{ - int ret; - if (attr == NULL) { - errno = EINVAL; - ret = -1; - } else { - ret = attr->m_type; - } - return(ret); -} - -int -pthread_mutexattr_settype(pthread_mutexattr_t *attr, int type) -{ - int ret; - if (attr == NULL || *attr == NULL || type >= MUTEX_TYPE_MAX) { - errno = EINVAL; - ret = -1; - } else { - (*attr)->m_type = type; - ret = 0; - } - return(ret); -} -#endif diff --git a/lib/libkse/thread/thr_multi_np.c b/lib/libkse/thread/thr_multi_np.c deleted file mode 100644 index 64f360fdacfe7..0000000000000 --- a/lib/libkse/thread/thr_multi_np.c +++ /dev/null @@ -1,44 +0,0 @@ -/* - * Copyright (c) 1996 John Birrell <jb@cimlogic.com.au>. - * 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 John Birrell. - * 4. Neither the name of the author nor the names of any co-contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY JOHN BIRRELL 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 <string.h> -#ifdef _THREAD_SAFE -#include <pthread.h> -#include "pthread_private.h" - -int pthread_multi_np() -{ - /* Return to multi-threaded scheduling mode: */ - _thread_single = NULL; - return(0); -} -#endif diff --git a/lib/libkse/thread/thr_mutex.c b/lib/libkse/thread/thr_mutex.c deleted file mode 100644 index d3801f1750c0b..0000000000000 --- a/lib/libkse/thread/thr_mutex.c +++ /dev/null @@ -1,414 +0,0 @@ -/* - * Copyright (c) 1995 John Birrell <jb@cimlogic.com.au>. - * 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 John Birrell. - * 4. Neither the name of the author nor the names of any co-contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY JOHN BIRRELL 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 <stdlib.h> -#include <errno.h> -#include <string.h> -#ifdef _THREAD_SAFE -#include <pthread.h> -#include "pthread_private.h" - -static spinlock_t static_init_lock = _SPINLOCK_INITIALIZER; - -int -pthread_mutex_init(pthread_mutex_t * mutex, - const pthread_mutexattr_t * mutex_attr) -{ - enum pthread_mutextype type; - pthread_mutex_t pmutex; - int ret = 0; - - if (mutex == NULL) { - ret = EINVAL; - } else { - /* Check if default mutex attributes: */ - if (mutex_attr == NULL || *mutex_attr == NULL) - /* Default to a fast mutex: */ - type = PTHREAD_MUTEX_DEFAULT; - - else if ((*mutex_attr)->m_type >= MUTEX_TYPE_MAX) - /* Return an invalid argument error: */ - ret = EINVAL; - else - /* Use the requested mutex type: */ - type = (*mutex_attr)->m_type; - - /* Check no errors so far: */ - if (ret == 0) { - if ((pmutex = (pthread_mutex_t) - malloc(sizeof(struct pthread_mutex))) == NULL) - ret = ENOMEM; - else { - /* Reset the mutex flags: */ - pmutex->m_flags = 0; - - /* Process according to mutex type: */ - switch (type) { - /* Fast mutex: */ - case PTHREAD_MUTEX_DEFAULT: - case PTHREAD_MUTEX_NORMAL: - case PTHREAD_MUTEX_ERRORCHECK: - /* Nothing to do here. */ - break; - - /* Counting mutex: */ - case PTHREAD_MUTEX_RECURSIVE: - /* Reset the mutex count: */ - pmutex->m_data.m_count = 0; - break; - - /* Trap invalid mutex types: */ - default: - /* Return an invalid argument error: */ - ret = EINVAL; - break; - } - if (ret == 0) { - /* Initialise the rest of the mutex: */ - _thread_queue_init(&pmutex->m_queue); - pmutex->m_flags |= MUTEX_FLAGS_INITED; - pmutex->m_owner = NULL; - pmutex->m_type = type; - memset(&pmutex->lock, 0, - sizeof(pmutex->lock)); - *mutex = pmutex; - } else { - free(pmutex); - *mutex = NULL; - } - } - } - } - /* Return the completion status: */ - return (ret); -} - -int -pthread_mutex_destroy(pthread_mutex_t * mutex) -{ - int ret = 0; - - if (mutex == NULL || *mutex == NULL) - ret = EINVAL; - else { - /* Lock the mutex structure: */ - _SPINLOCK(&(*mutex)->lock); - - /* - * Free the memory allocated for the mutex - * structure: - */ - free(*mutex); - - /* - * Leave the caller's pointer NULL now that - * the mutex has been destroyed: - */ - *mutex = NULL; - } - - /* Return the completion status: */ - return (ret); -} - -static int -init_static (pthread_mutex_t *mutex) -{ - int ret; - - _SPINLOCK(&static_init_lock); - - if (*mutex == NULL) - ret = pthread_mutex_init(mutex, NULL); - else - ret = 0; - - _SPINUNLOCK(&static_init_lock); - - return(ret); -} - -int -pthread_mutex_trylock(pthread_mutex_t * mutex) -{ - int ret = 0; - - if (mutex == NULL) - ret = EINVAL; - - /* - * If the mutex is statically initialized, perform the dynamic - * initialization: - */ - else if (*mutex != NULL || (ret = init_static(mutex)) == 0) { - /* Lock the mutex structure: */ - _SPINLOCK(&(*mutex)->lock); - - /* Process according to mutex type: */ - switch ((*mutex)->m_type) { - /* Fast mutex: */ - case PTHREAD_MUTEX_NORMAL: - case PTHREAD_MUTEX_DEFAULT: - case PTHREAD_MUTEX_ERRORCHECK: - /* Check if this mutex is not locked: */ - if ((*mutex)->m_owner == NULL) { - /* Lock the mutex for the running thread: */ - (*mutex)->m_owner = _thread_run; - } else { - /* Return a busy error: */ - ret = EBUSY; - } - break; - - /* Counting mutex: */ - case PTHREAD_MUTEX_RECURSIVE: - /* Check if this mutex is locked: */ - if ((*mutex)->m_owner != NULL) { - /* - * Check if the mutex is locked by the running - * thread: - */ - if ((*mutex)->m_owner == _thread_run) { - /* Increment the lock count: */ - (*mutex)->m_data.m_count++; - } else { - /* Return a busy error: */ - ret = EBUSY; - } - } else { - /* Lock the mutex for the running thread: */ - (*mutex)->m_owner = _thread_run; - } - break; - - /* Trap invalid mutex types: */ - default: - /* Return an invalid argument error: */ - ret = EINVAL; - break; - } - - /* Unlock the mutex structure: */ - _SPINUNLOCK(&(*mutex)->lock); - } - - /* Return the completion status: */ - return (ret); -} - -int -pthread_mutex_lock(pthread_mutex_t * mutex) -{ - int ret = 0; - - if (mutex == NULL) - ret = EINVAL; - - /* - * If the mutex is statically initialized, perform the dynamic - * initialization: - */ - else if (*mutex != NULL || (ret = init_static(mutex)) == 0) { - /* Lock the mutex structure: */ - _SPINLOCK(&(*mutex)->lock); - - /* Process according to mutex type: */ - switch ((*mutex)->m_type) { - /* What SS2 define as a 'normal' mutex. This has to deadlock - on attempts to get a lock you already own. */ - case PTHREAD_MUTEX_NORMAL: - if ((*mutex)->m_owner == _thread_run) { - /* Intetionally deadlock */ - for (;;) - _thread_kern_sched_state(PS_MUTEX_WAIT, __FILE__, __LINE__); - } - goto COMMON_LOCK; - - /* Return error (not OK) on attempting to re-lock */ - case PTHREAD_MUTEX_ERRORCHECK: - if ((*mutex)->m_owner == _thread_run) { - ret = EDEADLK; - break; - } - - /* Fast mutexes do not check for any error conditions: */ - case PTHREAD_MUTEX_DEFAULT: - COMMON_LOCK: - /* - * Enter a loop to wait for the mutex to be locked by the - * current thread: - */ - while ((*mutex)->m_owner != _thread_run) { - /* Check if the mutex is not locked: */ - if ((*mutex)->m_owner == NULL) { - /* Lock the mutex for this thread: */ - (*mutex)->m_owner = _thread_run; - } else { - /* - * Join the queue of threads waiting to lock - * the mutex: - */ - _thread_queue_enq(&(*mutex)->m_queue, _thread_run); - - /* Wait for the mutex: */ - _thread_kern_sched_state_unlock( - PS_MUTEX_WAIT, &(*mutex)->lock, - __FILE__, __LINE__); - - /* Lock the mutex again: */ - _SPINLOCK(&(*mutex)->lock); - } - } - break; - - /* Counting mutex: */ - case PTHREAD_MUTEX_RECURSIVE: - /* - * Enter a loop to wait for the mutex to be locked by the - * current thread: - */ - while ((*mutex)->m_owner != _thread_run) { - /* Check if the mutex is not locked: */ - if ((*mutex)->m_owner == NULL) { - /* Lock the mutex for this thread: */ - (*mutex)->m_owner = _thread_run; - - /* Reset the lock count for this mutex: */ - (*mutex)->m_data.m_count = 0; - } else { - /* - * Join the queue of threads waiting to lock - * the mutex: - */ - _thread_queue_enq(&(*mutex)->m_queue, _thread_run); - - /* Wait for the mutex: */ - _thread_kern_sched_state_unlock( - PS_MUTEX_WAIT, &(*mutex)->lock, - __FILE__, __LINE__); - - /* Lock the mutex again: */ - _SPINLOCK(&(*mutex)->lock); - } - } - - /* Increment the lock count for this mutex: */ - (*mutex)->m_data.m_count++; - break; - - /* Trap invalid mutex types: */ - default: - /* Return an invalid argument error: */ - ret = EINVAL; - break; - } - - /* Unlock the mutex structure: */ - _SPINUNLOCK(&(*mutex)->lock); - } - - /* Return the completion status: */ - return (ret); -} - -int -pthread_mutex_unlock(pthread_mutex_t * mutex) -{ - int ret = 0; - - if (mutex == NULL || *mutex == NULL) { - ret = EINVAL; - } else { - /* Lock the mutex structure: */ - _SPINLOCK(&(*mutex)->lock); - - /* Process according to mutex type: */ - switch ((*mutex)->m_type) { - /* Default & normal mutexes do not really need to check for - any error conditions: */ - case PTHREAD_MUTEX_NORMAL: - case PTHREAD_MUTEX_DEFAULT: - case PTHREAD_MUTEX_ERRORCHECK: - /* Check if the running thread is not the owner of the mutex: */ - if ((*mutex)->m_owner != _thread_run) { - /* Return an invalid argument error: */ - ret = (*mutex)->m_owner ? EPERM : EINVAL; - } - /* - * Get the next thread from the queue of threads waiting on - * the mutex: - */ - else if (((*mutex)->m_owner = _thread_queue_deq(&(*mutex)->m_queue)) != NULL) { - /* Allow the new owner of the mutex to run: */ - PTHREAD_NEW_STATE((*mutex)->m_owner,PS_RUNNING); - } - break; - - /* Counting mutex: */ - case PTHREAD_MUTEX_RECURSIVE: - /* Check if the running thread is not the owner of the mutex: */ - if ((*mutex)->m_owner != _thread_run) { - /* Return an invalid argument error: */ - ret = EINVAL; - } - /* Check if there are still counts: */ - else if ((*mutex)->m_data.m_count > 1) { - /* Decrement the count: */ - (*mutex)->m_data.m_count--; - } else { - (*mutex)->m_data.m_count = 0; - /* - * Get the next thread from the queue of threads waiting on - * the mutex: - */ - if (((*mutex)->m_owner = _thread_queue_deq(&(*mutex)->m_queue)) != NULL) { - /* Allow the new owner of the mutex to run: */ - PTHREAD_NEW_STATE((*mutex)->m_owner,PS_RUNNING); - } - } - break; - - /* Trap invalid mutex types: */ - default: - /* Return an invalid argument error: */ - ret = EINVAL; - break; - } - - /* Unlock the mutex structure: */ - _SPINUNLOCK(&(*mutex)->lock); - } - - /* Return the completion status: */ - return (ret); -} -#endif diff --git a/lib/libkse/thread/thr_mutexattr_destroy.c b/lib/libkse/thread/thr_mutexattr_destroy.c deleted file mode 100644 index 5642cbef589dc..0000000000000 --- a/lib/libkse/thread/thr_mutexattr_destroy.c +++ /dev/null @@ -1,51 +0,0 @@ -/* - * Copyright (c) 1997 John Birrell <jb@cimlogic.com.au>. - * 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 John Birrell. - * 4. Neither the name of the author nor the names of any co-contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY JOHN BIRRELL 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 <stdlib.h> -#include <errno.h> -#ifdef _THREAD_SAFE -#include <pthread.h> -#include "pthread_private.h" - -int pthread_mutexattr_destroy(pthread_mutexattr_t *attr) -{ - int ret; - if (attr == NULL || *attr == NULL) { - ret = EINVAL; - } else { - free(*attr); - *attr = NULL; - ret = 0; - } - return(ret); -} -#endif diff --git a/lib/libkse/thread/thr_nanosleep.c b/lib/libkse/thread/thr_nanosleep.c deleted file mode 100644 index 4ec7d3f317200..0000000000000 --- a/lib/libkse/thread/thr_nanosleep.c +++ /dev/null @@ -1,119 +0,0 @@ -/* - * Copyright (c) 1995 John Birrell <jb@cimlogic.com.au>. - * 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 John Birrell. - * 4. Neither the name of the author nor the names of any co-contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY JOHN BIRRELL 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 <stdio.h> -#include <errno.h> -#ifdef _THREAD_SAFE -#include <pthread.h> -#include "pthread_private.h" - -int -nanosleep(const struct timespec * time_to_sleep, - struct timespec * time_remaining) -{ - int ret = 0; - struct timespec current_time; - struct timespec current_time1; - struct timespec remaining_time; - struct timeval tv; - - /* Check if the time to sleep is legal: */ - if (time_to_sleep == NULL || time_to_sleep->tv_nsec < 0 || time_to_sleep->tv_nsec > 1000000000) { - /* Return an EINVAL error : */ - errno = EINVAL; - ret = -1; - } else { - /* Get the current time: */ - gettimeofday(&tv, NULL); - TIMEVAL_TO_TIMESPEC(&tv, ¤t_time); - - /* Calculate the time for the current thread to wake up: */ - _thread_run->wakeup_time.tv_sec = current_time.tv_sec + time_to_sleep->tv_sec; - _thread_run->wakeup_time.tv_nsec = current_time.tv_nsec + time_to_sleep->tv_nsec; - - /* Check if the nanosecond field has overflowed: */ - if (_thread_run->wakeup_time.tv_nsec >= 1000000000) { - /* Wrap the nanosecond field: */ - _thread_run->wakeup_time.tv_sec += 1; - _thread_run->wakeup_time.tv_nsec -= 1000000000; - } - _thread_run->interrupted = 0; - - /* Reschedule the current thread to sleep: */ - _thread_kern_sched_state(PS_SLEEP_WAIT, __FILE__, __LINE__); - - /* Get the current time: */ - gettimeofday(&tv, NULL); - TIMEVAL_TO_TIMESPEC(&tv, ¤t_time1); - - /* Calculate the remaining time to sleep: */ - remaining_time.tv_sec = time_to_sleep->tv_sec + current_time.tv_sec - current_time1.tv_sec; - remaining_time.tv_nsec = time_to_sleep->tv_nsec + current_time.tv_nsec - current_time1.tv_nsec; - - /* Check if the nanosecond field has underflowed: */ - if (remaining_time.tv_nsec < 0) { - /* Handle the underflow: */ - remaining_time.tv_sec -= 1; - remaining_time.tv_nsec += 1000000000; - } - - /* Check if the nanosecond field has overflowed: */ - if (remaining_time.tv_nsec >= 1000000000) { - /* Handle the overflow: */ - remaining_time.tv_sec += 1; - remaining_time.tv_nsec -= 1000000000; - } - - /* Check if the sleep was longer than the required time: */ - if (remaining_time.tv_sec < 0) { - /* Reset the time left: */ - remaining_time.tv_sec = 0; - remaining_time.tv_nsec = 0; - } - - /* Check if the time remaining is to be returned: */ - if (time_remaining != NULL) { - /* Return the actual time slept: */ - time_remaining->tv_sec = remaining_time.tv_sec; - time_remaining->tv_nsec = remaining_time.tv_nsec; - } - - /* Check if the sleep was interrupted: */ - if (_thread_run->interrupted) { - /* Return an EINTR error : */ - errno = EINTR; - ret = -1; - } - } - return (ret); -} -#endif diff --git a/lib/libkse/thread/thr_once.c b/lib/libkse/thread/thr_once.c deleted file mode 100644 index c55ba9eaf74b5..0000000000000 --- a/lib/libkse/thread/thr_once.c +++ /dev/null @@ -1,50 +0,0 @@ -/* - * Copyright (c) 1995 John Birrell <jb@cimlogic.com.au>. - * 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 John Birrell. - * 4. Neither the name of the author nor the names of any co-contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY JOHN BIRRELL 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. - * - */ -#ifdef _THREAD_SAFE -#include <pthread.h> -#include "pthread_private.h" - -int -pthread_once(pthread_once_t * once_control, void (*init_routine) (void)) -{ - if (once_control->state == PTHREAD_NEEDS_INIT) { - pthread_mutex_lock(&(once_control->mutex)); - if (once_control->state == PTHREAD_NEEDS_INIT) { - init_routine(); - once_control->state = PTHREAD_DONE_INIT; - } - pthread_mutex_unlock(&(once_control->mutex)); - } - return (0); -} -#endif diff --git a/lib/libkse/thread/thr_open.c b/lib/libkse/thread/thr_open.c deleted file mode 100644 index a538a758f4613..0000000000000 --- a/lib/libkse/thread/thr_open.c +++ /dev/null @@ -1,74 +0,0 @@ -/* - * Copyright (c) 1995-1998 John Birrell <jb@cimlogic.com.au> - * 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 John Birrell. - * 4. Neither the name of the author nor the names of any co-contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY JOHN BIRRELL 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. - * - * $Id: uthread_open.c,v 1.3 1997/05/03 03:57:21 jb Exp $ - * - */ -#include <stdarg.h> -#include <unistd.h> -#include <fcntl.h> -#include <dirent.h> -#include <errno.h> -#ifdef _THREAD_SAFE -#include <pthread.h> -#include "pthread_private.h" - -int -open(const char *path, int flags,...) -{ - int fd; - int mode = 0; - int status; - va_list ap; - - /* Check if the file is being created: */ - if (flags & O_CREAT) { - /* Get the creation mode: */ - va_start(ap, flags); - mode = va_arg(ap, int); - va_end(ap); - } - /* Open the file: */ - if ((fd = _thread_sys_open(path, flags, mode)) < 0) { - } - /* Initialise the file descriptor table entry: */ - else if (_thread_fd_table_init(fd) != 0) { - /* Quietly close the file: */ - _thread_sys_close(fd); - - /* Reset the file descriptor: */ - fd = -1; - } - - /* Return the file descriptor or -1 on error: */ - return (fd); -} -#endif diff --git a/lib/libkse/thread/thr_private.h b/lib/libkse/thread/thr_private.h deleted file mode 100644 index 2d7e723bbfa1e..0000000000000 --- a/lib/libkse/thread/thr_private.h +++ /dev/null @@ -1,847 +0,0 @@ -/* - * Copyright (c) 1995-1998 John Birrell <jb@cimlogic.com.au>. - * 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 John Birrell. - * 4. Neither the name of the author nor the names of any co-contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY JOHN BIRRELL 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. - * - * Private thread definitions for the uthread kernel. - * - */ - -#ifndef _PTHREAD_PRIVATE_H -#define _PTHREAD_PRIVATE_H - -/* - * Evaluate the storage class specifier. - */ -#ifdef GLOBAL_PTHREAD_PRIVATE -#define SCLASS -#else -#define SCLASS extern -#endif - -/* - * Include files. - */ -#include <setjmp.h> -#include <signal.h> -#include <sys/queue.h> -#include <sys/types.h> -#include <sys/time.h> -#include <sched.h> -#include <spinlock.h> - -/* - * Kernel fatal error handler macro. - */ -#define PANIC(string) _thread_exit(__FILE__,__LINE__,string) - -/* Output debug messages like this: */ -#define stdout_debug(_x) _thread_sys_write(1,_x,strlen(_x)); -#define stderr_debug(_x) _thread_sys_write(2,_x,strlen(_x)); - -/* - * State change macro: - */ -#define PTHREAD_NEW_STATE(thrd, newstate) { \ - (thrd)->state = newstate; \ - (thrd)->fname = __FILE__; \ - (thrd)->lineno = __LINE__; \ -} - -/* - * Queue definitions. - */ -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 } - -/* - * Mutex definitions. - */ -union pthread_mutex_data { - void *m_ptr; - int m_count; -}; - -struct pthread_mutex { - enum pthread_mutextype m_type; - struct pthread_queue m_queue; - struct pthread *m_owner; - union pthread_mutex_data m_data; - long m_flags; - - /* - * Lock for accesses to this structure. - */ - spinlock_t lock; -}; - -/* - * 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_STATIC_INITIALIZER \ - { MUTEX_TYPE_FAST, PTHREAD_QUEUE_INITIALIZER, \ - NULL, { NULL }, MUTEX_FLAGS_INITED } - -struct pthread_mutex_attr { - enum pthread_mutextype m_type; - long m_flags; -}; - -/* - * Condition variable definitions. - */ -enum pthread_cond_type { - COND_TYPE_FAST, - COND_TYPE_MAX -}; - -struct pthread_cond { - enum pthread_cond_type c_type; - struct pthread_queue c_queue; - void *c_data; - long c_flags; - - /* - * Lock for accesses to this structure. - */ - spinlock_t lock; -}; - -struct pthread_cond_attr { - enum pthread_cond_type c_type; - long c_flags; -}; - -/* - * Flags for condition variables. - */ -#define COND_FLAGS_PRIVATE 0x01 -#define COND_FLAGS_INITED 0x02 -#define COND_FLAGS_BUSY 0x04 - -/* - * Static cond initialization values. - */ -#define PTHREAD_COND_STATIC_INITIALIZER \ - { COND_TYPE_FAST, PTHREAD_QUEUE_INITIALIZER, NULL, COND_FLAGS_INITED } - -/* - * Cleanup definitions. - */ -struct pthread_cleanup { - struct pthread_cleanup *next; - void (*routine) (); - void *routine_arg; -}; - -struct pthread_attr { - int schedparam_policy; - int prio; - int suspend; - int flags; - void *arg_attr; - void (*cleanup_attr) (); - void *stackaddr_attr; - size_t stacksize_attr; -}; - -/* - * Thread creation state attributes. - */ -#define PTHREAD_CREATE_RUNNING 0 -#define PTHREAD_CREATE_SUSPENDED 1 - -/* - * Miscellaneous definitions. - */ -#define PTHREAD_STACK_DEFAULT 65536 -#define PTHREAD_DEFAULT_PRIORITY 64 -#define PTHREAD_MAX_PRIORITY 126 -#define PTHREAD_MIN_PRIORITY 0 -#define _POSIX_THREAD_ATTR_STACKSIZE - -/* - * Clock resolution in nanoseconds. - */ -#define CLOCK_RES_NSEC 10000000 - -/* - * Number of microseconds between incremental priority updates for - * threads that are ready to run, but denied being run. - */ -#define INC_PRIO_USEC 500000 - -/* - * Time slice period in microseconds. - */ -#define TIMESLICE_USEC 100000 - -struct pthread_key { - spinlock_t lock; - volatile int allocated; - volatile int count; - void (*destructor) (); -}; - -struct pthread_rwlockattr { - int pshared; -}; - -struct pthread_rwlock { - pthread_mutex_t lock; /* monitor lock */ - int state; /* 0 = idle >0 = # of readers -1 = writer */ - pthread_cond_t read_signal; - pthread_cond_t write_signal; - int blocked_writers; -}; - -/* - * Thread states. - */ -enum pthread_state { - PS_RUNNING, - PS_SIGTHREAD, - PS_MUTEX_WAIT, - PS_COND_WAIT, - PS_FDLR_WAIT, - PS_FDLW_WAIT, - PS_FDR_WAIT, - PS_FDW_WAIT, - PS_FILE_WAIT, - PS_SELECT_WAIT, - PS_SLEEP_WAIT, - PS_WAIT_WAIT, - PS_SIGSUSPEND, - PS_SIGWAIT, - PS_JOIN, - PS_SUSPENDED, - PS_DEAD, - PS_STATE_MAX -}; - - -/* - * File descriptor locking definitions. - */ -#define FD_READ 0x1 -#define FD_WRITE 0x2 -#define FD_RDWR (FD_READ | FD_WRITE) - -/* - * File descriptor table structure. - */ -struct fd_table_entry { - /* - * Lock for accesses to this file descriptor table - * entry. This is passed to _spinlock() to provide atomic - * access to this structure. It does *not* represent the - * state of the lock on the file descriptor. - */ - spinlock_t lock; - struct pthread_queue r_queue; /* Read queue. */ - struct pthread_queue w_queue; /* Write queue. */ - struct pthread *r_owner; /* Ptr to thread owning read lock. */ - struct pthread *w_owner; /* Ptr to thread owning write lock. */ - char *r_fname; /* Ptr to read lock source file name */ - int r_lineno; /* Read lock source line number. */ - char *w_fname; /* Ptr to write lock source file name */ - int w_lineno; /* Write lock source line number. */ - int r_lockcount; /* Count for FILE read locks. */ - int w_lockcount; /* Count for FILE write locks. */ - int flags; /* Flags used in open. */ -}; - -struct pthread_select_data { - int nfds; - fd_set readfds; - fd_set writefds; - fd_set exceptfds; -}; - -union pthread_wait_data { - pthread_mutex_t *mutex; - pthread_cond_t *cond; - const sigset_t *sigwait; /* Waiting on a signal in sigwait */ - struct { - short fd; /* Used when thread waiting on fd */ - short branch; /* Line number, for debugging. */ - char *fname; /* Source file name for debugging.*/ - } fd; - struct pthread_select_data * select_data; -}; - -/* - * Thread structure. - */ -struct pthread { - /* - * Magic value to help recognize a valid thread structure - * from an invalid one: - */ -#define PTHREAD_MAGIC ((u_int32_t) 0xd09ba115) - u_int32_t magic; - char *name; - - /* - * Lock for accesses to this thread structure. - */ - spinlock_t lock; - - /* - * Pointer to the next thread in the thread linked list. - */ - struct pthread *nxt; - - /* - * Pointer to the next thread in the dead thread linked list. - */ - struct pthread *nxt_dead; - - /* - * Thread start routine, argument, stack pointer and thread - * attributes. - */ - void *(*start_routine)(void *); - void *arg; - void *stack; - struct pthread_attr attr; - -#if (defined(__FreeBSD__) || defined(__NetBSD__)) && defined(__i386__) - /* - * Saved floating point registers on systems where they are not - * saved in the signal context. - */ - char saved_fp[108]; -#endif - - /* - * Saved signal context used in call to sigreturn by - * _thread_kern_sched if sig_saved is TRUE. - */ - struct sigcontext saved_sigcontext; - - /* - * Saved jump buffer used in call to longjmp by _thread_kern_sched - * if sig_saved is FALSE. - */ - jmp_buf saved_jmp_buf; - - /* - * TRUE if the last state saved was a signal context. FALSE if the - * last state saved was a jump buffer. - */ - int sig_saved; - - /* - * Current signal mask and pending signals. - */ - sigset_t sigmask; - sigset_t sigpend; - - /* Thread state: */ - enum pthread_state state; - - /* Time that this thread was last made active. */ - struct timeval last_active; - - /* Time that this thread was last made inactive. */ - struct timeval last_inactive; - - /* - * Number of microseconds accumulated by this thread when - * time slicing is active. - */ - long slice_usec; - - /* - * Incremental priority accumulated by thread while it is ready to - * run but is denied being run. - */ - int inc_prio; - - /* - * Time to wake up thread. This is used for sleeping threads and - * for any operation which may time out (such as select). - */ - struct timespec wakeup_time; - - /* TRUE if operation has timed out. */ - int timeout; - - /* - * Error variable used instead of errno. The function __error() - * returns a pointer to this. - */ - int error; - - /* Join queue for waiting threads: */ - struct pthread_queue join_queue; - - /* - * The current thread can belong to only one queue at a time. - * - * Pointer to queue (if any) on which the current thread is waiting. - * - * XXX The queuing should be changed to use the TAILQ entry below. - * XXX For the time being, it's hybrid. - */ - struct pthread_queue *queue; - - /* Pointer to next element in queue. */ - struct pthread *qnxt; - - /* Queue entry for this thread: */ - TAILQ_ENTRY(pthread) qe; - - /* Wait data. */ - union pthread_wait_data data; - - /* - * Set to TRUE if a blocking operation was - * interrupted by a signal: - */ - int interrupted; - - /* Signal number when in state PS_SIGWAIT: */ - int signo; - - /* Miscellaneous data. */ - int flags; -#define PTHREAD_EXITING 0x0100 - char pthread_priority; - void *ret; - const void **specific_data; - int specific_data_count; - - /* Cleanup handlers Link List */ - struct pthread_cleanup *cleanup; - char *fname; /* Ptr to source file name */ - int lineno; /* Source line number. */ -}; - -/* - * Global variables for the uthread kernel. - */ - -/* Kernel thread structure used when there are no running threads: */ -SCLASS struct pthread _thread_kern_thread; - -/* Ptr to the thread structure for the running thread: */ -SCLASS struct pthread * volatile _thread_run -#ifdef GLOBAL_PTHREAD_PRIVATE -= &_thread_kern_thread; -#else -; -#endif - -/* - * Ptr to the thread running in single-threaded mode or NULL if - * running multi-threaded (default POSIX behaviour). - */ -SCLASS struct pthread * volatile _thread_single -#ifdef GLOBAL_PTHREAD_PRIVATE -= NULL; -#else -; -#endif - -/* Ptr to the first thread in the thread linked list: */ -SCLASS struct pthread * volatile _thread_link_list -#ifdef GLOBAL_PTHREAD_PRIVATE -= NULL; -#else -; -#endif - -/* - * Array of kernel pipe file descriptors that are used to ensure that - * no signals are missed in calls to _select. - */ -SCLASS int _thread_kern_pipe[2] -#ifdef GLOBAL_PTHREAD_PRIVATE -= { - -1, - -1 -}; -#else -; -#endif -SCLASS int _thread_kern_in_select -#ifdef GLOBAL_PTHREAD_PRIVATE -= 0; -#else -; -#endif -SCLASS int _thread_kern_in_sched -#ifdef GLOBAL_PTHREAD_PRIVATE -= 0; -#else -; -#endif - -/* Last time that an incremental priority update was performed: */ -SCLASS struct timeval kern_inc_prio_time -#ifdef GLOBAL_PTHREAD_PRIVATE -= { 0, 0 }; -#else -; -#endif - -/* Dead threads: */ -SCLASS struct pthread * volatile _thread_dead -#ifdef GLOBAL_PTHREAD_PRIVATE -= NULL; -#else -; -#endif - -/* Initial thread: */ -SCLASS struct pthread *_thread_initial -#ifdef GLOBAL_PTHREAD_PRIVATE -= NULL; -#else -; -#endif - -/* Default thread attributes: */ -SCLASS struct pthread_attr pthread_attr_default -#ifdef GLOBAL_PTHREAD_PRIVATE -= { SCHED_RR, PTHREAD_DEFAULT_PRIORITY, PTHREAD_CREATE_RUNNING, - PTHREAD_CREATE_JOINABLE, NULL, NULL, NULL, PTHREAD_STACK_DEFAULT }; -#else -; -#endif - -/* Default mutex attributes: */ -SCLASS struct pthread_mutex_attr pthread_mutexattr_default -#ifdef GLOBAL_PTHREAD_PRIVATE -= { MUTEX_TYPE_FAST, 0 }; -#else -; -#endif - -/* Default condition variable attributes: */ -SCLASS struct pthread_cond_attr pthread_condattr_default -#ifdef GLOBAL_PTHREAD_PRIVATE -= { COND_TYPE_FAST, 0 }; -#else -; -#endif - -/* - * Standard I/O file descriptors need special flag treatment since - * setting one to non-blocking does all on *BSD. Sigh. This array - * is used to store the initial flag settings. - */ -SCLASS int _pthread_stdio_flags[3]; - -/* File table information: */ -SCLASS struct fd_table_entry **_thread_fd_table -#ifdef GLOBAL_PTHREAD_PRIVATE -= NULL; -#else -; -#endif - -SCLASS const int dtablecount -#ifdef GLOBAL_PTHREAD_PRIVATE -= 4096/sizeof(struct fd_table_entry); -#else -; -#endif -SCLASS int _thread_dtablesize /* Descriptor table size. */ -#ifdef GLOBAL_PTHREAD_PRIVATE -= 1024; -#else -; -#endif - -/* Garbage collector mutex and condition variable. */ -SCLASS pthread_mutex_t _gc_mutex -#ifdef GLOBAL_PTHREAD_PRIVATE -= NULL -#endif -; -SCLASS pthread_cond_t _gc_cond -#ifdef GLOBAL_PTHREAD_PRIVATE -= NULL -#endif -; - -/* - * Array of signal actions for this process. - */ -struct sigaction _thread_sigact[NSIG]; - -/* Undefine the storage class specifier: */ -#undef SCLASS - -#ifdef _LOCK_DEBUG -#define _FD_LOCK(_fd,_type,_ts) _thread_fd_lock_debug(_fd, _type, \ - _ts, __FILE__, __LINE__) -#define _FD_UNLOCK(_fd,_type) _thread_fd_unlock_debug(_fd, _type, \ - __FILE__, __LINE__) -#else -#define _FD_LOCK(_fd,_type,_ts) _thread_fd_lock(_fd, _type, _ts) -#define _FD_UNLOCK(_fd,_type) _thread_fd_unlock(_fd, _type) -#endif - -/* - * Function prototype definitions. - */ -__BEGIN_DECLS -char *__ttyname_basic(int); -char *__ttyname_r_basic(int, char *, size_t); -char *ttyname_r(int, char *, size_t); -int _find_dead_thread(pthread_t); -int _find_thread(pthread_t); -int _thread_create(pthread_t *,const pthread_attr_t *,void *(*start_routine)(void *),void *,pthread_t); -int _thread_fd_lock(int, int, struct timespec *); -int _thread_fd_lock_debug(int, int, struct timespec *,char *fname,int lineno); -void _dispatch_signals(void); -void _thread_signal(pthread_t, int); -void _lock_thread(void); -void _lock_thread_list(void); -void _unlock_thread(void); -void _unlock_thread_list(void); -void _thread_exit(char *, int, char *); -void _thread_fd_unlock(int, int); -void _thread_fd_unlock_debug(int, int, char *, int); -void *_thread_cleanup(pthread_t); -void _thread_cleanupspecific(void); -void _thread_dump_info(void); -void _thread_init(void); -void _thread_kern_sched(struct sigcontext *); -void _thread_kern_sched_state(enum pthread_state,char *fname,int lineno); -void _thread_kern_sched_state_unlock(enum pthread_state state, - spinlock_t *lock, char *fname, int lineno); -void _thread_kern_set_timeout(struct timespec *); -void _thread_sig_handler(int, int, struct sigcontext *); -void _thread_start(void); -void _thread_start_sig_handler(void); -void _thread_seterrno(pthread_t,int); -void _thread_queue_init(struct pthread_queue *); -void _thread_queue_enq(struct pthread_queue *, struct pthread *); -int _thread_queue_remove(struct pthread_queue *, struct pthread *); -int _thread_fd_table_init(int fd); -struct pthread *_thread_queue_get(struct pthread_queue *); -struct pthread *_thread_queue_deq(struct pthread_queue *); -pthread_addr_t _thread_gc(pthread_addr_t); - -/* #include <signal.h> */ -int _thread_sys_sigaction(int, const struct sigaction *, struct sigaction *); -int _thread_sys_sigpending(sigset_t *); -int _thread_sys_sigprocmask(int, const sigset_t *, sigset_t *); -int _thread_sys_sigsuspend(const sigset_t *); -int _thread_sys_siginterrupt(int, int); -int _thread_sys_sigpause(int); -int _thread_sys_sigreturn(struct sigcontext *); -int _thread_sys_sigstack(const struct sigstack *, struct sigstack *); -int _thread_sys_sigvec(int, struct sigvec *, struct sigvec *); -void _thread_sys_psignal(unsigned int, const char *); -void (*_thread_sys_signal(int, void (*)(int)))(int); - -/* #include <sys/stat.h> */ -#ifdef _SYS_STAT_H_ -int _thread_sys_fchmod(int, mode_t); -int _thread_sys_fstat(int, struct stat *); -int _thread_sys_fchflags(int, u_long); -#endif - -/* #include <sys/mount.h> */ -#ifdef _SYS_MOUNT_H_ -int _thread_sys_fstatfs(int, struct statfs *); -#endif -int _thread_sys_pipe(int *); - -/* #include <sys/socket.h> */ -#ifdef _SYS_SOCKET_H_ -int _thread_sys_accept(int, struct sockaddr *, int *); -int _thread_sys_bind(int, const struct sockaddr *, int); -int _thread_sys_connect(int, const struct sockaddr *, int); -int _thread_sys_getpeername(int, struct sockaddr *, int *); -int _thread_sys_getsockname(int, struct sockaddr *, int *); -int _thread_sys_getsockopt(int, int, int, void *, int *); -int _thread_sys_listen(int, int); -int _thread_sys_setsockopt(int, int, int, const void *, int); -int _thread_sys_shutdown(int, int); -int _thread_sys_socket(int, int, int); -int _thread_sys_socketpair(int, int, int, int *); -ssize_t _thread_sys_recv(int, void *, size_t, int); -ssize_t _thread_sys_recvfrom(int, void *, size_t, int, struct sockaddr *, int *); -ssize_t _thread_sys_recvmsg(int, struct msghdr *, int); -ssize_t _thread_sys_send(int, const void *, size_t, int); -ssize_t _thread_sys_sendmsg(int, const struct msghdr *, int); -ssize_t _thread_sys_sendto(int, const void *,size_t, int, const struct sockaddr *, int); -#endif - -/* #include <stdio.h> */ -#ifdef _STDIO_H_ -FILE *_thread_sys_fdopen(int, const char *); -FILE *_thread_sys_fopen(const char *, const char *); -FILE *_thread_sys_freopen(const char *, const char *, FILE *); -FILE *_thread_sys_popen(const char *, const char *); -FILE *_thread_sys_tmpfile(void); -char *_thread_sys_ctermid(char *); -char *_thread_sys_cuserid(char *); -char *_thread_sys_fgetln(FILE *, size_t *); -char *_thread_sys_fgets(char *, int, FILE *); -char *_thread_sys_gets(char *); -char *_thread_sys_tempnam(const char *, const char *); -char *_thread_sys_tmpnam(char *); -int _thread_sys_fclose(FILE *); -int _thread_sys_feof(FILE *); -int _thread_sys_ferror(FILE *); -int _thread_sys_fflush(FILE *); -int _thread_sys_fgetc(FILE *); -int _thread_sys_fgetpos(FILE *, fpos_t *); -int _thread_sys_fileno(FILE *); -int _thread_sys_fprintf(FILE *, const char *, ...); -int _thread_sys_fpurge(FILE *); -int _thread_sys_fputc(int, FILE *); -int _thread_sys_fputs(const char *, FILE *); -int _thread_sys_fscanf(FILE *, const char *, ...); -int _thread_sys_fseek(FILE *, long, int); -int _thread_sys_fsetpos(FILE *, const fpos_t *); -int _thread_sys_getc(FILE *); -int _thread_sys_getchar(void); -int _thread_sys_getw(FILE *); -int _thread_sys_pclose(FILE *); -int _thread_sys_printf(const char *, ...); -int _thread_sys_putc(int, FILE *); -int _thread_sys_putchar(int); -int _thread_sys_puts(const char *); -int _thread_sys_putw(int, FILE *); -int _thread_sys_remove(const char *); -int _thread_sys_rename (const char *, const char *); -int _thread_sys_scanf(const char *, ...); -int _thread_sys_setlinebuf(FILE *); -int _thread_sys_setvbuf(FILE *, char *, int, size_t); -int _thread_sys_snprintf(char *, size_t, const char *, ...); -int _thread_sys_sprintf(char *, const char *, ...); -int _thread_sys_sscanf(const char *, const char *, ...); -int _thread_sys_ungetc(int, FILE *); -int _thread_sys_vfprintf(FILE *, const char *, _BSD_VA_LIST_); -int _thread_sys_vprintf(const char *, _BSD_VA_LIST_); -int _thread_sys_vscanf(const char *, _BSD_VA_LIST_); -int _thread_sys_vsnprintf(char *, size_t, const char *, _BSD_VA_LIST_); -int _thread_sys_vsprintf(char *, const char *, _BSD_VA_LIST_); -int _thread_sys_vsscanf(const char *, const char *, _BSD_VA_LIST_); -long _thread_sys_ftell(FILE *); -size_t _thread_sys_fread(void *, size_t, size_t, FILE *); -size_t _thread_sys_fwrite(const void *, size_t, size_t, FILE *); -void _thread_sys_clearerr(FILE *); -void _thread_sys_perror(const char *); -void _thread_sys_rewind(FILE *); -void _thread_sys_setbuf(FILE *, char *); -void _thread_sys_setbuffer(FILE *, char *, int); -#endif - -/* #include <unistd.h> */ -#ifdef _UNISTD_H_ -char *_thread_sys_ttyname(int); -int _thread_sys_close(int); -int _thread_sys_dup(int); -int _thread_sys_dup2(int, int); -int _thread_sys_exect(const char *, char * const *, char * const *); -int _thread_sys_execve(const char *, char * const *, char * const *); -int _thread_sys_fchdir(int); -int _thread_sys_fchown(int, uid_t, gid_t); -int _thread_sys_fsync(int); -int _thread_sys_ftruncate(int, off_t); -int _thread_sys_pause(void); -int _thread_sys_pipe(int *); -int _thread_sys_select(int, fd_set *, fd_set *, fd_set *, struct timeval *); -off_t _thread_sys_lseek(int, off_t, int); -pid_t _thread_sys_fork(void); -pid_t _thread_sys_tcgetpgrp(int); -ssize_t _thread_sys_read(int, void *, size_t); -ssize_t _thread_sys_write(int, const void *, size_t); -void _thread_sys__exit(int); -#endif - -/* #include <fcntl.h> */ -#ifdef _SYS_FCNTL_H_ -int _thread_sys_creat(const char *, mode_t); -int _thread_sys_fcntl(int, int, ...); -int _thread_sys_flock(int, int); -int _thread_sys_open(const char *, int, ...); -#endif - -/* #include <sys/ioctl.h> */ -#ifdef _SYS_IOCTL_H_ -int _thread_sys_ioctl(int, unsigned long, ...); -#endif - -/* #include <dirent.h> */ -#ifdef _DIRENT_H_ -DIR *___thread_sys_opendir2(const char *, int); -DIR *_thread_sys_opendir(const char *); -int _thread_sys_alphasort(const void *, const void *); -int _thread_sys_scandir(const char *, struct dirent ***, - int (*)(struct dirent *), int (*)(const void *, const void *)); -int _thread_sys_closedir(DIR *); -int _thread_sys_getdirentries(int, char *, int, long *); -long _thread_sys_telldir(const DIR *); -struct dirent *_thread_sys_readdir(DIR *); -void _thread_sys_rewinddir(DIR *); -void _thread_sys_seekdir(DIR *, long); -#endif - -/* #include <sys/uio.h> */ -#ifdef _SYS_UIO_H_ -ssize_t _thread_sys_readv(int, const struct iovec *, int); -ssize_t _thread_sys_writev(int, const struct iovec *, int); -#endif - -/* #include <sys/wait.h> */ -#ifdef WNOHANG -pid_t _thread_sys_wait(int *); -pid_t _thread_sys_waitpid(pid_t, int *, int); -pid_t _thread_sys_wait3(int *, int, struct rusage *); -pid_t _thread_sys_wait4(pid_t, int *, int, struct rusage *); -#endif -__END_DECLS - -#endif /* !_PTHREAD_PRIVATE_H */ diff --git a/lib/libkse/thread/thr_read.c b/lib/libkse/thread/thr_read.c deleted file mode 100644 index 6c4d211218768..0000000000000 --- a/lib/libkse/thread/thr_read.c +++ /dev/null @@ -1,97 +0,0 @@ -/* - * Copyright (c) 1995-1998 John Birrell <jb@cimlogic.com.au> - * 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 John Birrell. - * 4. Neither the name of the author nor the names of any co-contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY JOHN BIRRELL 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. - * - * $Id: uthread_read.c,v 1.5 1998/06/09 23:20:53 jb Exp $ - * - */ -#include <sys/types.h> -#include <sys/fcntl.h> -#include <sys/uio.h> -#include <errno.h> -#include <unistd.h> -#ifdef _THREAD_SAFE -#include <pthread.h> -#include "pthread_private.h" - -ssize_t -read(int fd, void *buf, size_t nbytes) -{ - int ret; - int type; - - /* POSIX says to do just this: */ - if (nbytes == 0) - return (0); - - /* Lock the file descriptor for read: */ - if ((ret = _FD_LOCK(fd, FD_READ, NULL)) == 0) { - /* Get the read/write mode type: */ - type = _thread_fd_table[fd]->flags & O_ACCMODE; - - /* Check if the file is not open for read: */ - if (type != O_RDONLY && type != O_RDWR) { - /* File is not open for read: */ - errno = EBADF; - _FD_UNLOCK(fd, FD_READ); - return (-1); - } - - /* Perform a non-blocking read syscall: */ - while ((ret = _thread_sys_read(fd, buf, nbytes)) < 0) { - if ((_thread_fd_table[fd]->flags & O_NONBLOCK) == 0 && - (errno == EWOULDBLOCK || errno == EAGAIN)) { - _thread_run->data.fd.fd = fd; - _thread_kern_set_timeout(NULL); - - /* Reset the interrupted operation flag: */ - _thread_run->interrupted = 0; - - _thread_kern_sched_state(PS_FDR_WAIT, - __FILE__, __LINE__); - - /* - * Check if the operation was - * interrupted by a signal - */ - if (_thread_run->interrupted) { - errno = EINTR; - ret = -1; - break; - } - } else { - break; - } - } - _FD_UNLOCK(fd, FD_READ); - } - return (ret); -} -#endif diff --git a/lib/libkse/thread/thr_readv.c b/lib/libkse/thread/thr_readv.c deleted file mode 100644 index 819e20cbc257f..0000000000000 --- a/lib/libkse/thread/thr_readv.c +++ /dev/null @@ -1,93 +0,0 @@ -/* - * Copyright (c) 1995-1998 John Birrell <jb@cimlogic.com.au> - * 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 John Birrell. - * 4. Neither the name of the author nor the names of any co-contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY JOHN BIRRELL 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. - * - * $Id: uthread_readv.c,v 1.5 1998/06/09 23:20:54 jb Exp $ - * - */ -#include <sys/types.h> -#include <sys/fcntl.h> -#include <sys/uio.h> -#include <errno.h> -#include <unistd.h> -#ifdef _THREAD_SAFE -#include <pthread.h> -#include "pthread_private.h" - -ssize_t -readv(int fd, const struct iovec * iov, int iovcnt) -{ - int ret; - int type; - - /* Lock the file descriptor for read: */ - if ((ret = _FD_LOCK(fd, FD_READ, NULL)) == 0) { - /* Get the read/write mode type: */ - type = _thread_fd_table[fd]->flags & O_ACCMODE; - - /* Check if the file is not open for read: */ - if (type != O_RDONLY && type != O_RDWR) { - /* File is not open for read: */ - errno = EBADF; - _FD_UNLOCK(fd, FD_READ); - return (-1); - } - - /* Perform a non-blocking readv syscall: */ - while ((ret = _thread_sys_readv(fd, iov, iovcnt)) < 0) { - if ((_thread_fd_table[fd]->flags & O_NONBLOCK) == 0 && - (errno == EWOULDBLOCK || errno == EAGAIN)) { - _thread_run->data.fd.fd = fd; - _thread_kern_set_timeout(NULL); - - /* Reset the interrupted operation flag: */ - _thread_run->interrupted = 0; - - _thread_kern_sched_state(PS_FDR_WAIT, - __FILE__, __LINE__); - - /* - * Check if the operation was - * interrupted by a signal - */ - if (_thread_run->interrupted) { - errno = EINTR; - ret = -1; - break; - } - } else { - break; - } - } - _FD_UNLOCK(fd, FD_READ); - } - return (ret); -} -#endif diff --git a/lib/libkse/thread/thr_resume_np.c b/lib/libkse/thread/thr_resume_np.c deleted file mode 100644 index 7c5f46adfcef5..0000000000000 --- a/lib/libkse/thread/thr_resume_np.c +++ /dev/null @@ -1,54 +0,0 @@ -/* - * Copyright (c) 1995 John Birrell <jb@cimlogic.com.au>. - * 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 John Birrell. - * 4. Neither the name of the author nor the names of any co-contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY JOHN BIRRELL 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 <errno.h> -#ifdef _THREAD_SAFE -#include <pthread.h> -#include "pthread_private.h" - -/* Resume a thread: */ -int -pthread_resume_np(pthread_t thread) -{ - int ret; - - /* Find the thread in the list of active threads: */ - if ((ret = _find_thread(thread)) == 0) { - /* The thread exists. Is it suspended? */ - if (thread->state != PS_SUSPENDED) { - /* Allow the thread to run. */ - PTHREAD_NEW_STATE(thread,PS_RUNNING); - } - } - return(ret); -} -#endif diff --git a/lib/libkse/thread/thr_rwlock.c b/lib/libkse/thread/thr_rwlock.c deleted file mode 100644 index f398a1857d4a5..0000000000000 --- a/lib/libkse/thread/thr_rwlock.c +++ /dev/null @@ -1,335 +0,0 @@ -/*- - * Copyright (c) 1998 Alex Nash - * 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. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR 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 AUTHOR 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. - * - * $Id: uthread_rwlock.c,v 1.2 1998/09/07 19:23:55 alex Exp $ - */ - -#ifdef _THREAD_SAFE -#include <errno.h> -#include <limits.h> -#include <stdlib.h> - -#include <pthread.h> -#include "pthread_private.h" - -/* maximum number of times a read lock may be obtained */ -#define MAX_READ_LOCKS (INT_MAX - 1) - -static int init_static (pthread_rwlock_t *rwlock); - -static spinlock_t static_init_lock = _SPINLOCK_INITIALIZER; - -static int -init_static (pthread_rwlock_t *rwlock) -{ - int ret; - - _SPINLOCK(&static_init_lock); - - if (*rwlock == NULL) - ret = pthread_rwlock_init(rwlock, NULL); - else - ret = 0; - - _SPINUNLOCK(&static_init_lock); - - return(ret); -} - -int -pthread_rwlock_destroy (pthread_rwlock_t *rwlock) -{ - int ret; - - if (rwlock == NULL) - ret = EINVAL; - else { - pthread_rwlock_t prwlock; - - prwlock = *rwlock; - - pthread_mutex_destroy(&prwlock->lock); - pthread_cond_destroy(&prwlock->read_signal); - pthread_cond_destroy(&prwlock->write_signal); - free(prwlock); - - *rwlock = NULL; - - ret = 0; - } - - return(ret); -} - -int -pthread_rwlock_init (pthread_rwlock_t *rwlock, const pthread_rwlockattr_t *attr) -{ - pthread_rwlock_t prwlock; - int ret; - - /* allocate rwlock object */ - prwlock = (pthread_rwlock_t)malloc(sizeof(struct pthread_rwlock)); - - if (prwlock == NULL) - return(ENOMEM); - - /* initialize the lock */ - if ((ret = pthread_mutex_init(&prwlock->lock, NULL)) != 0) - free(prwlock); - else { - /* initialize the read condition signal */ - ret = pthread_cond_init(&prwlock->read_signal, NULL); - - if (ret != 0) { - pthread_mutex_destroy(&prwlock->lock); - free(prwlock); - } else { - /* initialize the write condition signal */ - ret = pthread_cond_init(&prwlock->write_signal, NULL); - - if (ret != 0) { - pthread_cond_destroy(&prwlock->read_signal); - pthread_mutex_destroy(&prwlock->lock); - free(prwlock); - } else { - /* success */ - prwlock->state = 0; - prwlock->blocked_writers = 0; - - *rwlock = prwlock; - } - } - } - - return(ret); -} - -int -pthread_rwlock_rdlock (pthread_rwlock_t *rwlock) -{ - pthread_rwlock_t prwlock; - int ret; - - if (rwlock == NULL) - return(EINVAL); - - prwlock = *rwlock; - - /* check for static initialization */ - if (prwlock == NULL) { - if ((ret = init_static(rwlock)) != 0) - return(ret); - - prwlock = *rwlock; - } - - /* grab the monitor lock */ - if ((ret = pthread_mutex_lock(&prwlock->lock)) != 0) - return(ret); - - /* give writers priority over readers */ - while (prwlock->blocked_writers || prwlock->state < 0) { - ret = pthread_cond_wait(&prwlock->read_signal, &prwlock->lock); - - if (ret != 0) { - /* can't do a whole lot if this fails */ - pthread_mutex_unlock(&prwlock->lock); - return(ret); - } - } - - /* check lock count */ - if (prwlock->state == MAX_READ_LOCKS) - ret = EAGAIN; - else - ++prwlock->state; /* indicate we are locked for reading */ - - /* - * Something is really wrong if this call fails. Returning - * error won't do because we've already obtained the read - * lock. Decrementing 'state' is no good because we probably - * don't have the monitor lock. - */ - pthread_mutex_unlock(&prwlock->lock); - - return(ret); -} - -int -pthread_rwlock_tryrdlock (pthread_rwlock_t *rwlock) -{ - pthread_rwlock_t prwlock; - int ret; - - if (rwlock == NULL) - return(EINVAL); - - prwlock = *rwlock; - - /* check for static initialization */ - if (prwlock == NULL) { - if ((ret = init_static(rwlock)) != 0) - return(ret); - - prwlock = *rwlock; - } - - /* grab the monitor lock */ - if ((ret = pthread_mutex_lock(&prwlock->lock)) != 0) - return(ret); - - /* give writers priority over readers */ - if (prwlock->blocked_writers || prwlock->state < 0) - ret = EWOULDBLOCK; - else if (prwlock->state == MAX_READ_LOCKS) - ret = EAGAIN; /* too many read locks acquired */ - else - ++prwlock->state; /* indicate we are locked for reading */ - - /* see the comment on this in pthread_rwlock_rdlock */ - pthread_mutex_unlock(&prwlock->lock); - - return(ret); -} - -int -pthread_rwlock_trywrlock (pthread_rwlock_t *rwlock) -{ - pthread_rwlock_t prwlock; - int ret; - - if (rwlock == NULL) - return(EINVAL); - - prwlock = *rwlock; - - /* check for static initialization */ - if (prwlock == NULL) { - if ((ret = init_static(rwlock)) != 0) - return(ret); - - prwlock = *rwlock; - } - - /* grab the monitor lock */ - if ((ret = pthread_mutex_lock(&prwlock->lock)) != 0) - return(ret); - - if (prwlock->state != 0) - ret = EWOULDBLOCK; - else - /* indicate we are locked for writing */ - prwlock->state = -1; - - /* see the comment on this in pthread_rwlock_rdlock */ - pthread_mutex_unlock(&prwlock->lock); - - return(ret); -} - -int -pthread_rwlock_unlock (pthread_rwlock_t *rwlock) -{ - pthread_rwlock_t prwlock; - int ret; - - if (rwlock == NULL) - return(EINVAL); - - prwlock = *rwlock; - - if (prwlock == NULL) - return(EINVAL); - - /* grab the monitor lock */ - if ((ret = pthread_mutex_lock(&prwlock->lock)) != 0) - return(ret); - - if (prwlock->state > 0) { - if (--prwlock->state == 0 && prwlock->blocked_writers) - ret = pthread_cond_signal(&prwlock->write_signal); - } else if (prwlock->state < 0) { - prwlock->state = 0; - - if (prwlock->blocked_writers) - ret = pthread_cond_signal(&prwlock->write_signal); - else - ret = pthread_cond_broadcast(&prwlock->read_signal); - } else - ret = EINVAL; - - /* see the comment on this in pthread_rwlock_rdlock */ - pthread_mutex_unlock(&prwlock->lock); - - return(ret); -} - -int -pthread_rwlock_wrlock (pthread_rwlock_t *rwlock) -{ - pthread_rwlock_t prwlock; - int ret; - - if (rwlock == NULL) - return(EINVAL); - - prwlock = *rwlock; - - /* check for static initialization */ - if (prwlock == NULL) { - if ((ret = init_static(rwlock)) != 0) - return(ret); - - prwlock = *rwlock; - } - - /* grab the monitor lock */ - if ((ret = pthread_mutex_lock(&prwlock->lock)) != 0) - return(ret); - - while (prwlock->state != 0) { - ++prwlock->blocked_writers; - - ret = pthread_cond_wait(&prwlock->write_signal, &prwlock->lock); - - if (ret != 0) { - --prwlock->blocked_writers; - pthread_mutex_unlock(&prwlock->lock); - return(ret); - } - - --prwlock->blocked_writers; - } - - /* indicate we are locked for writing */ - prwlock->state = -1; - - /* see the comment on this in pthread_rwlock_rdlock */ - pthread_mutex_unlock(&prwlock->lock); - - return(ret); -} - -#endif /* _THREAD_SAFE */ diff --git a/lib/libkse/thread/thr_rwlockattr.c b/lib/libkse/thread/thr_rwlockattr.c deleted file mode 100644 index 50b128b928072..0000000000000 --- a/lib/libkse/thread/thr_rwlockattr.c +++ /dev/null @@ -1,98 +0,0 @@ -/*- - * Copyright (c) 1998 Alex Nash - * 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. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR 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 AUTHOR 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. - * - * $Id: uthread_rwlockattr.c,v 1.1 1998/09/07 19:01:43 alex Exp $ - */ - -#ifdef _THREAD_SAFE -#include <errno.h> -#include <stdlib.h> - -#include <pthread.h> -#include "pthread_private.h" - -int -pthread_rwlockattr_destroy (pthread_rwlockattr_t *rwlockattr) -{ - pthread_rwlockattr_t prwlockattr; - - if (rwlockattr == NULL) - return(EINVAL); - - prwlockattr = *rwlockattr; - - if (prwlockattr == NULL) - return(EINVAL); - - free(prwlockattr); - - return(0); -} - -int -pthread_rwlockattr_getpshared (const pthread_rwlockattr_t *rwlockattr, - int *pshared) -{ - *pshared = (*rwlockattr)->pshared; - - return(0); -} - -int -pthread_rwlockattr_init (pthread_rwlockattr_t *rwlockattr) -{ - pthread_rwlockattr_t prwlockattr; - - if (rwlockattr == NULL) - return(EINVAL); - - prwlockattr = (pthread_rwlockattr_t) - malloc(sizeof(struct pthread_rwlockattr)); - - if (prwlockattr == NULL) - return(ENOMEM); - - prwlockattr->pshared = PTHREAD_PROCESS_PRIVATE; - *rwlockattr = prwlockattr; - - return(0); -} - -int -pthread_rwlockattr_setpshared (pthread_rwlockattr_t *rwlockattr, - int *pshared) -{ - int ps = *pshared; - - /* only PTHREAD_PROCESS_PRIVATE is supported */ - if (ps != PTHREAD_PROCESS_PRIVATE) - return(EINVAL); - - (*rwlockattr)->pshared = ps; - - return(0); -} - -#endif /* _THREAD_SAFE */ diff --git a/lib/libkse/thread/thr_select.c b/lib/libkse/thread/thr_select.c deleted file mode 100644 index d6202db01406d..0000000000000 --- a/lib/libkse/thread/thr_select.c +++ /dev/null @@ -1,177 +0,0 @@ -/* - * Copyright (c) 1995-1998 John Birrell <jb@cimlogic.com.au> - * 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 John Birrell. - * 4. Neither the name of the author nor the names of any co-contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY JOHN BIRRELL 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 <unistd.h> -#include <errno.h> -#include <string.h> -#include <sys/types.h> -#include <sys/time.h> -#ifdef _THREAD_SAFE -#include <pthread.h> -#include "pthread_private.h" - -int -select(int numfds, fd_set * readfds, fd_set * writefds, - fd_set * exceptfds, struct timeval * timeout) -{ - fd_set read_locks, write_locks, rdwr_locks; - struct timespec ts; - struct timeval zero_timeout = {0, 0}; - int i, ret = 0, got_all_locks = 1; - struct pthread_select_data data; - - if (numfds > _thread_dtablesize) { - numfds = _thread_dtablesize; - } - /* Check if a timeout was specified: */ - if (timeout) { - /* Convert the timeval to a timespec: */ - TIMEVAL_TO_TIMESPEC(timeout, &ts); - - /* Set the wake up time: */ - _thread_kern_set_timeout(&ts); - } else { - /* Wait for ever: */ - _thread_kern_set_timeout(NULL); - } - - FD_ZERO(&read_locks); - FD_ZERO(&write_locks); - FD_ZERO(&rdwr_locks); - - /* lock readfds */ - if (readfds || writefds || exceptfds) { - for (i = 0; i < numfds; i++) { - if ((readfds && (FD_ISSET(i, readfds))) || (exceptfds && FD_ISSET(i, exceptfds))) { - if (writefds && FD_ISSET(i, writefds)) { - if ((ret = _FD_LOCK(i, FD_RDWR, NULL)) != 0) { - got_all_locks = 0; - break; - } - FD_SET(i, &rdwr_locks); - } else { - if ((ret = _FD_LOCK(i, FD_READ, NULL)) != 0) { - got_all_locks = 0; - break; - } - FD_SET(i, &read_locks); - } - } else { - if (writefds && FD_ISSET(i, writefds)) { - if ((ret = _FD_LOCK(i, FD_WRITE, NULL)) != 0) { - got_all_locks = 0; - break; - } - FD_SET(i, &write_locks); - } - } - } - } - if (got_all_locks) { - data.nfds = numfds; - FD_ZERO(&data.readfds); - FD_ZERO(&data.writefds); - FD_ZERO(&data.exceptfds); - if (readfds != NULL) { - memcpy(&data.readfds, readfds, sizeof(data.readfds)); - } - if (writefds != NULL) { - memcpy(&data.writefds, writefds, sizeof(data.writefds)); - } - if (exceptfds != NULL) { - memcpy(&data.exceptfds, exceptfds, sizeof(data.exceptfds)); - } - if ((ret = _thread_sys_select(data.nfds, &data.readfds, &data.writefds, &data.exceptfds, &zero_timeout)) == 0) { - data.nfds = numfds; - FD_ZERO(&data.readfds); - FD_ZERO(&data.writefds); - FD_ZERO(&data.exceptfds); - if (readfds != NULL) { - memcpy(&data.readfds, readfds, sizeof(data.readfds)); - } - if (writefds != NULL) { - memcpy(&data.writefds, writefds, sizeof(data.writefds)); - } - if (exceptfds != NULL) { - memcpy(&data.exceptfds, exceptfds, sizeof(data.exceptfds)); - } - _thread_run->data.select_data = &data; - _thread_run->interrupted = 0; - _thread_kern_sched_state(PS_SELECT_WAIT, __FILE__, __LINE__); - if (_thread_run->interrupted) { - errno = EINTR; - ret = -1; - } else - ret = data.nfds; - } - } - /* clean up the locks */ - for (i = 0; i < numfds; i++) - if (FD_ISSET(i, &read_locks)) - _FD_UNLOCK(i, FD_READ); - for (i = 0; i < numfds; i++) - if (FD_ISSET(i, &rdwr_locks)) - _FD_UNLOCK(i, FD_RDWR); - for (i = 0; i < numfds; i++) - if (FD_ISSET(i, &write_locks)) - _FD_UNLOCK(i, FD_WRITE); - - if (ret >= 0) { - if (readfds != NULL) { - for (i = 0; i < numfds; i++) { - if (FD_ISSET(i, readfds) && - !FD_ISSET(i, &data.readfds)) { - FD_CLR(i, readfds); - } - } - } - if (writefds != NULL) { - for (i = 0; i < numfds; i++) { - if (FD_ISSET(i, writefds) && - !FD_ISSET(i, &data.writefds)) { - FD_CLR(i, writefds); - } - } - } - if (exceptfds != NULL) { - for (i = 0; i < numfds; i++) { - if (FD_ISSET(i, exceptfds) && - !FD_ISSET(i, &data.exceptfds)) { - FD_CLR(i, exceptfds); - } - } - } - } - - return (ret); -} -#endif diff --git a/lib/libkse/thread/thr_self.c b/lib/libkse/thread/thr_self.c deleted file mode 100644 index a0a2d2aded6e2..0000000000000 --- a/lib/libkse/thread/thr_self.c +++ /dev/null @@ -1,43 +0,0 @@ -/* - * Copyright (c) 1995 John Birrell <jb@cimlogic.com.au>. - * 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 John Birrell. - * 4. Neither the name of the author nor the names of any co-contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY JOHN BIRRELL 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. - * - */ -#ifdef _THREAD_SAFE -#include <pthread.h> -#include "pthread_private.h" - -pthread_t -pthread_self(void) -{ - /* Return the running thread pointer: */ - return (_thread_run); -} -#endif diff --git a/lib/libkse/thread/thr_seterrno.c b/lib/libkse/thread/thr_seterrno.c deleted file mode 100644 index 570807f1fc7e5..0000000000000 --- a/lib/libkse/thread/thr_seterrno.c +++ /dev/null @@ -1,60 +0,0 @@ -/* - * Copyright (c) 1995 John Birrell <jb@cimlogic.com.au>. - * 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 John Birrell. - * 4. Neither the name of the author nor the names of any co-contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY JOHN BIRRELL 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. - * - */ -#ifdef _THREAD_SAFE -#include <pthread.h> -#include "pthread_private.h" - -/* - * This function needs to reference the global error variable which is - * normally hidden from the user. - */ -#ifdef errno -#undef errno; -#endif -extern int errno; - -void -_thread_seterrno(pthread_t thread, int error) -{ - /* Check for the initial thread: */ - if (thread == _thread_initial) - /* The initial thread always uses the global error variable: */ - errno = error; - else - /* - * Threads other than the initial thread always use the error - * field in the thread structureL - */ - thread->error = error; -} -#endif diff --git a/lib/libkse/thread/thr_setprio.c b/lib/libkse/thread/thr_setprio.c deleted file mode 100644 index dd89f156a50fd..0000000000000 --- a/lib/libkse/thread/thr_setprio.c +++ /dev/null @@ -1,56 +0,0 @@ -/* - * Copyright (c) 1995 John Birrell <jb@cimlogic.com.au>. - * 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 John Birrell. - * 4. Neither the name of the author nor the names of any co-contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY JOHN BIRRELL 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 <errno.h> -#ifdef _THREAD_SAFE -#include <pthread.h> -#include "pthread_private.h" - -int -pthread_setprio(pthread_t pthread, int prio) -{ - int ret; - - /* Check if the priority is invalid: */ - if (prio < PTHREAD_MIN_PRIORITY || prio > PTHREAD_MAX_PRIORITY) - /* Return an invalid argument error: */ - ret = EINVAL; - - /* Find the thread in the list of active threads: */ - else if ((ret = _find_thread(pthread)) == 0) - /* Set the thread priority: */ - pthread->pthread_priority = prio; - - /* Return the error status: */ - return (ret); -} -#endif diff --git a/lib/libkse/thread/thr_sig.c b/lib/libkse/thread/thr_sig.c deleted file mode 100644 index 3e55d6505a36b..0000000000000 --- a/lib/libkse/thread/thr_sig.c +++ /dev/null @@ -1,335 +0,0 @@ -/* - * Copyright (c) 1995-1998 John Birrell <jb@cimlogic.com.au> - * 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 John Birrell. - * 4. Neither the name of the author nor the names of any co-contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY JOHN BIRRELL 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 <signal.h> -#include <fcntl.h> -#include <unistd.h> -#include <errno.h> -#ifdef _THREAD_SAFE -#include <pthread.h> -#include "pthread_private.h" - -/* Static variables: */ -static int volatile yield_on_unlock_thread = 0; -static spinlock_t thread_link_list_lock = _SPINLOCK_INITIALIZER; - -/* Lock the thread list: */ -void -_lock_thread_list() -{ - /* Lock the thread list: */ - _SPINLOCK(&thread_link_list_lock); -} - -/* Lock the thread list: */ -void -_unlock_thread_list() -{ - /* Unlock the thread list: */ - _SPINUNLOCK(&thread_link_list_lock); - - /* - * Check if a scheduler interrupt occurred while the thread - * list was locked: - */ - if (yield_on_unlock_thread) { - /* Reset the interrupt flag: */ - yield_on_unlock_thread = 0; - - /* This thread has overstayed it's welcome: */ - sched_yield(); - } -} - -void -_thread_sig_handler(int sig, int code, struct sigcontext * scp) -{ - char c; - int i; - pthread_t pthread; - - /* - * Check if the pthread kernel has unblocked signals (or is about to) - * and was on its way into a _select when the current - * signal interrupted it: - */ - if (_thread_kern_in_select) { - /* Cast the signal number to a character variable: */ - c = sig; - - /* - * Write the signal number to the kernel pipe so that it will - * be ready to read when this signal handler returns. This - * means that the _select call will complete - * immediately. - */ - _thread_sys_write(_thread_kern_pipe[1], &c, 1); - } - - /* Check if the signal requires a dump of thread information: */ - if (sig == SIGINFO) - /* Dump thread information to file: */ - _thread_dump_info(); - - /* Check if an interval timer signal: */ - else if (sig == SIGVTALRM) { - /* Check if the scheduler interrupt has come at an - * unfortunate time which one of the threads is - * modifying the thread list: - */ - if (thread_link_list_lock.access_lock) - /* - * Set a flag so that the thread that has - * the lock yields when it unlocks the - * thread list: - */ - yield_on_unlock_thread = 1; - - /* - * Check if the kernel has not been interrupted while - * executing scheduler code: - */ - else if (!_thread_kern_in_sched) { - /* - * Schedule the next thread. This function is not - * expected to return because it will do a longjmp - * instead. - */ - _thread_kern_sched(scp); - - /* - * This point should not be reached, so abort the - * process: - */ - PANIC("Returned to signal function from scheduler"); - } - } else { - /* Check if a child has terminated: */ - if (sig == SIGCHLD) { - /* - * Go through the file list and set all files - * to non-blocking again in case the child - * set some of them to block. Sigh. - */ - for (i = 0; i < _thread_dtablesize; i++) { - /* Check if this file is used: */ - if (_thread_fd_table[i] != NULL) { - /* - * Set the file descriptor to - * non-blocking: - */ - _thread_sys_fcntl(i, F_SETFL, - _thread_fd_table[i]->flags | - O_NONBLOCK); - } - } - } - - /* - * POSIX says that pending SIGCONT signals are - * discarded when one of these signals occurs. - */ - if (sig == SIGTSTP || sig == SIGTTIN || sig == SIGTTOU) { - /* - * Enter a loop to discard pending SIGCONT - * signals: - */ - for (pthread = _thread_link_list; - pthread != NULL; - pthread = pthread->nxt) - sigdelset(&pthread->sigpend,SIGCONT); - } - - /* - * Enter a loop to process each thread in the linked - * list that is sigwait-ing on a signal. Since POSIX - * doesn't specify which thread will get the signal - * if there are multiple waiters, we'll give it to the - * first one we find. - */ - for (pthread = _thread_link_list; pthread != NULL; - pthread = pthread->nxt) { - if ((pthread->state == PS_SIGWAIT) && - sigismember(pthread->data.sigwait, sig)) { - /* Change the state of the thread to run: */ - PTHREAD_NEW_STATE(pthread,PS_RUNNING); - - /* Return the signal number: */ - pthread->signo = sig; - - /* - * Do not attempt to deliver this signal - * to other threads. - */ - return; - } - } - - /* Check if the signal is not being ignored: */ - if (_thread_sigact[sig - 1].sa_handler != SIG_IGN) - /* - * Enter a loop to process each thread in the linked - * list: - */ - for (pthread = _thread_link_list; pthread != NULL; - pthread = pthread->nxt) - _thread_signal(pthread,sig); - - /* Dispatch pending signals to the running thread: */ - _dispatch_signals(); - } - - /* Returns nothing. */ - return; -} - -/* Perform thread specific actions in response to a signal: */ -void -_thread_signal(pthread_t pthread, int sig) -{ - /* - * Flag the signal as pending. It will be dispatched later. - */ - sigaddset(&pthread->sigpend,sig); - - /* - * Process according to thread state: - */ - switch (pthread->state) { - /* - * States which do not change when a signal is trapped: - */ - case PS_COND_WAIT: - case PS_DEAD: - case PS_FDLR_WAIT: - case PS_FDLW_WAIT: - case PS_FILE_WAIT: - case PS_JOIN: - case PS_MUTEX_WAIT: - case PS_RUNNING: - case PS_STATE_MAX: - case PS_SIGTHREAD: - case PS_SIGWAIT: - case PS_SUSPENDED: - /* Nothing to do here. */ - break; - - /* - * The wait state is a special case due to the handling of - * SIGCHLD signals. - */ - case PS_WAIT_WAIT: - /* - * Check for signals other than the death of a child - * process: - */ - if (sig != SIGCHLD) - /* Flag the operation as interrupted: */ - pthread->interrupted = 1; - - /* Change the state of the thread to run: */ - PTHREAD_NEW_STATE(pthread,PS_RUNNING); - - /* Return the signal number: */ - pthread->signo = sig; - break; - - /* - * States that are interrupted by the occurrence of a signal - * other than the scheduling alarm: - */ - case PS_FDR_WAIT: - case PS_FDW_WAIT: - case PS_SLEEP_WAIT: - case PS_SELECT_WAIT: - if (sig != SIGCHLD || - _thread_sigact[sig - 1].sa_handler != SIG_DFL) { - /* Flag the operation as interrupted: */ - pthread->interrupted = 1; - - /* Change the state of the thread to run: */ - PTHREAD_NEW_STATE(pthread,PS_RUNNING); - - /* Return the signal number: */ - pthread->signo = sig; - } - break; - - case PS_SIGSUSPEND: - /* - * Only wake up the thread if the signal is unblocked - * and there is a handler installed for the signal. - */ - if (!sigismember(&pthread->sigmask, sig) && - _thread_sigact[sig - 1].sa_handler != SIG_DFL) { - /* Change the state of the thread to run: */ - PTHREAD_NEW_STATE(pthread,PS_RUNNING); - - /* Return the signal number: */ - pthread->signo = sig; - } - break; - } -} - -/* Dispatch pending signals to the running thread: */ -void -_dispatch_signals() -{ - int i; - - /* - * Check if there are pending signals for the running - * thread that aren't blocked: - */ - if ((_thread_run->sigpend & ~_thread_run->sigmask) != 0) - /* Look for all possible pending signals: */ - for (i = 1; i < NSIG; i++) - /* - * Check that a custom handler is installed - * and if the signal is not blocked: - */ - if (_thread_sigact[i - 1].sa_handler != SIG_DFL && - _thread_sigact[i - 1].sa_handler != SIG_IGN && - sigismember(&_thread_run->sigpend,i) && - !sigismember(&_thread_run->sigmask,i)) { - /* Clear the pending signal: */ - sigdelset(&_thread_run->sigpend,i); - - /* - * Dispatch the signal via the custom signal - * handler: - */ - (*(_thread_sigact[i - 1].sa_handler))(i); - } -} -#endif diff --git a/lib/libkse/thread/thr_sigaction.c b/lib/libkse/thread/thr_sigaction.c deleted file mode 100644 index 40f3850008e0d..0000000000000 --- a/lib/libkse/thread/thr_sigaction.c +++ /dev/null @@ -1,104 +0,0 @@ -/* - * Copyright (c) 1995-1998 John Birrell <jb@cimlogic.com.au> - * 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 John Birrell. - * 4. Neither the name of the author nor the names of any co-contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY JOHN BIRRELL 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 <signal.h> -#include <errno.h> -#ifdef _THREAD_SAFE -#include <pthread.h> -#include "pthread_private.h" - -int -sigaction(int sig, const struct sigaction * act, struct sigaction * oact) -{ - int ret = 0; - struct sigaction gact; - - /* Check if the signal number is out of range: */ - if (sig < 1 || sig > NSIG) { - /* Return an invalid argument: */ - errno = EINVAL; - ret = -1; - } else { - /* - * Check if the existing signal action structure contents are - * to be returned: - */ - if (oact != NULL) { - /* Return the existing signal action contents: */ - oact->sa_handler = _thread_sigact[sig - 1].sa_handler; - oact->sa_mask = _thread_sigact[sig - 1].sa_mask; - oact->sa_flags = _thread_sigact[sig - 1].sa_flags; - } - - /* Check if a signal action was supplied: */ - if (act != NULL) { - /* Set the new signal handler: */ - _thread_sigact[sig - 1].sa_mask = act->sa_mask; - _thread_sigact[sig - 1].sa_flags = act->sa_flags; - _thread_sigact[sig - 1].sa_handler = act->sa_handler; - } - - /* - * Check if the kernel needs to be advised of a change - * in signal action: - */ - if (act != NULL && sig != SIGVTALRM && sig != SIGCHLD && - sig != SIGINFO) { - /* Initialise the global signal action structure: */ - gact.sa_mask = act->sa_mask; - gact.sa_flags = 0; - - /* - * Check if the signal handler is being set to - * the default or ignore handlers: - */ - if (act->sa_handler == SIG_DFL || - act->sa_handler == SIG_IGN) - /* Specify the built in handler: */ - gact.sa_handler = act->sa_handler; - else - /* - * Specify the thread kernel signal - * handler: - */ - gact.sa_handler = (void (*) ()) _thread_sig_handler; - - /* Change the signal action in the kernel: */ - if (_thread_sys_sigaction(sig,&gact,NULL) != 0) - ret = -1; - } - } - - /* Return the completion status: */ - return (ret); -} -#endif diff --git a/lib/libkse/thread/thr_sigmask.c b/lib/libkse/thread/thr_sigmask.c deleted file mode 100644 index 23d6b7ff2a3e2..0000000000000 --- a/lib/libkse/thread/thr_sigmask.c +++ /dev/null @@ -1,89 +0,0 @@ -/* - * Copyright (c) 1997 John Birrell <jb@cimlogic.com.au>. - * 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 John Birrell. - * 4. Neither the name of the author nor the names of any co-contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY JOHN BIRRELL 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 <errno.h> -#include <signal.h> -#ifdef _THREAD_SAFE -#include <pthread.h> -#include "pthread_private.h" - -int -pthread_sigmask(int how, const sigset_t *set, sigset_t *oset) -{ - int ret = 0; - - /* Check if the existing signal process mask is to be returned: */ - if (oset != NULL) { - /* Return the current mask: */ - *oset = _thread_run->sigmask; - } - /* Check if a new signal set was provided by the caller: */ - if (set != NULL) { - /* Process according to what to do: */ - switch (how) { - /* Block signals: */ - case SIG_BLOCK: - /* Add signals to the existing mask: */ - _thread_run->sigmask |= *set; - break; - - /* Unblock signals: */ - case SIG_UNBLOCK: - /* Clear signals from the existing mask: */ - _thread_run->sigmask &= ~(*set); - break; - - /* Set the signal process mask: */ - case SIG_SETMASK: - /* Set the new mask: */ - _thread_run->sigmask = *set; - break; - - /* Trap invalid actions: */ - default: - /* Return an invalid argument: */ - errno = EINVAL; - ret = -1; - break; - } - - /* - * Dispatch signals to the running thread that are pending - * and now unblocked: - */ - _dispatch_signals(); - } - - /* Return the completion status: */ - return (ret); -} -#endif diff --git a/lib/libkse/thread/thr_sigprocmask.c b/lib/libkse/thread/thr_sigprocmask.c deleted file mode 100644 index 81b602f581c8a..0000000000000 --- a/lib/libkse/thread/thr_sigprocmask.c +++ /dev/null @@ -1,88 +0,0 @@ -/* - * Copyright (c) 1995 John Birrell <jb@cimlogic.com.au>. - * 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 John Birrell. - * 4. Neither the name of the author nor the names of any co-contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY JOHN BIRRELL 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 <signal.h> -#include <errno.h> -#ifdef _THREAD_SAFE -#include <pthread.h> -#include "pthread_private.h" - -int -sigprocmask(int how, const sigset_t * set, sigset_t * oset) -{ - int ret = 0; - - /* Check if the existing signal process mask is to be returned: */ - if (oset != NULL) { - /* Return the current mask: */ - *oset = _thread_run->sigmask; - } - /* Check if a new signal set was provided by the caller: */ - if (set != NULL) { - /* Process according to what to do: */ - switch (how) { - /* Block signals: */ - case SIG_BLOCK: - /* Add signals to the existing mask: */ - _thread_run->sigmask |= *set; - break; - - /* Unblock signals: */ - case SIG_UNBLOCK: - /* Clear signals from the existing mask: */ - _thread_run->sigmask &= ~(*set); - break; - - /* Set the signal process mask: */ - case SIG_SETMASK: - /* Set the new mask: */ - _thread_run->sigmask = *set; - break; - - /* Trap invalid actions: */ - default: - /* Return an invalid argument: */ - errno = EINVAL; - ret = -1; - break; - } - - /* - * Dispatch signals to the running thread that are pending - * and now unblocked: - */ - _dispatch_signals(); - } - /* Return the completion status: */ - return (ret); -} -#endif diff --git a/lib/libkse/thread/thr_sigsuspend.c b/lib/libkse/thread/thr_sigsuspend.c deleted file mode 100644 index 0ae9a4f7b3efe..0000000000000 --- a/lib/libkse/thread/thr_sigsuspend.c +++ /dev/null @@ -1,69 +0,0 @@ -/* - * Copyright (c) 1995 John Birrell <jb@cimlogic.com.au>. - * 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 John Birrell. - * 4. Neither the name of the author nor the names of any co-contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY JOHN BIRRELL 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 <signal.h> -#include <errno.h> -#ifdef _THREAD_SAFE -#include <pthread.h> -#include "pthread_private.h" - -int -sigsuspend(const sigset_t * set) -{ - int ret = -1; - sigset_t oset; - - /* Check if a new signal set was provided by the caller: */ - if (set != NULL) { - /* Save the current signal mask: */ - oset = _thread_run->sigmask; - - /* Change the caller's mask: */ - _thread_run->sigmask = *set; - - /* Wait for a signal: */ - _thread_kern_sched_state(PS_SIGSUSPEND, __FILE__, __LINE__); - - /* Always return an interrupted error: */ - errno = EINTR; - - /* Restore the signal mask: */ - _thread_run->sigmask = oset; - } else { - /* Return an invalid argument error: */ - errno = EINVAL; - } - - /* Return the completion status: */ - return (ret); -} -#endif diff --git a/lib/libkse/thread/thr_sigwait.c b/lib/libkse/thread/thr_sigwait.c deleted file mode 100644 index 590f9db463159..0000000000000 --- a/lib/libkse/thread/thr_sigwait.c +++ /dev/null @@ -1,132 +0,0 @@ -/* - * Copyright (c) 1997 John Birrell <jb@cimlogic.com.au>. - * 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 John Birrell. - * 4. Neither the name of the author nor the names of any co-contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY JOHN BIRRELL 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 <signal.h> -#include <errno.h> -#ifdef _THREAD_SAFE -#include <pthread.h> -#include "pthread_private.h" - -int -sigwait(const sigset_t * set, int *sig) -{ - int ret = 0; - int i; - sigset_t tempset; - struct sigaction act; - - /* - * Specify the thread kernel signal handler. - */ - act.sa_handler = (void (*) ()) _thread_sig_handler; - act.sa_flags = SA_RESTART; - act.sa_mask = *set; - - /* - * These signals can't be waited on. - */ - sigdelset(&act.sa_mask, SIGKILL); - sigdelset(&act.sa_mask, SIGSTOP); - sigdelset(&act.sa_mask, SIGVTALRM); - sigdelset(&act.sa_mask, SIGCHLD); - sigdelset(&act.sa_mask, SIGINFO); - - /* Check to see if a pending signal is in the wait mask. */ - if (tempset = (_thread_run->sigpend & act.sa_mask)) { - /* Enter a loop to find a pending signal: */ - for (i = 1; i < NSIG; i++) { - if (sigismember (&tempset, i)) - break; - } - - /* Clear the pending signal: */ - sigdelset(&_thread_run->sigpend,i); - - /* Return the signal number to the caller: */ - *sig = i; - - return (0); - } - - /* - * Enter a loop to find the signals that are SIG_DFL. For - * these signals we must install a dummy signal handler in - * order for the kernel to pass them in to us. POSIX says - * that the application must explicitly install a dummy - * handler for signals that are SIG_IGN in order to sigwait - * on them. Note that SIG_IGN signals are left in the - * mask because a subsequent sigaction could enable an - * ignored signal. - */ - for (i = 1; i < NSIG; i++) { - if (sigismember(&act.sa_mask, i)) { - if (_thread_sigact[i - 1].sa_handler == SIG_DFL) - if (_thread_sys_sigaction(i,&act,NULL) != 0) - ret = -1; - } - } - if (ret == 0) { - - /* - * Save the wait signal mask. The wait signal - * mask is independent of the threads signal mask - * and requires separate storage. - */ - _thread_run->data.sigwait = &act.sa_mask; - - /* Wait for a signal: */ - _thread_kern_sched_state(PS_SIGWAIT, __FILE__, __LINE__); - - /* Return the signal number to the caller: */ - *sig = _thread_run->signo; - - /* - * Probably unnecessary, but since it's in a union struct - * we don't know how it could be used in the future. - */ - _thread_run->data.sigwait = NULL; - } - - /* Restore the sigactions: */ - act.sa_handler = SIG_DFL; - for (i = 1; i < NSIG; i++) { - if (sigismember(&act.sa_mask, i) && - (_thread_sigact[i - 1].sa_handler == SIG_DFL)) { - if (_thread_sys_sigaction(i,&act,NULL) != 0) - ret = -1; - } - } - - /* Return the completion status: */ - return (ret); -} -#endif diff --git a/lib/libkse/thread/thr_single_np.c b/lib/libkse/thread/thr_single_np.c deleted file mode 100644 index e36c856c63763..0000000000000 --- a/lib/libkse/thread/thr_single_np.c +++ /dev/null @@ -1,44 +0,0 @@ -/* - * Copyright (c) 1996 John Birrell <jb@cimlogic.com.au>. - * 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 John Birrell. - * 4. Neither the name of the author nor the names of any co-contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY JOHN BIRRELL 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 <string.h> -#ifdef _THREAD_SAFE -#include <pthread.h> -#include "pthread_private.h" - -int pthread_single_np() -{ - /* Enter single-threaded (non-POSIX) scheduling mode: */ - _thread_single = _thread_run; - return(0); -} -#endif diff --git a/lib/libkse/thread/thr_spec.c b/lib/libkse/thread/thr_spec.c deleted file mode 100644 index 8558dff85980f..0000000000000 --- a/lib/libkse/thread/thr_spec.c +++ /dev/null @@ -1,199 +0,0 @@ -/* - * Copyright (c) 1995 John Birrell <jb@cimlogic.com.au>. - * 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 John Birrell. - * 4. Neither the name of the author nor the names of any co-contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY JOHN BIRRELL 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 <signal.h> -#include <stdlib.h> -#include <string.h> -#include <errno.h> -#ifdef _THREAD_SAFE -#include <pthread.h> -#include "pthread_private.h" - -/* Static variables: */ -static struct pthread_key key_table[PTHREAD_KEYS_MAX]; - -int -pthread_key_create(pthread_key_t * key, void (*destructor) (void *)) -{ - for ((*key) = 0; (*key) < PTHREAD_KEYS_MAX; (*key)++) { - /* Lock the key table entry: */ - _SPINLOCK(&key_table[*key].lock); - - if (key_table[(*key)].allocated == 0) { - key_table[(*key)].allocated = 1; - key_table[(*key)].destructor = destructor; - - /* Unlock the key table entry: */ - _SPINUNLOCK(&key_table[*key].lock); - return (0); - } - - /* Unlock the key table entry: */ - _SPINUNLOCK(&key_table[*key].lock); - } - return (EAGAIN); -} - -int -pthread_key_delete(pthread_key_t key) -{ - int ret = 0; - - if (key < PTHREAD_KEYS_MAX) { - /* Lock the key table entry: */ - _SPINLOCK(&key_table[key].lock); - - if (key_table[key].allocated) - key_table[key].allocated = 0; - else - ret = EINVAL; - - /* Unlock the key table entry: */ - _SPINUNLOCK(&key_table[key].lock); - } else - ret = EINVAL; - return (ret); -} - -void -_thread_cleanupspecific(void) -{ - void *data; - int key; - int itr; - void (*destructor)( void *); - - for (itr = 0; itr < PTHREAD_DESTRUCTOR_ITERATIONS; itr++) { - for (key = 0; key < PTHREAD_KEYS_MAX; key++) { - if (_thread_run->specific_data_count) { - /* Lock the key table entry: */ - _SPINLOCK(&key_table[key].lock); - destructor = NULL; - - if (key_table[key].allocated) { - if (_thread_run->specific_data[key]) { - data = (void *) _thread_run->specific_data[key]; - _thread_run->specific_data[key] = NULL; - _thread_run->specific_data_count--; - destructor = key_table[key].destructor; - } - } - - /* Unlock the key table entry: */ - _SPINUNLOCK(&key_table[key].lock); - - /* - * If there is a destructore, call it - * with the key table entry unlocked: - */ - if (destructor) - destructor(data); - } else { - free(_thread_run->specific_data); - _thread_run->specific_data = NULL; - return; - } - } - } - _thread_run->specific_data = NULL; - free(_thread_run->specific_data); -} - -static inline const void ** -pthread_key_allocate_data(void) -{ - const void **new_data; - if ((new_data = (const void **) malloc(sizeof(void *) * PTHREAD_KEYS_MAX)) != NULL) { - memset((void *) new_data, 0, sizeof(void *) * PTHREAD_KEYS_MAX); - } - return (new_data); -} - -int -pthread_setspecific(pthread_key_t key, const void *value) -{ - pthread_t pthread; - int ret = 0; - - /* Point to the running thread: */ - pthread = _thread_run; - - if ((pthread->specific_data) || - (pthread->specific_data = pthread_key_allocate_data())) { - if (key < PTHREAD_KEYS_MAX) { - if (key_table[key].allocated) { - if (pthread->specific_data[key] == NULL) { - if (value != NULL) - pthread->specific_data_count++; - } else { - if (value == NULL) - pthread->specific_data_count--; - } - pthread->specific_data[key] = value; - ret = 0; - } else - ret = EINVAL; - } else - ret = EINVAL; - } else - ret = ENOMEM; - return (ret); -} - -void * -pthread_getspecific(pthread_key_t key) -{ - pthread_t pthread; - void *data; - - /* Point to the running thread: */ - pthread = _thread_run; - - /* Check if there is specific data: */ - if (pthread->specific_data != NULL && key < PTHREAD_KEYS_MAX) { - /* Check if this key has been used before: */ - if (key_table[key].allocated) { - /* Return the value: */ - data = (void *) pthread->specific_data[key]; - } else { - /* - * This key has not been used before, so return NULL - * instead: - */ - data = NULL; - } - } else - /* No specific data has been created, so just return NULL: */ - data = NULL; - return (data); -} -#endif diff --git a/lib/libkse/thread/thr_spinlock.c b/lib/libkse/thread/thr_spinlock.c deleted file mode 100644 index 9da115e5eedb7..0000000000000 --- a/lib/libkse/thread/thr_spinlock.c +++ /dev/null @@ -1,108 +0,0 @@ -/* - * Copyright (c) 1997 John Birrell <jb@cimlogic.com.au>. - * 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 John Birrell. - * 4. Neither the name of the author nor the names of any co-contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY JOHN BIRRELL 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. - * - * $Id: uthread_spinlock.c,v 1.3 1998/06/06 07:27:06 jb Exp $ - * - */ - -#include <stdio.h> -#include <sched.h> -#include <unistd.h> -#include <pthread.h> -#include <string.h> -#include "pthread_private.h" - -extern char *__progname; - -/* - * Lock a location for the running thread. Yield to allow other - * threads to run if this thread is blocked because the lock is - * not available. Note that this function does not sleep. It - * assumes that the lock will be available very soon. - */ -void -_spinlock(spinlock_t *lck) -{ - /* - * Try to grab the lock and loop if another thread grabs - * it before we do. - */ - while(_atomic_lock(&lck->access_lock)) { - /* Give up the time slice: */ - sched_yield(); - - /* Check if already locked by the running thread: */ - if (lck->lock_owner == (long) _thread_run) - return; - } - - /* The running thread now owns the lock: */ - lck->lock_owner = (long) _thread_run; -} - -/* - * Lock a location for the running thread. Yield to allow other - * threads to run if this thread is blocked because the lock is - * not available. Note that this function does not sleep. It - * assumes that the lock will be available very soon. - * - * This function checks if the running thread has already locked the - * location, warns if this occurs and creates a thread dump before - * returning. - */ -void -_spinlock_debug(spinlock_t *lck, char *fname, int lineno) -{ - /* - * Try to grab the lock and loop if another thread grabs - * it before we do. - */ - while(_atomic_lock(&lck->access_lock)) { - /* Give up the time slice: */ - sched_yield(); - - /* Check if already locked by the running thread: */ - if (lck->lock_owner == (long) _thread_run) { - char str[256]; - snprintf(str, sizeof(str), "%s - Warning: Thread %p attempted to lock %p from %s (%d) which it had already locked in %s (%d)\n", __progname, _thread_run, lck, fname, lineno, lck->fname, lck->lineno); - _thread_sys_write(2,str,strlen(str)); - - /* Create a thread dump to help debug this problem: */ - _thread_dump_info(); - return; - } - } - - /* The running thread now owns the lock: */ - lck->lock_owner = (long) _thread_run; - lck->fname = fname; - lck->lineno = lineno; -} diff --git a/lib/libkse/thread/thr_suspend_np.c b/lib/libkse/thread/thr_suspend_np.c deleted file mode 100644 index 871683ad92aba..0000000000000 --- a/lib/libkse/thread/thr_suspend_np.c +++ /dev/null @@ -1,59 +0,0 @@ -/* - * Copyright (c) 1995-1998 John Birrell <jb@cimlogic.com.au>. - * 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 John Birrell. - * 4. Neither the name of the author nor the names of any co-contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY JOHN BIRRELL 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 <errno.h> -#ifdef _THREAD_SAFE -#include <pthread.h> -#include "pthread_private.h" - -/* Suspend a thread: */ -int -pthread_suspend_np(pthread_t thread) -{ - int ret; - - /* Find the thread in the list of active threads: */ - if ((ret = _find_thread(thread)) == 0) { - /* The thread exists. Is it running? */ - if (thread->state != PS_RUNNING && - thread->state != PS_SUSPENDED) { - /* The thread operation has been interrupted */ - _thread_seterrno(thread,EINTR); - thread->interrupted = 1; - } - - /* Suspend the thread. */ - PTHREAD_NEW_STATE(thread,PS_SUSPENDED); - } - return(ret); -} -#endif diff --git a/lib/libkse/thread/thr_vfork.c b/lib/libkse/thread/thr_vfork.c deleted file mode 100644 index bbfcf002bc02c..0000000000000 --- a/lib/libkse/thread/thr_vfork.c +++ /dev/null @@ -1,9 +0,0 @@ -#include <unistd.h> -#ifdef _THREAD_SAFE - -int -vfork(void) -{ - return (fork()); -} -#endif diff --git a/lib/libkse/thread/thr_wait4.c b/lib/libkse/thread/thr_wait4.c deleted file mode 100644 index dda8aeea61cb3..0000000000000 --- a/lib/libkse/thread/thr_wait4.c +++ /dev/null @@ -1,61 +0,0 @@ -/* - * Copyright (c) 1995-1998 John Birrell <jb@cimlogic.com.au> - * 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 John Birrell. - * 4. Neither the name of the author nor the names of any co-contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY JOHN BIRRELL 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 <errno.h> -#include <sys/wait.h> -#ifdef _THREAD_SAFE -#include <pthread.h> -#include "pthread_private.h" - -pid_t -wait4(pid_t pid, int *istat, int options, struct rusage * rusage) -{ - pid_t ret; - - /* Perform a non-blocking wait4 syscall: */ - while ((ret = _thread_sys_wait4(pid, istat, options | WNOHANG, rusage)) == 0 && (options & WNOHANG) == 0) { - /* Reset the interrupted operation flag: */ - _thread_run->interrupted = 0; - - /* Schedule the next thread while this one waits: */ - _thread_kern_sched_state(PS_WAIT_WAIT, __FILE__, __LINE__); - - /* Check if this call was interrupted by a signal: */ - if (_thread_run->interrupted) { - errno = EINTR; - ret = -1; - break; - } - } - return (ret); -} -#endif diff --git a/lib/libkse/thread/thr_write.c b/lib/libkse/thread/thr_write.c deleted file mode 100644 index 23cef52b6f2da..0000000000000 --- a/lib/libkse/thread/thr_write.c +++ /dev/null @@ -1,134 +0,0 @@ -/* - * Copyright (c) 1995-1998 John Birrell <jb@cimlogic.com.au> - * 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 John Birrell. - * 4. Neither the name of the author nor the names of any co-contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY JOHN BIRRELL 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. - * - * $Id: uthread_write.c,v 1.9 1998/06/14 09:36:11 jb Exp $ - * - */ -#include <sys/types.h> -#include <sys/fcntl.h> -#include <sys/uio.h> -#include <errno.h> -#include <unistd.h> -#ifdef _THREAD_SAFE -#include <pthread.h> -#include "pthread_private.h" - -ssize_t -write(int fd, const void *buf, size_t nbytes) -{ - int blocking; - int type; - ssize_t n; - ssize_t num = 0; - ssize_t ret; - - /* POSIX says to do just this: */ - if (nbytes == 0) - return (0); - - /* Lock the file descriptor for write: */ - if ((ret = _FD_LOCK(fd, FD_WRITE, NULL)) == 0) { - /* Get the read/write mode type: */ - type = _thread_fd_table[fd]->flags & O_ACCMODE; - - /* Check if the file is not open for write: */ - if (type != O_WRONLY && type != O_RDWR) { - /* File is not open for write: */ - errno = EBADF; - _FD_UNLOCK(fd, FD_WRITE); - return (-1); - } - - /* Check if file operations are to block */ - blocking = ((_thread_fd_table[fd]->flags & O_NONBLOCK) == 0); - - /* - * Loop while no error occurs and until the expected number - * of bytes are written if performing a blocking write: - */ - while (ret == 0) { - /* Perform a non-blocking write syscall: */ - n = _thread_sys_write(fd, buf + num, nbytes - num); - - /* Check if one or more bytes were written: */ - if (n > 0) - /* - * Keep a count of the number of bytes - * written: - */ - num += n; - - /* - * If performing a blocking write, check if the - * write would have blocked or if some bytes - * were written but there are still more to - * write: - */ - if (blocking && ((n < 0 && (errno == EWOULDBLOCK || - errno == EAGAIN)) || (n >= 0 && num < nbytes))) { - _thread_run->data.fd.fd = fd; - _thread_kern_set_timeout(NULL); - - /* Reset the interrupted operation flag: */ - _thread_run->interrupted = 0; - - _thread_kern_sched_state(PS_FDW_WAIT, - __FILE__, __LINE__); - - /* - * Check if the operation was - * interrupted by a signal - */ - if (_thread_run->interrupted) { - /* Return an error: */ - ret = -1; - } - - /* - * If performing a non-blocking write or if an - * error occurred, just return whatever the write - * syscall did: - */ - } else if (!blocking || n < 0) { - /* A non-blocking call might return zero: */ - ret = n; - break; - - /* Check if the write has completed: */ - } else if (num >= nbytes) - /* Return the number of bytes written: */ - ret = num; - } - _FD_UNLOCK(fd, FD_RDWR); - } - return (ret); -} -#endif diff --git a/lib/libkse/thread/thr_writev.c b/lib/libkse/thread/thr_writev.c deleted file mode 100644 index 81afcfd0e22c7..0000000000000 --- a/lib/libkse/thread/thr_writev.c +++ /dev/null @@ -1,191 +0,0 @@ -/* - * Copyright (c) 1995-1998 John Birrell <jb@cimlogic.com.au> - * 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 John Birrell. - * 4. Neither the name of the author nor the names of any co-contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY JOHN BIRRELL 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. - * - * $Id: uthread_writev.c,v 1.9 1998/06/10 22:28:45 jb Exp $ - * - */ -#include <sys/types.h> -#include <sys/fcntl.h> -#include <sys/uio.h> -#include <errno.h> -#include <stdlib.h> -#include <string.h> -#include <unistd.h> -#ifdef _THREAD_SAFE -#include <pthread.h> -#include "pthread_private.h" - -ssize_t -writev(int fd, const struct iovec * iov, int iovcnt) -{ - int blocking; - int idx = 0; - int type; - ssize_t cnt; - ssize_t n; - ssize_t num = 0; - ssize_t ret; - struct iovec liov[20]; - struct iovec *p_iov = liov; - - /* Check if the array size exceeds to compiled in size: */ - if (iovcnt > (sizeof(liov) / sizeof(struct iovec))) { - /* Allocate memory for the local array: */ - if ((p_iov = (struct iovec *) - malloc(iovcnt * sizeof(struct iovec))) == NULL) { - /* Insufficient memory: */ - errno = ENOMEM; - return (-1); - } - } - - /* Copy the caller's array so that it can be modified locally: */ - memcpy(p_iov,iov,iovcnt * sizeof(struct iovec)); - - /* Lock the file descriptor for write: */ - if ((ret = _FD_LOCK(fd, FD_WRITE, NULL)) == 0) { - /* Get the read/write mode type: */ - type = _thread_fd_table[fd]->flags & O_ACCMODE; - - /* Check if the file is not open for write: */ - if (type != O_WRONLY && type != O_RDWR) { - /* File is not open for write: */ - errno = EBADF; - _FD_UNLOCK(fd, FD_WRITE); - return (-1); - } - - /* Check if file operations are to block */ - blocking = ((_thread_fd_table[fd]->flags & O_NONBLOCK) == 0); - - /* - * Loop while no error occurs and until the expected number - * of bytes are written if performing a blocking write: - */ - while (ret == 0) { - /* Perform a non-blocking write syscall: */ - n = _thread_sys_writev(fd, &p_iov[idx], iovcnt - idx); - - /* Check if one or more bytes were written: */ - if (n > 0) { - /* - * Keep a count of the number of bytes - * written: - */ - num += n; - - /* - * Enter a loop to check if a short write - * occurred and move the index to the - * array entry where the short write - * ended: - */ - cnt = n; - while (cnt > 0 && idx < iovcnt) { - /* - * If the residual count exceeds - * the size of this vector, then - * it was completely written: - */ - if (cnt >= p_iov[idx].iov_len) - /* - * Decrement the residual - * count and increment the - * index to the next array - * entry: - */ - cnt -= p_iov[idx++].iov_len; - else { - /* - * This entry was only - * partially written, so - * adjust it's length - * and base pointer ready - * for the next write: - */ - p_iov[idx].iov_len -= cnt; - p_iov[idx].iov_base += cnt; - cnt = 0; - } - } - } - - /* - * If performing a blocking write, check if the - * write would have blocked or if some bytes - * were written but there are still more to - * write: - */ - if (blocking && ((n < 0 && (errno == EWOULDBLOCK || - errno == EAGAIN)) || (n >= 0 && idx < iovcnt))) { - _thread_run->data.fd.fd = fd; - _thread_kern_set_timeout(NULL); - - /* Reset the interrupted operation flag: */ - _thread_run->interrupted = 0; - - _thread_kern_sched_state(PS_FDW_WAIT, - __FILE__, __LINE__); - - /* - * Check if the operation was - * interrupted by a signal - */ - if (_thread_run->interrupted) { - /* Return an error: */ - ret = -1; - } - - /* - * If performing a non-blocking write or if an - * error occurred, just return whatever the write - * syscall did: - */ - } else if (!blocking || n < 0) { - /* A non-blocking call might return zero: */ - ret = n; - break; - - /* Check if the write has completed: */ - } else if (idx == iovcnt) - /* Return the number of bytes written: */ - ret = num; - } - _FD_UNLOCK(fd, FD_RDWR); - } - - /* If memory was allocated for the array, free it: */ - if (p_iov != liov) - free(p_iov); - - return (ret); -} -#endif diff --git a/lib/libkse/thread/thr_yield.c b/lib/libkse/thread/thr_yield.c deleted file mode 100644 index 877f5e6b0e856..0000000000000 --- a/lib/libkse/thread/thr_yield.c +++ /dev/null @@ -1,63 +0,0 @@ -/* - * Copyright (c) 1995 John Birrell <jb@cimlogic.com.au>. - * 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 John Birrell. - * 4. Neither the name of the author nor the names of any co-contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY JOHN BIRRELL 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. - * - */ -#ifdef _THREAD_SAFE -#include <pthread.h> -#include "pthread_private.h" - -int -sched_yield(void) -{ - /* Reset the accumulated time slice value for the current thread: */ - _thread_run->slice_usec = -1; - - /* Schedule the next thread: */ - _thread_kern_sched(NULL); - - /* Always return no error. */ - return(0); -} - -/* Draft 4 yield */ -void -pthread_yield(void) -{ - /* Reset the accumulated time slice value for the current thread: */ - _thread_run->slice_usec = -1; - - /* Schedule the next thread: */ - _thread_kern_sched(NULL); - - /* Nothing to return. */ - return; -} -#endif diff --git a/lib/libkvm/kvm.h b/lib/libkvm/kvm.h deleted file mode 100644 index 9e0d9212a444b..0000000000000 --- a/lib/libkvm/kvm.h +++ /dev/null @@ -1,82 +0,0 @@ -/*- - * Copyright (c) 1989, 1993 - * 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. - * - * @(#)kvm.h 8.1 (Berkeley) 6/2/93 - * $Id$ - */ - -#ifndef _KVM_H_ -#define _KVM_H_ - -/* Default version symbol. */ -#define VRS_SYM "_version" -#define VRS_KEY "VERSION" - -#include <nlist.h> -#include <sys/cdefs.h> - -#ifdef _BSD_SIZE_T_ -typedef _BSD_SIZE_T_ size_t; -#undef _BSD_SIZE_T_ -#endif - -#ifdef _BSD_SSIZE_T_ -typedef _BSD_SSIZE_T_ ssize_t; -#undef _BSD_SSIZE_T_ -#endif - -typedef struct __kvm kvm_t; - -struct kinfo_proc; -struct proc; - -__BEGIN_DECLS -int kvm_close __P((kvm_t *)); -char **kvm_getargv __P((kvm_t *, const struct kinfo_proc *, int)); -char **kvm_getenvv __P((kvm_t *, const struct kinfo_proc *, int)); -char *kvm_geterr __P((kvm_t *)); -int kvm_getloadavg __P((kvm_t *, double [], int)); -char *kvm_getfiles __P((kvm_t *, int, int, int *)); -struct kinfo_proc * - kvm_getprocs __P((kvm_t *, int, int, int *)); -int kvm_nlist __P((kvm_t *, struct nlist *)); -kvm_t *kvm_open - __P((const char *, const char *, const char *, int, const char *)); -kvm_t *kvm_openfiles - __P((const char *, const char *, const char *, int, char *)); -ssize_t kvm_read __P((kvm_t *, unsigned long, void *, size_t)); -ssize_t kvm_uread - __P((kvm_t *, const struct proc *, unsigned long, char *, size_t)); -ssize_t kvm_write __P((kvm_t *, unsigned long, const void *, size_t)); -__END_DECLS - -#endif /* !_KVM_H_ */ diff --git a/lib/libkvm/kvm_amd64.c b/lib/libkvm/kvm_amd64.c deleted file mode 100644 index d36b922584e32..0000000000000 --- a/lib/libkvm/kvm_amd64.c +++ /dev/null @@ -1,194 +0,0 @@ -/*- - * Copyright (c) 1989, 1992, 1993 - * The Regents of the University of California. All rights reserved. - * - * This code is derived from software developed by the Computer Systems - * Engineering group at Lawrence Berkeley Laboratory under DARPA contract - * BG 91-66 and contributed to Berkeley. - * - * 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. - */ - -#if defined(LIBC_SCCS) && !defined(lint) -static char sccsid[] = "@(#)kvm_hp300.c 8.1 (Berkeley) 6/4/93"; -#endif /* LIBC_SCCS and not lint */ - -/* - * i386 machine dependent routines for kvm. Hopefully, the forthcoming - * vm code will one day obsolete this module. - */ - -#include <sys/param.h> -#include <sys/user.h> -#include <sys/proc.h> -#include <sys/stat.h> -#include <stdlib.h> -#include <unistd.h> -#include <nlist.h> -#include <kvm.h> - -#include <vm/vm.h> -#include <vm/vm_param.h> - -#include <limits.h> -#include <db.h> - -#include "kvm_private.h" - -#ifndef btop -#define btop(x) (i386_btop(x)) -#define ptob(x) (i386_ptob(x)) -#endif - -struct vmstate { - pd_entry_t *PTD; -}; - -void -_kvm_freevtop(kvm_t *kd) -{ - if (kd->vmst != 0) { - if (kd->vmst->PTD) { - free(kd->vmst->PTD); - } - free(kd->vmst); - } -} - -int -_kvm_initvtop(kvm_t *kd) -{ - struct vmstate *vm; - struct nlist nlist[2]; - u_long pa; - pd_entry_t *PTD; - - vm = (struct vmstate *)_kvm_malloc(kd, sizeof(*vm)); - if (vm == 0) { - _kvm_err(kd, kd->program, "cannot allocate vm"); - return (-1); - } - kd->vmst = vm; - vm->PTD = 0; - - nlist[0].n_name = "_IdlePTD"; - nlist[1].n_name = 0; - - if (kvm_nlist(kd, nlist) != 0) { - _kvm_err(kd, kd->program, "bad namelist"); - return (-1); - } - if (kvm_read(kd, (nlist[0].n_value - KERNBASE), &pa, sizeof(pa)) != sizeof(pa)) { - _kvm_err(kd, kd->program, "cannot read IdlePTD"); - return (-1); - } - PTD = _kvm_malloc(kd, PAGE_SIZE); - if (kvm_read(kd, pa, PTD, PAGE_SIZE) != PAGE_SIZE) { - _kvm_err(kd, kd->program, "cannot read PTD"); - return (-1); - } - vm->PTD = PTD; - return (0); -} - -static int -_kvm_vatop(kvm_t *kd, u_long va, u_long *pa) -{ - struct vmstate *vm; - u_long offset; - u_long pte_pa; - pd_entry_t pde; - pt_entry_t pte; - u_long pdeindex; - u_long pteindex; - int i; - - if (ISALIVE(kd)) { - _kvm_err(kd, 0, "vatop called in live kernel!"); - return((off_t)0); - } - - vm = kd->vmst; - offset = va & (PAGE_SIZE - 1); - - /* - * If we are initializing (kernel page table descriptor pointer - * not yet set) then return pa == va to avoid infinite recursion. - */ - if (vm->PTD == 0) { - *pa = va; - return (PAGE_SIZE - offset); - } - - pdeindex = va >> PDRSHIFT; - pde = vm->PTD[pdeindex]; - if (((u_long)pde & PG_V) == 0) - goto invalid; - - if ((u_long)pde & PG_PS) { - /* - * No second-level page table; ptd describes one 4MB page. - * (We assume that the kernel wouldn't set PG_PS without enabling - * it cr0, and that the kernel doesn't support 36-bit physical - * addresses). - */ -#define PAGE4M_MASK (NBPDR - 1) -#define PG_FRAME4M (~PAGE4M_MASK) - *pa = ((u_long)pde & PG_FRAME4M) + (va & PAGE4M_MASK); - return (NBPDR - (va & PAGE4M_MASK)); - } - - pteindex = (va >> PAGE_SHIFT) & (NPTEPG-1); - pte_pa = ((u_long)pde & PG_FRAME) + (pteindex * sizeof(pt_entry_t)); - - /* XXX This has to be a physical address read, kvm_read is virtual */ - if (lseek(kd->pmfd, pte_pa, 0) == -1) { - _kvm_syserr(kd, kd->program, "_kvm_vatop: lseek"); - goto invalid; - } - if (read(kd->pmfd, &pte, sizeof pte) != sizeof pte) { - _kvm_syserr(kd, kd->program, "_kvm_vatop: read"); - goto invalid; - } - if (((u_long)pte & PG_V) == 0) - goto invalid; - - *pa = ((u_long)pte & PG_FRAME) + offset; - return (PAGE_SIZE - offset); - -invalid: - _kvm_err(kd, 0, "invalid address (%x)", va); - return (0); -} - -int -_kvm_kvatop(kvm_t *kd, u_long va, u_long *pa) -{ - return (_kvm_vatop(kd, va, pa)); -} diff --git a/lib/libopie/config.h b/lib/libopie/config.h deleted file mode 100644 index bf91b2e68e8d1..0000000000000 --- a/lib/libopie/config.h +++ /dev/null @@ -1,379 +0,0 @@ -/* config.h. Generated automatically by configure. */ -/* config.h.in. Generated automatically from configure.in by autoheader. */ - -/* Define if on AIX 3. - System headers sometimes define this. - We just want to avoid a redefinition error message. */ -#ifndef _ALL_SOURCE -/* #undef _ALL_SOURCE */ -#endif - -/* Define if using alloca.c. */ -/* #undef C_ALLOCA */ - -/* Define to empty if the keyword does not work. */ -/* #undef const */ - -/* Define to one of _getb67, GETB67, getb67 for Cray-2 and Cray-YMP systems. - This function is required for alloca.c support on those systems. */ -/* #undef CRAY_STACKSEG_END */ - -/* Define if you have alloca, as a function or macro. */ -#define HAVE_ALLOCA 1 - -/* Define if you have <alloca.h> and it should be used (not on Ultrix). */ -/* #undef HAVE_ALLOCA_H */ - -/* Define if you have <sys/wait.h> that is POSIX.1 compatible. */ -#define HAVE_SYS_WAIT_H 1 - -/* Define if on MINIX. */ -/* #undef _MINIX */ - -/* Define if the system does not provide POSIX.1 features except - with this defined. */ -/* #undef _POSIX_1_SOURCE */ - -/* Define if you need to in order for stat and other things to work. */ -/* #undef _POSIX_SOURCE */ - -/* Define as the return type of signal handlers (int or void). */ -#define RETSIGTYPE void - -/* If using the C implementation of alloca, define if you know the - direction of stack growth for your system; otherwise it will be - automatically deduced at run-time. - STACK_DIRECTION > 0 => grows toward higher addresses - STACK_DIRECTION < 0 => grows toward lower addresses - STACK_DIRECTION = 0 => direction of growth unknown - */ -/* #undef STACK_DIRECTION */ - -/* Define if you want the FTP daemon to support anonymous logins. */ -/* #undef DOANONYMOUS */ - -/* The default value of the PATH environment variable */ -#define DEFAULT_PATH "/usr/bin:/bin:/usr/sbin:/sbin:/usr/X11R6/bin" - -/* Defined if the file /etc/default/login exists - (and, presumably, should be looked at by login) */ -/* #undef HAVE_ETC_DEFAULT_LOGIN */ - -/* Defined to the name of a file that contains a list of files whose - permissions and ownerships should be changed on login. */ -/* #undef HAVE_LOGIN_PERMFILE */ - -/* Defined to the name of a file that contains a list of environment - values that should be set on login. */ -/* #undef HAVE_LOGIN_ENVFILE */ - -/* Defined if the file /etc/securetty exists - (and, presumably, should be looked at by login) */ -/* #undef HAVE_SECURETTY */ - -/* Defined if the file /etc/shadow exists - (and, presumably, should be looked at for shadow passwords) */ -/* #undef HAVE_ETC_SHADOW */ - -/* The path to the access file, if we're going to use it */ -/* #undef PATH_ACCESS_FILE */ - -/* The path to the mail spool, if we know it */ -#define PATH_MAIL "/var/mail" - -/* The path to the utmp file, if we know it */ -#define PATH_UTMP_AC "/var/run/utmp" - -/* The path to the wtmp file, if we know it */ -#define PATH_WTMP_AC "/var/log/wtmp" - -/* The path to the wtmpx file, if we know it */ -/* #undef PATH_WTMPX_AC */ - -/* Defined if the system's profile (/etc/profile) displays - the motd file */ -/* #undef HAVE_MOTD_IN_PROFILE */ - -/* Defined if the system's profile (/etc/profile) informs the - user of new mail */ -/* #undef HAVE_MAILCHECK_IN_PROFILE */ - -/* Define if you have a nonstandard gettimeofday() that takes one argument - instead of two. */ -/* #undef HAVE_ONE_ARG_GETTIMEOFDAY */ - -/* Define if the system has the getenv function */ -#define HAVE_GETENV 1 - -/* Define if the system has the setenv function */ -#define HAVE_SETENV 1 - -/* Define if the system has the /var/adm/sulog file */ -/* #undef HAVE_SULOG */ - -/* Define if the system has the unsetenv function */ -#define HAVE_UNSETENV 1 - -/* Define if the compiler can handle ANSI-style argument lists */ -#define HAVE_ANSIDECL 1 - -/* Define if the compiler can handle ANSI-style prototypes */ -#define HAVE_ANSIPROTO 1 - -/* Define if the system has an ANSI-style printf (returns int instead of char *) */ -#define HAVE_ANSISPRINTF 1 - -/* Define if the compiler can handle ANSI-style variable argument lists */ -#define HAVE_ANSISTDARG 1 - -/* Define if the compiler can handle void argument lists to functions */ -#define HAVE_VOIDARG 1 - -/* Define if the compiler can handle void return "values" from functions */ -#define HAVE_VOIDRET 1 - -/* Define if the compiler can handle void pointers to our liking */ -#define HAVE_VOIDPTR 1 - -/* Define if the /bin/ls command seems to support the -g flag */ -/* #undef HAVE_LS_G_FLAG */ - -/* Define if there is a ut_pid field in struct utmp */ -/* #undef HAVE_UT_PID */ - -/* Define if there is a ut_type field in struct utmp */ -/* #undef HAVE_UT_TYPE */ - -/* Define if there is a ut_name field in struct utmp */ -#define HAVE_UT_NAME 1 - -/* Define if there is a ut_host field in struct utmp */ -#define HAVE_UT_HOST 1 - -/* Define if the system has getutline() */ -/* #undef HAVE_GETUTLINE */ - -/* Defined if the system has SunOS C2 security shadow passwords */ -/* #undef HAVE_SUNOS_C2_SHADOW */ - -/* Defined if you want to disable utmp support */ -/* #undef DISABLE_UTMP */ - -/* Defined if you want to allow users to override the insecure checks */ -/* #undef INSECURE_OVERRIDE */ - -/* Defined to the default hash value, always defined */ -#define MDX 5 - -/* Defined if new-style prompts are to be used */ -#define NEW_PROMPTS 1 - -/* Defined to the path of the OPIE lock directory */ -#define OPIE_LOCK_DIR "/var/spool/opielocks" - -/* Defined if users are to be asked to re-type secret pass phrases */ -/* #undef RETYPE */ - -/* Defined if su should not switch to disabled accounts */ -/* #undef SU_STAR_CHECK */ - -/* Defined if user locking is to be used */ -#define USER_LOCKING 1 - -/* Define if you have the bcopy function. */ -/* #undef HAVE_BCOPY */ - -/* Define if you have the bzero function. */ -/* #undef HAVE_BZERO */ - -/* Define if you have the endspent function. */ -/* #undef HAVE_ENDSPENT */ - -/* Define if you have the fpurge function. */ -#define HAVE_FPURGE 1 - -/* Define if you have the getdtablesize function. */ -/* #undef HAVE_GETDTABLESIZE */ - -/* Define if you have the getgroups function. */ -#define HAVE_GETGROUPS 1 - -/* Define if you have the gethostname function. */ -/* #undef HAVE_GETHOSTNAME */ - -/* Define if you have the getspnam function. */ -/* #undef HAVE_GETSPNAM */ - -/* Define if you have the gettimeofday function. */ -#define HAVE_GETTIMEOFDAY 1 - -/* Define if you have the getttynam function. */ -#define HAVE_GETTTYNAM 1 - -/* Define if you have the getusershell function. */ -#define HAVE_GETUSERSHELL 1 - -/* Define if you have the getutxline function. */ -/* #undef HAVE_GETUTXLINE */ - -/* Define if you have the getwd function. */ -/* #undef HAVE_GETWD */ - -/* Define if you have the index function. */ -/* #undef HAVE_INDEX */ - -/* Define if you have the lstat function. */ -#define HAVE_LSTAT 1 - -/* Define if you have the on_exit function. */ -/* #undef HAVE_ON_EXIT */ - -/* Define if you have the pututxline function. */ -/* #undef HAVE_PUTUTXLINE */ - -/* Define if you have the rindex function. */ -/* #undef HAVE_RINDEX */ - -/* Define if you have the setgroups function. */ -#define HAVE_SETGROUPS 1 - -/* Define if you have the setlogin function. */ -#define HAVE_SETLOGIN 1 - -/* Define if you have the setpriority function. */ -#define HAVE_SETPRIORITY 1 - -/* Define if you have the setregid function. */ -/* #undef HAVE_SETREGID */ - -/* Define if you have the setresgid function. */ -/* #undef HAVE_SETRESGID */ - -/* Define if you have the setresuid function. */ -/* #undef HAVE_SETRESUID */ - -/* Define if you have the setreuid function. */ -/* #undef HAVE_SETREUID */ - -/* Define if you have the setvbuf function. */ -#define HAVE_SETVBUF 1 - -/* Define if you have the sigaddset function. */ -#define HAVE_SIGADDSET 1 - -/* Define if you have the sigblock function. */ -/* #undef HAVE_SIGBLOCK */ - -/* Define if you have the sigemptyset function. */ -#define HAVE_SIGEMPTYSET 1 - -/* Define if you have the sigsetmask function. */ -/* #undef HAVE_SIGSETMASK */ - -/* Define if you have the socket function. */ -#define HAVE_SOCKET 1 - -/* Define if you have the strerror function. */ -#define HAVE_STRERROR 1 - -/* Define if you have the strftime function. */ -#define HAVE_STRFTIME 1 - -/* Define if you have the strncasecmp function. */ -#define HAVE_STRNCASECMP 1 - -/* Define if you have the strstr function. */ -#define HAVE_STRSTR 1 - -/* Define if you have the ttyslot function. */ -#define HAVE_TTYSLOT 1 - -/* Define if you have the usleep function. */ -#define HAVE_USLEEP 1 - -/* Define if you have the <crypt.h> header file. */ -/* #undef HAVE_CRYPT_H */ - -/* Define if you have the <dirent.h> header file. */ -#define HAVE_DIRENT_H 1 - -/* Define if you have the <fcntl.h> header file. */ -#define HAVE_FCNTL_H 1 - -/* Define if you have the <lastlog.h> header file. */ -/* #undef HAVE_LASTLOG_H */ - -/* Define if you have the <limits.h> header file. */ -#define HAVE_LIMITS_H 1 - -/* Define if you have the <ndir.h> header file. */ -/* #undef HAVE_NDIR_H */ - -/* Define if you have the <paths.h> header file. */ -#define HAVE_PATHS_H 1 - -/* Define if you have the <pwd.h> header file. */ -#define HAVE_PWD_H 1 - -/* Define if you have the <shadow.h> header file. */ -/* #undef HAVE_SHADOW_H */ - -/* Define if you have the <signal.h> header file. */ -#define HAVE_SIGNAL_H 1 - -/* Define if you have the <stdlib.h> header file. */ -#define HAVE_STDLIB_H 1 - -/* Define if you have the <string.h> header file. */ -#define HAVE_STRING_H 1 - -/* Define if you have the <sys/dir.h> header file. */ -/* #undef HAVE_SYS_DIR_H */ - -/* Define if you have the <sys/file.h> header file. */ -#define HAVE_SYS_FILE_H 1 - -/* Define if you have the <sys/ioctl.h> header file. */ -#define HAVE_SYS_IOCTL_H 1 - -/* Define if you have the <sys/ndir.h> header file. */ -/* #undef HAVE_SYS_NDIR_H */ - -/* Define if you have the <sys/param.h> header file. */ -#define HAVE_SYS_PARAM_H 1 - -/* Define if you have the <sys/select.h> header file. */ -#define HAVE_SYS_SELECT_H 1 - -/* Define if you have the <sys/signal.h> header file. */ -#define HAVE_SYS_SIGNAL_H 1 - -/* Define if you have the <sys/time.h> header file. */ -#define HAVE_SYS_TIME_H 1 - -/* Define if you have the <sys/utsname.h> header file. */ -#define HAVE_SYS_UTSNAME_H 1 - -/* Define if you have the <syslog.h> header file. */ -#define HAVE_SYSLOG_H 1 - -/* Define if you have the <termios.h> header file. */ -#define HAVE_TERMIOS_H 1 - -/* Define if you have the <unistd.h> header file. */ -#define HAVE_UNISTD_H 1 - -/* Define if you have the <utmpx.h> header file. */ -/* #undef HAVE_UTMPX_H */ - -/* Define if you have the crypt library (-lcrypt). */ -#define HAVE_LIBCRYPT 1 - -/* Define if you have the nsl library (-lnsl). */ -/* #undef HAVE_LIBNSL */ - -/* Define if you have the posix library (-lposix). */ -/* #undef HAVE_LIBPOSIX */ - -/* Define if you have the socket library (-lsocket). */ -/* #undef HAVE_LIBSOCKET */ diff --git a/lib/libpam/libpam/security/pam_mod_misc.h b/lib/libpam/libpam/security/pam_mod_misc.h deleted file mode 100644 index 06f474d293a22..0000000000000 --- a/lib/libpam/libpam/security/pam_mod_misc.h +++ /dev/null @@ -1,48 +0,0 @@ -/*- - * Copyright 1998 Juniper Networks, Inc. - * 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. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR 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 AUTHOR 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. - * - * $FreeBSD$ - */ - -#ifndef PAM_MOD_MISC_H -#define PAM_MOD_MISC_H - -#include <sys/cdefs.h> - -/* Options */ -#define PAM_OPT_DEBUG 0x01 -#define PAM_OPT_NO_WARN 0x02 -#define PAM_OPT_USE_FIRST_PASS 0x04 -#define PAM_OPT_TRY_FIRST_PASS 0x08 -#define PAM_OPT_USE_MAPPED_PASS 0x10 -#define PAM_OPT_ECHO_PASS 0x20 - -__BEGIN_DECLS -int pam_get_pass(pam_handle_t *, const char **, const char *, int); -int pam_prompt(pam_handle_t *, int, const char *, char **); -int pam_std_option(int *, const char *); -__END_DECLS - -#endif diff --git a/lib/libpam/modules/pam_login_access/login.access.5 b/lib/libpam/modules/pam_login_access/login.access.5 deleted file mode 100644 index d8630966dd978..0000000000000 --- a/lib/libpam/modules/pam_login_access/login.access.5 +++ /dev/null @@ -1,51 +0,0 @@ -.\" this is comment -.Dd April 30, 1994 -.Dt LOGIN.ACCESS 5 -.Os FreeBSD 1.2 -.Sh NAME -.Nm login.access -.Nd login access control table -.Sh DESCRIPTION -The -.Nm -file specifies (user, host) combinations and/or (user, tty) -combinations for which a login will be either accepted or refused. -.Pp -When someone logs in, the -.Nm -is scanned for the first entry that -matches the (user, host) combination, or, in case of non-networked -logins, the first entry that matches the (user, tty) combination. The -permissions field of that table entry determines whether the login will -be accepted or refused. -.Pp -Each line of the login access control table has three fields separated by a -":" character: permission : users : origins -.Pp -The first field should be a "+" (access granted) or "-" (access denied) -character. The second field should be a list of one or more login names, -group names, or ALL (always matches). The third field should be a list -of one or more tty names (for non-networked logins), host names, domain -names (begin with "."), host addresses, internet network numbers (end -with "."), ALL (always matches) or LOCAL (matches any string that does -not contain a "." character). If you run NIS you can use @netgroupname -in host or user patterns. -.Pp -The EXCEPT operator makes it possible to write very compact rules. -.Pp -The group file is searched only when a name does not match that of the -logged-in user. Only groups are matched in which users are explicitly -listed: the program does not look at a user's primary group id value. -.Sh FILES -.Bl -tag -width /etc/login.access -compact -.It Pa /etc/login.access -The -.Nm -file resides in -.Pa /etc . -.El -.Sh SEE ALSO -.Xr login 1 , -.Xr pam 8 -.Sh AUTHORS -.An Guido van Rooij diff --git a/lib/libpam/modules/pam_login_access/login_access.c b/lib/libpam/modules/pam_login_access/login_access.c deleted file mode 100644 index cfb24d2e2e7a2..0000000000000 --- a/lib/libpam/modules/pam_login_access/login_access.c +++ /dev/null @@ -1,239 +0,0 @@ - /* - * This module implements a simple but effective form of login access - * control based on login names and on host (or domain) names, internet - * addresses (or network numbers), or on terminal line names in case of - * non-networked logins. Diagnostics are reported through syslog(3). - * - * Author: Wietse Venema, Eindhoven University of Technology, The Netherlands. - */ - -#ifdef LOGIN_ACCESS -#ifndef lint -static const char sccsid[] = "%Z% %M% %I% %E% %U%"; -#endif - -#include <stdio.h> -#include <syslog.h> -#include <ctype.h> -#include <sys/types.h> -#include <grp.h> -#include <errno.h> -#include <string.h> -#include <unistd.h> -#include <stdlib.h> - -#include "pathnames.h" - - /* Delimiters for fields and for lists of users, ttys or hosts. */ - -static char fs[] = ":"; /* field separator */ -static char sep[] = ", \t"; /* list-element separator */ - - /* Constants to be used in assignments only, not in comparisons... */ - -#define YES 1 -#define NO 0 - -static int list_match(); -static int user_match(); -static int from_match(); -static int string_match(); - -/* login_access - match username/group and host/tty with access control file */ - -int -login_access(user, from) -char *user; -char *from; -{ - FILE *fp; - char line[BUFSIZ]; - char *perm; /* becomes permission field */ - char *users; /* becomes list of login names */ - char *froms; /* becomes list of terminals or hosts */ - int match = NO; - int end; - int lineno = 0; /* for diagnostics */ - - /* - * Process the table one line at a time and stop at the first match. - * Blank lines and lines that begin with a '#' character are ignored. - * Non-comment lines are broken at the ':' character. All fields are - * mandatory. The first field should be a "+" or "-" character. A - * non-existing table means no access control. - */ - - if ((fp = fopen(_PATH_LOGACCESS, "r")) != NULL) { - while (!match && fgets(line, sizeof(line), fp)) { - lineno++; - if (line[end = strlen(line) - 1] != '\n') { - syslog(LOG_ERR, "%s: line %d: missing newline or line too long", - _PATH_LOGACCESS, lineno); - continue; - } - if (line[0] == '#') - continue; /* comment line */ - while (end > 0 && isspace(line[end - 1])) - end--; - line[end] = 0; /* strip trailing whitespace */ - if (line[0] == 0) /* skip blank lines */ - continue; - if (!(perm = strtok(line, fs)) - || !(users = strtok((char *) 0, fs)) - || !(froms = strtok((char *) 0, fs)) - || strtok((char *) 0, fs)) { - syslog(LOG_ERR, "%s: line %d: bad field count", _PATH_LOGACCESS, - lineno); - continue; - } - if (perm[0] != '+' && perm[0] != '-') { - syslog(LOG_ERR, "%s: line %d: bad first field", _PATH_LOGACCESS, - lineno); - continue; - } - match = (list_match(froms, from, from_match) - && list_match(users, user, user_match)); - } - (void) fclose(fp); - } else if (errno != ENOENT) { - syslog(LOG_ERR, "cannot open %s: %m", _PATH_LOGACCESS); - } - return (match == 0 || (line[0] == '+')); -} - -/* list_match - match an item against a list of tokens with exceptions */ - -static int list_match(list, item, match_fn) -char *list; -char *item; -int (*match_fn) (); -{ - char *tok; - int match = NO; - - /* - * Process tokens one at a time. We have exhausted all possible matches - * when we reach an "EXCEPT" token or the end of the list. If we do find - * a match, look for an "EXCEPT" list and recurse to determine whether - * the match is affected by any exceptions. - */ - - for (tok = strtok(list, sep); tok != 0; tok = strtok((char *) 0, sep)) { - if (strcasecmp(tok, "EXCEPT") == 0) /* EXCEPT: give up */ - break; - if ((match = (*match_fn)(tok, item)) != NULL) /* YES */ - break; - } - /* Process exceptions to matches. */ - - if (match != NO) { - while ((tok = strtok((char *) 0, sep)) && strcasecmp(tok, "EXCEPT")) - /* VOID */ ; - if (tok == 0 || list_match((char *) 0, item, match_fn) == NO) - return (match); - } - return (NO); -} - -/* netgroup_match - match group against machine or user */ - -static int netgroup_match(group, machine, user) -gid_t group; -char *machine; -char *user; -{ -#ifdef NIS - static char *mydomain = 0; - - if (mydomain == 0) - yp_get_default_domain(&mydomain); - return (innetgr(group, machine, user, mydomain)); -#else - syslog(LOG_ERR, "NIS netgroup support not configured"); - return 0; -#endif -} - -/* user_match - match a username against one token */ - -static int user_match(tok, string) -char *tok; -char *string; -{ - struct group *group; - int i; - - /* - * If a token has the magic value "ALL" the match always succeeds. - * Otherwise, return YES if the token fully matches the username, or if - * the token is a group that contains the username. - */ - - if (tok[0] == '@') { /* netgroup */ - return (netgroup_match(tok + 1, (char *) 0, string)); - } else if (string_match(tok, string)) { /* ALL or exact match */ - return (YES); - } else if ((group = getgrnam(tok)) != NULL) {/* try group membership */ - for (i = 0; group->gr_mem[i]; i++) - if (strcasecmp(string, group->gr_mem[i]) == 0) - return (YES); - } - return (NO); -} - -/* from_match - match a host or tty against a list of tokens */ - -static int from_match(tok, string) -char *tok; -char *string; -{ - int tok_len; - int str_len; - - /* - * If a token has the magic value "ALL" the match always succeeds. Return - * YES if the token fully matches the string. If the token is a domain - * name, return YES if it matches the last fields of the string. If the - * token has the magic value "LOCAL", return YES if the string does not - * contain a "." character. If the token is a network number, return YES - * if it matches the head of the string. - */ - - if (tok[0] == '@') { /* netgroup */ - return (netgroup_match(tok + 1, string, (char *) 0)); - } else if (string_match(tok, string)) { /* ALL or exact match */ - return (YES); - } else if (tok[0] == '.') { /* domain: match last fields */ - if ((str_len = strlen(string)) > (tok_len = strlen(tok)) - && strcasecmp(tok, string + str_len - tok_len) == 0) - return (YES); - } else if (strcasecmp(tok, "LOCAL") == 0) { /* local: no dots */ - if (strchr(string, '.') == 0) - return (YES); - } else if (tok[(tok_len = strlen(tok)) - 1] == '.' /* network */ - && strncmp(tok, string, tok_len) == 0) { - return (YES); - } - return (NO); -} - -/* string_match - match a string against one token */ - -static int string_match(tok, string) -char *tok; -char *string; -{ - - /* - * If the token has the magic value "ALL" the match always succeeds. - * Otherwise, return YES if the token fully matches the string. - */ - - if (strcasecmp(tok, "ALL") == 0) { /* all: always matches */ - return (YES); - } else if (strcasecmp(tok, string) == 0) { /* try exact match */ - return (YES); - } - return (NO); -} -#endif /* LOGIN_ACCES */ diff --git a/lib/libpthread/Makefile b/lib/libpthread/Makefile deleted file mode 100644 index 806cd10b5fa5a..0000000000000 --- a/lib/libpthread/Makefile +++ /dev/null @@ -1,39 +0,0 @@ -# $Id: Makefile,v 1.13 1998/06/14 11:25:44 peter Exp $ -# -# All library objects contain rcsid strings by default; they may be -# excluded as a space-saving measure. To produce a library that does -# not contain these strings, delete -DLIBC_RCS and -DSYSLIBC_RCS -# from CFLAGS below. To remove these strings from just the system call -# stubs, remove just -DSYSLIBC_RCS from CFLAGS. -LIB=c_r -SHLIB_MAJOR= 3 -SHLIB_MINOR= 0 -CFLAGS+=-DLIBC_RCS -DSYSLIBC_RCS -I${.CURDIR}/../libc/include -CFLAGS+=-DPTHREAD_KERNEL -D_THREAD_SAFE -DNOPOLL -I${.CURDIR}/uthread - -# Uncomment this if you want libc_r to contain debug information for -# thread locking. -# CFLAGS+=-D_LOCK_DEBUG - -AINC= -I${.CURDIR}/../libc/${MACHINE_ARCH} -I${.CURDIR}/uthread -PRECIOUSLIB= yes - -# -# This is a list of syscalls that are renamed as _thread_sys_{syscall} -# so that libc_r can provide replacement functions. -# -HIDDEN_SYSCALLS= accept.o bind.o close.o connect.o dup.o dup2.o \ - execve.o fchflags.o fchmod.o fchown.o fcntl.o \ - flock.o fpathconf.o fstat.o fstatfs.o fsync.o getdirentries.o \ - getpeername.o getsockname.o getsockopt.o ioctl.o listen.o \ - nanosleep.o nfssvc.o open.o poll.o read.o readv.o recvfrom.o \ - recvmsg.o sched_yield.o select.o sendmsg.o sendto.o \ - setsockopt.o shutdown.o sigaction.o sigaltstack.o \ - signanosleep.o socket.o socketpair.o wait4.o write.o writev.o - -.include "${.CURDIR}/../libc/Makefile.inc" -.include "${.CURDIR}/man/Makefile.inc" -.include "${.CURDIR}/uthread/Makefile.inc" -.include "${.CURDIR}/sys/Makefile.inc" - -.include <bsd.lib.mk> diff --git a/lib/libpthread/arch/alpha/alpha/_atomic_lock.S b/lib/libpthread/arch/alpha/alpha/_atomic_lock.S deleted file mode 100644 index 4a21fdf1abc41..0000000000000 --- a/lib/libpthread/arch/alpha/alpha/_atomic_lock.S +++ /dev/null @@ -1,45 +0,0 @@ -/* - * Copyright (c) 1998 John Birrell <jb@cimlogic.com.au>. - * All rights reserved. - * copyright Douglas Santry 1996 - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the above copyright is retained - * in the source form. - * - * THIS SOFTWARE IS PROVIDED BY Douglas Santry 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 Douglas Santry 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. - * - * $Id: _atomic_lock.S,v 1.1 1998/06/09 08:21:55 jb Exp $ - * - */ - -#include "SYS.h" - -/* - * Atomicly lock a location with an identifier provided the location - * is not currently locked. - * - * long _atomic_lock(long *); - * v0 will contain the return value (zero if lock obtained). - */ -LEAF(_atomic_lock,0) - LDGP(pv) - -0: ldq_l v0, 0(a0) /* read existing lock value */ - mov 1, t0 /* locked value to store */ - stq_c t0, 0(a0) /* attempt to store, status in t0 */ - beq t0, 1f /* branch foward to optimise prediction */ - mb /* sync with other processors */ - RET /* return with v0==0 if lock obtained */ -1: br 0b /* loop to try again */ -END(_atomic_lock) diff --git a/lib/libpthread/arch/i386/i386/_atomic_lock.S b/lib/libpthread/arch/i386/i386/_atomic_lock.S deleted file mode 100644 index e0ef0eb6244f5..0000000000000 --- a/lib/libpthread/arch/i386/i386/_atomic_lock.S +++ /dev/null @@ -1,45 +0,0 @@ -/* - * Copyright (c) 1995-1998 John Birrell <jb@cimlogic.com.au>. - * All rights reserved. - * copyright Douglas Santry 1996 - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the above copyright is retained - * in the source form. - * - * THIS SOFTWARE IS PROVIDED BY Douglas Santry 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 Douglas Santry 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. - * - * $Id: _atomic_lock.S,v 1.1 1998/04/29 09:36:03 jb Exp $ - * - */ - -#if defined(LIBC_RCS) && !defined(lint) - .text - .asciz "$Id: _atomic_lock.S,v 1.1 1998/04/29 09:36:03 jb Exp $" -#endif /* LIBC_RCS and not lint */ - -#include "DEFS.h" - -/* - * Atomicly lock a location with an identifier provided the location - * is not currently locked. - * - * long _atomic_lock(long *); - * eax will contain the return value (zero if lock obtained). - */ -ENTRY(_atomic_lock) - movl 4(%esp), %ecx - movl $1, %eax - xchg %eax, (%ecx) - ret - diff --git a/lib/libpthread/man/Makefile.inc b/lib/libpthread/man/Makefile.inc deleted file mode 100644 index f92f3df5230e0..0000000000000 --- a/lib/libpthread/man/Makefile.inc +++ /dev/null @@ -1,39 +0,0 @@ -# $Id: Makefile.inc,v 1.4 1998/07/31 09:09:19 phk Exp $ - -# POSIX thread man files - -.PATH: ${.CURDIR}/man - -MAN3+= pthread_cleanup_pop.3 \ - pthread_cleanup_push.3 \ - pthread_cond_broadcast.3 \ - pthread_cond_destroy.3 \ - pthread_cond_init.3 \ - pthread_cond_signal.3 \ - pthread_cond_timedwait.3 \ - pthread_cond_wait.3 \ - pthread_create.3 \ - pthread_detach.3 \ - pthread_equal.3 \ - pthread_exit.3 \ - pthread_getspecific.3 \ - pthread_join.3 \ - pthread_key_create.3 \ - pthread_key_delete.3 \ - pthread_mutex_destroy.3 \ - pthread_mutex_init.3 \ - pthread_mutex_lock.3 \ - pthread_mutex_trylock.3 \ - pthread_mutex_unlock.3 \ - pthread_once.3 \ - pthread_rwlock_destroy.3 \ - pthread_rwlock_init.3 \ - pthread_rwlock_rdlock.3 \ - pthread_rwlock_unlock.3 \ - pthread_rwlock_wrlock.3 \ - pthread_rwlockattr_destroy.3 \ - pthread_rwlockattr_getpshared.3 \ - pthread_rwlockattr_init.3 \ - pthread_rwlockattr_setpshared.3 \ - pthread_self.3 \ - pthread_setspecific.3 diff --git a/lib/libpthread/man/pthread_cleanup_pop.3 b/lib/libpthread/man/pthread_cleanup_pop.3 deleted file mode 100644 index eefe4f335ae75..0000000000000 --- a/lib/libpthread/man/pthread_cleanup_pop.3 +++ /dev/null @@ -1,60 +0,0 @@ -.\" Copyright (c) 1997 Brian Cully <shmit@kublai.com> -.\" 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. Neither the name of the author nor the names of any co-contributors -.\" may be used to endorse or promote products derived from this software -.\" without specific prior written permission. -.\" -.\" THIS SOFTWARE IS PROVIDED BY JOHN BIRRELL 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. -.\" -.Dd July 30, 1998 -.Dt PTHREAD_CLEANUP_POP 3 -.Os BSD 4 -.Sh NAME -.Nm pthread_cleanup_pop -.Nd call the first cleanup routine -.Sh SYNOPSIS -.Fd #include <pthread.h> -.Ft void -.Fn pthread_cleanup_pop "int execute" -.Sh DESCRIPTION -The -.Fn pthread_cleanup_pop -function pops the top cleanup routine off of the current threads cleanup -routine stack, and, if -.Fa execute -is non-zero, it will execute the function. If there is no cleanup routine -then -.Fn pthread_cleanup_pop -does nothing. -.Sh RETURN VALUES -.Fn pthread_cleanup_pop -does not return any value. -.Sh ERRORS -None -.Sh SEE ALSO -.Xr pthread_cleanup_push 3 , -.Xr pthread_exit 3 -.Sh STANDARDS -.Fn pthread_cleanup_pop -conforms to ISO/IEC 9945-1 ANSI/IEEE -.Pq Dq Tn POSIX -Std 1003.1 Second Edition 1996-07-12. diff --git a/lib/libpthread/man/pthread_cleanup_push.3 b/lib/libpthread/man/pthread_cleanup_push.3 deleted file mode 100644 index 9bb3f400b6462..0000000000000 --- a/lib/libpthread/man/pthread_cleanup_push.3 +++ /dev/null @@ -1,63 +0,0 @@ -.\" Copyright (c) 1997 Brian Cully <shmit@kublai.com> -.\" 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. Neither the name of the author nor the names of any co-contributors -.\" may be used to endorse or promote products derived from this software -.\" without specific prior written permission. -.\" -.\" THIS SOFTWARE IS PROVIDED BY JOHN BIRRELL 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. -.\" -.Dd July 30, 1998 -.Dt PTHREAD_CLEANUP_PUSH 3 -.Os BSD 4 -.Sh NAME -.Nm pthread_cleanup_push -.Nd add a cleanup function for thread exit -.Sh SYNOPSIS -.Fd #include <pthread.h> -.Ft void -.Fn pthread_cleanup_push "void (*cleanup_routine)(void *)" "void *arg" -.Sh DESCRIPTION -The -.Fn pthread_cleanup_push -function adds -.Fa cleanup_routine -to the top of the stack of cleanup handlers that -get called when the current thread exits. -.Pp -When -.Fn pthread_cleanup_push -is called, it is passed -.Fa arg -as its only argument. -.Sh RETURN VALUES -.Fn pthread_cleanup_push -does not return any value. -.Sh ERRORS -None -.Sh SEE ALSO -.Xr pthread_cleanup_pop 3 , -.Xr pthread_exit 3 -.Sh STANDARDS -.Fn pthread_cleanup_push -conforms to ISO/IEC 9945-1 ANSI/IEEE -.Pq Dq Tn POSIX -Std 1003.1 Second Edition 1996-07-12. diff --git a/lib/libpthread/man/pthread_cond_broadcast.3 b/lib/libpthread/man/pthread_cond_broadcast.3 deleted file mode 100644 index 3b39287046db6..0000000000000 --- a/lib/libpthread/man/pthread_cond_broadcast.3 +++ /dev/null @@ -1,68 +0,0 @@ -.\" Copyright (c) 1997 Brian Cully <shmit@kublai.com> -.\" 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. Neither the name of the author nor the names of any co-contributors -.\" may be used to endorse or promote products derived from this software -.\" without specific prior written permission. -.\" -.\" THIS SOFTWARE IS PROVIDED BY JOHN BIRRELL 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. -.\" -.Dd July 28, 1998 -.Dt PTHREAD_COND_BROADCAST 3 -.Os BSD 4 -.Sh NAME -.Nm pthread_cond_broadcast -.Nd unblock all threads waiting for a condition variable -.Sh SYNOPSIS -.Fd #include <pthread.h> -.Ft int -.Fn pthread_cond_broadcast "pthread_cond_t *cond" -.Sh DESCRIPTION -The -.Fn pthread_cond_broadcast -function unblocks all threads waiting for the condition variable -.Fa cond . -.Sh RETURN VALUES -If successful, the -.Fn pthread_cond_broadcast -function will return zero, otherwise an error number will be returned -to indicate the error. -.Sh ERRORS -.Fn pthread_cond_broadcast -will fail if: -.Bl -tag -width Er -.It Bq Er EINVAL -The value specified by -.Fa cond -is invalid. -.El -.Pp -.Sh SEE ALSO -.Xr pthread_cond_destroy 3 , -.Xr pthread_cond_init 3 , -.Xr pthread_cond_signal 3 , -.Xr pthread_cond_timedwait 3 , -.Xr pthread_cond_wait 3 -.Sh STANDARDS -.Fn pthread_cond_broadcast -conforms to ISO/IEC 9945-1 ANSI/IEEE -.Pq Dq Tn POSIX -Std 1003.1 Second Edition 1996-07-12. diff --git a/lib/libpthread/man/pthread_cond_destroy.3 b/lib/libpthread/man/pthread_cond_destroy.3 deleted file mode 100644 index 22921b49a5edb..0000000000000 --- a/lib/libpthread/man/pthread_cond_destroy.3 +++ /dev/null @@ -1,72 +0,0 @@ -.\" Copyright (c) 1997 Brian Cully <shmit@kublai.com> -.\" 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. Neither the name of the author nor the names of any co-contributors -.\" may be used to endorse or promote products derived from this software -.\" without specific prior written permission. -.\" -.\" THIS SOFTWARE IS PROVIDED BY JOHN BIRRELL 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. -.\" -.Dd July 28, 1998 -.Dt PTHREAD_COND_DESTROY 3 -.Os BSD 4 -.Sh NAME -.Nm pthread_cond_destroy -.Nd destroy a condition variable -.Sh SYNOPSIS -.Fd #include <pthread.h> -.Ft int -.Fn pthread_cond_destroy "pthread_cond_t *cond" -.Sh DESCRIPTION -The -.Fn pthread_cond_destroy -function frees the resources allocated by the condition variable -.Fa cond . -.Sh RETURN VALUES -If successful, the -.Fn pthread_cond_init -function will return zero, otherwise an error number will be returned -to indicate the error. -.Sh ERRORS -.Fn pthread_cond_destroy -will fail if: -.Bl -tag -width Er -.It Bq Er EINVAL -The value specified by -.Fa cond -is invalid. -.It Bq Er EBUSY -The variable -.Fa cond -is locked by another thread. -.El -.Pp -.Sh SEE ALSO -.Xr pthread_cond_broadcast 3 , -.Xr pthread_cond_init 3 , -.Xr pthread_cond_signal 3 , -.Xr pthread_cond_timedwait 3 , -.Xr pthread_cond_wait 3 -.Sh STANDARDS -.Fn pthread_cond_destroy -conforms to ISO/IEC 9945-1 ANSI/IEEE -.Pq Dq Tn POSIX -Std 1003.1 Second Edition 1996-07-12. diff --git a/lib/libpthread/man/pthread_cond_init.3 b/lib/libpthread/man/pthread_cond_init.3 deleted file mode 100644 index 00f669d51befc..0000000000000 --- a/lib/libpthread/man/pthread_cond_init.3 +++ /dev/null @@ -1,77 +0,0 @@ -.\" Copyright (c) 1997 Brian Cully <shmit@kublai.com> -.\" 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. Neither the name of the author nor the names of any co-contributors -.\" may be used to endorse or promote products derived from this software -.\" without specific prior written permission. -.\" -.\" THIS SOFTWARE IS PROVIDED BY JOHN BIRRELL 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. -.\" -.Dd July 28, 1998 -.Dt PTHREAD_COND_INIT 3 -.Os BSD 4 -.Sh NAME -.Nm pthread_cond_init -.Nd create a condition variable -.Sh SYNOPSIS -.Fd #include <pthread.h> -.Ft int -.Fn pthread_cond_init "pthread_cond_t *cond" "const pthread_condattr_t *attr" -.Sh DESCRIPTION -The -.Fn pthread_cond_init -function creates a new condition variable, with attributes specified with -.Fa attr . -If -.Fa attr -is NULL the default attributes are used. -.Sh RETURN VALUES -If successful, the -.Fn pthread_cond_init -function will return zero and put the new condition variable id into -.Fa cond , -otherwise an error number will be returned to indicate the error. -.Sh ERRORS -.Fn pthread_cond_init -will fail if: -.Bl -tag -width Er -.It Bq Er EINVAL -The value specified by -.Fa attr -is invalid. -.It Bq Er ENOMEM -The process cannot allocate enough memory to create another condition -variable. -.It Bq Er EAGAIN -The temporarily lacks the resources to create another condition variable. -.El -.Pp -.Sh SEE ALSO -.Xr pthread_cond_broadcast 3 , -.Xr pthread_cond_destroy 3 , -.Xr pthread_cond_signal 3 , -.Xr pthread_cond_timedwait 3 , -.Xr pthread_cond_wait 3 -.Sh STANDARDS -.Fn pthread_cond_init -conforms to ISO/IEC 9945-1 ANSI/IEEE -.Pq Dq Tn POSIX -Std 1003.1 Second Edition 1996-07-12. diff --git a/lib/libpthread/man/pthread_cond_signal.3 b/lib/libpthread/man/pthread_cond_signal.3 deleted file mode 100644 index 679e46fb2ed2d..0000000000000 --- a/lib/libpthread/man/pthread_cond_signal.3 +++ /dev/null @@ -1,68 +0,0 @@ -.\" Copyright (c) 1997 Brian Cully <shmit@kublai.com> -.\" 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. Neither the name of the author nor the names of any co-contributors -.\" may be used to endorse or promote products derived from this software -.\" without specific prior written permission. -.\" -.\" THIS SOFTWARE IS PROVIDED BY JOHN BIRRELL 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. -.\" -.Dd July 28, 1998 -.Dt PTHREAD_COND_SIGNAL 3 -.Os BSD 4 -.Sh NAME -.Nm pthread_cond_signal -.Nd unblock a thread waiting for a condition variable -.Sh SYNOPSIS -.Fd #include <pthread.h> -.Ft int -.Fn pthread_cond_signal "pthread_cond_t *cond" -.Sh DESCRIPTION -The -.Fn pthread_cond_signal -function unblocks one thread waiting for the condition variable -.Fa cond . -.Sh RETURN VALUES -If successful, the -.Fn pthread_cond_signal -function will return zero, otherwise an error number will be returned -to indicate the error. -.Sh ERRORS -.Fn pthread_cond_signal -will fail if: -.Bl -tag -width Er -.It Bq Er EINVAL -The value specified by -.Fa cond -is invalid. -.El -.Pp -.Sh SEE ALSO -.Xr pthread_cond_broadcast 3 , -.Xr pthread_cond_destroy 3 , -.Xr pthread_cond_init 3 , -.Xr pthread_cond_timedwait 3 , -.Xr pthread_cond_wait 3 -.Sh STANDARDS -.Fn pthread_cond_signal -conforms to ISO/IEC 9945-1 ANSI/IEEE -.Pq Dq Tn POSIX -Std 1003.1 Second Edition 1996-07-12. diff --git a/lib/libpthread/man/pthread_cond_timedwait.3 b/lib/libpthread/man/pthread_cond_timedwait.3 deleted file mode 100644 index ab0184a7c5844..0000000000000 --- a/lib/libpthread/man/pthread_cond_timedwait.3 +++ /dev/null @@ -1,85 +0,0 @@ -.\" Copyright (c) 1997 Brian Cully <shmit@kublai.com> -.\" 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. Neither the name of the author nor the names of any co-contributors -.\" may be used to endorse or promote products derived from this software -.\" without specific prior written permission. -.\" -.\" THIS SOFTWARE IS PROVIDED BY JOHN BIRRELL 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. -.\" -.Dd July 28, 1998 -.Dt PTHREAD_COND_TIMEDWAIT 3 -.Os BSD 4 -.Sh NAME -.Nm pthread_cond_timedwait -.Nd wait on a condition variable for a specific amount of time -.Sh SYNOPSIS -.Fd #include <pthread.h> -.Ft int -.Fn pthread_cond_timedwait "pthread_cond_t *cond" "pthread_mutex_t *mutex" "const struct timespec *abstime" -.Sh DESCRIPTION -The -.Fn pthread_cond_timedwait -function atomically blocks the current thread waiting on the condition -variable specified by -.Fa cond , -and unblocks the mutex specified by -.Fa mutex . -The waiting thread unblocks only after another thread calls -.Xr pthread_cond_signal 3 , -or -.Xr pthread_cond_broadcast 3 -with the same condition variable, or if the system time reaches the -time specified in -.Fa abstime , -and the current thread reaquires the lock on -.Fa mutex . -.Sh RETURN VALUES -If successful, the -.Fn pthread_cond_timedwait -function will return zero. Otherwise an error number will be returned to -indicate the error. -.Sh ERRORS -.Fn pthread_cond_timedwait -will fail if: -.Bl -tag -width Er -.It Bq Er EINVAL -The value specified by -.Fa cond -or the value specified by -.Fa attr -is invalid. -.It Bq Er ETIMEDOUT -The system time has reached or exceeded the time specified in -.Fa abstime . -.El -.Pp -.Sh SEE ALSO -.Xr pthread_cond_broadcast 3 , -.Xr pthread_cond_destroy 3 , -.Xr pthread_cond_init 3 , -.Xr pthread_cond_signal 3 , -.Xr pthread_cond_wait 3 -.Sh STANDARDS -.Fn pthread_cond_timedwait -conforms to ISO/IEC 9945-1 ANSI/IEEE -.Pq Dq Tn POSIX -Std 1003.1 Second Edition 1996-07-12. diff --git a/lib/libpthread/man/pthread_cond_wait.3 b/lib/libpthread/man/pthread_cond_wait.3 deleted file mode 100644 index 7f70b591f037c..0000000000000 --- a/lib/libpthread/man/pthread_cond_wait.3 +++ /dev/null @@ -1,79 +0,0 @@ -.\" Copyright (c) 1997 Brian Cully <shmit@kublai.com> -.\" 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. Neither the name of the author nor the names of any co-contributors -.\" may be used to endorse or promote products derived from this software -.\" without specific prior written permission. -.\" -.\" THIS SOFTWARE IS PROVIDED BY JOHN BIRRELL 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. -.\" -.Dd July 28, 1998 -.Dt PTHREAD_COND_WAIT 3 -.Os BSD 4 -.Sh NAME -.Nm pthread_cond_wait -.Nd wait on a condition variable -.Sh SYNOPSIS -.Fd #include <pthread.h> -.Ft int -.Fn pthread_cond_wait "pthread_cond_t *cond" "pthread_mutex_t *mutex" -.Sh DESCRIPTION -The -.Fn pthread_cond_wait -function atomically blocks the current thread waiting on the condition -variable specified by -.Fa cond , -and unblocks the mutex specified by -.Fa mutex . -The waiting thread unblocks only after another thread calls -.Xr pthread_cond_signal 3 , or -.Xr pthread_cond_broadcast 3 -with the same condition variable, and the current thread reaquires the lock -on -.Fa mutex . -.Sh RETURN VALUES -If successful, the -.Fn pthread_cond_wait -function will return zero. Otherwise an error number will be returned to -indicate the error. -.Sh ERRORS -.Fn pthread_cond_wait -will fail if: -.Bl -tag -width Er -.It Bq Er EINVAL -The value specified by -.Fa cond -or the value specified by -.Fa attr -is invalid. -.El -.Pp -.Sh SEE ALSO -.Xr pthread_cond_broadcast 3 , -.Xr pthread_cond_destroy 3 , -.Xr pthread_cond_init 3 , -.Xr pthread_cond_signal 3 , -.Xr pthread_cond_timedwait 3 -.Sh STANDARDS -.Fn pthread_cond_wait -conforms to ISO/IEC 9945-1 ANSI/IEEE -.Pq Dq Tn POSIX -Std 1003.1 Second Edition 1996-07-12. diff --git a/lib/libpthread/man/pthread_create.3 b/lib/libpthread/man/pthread_create.3 deleted file mode 100644 index 6966b56398aa9..0000000000000 --- a/lib/libpthread/man/pthread_create.3 +++ /dev/null @@ -1,112 +0,0 @@ -.\" Copyright (c) 1996 John Birrell <jb@cimlogic.com.au>. -.\" 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 John Birrell. -.\" 4. Neither the name of the author nor the names of any co-contributors -.\" may be used to endorse or promote products derived from this software -.\" without specific prior written permission. -.\" -.\" THIS SOFTWARE IS PROVIDED BY JOHN BIRRELL 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. -.\" -.Dd April 4, 1996 -.Dt PTHREAD_CREATE 3 -.Os BSD 4 -.Sh NAME -.Nm pthread_create -.Nd create a new thread -.Sh SYNOPSIS -.Fd #include <pthread.h> -.Ft int -.Fn pthread_create "pthread_t *thread" "const pthread_attr_t *attr" "void *(*start_routine)(void *)" "void *arg" -.Sh DESCRIPTION -The -.Fn pthread_create -function is used to create a new thread, with attributes specified by -.Fa attr , -within a process. If -.Fa attr -is NULL, the default attributes are used. If the attributes specified by -.Fa attr -are modified later, the thread's attributes are not affected. Upon -successful completion -.Fn pthread_create -will store the ID of the created thread in the location specified by -.Fa thread . -.Pp -The thread is created executing -.Fa start_routine -with -.Fa arg -as its sole argument. If the -.Fa start_routine -returns, the effect is as if there was an implicit call to -.Fn pthread_exit -using the return value of -.Fa start_routine -as the exit status. Note that the thread in which -.Fn main -was originally invoked differs from this. When it returns from -.Fn main , -the effect is as if there was an implicit call to -.Fn exit -using the return value of -.Fn main -as the exit status. -.Pp -The signal state of the new thread is initialized as: -.Bl -bullet -offset indent -.It -The signal mask is inherited from the creating thread. -.It -The set of signals pending for the new thread is empty. -.El -.Sh RETURN VALUES -If successful, the -.Fn pthread_create -function will return zero. Otherwise an error number will be returned to -indicate the error. -.Sh ERRORS -.Fn pthread_create -will fail if: -.Bl -tag -width Er -.It Bq Er EAGAIN -The system lacked the necessary resources to create another thread, or -the system-imposed limit on the total number of threads in a process -[PTHREAD_THREADS_MAX] would be exceeded. -.It Bq Er EINVAL -The value specified by -.Fa attr -is invalid. -.El -.Pp -.Sh SEE ALSO -.Xr fork 2 , -.Xr pthread_cleanup_pop 3 , -.Xr pthread_cleanup_push 3 , -.Xr pthread_exit 3 , -.Xr pthread_join 3 -.Sh STANDARDS -.Fn pthread_create -conforms to ISO/IEC 9945-1 ANSI/IEEE -.Pq Dq Tn POSIX -Std 1003.1 Second Edition 1996-07-12. diff --git a/lib/libpthread/man/pthread_detach.3 b/lib/libpthread/man/pthread_detach.3 deleted file mode 100644 index a7f0490ae0d3d..0000000000000 --- a/lib/libpthread/man/pthread_detach.3 +++ /dev/null @@ -1,81 +0,0 @@ -.\" Copyright (c) 1996-1998 John Birrell <jb@cimlogic.com.au>. -.\" 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 John Birrell. -.\" 4. Neither the name of the author nor the names of any co-contributors -.\" may be used to endorse or promote products derived from this software -.\" without specific prior written permission. -.\" -.\" THIS SOFTWARE IS PROVIDED BY JOHN BIRRELL 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. -.\" -.Dd April 4, 1996 -.Dt PTHREAD_DETACH 3 -.Os BSD 4 -.Sh NAME -.Nm pthread_detach -.Nd detach a thread -.Sh SYNOPSIS -.Fd #include <pthread.h> -.Ft int -.Fn pthread_detach "pthread_t thread" -.Sh DESCRIPTION -The -.Fn pthread_detach -function is used to indicate to the implementation that storage for the -thread -.Fa thread -can be reclaimed when the thread terminates. If -.Fa thread -has not terminated, -.Fn pthread_detach -will not cause it to terminate. The effect of multiple -.Fn pthread_detach -calls on the same target thread is unspecified. -.Sh RETURN VALUES -If successful, the -.Fn pthread_detach -function will return zero. Otherwise an error number will be returned to -indicate the error. Note that the function does not change the value -of errno as it did for some drafts of the standard. These early drafts -also passed a pointer to pthread_t as the argument. Beware! -.Sh ERRORS -.Fn pthread_detach -will fail if: -.Bl -tag -width Er -.It Bq Er EINVAL -The implementation has detected that the value specified by -.Fa thread -does not refer to a joinable thread. -.It Bq Er ESRCH -No thread could be found corresponding to that specified by the given -thread ID, -.Fa thread . -.El -.Pp -.Sh SEE ALSO -.Xr pthread_join 3 -.Sh STANDARDS -.Fn pthread_detach -conforms to ISO/IEC 9945-1 ANSI/IEEE -.Pq Dq Tn POSIX -Std 1003.1 Second Edition 1996-07-12. diff --git a/lib/libpthread/man/pthread_equal.3 b/lib/libpthread/man/pthread_equal.3 deleted file mode 100644 index 74a588279b9dc..0000000000000 --- a/lib/libpthread/man/pthread_equal.3 +++ /dev/null @@ -1,66 +0,0 @@ -.\" Copyright (c) 1996 John Birrell <jb@cimlogic.com.au>. -.\" 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 John Birrell. -.\" 4. Neither the name of the author nor the names of any co-contributors -.\" may be used to endorse or promote products derived from this software -.\" without specific prior written permission. -.\" -.\" THIS SOFTWARE IS PROVIDED BY JOHN BIRRELL 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. -.\" -.Dd April 4, 1996 -.Dt PTHREAD_EQUAL 3 -.Os BSD 4 -.Sh NAME -.Nm pthread_equal -.Nd compare thread IDs -.Sh SYNOPSIS -.Fd #include <pthread.h> -.Ft int -.Fn pthread_equal "pthread_t t1" "pthread_t t2" -.Sh DESCRIPTION -The -.Fn pthread_equal -function compares the thread IDs -.Fa t1 -and -.Fa t2 . -.Sh RETURN VALUES -The -.Fn pthread_equal -function will non-zero if the thread IDs -.Fa t1 -and -.Fa t2 -correspond to the same thread, otherwise it will return zero. -.Sh ERRORS -None. -.Pp -.Sh SEE ALSO -.Xr pthread_create 3 , -.Xr pthread_exit 3 -.Sh STANDARDS -.Fn pthread_equal -conforms to ISO/IEC 9945-1 ANSI/IEEE -.Pq Dq Tn POSIX -Std 1003.1 Second Edition 1996-07-12. diff --git a/lib/libpthread/man/pthread_exit.3 b/lib/libpthread/man/pthread_exit.3 deleted file mode 100644 index 0e0f1765ee851..0000000000000 --- a/lib/libpthread/man/pthread_exit.3 +++ /dev/null @@ -1,99 +0,0 @@ -.\" Copyright (c) 1996 John Birrell <jb@cimlogic.com.au>. -.\" 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 John Birrell. -.\" 4. Neither the name of the author nor the names of any co-contributors -.\" may be used to endorse or promote products derived from this software -.\" without specific prior written permission. -.\" -.\" THIS SOFTWARE IS PROVIDED BY JOHN BIRRELL 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. -.\" -.Dd April 4, 1996 -.Dt PTHREAD_EXIT 3 -.Os BSD 4 -.Sh NAME -.Nm pthread_exit -.Nd terminate the calling thread -.Sh SYNOPSIS -.Fd #include <pthread.h> -.Ft void -.Fn pthread_exit "void *value_ptr" -.Sh DESCRIPTION -The -.Fn pthread_exit -function terminates the calling thread and makes the value -.Fa value_ptr -available to any successful join with the terminating thread. Any -cancellation cleanup handlers that have been pushed and are not yet popped -are popped in the reverse order that they were pushed and then executed. -After all cancellation handlers have been executed, if the thread has any -thread-specific data, appropriate destructor functions are called in an -unspecified order. Thread termination does not release any application -visible process resources, including, but not limited to, mutexes and -file descriptors, nor does it perform any process level cleanup -actions, including, but not limited to, calling -.Fn atexit -routines that may exist. -.Pp -An implicit call to -.Fn pthread_exit -is made when a thread other than the thread in which -.Fn main -was first invoked returns from the start routine that was used to create -it. The function's return value serves as the thread's exit status. -.Pp -The behavior of -.Fn pthread_exit -is undefied if called from a cancellation handler or destructor function -that was invoked as the result of an implicit or explicit call to -.Fn pthread_exit . -.Pp -After a thread has terminated, the result of access to local (auto) -variables of the thread is undefined. Thus, references to local variables -of the exiting thread should not be used for the -.Fn pthread_exit -.Fa value_ptr -parameter value. -.Pp -The process will exit with an exit status of 0 after the last thread has -been terminated. The behavior is as if the implementation called -.Fn exit -with a zero argument at thread termination time. -.Pp -.Sh RETURN VALUES -The -.Fn pthread_exit -function cannot return to its caller. -.Sh ERRORS -None. -.Pp -.Sh SEE ALSO -.Xr _exit 2 , -.Xr exit 2 , -.Xr pthread_create 3 , -.Xr pthread_join 3 -.Sh STANDARDS -.Fn pthread_exit -conforms to ISO/IEC 9945-1 ANSI/IEEE -.Pq Dq Tn POSIX -Std 1003.1 Second Edition 1996-07-12. diff --git a/lib/libpthread/man/pthread_getspecific.3 b/lib/libpthread/man/pthread_getspecific.3 deleted file mode 100644 index b7875fbdb846d..0000000000000 --- a/lib/libpthread/man/pthread_getspecific.3 +++ /dev/null @@ -1,82 +0,0 @@ -.\" Copyright (c) 1996 John Birrell <jb@cimlogic.com.au>. -.\" 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 John Birrell. -.\" 4. Neither the name of the author nor the names of any co-contributors -.\" may be used to endorse or promote products derived from this software -.\" without specific prior written permission. -.\" -.\" THIS SOFTWARE IS PROVIDED BY JOHN BIRRELL 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. -.\" -.\" $Id: pthread_getspecific.3,v 1.4 1997/02/22 15:05:24 peter Exp $ -.\" -.Dd April 4, 1996 -.Dt PTHREAD_GETSPECIFIC 3 -.Os BSD 4 -.Sh NAME -.Nm pthread_getspecific -.Nd get a thread-specific data value -.Sh SYNOPSIS -.Fd #include <pthread.h> -.Ft void * -.Fn pthread_getspecific "pthread_key_t key" -.Sh DESCRIPTION -The -.Fn pthread_getspecific -function returns the value currently bound to the specified -.Fa key -on behalf of the calling thread. -.Pp -The effect of calling -.Fn pthread_getspecific -with a -.Fa key -value not obtained from -.Fn pthread_key_create -or after -.Fa key -has been deleted with -.Fn pthread_key_delete -is undefined. -.Pp -.Fn pthread_getspecific -may be called from a thread-specific data destructor function. -.Sh RETURN VALUES -The -.Fn pthread_getspecific -function will return the thread-specific data value associated with the given -.Fa key . -If no thread-specific data value is associated with -.Fa key , -then the value NULL is returned. -.Sh ERRORS -None. -.Sh SEE ALSO -.Xr pthread_key_create 3 , -.Xr pthread_key_delete 3 , -.Xr pthread_setspecific 3 -.Sh STANDARDS -.Fn pthread_getspecific -conforms to ISO/IEC 9945-1 ANSI/IEEE -.Pq Dq Tn POSIX -Std 1003.1 Second Edition 1996-07-12. diff --git a/lib/libpthread/man/pthread_join.3 b/lib/libpthread/man/pthread_join.3 deleted file mode 100644 index d7a28a1305358..0000000000000 --- a/lib/libpthread/man/pthread_join.3 +++ /dev/null @@ -1,100 +0,0 @@ -.\" Copyright (c) 1996-1998 John Birrell <jb@cimlogic.com.au>. -.\" 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 John Birrell. -.\" 4. Neither the name of the author nor the names of any co-contributors -.\" may be used to endorse or promote products derived from this software -.\" without specific prior written permission. -.\" -.\" THIS SOFTWARE IS PROVIDED BY JOHN BIRRELL 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. -.\" -.Dd April 4, 1996 -.Dt PTHREAD_JOIN 3 -.Os BSD 4 -.Sh NAME -.Nm pthread_join -.Nd wait for thread termination -.Sh SYNOPSIS -.Fd #include <pthread.h> -.Ft int -.Fn pthread_join "pthread_t thread" "void **value_ptr" -.Sh DESCRIPTION -The -.Fn pthread_join -function suspends execution of the calling thread until the target -.Fa thread -terminates unless the target -.Fa thread -has already terminated. -.Pp -On return from a successful -.Fn pthread_join -call with a non-NULL -.Fa value_ptr -argument, the value passed to -.Fn pthread_exit -by the terminating thread is stored in the location referenced by -.Fa value_ptr . -When a -.Fn pthread_join -returns successfully, the target thread has been terminated. The results -of multiple simultaneous calls to -.Fn pthread_join -specifying the same target thread are undefined. If the thread calling -.Fn pthread_join -is cancelled, then the target thread is not detached. -.Pp -A thread that has exited but remains unjoined counts against -[_POSIX_THREAD_THREADS_MAX]. -.Pp -.Sh RETURN VALUES -If successful, the -.Fn pthread_join -function will return zero. Otherwise an error number will be returned to -indicate the error. -.Sh ERRORS -.Fn pthread_join -will fail if: -.Bl -tag -width Er -.It Bq Er EINVAL -The implementation has detected that the value specified by -.Fa thread -does not refer to a joinable thread. -.It Bq Er ESRCH -No thread could be found corresponding to that specified by the given -thread ID, -.Fa thread . -.It Bq Er EDEADLK -A deadlock was detected or the value of -.Fa thread -specifies the calling thread. -.El -.Pp -.Sh SEE ALSO -.Xr wait 2 , -.Xr pthread_create 3 -.Sh STANDARDS -.Fn pthread_join -conforms to ISO/IEC 9945-1 ANSI/IEEE -.Pq Dq Tn POSIX -Std 1003.1 Second Edition 1996-07-12. diff --git a/lib/libpthread/man/pthread_key_create.3 b/lib/libpthread/man/pthread_key_create.3 deleted file mode 100644 index c7c15fd0cef7f..0000000000000 --- a/lib/libpthread/man/pthread_key_create.3 +++ /dev/null @@ -1,98 +0,0 @@ -.\" Copyright (c) 1996 John Birrell <jb@cimlogic.com.au>. -.\" 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 John Birrell. -.\" 4. Neither the name of the author nor the names of any co-contributors -.\" may be used to endorse or promote products derived from this software -.\" without specific prior written permission. -.\" -.\" THIS SOFTWARE IS PROVIDED BY JOHN BIRRELL 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. -.\" -.Dd April 4, 1996 -.Dt PTHREAD_KEY_CREATE 3 -.Os BSD 4 -.Sh NAME -.Nm pthread_key_create -.Nd thread-specific data key creation -.Sh SYNOPSIS -.Fd #include <pthread.h> -.Ft int -.Fn pthread_key_create "pthread_key_t *key" "void (*destructor)(void *)" -.Sh DESCRIPTION -The -.Fn pthread_key_create -function creates a thread-specific data key visible to all threads in the -process. Key values provided by -.Fn pthread_key_create -are opaque objects used to locate thread-specific data. Although the same -key value may be used by different threads, the values bound to the key -by -.Fn pthread_setspecific -are maintained on a per-thread basis and persist for the life of the calling -thread. -.Pp -Upon key creation, the value NULL is associated with the new key in all -active threads. Upon thread creation, the value NULL is associated with all -defined keys in the new thread. -.Pp -An optional destructor function may be associated with each key value. At -thread exit, if a key value has a non-NULL destructor pointer, and the -thread has a non-NULL value associated with the key, the function pointed -to is called with the current associated value as its sole argument. The -order of destructor calls is unspecified if more than one destructor exists -for a thread when it exits. -.Pp -If, after all the destructors have been called for all non-NULL values -with associated destructors, there are still some non-NULL values with -associated destructors, then the process is repeated. If, after at least -[PTHREAD_DESTRUCTOR_ITERATIONS] iterations of destructor calls for -outstanding non-NULL values, there are still some non-NULL values with -associated destructors, the implementation stops calling destructors. -.Sh RETURN VALUES -If successful, the -.Fn pthread_key_create -function will store the newly created key value at the location specified by -.Fa key -and returns zero. Otherwise an error number will be returned to indicate -the error. -.Sh ERRORS -.Fn pthread_key_create -will fail if: -.Bl -tag -width Er -.It Bq Er EAGAIN -The system lacked the necessary resources to create another thread-specific -data key, or the system-imposed limit on the total number of keys per process -[PTHREAD_KEYS_MAX] would be exceeded. -.It Bq Er ENOMEM -Insufficient memory exists to create the key. -.El -.Pp -.Sh SEE ALSO -.Xr pthread_getspecific 3 , -.Xr pthread_key_delete 3 , -.Xr pthread_setspecific 3 -.Sh STANDARDS -.Fn pthread_key_create -conforms to ISO/IEC 9945-1 ANSI/IEEE -.Pq Dq Tn POSIX -Std 1003.1 Second Edition 1996-07-12. diff --git a/lib/libpthread/man/pthread_key_delete.3 b/lib/libpthread/man/pthread_key_delete.3 deleted file mode 100644 index cf1ad12ae999e..0000000000000 --- a/lib/libpthread/man/pthread_key_delete.3 +++ /dev/null @@ -1,92 +0,0 @@ -.\" Copyright (c) 1996 John Birrell <jb@cimlogic.com.au>. -.\" 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 John Birrell. -.\" 4. Neither the name of the author nor the names of any co-contributors -.\" may be used to endorse or promote products derived from this software -.\" without specific prior written permission. -.\" -.\" THIS SOFTWARE IS PROVIDED BY JOHN BIRRELL 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. -.\" -.Dd April 4, 1996 -.Dt PTHREAD_KEY_DELETE 3 -.Os BSD 4 -.Sh NAME -.Nm pthread_key_delete -.Nd delete a thread-specific data key -.Sh SYNOPSIS -.Fd #include <pthread.h> -.Ft int -.Fn pthread_key_delete "pthread_key_t key" -.Sh DESCRIPTION -The -.Fn pthread_key_delete -function deletes a thread-specific data key previously returned by -.Fn pthread_key_create . -The thread-specific data values associated with -.Fa key -need not be NULL at the time that -.Fn pthread_key_delete -is called. It is the responsibility of the application to free any -application storage or perform any cleanup actions for data structures -related to the deleted key or associated thread-specific data in any threads; -this cleanup can be done either before or after -.Fn pthread_key_delete -is called. Any attempt to use -.Fa key -following the call to -.Fn pthread_key_delete -results in undefined behavior. -.Pp -The -.Fn pthread_key_delete -function is callable from within destructor functions. Destructor functions -are not invoked by -.Fn pthread_key_delete . -Any destructor function that may have been associated with -.Fa key -will no longer be called upon thread exit. -.Sh RETURN VALUES -If successful, the -.Fn pthread_key_delete -function will return zero. Otherwise an error number will be returned to -indicate the error. -.Sh ERRORS -.Fn pthread_key_delete -will fail if: -.Bl -tag -width Er -.It Bq Er EINVAL -The -.Fa key -value is invalid. -.El -.Pp -.Sh SEE ALSO -.Xr pthread_getspecific 3 , -.Xr pthread_key_create 3 , -.Xr pthread_setspecific 3 -.Sh STANDARDS -.Fn pthread_key_delete -conforms to ISO/IEC 9945-1 ANSI/IEEE -.Pq Dq Tn POSIX -Std 1003.1 Second Edition 1996-07-12. diff --git a/lib/libpthread/man/pthread_mutex_destroy.3 b/lib/libpthread/man/pthread_mutex_destroy.3 deleted file mode 100644 index e9fb9c11d0451..0000000000000 --- a/lib/libpthread/man/pthread_mutex_destroy.3 +++ /dev/null @@ -1,70 +0,0 @@ -.\" Copyright (c) 1997 Brian Cully <shmit@kublai.com> -.\" 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. Neither the name of the author nor the names of any co-contributors -.\" may be used to endorse or promote products derived from this software -.\" without specific prior written permission. -.\" -.\" THIS SOFTWARE IS PROVIDED BY JOHN BIRRELL 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. -.\" -.Dd July 29, 1998 -.Dt PTHREAD_MUTEX_DESTROY 3 -.Os BSD 4 -.Sh NAME -.Nm pthread_mutex_destroy -.Nd free resources allocated for a mutex -.Sh SYNOPSIS -.Fd #include <pthread.h> -.Ft int -.Fn pthread_mutex_destroy "pthread_mutex_t *mutex" -.Sh DESCRIPTION -The -.Fn pthread_mutex_destroy -function frees the resources allocated for -.Fa mutex . -.Sh RETURN VALUES -If successful, -.Fn pthread_mutex_destroy -will return zero, otherwise an error number will be returned to -indicate the error. -.Sh ERRORS -.Fn pthread_mutex_destroy -will fail if: -.Bl -tag -width Er -.It Bq Er EINVAL -The value specified by -.Fa mutex -is invalid. -.It Bq Er EBUSY -.Fa Mutex -is locked by another thread. -.El -.Pp -.Sh SEE ALSO -.Xr pthread_mutex_init 3 , -.Xr pthread_mutex_lock 3 , -.Xr pthread_mutex_trylock 3 , -.Xr pthread_mutex_unlock 3 -.Sh STANDARDS -.Fn pthread_mutex_destroy -conforms to ISO/IEC 9945-1 ANSI/IEEE -.Pq Dq Tn POSIX -Std 1003.1 Second Edition 1996-07-12. diff --git a/lib/libpthread/man/pthread_mutex_init.3 b/lib/libpthread/man/pthread_mutex_init.3 deleted file mode 100644 index d5292ff8e107c..0000000000000 --- a/lib/libpthread/man/pthread_mutex_init.3 +++ /dev/null @@ -1,75 +0,0 @@ -.\" Copyright (c) 1997 Brian Cully <shmit@kublai.com> -.\" 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. Neither the name of the author nor the names of any co-contributors -.\" may be used to endorse or promote products derived from this software -.\" without specific prior written permission. -.\" -.\" THIS SOFTWARE IS PROVIDED BY JOHN BIRRELL 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. -.\" -.Dd July 29, 1998 -.Dt PTHREAD_MUTEX_INIT 3 -.Os BSD 4 -.Sh NAME -.Nm pthread_mutex_init -.Nd create a mutex -.Sh SYNOPSIS -.Fd #include <pthread.h> -.Ft int -.Fn pthread_mutex_init "pthread_mutex_t *mutex" "const pthread_mutexattr_t *attr" -.Sh DESCRIPTION -The -.Fn pthread_mutex_init -function creates a new mutex, with attributes specified with -.Fa attr . -If -.Fa attr -is NULL the default attributes are used. -.Sh RETURN VALUES -If successful, -.Fn pthread_mutex_init -will return zero and put the new mutex id into -.Fa mutex , -otherwise an error number will be returned to indicate the error. -.Sh ERRORS -.Fn pthread_mutex_init -will fail if: -.Bl -tag -width Er -.It Bq Er EINVAL -The value specified by -.Fa attr -is invalid. -.It Bq Er ENOMEM -The process cannot allocate enough memory to create another mutex. -.It Bq Er EAGAIN -The temporarily lacks the resources to create another mutex. -.El -.Pp -.Sh SEE ALSO -.Xr pthread_mutex_destroy 3 , -.Xr pthread_mutex_lock 3 , -.Xr pthread_mutex_trylock 3 , -.Xr pthread_mutex_unlock 3 -.Sh STANDARDS -.Fn pthread_mutex_init -conforms to ISO/IEC 9945-1 ANSI/IEEE -.Pq Dq Tn POSIX -Std 1003.1 Second Edition 1996-07-12. diff --git a/lib/libpthread/man/pthread_mutex_lock.3 b/lib/libpthread/man/pthread_mutex_lock.3 deleted file mode 100644 index a0aa07d76d6c5..0000000000000 --- a/lib/libpthread/man/pthread_mutex_lock.3 +++ /dev/null @@ -1,72 +0,0 @@ -.\" Copyright (c) 1997 Brian Cully <shmit@kublai.com> -.\" 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. Neither the name of the author nor the names of any co-contributors -.\" may be used to endorse or promote products derived from this software -.\" without specific prior written permission. -.\" -.\" THIS SOFTWARE IS PROVIDED BY JOHN BIRRELL 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. -.\" -.Dd July 30, 1998 -.Dt PTHREAD_MUTEX_LOCK 3 -.Os BSD 4 -.Sh NAME -.Nm pthread_mutex_lock -.Nd lock a mutex -.Sh SYNOPSIS -.Fd #include <pthread.h> -.Ft int -.Fn pthread_mutex_lock "pthread_mutex_t *mutex" -.Sh DESCRIPTION -The -.Fn pthread_mutex_lock -function locks -.Fa mutex . -If the mutex is already locked, the calling thread will block until the -mutex becomes available. -.Sh RETURN VALUES -If successful, -.Fn pthread_mutex_lock -will return zero, otherwise an error number will be returned to -indicate the error. -.Sh ERRORS -.Fn pthread_mutex_lock -will fail if: -.Bl -tag -width Er -.It Bq Er EINVAL -The value specified by -.Fa mutex -is invalid. -.It Bq Er EDEADLK -A deadlock would occur if the thread blocked waiting for -.Fa mutex . -.El -.Pp -.Sh SEE ALSO -.Xr pthread_mutex_destroy 3 , -.Xr pthread_mutex_init 3 , -.Xr pthread_mutex_trylock 3 , -.Xr pthread_mutex_unlock 3 -.Sh STANDARDS -.Fn pthread_mutex_lock -conforms to ISO/IEC 9945-1 ANSI/IEEE -.Pq Dq Tn POSIX -Std 1003.1 Second Edition 1996-07-12. diff --git a/lib/libpthread/man/pthread_mutex_trylock.3 b/lib/libpthread/man/pthread_mutex_trylock.3 deleted file mode 100644 index 9f283801e549c..0000000000000 --- a/lib/libpthread/man/pthread_mutex_trylock.3 +++ /dev/null @@ -1,73 +0,0 @@ -.\" Copyright (c) 1997 Brian Cully <shmit@kublai.com> -.\" 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. Neither the name of the author nor the names of any co-contributors -.\" may be used to endorse or promote products derived from this software -.\" without specific prior written permission. -.\" -.\" THIS SOFTWARE IS PROVIDED BY JOHN BIRRELL 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. -.\" -.Dd July 30, 1998 -.Dt PTHREAD_MUTEX_TRYLOCK 3 -.Os BSD 4 -.Sh NAME -.Nm pthread_mutex_trylock -.Nd attempt to lock a mutex without blocking -.Sh SYNOPSIS -.Fd #include <pthread.h> -.Ft int -.Fn pthread_mutex_trylock "pthread_mutex_t *mutex" -.Sh DESCRIPTION -The -.Fn pthread_mutex_trylock -function locks -.Fa mutex . -If the mutex is already locked, -.Fn pthread_mutex_trylock -will not block waiting for the mutex, but will return an error condition. -.Sh RETURN VALUES -If successful, -.Fn pthread_mutex_trylock -will return zero, otherwise an error number will be returned to -indicate the error. -.Sh ERRORS -.Fn pthread_mutex_trylock -will fail if: -.Bl -tag -width Er -.It Bq Er EINVAL -The value specified by -.Fa mutex -is invalid. -.It Bq Er EBUSY -.Fa Mutex -is already locked. -.El -.Pp -.Sh SEE ALSO -.Xr pthread_mutex_destroy 3 , -.Xr pthread_mutex_init 3 , -.Xr pthread_mutex_lock 3 , -.Xr pthread_mutex_unlock 3 -.Sh STANDARDS -.Fn pthread_mutex_trylock -conforms to ISO/IEC 9945-1 ANSI/IEEE -.Pq Dq Tn POSIX -Std 1003.1 Second Edition 1996-07-12. diff --git a/lib/libpthread/man/pthread_mutex_unlock.3 b/lib/libpthread/man/pthread_mutex_unlock.3 deleted file mode 100644 index 95ba7e6851100..0000000000000 --- a/lib/libpthread/man/pthread_mutex_unlock.3 +++ /dev/null @@ -1,72 +0,0 @@ -.\" Copyright (c) 1997 Brian Cully <shmit@kublai.com> -.\" 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. Neither the name of the author nor the names of any co-contributors -.\" may be used to endorse or promote products derived from this software -.\" without specific prior written permission. -.\" -.\" THIS SOFTWARE IS PROVIDED BY JOHN BIRRELL 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. -.\" -.Dd July 30, 1998 -.Dt PTHREAD_MUTEX_UNLOCK 3 -.Os BSD 4 -.Sh NAME -.Nm pthread_mutex_unlock -.Nd unlock a mutex -.Sh SYNOPSIS -.Fd #include <pthread.h> -.Ft int -.Fn pthread_mutex_unlock "pthread_mutex_t *mutex" -.Sh DESCRIPTION -If the current thread holds the lock on -.Fa mutex , -then the -.Fn pthread_mutex_unlock -function unlocks -.Fa mutex . -.Sh RETURN VALUES -If successful, -.Fn pthread_mutex_unlock -will return zero, otherwise an error number will be returned to -indicate the error. -.Sh ERRORS -.Fn pthread_mutex_trylock -will fail if: -.Bl -tag -width Er -.It Bq Er EINVAL -The value specified by -.Fa mutex -is invalid. -.It Bq Er EPERM -The current thread does not hold a lock on -.Fa mutex . -.El -.Pp -.Sh SEE ALSO -.Xr pthread_mutex_destroy 3 , -.Xr pthread_mutex_init 3 , -.Xr pthread_mutex_lock 3 , -.Xr pthread_mutex_trylock 3 -.Sh STANDARDS -.Fn pthread_mutex_unlock -conforms to ISO/IEC 9945-1 ANSI/IEEE -.Pq Dq Tn POSIX -Std 1003.1 Second Edition 1996-07-12. diff --git a/lib/libpthread/man/pthread_once.3 b/lib/libpthread/man/pthread_once.3 deleted file mode 100644 index fc50d56bf25a7..0000000000000 --- a/lib/libpthread/man/pthread_once.3 +++ /dev/null @@ -1,100 +0,0 @@ -.\" Copyright (c) 1996 John Birrell <jb@cimlogic.com.au>. -.\" 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 John Birrell. -.\" 4. Neither the name of the author nor the names of any co-contributors -.\" may be used to endorse or promote products derived from this software -.\" without specific prior written permission. -.\" -.\" THIS SOFTWARE IS PROVIDED BY JOHN BIRRELL 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. -.\" -.Dd April 4, 1996 -.Dt PTHREAD_ONCE 3 -.Os BSD 4 -.Sh NAME -.Nm pthread_once -.Nd dynamic package initialization -.Sh SYNOPSIS -.Fd #include <pthread.h> -.Pp -pthread_once -.Fa once_control -= PTHREAD_ONCE_INIT; -.Ft int -.Fn pthread_once "pthread_once_t *once_control" "void (*init_routine)(void)" -.Sh DESCRIPTION -The first call to -.Fn pthread_once -by any thread in a process, with a given -.Fa once_control , -will call the -.Fn init_routine -with no arguments. Subsequent calls to -.Fn pthread_once -with the same -.Fa once_control -will not call the -.Fn init_routine . -On return from -.Fn pthread_once , -it is guaranteed that -.Fn init_routine -has completed. The -.Fa once_control -parameter is used to determine whether the associated initialization -routine has been called. -.Pp -The function -.Fn pthread_once -is not a cancellation point. However, if -.Fn init_routine -is a cancellation point and is cancelled, the effect on -.Fa once_control is as if -.Fn pthread_once -was never called. -.Pp -The constant -.Fa PTHREAD_ONCE_INIT -is defined by header -.Aq Pa pthread.h . -.Pp -The behavior of -.Fn pthread_once -is undefined if -.Fa once_control -has automatic storage duration or is not initialized by -.Fa PTHREAD_ONCE_INIT . -.Pp -.Sh RETURN VALUES -If successful, the -.Fn pthread_once -function will return zero. Otherwise an error number will be returned to -indicate the error. -.Sh ERRORS -None. -.Pp -.Sh STANDARDS -.Fn pthread_once -conforms to ISO/IEC 9945-1 ANSI/IEEE -.Pq Dq Tn POSIX -Std 1003.1 Second Edition 1996-07-12. diff --git a/lib/libpthread/man/pthread_rwlock_destroy.3 b/lib/libpthread/man/pthread_rwlock_destroy.3 deleted file mode 100644 index 74532745dd744..0000000000000 --- a/lib/libpthread/man/pthread_rwlock_destroy.3 +++ /dev/null @@ -1,80 +0,0 @@ -.\" Copyright (c) 1998 Alex Nash -.\" 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. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR 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 AUTHOR 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. -.\" -.\" $Id$ -.\" -.Dd August 4, 1998 -.Dt PTHREAD_RWLOCK_DESTROY 3 -.Os -.Sh NAME -.Nm pthread_rwlock_destroy -.Nd destroy a read/write lock -.Sh SYNOPSIS -.Fd #include <pthread.h> -.Ft int -.Fn pthread_rwlock_destroy "pthread_rwlock_t *lock" -.Sh DESCRIPTION -The -.Fn pthread_rwlock_destroy -function is used to destroy a read/write lock previously created with -.Fn pthread_rwlock_init . -.Sh RETURN VALUES -If successful, the -.Fn pthread_rwlock_destroy -function will return zero. Otherwise an error number will be returned -to indicate the error. -.Sh SEE ALSO -.Xr pthread_rwlock_init 3 , -.Sh STANDARDS -The -.Fn pthread_rwlock_destroy -function is expected to conform to -.St -susv2 . -.Sh ERRORS -The -.Fn pthread_rwlock_destroy -function will fail if: -.Bl -tag -width Er -.It Bq Er EPERM -The caller does not have the privilege to perform the operation. -.El -.Pp -The -.Fn pthread_rwlock_destroy -function may fail if: -.Bl -tag -width Er -.It Bq Er EBUSY -The system has detected an attempt to destroy the object referenced by -.Fa lock -while it is locked. -.It Bq Er EINVAL -The value specified by -.Fa lock -is invalid. -.El -.Sh HISTORY -The -.Fn pthread_rwlock_destroy -function first appeared in -.Fx 3.0 . diff --git a/lib/libpthread/man/pthread_rwlock_init.3 b/lib/libpthread/man/pthread_rwlock_init.3 deleted file mode 100644 index a56169507b482..0000000000000 --- a/lib/libpthread/man/pthread_rwlock_init.3 +++ /dev/null @@ -1,99 +0,0 @@ -.\" Copyright (c) 1998 Alex Nash -.\" 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. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR 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 AUTHOR 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. -.\" -.\" $Id$ -.\" -.Dd August 4, 1998 -.Dt PTHREAD_RWLOCK_INIT 3 -.Os -.Sh NAME -.Nm pthread_rwlock_init -.Nd initialize a read/write lock -.Sh SYNOPSIS -.Fd #include <pthread.h> -.Ft int -.Fn pthread_rwlock_init "pthread_rwlock_t *lock" "const pthread_rwlockattr_t *attr" -.Sh DESCRIPTION -The -.Fn pthread_rwlock_init -function is used to initialize a read/write lock, with attributes -specified by -.Fa attr . -If -.Fa attr -is NULL, the default read/write lock attributes are used. -.Pp -The results of calling -.Fn pthread_rwlock_init -with an already initialized lock are undefined. -.Sh RETURN VALUES -If successful, the -.Fn pthread_rwlock_init -function will return zero. Otherwise an error number will be returned -to indicate the error. -.Sh SEE ALSO -.Xr pthread_rwlock_destroy 3 , -.Xr pthread_rwlockattr_init 3 , -.Xr pthread_rwlockattr_setpshared 3 -.Sh STANDARDS -The -.Fn pthread_rwlock_init -function is expected to conform to -.St -susv2 . -.Sh ERRORS -The -.Fn pthread_rwlock_init -function will fail if: -.Bl -tag -width Er -.It Bq Er EAGAIN -The system lacked the necessary resources (other than memory) to -initialize the lock. -.It Bq Er ENOMEM -Insufficient memory exists to initialize the lock. -.It Bq Er EPERM -The caller does not have sufficient privilege to perform the -operation. -.El -.Pp -The -.Fn pthread_rwlock_init -function may fail if: -.Bl -tag -width Er -.It Bq Er EBUSY -The system has detected an attempt to re-initialize the object -referenced by -.Fa lock , -a previously initialized but not yet destroyed read/write lock. -.It Bq Er EINVAL -The value specified by -.Fa attr -is invalid. -.El -.Sh HISTORY -The -.Fn pthread_rwlock_init -function first appeared in -.Fx 3.0 . -.Sh BUGS -The PTHREAD_PROCESS_SHARED attribute is not supported. diff --git a/lib/libpthread/man/pthread_rwlock_rdlock.3 b/lib/libpthread/man/pthread_rwlock_rdlock.3 deleted file mode 100644 index 9181be96cd5dc..0000000000000 --- a/lib/libpthread/man/pthread_rwlock_rdlock.3 +++ /dev/null @@ -1,122 +0,0 @@ -.\" Copyright (c) 1998 Alex Nash -.\" 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. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR 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 AUTHOR 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. -.\" -.\" $Id$ -.\" -.Dd August 4, 1998 -.Dt PTHREAD_RWLOCK_RDLOCK 3 -.Os -.Sh NAME -.Nm pthread_rwlock_rdlock , -.Nm pthread_rwlock_tryrdlock -.Nd acquire a read/write lock for reading -.Sh SYNOPSIS -.Fd #include <pthread.h> -.Ft int -.Fn pthread_rwlock_rdlock "pthread_rwlock_t *lock" -.Ft int -.Fn pthread_rwlock_tryrdlock "pthread_rwlock_t *lock" -.Sh DESCRIPTION -The -.Fn pthread_rwlock_rdlock -function acquires a read lock on -.Fa lock -provided that -.Fa lock -is not presently held for writing and no writer threads are -presently blocked on the lock. If the read lock cannot be -immediately acquired, the calling thread blocks until it can -acquire the lock. -.Pp -The -.Fn pthread_rwlock_tryrdlock -function performs the same action, but does not block if the lock -cannot be immediately obtained (i.e. the lock is held for writing -or there are waiting writers). -.Pp -A thread may hold multiple concurrent read locks. If so, -.Fn pthread_rwlock_unlock -must be called once for each lock obtained. -.Pp -The results of acquiring a read lock while the calling thread holds -a write lock are undefined. -.Sh IMPLEMENTATION NOTES -To prevent writer starvation, writers are favored over readers. -.Sh RETURN VALUES -If successful, the -.Fn pthread_rwlock_rdlock -and -.Fn pthread_rwlock_tryrdlock -functions will return zero. Otherwise an error number will be returned -to indicate the error. -.Sh SEE ALSO -.Xr pthread_rwlock_init 3 , -.Xr pthread_rwlock_trywrlock 3 , -.Xr pthread_rwlock_unlock 3 , -.Xr pthread_rwlock_wrlock 3 -.Sh STANDARDS -The -.Fn pthread_rwlock_rdlock -and -.Fn pthread_rwlock_tryrdlock -functions are expected to conform to -.St -susv2 . -.Sh ERRORS -The -.Fn pthread_rwlock_tryrdlock -function will fail if: -.Bl -tag -width Er -.It Bq Er EBUSY -The lock could not be acquired because a writer holds the lock or -was blocked on it. -.El -.Pp -The -.Fn pthread_rwlock_rdlock -and -.Fn pthread_rwlock_tryrdlock -functions may fail if: -.Bl -tag -width Er -.It Bq Er EAGAIN -The lock could not be acquired because the maximum number of read locks -against -.Fa lock -has been exceeded. -.It Bq Er EDEADLK -The current thread already owns -.Fa lock -for writing. -.It Bq Er EINVAL -The value specified by -.Fa lock -is invalid. -.It Bq Er ENOMEM -Insufficient memory exists to initialize the lock (applies to -statically initialized locks only). -.El -.Sh HISTORY -The -.Fn pthread_rwlock_rdlock -function first appeared in -.Fx 3.0 . diff --git a/lib/libpthread/man/pthread_rwlock_unlock.3 b/lib/libpthread/man/pthread_rwlock_unlock.3 deleted file mode 100644 index 1c9fd05797ad7..0000000000000 --- a/lib/libpthread/man/pthread_rwlock_unlock.3 +++ /dev/null @@ -1,79 +0,0 @@ -.\" Copyright (c) 1998 Alex Nash -.\" 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. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR 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 AUTHOR 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. -.\" -.\" $Id$ -.\" -.Dd August 4, 1998 -.Dt PTHREAD_RWLOCK_UNLOCK 3 -.Os -.Sh NAME -.Nm pthread_rwlock_unlock -.Nd release a read/write lock -.Sh SYNOPSIS -.Fd #include <pthread.h> -.Ft int -.Fn pthread_rwlock_unlock "pthread_rwlock_t *lock" -.Sh DESCRIPTION -The -.Fn pthread_rwlock_unlock -function is used to release the read/write lock previously obtained by -.Fn pthread_rwlock_rdlock , -.Fn pthread_rwlock_wrlock , -.Fn pthread_rwlock_tryrdlock , -or -.Fn pthread_rwlock_trywrlock . -.Sh RETURN VALUES -If successful, the -.Fn pthread_rwlock_unlock -function will return zero. Otherwise an error number will be returned -to indicate the error. -.Pp -The results are undefined if -.Fa lock -is not held by the calling thread. -.Sh SEE ALSO -.Xr pthread_rwlock_rdlock 3 , -.Xr pthread_rwlock_wrlock 3 -.Sh STANDARDS -The -.Fn pthread_rwlock_unlock -function is expected to conform to -.St -susv2 . -.Sh ERRORS -The -.Fn pthread_rwlock_unlock -function may fail if: -.Bl -tag -width Er -.It Bq Er EINVAL -The value specified by -.Fa lock -is invalid. -.It Bq Er EPERM -The current thread does not own the read/write lock. -.El -.Sh HISTORY -The -.Fn pthread_rwlock_unlock -function first appeared in -.Fx 3.0 . diff --git a/lib/libpthread/man/pthread_rwlock_wrlock.3 b/lib/libpthread/man/pthread_rwlock_wrlock.3 deleted file mode 100644 index a5a3674065669..0000000000000 --- a/lib/libpthread/man/pthread_rwlock_wrlock.3 +++ /dev/null @@ -1,102 +0,0 @@ -.\" Copyright (c) 1998 Alex Nash -.\" 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. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR 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 AUTHOR 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. -.\" -.\" $Id$ -.\" -.Dd August 4, 1998 -.Dt PTHREAD_RWLOCK_WRLOCK 3 -.Os -.Sh NAME -.Nm pthread_rwlock_wrlock , -.Nm pthread_rwlock_trywrlock -.Nd acquire a read/write lock for writing -.Sh SYNOPSIS -.Fd #include <pthread.h> -.Ft int -.Fn pthread_rwlock_wrlock "pthread_rwlock_t *lock" -.Ft int -.Fn pthread_rwlock_trywrlock "pthread_rwlock_t *lock" -.Sh DESCRIPTION -The -.Fn pthread_rwlock_wrlock -function blocks until a write lock can be acquired against -.Fa lock . -The -.Fn pthread_rwlock_trywrlock -function performs the same action, but does not block if the lock -cannot be immediately obtained. -.Pp -The results are undefined if the calling thread already holds the -lock at the time the call is made. -.Sh IMPLEMENTATION NOTES -To prevent writer starvation, writers are favored over readers. -.Sh RETURN VALUES -If successful, the -.Fn pthread_rwlock_wrlock -and -.Fn pthread_rwlock_trywrlock -functions will return zero. Otherwise an error number will be returned -to indicate the error. -.Sh SEE ALSO -.Xr pthread_rwlock_trywrlock 3 , -.Xr pthread_rwlock_unlock 3 , -.Xr pthread_rwlock_wrlock 3 -.Sh STANDARDS -The -.Fn pthread_rwlock_wrlock -and -.Fn pthread_rwlock_trywrlock -functions are expected to conform to -.St -susv2 . -.Sh ERRORS -The -.Fn pthread_rwlock_trywrlock -function will fail if: -.Bl -tag -width Er -.It Bq Er EBUSY -The calling thread is not able to acquire the lock without blocking. -.El -.Pp -The -.Fn pthread_rwlock_wrlock -and -.Fn pthread_rwlock_trywrlock -functions may fail if: -.Bl -tag -width Er -.It Bq Er EDEADLK -The calling thread already owns the read/write lock (for reading -or writing). -.It Bq Er EINVAL -The value specified by -.Fa lock -is invalid. -.It Bq Er ENOMEM -Insufficient memory exists to initialize the lock (applies to -statically initialized locks only). -.El -.Sh HISTORY -The -.Fn pthread_rwlock_wrlock -function first appeared in -.Fx 3.0 . diff --git a/lib/libpthread/man/pthread_rwlockattr_destroy.3 b/lib/libpthread/man/pthread_rwlockattr_destroy.3 deleted file mode 100644 index ee3c4054d6425..0000000000000 --- a/lib/libpthread/man/pthread_rwlockattr_destroy.3 +++ /dev/null @@ -1,68 +0,0 @@ -.\" Copyright (c) 1998 Alex Nash -.\" 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. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR 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 AUTHOR 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. -.\" -.\" $Id$ -.\" -.Dd August 4, 1998 -.Dt PTHREAD_RWLOCKATTR_DESTROY 3 -.Os -.Sh NAME -.Nm pthread_rwlockattr_destroy -.Nd destroy a read/write lock -.Sh SYNOPSIS -.Fd #include <pthread.h> -.Ft int -.Fn pthread_rwlockattr_destroy "pthread_rwlockattr_t *attr" -.Sh DESCRIPTION -The -.Fn pthread_rwlockattr_destroy -function is used to destroy a read/write lock attribute object -previously created with -.Fn pthread_rwlockattr_init . -.Sh RETURN VALUES -If successful, the -.Fn pthread_rwlockattr_destroy -function will return zero. Otherwise an error number will be returned -to indicate the error. -.Sh SEE ALSO -.Xr pthread_rwlockattr_init 3 , -.Sh STANDARDS -The -.Fn pthread_rwlockattr_destroy -function is expected to conform to -.St -susv2 . -.Sh ERRORS -.Fn pthread_rwlockattr_destroy -may fail if: -.Bl -tag -width Er -.It Bq Er EINVAL -The value specified by -.Fa attr -is invalid. -.El -.Sh HISTORY -The -.Fn pthread_rwlockattr_destroy -function first appeared in -.Fx 3.0 . diff --git a/lib/libpthread/man/pthread_rwlockattr_getpshared.3 b/lib/libpthread/man/pthread_rwlockattr_getpshared.3 deleted file mode 100644 index 8e8160bc0f338..0000000000000 --- a/lib/libpthread/man/pthread_rwlockattr_getpshared.3 +++ /dev/null @@ -1,80 +0,0 @@ -.\" Copyright (c) 1998 Alex Nash -.\" 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. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR 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 AUTHOR 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. -.\" -.\" $Id$ -.\" -.Dd August 4, 1998 -.Dt PTHREAD_RWLOCKATTR_GETPSHARED 3 -.Os -.Sh NAME -.Nm pthread_rwlockattr_getpshared -.Nd set the process shared attribute -.Sh SYNOPSIS -.Fd #include <pthread.h> -.Ft int -.Fn pthread_rwlockattr_getpshared "pthread_rwlockattr_t *attr" "int *pshared" -.Sh DESCRIPTION -The -.Fn pthread_rwlockattr_getpshared -function is used to get the process shared setting of a read/write -lock attribute object. The setting is returned via -.Fa pshared , -and may be one of two values: -.Bl -hang -offset flag -width 123456789012345678901234 -.It Ar PTHREAD_PROCESS_SHARED -Any thread of any process that has access to the memory where the -read/write lock resides can manipulate the lock. -.It Ar PTHREAD_PROCESS_PRIVATE -Only threads created within the same process as the thread that -initialized the read/write lock can manipulate the lock. This is -the default value. -.El -.Sh RETURN VALUES -If successful, the -.Fn pthread_rwlockattr_getpshared -function will return zero. Otherwise an error number will be returned -to indicate the error. -.Sh SEE ALSO -.Xr pthread_rwlock_init 3 , -.Xr pthread_rwlockattr_init 3 , -.Xr pthread_rwlockattr_setpshared 3 -.Sh STANDARDS -The -.Fn pthread_rwlockattr_getpshared -function is expected to conform to -.St -susv2 . -.Sh ERRORS -.Fn pthread_rwlockattr_getpshared -may fail if: -.Bl -tag -width Er -.It Bq Er EINVAL -The value specified by -.Fa attr -is invalid. -.El -.Sh HISTORY -The -.Fn pthread_rwlockattr_getpshared -function first appeared in -.Fx 3.0 . diff --git a/lib/libpthread/man/pthread_rwlockattr_init.3 b/lib/libpthread/man/pthread_rwlockattr_init.3 deleted file mode 100644 index 88271216f8996..0000000000000 --- a/lib/libpthread/man/pthread_rwlockattr_init.3 +++ /dev/null @@ -1,67 +0,0 @@ -.\" Copyright (c) 1998 Alex Nash -.\" 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. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR 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 AUTHOR 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. -.\" -.\" $Id$ -.\" -.Dd August 4, 1998 -.Dt PTHREAD_RWLOCKATTR_INIT 3 -.Os -.Sh NAME -.Nm pthread_rwlockattr_init -.Nd initialize a read/write lock -.Sh SYNOPSIS -.Fd #include <pthread.h> -.Ft int -.Fn pthread_rwlockattr_init "pthread_rwlockattr_t *attr" -.Sh DESCRIPTION -The -.Fn pthread_rwlockattr_init -function is used to initialize a read/write lock attributes object. -.Sh RETURN VALUES -If successful, the -.Fn pthread_rwlockattr_init -function will return zero. Otherwise an error number will be returned -to indicate the error. -.Sh SEE ALSO -.Xr pthread_rwlock_init 3 , -.Xr pthread_rwlockattr_destroy 3 , -.Xr pthread_rwlockattr_getpshared 3 -.Xr pthread_rwlockattr_setpshared 3 -.Sh STANDARDS -The -.Fn pthread_rwlockattr_init -function is expected to conform to -.St -susv2 . -.Sh ERRORS -.Fn pthread_rwlockattr_init -will fail if: -.Bl -tag -width Er -.It Bq Er ENOMEM -Insufficient memory exists to initialize the attribute object. -.El -.Sh HISTORY -The -.Fn pthread_rwlockattr_init -function first appeared in -.Fx 3.0 . diff --git a/lib/libpthread/man/pthread_rwlockattr_setpshared.3 b/lib/libpthread/man/pthread_rwlockattr_setpshared.3 deleted file mode 100644 index e63debfc400b7..0000000000000 --- a/lib/libpthread/man/pthread_rwlockattr_setpshared.3 +++ /dev/null @@ -1,86 +0,0 @@ -.\" Copyright (c) 1998 Alex Nash -.\" 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. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR 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 AUTHOR 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. -.\" -.\" $Id$ -.\" -.Dd August 4, 1998 -.Dt PTHREAD_RWLOCKATTR_SETPSHARED 3 -.Os -.Sh NAME -.Nm pthread_rwlockattr_setpshared -.Nd set the process shared attribute -.Sh SYNOPSIS -.Fd #include <pthread.h> -.Ft int -.Fn pthread_rwlockattr_setpshared "pthread_rwlockattr_t *attr" "int *pshared" -.Sh DESCRIPTION -The -.Fn pthread_rwlockattr_setpshared -function sets the process shared attribute of -.Fa attr -to the value referenced by -.Fa pshared . -.Fa pshared -may be one of two values: -.Bl -hang -offset flag -width 123456789012345678901234 -.It Ar PTHREAD_PROCESS_SHARED -Any thread of any process that has access to the memory where the -read/write lock resides can manipulate the lock. -.It Ar PTHREAD_PROCESS_PRIVATE -Only threads created within the same process as the thread that -initialized the read/write lock can manipulate the lock. This is -the default value. -.El -.Sh RETURN VALUES -If successful, the -.Fn pthread_rwlockattr_setpshared -function will return zero. Otherwise an error number will be returned -to indicate the error. -.Sh SEE ALSO -.Xr pthread_rwlock_init 3 , -.Xr pthread_rwlockattr_init 3 , -.Xr pthread_rwlockattr_setpshared 3 -.Sh STANDARDS -The -.Fn pthread_rwlockattr_setpshared -function is expected to conform to -.St -susv2 . -.Sh ERRORS -.Fn pthread_rwlockattr_setpshared -will fail if: -.Bl -tag -width Er -.It Bq Er EINVAL -The value specified by -.Fa attr -or -.Fa pshared -is invalid. -.El -.Sh HISTORY -The -.Fn pthread_rwlockattr_setpshared -function first appeared in -.Fx 3.0 . -.Sh BUGS -The PTHREAD_PROCESS_SHARED attribute is not supported. diff --git a/lib/libpthread/man/pthread_self.3 b/lib/libpthread/man/pthread_self.3 deleted file mode 100644 index 46c118af09f81..0000000000000 --- a/lib/libpthread/man/pthread_self.3 +++ /dev/null @@ -1,59 +0,0 @@ -.\" Copyright (c) 1996 John Birrell <jb@cimlogic.com.au>. -.\" 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 John Birrell. -.\" 4. Neither the name of the author nor the names of any co-contributors -.\" may be used to endorse or promote products derived from this software -.\" without specific prior written permission. -.\" -.\" THIS SOFTWARE IS PROVIDED BY JOHN BIRRELL 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. -.\" -.Dd April 4, 1996 -.Dt PTHREAD_SELF 3 -.Os BSD 4 -.Sh NAME -.Nm pthread_self -.Nd get the calling thread's ID -.Sh SYNOPSIS -.Fd #include <pthread.h> -.Ft pthread_t -.Fn pthread_self "void" -.Sh DESCRIPTION -The -.Fn pthread_self -function returns the thread ID of the calling thread. -.Sh RETURN VALUES -The -.Fn pthread_self -function returns the thread ID of the calling thread. -.Sh ERRORS -None. -.Pp -.Sh SEE ALSO -.Xr pthread_create 3 , -.Xr pthread_equal 3 -.Sh STANDARDS -.Fn pthread_self -conforms to ISO/IEC 9945-1 ANSI/IEEE -.Pq Dq Tn POSIX -Std 1003.1 Second Edition 1996-07-12. diff --git a/lib/libpthread/man/pthread_setspecific.3 b/lib/libpthread/man/pthread_setspecific.3 deleted file mode 100644 index e28cf568213b9..0000000000000 --- a/lib/libpthread/man/pthread_setspecific.3 +++ /dev/null @@ -1,91 +0,0 @@ -.\" Copyright (c) 1996 John Birrell <jb@cimlogic.com.au>. -.\" 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 John Birrell. -.\" 4. Neither the name of the author nor the names of any co-contributors -.\" may be used to endorse or promote products derived from this software -.\" without specific prior written permission. -.\" -.\" THIS SOFTWARE IS PROVIDED BY JOHN BIRRELL 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. -.\" -.Dd April 4, 1996 -.Dt PTHREAD_SETSPECIFIC 3 -.Os BSD 4 -.Sh NAME -.Nm pthread_setspecific -.Nd set a thread-specific data value -.Sh SYNOPSIS -.Fd #include <pthread.h> -.Ft int -.Fn pthread_setspecific "pthread_key_t key" "const void *value" -.Sh DESCRIPTION -The -.Fn pthread_setspecific -function associates a thread-specific value with a -.Fa key -obtained via a previous call to -.Fn pthread_key_create . -Different threads man bind different values to the same key. These values are -typically pointers to blocks of dynamically allocated memory that have been -reserved for use by the calling thread. -.Pp -The effect of calling -.Fn pthread_setspecific -with a key value not obtained from -.Fn pthread_key_create -or after -.Fa key -has been deleted with -.Fn pthread_key_delete -is undefined. -.Pp -.Fn pthread_setspecific -may be called from a thread-specific data destructor function, however this -may result in lost storage or infinite loops. -.Sh RETURN VALUES -If successful, the -.Fn pthread_setspecific -function will return zero. Otherwise an error number will be returned to -indicate the error. -.Sh ERRORS -.Fn pthread_setspecific -will fail if: -.Bl -tag -width Er -.It Bq Er ENOMEM -Insufficient memory exists to associate the value with the -.Fa key . -.It Bq Er EINVAL -The -.Fa key -value is invalid. -.El -.Pp -.Sh SEE ALSO -.Xr pthread_getspecific 3 , -.Xr pthread_key_create 3 , -.Xr pthread_key_delete 3 -.Sh STANDARDS -.Fn pthread_setspecific -conforms to ISO/IEC 9945-1 ANSI/IEEE -.Pq Dq Tn POSIX -Std 1003.1 Second Edition 1996-07-12. diff --git a/lib/libpthread/sys/Makefile.inc b/lib/libpthread/sys/Makefile.inc deleted file mode 100644 index 50952cdfad1a4..0000000000000 --- a/lib/libpthread/sys/Makefile.inc +++ /dev/null @@ -1,6 +0,0 @@ -# $Id: Makefile.inc,v 1.8 1998/04/29 11:03:34 jb Exp $ - -.PATH: ${.CURDIR}/sys ${.CURDIR}/arch/${MACHINE_ARCH} - -SRCS+= uthread_error.c _atomic_lock.S - diff --git a/lib/libpthread/sys/thr_error.c b/lib/libpthread/sys/thr_error.c deleted file mode 100644 index 545dfb06652c4..0000000000000 --- a/lib/libpthread/sys/thr_error.c +++ /dev/null @@ -1,50 +0,0 @@ -/* - * Copyright (c) 1995 John Birrell <jb@cimlogic.com.au>. - * 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 John Birrell - * and Chris Provenzano. - * 4. Neither the name of the author nor the names of any co-contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY JOHN BIRRELL 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. - * - */ -#ifdef _THREAD_SAFE -#include <pthread.h> -#include "pthread_private.h" -extern int errno; - -int * __error() -{ - int *p_errno; - if (_thread_run == _thread_initial) { - p_errno = &errno; - } else { - p_errno = &_thread_run->error; - } - return(p_errno); -} -#endif diff --git a/lib/libpthread/test/Makefile b/lib/libpthread/test/Makefile deleted file mode 100644 index adf1673639772..0000000000000 --- a/lib/libpthread/test/Makefile +++ /dev/null @@ -1,8 +0,0 @@ -# $Id: Makefile,v 1.1 1998/08/25 12:33:22 jb Exp $ -# -# Tests for libc_r functionality. -# - -SUBDIR= sigsuspend sigwait - -.include <bsd.subdir.mk> diff --git a/lib/libpthread/thread/Makefile.inc b/lib/libpthread/thread/Makefile.inc deleted file mode 100644 index 004982a8b6bcd..0000000000000 --- a/lib/libpthread/thread/Makefile.inc +++ /dev/null @@ -1,99 +0,0 @@ -# $Id: Makefile.inc,v 1.15 1998/09/12 22:03:20 dt Exp $ - -# uthread sources -.PATH: ${.CURDIR}/uthread - -SRCS+= \ - uthread_accept.c \ - uthread_attr_destroy.c \ - uthread_attr_init.c \ - uthread_attr_getdetachstate.c \ - uthread_attr_getstackaddr.c \ - uthread_attr_getstacksize.c \ - uthread_attr_setcreatesuspend_np.c \ - uthread_attr_setdetachstate.c \ - uthread_attr_setstackaddr.c \ - uthread_attr_setstacksize.c \ - uthread_autoinit.cc \ - uthread_bind.c \ - uthread_clean.c \ - uthread_close.c \ - uthread_cond.c \ - uthread_condattr_destroy.c \ - uthread_condattr_init.c \ - uthread_connect.c \ - uthread_create.c \ - uthread_detach.c \ - uthread_dup.c \ - uthread_dup2.c \ - uthread_equal.c \ - uthread_execve.c \ - uthread_exit.c \ - uthread_fchmod.c \ - uthread_fchown.c \ - uthread_fcntl.c \ - uthread_fd.c \ - uthread_file.c \ - uthread_find_thread.c \ - uthread_flock.c \ - uthread_fork.c \ - uthread_fstat.c \ - uthread_fstatfs.c \ - uthread_fsync.c \ - uthread_gc.c \ - uthread_getdirentries.c \ - uthread_getpeername.c \ - uthread_getprio.c \ - uthread_getsockname.c \ - uthread_getsockopt.c \ - uthread_info.c \ - uthread_init.c \ - uthread_ioctl.c \ - uthread_join.c \ - uthread_kern.c \ - uthread_kill.c \ - uthread_listen.c \ - uthread_mattr_init.c \ - uthread_mattr_kind_np.c \ - uthread_multi_np.c \ - uthread_mutex.c \ - uthread_mutexattr_destroy.c \ - uthread_nanosleep.c \ - uthread_once.c \ - uthread_open.c \ - uthread_pipe.c \ - uthread_queue.c \ - uthread_read.c \ - uthread_readv.c \ - uthread_recvfrom.c \ - uthread_recvmsg.c \ - uthread_resume_np.c \ - uthread_rwlock.c \ - uthread_rwlockattr.c \ - uthread_select.c \ - uthread_self.c \ - uthread_sendmsg.c \ - uthread_sendto.c \ - uthread_seterrno.c \ - uthread_setprio.c \ - uthread_setsockopt.c \ - uthread_shutdown.c \ - uthread_sig.c \ - uthread_sigaction.c \ - uthread_sigblock.c \ - uthread_sigmask.c \ - uthread_sigprocmask.c \ - uthread_sigsetmask.c \ - uthread_sigsuspend.c \ - uthread_sigwait.c \ - uthread_single_np.c \ - uthread_socket.c \ - uthread_socketpair.c \ - uthread_spec.c \ - uthread_spinlock.c \ - uthread_suspend_np.c \ - uthread_vfork.c \ - uthread_wait4.c \ - uthread_write.c \ - uthread_writev.c \ - uthread_yield.c diff --git a/lib/libpthread/thread/thr_attr_destroy.c b/lib/libpthread/thread/thr_attr_destroy.c deleted file mode 100644 index 1f4b2c8523c33..0000000000000 --- a/lib/libpthread/thread/thr_attr_destroy.c +++ /dev/null @@ -1,60 +0,0 @@ -/* - * Copyright (c) 1996 John Birrell <jb@cimlogic.com.au>. - * 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 John Birrell. - * 4. Neither the name of the author nor the names of any co-contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY JOHN BIRRELL 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 <stdlib.h> -#include <errno.h> -#ifdef _THREAD_SAFE -#include <pthread.h> -#include "pthread_private.h" - -int pthread_attr_destroy(pthread_attr_t *attr) -{ - int ret; - - /* Check for invalid arguments: */ - if (attr == NULL || *attr == NULL) - /* Invalid argument: */ - ret = EINVAL; - else { - /* Free the memory allocated to the attribute object: */ - free(*attr); - - /* - * Leave the attribute pointer NULL now that the memory - * has been freed: - */ - *attr = NULL; - ret = 0; - } - return(ret); -} -#endif diff --git a/lib/libpthread/thread/thr_attr_getdetachstate.c b/lib/libpthread/thread/thr_attr_getdetachstate.c deleted file mode 100644 index 4715cb6f24244..0000000000000 --- a/lib/libpthread/thread/thr_attr_getdetachstate.c +++ /dev/null @@ -1,57 +0,0 @@ -/* - * Copyright (c) 1997 John Birrell <jb@cimlogic.com.au>. - * 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 John Birrell. - * 4. Neither the name of the author nor the names of any co-contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY JOHN BIRRELL 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 <errno.h> -#ifdef _THREAD_SAFE -#include <pthread.h> -#include "pthread_private.h" - -int pthread_attr_getdetachstate(pthread_attr_t *attr, int *detachstate) -{ - int ret; - - /* Check for invalid arguments: */ - if (attr == NULL || *attr == NULL || detachstate == NULL) - ret = EINVAL; - else { - /* Check if the detached flag is set: */ - if ((*attr)->flags & PTHREAD_DETACHED) - /* Return detached: */ - *detachstate = PTHREAD_CREATE_DETACHED; - else - /* Return joinable: */ - *detachstate = PTHREAD_CREATE_JOINABLE; - ret = 0; - } - return(ret); -} -#endif diff --git a/lib/libpthread/thread/thr_attr_getstackaddr.c b/lib/libpthread/thread/thr_attr_getstackaddr.c deleted file mode 100644 index 1850a324c611f..0000000000000 --- a/lib/libpthread/thread/thr_attr_getstackaddr.c +++ /dev/null @@ -1,52 +0,0 @@ -/* - * Copyright (c) 1997 John Birrell <jb@cimlogic.com.au>. - * 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 John Birrell. - * 4. Neither the name of the author nor the names of any co-contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY JOHN BIRRELL 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 <errno.h> -#ifdef _THREAD_SAFE -#include <pthread.h> -#include "pthread_private.h" - -int pthread_attr_getstackaddr(pthread_attr_t *attr, void **stackaddr) -{ - int ret; - - /* Check for invalid arguments: */ - if (attr == NULL || *attr == NULL || stackaddr == NULL) - ret = EINVAL; - else { - /* Return the stack address: */ - *stackaddr = (*attr)->stackaddr_attr; - ret = 0; - } - return(ret); -} -#endif diff --git a/lib/libpthread/thread/thr_attr_getstacksize.c b/lib/libpthread/thread/thr_attr_getstacksize.c deleted file mode 100644 index de81106083d49..0000000000000 --- a/lib/libpthread/thread/thr_attr_getstacksize.c +++ /dev/null @@ -1,52 +0,0 @@ -/* - * Copyright (c) 1997 John Birrell <jb@cimlogic.com.au>. - * 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 John Birrell. - * 4. Neither the name of the author nor the names of any co-contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY JOHN BIRRELL 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 <errno.h> -#ifdef _THREAD_SAFE -#include <pthread.h> -#include "pthread_private.h" - -int pthread_attr_getstacksize(pthread_attr_t *attr, size_t *stacksize) -{ - int ret; - - /* Check for invalid arguments: */ - if (attr == NULL || *attr == NULL || stacksize == NULL) - ret = EINVAL; - else { - /* Return the stack size: */ - *stacksize = (*attr)->stacksize_attr; - ret = 0; - } - return(ret); -} -#endif diff --git a/lib/libpthread/thread/thr_attr_init.c b/lib/libpthread/thread/thr_attr_init.c deleted file mode 100644 index c64e29fed11cc..0000000000000 --- a/lib/libpthread/thread/thr_attr_init.c +++ /dev/null @@ -1,59 +0,0 @@ -/* - * Copyright (c) 1996 John Birrell <jb@cimlogic.com.au>. - * 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 John Birrell. - * 4. Neither the name of the author nor the names of any co-contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY JOHN BIRRELL 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 <string.h> -#include <stdlib.h> -#include <errno.h> -#ifdef _THREAD_SAFE -#include <pthread.h> -#include "pthread_private.h" - -int pthread_attr_init(pthread_attr_t *attr) -{ - int ret; - pthread_attr_t pattr; - - /* Allocate memory for the attribute object: */ - if ((pattr = (pthread_attr_t) malloc(sizeof(struct pthread_attr))) == NULL) - /* Insufficient memory: */ - ret = ENOMEM; - else { - /* Initialise the attribute object with the defaults: */ - memcpy(pattr, &pthread_attr_default, sizeof(struct pthread_attr)); - - /* Return a pointer to the attribute object: */ - *attr = pattr; - ret = 0; - } - return(ret); -} -#endif diff --git a/lib/libpthread/thread/thr_attr_setcreatesuspend_np.c b/lib/libpthread/thread/thr_attr_setcreatesuspend_np.c deleted file mode 100644 index afe6b23c3cb27..0000000000000 --- a/lib/libpthread/thread/thr_attr_setcreatesuspend_np.c +++ /dev/null @@ -1,51 +0,0 @@ -/* - * Copyright (c) 1995 John Birrell <jb@cimlogic.com.au>. - * 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 John Birrell. - * 4. Neither the name of the author nor the names of any co-contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY JOHN BIRRELL 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 <errno.h> -#ifdef _THREAD_SAFE -#include <pthread.h> -#include "pthread_private.h" - -int -pthread_attr_setcreatesuspend_np(pthread_attr_t *attr) -{ - int ret; - if (attr == NULL || *attr == NULL) { - errno = EINVAL; - ret = -1; - } else { - (*attr)->suspend = PTHREAD_CREATE_SUSPENDED; - ret = 0; - } - return(ret); -} -#endif diff --git a/lib/libpthread/thread/thr_attr_setdetachstate.c b/lib/libpthread/thread/thr_attr_setdetachstate.c deleted file mode 100644 index 6ec0dbc1c585d..0000000000000 --- a/lib/libpthread/thread/thr_attr_setdetachstate.c +++ /dev/null @@ -1,59 +0,0 @@ -/* - * Copyright (c) 1997 John Birrell <jb@cimlogic.com.au>. - * 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 John Birrell. - * 4. Neither the name of the author nor the names of any co-contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY JOHN BIRRELL 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 <errno.h> -#ifdef _THREAD_SAFE -#include <pthread.h> -#include "pthread_private.h" - -int pthread_attr_setdetachstate(pthread_attr_t *attr, int detachstate) -{ - int ret; - - /* Check for invalid arguments: */ - if (attr == NULL || *attr == NULL || - (detachstate != PTHREAD_CREATE_DETACHED && - detachstate != PTHREAD_CREATE_JOINABLE)) - ret = EINVAL; - else { - /* Check if detached state: */ - if (detachstate == PTHREAD_CREATE_DETACHED) - /* Set the detached flag: */ - (*attr)->flags |= PTHREAD_DETACHED; - else - /* Reset the detached flag: */ - (*attr)->flags &= ~PTHREAD_DETACHED; - ret = 0; - } - return(ret); -} -#endif diff --git a/lib/libpthread/thread/thr_attr_setstackaddr.c b/lib/libpthread/thread/thr_attr_setstackaddr.c deleted file mode 100644 index ce54915d096d2..0000000000000 --- a/lib/libpthread/thread/thr_attr_setstackaddr.c +++ /dev/null @@ -1,52 +0,0 @@ -/* - * Copyright (c) 1997 John Birrell <jb@cimlogic.com.au>. - * 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 John Birrell. - * 4. Neither the name of the author nor the names of any co-contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY JOHN BIRRELL 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 <errno.h> -#ifdef _THREAD_SAFE -#include <pthread.h> -#include "pthread_private.h" - -int pthread_attr_setstackaddr(pthread_attr_t *attr, void *stackaddr) -{ - int ret; - - /* Check for invalid arguments: */ - if (attr == NULL || *attr == NULL || stackaddr == NULL) - ret = EINVAL; - else { - /* Save the stack address: */ - (*attr)->stackaddr_attr = stackaddr; - ret = 0; - } - return(ret); -} -#endif diff --git a/lib/libpthread/thread/thr_attr_setstacksize.c b/lib/libpthread/thread/thr_attr_setstacksize.c deleted file mode 100644 index 94e575e0ddedf..0000000000000 --- a/lib/libpthread/thread/thr_attr_setstacksize.c +++ /dev/null @@ -1,52 +0,0 @@ -/* - * Copyright (c) 1996 John Birrell <jb@cimlogic.com.au>. - * 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 John Birrell. - * 4. Neither the name of the author nor the names of any co-contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY JOHN BIRRELL 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 <errno.h> -#ifdef _THREAD_SAFE -#include <pthread.h> -#include "pthread_private.h" - -int pthread_attr_setstacksize(pthread_attr_t *attr, size_t stacksize) -{ - int ret; - - /* Check for invalid arguments: */ - if (attr == NULL || *attr == NULL || stacksize < PTHREAD_STACK_MIN) - ret = EINVAL; - else { - /* Save the stack size: */ - (*attr)->stacksize_attr = stacksize; - ret = 0; - } - return(ret); -} -#endif diff --git a/lib/libpthread/thread/thr_clean.c b/lib/libpthread/thread/thr_clean.c deleted file mode 100644 index 9319f85efbea0..0000000000000 --- a/lib/libpthread/thread/thr_clean.c +++ /dev/null @@ -1,68 +0,0 @@ -/* - * Copyright (c) 1995 John Birrell <jb@cimlogic.com.au>. - * 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 John Birrell. - * 4. Neither the name of the author nor the names of any co-contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY JOHN BIRRELL 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 <signal.h> -#include <errno.h> -#include <stdlib.h> -#ifdef _THREAD_SAFE -#include <pthread.h> -#include "pthread_private.h" - -void -pthread_cleanup_push(void (*routine) (void *), void *routine_arg) -{ - struct pthread_cleanup *new; - - if ((new = (struct pthread_cleanup *) malloc(sizeof(struct pthread_cleanup))) != NULL) { - new->routine = routine; - new->routine_arg = routine_arg; - new->next = _thread_run->cleanup; - - _thread_run->cleanup = new; - } -} - -void -pthread_cleanup_pop(int execute) -{ - struct pthread_cleanup *old; - - if ((old = _thread_run->cleanup) != NULL) { - _thread_run->cleanup = old->next; - if (execute) { - old->routine(old->routine_arg); - } - free(old); - } -} - -#endif diff --git a/lib/libpthread/thread/thr_close.c b/lib/libpthread/thread/thr_close.c deleted file mode 100644 index 7e21853223e86..0000000000000 --- a/lib/libpthread/thread/thr_close.c +++ /dev/null @@ -1,89 +0,0 @@ -/* - * Copyright (c) 1995-1998 John Birrell <jb@cimlogic.com.au> - * 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 John Birrell. - * 4. Neither the name of the author nor the names of any co-contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY JOHN BIRRELL 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 <stdlib.h> -#include <unistd.h> -#include <fcntl.h> -#include <sys/stat.h> -#ifdef _THREAD_SAFE -#include <pthread.h> -#include "pthread_private.h" - -int -close(int fd) -{ - int flags; - int ret; - int status; - struct stat sb; - - /* Lock the file descriptor while the file is closed: */ - if ((ret = _FD_LOCK(fd, FD_RDWR, NULL)) == 0) { - /* Get file descriptor status. */ - _thread_sys_fstat(fd, &sb); - - /* - * Check if the file should be left as blocking. - * - * This is so that the file descriptors shared with a parent - * process aren't left set to non-blocking if the child - * closes them prior to exit. An example where this causes - * problems with /bin/sh is when a child closes stdin. - * - * Setting a file as blocking causes problems if a threaded - * parent accesses the file descriptor before the child exits. - * Once the threaded parent receives a SIGCHLD then it resets - * all of its files to non-blocking, and so it is then safe - * to access them. - * - * Pipes are not set to blocking when they are closed, as - * the parent and child will normally close the file - * descriptor of the end of the pipe that they are not - * using, which would then cause any reads to block - * indefinitely. - */ - if ((S_ISREG(sb.st_mode) || S_ISCHR(sb.st_mode)) && (_thread_fd_table[fd]->flags & O_NONBLOCK) == 0) { - /* Get the current flags: */ - flags = _thread_sys_fcntl(fd, F_GETFL, NULL); - /* Clear the nonblocking file descriptor flag: */ - _thread_sys_fcntl(fd, F_SETFL, flags & ~O_NONBLOCK); - } - - /* Close the file descriptor: */ - ret = _thread_sys_close(fd); - - free(_thread_fd_table[fd]); - _thread_fd_table[fd] = NULL; - } - return (ret); -} -#endif diff --git a/lib/libpthread/thread/thr_cond.c b/lib/libpthread/thread/thr_cond.c deleted file mode 100644 index a085ea60fa899..0000000000000 --- a/lib/libpthread/thread/thr_cond.c +++ /dev/null @@ -1,353 +0,0 @@ -/* - * Copyright (c) 1995 John Birrell <jb@cimlogic.com.au>. - * 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 John Birrell. - * 4. Neither the name of the author nor the names of any co-contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY JOHN BIRRELL 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 <stdlib.h> -#include <errno.h> -#include <string.h> -#ifdef _THREAD_SAFE -#include <pthread.h> -#include "pthread_private.h" - -int -pthread_cond_init(pthread_cond_t * cond, const pthread_condattr_t * cond_attr) -{ - enum pthread_cond_type type; - pthread_cond_t pcond; - int rval = 0; - - if (cond == NULL) - rval = EINVAL; - else { - /* - * Check if a pointer to a condition variable attribute - * structure was passed by the caller: - */ - if (cond_attr != NULL && *cond_attr != NULL) { - /* Default to a fast condition variable: */ - type = (*cond_attr)->c_type; - } else { - /* Default to a fast condition variable: */ - type = COND_TYPE_FAST; - } - - /* Process according to condition variable type: */ - switch (type) { - /* Fast condition variable: */ - case COND_TYPE_FAST: - /* Nothing to do here. */ - break; - - /* Trap invalid condition variable types: */ - default: - /* Return an invalid argument error: */ - rval = EINVAL; - break; - } - - /* Check for no errors: */ - if (rval == 0) { - if ((pcond = (pthread_cond_t) - malloc(sizeof(struct pthread_cond))) == NULL) { - rval = ENOMEM; - } else { - /* - * Initialise the condition variable - * structure: - */ - _thread_queue_init(&pcond->c_queue); - pcond->c_flags |= COND_FLAGS_INITED; - pcond->c_type = type; - memset(&pcond->lock,0,sizeof(pcond->lock)); - *cond = pcond; - } - } - } - /* Return the completion status: */ - return (rval); -} - -int -pthread_cond_destroy(pthread_cond_t * cond) -{ - int rval = 0; - - if (cond == NULL || *cond == NULL) - rval = EINVAL; - else { - /* Lock the condition variable structure: */ - _SPINLOCK(&(*cond)->lock); - - /* - * Free the memory allocated for the condition - * variable structure: - */ - free(*cond); - - /* - * NULL the caller's pointer now that the condition - * variable has been destroyed: - */ - *cond = NULL; - } - /* Return the completion status: */ - return (rval); -} - -int -pthread_cond_wait(pthread_cond_t * cond, pthread_mutex_t * mutex) -{ - int rval = 0; - int status; - - if (cond == NULL) - rval = EINVAL; - - /* - * If the condition variable is statically initialized, - * perform the dynamic initialization: - */ - else if (*cond != NULL || - (rval = pthread_cond_init(cond,NULL)) == 0) { - /* Lock the condition variable structure: */ - _SPINLOCK(&(*cond)->lock); - - /* Process according to condition variable type: */ - switch ((*cond)->c_type) { - /* Fast condition variable: */ - case COND_TYPE_FAST: - /* Wait forever: */ - _thread_run->wakeup_time.tv_sec = -1; - - /* - * Queue the running thread for the condition - * variable: - */ - _thread_queue_enq(&(*cond)->c_queue, _thread_run); - - /* Unlock the mutex: */ - if ((rval = pthread_mutex_unlock(mutex)) != 0) { - /* - * Cannot unlock the mutex, so remove the - * running thread from the condition - * variable queue: - */ - _thread_queue_deq(&(*cond)->c_queue); - - /* Unlock the condition variable structure: */ - _SPINUNLOCK(&(*cond)->lock); - } else { - /* Schedule the next thread: */ - _thread_kern_sched_state_unlock(PS_COND_WAIT, - &(*cond)->lock, __FILE__, __LINE__); - - /* Lock the mutex: */ - rval = pthread_mutex_lock(mutex); - } - break; - - /* Trap invalid condition variable types: */ - default: - /* Unlock the condition variable structure: */ - _SPINUNLOCK(&(*cond)->lock); - - /* Return an invalid argument error: */ - rval = EINVAL; - break; - } - - } - - /* Return the completion status: */ - return (rval); -} - -int -pthread_cond_timedwait(pthread_cond_t * cond, pthread_mutex_t * mutex, - const struct timespec * abstime) -{ - int rval = 0; - int status; - - if (cond == NULL) - rval = EINVAL; - - /* - * If the condition variable is statically initialized, - * perform the dynamic initialization: - */ - else if (*cond != NULL || - (rval = pthread_cond_init(cond,NULL)) == 0) { - /* Lock the condition variable structure: */ - _SPINLOCK(&(*cond)->lock); - - /* Process according to condition variable type: */ - switch ((*cond)->c_type) { - /* Fast condition variable: */ - case COND_TYPE_FAST: - /* Set the wakeup time: */ - _thread_run->wakeup_time.tv_sec = abstime->tv_sec; - _thread_run->wakeup_time.tv_nsec = abstime->tv_nsec; - - /* Reset the timeout flag: */ - _thread_run->timeout = 0; - - /* - * Queue the running thread for the condition - * variable: - */ - _thread_queue_enq(&(*cond)->c_queue, _thread_run); - - /* Unlock the mutex: */ - if ((rval = pthread_mutex_unlock(mutex)) != 0) { - /* - * Cannot unlock the mutex, so remove the - * running thread from the condition - * variable queue: - */ - _thread_queue_deq(&(*cond)->c_queue); - - /* Unlock the condition variable structure: */ - _SPINUNLOCK(&(*cond)->lock); - } else { - /* Schedule the next thread: */ - _thread_kern_sched_state_unlock(PS_COND_WAIT, - &(*cond)->lock, __FILE__, __LINE__); - - /* Lock the mutex: */ - if ((rval = pthread_mutex_lock(mutex)) != 0) { - } - /* Check if the wait timed out: */ - else if (_thread_run->timeout) { - /* Return a timeout error: */ - rval = ETIMEDOUT; - } - } - break; - - /* Trap invalid condition variable types: */ - default: - /* Unlock the condition variable structure: */ - _SPINUNLOCK(&(*cond)->lock); - - /* Return an invalid argument error: */ - rval = EINVAL; - break; - } - - } - - /* Return the completion status: */ - return (rval); -} - -int -pthread_cond_signal(pthread_cond_t * cond) -{ - int rval = 0; - int status; - pthread_t pthread; - - if (cond == NULL || *cond == NULL) - rval = EINVAL; - else { - /* Lock the condition variable structure: */ - _SPINLOCK(&(*cond)->lock); - - /* Process according to condition variable type: */ - switch ((*cond)->c_type) { - /* Fast condition variable: */ - case COND_TYPE_FAST: - /* Bring the next thread off the condition queue: */ - if ((pthread = _thread_queue_deq(&(*cond)->c_queue)) != NULL) { - /* Allow the thread to run: */ - PTHREAD_NEW_STATE(pthread,PS_RUNNING); - } - break; - - /* Trap invalid condition variable types: */ - default: - /* Return an invalid argument error: */ - rval = EINVAL; - break; - } - - /* Unlock the condition variable structure: */ - _SPINUNLOCK(&(*cond)->lock); - } - - /* Return the completion status: */ - return (rval); -} - -int -pthread_cond_broadcast(pthread_cond_t * cond) -{ - int rval = 0; - int status; - pthread_t pthread; - - if (cond == NULL || *cond == NULL) - rval = EINVAL; - else { - /* Lock the condition variable structure: */ - _SPINLOCK(&(*cond)->lock); - - /* Process according to condition variable type: */ - switch ((*cond)->c_type) { - /* Fast condition variable: */ - case COND_TYPE_FAST: - /* - * Enter a loop to bring all threads off the - * condition queue: - */ - while ((pthread = - _thread_queue_deq(&(*cond)->c_queue)) != NULL) { - /* Allow the thread to run: */ - PTHREAD_NEW_STATE(pthread,PS_RUNNING); - } - break; - - /* Trap invalid condition variable types: */ - default: - /* Return an invalid argument error: */ - rval = EINVAL; - break; - } - - /* Unlock the condition variable structure: */ - _SPINUNLOCK(&(*cond)->lock); - } - - /* Return the completion status: */ - return (rval); -} -#endif diff --git a/lib/libpthread/thread/thr_condattr_destroy.c b/lib/libpthread/thread/thr_condattr_destroy.c deleted file mode 100644 index 4179970ad9db8..0000000000000 --- a/lib/libpthread/thread/thr_condattr_destroy.c +++ /dev/null @@ -1,51 +0,0 @@ -/* - * Copyright (c) 1997 John Birrell <jb@cimlogic.com.au>. - * 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 John Birrell. - * 4. Neither the name of the author nor the names of any co-contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY JOHN BIRRELL 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 <stdlib.h> -#include <errno.h> -#ifdef _THREAD_SAFE -#include <pthread.h> -#include "pthread_private.h" - -int pthread_condattr_destroy(pthread_condattr_t *attr) -{ - int ret; - if (attr == NULL || *attr == NULL) { - ret = EINVAL; - } else { - free(*attr); - *attr = NULL; - ret = 0; - } - return(ret); -} -#endif diff --git a/lib/libpthread/thread/thr_condattr_init.c b/lib/libpthread/thread/thr_condattr_init.c deleted file mode 100644 index c87323dc1978d..0000000000000 --- a/lib/libpthread/thread/thr_condattr_init.c +++ /dev/null @@ -1,57 +0,0 @@ -/* - * Copyright (c) 1997 John Birrell <jb@cimlogic.com.au> - * 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 John Birrell. - * 4. Neither the name of the author nor the names of any co-contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY JOHN BIRRELL 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 <string.h> -#include <stdlib.h> -#include <errno.h> -#ifdef _THREAD_SAFE -#include <pthread.h> -#include "pthread_private.h" - -int -pthread_condattr_init(pthread_condattr_t *attr) -{ - int ret; - pthread_condattr_t pattr; - - if ((pattr = (pthread_condattr_t) - malloc(sizeof(struct pthread_cond_attr))) == NULL) { - ret = ENOMEM; - } else { - memcpy(pattr, &pthread_condattr_default, - sizeof(struct pthread_cond_attr)); - *attr = pattr; - ret = 0; - } - return(ret); -} -#endif diff --git a/lib/libpthread/thread/thr_create.c b/lib/libpthread/thread/thr_create.c deleted file mode 100644 index 416946131add2..0000000000000 --- a/lib/libpthread/thread/thr_create.c +++ /dev/null @@ -1,235 +0,0 @@ -/* - * Copyright (c) 1995-1998 John Birrell <jb@cimlogic.com.au> - * 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 John Birrell. - * 4. Neither the name of the author nor the names of any co-contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY JOHN BIRRELL 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 <errno.h> -#include <stdlib.h> -#include <string.h> -#include <fcntl.h> -#include <unistd.h> -#include <sys/time.h> -#ifdef _THREAD_SAFE -#include <machine/reg.h> -#include <pthread.h> -#include "pthread_private.h" -#include "libc_private.h" - -int -pthread_create(pthread_t * thread, const pthread_attr_t * attr, - void *(*start_routine) (void *), void *arg) -{ - int f_gc = 0; - int i; - int ret = 0; - int status; - pthread_t gc_thread; - pthread_t new_thread; - pthread_attr_t pattr; - void *stack; - - /* - * Locking functions in libc are required when there are - * threads other than the initial thread. - */ - __isthreaded = 1; - - /* Allocate memory for the thread structure: */ - if ((new_thread = (pthread_t) malloc(sizeof(struct pthread))) == NULL) { - /* Insufficient memory to create a thread: */ - ret = EAGAIN; - } else { - /* Check if default thread attributes are required: */ - if (attr == NULL || *attr == NULL) { - /* Use the default thread attributes: */ - pattr = &pthread_attr_default; - } else { - pattr = *attr; - } - /* Check if a stack was specified in the thread attributes: */ - if ((stack = pattr->stackaddr_attr) != NULL) { - } - /* Allocate memory for the stack: */ - else if ((stack = (void *) malloc(pattr->stacksize_attr)) == NULL) { - /* Insufficient memory to create a thread: */ - ret = EAGAIN; - free(new_thread); - } - /* Check for errors: */ - if (ret != 0) { - } else { - /* Initialise the thread structure: */ - memset(new_thread, 0, sizeof(struct pthread)); - new_thread->slice_usec = -1; - new_thread->sig_saved = 0; - new_thread->stack = stack; - new_thread->start_routine = start_routine; - new_thread->arg = arg; - - /* - * Write a magic value to the thread structure - * to help identify valid ones: - */ - new_thread->magic = PTHREAD_MAGIC; - - if (pattr->suspend == PTHREAD_CREATE_SUSPENDED) { - PTHREAD_NEW_STATE(new_thread,PS_SUSPENDED); - } else { - PTHREAD_NEW_STATE(new_thread,PS_RUNNING); - } - - /* Initialise the thread for signals: */ - new_thread->sigmask = _thread_run->sigmask; - - /* Initialise the jump buffer: */ - setjmp(new_thread->saved_jmp_buf); - - /* - * Set up new stack frame so that it looks like it - * returned from a longjmp() to the beginning of - * _thread_start(). - */ -#if defined(__FreeBSD__) -#if defined(__alpha__) - new_thread->saved_jmp_buf[0]._jb[2] = (long) _thread_start; - new_thread->saved_jmp_buf[0]._jb[4 + R_RA] = 0; - new_thread->saved_jmp_buf[0]._jb[4 + R_T12] = (long) _thread_start; -#else - new_thread->saved_jmp_buf[0]._jb[0] = (long) _thread_start; -#endif -#elif defined(__NetBSD__) -#if defined(__alpha__) - new_thread->saved_jmp_buf[2] = (long) _thread_start; - new_thread->saved_jmp_buf[4 + R_RA] = 0; - new_thread->saved_jmp_buf[4 + R_T12] = (long) _thread_start; -#else - new_thread->saved_jmp_buf[0] = (long) _thread_start; -#endif -#else -#error "Don't recognize this operating system!" -#endif - - /* The stack starts high and builds down: */ -#if defined(__FreeBSD__) -#if defined(__alpha__) - new_thread->saved_jmp_buf[0]._jb[4 + R_SP] = (long) new_thread->stack + pattr->stacksize_attr - sizeof(double); -#else - new_thread->saved_jmp_buf[0]._jb[2] = (int) (new_thread->stack + pattr->stacksize_attr - sizeof(double)); -#endif -#elif defined(__NetBSD__) -#if defined(__alpha__) - new_thread->saved_jmp_buf[4 + R_SP] = (long) new_thread->stack + pattr->stacksize_attr - sizeof(double); -#else - new_thread->saved_jmp_buf[2] = (long) new_thread->stack + pattr->stacksize_attr - sizeof(double); -#endif -#else -#error "Don't recognize this operating system!" -#endif - - /* Copy the thread attributes: */ - memcpy(&new_thread->attr, pattr, sizeof(struct pthread_attr)); - - /* - * Check if this thread is to inherit the scheduling - * attributes from its parent: - */ - if (new_thread->attr.flags & PTHREAD_INHERIT_SCHED) { - /* Copy the scheduling attributes: */ - new_thread->pthread_priority = _thread_run->pthread_priority; - new_thread->attr.prio = _thread_run->pthread_priority; - new_thread->attr.schedparam_policy = _thread_run->attr.schedparam_policy; - } else { - /* - * Use just the thread priority, leaving the - * other scheduling attributes as their - * default values: - */ - new_thread->pthread_priority = new_thread->attr.prio; - } - - /* Initialise the join queue for the new thread: */ - _thread_queue_init(&(new_thread->join_queue)); - - /* Initialise hooks in the thread structure: */ - new_thread->specific_data = NULL; - new_thread->cleanup = NULL; - new_thread->queue = NULL; - new_thread->qnxt = NULL; - new_thread->flags = 0; - - /* Lock the thread list: */ - _lock_thread_list(); - - /* - * Check if the garbage collector thread - * needs to be started. - */ - f_gc = (_thread_link_list == _thread_initial); - - /* Add the thread to the linked list of all threads: */ - new_thread->nxt = _thread_link_list; - _thread_link_list = new_thread; - - /* Unlock the thread list: */ - _unlock_thread_list(); - - /* Return a pointer to the thread structure: */ - (*thread) = new_thread; - - /* Schedule the new user thread: */ - _thread_kern_sched(NULL); - - /* - * Start a garbage collector thread - * if necessary. - */ - if (f_gc && pthread_create(&gc_thread,NULL, - _thread_gc,NULL) != 0) - PANIC("Can't create gc thread"); - } - } - - /* Return the status: */ - return (ret); -} - -void -_thread_start(void) -{ - /* We just left the scheduler via longjmp: */ - _thread_kern_in_sched = 0; - - /* Run the current thread's start routine with argument: */ - pthread_exit(_thread_run->start_routine(_thread_run->arg)); - - /* This point should never be reached. */ - PANIC("Thread has resumed after exit"); -} -#endif diff --git a/lib/libpthread/thread/thr_detach.c b/lib/libpthread/thread/thr_detach.c deleted file mode 100644 index da456bfbab90d..0000000000000 --- a/lib/libpthread/thread/thr_detach.c +++ /dev/null @@ -1,67 +0,0 @@ -/* - * Copyright (c) 1995 John Birrell <jb@cimlogic.com.au>. - * 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 John Birrell. - * 4. Neither the name of the author nor the names of any co-contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY JOHN BIRRELL 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 <errno.h> -#ifdef _THREAD_SAFE -#include <pthread.h> -#include "pthread_private.h" - -int -pthread_detach(pthread_t pthread) -{ - int rval = 0; - int status; - pthread_t next_thread; - - /* Check for invalid calling parameters: */ - if (pthread == NULL || pthread->magic != PTHREAD_MAGIC) - /* Return an invalid argument error: */ - rval = EINVAL; - - /* Check if the thread has not been detached: */ - else if ((pthread->attr.flags & PTHREAD_DETACHED) == 0) { - /* Flag the thread as detached: */ - pthread->attr.flags |= PTHREAD_DETACHED; - - /* Enter a loop to bring all threads off the join queue: */ - while ((next_thread = _thread_queue_deq(&pthread->join_queue)) != NULL) { - /* Make the thread run: */ - PTHREAD_NEW_STATE(next_thread,PS_RUNNING); - } - } else - /* Return an error: */ - rval = EINVAL; - - /* Return the completion status: */ - return (rval); -} -#endif diff --git a/lib/libpthread/thread/thr_equal.c b/lib/libpthread/thread/thr_equal.c deleted file mode 100644 index 99ffb5d8b7d7c..0000000000000 --- a/lib/libpthread/thread/thr_equal.c +++ /dev/null @@ -1,43 +0,0 @@ -/* - * Copyright (c) 1995 John Birrell <jb@cimlogic.com.au>. - * 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 John Birrell. - * 4. Neither the name of the author nor the names of any co-contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY JOHN BIRRELL 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. - * - */ -#ifdef _THREAD_SAFE -#include <pthread.h> -#include "pthread_private.h" - -int -pthread_equal(pthread_t t1, pthread_t t2) -{ - /* Compare the two thread pointers: */ - return (t1 == t2); -} -#endif diff --git a/lib/libpthread/thread/thr_exit.c b/lib/libpthread/thread/thr_exit.c deleted file mode 100644 index a5fc4001e4143..0000000000000 --- a/lib/libpthread/thread/thr_exit.c +++ /dev/null @@ -1,164 +0,0 @@ -/* - * Copyright (c) 1995-1998 John Birrell <jb@cimlogic.com.au> - * 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 John Birrell. - * 4. Neither the name of the author nor the names of any co-contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY JOHN BIRRELL 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 <errno.h> -#include <unistd.h> -#include <fcntl.h> -#include <string.h> -#ifdef _THREAD_SAFE -#include <pthread.h> -#include "pthread_private.h" - -void _exit(int status) -{ - int flags; - int i; - struct itimerval itimer; - - /* Disable the interval timer: */ - itimer.it_interval.tv_sec = 0; - itimer.it_interval.tv_usec = 0; - itimer.it_value.tv_sec = 0; - itimer.it_value.tv_usec = 0; - setitimer(ITIMER_VIRTUAL, &itimer, NULL); - - /* Close the pthread kernel pipe: */ - _thread_sys_close(_thread_kern_pipe[0]); - _thread_sys_close(_thread_kern_pipe[1]); - - /* - * Enter a loop to set all file descriptors to blocking - * if they were not created as non-blocking: - */ - for (i = 0; i < _thread_dtablesize; i++) { - /* Check if this file descriptor is in use: */ - if (_thread_fd_table[i] != NULL && - !(_thread_fd_table[i]->flags & O_NONBLOCK)) { - /* Get the current flags: */ - flags = _thread_sys_fcntl(i, F_GETFL, NULL); - /* Clear the nonblocking file descriptor flag: */ - _thread_sys_fcntl(i, F_SETFL, flags & ~O_NONBLOCK); - } - } - - /* Call the _exit syscall: */ - _thread_sys__exit(status); -} - -void -_thread_exit(char *fname, int lineno, char *string) -{ - char s[256]; - - /* Prepare an error message string: */ - strcpy(s, "Fatal error '"); - strcat(s, string); - strcat(s, "' at line ? "); - strcat(s, "in file "); - strcat(s, fname); - strcat(s, " (errno = ?"); - strcat(s, ")\n"); - - /* Write the string to the standard error file descriptor: */ - _thread_sys_write(2, s, strlen(s)); - - /* Force this process to exit: */ - _exit(1); -} - -void -pthread_exit(void *status) -{ - int sig; - long l; - pthread_t pthread; - - /* Check if this thread is already in the process of exiting: */ - if ((_thread_run->flags & PTHREAD_EXITING) != 0) { - char msg[128]; - snprintf(msg,"Thread %p has called pthread_exit() from a destructor. POSIX 1003.1 1996 s16.2.5.2 does not allow this!",_thread_run); - PANIC(msg); - } - - /* Flag this thread as exiting: */ - _thread_run->flags |= PTHREAD_EXITING; - - /* Save the return value: */ - _thread_run->ret = status; - - while (_thread_run->cleanup != NULL) { - pthread_cleanup_pop(1); - } - - if (_thread_run->attr.cleanup_attr != NULL) { - _thread_run->attr.cleanup_attr(_thread_run->attr.arg_attr); - } - /* Check if there is thread specific data: */ - if (_thread_run->specific_data != NULL) { - /* Run the thread-specific data destructors: */ - _thread_cleanupspecific(); - } - /* Check if there are any threads joined to this one: */ - while ((pthread = _thread_queue_deq(&(_thread_run->join_queue))) != NULL) { - /* Wake the joined thread and let it detach this thread: */ - PTHREAD_NEW_STATE(pthread,PS_RUNNING); - } - - /* - * Lock the garbage collector mutex to ensure that the garbage - * collector is not using the dead thread list. - */ - if (pthread_mutex_lock(&_gc_mutex) != 0) - PANIC("Cannot lock gc mutex"); - - /* Add this thread to the list of dead threads. */ - _thread_run->nxt_dead = _thread_dead; - _thread_dead = _thread_run; - - /* - * Signal the garbage collector thread that there is something - * to clean up. - */ - if (pthread_cond_signal(&_gc_cond) != 0) - PANIC("Cannot signal gc cond"); - - /* Unlock the garbage collector mutex: */ - if (pthread_mutex_unlock(&_gc_mutex) != 0) - PANIC("Cannot lock gc mutex"); - - /* This this thread will never be re-scheduled. */ - _thread_kern_sched_state(PS_DEAD, __FILE__, __LINE__); - - /* This point should not be reached. */ - PANIC("Dead thread has resumed"); -} -#endif diff --git a/lib/libpthread/thread/thr_fcntl.c b/lib/libpthread/thread/thr_fcntl.c deleted file mode 100644 index 6ea013afe5d77..0000000000000 --- a/lib/libpthread/thread/thr_fcntl.c +++ /dev/null @@ -1,141 +0,0 @@ -/* - * Copyright (c) 1995-1998 John Birrell <jb@cimlogic.com.au> - * 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 John Birrell. - * 4. Neither the name of the author nor the names of any co-contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY JOHN BIRRELL 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 <stdarg.h> -#include <unistd.h> -#include <fcntl.h> -#ifdef _THREAD_SAFE -#include <pthread.h> -#include "pthread_private.h" - -int -fcntl(int fd, int cmd,...) -{ - int flags = 0; - int nonblock; - int oldfd; - int ret; - va_list ap; - - /* Lock the file descriptor: */ - if ((ret = _FD_LOCK(fd, FD_RDWR, NULL)) == 0) { - /* Initialise the variable argument list: */ - va_start(ap, cmd); - - /* Process according to file control command type: */ - switch (cmd) { - /* Duplicate a file descriptor: */ - case F_DUPFD: - /* - * Get the file descriptor that the caller wants to - * use: - */ - oldfd = va_arg(ap, int); - - /* Initialise the file descriptor table entry: */ - if ((ret = _thread_sys_fcntl(fd, cmd, oldfd)) < 0) { - } - /* Initialise the file descriptor table entry: */ - else if (_thread_fd_table_init(ret) != 0) { - /* Quietly close the file: */ - _thread_sys_close(ret); - - /* Reset the file descriptor: */ - ret = -1; - } else { - /* - * Save the file open flags so that they can - * be checked later: - */ - _thread_fd_table[ret]->flags = _thread_fd_table[fd]->flags; - } - break; - case F_SETFD: - flags = va_arg(ap, int); - ret = _thread_sys_fcntl(fd, cmd, flags); - break; - case F_GETFD: - ret = _thread_sys_fcntl(fd, cmd, 0); - break; - case F_GETFL: - ret = _thread_fd_table[fd]->flags; - break; - case F_SETFL: - /* - * Get the file descriptor flags passed by the - * caller: - */ - flags = va_arg(ap, int); - - /* - * Check if the user wants a non-blocking file - * descriptor: - */ - nonblock = flags & O_NONBLOCK; - - /* Set the file descriptor flags: */ - if ((ret = _thread_sys_fcntl(fd, cmd, flags | O_NONBLOCK)) != 0) { - - /* Get the flags so that we behave like the kernel: */ - } else if ((flags = _thread_sys_fcntl(fd, - F_GETFL, 0)) == -1) { - /* Error getting flags: */ - ret = -1; - - /* - * Check if the file descriptor is non-blocking - * with respect to the user: - */ - } else if (nonblock) - /* A non-blocking descriptor: */ - _thread_fd_table[fd]->flags = flags | O_NONBLOCK; - else - /* Save the flags: */ - _thread_fd_table[fd]->flags = flags & ~O_NONBLOCK; - break; - default: - /* Might want to make va_arg use a union */ - ret = _thread_sys_fcntl(fd, cmd, va_arg(ap, void *)); - break; - } - - /* Free variable arguments: */ - va_end(ap); - - /* Unlock the file descriptor: */ - _FD_UNLOCK(fd, FD_RDWR); - } - - /* Return the completion status: */ - return (ret); -} -#endif diff --git a/lib/libpthread/thread/thr_find_thread.c b/lib/libpthread/thread/thr_find_thread.c deleted file mode 100644 index e4a59a0d83f61..0000000000000 --- a/lib/libpthread/thread/thr_find_thread.c +++ /dev/null @@ -1,102 +0,0 @@ -/* - * Copyright (c) 1998 John Birrell <jb@cimlogic.com.au>. - * 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 John Birrell. - * 4. Neither the name of the author nor the names of any co-contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY JOHN BIRRELL 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 <errno.h> -#ifdef _THREAD_SAFE -#include <pthread.h> -#include "pthread_private.h" - -/* Find a thread in the linked list of active threads: */ -int -_find_thread(pthread_t pthread) -{ - pthread_t pthread1; - - /* Check if the caller has specified an invalid thread: */ - if (pthread == NULL || pthread->magic != PTHREAD_MAGIC) - /* Invalid thread: */ - return(EINVAL); - - /* Lock the thread list: */ - _lock_thread_list(); - - /* Point to the first thread in the list: */ - pthread1 = _thread_link_list; - - /* Search for the thread to join to: */ - while (pthread1 != NULL && pthread1 != pthread) { - /* Point to the next thread: */ - pthread1 = pthread1->nxt; - } - - /* Unlock the thread list: */ - _unlock_thread_list(); - - /* Return zero if the thread exists: */ - return ((pthread1 != NULL) ? 0:ESRCH); -} - -/* Find a thread in the linked list of dead threads: */ -int -_find_dead_thread(pthread_t pthread) -{ - pthread_t pthread1; - - /* Check if the caller has specified an invalid thread: */ - if (pthread == NULL || pthread->magic != PTHREAD_MAGIC) - /* Invalid thread: */ - return(EINVAL); - - /* - * Lock the garbage collector mutex to ensure that the garbage - * collector is not using the dead thread list. - */ - if (pthread_mutex_lock(&_gc_mutex) != 0) - PANIC("Cannot lock gc mutex"); - - /* Point to the first thread in the list: */ - pthread1 = _thread_dead; - - /* Search for the thread to join to: */ - while (pthread1 != NULL && pthread1 != pthread) { - /* Point to the next thread: */ - pthread1 = pthread1->nxt_dead; - } - - /* Unlock the garbage collector mutex: */ - if (pthread_mutex_unlock(&_gc_mutex) != 0) - PANIC("Cannot lock gc mutex"); - - /* Return zero if the thread exists: */ - return ((pthread1 != NULL) ? 0:ESRCH); -} -#endif diff --git a/lib/libpthread/thread/thr_fork.c b/lib/libpthread/thread/thr_fork.c deleted file mode 100644 index 960c1dea7da35..0000000000000 --- a/lib/libpthread/thread/thr_fork.c +++ /dev/null @@ -1,131 +0,0 @@ -/* - * Copyright (c) 1995-1998 John Birrell <jb@cimlogic.com.au> - * 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 John Birrell. - * 4. Neither the name of the author nor the names of any co-contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY JOHN BIRRELL 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 <errno.h> -#include <string.h> -#include <unistd.h> -#include <fcntl.h> -#ifdef _THREAD_SAFE -#include <pthread.h> -#include "pthread_private.h" - -pid_t -fork(void) -{ - int flags; - pid_t ret; - pthread_t pthread; - pthread_t pthread_next; - - /* Lock the thread list: */ - _lock_thread_list(); - - /* Fork a new process: */ - if ((ret = _thread_sys_fork()) != 0) { - /* Parent process or error. Nothing to do here. */ - } else { - /* Close the pthread kernel pipe: */ - _thread_sys_close(_thread_kern_pipe[0]); - _thread_sys_close(_thread_kern_pipe[1]); - - /* Reset signals pending for the running thread: */ - _thread_run->sigpend = 0; - - /* - * Create a pipe that is written to by the signal handler to - * prevent signals being missed in calls to - * _thread_sys_select: - */ - if (_thread_sys_pipe(_thread_kern_pipe) != 0) { - /* Cannot create pipe, so abort: */ - PANIC("Cannot create pthread kernel pipe for forked process"); - } - /* Get the flags for the read pipe: */ - else if ((flags = _thread_sys_fcntl(_thread_kern_pipe[0], F_GETFL, NULL)) == -1) { - /* Abort this application: */ - abort(); - } - /* Make the read pipe non-blocking: */ - else if (_thread_sys_fcntl(_thread_kern_pipe[0], F_SETFL, flags | O_NONBLOCK) == -1) { - /* Abort this application: */ - abort(); - } - /* Get the flags for the write pipe: */ - else if ((flags = _thread_sys_fcntl(_thread_kern_pipe[1], F_GETFL, NULL)) == -1) { - /* Abort this application: */ - abort(); - } - /* Make the write pipe non-blocking: */ - else if (_thread_sys_fcntl(_thread_kern_pipe[1], F_SETFL, flags | O_NONBLOCK) == -1) { - /* Abort this application: */ - abort(); - } else { - /* Point to the first thread in the list: */ - pthread = _thread_link_list; - - /* - * Enter a loop to remove all threads other than - * the running thread from the thread list: - */ - while (pthread != NULL) { - pthread_next = pthread->nxt; - if (pthread == _thread_run) { - _thread_link_list = pthread; - pthread->nxt = NULL; - } else { - if (pthread->attr.stackaddr_attr == - NULL && pthread->stack != NULL) - /* - * Free the stack of the - * dead thread: - */ - free(pthread->stack); - - if (pthread->specific_data != NULL) - free(pthread->specific_data); - - free(pthread); - } - - /* Point to the next thread: */ - pthread = pthread_next; - } - } - } - - /* Unock the thread list: */ - _unlock_thread_list(); - - /* Return the process ID: */ - return (ret); -} -#endif diff --git a/lib/libpthread/thread/thr_fsync.c b/lib/libpthread/thread/thr_fsync.c deleted file mode 100644 index 9141d47119ea4..0000000000000 --- a/lib/libpthread/thread/thr_fsync.c +++ /dev/null @@ -1,49 +0,0 @@ -/* - * Copyright (c) 1995-1998 John Birrell <jb@cimlogic.com.au> - * 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 John Birrell. - * 4. Neither the name of the author nor the names of any co-contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY JOHN BIRRELL 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 <unistd.h> -#ifdef _THREAD_SAFE -#include <pthread.h> -#include "pthread_private.h" - -int -fsync(int fd) -{ - int ret; - - if ((ret = _FD_LOCK(fd, FD_RDWR, NULL)) == 0) { - ret = _thread_sys_fsync(fd); - _FD_UNLOCK(fd, FD_RDWR); - } - return (ret); -} -#endif diff --git a/lib/libpthread/thread/thr_gc.c b/lib/libpthread/thread/thr_gc.c deleted file mode 100644 index f297fa8a49530..0000000000000 --- a/lib/libpthread/thread/thr_gc.c +++ /dev/null @@ -1,272 +0,0 @@ -/* - * Copyright (c) 1998 John Birrell <jb@cimlogic.com.au> - * 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 John Birrell. - * 4. Neither the name of the author nor the names of any co-contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY JOHN BIRRELL 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. - * - * $Id: uthread_gc.c,v 1.1 1998/09/30 06:36:56 jb Exp $ - * - * Garbage collector thread. Frees memory allocated for dead threads. - * - */ -#include <errno.h> -#include <time.h> -#include <unistd.h> -#include <sys/types.h> -#include <pthread.h> -#include "pthread_private.h" - -pthread_addr_t -_thread_gc(pthread_addr_t arg) -{ - int f_debug; - int f_done = 0; - int ret; - pthread_t pthread; - pthread_t pthread_cln; - pthread_t pthread_nxt; - pthread_t pthread_prv; - struct timespec abstime; - void *p_stack; - - /* Set a debug flag based on an environment variable. */ - f_debug = (getenv("LIBC_R_DEBUG") != NULL); - - /* Set the name of this thread. */ - pthread_set_name_np(_thread_run,"GC"); - - while (!f_done) { - /* Check if debugging this application. */ - if (f_debug) - /* Dump thread info to file. */ - _thread_dump_info(); - - /* Lock the thread list: */ - _lock_thread_list(); - - /* Check if this is the last running thread: */ - if (_thread_link_list == _thread_run && - _thread_link_list->nxt == NULL) - /* - * This is the last thread, so it can exit - * now. - */ - f_done = 1; - - /* Unlock the thread list: */ - _unlock_thread_list(); - - /* - * Lock the garbage collector mutex which ensures that - * this thread sees another thread exit: - */ - if (pthread_mutex_lock(&_gc_mutex) != 0) - PANIC("Cannot lock gc mutex"); - - /* No stack of thread structure to free yet: */ - p_stack = NULL; - pthread_cln = NULL; - - /* Point to the first dead thread (if there are any): */ - pthread = _thread_dead; - - /* There is no previous dead thread: */ - pthread_prv = NULL; - - /* - * Enter a loop to search for the first dead thread that - * has memory to free. - */ - while (p_stack == NULL && pthread_cln == NULL && - pthread != NULL) { - /* Save a pointer to the next thread: */ - pthread_nxt = pthread->nxt_dead; - - /* Check if the initial thread: */ - if (pthread == _thread_initial) - /* Don't destroy the initial thread. */ - pthread_prv = pthread; - - /* - * Check if this thread has detached: - */ - else if ((pthread->attr.flags & - PTHREAD_DETACHED) != 0) { - /* - * Check if there is no previous dead - * thread: - */ - if (pthread_prv == NULL) - /* - * The dead thread is at the head - * of the list: - */ - _thread_dead = pthread_nxt; - else - /* - * The dead thread is not at the - * head of the list: - */ - pthread_prv->nxt_dead = - pthread->nxt_dead; - - /* - * Check if the stack was not specified by - * the caller to pthread_create and has not - * been destroyed yet: - */ - if (pthread->attr.stackaddr_attr == NULL && - pthread->stack != NULL) { - /* - * Point to the stack that must - * be freed outside the locks: - */ - p_stack = pthread->stack; - } - - /* - * Point to the thread structure that must - * be freed outside the locks: - */ - pthread_cln = pthread; - } else { - /* - * This thread has not detached, so do - * not destroy it: - */ - pthread_prv = pthread; - - /* - * Check if the stack was not specified by - * the caller to pthread_create and has not - * been destroyed yet: - */ - if (pthread->attr.stackaddr_attr == NULL && - pthread->stack != NULL) { - /* - * Point to the stack that must - * be freed outside the locks: - */ - p_stack = pthread->stack; - - /* - * NULL the stack pointer now - * that the memory has been freed: - */ - pthread->stack = NULL; - } - } - - /* Point to the next thread: */ - pthread = pthread_nxt; - } - - /* - * Check if this is not the last thread and there is no - * memory to free this time around. - */ - if (!f_done && p_stack == NULL && pthread_cln == NULL) { - /* Get the current time. */ - if (clock_gettime(CLOCK_REALTIME,&abstime) != 0) - PANIC("gc cannot get time"); - - /* - * Do a backup poll in 10 seconds if no threads - * die before then. - */ - abstime.tv_sec += 10; - - /* - * Wait for a signal from a dying thread or a - * timeout (for a backup poll). - */ - if ((ret = pthread_cond_timedwait(&_gc_cond, - &_gc_mutex, &abstime)) != 0 && ret != ETIMEDOUT) - PANIC("gc cannot wait for a signal"); - } - - /* Unlock the garbage collector mutex: */ - if (pthread_mutex_unlock(&_gc_mutex) != 0) - PANIC("Cannot unlock gc mutex"); - - /* - * If there is memory to free, do it now. The call to - * free() might block, so this must be done outside the - * locks. - */ - if (p_stack != NULL) - free(p_stack); - if (pthread_cln != NULL) { - /* Lock the thread list: */ - _lock_thread_list(); - - /* - * Check if the thread is at the head of the - * linked list. - */ - if (_thread_link_list == pthread_cln) - /* There is no previous thread: */ - _thread_link_list = pthread_cln->nxt; - else { - /* Point to the first thread in the list: */ - pthread = _thread_link_list; - - /* - * Enter a loop to find the thread in the - * linked list before the thread that is - * about to be freed. - */ - while (pthread != NULL && - pthread->nxt != pthread_cln) - /* Point to the next thread: */ - pthread = pthread->nxt; - - /* Check that a previous thread was found: */ - if (pthread != NULL) { - /* - * Point the previous thread to - * the one after the thread being - * freed: - */ - pthread->nxt = pthread_cln->nxt; - } - } - - /* Unlock the thread list: */ - _unlock_thread_list(); - - /* - * Free the memory allocated for the thread - * structure. - */ - free(pthread_cln); - } - - } - return (NULL); -} diff --git a/lib/libpthread/thread/thr_getprio.c b/lib/libpthread/thread/thr_getprio.c deleted file mode 100644 index 708b8f1adf75a..0000000000000 --- a/lib/libpthread/thread/thr_getprio.c +++ /dev/null @@ -1,56 +0,0 @@ -/* - * Copyright (c) 1995 John Birrell <jb@cimlogic.com.au>. - * 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 John Birrell. - * 4. Neither the name of the author nor the names of any co-contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY JOHN BIRRELL 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 <errno.h> -#ifdef _THREAD_SAFE -#include <pthread.h> -#include "pthread_private.h" - -int -pthread_getprio(pthread_t pthread) -{ - int ret; - - /* Find the thread in the list of active threads: */ - if ((ret = _find_thread(pthread)) == 0) - /* Get the thread priority: */ - ret = pthread->pthread_priority; - else { - /* Invalid thread: */ - errno = ret; - ret = -1; - } - - /* Return the thread priority or an error status: */ - return (ret); -} -#endif diff --git a/lib/libpthread/thread/thr_info.c b/lib/libpthread/thread/thr_info.c deleted file mode 100644 index f66dd2d6ddcf4..0000000000000 --- a/lib/libpthread/thread/thr_info.c +++ /dev/null @@ -1,237 +0,0 @@ -/* - * Copyright (c) 1995-1998 John Birrell <jb@cimlogic.com.au> - * 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 John Birrell. - * 4. Neither the name of the author nor the names of any co-contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY JOHN BIRRELL 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 <stdio.h> -#include <fcntl.h> -#include <string.h> -#include <unistd.h> -#ifdef _THREAD_SAFE -#include <pthread.h> -#include <errno.h> -#include "pthread_private.h" - -struct s_thread_info { - enum pthread_state state; - char *name; -}; - -/* Static variables: */ -static const struct s_thread_info thread_info[] = { - {PS_RUNNING , "Running"}, - {PS_SIGTHREAD , "Waiting on signal thread"}, - {PS_MUTEX_WAIT , "Waiting on a mutex"}, - {PS_COND_WAIT , "Waiting on a condition variable"}, - {PS_FDLR_WAIT , "Waiting for a file read lock"}, - {PS_FDLW_WAIT , "Waiting for a file write lock"}, - {PS_FDR_WAIT , "Waiting for read"}, - {PS_FDW_WAIT , "Waiting for write"}, - {PS_FILE_WAIT , "Waiting for FILE lock"}, - {PS_SELECT_WAIT , "Waiting on select"}, - {PS_SLEEP_WAIT , "Sleeping"}, - {PS_WAIT_WAIT , "Waiting process"}, - {PS_SIGSUSPEND , "Suspended, waiting for a signal"}, - {PS_SIGWAIT , "Waiting for a signal"}, - {PS_JOIN , "Waiting to join"}, - {PS_SUSPENDED , "Suspended"}, - {PS_DEAD , "Dead"}, - {PS_STATE_MAX , "Not a real state!"} -}; - -void -_thread_dump_info(void) -{ - char s[512]; - int fd; - int i; - int j; - pthread_t pthread; - char tmpfile[128]; - - for (i = 0; i < 100000; i++) { - snprintf(tmpfile, sizeof(tmpfile), "/tmp/uthread.dump.%u.%i", - getpid(), i); - /* Open the dump file for append and create it if necessary: */ - if ((fd = _thread_sys_open(tmpfile, O_RDWR | O_CREAT | O_EXCL, - 0666)) < 0) { - /* Can't open the dump file. */ - if (errno == EEXIST) - continue; - /* - * We only need to continue in case of - * EEXIT error. Most other error - * codes means that we will fail all - * the times. - */ - return; - } else { - break; - } - } - if (i==100000) { - /* all 100000 possibilities are in use :( */ - return; - } else { - /* Output a header for active threads: */ - strcpy(s, "\n\n=============\nACTIVE THREADS\n\n"); - _thread_sys_write(fd, s, strlen(s)); - - /* Enter a loop to report each thread in the global list: */ - for (pthread = _thread_link_list; pthread != NULL; - pthread = pthread->nxt) { - /* Find the state: */ - for (j = 0; j < (sizeof(thread_info) / - sizeof(struct s_thread_info)) - 1; j++) - if (thread_info[j].state == pthread->state) - break; - /* Output a record for the current thread: */ - snprintf(s, sizeof(s), - "--------------------\nThread %p (%s) prio %3d state %s [%s:%d]\n", - pthread, (pthread->name == NULL) ? - "":pthread->name, pthread->pthread_priority, - thread_info[j].name, - pthread->fname,pthread->lineno); - _thread_sys_write(fd, s, strlen(s)); - - /* Check if this is the running thread: */ - if (pthread == _thread_run) { - /* Output a record for the running thread: */ - strcpy(s, "This is the running thread\n"); - _thread_sys_write(fd, s, strlen(s)); - } - /* Check if this is the initial thread: */ - if (pthread == _thread_initial) { - /* Output a record for the initial thread: */ - strcpy(s, "This is the initial thread\n"); - _thread_sys_write(fd, s, strlen(s)); - } - /* Process according to thread state: */ - switch (pthread->state) { - /* File descriptor read lock wait: */ - case PS_FDLR_WAIT: - case PS_FDLW_WAIT: - case PS_FDR_WAIT: - case PS_FDW_WAIT: - /* Write the lock details: */ - snprintf(s, sizeof(s), "fd %d[%s:%d]", - pthread->data.fd.fd, - pthread->data.fd.fname, - pthread->data.fd.branch); - _thread_sys_write(fd, s, strlen(s)); - snprintf(s, sizeof(s), "owner %pr/%pw\n", - _thread_fd_table[pthread->data.fd.fd]->r_owner, - _thread_fd_table[pthread->data.fd.fd]->w_owner); - _thread_sys_write(fd, s, strlen(s)); - break; - case PS_SIGWAIT: - snprintf(s, sizeof(s), "sigmask 0x%08lx\n", - (unsigned long)pthread->sigmask); - _thread_sys_write(fd, s, strlen(s)); - break; - - /* - * Trap other states that are not explicitly - * coded to dump information: - */ - default: - /* Nothing to do here. */ - break; - } - } - - /* Check if there are no dead threads: */ - if (_thread_dead == NULL) { - /* Output a record: */ - strcpy(s, "\n\nTHERE ARE NO DEAD THREADS\n"); - _thread_sys_write(fd, s, strlen(s)); - } else { - /* Output a header for dead threads: */ - strcpy(s, "\n\nDEAD THREADS\n\n"); - _thread_sys_write(fd, s, strlen(s)); - - /* - * Enter a loop to report each thread in the global - * dead thread list: - */ - for (pthread = _thread_dead; pthread != NULL; - pthread = pthread->nxt_dead) { - /* Output a record for the current thread: */ - snprintf(s, sizeof(s), - "Thread %p prio %3d [%s:%d]\n", - pthread, pthread->pthread_priority, - pthread->fname,pthread->lineno); - _thread_sys_write(fd, s, strlen(s)); - } - } - - /* Output a header for file descriptors: */ - snprintf(s, sizeof(s), "\n\n=============\nFILE DESCRIPTOR TABLE (table size %d)\n\n",_thread_dtablesize); - _thread_sys_write(fd, s, strlen(s)); - - /* Enter a loop to report file descriptor lock usage: */ - for (i = 0; i < _thread_dtablesize; i++) { - /* - * Check if memory is allocated for this file - * descriptor: - */ - if (_thread_fd_table[i] != NULL) { - /* Report the file descriptor lock status: */ - snprintf(s, sizeof(s), - "fd[%3d] read owner %p count %d [%s:%d]\n write owner %p count %d [%s:%d]\n", - i, - _thread_fd_table[i]->r_owner, - _thread_fd_table[i]->r_lockcount, - _thread_fd_table[i]->r_fname, - _thread_fd_table[i]->r_lineno, - _thread_fd_table[i]->w_owner, - _thread_fd_table[i]->w_lockcount, - _thread_fd_table[i]->w_fname, - _thread_fd_table[i]->w_lineno); - _thread_sys_write(fd, s, strlen(s)); - } - } - - /* Close the dump file: */ - _thread_sys_close(fd); - } - return; -} - -/* Set the thread name for debug: */ -void -pthread_set_name_np(pthread_t thread, char *name) -{ - /* Check if the caller has specified a valid thread: */ - if (thread != NULL && thread->magic == PTHREAD_MAGIC) - thread->name = strdup(name); - return; -} -#endif diff --git a/lib/libpthread/thread/thr_init.c b/lib/libpthread/thread/thr_init.c deleted file mode 100644 index 50f3bef8973a7..0000000000000 --- a/lib/libpthread/thread/thr_init.c +++ /dev/null @@ -1,284 +0,0 @@ -/* - * Copyright (c) 1995-1998 John Birrell <jb@cimlogic.com.au> - * 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 John Birrell. - * 4. Neither the name of the author nor the names of any co-contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY JOHN BIRRELL 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. - * - */ - -/* Allocate space for global thread variables here: */ -#define GLOBAL_PTHREAD_PRIVATE - -#include <errno.h> -#include <stdlib.h> -#include <string.h> -#include <fcntl.h> -#include <paths.h> -#include <unistd.h> -#include <sys/time.h> -#include <sys/ttycom.h> -#ifdef _THREAD_SAFE -#include <machine/reg.h> -#include <pthread.h> -#include "pthread_private.h" - -#ifdef GCC_2_8_MADE_THREAD_AWARE -typedef void *** (*dynamic_handler_allocator)(); -extern void __set_dynamic_handler_allocator(dynamic_handler_allocator); - -static pthread_key_t except_head_key; - -typedef struct { - void **__dynamic_handler_chain; - void *top_elt[2]; -} except_struct; - -static void ***dynamic_allocator_handler_fn() -{ - except_struct *dh = (except_struct *)pthread_getspecific(except_head_key); - - if(dh == NULL) { - dh = (except_struct *)malloc( sizeof(except_struct) ); - memset(dh, '\0', sizeof(except_struct)); - dh->__dynamic_handler_chain= dh->top_elt; - pthread_setspecific(except_head_key, (void *)dh); - } - return &dh->__dynamic_handler_chain; -} -#endif /* GCC_2_8_MADE_THREAD_AWARE */ - -/* - * Threaded process initialization - */ -void -_thread_init(void) -{ - int fd; - int flags; - int i; - struct sigaction act; - - /* Check if this function has already been called: */ - if (_thread_initial) - /* Only initialise the threaded application once. */ - return; - - /* - * Check for the special case of this process running as - * or in place of init as pid = 1: - */ - if (getpid() == 1) { - /* - * Setup a new session for this process which is - * assumed to be running as root. - */ - if (setsid() == -1) - PANIC("Can't set session ID"); - if (revoke(_PATH_CONSOLE) != 0) - PANIC("Can't revoke console"); - if ((fd = _thread_sys_open(_PATH_CONSOLE, O_RDWR)) < 0) - PANIC("Can't open console"); - if (setlogin("root") == -1) - PANIC("Can't set login to root"); - if (_thread_sys_ioctl(fd,TIOCSCTTY, (char *) NULL) == -1) - PANIC("Can't set controlling terminal"); - if (_thread_sys_dup2(fd,0) == -1 || - _thread_sys_dup2(fd,1) == -1 || - _thread_sys_dup2(fd,2) == -1) - PANIC("Can't dup2"); - } - - /* Get the standard I/O flags before messing with them : */ - for (i = 0; i < 3; i++) - if ((_pthread_stdio_flags[i] = - _thread_sys_fcntl(i,F_GETFL, NULL)) == -1) - PANIC("Cannot get stdio flags"); - - /* - * Create a pipe that is written to by the signal handler to prevent - * signals being missed in calls to _select: - */ - if (_thread_sys_pipe(_thread_kern_pipe) != 0) { - /* Cannot create pipe, so abort: */ - PANIC("Cannot create kernel pipe"); - } - /* Get the flags for the read pipe: */ - else if ((flags = _thread_sys_fcntl(_thread_kern_pipe[0], F_GETFL, NULL)) == -1) { - /* Abort this application: */ - PANIC("Cannot get kernel read pipe flags"); - } - /* Make the read pipe non-blocking: */ - else if (_thread_sys_fcntl(_thread_kern_pipe[0], F_SETFL, flags | O_NONBLOCK) == -1) { - /* Abort this application: */ - PANIC("Cannot make kernel read pipe non-blocking"); - } - /* Get the flags for the write pipe: */ - else if ((flags = _thread_sys_fcntl(_thread_kern_pipe[1], F_GETFL, NULL)) == -1) { - /* Abort this application: */ - PANIC("Cannot get kernel write pipe flags"); - } - /* Make the write pipe non-blocking: */ - else if (_thread_sys_fcntl(_thread_kern_pipe[1], F_SETFL, flags | O_NONBLOCK) == -1) { - /* Abort this application: */ - PANIC("Cannot get kernel write pipe flags"); - } - /* Allocate memory for the thread structure of the initial thread: */ - else if ((_thread_initial = (pthread_t) malloc(sizeof(struct pthread))) == NULL) { - /* - * Insufficient memory to initialise this application, so - * abort: - */ - PANIC("Cannot allocate memory for initial thread"); - } else { - /* Zero the global kernel thread structure: */ - memset(&_thread_kern_thread, 0, sizeof(struct pthread)); - memset(_thread_initial, 0, sizeof(struct pthread)); - - /* Default the priority of the initial thread: */ - _thread_initial->pthread_priority = PTHREAD_DEFAULT_PRIORITY; - - /* Initialise the state of the initial thread: */ - _thread_initial->state = PS_RUNNING; - - /* Initialise the queue: */ - _thread_queue_init(&(_thread_initial->join_queue)); - - /* Initialise the rest of the fields: */ - _thread_initial->specific_data = NULL; - _thread_initial->cleanup = NULL; - _thread_initial->queue = NULL; - _thread_initial->qnxt = NULL; - _thread_initial->nxt = NULL; - _thread_initial->flags = 0; - _thread_initial->error = 0; - _thread_link_list = _thread_initial; - _thread_run = _thread_initial; - - /* Initialise the global signal action structure: */ - sigfillset(&act.sa_mask); - act.sa_handler = (void (*) ()) _thread_sig_handler; - act.sa_flags = 0; - - /* Enter a loop to get the existing signal status: */ - for (i = 1; i < NSIG; i++) { - /* Check for signals which cannot be trapped: */ - if (i == SIGKILL || i == SIGSTOP) { - } - - /* Get the signal handler details: */ - else if (_thread_sys_sigaction(i, NULL, - &_thread_sigact[i - 1]) != 0) { - /* - * Abort this process if signal - * initialisation fails: - */ - PANIC("Cannot read signal handler info"); - } - } - - /* - * Install the signal handler for the most important - * signals that the user-thread kernel needs. Actually - * SIGINFO isn't really needed, but it is nice to have. - */ - if (_thread_sys_sigaction(SIGVTALRM, &act, NULL) != 0 || - _thread_sys_sigaction(SIGINFO , &act, NULL) != 0 || - _thread_sys_sigaction(SIGCHLD , &act, NULL) != 0) { - /* - * Abort this process if signal initialisation fails: - */ - PANIC("Cannot initialise signal handler"); - } - - /* Get the table size: */ - if ((_thread_dtablesize = getdtablesize()) < 0) { - /* - * Cannot get the system defined table size, so abort - * this process. - */ - PANIC("Cannot get dtablesize"); - } - /* Allocate memory for the file descriptor table: */ - if ((_thread_fd_table = (struct fd_table_entry **) malloc(sizeof(struct fd_table_entry *) * _thread_dtablesize)) == NULL) { - /* - * Cannot allocate memory for the file descriptor - * table, so abort this process. - */ - PANIC("Cannot allocate memory for file descriptor table"); - } else { - /* - * Enter a loop to initialise the file descriptor - * table: - */ - for (i = 0; i < _thread_dtablesize; i++) { - /* Initialise the file descriptor table: */ - _thread_fd_table[i] = NULL; - } - } - } - -#ifdef GCC_2_8_MADE_THREAD_AWARE - /* Create the thread-specific data for the exception linked list. */ - if(pthread_key_create(&except_head_key, NULL) != 0) - PANIC("Failed to create thread specific execption head"); - - /* Setup the gcc exception handler per thread. */ - __set_dynamic_handler_allocator( dynamic_allocator_handler_fn ); -#endif /* GCC_2_8_MADE_THREAD_AWARE */ - - /* Initialise the garbage collector mutex and condition variable. */ - if (pthread_mutex_init(&_gc_mutex,NULL) != 0 || - pthread_cond_init(&_gc_cond,NULL) != 0) - PANIC("Failed to initialise garbage collector mutex or condvar"); - - return; -} - -/* - * Special start up code for NetBSD/Alpha - */ -#if defined(__NetBSD__) && defined(__alpha__) -int -main(int argc, char *argv[], char *env); - -int -_thread_main(int argc, char *argv[], char *env) -{ - _thread_init(); - return (main(argc, argv, env)); -} -#endif -#else -/* - * A stub for non-threaded programs. - */ -void -_thread_init(void) -{ -} -#endif diff --git a/lib/libpthread/thread/thr_join.c b/lib/libpthread/thread/thr_join.c deleted file mode 100644 index 2043b76f5d241..0000000000000 --- a/lib/libpthread/thread/thr_join.c +++ /dev/null @@ -1,98 +0,0 @@ -/* - * Copyright (c) 1995 John Birrell <jb@cimlogic.com.au>. - * 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 John Birrell. - * 4. Neither the name of the author nor the names of any co-contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY JOHN BIRRELL 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 <errno.h> -#ifdef _THREAD_SAFE -#include <pthread.h> -#include "pthread_private.h" - -int -pthread_join(pthread_t pthread, void **thread_return) -{ - int ret = 0; - pthread_t pthread1 = NULL; - - /* Check if the caller has specified an invalid thread: */ - if (pthread == NULL || pthread->magic != PTHREAD_MAGIC) - /* Invalid thread: */ - return(EINVAL); - - /* Check if the caller has specified itself: */ - if (pthread == _thread_run) - /* Avoid a deadlock condition: */ - return(EDEADLK); - - /* - * Find the thread in the list of active threads or in the - * list of dead threads: - */ - if (_find_thread(pthread) == 0 || - _find_dead_thread(pthread) == 0) - pthread1 = pthread; - - if (pthread1 == NULL) - /* Return an error: */ - ret = ESRCH; - - /* Check if this thread has been detached: */ - else if ((pthread->attr.flags & PTHREAD_DETACHED) != 0) - /* Return an error: */ - ret = ESRCH; - - /* Check if the thread is not dead: */ - else if (pthread->state != PS_DEAD) { - /* Add the running thread to the join queue: */ - _thread_queue_enq(&(pthread->join_queue), _thread_run); - - /* Schedule the next thread: */ - _thread_kern_sched_state(PS_JOIN, __FILE__, __LINE__); - - /* Check if the thread is not detached: */ - if ((pthread->attr.flags & PTHREAD_DETACHED) == 0) { - /* Check if the return value is required: */ - if (thread_return) - /* Return the thread's return value: */ - *thread_return = pthread->ret; - } - else - /* Return an error: */ - ret = ESRCH; - - /* Check if the return value is required: */ - } else if (thread_return != NULL) - /* Return the thread's return value: */ - *thread_return = pthread->ret; - - /* Return the completion status: */ - return (ret); -} -#endif diff --git a/lib/libpthread/thread/thr_kern.c b/lib/libpthread/thread/thr_kern.c deleted file mode 100644 index 3a6966bad5bf3..0000000000000 --- a/lib/libpthread/thread/thr_kern.c +++ /dev/null @@ -1,1323 +0,0 @@ -/* - * Copyright (c) 1995-1998 John Birrell <jb@cimlogic.com.au> - * 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 John Birrell. - * 4. Neither the name of the author nor the names of any co-contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY JOHN BIRRELL 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. - * - * $Id: uthread_kern.c,v 1.14 1998/10/09 19:01:30 dt Exp $ - * - */ -#include <errno.h> -#include <stdlib.h> -#include <stdarg.h> -#include <string.h> -#include <unistd.h> -#include <setjmp.h> -#include <sys/types.h> -#include <sys/stat.h> -#include <sys/time.h> -#include <sys/socket.h> -#include <sys/uio.h> -#include <sys/syscall.h> -#include <fcntl.h> -#ifdef _THREAD_SAFE -#include <pthread.h> -#include "pthread_private.h" - -/* Static function prototype definitions: */ -static void -_thread_kern_select(int wait_reqd); - -void -_thread_kern_sched(struct sigcontext * scp) -{ -#ifndef __alpha__ - char *fdata; -#endif - int prio = -1; - pthread_t pthread; - pthread_t pthread_h = NULL; - pthread_t pthread_s = NULL; - struct itimerval itimer; - struct timespec ts; - struct timespec ts1; - struct timeval tv; - struct timeval tv1; - - /* - * Flag the pthread kernel as executing scheduler code - * to avoid a scheduler signal from interrupting this - * execution and calling the scheduler again. - */ - _thread_kern_in_sched = 1; - - /* Check if this function was called from the signal handler: */ - if (scp != NULL) { - /* - * Copy the signal context to the current thread's jump - * buffer: - */ - memcpy(&_thread_run->saved_sigcontext, scp, sizeof(_thread_run->saved_sigcontext)); - -#ifndef __alpha__ - /* Point to the floating point data in the running thread: */ - fdata = _thread_run->saved_fp; - - /* Save the floating point data: */ -__asm__("fnsave %0": :"m"(*fdata)); -#endif - - /* Flag the signal context as the last state saved: */ - _thread_run->sig_saved = 1; - } - /* Save the state of the current thread: */ - else if (setjmp(_thread_run->saved_jmp_buf) != 0) { - /* - * This point is reached when a longjmp() is called to - * restore the state of a thread. - * - * This is the normal way out of the scheduler. - */ - _thread_kern_in_sched = 0; - - /* - * There might be pending signals for this thread, so - * dispatch any that aren't blocked: - */ - _dispatch_signals(); - return; - } else - /* Flag the jump buffer was the last state saved: */ - _thread_run->sig_saved = 0; - - /* - * Enter a the scheduling loop that finds the next thread that is - * ready to run. This loop completes when there are no more threads - * in the global list or when a thread has its state restored by - * either a sigreturn (if the state was saved as a sigcontext) or a - * longjmp (if the state was saved by a setjmp). - */ - while (_thread_link_list != NULL) { - /* Get the current time of day: */ - gettimeofday(&tv, NULL); - TIMEVAL_TO_TIMESPEC(&tv, &ts); - - /* - * Poll file descriptors to update the state of threads - * waiting on file I/O where data may be available: - */ - _thread_kern_select(0); - - /* - * Enter a loop to look for sleeping threads that are ready: - */ - for (pthread = _thread_link_list; pthread != NULL; - pthread = pthread->nxt) { - /* Check if this thread is to timeout: */ - if (pthread->state == PS_COND_WAIT || - pthread->state == PS_SLEEP_WAIT || - pthread->state == PS_FDR_WAIT || - pthread->state == PS_FDW_WAIT || - pthread->state == PS_SELECT_WAIT) { - /* Check if this thread is to wait forever: */ - if (pthread->wakeup_time.tv_sec == -1) { - } - /* - * Check if this thread is to wakeup - * immediately or if it is past its wakeup - * time: - */ - else if ((pthread->wakeup_time.tv_sec == 0 && - pthread->wakeup_time.tv_nsec == 0) || - (ts.tv_sec > pthread->wakeup_time.tv_sec) || - ((ts.tv_sec == pthread->wakeup_time.tv_sec) && - (ts.tv_nsec >= pthread->wakeup_time.tv_nsec))) { - /* - * Check if this thread is waiting on - * select: - */ - if (pthread->state == PS_SELECT_WAIT) { - /* - * The select has timed out, - * so zero the file - * descriptor sets: - */ - FD_ZERO(&pthread->data.select_data->readfds); - FD_ZERO(&pthread->data.select_data->writefds); - FD_ZERO(&pthread->data.select_data->exceptfds); - pthread->data.select_data->nfds = 0; - } - /* - * Return an error as an interrupted - * wait: - */ - _thread_seterrno(pthread, EINTR); - - /* - * Flag the timeout in the thread - * structure: - */ - pthread->timeout = 1; - - /* - * Change the threads state to allow - * it to be restarted: - */ - PTHREAD_NEW_STATE(pthread,PS_RUNNING); - } - } - } - - /* Check if there is a current thread: */ - if (_thread_run != &_thread_kern_thread) { - /* - * Save the current time as the time that the thread - * became inactive: - */ - _thread_run->last_inactive.tv_sec = tv.tv_sec; - _thread_run->last_inactive.tv_usec = tv.tv_usec; - - /* - * Accumulate the number of microseconds that this - * thread has run for: - */ - if (_thread_run->slice_usec != -1) { - _thread_run->slice_usec += (_thread_run->last_inactive.tv_sec - - _thread_run->last_active.tv_sec) * 1000000 + - _thread_run->last_inactive.tv_usec - - _thread_run->last_active.tv_usec; - } - - /* - * Check if this thread has reached its allocated - * time slice period: - */ - if (_thread_run->slice_usec > TIMESLICE_USEC) { - /* - * Flag the allocated time slice period as - * up: - */ - _thread_run->slice_usec = -1; - } - } - /* Check if an incremental priority update is required: */ - if (((tv.tv_sec - kern_inc_prio_time.tv_sec) * 1000000 + - tv.tv_usec - kern_inc_prio_time.tv_usec) > INC_PRIO_USEC) { - /* - * Enter a loop to look for run-enabled threads that - * have not run since the last time that an - * incremental priority update was performed: - */ - for (pthread = _thread_link_list; pthread != NULL; pthread = pthread->nxt) { - /* Check if this thread is unable to run: */ - if (pthread->state != PS_RUNNING) { - } - /* - * Check if the last time that this thread - * was run (as indicated by the last time it - * became inactive) is before the time that - * the last incremental priority check was - * made: - */ - else if (timercmp(&pthread->last_inactive, &kern_inc_prio_time, <)) { - /* - * Increment the incremental priority - * for this thread in the hope that - * it will eventually get a chance to - * run: - */ - (pthread->inc_prio)++; - } - } - - /* Save the new incremental priority update time: */ - kern_inc_prio_time.tv_sec = tv.tv_sec; - kern_inc_prio_time.tv_usec = tv.tv_usec; - } - /* - * Enter a loop to look for the first thread of the highest - * priority that is ready to run: - */ - for (pthread = _thread_link_list; pthread != NULL; pthread = pthread->nxt) { - /* Check if the current thread is unable to run: */ - if (pthread->state != PS_RUNNING) { - } - /* - * Check if no run-enabled thread has been seen or if - * the current thread has a priority higher than the - * highest seen so far: - */ - else if (pthread_h == NULL || (pthread->pthread_priority + pthread->inc_prio) > prio) { - /* - * Save this thread as the highest priority - * thread seen so far: - */ - pthread_h = pthread; - prio = pthread->pthread_priority + pthread->inc_prio; - } - } - - /* - * Enter a loop to look for a thread that: 1. Is run-enabled. - * 2. Has the required agregate priority. 3. Has not been - * allocated its allocated time slice. 4. Became inactive - * least recently. - */ - for (pthread = _thread_link_list; pthread != NULL; pthread = pthread->nxt) { - /* Check if the current thread is unable to run: */ - if (pthread->state != PS_RUNNING) { - /* Ignore threads that are not ready to run. */ - } - - /* - * Check if the current thread as an agregate - * priority not equal to the highest priority found - * above: - */ - else if ((pthread->pthread_priority + pthread->inc_prio) != prio) { - /* - * Ignore threads which have lower agregate - * priority. - */ - } - - /* - * Check if the current thread reached its time slice - * allocation last time it ran (or if it has not run - * yet): - */ - else if (pthread->slice_usec == -1) { - } - - /* - * Check if an eligible thread has not been found - * yet, or if the current thread has an inactive time - * earlier than the last one seen: - */ - else if (pthread_s == NULL || timercmp(&pthread->last_inactive, &tv1, <)) { - /* - * Save the pointer to the current thread as - * the most eligible thread seen so far: - */ - pthread_s = pthread; - - /* - * Save the time that the selected thread - * became inactive: - */ - tv1.tv_sec = pthread->last_inactive.tv_sec; - tv1.tv_usec = pthread->last_inactive.tv_usec; - } - } - - /* - * Check if no thread was selected according to incomplete - * time slice allocation: - */ - if (pthread_s == NULL) { - /* - * Enter a loop to look for any other thread that: 1. - * Is run-enabled. 2. Has the required agregate - * priority. 3. Became inactive least recently. - */ - for (pthread = _thread_link_list; pthread != NULL; pthread = pthread->nxt) { - /* - * Check if the current thread is unable to - * run: - */ - if (pthread->state != PS_RUNNING) { - /* - * Ignore threads that are not ready - * to run. - */ - } - /* - * Check if the current thread as an agregate - * priority not equal to the highest priority - * found above: - */ - else if ((pthread->pthread_priority + pthread->inc_prio) != prio) { - /* - * Ignore threads which have lower - * agregate priority. - */ - } - /* - * Check if an eligible thread has not been - * found yet, or if the current thread has an - * inactive time earlier than the last one - * seen: - */ - else if (pthread_s == NULL || timercmp(&pthread->last_inactive, &tv1, <)) { - /* - * Save the pointer to the current - * thread as the most eligible thread - * seen so far: - */ - pthread_s = pthread; - - /* - * Save the time that the selected - * thread became inactive: - */ - tv1.tv_sec = pthread->last_inactive.tv_sec; - tv1.tv_usec = pthread->last_inactive.tv_usec; - } - } - } - /* Check if there are no threads ready to run: */ - if (pthread_s == NULL) { - /* - * Lock the pthread kernel by changing the pointer to - * the running thread to point to the global kernel - * thread structure: - */ - _thread_run = &_thread_kern_thread; - - /* - * There are no threads ready to run, so wait until - * something happens that changes this condition: - */ - _thread_kern_select(1); - } else { - /* Make the selected thread the current thread: */ - _thread_run = pthread_s; - - /* - * Save the current time as the time that the thread - * became active: - */ - _thread_run->last_active.tv_sec = tv.tv_sec; - _thread_run->last_active.tv_usec = tv.tv_usec; - - /* - * Check if this thread is running for the first time - * or running again after using its full time slice - * allocation: - */ - if (_thread_run->slice_usec == -1) { - /* Reset the accumulated time slice period: */ - _thread_run->slice_usec = 0; - } - /* - * Reset the incremental priority now that this - * thread has been given the chance to run: - */ - _thread_run->inc_prio = 0; - - /* Check if there is more than one thread: */ - if (_thread_run != _thread_link_list || _thread_run->nxt != NULL) { - /* - * Define the maximum time before a SIGVTALRM - * is required: - */ - itimer.it_value.tv_sec = 0; - itimer.it_value.tv_usec = TIMESLICE_USEC; - - /* - * The interval timer is not reloaded when it - * times out. The interval time needs to be - * calculated every time. - */ - itimer.it_interval.tv_sec = 0; - itimer.it_interval.tv_usec = 0; - - /* - * Enter a loop to look for threads waiting - * for a time: - */ - for (pthread = _thread_link_list; pthread != NULL; pthread = pthread->nxt) { - /* - * Check if this thread is to - * timeout: - */ - if (pthread->state == PS_COND_WAIT || - pthread->state == PS_SLEEP_WAIT || - pthread->state == PS_FDR_WAIT || - pthread->state == PS_FDW_WAIT || - pthread->state == PS_SELECT_WAIT) { - /* - * Check if this thread is to - * wait forever: - */ - if (pthread->wakeup_time.tv_sec == -1) { - } - /* - * Check if this thread is to - * wakeup immediately: - */ - else if (pthread->wakeup_time.tv_sec == 0 && - pthread->wakeup_time.tv_nsec == 0) { - } - /* - * Check if the current time - * is after the wakeup time: - */ - else if ((ts.tv_sec > pthread->wakeup_time.tv_sec) || - ((ts.tv_sec == pthread->wakeup_time.tv_sec) && - (ts.tv_nsec > pthread->wakeup_time.tv_nsec))) { - } else { - /* - * Calculate the time - * until this thread - * is ready, allowing - * for the clock - * resolution: - */ - ts1.tv_sec = pthread->wakeup_time.tv_sec - ts.tv_sec; - ts1.tv_nsec = pthread->wakeup_time.tv_nsec - ts.tv_nsec + - CLOCK_RES_NSEC; - - /* - * Check for - * underflow of the - * nanosecond field: - */ - if (ts1.tv_nsec < 0) { - /* - * Allow for - * the - * underflow - * of the - * nanosecond - * field: - */ - ts1.tv_sec--; - ts1.tv_nsec += 1000000000; - } - /* - * Check for overflow - * of the nanosecond - * field: - */ - if (ts1.tv_nsec >= 1000000000) { - /* - * Allow for - * the - * overflow - * of the - * nanosecond - * field: - */ - ts1.tv_sec++; - ts1.tv_nsec -= 1000000000; - } - /* - * Convert the - * timespec structure - * to a timeval - * structure: - */ - TIMESPEC_TO_TIMEVAL(&tv, &ts1); - - /* - * Check if the - * thread will be - * ready sooner than - * the earliest one - * found so far: - */ - if (timercmp(&tv, &itimer.it_value, <)) { - /* - * Update the - * time - * value: - */ - itimer.it_value.tv_sec = tv.tv_sec; - itimer.it_value.tv_usec = tv.tv_usec; - } - } - } - } - - /* - * Start the interval timer for the - * calculated time interval: - */ - if (setitimer(ITIMER_VIRTUAL, &itimer, NULL) != 0) { - /* - * Cannot initialise the timer, so - * abort this process: - */ - PANIC("Cannot set virtual timer"); - } - } - /* Check if a signal context was saved: */ - if (_thread_run->sig_saved == 1) { -#ifndef __alpha__ - /* - * Point to the floating point data in the - * running thread: - */ - fdata = _thread_run->saved_fp; - - /* Restore the floating point state: */ - __asm__("frstor %0": :"m"(*fdata)); -#endif - - /* - * Do a sigreturn to restart the thread that - * was interrupted by a signal: - */ - _thread_kern_in_sched = 0; - _thread_sys_sigreturn(&_thread_run->saved_sigcontext); - } else - /* - * Do a longjmp to restart the thread that - * was context switched out (by a longjmp to - * a different thread): - */ - longjmp(_thread_run->saved_jmp_buf, 1); - - /* This point should not be reached. */ - PANIC("Thread has returned from sigreturn or longjmp"); - } - } - - /* There are no more threads, so exit this process: */ - exit(0); -} - -void -_thread_kern_sched_state(enum pthread_state state, char *fname, int lineno) -{ - /* Change the state of the current thread: */ - _thread_run->state = state; - _thread_run->fname = fname; - _thread_run->lineno = lineno; - - /* Schedule the next thread that is ready: */ - _thread_kern_sched(NULL); - return; -} - -void -_thread_kern_sched_state_unlock(enum pthread_state state, - spinlock_t *lock, char *fname, int lineno) -{ - /* Change the state of the current thread: */ - _thread_run->state = state; - _thread_run->fname = fname; - _thread_run->lineno = lineno; - - _SPINUNLOCK(lock); - - /* Schedule the next thread that is ready: */ - _thread_kern_sched(NULL); - return; -} - -static void -_thread_kern_select(int wait_reqd) -{ - char bufr[128]; - fd_set fd_set_except; - fd_set fd_set_read; - fd_set fd_set_write; - int count = 0; - int count_dec; - int found_one; - int i; - int nfds = -1; - int settimeout; - pthread_t pthread; - ssize_t num; - struct timespec ts; - struct timespec ts1; - struct timeval *p_tv; - struct timeval tv; - struct timeval tv1; - - /* Zero the file descriptor sets: */ - FD_ZERO(&fd_set_read); - FD_ZERO(&fd_set_write); - FD_ZERO(&fd_set_except); - - /* Check if the caller wants to wait: */ - if (wait_reqd) { - /* - * Add the pthread kernel pipe file descriptor to the read - * set: - */ - FD_SET(_thread_kern_pipe[0], &fd_set_read); - nfds = _thread_kern_pipe[0]; - - /* Get the current time of day: */ - gettimeofday(&tv, NULL); - TIMEVAL_TO_TIMESPEC(&tv, &ts); - } - /* Initialise the time value structure: */ - tv.tv_sec = 0; - tv.tv_usec = 0; - - /* - * Enter a loop to process threads waiting on either file descriptors - * or times: - */ - for (pthread = _thread_link_list; pthread != NULL; pthread = pthread->nxt) { - /* Assume that this state does not time out: */ - settimeout = 0; - - /* Process according to thread state: */ - switch (pthread->state) { - /* - * States which do not depend on file descriptor I/O - * operations or timeouts: - */ - case PS_DEAD: - case PS_FDLR_WAIT: - case PS_FDLW_WAIT: - case PS_FILE_WAIT: - case PS_JOIN: - case PS_MUTEX_WAIT: - case PS_RUNNING: - case PS_SIGTHREAD: - case PS_SIGWAIT: - case PS_STATE_MAX: - case PS_WAIT_WAIT: - case PS_SUSPENDED: - /* Nothing to do here. */ - break; - - /* File descriptor read wait: */ - case PS_FDR_WAIT: - /* Add the file descriptor to the read set: */ - FD_SET(pthread->data.fd.fd, &fd_set_read); - - /* - * Check if this file descriptor is greater than any - * of those seen so far: - */ - if (pthread->data.fd.fd > nfds) { - /* Remember this file descriptor: */ - nfds = pthread->data.fd.fd; - } - /* Increment the file descriptor count: */ - count++; - - /* This state can time out: */ - settimeout = 1; - break; - - /* File descriptor write wait: */ - case PS_FDW_WAIT: - /* Add the file descriptor to the write set: */ - FD_SET(pthread->data.fd.fd, &fd_set_write); - - /* - * Check if this file descriptor is greater than any - * of those seen so far: - */ - if (pthread->data.fd.fd > nfds) { - /* Remember this file descriptor: */ - nfds = pthread->data.fd.fd; - } - /* Increment the file descriptor count: */ - count++; - - /* This state can time out: */ - settimeout = 1; - break; - - /* States that time out: */ - case PS_SLEEP_WAIT: - case PS_COND_WAIT: - /* Flag a timeout as required: */ - settimeout = 1; - break; - - /* Select wait: */ - case PS_SELECT_WAIT: - /* - * Enter a loop to process each file descriptor in - * the thread-specific file descriptor sets: - */ - for (i = 0; i < pthread->data.select_data->nfds; i++) { - /* - * Check if this file descriptor is set for - * exceptions: - */ - if (FD_ISSET(i, &pthread->data.select_data->exceptfds)) { - /* - * Add the file descriptor to the - * exception set: - */ - FD_SET(i, &fd_set_except); - - /* - * Increment the file descriptor - * count: - */ - count++; - - /* - * Check if this file descriptor is - * greater than any of those seen so - * far: - */ - if (i > nfds) { - /* - * Remember this file - * descriptor: - */ - nfds = i; - } - } - /* - * Check if this file descriptor is set for - * write: - */ - if (FD_ISSET(i, &pthread->data.select_data->writefds)) { - /* - * Add the file descriptor to the - * write set: - */ - FD_SET(i, &fd_set_write); - - /* - * Increment the file descriptor - * count: - */ - count++; - - /* - * Check if this file descriptor is - * greater than any of those seen so - * far: - */ - if (i > nfds) { - /* - * Remember this file - * descriptor: - */ - nfds = i; - } - } - /* - * Check if this file descriptor is set for - * read: - */ - if (FD_ISSET(i, &pthread->data.select_data->readfds)) { - /* - * Add the file descriptor to the - * read set: - */ - FD_SET(i, &fd_set_read); - - /* - * Increment the file descriptor - * count: - */ - count++; - - /* - * Check if this file descriptor is - * greater than any of those seen so - * far: - */ - if (i > nfds) { - /* - * Remember this file - * descriptor: - */ - nfds = i; - } - } - } - - /* This state can time out: */ - settimeout = 1; - break; - } - - /* - * Check if the caller wants to wait and if the thread state - * is one that times out: - */ - if (wait_reqd && settimeout) { - /* Check if this thread wants to wait forever: */ - if (pthread->wakeup_time.tv_sec == -1) { - } - /* Check if this thread doesn't want to wait at all: */ - else if (pthread->wakeup_time.tv_sec == 0 && - pthread->wakeup_time.tv_nsec == 0) { - /* Override the caller's request to wait: */ - wait_reqd = 0; - } else { - /* - * Calculate the time until this thread is - * ready, allowing for the clock resolution: - */ - ts1.tv_sec = pthread->wakeup_time.tv_sec - ts.tv_sec; - ts1.tv_nsec = pthread->wakeup_time.tv_nsec - ts.tv_nsec + - CLOCK_RES_NSEC; - - /* - * Check for underflow of the nanosecond - * field: - */ - if (ts1.tv_nsec < 0) { - /* - * Allow for the underflow of the - * nanosecond field: - */ - ts1.tv_sec--; - ts1.tv_nsec += 1000000000; - } - /* - * Check for overflow of the nanosecond - * field: - */ - if (ts1.tv_nsec >= 1000000000) { - /* - * Allow for the overflow of the - * nanosecond field: - */ - ts1.tv_sec++; - ts1.tv_nsec -= 1000000000; - } - /* - * Convert the timespec structure to a - * timeval structure: - */ - TIMESPEC_TO_TIMEVAL(&tv1, &ts1); - - /* - * Check if no time value has been found yet, - * or if the thread will be ready sooner that - * the earliest one found so far: - */ - if ((tv.tv_sec == 0 && tv.tv_usec == 0) || timercmp(&tv1, &tv, <)) { - /* Update the time value: */ - tv.tv_sec = tv1.tv_sec; - tv.tv_usec = tv1.tv_usec; - } - } - } - } - - /* Check if the caller wants to wait: */ - if (wait_reqd) { - /* Check if no threads were found with timeouts: */ - if (tv.tv_sec == 0 && tv.tv_usec == 0) { - /* Wait forever: */ - p_tv = NULL; - } else { - /* - * Point to the time value structure which contains - * the earliest time that a thread will be ready: - */ - p_tv = &tv; - } - - /* - * Flag the pthread kernel as in a select. This is to avoid - * the window between the next statement that unblocks - * signals and the select statement which follows. - */ - _thread_kern_in_select = 1; - - /* - * Wait for a file descriptor to be ready for read, write, or - * an exception, or a timeout to occur: - */ - count = _thread_sys_select(nfds + 1, &fd_set_read, &fd_set_write, &fd_set_except, p_tv); - - /* Reset the kernel in select flag: */ - _thread_kern_in_select = 0; - - /* - * Check if it is possible that there are bytes in the kernel - * read pipe waiting to be read: - */ - if (count < 0 || FD_ISSET(_thread_kern_pipe[0], &fd_set_read)) { - /* - * Check if the kernel read pipe was included in the - * count: - */ - if (count > 0) { - /* - * Remove the kernel read pipe from the - * count: - */ - FD_CLR(_thread_kern_pipe[0], &fd_set_read); - - /* Decrement the count of file descriptors: */ - count--; - } - /* - * Enter a loop to read (and trash) bytes from the - * pthread kernel pipe: - */ - while ((num = _thread_sys_read(_thread_kern_pipe[0], bufr, sizeof(bufr))) > 0) { - /* - * The buffer read contains one byte per - * signal and each byte is the signal number. - * This data is not used, but the fact that - * the signal handler wrote to the pipe *is* - * used to cause the _select call - * to complete if the signal occurred between - * the time when signals were unblocked and - * the _select select call being - * made. - */ - } - } - } - /* Check if there are file descriptors to poll: */ - else if (count > 0) { - /* - * Point to the time value structure which has been zeroed so - * that the call to _select will not wait: - */ - p_tv = &tv; - - /* Poll file descrptors without wait: */ - count = _thread_sys_select(nfds + 1, &fd_set_read, &fd_set_write, &fd_set_except, p_tv); - } - - /* - * Check if any file descriptors are ready: - */ - if (count > 0) { - /* - * Enter a loop to look for threads waiting on file - * descriptors that are flagged as available by the - * _select syscall: - */ - for (pthread = _thread_link_list; pthread != NULL; pthread = pthread->nxt) { - /* Process according to thread state: */ - switch (pthread->state) { - /* - * States which do not depend on file - * descriptor I/O operations: - */ - case PS_RUNNING: - case PS_COND_WAIT: - case PS_DEAD: - case PS_FDLR_WAIT: - case PS_FDLW_WAIT: - case PS_FILE_WAIT: - case PS_JOIN: - case PS_MUTEX_WAIT: - case PS_SIGWAIT: - case PS_SLEEP_WAIT: - case PS_WAIT_WAIT: - case PS_SIGTHREAD: - case PS_STATE_MAX: - case PS_SUSPENDED: - /* Nothing to do here. */ - break; - - /* File descriptor read wait: */ - case PS_FDR_WAIT: - /* - * Check if the file descriptor is available - * for read: - */ - if (FD_ISSET(pthread->data.fd.fd, &fd_set_read)) { - /* - * Change the thread state to allow - * it to read from the file when it - * is scheduled next: - */ - pthread->state = PS_RUNNING; - } - break; - - /* File descriptor write wait: */ - case PS_FDW_WAIT: - /* - * Check if the file descriptor is available - * for write: - */ - if (FD_ISSET(pthread->data.fd.fd, &fd_set_write)) { - /* - * Change the thread state to allow - * it to write to the file when it is - * scheduled next: - */ - pthread->state = PS_RUNNING; - } - break; - - /* Select wait: */ - case PS_SELECT_WAIT: - /* - * Reset the flag that indicates if a file - * descriptor is ready for some type of - * operation: - */ - count_dec = 0; - - /* - * Enter a loop to search though the - * thread-specific select file descriptors - * for the first descriptor that is ready: - */ - for (i = 0; i < pthread->data.select_data->nfds && count_dec == 0; i++) { - /* - * Check if this file descriptor does - * not have an exception: - */ - if (FD_ISSET(i, &pthread->data.select_data->exceptfds) && FD_ISSET(i, &fd_set_except)) { - /* - * Flag this file descriptor - * as ready: - */ - count_dec = 1; - } - /* - * Check if this file descriptor is - * not ready for write: - */ - if (FD_ISSET(i, &pthread->data.select_data->writefds) && FD_ISSET(i, &fd_set_write)) { - /* - * Flag this file descriptor - * as ready: - */ - count_dec = 1; - } - /* - * Check if this file descriptor is - * not ready for read: - */ - if (FD_ISSET(i, &pthread->data.select_data->readfds) && FD_ISSET(i, &fd_set_read)) { - /* - * Flag this file descriptor - * as ready: - */ - count_dec = 1; - } - } - - /* - * Check if any file descriptors are ready - * for the current thread: - */ - if (count_dec) { - /* - * Reset the count of file - * descriptors that are ready for - * this thread: - */ - found_one = 0; - - /* - * Enter a loop to search though the - * thread-specific select file - * descriptors: - */ - for (i = 0; i < pthread->data.select_data->nfds; i++) { - /* - * Reset the count of - * operations for which the - * current file descriptor is - * ready: - */ - count_dec = 0; - - /* - * Check if this file - * descriptor is selected for - * exceptions: - */ - if (FD_ISSET(i, &pthread->data.select_data->exceptfds)) { - /* - * Check if this file - * descriptor has an - * exception: - */ - if (FD_ISSET(i, &fd_set_except)) { - /* - * Increment - * the count - * for this - * file: - */ - count_dec++; - } else { - /* - * Clear the - * file - * descriptor - * in the - * thread-spec - * ific file - * descriptor - * set: - */ - FD_CLR(i, &pthread->data.select_data->exceptfds); - } - } - /* - * Check if this file - * descriptor is selected for - * write: - */ - if (FD_ISSET(i, &pthread->data.select_data->writefds)) { - /* - * Check if this file - * descriptor is - * ready for write: - */ - if (FD_ISSET(i, &fd_set_write)) { - /* - * Increment - * the count - * for this - * file: - */ - count_dec++; - } else { - /* - * Clear the - * file - * descriptor - * in the - * thread-spec - * ific file - * descriptor - * set: - */ - FD_CLR(i, &pthread->data.select_data->writefds); - } - } - /* - * Check if this file - * descriptor is selected for - * read: - */ - if (FD_ISSET(i, &pthread->data.select_data->readfds)) { - /* - * Check if this file - * descriptor is - * ready for read: - */ - if (FD_ISSET(i, &fd_set_read)) { - /* - * Increment - * the count - * for this - * file: - */ - count_dec++; - } else { - /* - * Clear the - * file - * descriptor - * in the - * thread-spec - * ific file - * descriptor - * set: - */ - FD_CLR(i, &pthread->data.select_data->readfds); - } - } - /* - * Check if the current file - * descriptor is ready for - * any one of the operations: - */ - if (count_dec > 0) { - /* - * Increment the - * count of file - * descriptors that - * are ready for the - * current thread: - */ - found_one++; - } - } - - /* - * Return the number of file - * descriptors that are ready: - */ - pthread->data.select_data->nfds = found_one; - - /* - * Change the state of the current - * thread to run: - */ - pthread->state = PS_RUNNING; - } - break; - } - } - } - - /* Nothing to return. */ - return; -} - -void -_thread_kern_set_timeout(struct timespec * timeout) -{ - struct timespec current_time; - struct timeval tv; - - /* Reset the timeout flag for the running thread: */ - _thread_run->timeout = 0; - - /* Check if the thread is to wait forever: */ - if (timeout == NULL) { - /* - * Set the wakeup time to something that can be recognised as - * different to an actual time of day: - */ - _thread_run->wakeup_time.tv_sec = -1; - _thread_run->wakeup_time.tv_nsec = -1; - } - /* Check if no waiting is required: */ - else if (timeout->tv_sec == 0 && timeout->tv_nsec == 0) { - /* Set the wake up time to 'immediately': */ - _thread_run->wakeup_time.tv_sec = 0; - _thread_run->wakeup_time.tv_nsec = 0; - } else { - /* Get the current time: */ - gettimeofday(&tv, NULL); - TIMEVAL_TO_TIMESPEC(&tv, ¤t_time); - - /* Calculate the time for the current thread to wake up: */ - _thread_run->wakeup_time.tv_sec = current_time.tv_sec + timeout->tv_sec; - _thread_run->wakeup_time.tv_nsec = current_time.tv_nsec + timeout->tv_nsec; - - /* Check if the nanosecond field needs to wrap: */ - if (_thread_run->wakeup_time.tv_nsec >= 1000000000) { - /* Wrap the nanosecond field: */ - _thread_run->wakeup_time.tv_sec += 1; - _thread_run->wakeup_time.tv_nsec -= 1000000000; - } - } - return; -} -#endif diff --git a/lib/libpthread/thread/thr_kill.c b/lib/libpthread/thread/thr_kill.c deleted file mode 100644 index 7572c05faff73..0000000000000 --- a/lib/libpthread/thread/thr_kill.c +++ /dev/null @@ -1,116 +0,0 @@ -/* - * Copyright (c) 1997 John Birrell <jb@cimlogic.com.au>. - * 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 John Birrell. - * 4. Neither the name of the author nor the names of any co-contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY JOHN BIRRELL 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 <errno.h> -#include <signal.h> -#ifdef _THREAD_SAFE -#include <pthread.h> -#include "pthread_private.h" - -int -pthread_kill(pthread_t pthread, int sig) -{ - int ret; - - /* Check for invalid signal numbers: */ - if (sig < 0 || sig >= NSIG) - /* Invalid signal: */ - ret = EINVAL; - - /* Ignored signals get dropped on the floor. */ - else if (_thread_sigact[sig - 1].sa_handler == SIG_IGN) - ret = 0; - - /* Find the thread in the list of active threads: */ - else if ((ret = _find_thread(pthread)) == 0) { - switch (pthread->state) { - case PS_SIGSUSPEND: - /* - * Only wake up the thread if the signal is unblocked - * and there is a handler installed for the signal. - */ - if (!sigismember(&pthread->sigmask, sig) && - _thread_sigact[sig - 1].sa_handler != SIG_DFL) { - /* Change the state of the thread to run: */ - PTHREAD_NEW_STATE(pthread,PS_RUNNING); - - /* Return the signal number: */ - pthread->signo = sig; - } - /* Increment the pending signal count: */ - sigaddset(&pthread->sigpend,sig); - break; - - case PS_SIGWAIT: - /* Wake up the thread if the signal is blocked. */ - if (sigismember(pthread->data.sigwait, sig)) { - /* Change the state of the thread to run: */ - PTHREAD_NEW_STATE(pthread,PS_RUNNING); - - /* Return the signal number: */ - pthread->signo = sig; - } else - /* Increment the pending signal count. */ - sigaddset(&pthread->sigpend,sig); - break; - - case PS_SELECT_WAIT: - case PS_FDR_WAIT: - case PS_FDW_WAIT: - case PS_SLEEP_WAIT: - if (!sigismember(&pthread->sigmask, sig) && - (_thread_sigact[sig - 1].sa_handler != SIG_IGN)) { - /* Flag the operation as interrupted: */ - pthread->interrupted = 1; - - /* Change the state of the thread to run: */ - PTHREAD_NEW_STATE(pthread,PS_RUNNING); - - /* Return the signal number: */ - pthread->signo = sig; - } else { - /* Increment the pending signal count: */ - sigaddset(&pthread->sigpend,sig); - } - break; - - default: - /* Increment the pending signal count: */ - sigaddset(&pthread->sigpend,sig); - break; - } - } - - /* Return the completion status: */ - return (ret); -} -#endif diff --git a/lib/libpthread/thread/thr_mattr_init.c b/lib/libpthread/thread/thr_mattr_init.c deleted file mode 100644 index 73226a6b4714b..0000000000000 --- a/lib/libpthread/thread/thr_mattr_init.c +++ /dev/null @@ -1,57 +0,0 @@ -/* - * Copyright (c) 1996 Jeffrey Hsu <hsu@freebsd.org>. - * 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 John Birrell. - * 4. Neither the name of the author nor the names of any co-contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY JOHN BIRRELL 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 <string.h> -#include <stdlib.h> -#include <errno.h> -#ifdef _THREAD_SAFE -#include <pthread.h> -#include "pthread_private.h" - -int -pthread_mutexattr_init(pthread_mutexattr_t *attr) -{ - int ret; - pthread_mutexattr_t pattr; - - if ((pattr = (pthread_mutexattr_t) - malloc(sizeof(struct pthread_mutex_attr))) == NULL) { - ret = ENOMEM; - } else { - memcpy(pattr, &pthread_mutexattr_default, - sizeof(struct pthread_mutex_attr)); - *attr = pattr; - ret = 0; - } - return(ret); -} -#endif diff --git a/lib/libpthread/thread/thr_mattr_kind_np.c b/lib/libpthread/thread/thr_mattr_kind_np.c deleted file mode 100644 index c145a1f899277..0000000000000 --- a/lib/libpthread/thread/thr_mattr_kind_np.c +++ /dev/null @@ -1,78 +0,0 @@ -/* - * Copyright (c) 1996 Jeffrey Hsu <hsu@freebsd.org>. - * 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 John Birrell. - * 4. Neither the name of the author nor the names of any co-contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY JOHN BIRRELL 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 <errno.h> -#ifdef _THREAD_SAFE -#include <pthread.h> -#include "pthread_private.h" - -int -pthread_mutexattr_setkind_np(pthread_mutexattr_t *attr, int kind) -{ - int ret; - if (attr == NULL || *attr == NULL) { - errno = EINVAL; - ret = -1; - } else { - (*attr)->m_type = kind; - ret = 0; - } - return(ret); -} - -int -pthread_mutexattr_getkind_np(pthread_mutexattr_t attr) -{ - int ret; - if (attr == NULL) { - errno = EINVAL; - ret = -1; - } else { - ret = attr->m_type; - } - return(ret); -} - -int -pthread_mutexattr_settype(pthread_mutexattr_t *attr, int type) -{ - int ret; - if (attr == NULL || *attr == NULL || type >= MUTEX_TYPE_MAX) { - errno = EINVAL; - ret = -1; - } else { - (*attr)->m_type = type; - ret = 0; - } - return(ret); -} -#endif diff --git a/lib/libpthread/thread/thr_multi_np.c b/lib/libpthread/thread/thr_multi_np.c deleted file mode 100644 index 64f360fdacfe7..0000000000000 --- a/lib/libpthread/thread/thr_multi_np.c +++ /dev/null @@ -1,44 +0,0 @@ -/* - * Copyright (c) 1996 John Birrell <jb@cimlogic.com.au>. - * 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 John Birrell. - * 4. Neither the name of the author nor the names of any co-contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY JOHN BIRRELL 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 <string.h> -#ifdef _THREAD_SAFE -#include <pthread.h> -#include "pthread_private.h" - -int pthread_multi_np() -{ - /* Return to multi-threaded scheduling mode: */ - _thread_single = NULL; - return(0); -} -#endif diff --git a/lib/libpthread/thread/thr_mutex.c b/lib/libpthread/thread/thr_mutex.c deleted file mode 100644 index d3801f1750c0b..0000000000000 --- a/lib/libpthread/thread/thr_mutex.c +++ /dev/null @@ -1,414 +0,0 @@ -/* - * Copyright (c) 1995 John Birrell <jb@cimlogic.com.au>. - * 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 John Birrell. - * 4. Neither the name of the author nor the names of any co-contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY JOHN BIRRELL 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 <stdlib.h> -#include <errno.h> -#include <string.h> -#ifdef _THREAD_SAFE -#include <pthread.h> -#include "pthread_private.h" - -static spinlock_t static_init_lock = _SPINLOCK_INITIALIZER; - -int -pthread_mutex_init(pthread_mutex_t * mutex, - const pthread_mutexattr_t * mutex_attr) -{ - enum pthread_mutextype type; - pthread_mutex_t pmutex; - int ret = 0; - - if (mutex == NULL) { - ret = EINVAL; - } else { - /* Check if default mutex attributes: */ - if (mutex_attr == NULL || *mutex_attr == NULL) - /* Default to a fast mutex: */ - type = PTHREAD_MUTEX_DEFAULT; - - else if ((*mutex_attr)->m_type >= MUTEX_TYPE_MAX) - /* Return an invalid argument error: */ - ret = EINVAL; - else - /* Use the requested mutex type: */ - type = (*mutex_attr)->m_type; - - /* Check no errors so far: */ - if (ret == 0) { - if ((pmutex = (pthread_mutex_t) - malloc(sizeof(struct pthread_mutex))) == NULL) - ret = ENOMEM; - else { - /* Reset the mutex flags: */ - pmutex->m_flags = 0; - - /* Process according to mutex type: */ - switch (type) { - /* Fast mutex: */ - case PTHREAD_MUTEX_DEFAULT: - case PTHREAD_MUTEX_NORMAL: - case PTHREAD_MUTEX_ERRORCHECK: - /* Nothing to do here. */ - break; - - /* Counting mutex: */ - case PTHREAD_MUTEX_RECURSIVE: - /* Reset the mutex count: */ - pmutex->m_data.m_count = 0; - break; - - /* Trap invalid mutex types: */ - default: - /* Return an invalid argument error: */ - ret = EINVAL; - break; - } - if (ret == 0) { - /* Initialise the rest of the mutex: */ - _thread_queue_init(&pmutex->m_queue); - pmutex->m_flags |= MUTEX_FLAGS_INITED; - pmutex->m_owner = NULL; - pmutex->m_type = type; - memset(&pmutex->lock, 0, - sizeof(pmutex->lock)); - *mutex = pmutex; - } else { - free(pmutex); - *mutex = NULL; - } - } - } - } - /* Return the completion status: */ - return (ret); -} - -int -pthread_mutex_destroy(pthread_mutex_t * mutex) -{ - int ret = 0; - - if (mutex == NULL || *mutex == NULL) - ret = EINVAL; - else { - /* Lock the mutex structure: */ - _SPINLOCK(&(*mutex)->lock); - - /* - * Free the memory allocated for the mutex - * structure: - */ - free(*mutex); - - /* - * Leave the caller's pointer NULL now that - * the mutex has been destroyed: - */ - *mutex = NULL; - } - - /* Return the completion status: */ - return (ret); -} - -static int -init_static (pthread_mutex_t *mutex) -{ - int ret; - - _SPINLOCK(&static_init_lock); - - if (*mutex == NULL) - ret = pthread_mutex_init(mutex, NULL); - else - ret = 0; - - _SPINUNLOCK(&static_init_lock); - - return(ret); -} - -int -pthread_mutex_trylock(pthread_mutex_t * mutex) -{ - int ret = 0; - - if (mutex == NULL) - ret = EINVAL; - - /* - * If the mutex is statically initialized, perform the dynamic - * initialization: - */ - else if (*mutex != NULL || (ret = init_static(mutex)) == 0) { - /* Lock the mutex structure: */ - _SPINLOCK(&(*mutex)->lock); - - /* Process according to mutex type: */ - switch ((*mutex)->m_type) { - /* Fast mutex: */ - case PTHREAD_MUTEX_NORMAL: - case PTHREAD_MUTEX_DEFAULT: - case PTHREAD_MUTEX_ERRORCHECK: - /* Check if this mutex is not locked: */ - if ((*mutex)->m_owner == NULL) { - /* Lock the mutex for the running thread: */ - (*mutex)->m_owner = _thread_run; - } else { - /* Return a busy error: */ - ret = EBUSY; - } - break; - - /* Counting mutex: */ - case PTHREAD_MUTEX_RECURSIVE: - /* Check if this mutex is locked: */ - if ((*mutex)->m_owner != NULL) { - /* - * Check if the mutex is locked by the running - * thread: - */ - if ((*mutex)->m_owner == _thread_run) { - /* Increment the lock count: */ - (*mutex)->m_data.m_count++; - } else { - /* Return a busy error: */ - ret = EBUSY; - } - } else { - /* Lock the mutex for the running thread: */ - (*mutex)->m_owner = _thread_run; - } - break; - - /* Trap invalid mutex types: */ - default: - /* Return an invalid argument error: */ - ret = EINVAL; - break; - } - - /* Unlock the mutex structure: */ - _SPINUNLOCK(&(*mutex)->lock); - } - - /* Return the completion status: */ - return (ret); -} - -int -pthread_mutex_lock(pthread_mutex_t * mutex) -{ - int ret = 0; - - if (mutex == NULL) - ret = EINVAL; - - /* - * If the mutex is statically initialized, perform the dynamic - * initialization: - */ - else if (*mutex != NULL || (ret = init_static(mutex)) == 0) { - /* Lock the mutex structure: */ - _SPINLOCK(&(*mutex)->lock); - - /* Process according to mutex type: */ - switch ((*mutex)->m_type) { - /* What SS2 define as a 'normal' mutex. This has to deadlock - on attempts to get a lock you already own. */ - case PTHREAD_MUTEX_NORMAL: - if ((*mutex)->m_owner == _thread_run) { - /* Intetionally deadlock */ - for (;;) - _thread_kern_sched_state(PS_MUTEX_WAIT, __FILE__, __LINE__); - } - goto COMMON_LOCK; - - /* Return error (not OK) on attempting to re-lock */ - case PTHREAD_MUTEX_ERRORCHECK: - if ((*mutex)->m_owner == _thread_run) { - ret = EDEADLK; - break; - } - - /* Fast mutexes do not check for any error conditions: */ - case PTHREAD_MUTEX_DEFAULT: - COMMON_LOCK: - /* - * Enter a loop to wait for the mutex to be locked by the - * current thread: - */ - while ((*mutex)->m_owner != _thread_run) { - /* Check if the mutex is not locked: */ - if ((*mutex)->m_owner == NULL) { - /* Lock the mutex for this thread: */ - (*mutex)->m_owner = _thread_run; - } else { - /* - * Join the queue of threads waiting to lock - * the mutex: - */ - _thread_queue_enq(&(*mutex)->m_queue, _thread_run); - - /* Wait for the mutex: */ - _thread_kern_sched_state_unlock( - PS_MUTEX_WAIT, &(*mutex)->lock, - __FILE__, __LINE__); - - /* Lock the mutex again: */ - _SPINLOCK(&(*mutex)->lock); - } - } - break; - - /* Counting mutex: */ - case PTHREAD_MUTEX_RECURSIVE: - /* - * Enter a loop to wait for the mutex to be locked by the - * current thread: - */ - while ((*mutex)->m_owner != _thread_run) { - /* Check if the mutex is not locked: */ - if ((*mutex)->m_owner == NULL) { - /* Lock the mutex for this thread: */ - (*mutex)->m_owner = _thread_run; - - /* Reset the lock count for this mutex: */ - (*mutex)->m_data.m_count = 0; - } else { - /* - * Join the queue of threads waiting to lock - * the mutex: - */ - _thread_queue_enq(&(*mutex)->m_queue, _thread_run); - - /* Wait for the mutex: */ - _thread_kern_sched_state_unlock( - PS_MUTEX_WAIT, &(*mutex)->lock, - __FILE__, __LINE__); - - /* Lock the mutex again: */ - _SPINLOCK(&(*mutex)->lock); - } - } - - /* Increment the lock count for this mutex: */ - (*mutex)->m_data.m_count++; - break; - - /* Trap invalid mutex types: */ - default: - /* Return an invalid argument error: */ - ret = EINVAL; - break; - } - - /* Unlock the mutex structure: */ - _SPINUNLOCK(&(*mutex)->lock); - } - - /* Return the completion status: */ - return (ret); -} - -int -pthread_mutex_unlock(pthread_mutex_t * mutex) -{ - int ret = 0; - - if (mutex == NULL || *mutex == NULL) { - ret = EINVAL; - } else { - /* Lock the mutex structure: */ - _SPINLOCK(&(*mutex)->lock); - - /* Process according to mutex type: */ - switch ((*mutex)->m_type) { - /* Default & normal mutexes do not really need to check for - any error conditions: */ - case PTHREAD_MUTEX_NORMAL: - case PTHREAD_MUTEX_DEFAULT: - case PTHREAD_MUTEX_ERRORCHECK: - /* Check if the running thread is not the owner of the mutex: */ - if ((*mutex)->m_owner != _thread_run) { - /* Return an invalid argument error: */ - ret = (*mutex)->m_owner ? EPERM : EINVAL; - } - /* - * Get the next thread from the queue of threads waiting on - * the mutex: - */ - else if (((*mutex)->m_owner = _thread_queue_deq(&(*mutex)->m_queue)) != NULL) { - /* Allow the new owner of the mutex to run: */ - PTHREAD_NEW_STATE((*mutex)->m_owner,PS_RUNNING); - } - break; - - /* Counting mutex: */ - case PTHREAD_MUTEX_RECURSIVE: - /* Check if the running thread is not the owner of the mutex: */ - if ((*mutex)->m_owner != _thread_run) { - /* Return an invalid argument error: */ - ret = EINVAL; - } - /* Check if there are still counts: */ - else if ((*mutex)->m_data.m_count > 1) { - /* Decrement the count: */ - (*mutex)->m_data.m_count--; - } else { - (*mutex)->m_data.m_count = 0; - /* - * Get the next thread from the queue of threads waiting on - * the mutex: - */ - if (((*mutex)->m_owner = _thread_queue_deq(&(*mutex)->m_queue)) != NULL) { - /* Allow the new owner of the mutex to run: */ - PTHREAD_NEW_STATE((*mutex)->m_owner,PS_RUNNING); - } - } - break; - - /* Trap invalid mutex types: */ - default: - /* Return an invalid argument error: */ - ret = EINVAL; - break; - } - - /* Unlock the mutex structure: */ - _SPINUNLOCK(&(*mutex)->lock); - } - - /* Return the completion status: */ - return (ret); -} -#endif diff --git a/lib/libpthread/thread/thr_mutexattr_destroy.c b/lib/libpthread/thread/thr_mutexattr_destroy.c deleted file mode 100644 index 5642cbef589dc..0000000000000 --- a/lib/libpthread/thread/thr_mutexattr_destroy.c +++ /dev/null @@ -1,51 +0,0 @@ -/* - * Copyright (c) 1997 John Birrell <jb@cimlogic.com.au>. - * 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 John Birrell. - * 4. Neither the name of the author nor the names of any co-contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY JOHN BIRRELL 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 <stdlib.h> -#include <errno.h> -#ifdef _THREAD_SAFE -#include <pthread.h> -#include "pthread_private.h" - -int pthread_mutexattr_destroy(pthread_mutexattr_t *attr) -{ - int ret; - if (attr == NULL || *attr == NULL) { - ret = EINVAL; - } else { - free(*attr); - *attr = NULL; - ret = 0; - } - return(ret); -} -#endif diff --git a/lib/libpthread/thread/thr_nanosleep.c b/lib/libpthread/thread/thr_nanosleep.c deleted file mode 100644 index 4ec7d3f317200..0000000000000 --- a/lib/libpthread/thread/thr_nanosleep.c +++ /dev/null @@ -1,119 +0,0 @@ -/* - * Copyright (c) 1995 John Birrell <jb@cimlogic.com.au>. - * 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 John Birrell. - * 4. Neither the name of the author nor the names of any co-contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY JOHN BIRRELL 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 <stdio.h> -#include <errno.h> -#ifdef _THREAD_SAFE -#include <pthread.h> -#include "pthread_private.h" - -int -nanosleep(const struct timespec * time_to_sleep, - struct timespec * time_remaining) -{ - int ret = 0; - struct timespec current_time; - struct timespec current_time1; - struct timespec remaining_time; - struct timeval tv; - - /* Check if the time to sleep is legal: */ - if (time_to_sleep == NULL || time_to_sleep->tv_nsec < 0 || time_to_sleep->tv_nsec > 1000000000) { - /* Return an EINVAL error : */ - errno = EINVAL; - ret = -1; - } else { - /* Get the current time: */ - gettimeofday(&tv, NULL); - TIMEVAL_TO_TIMESPEC(&tv, ¤t_time); - - /* Calculate the time for the current thread to wake up: */ - _thread_run->wakeup_time.tv_sec = current_time.tv_sec + time_to_sleep->tv_sec; - _thread_run->wakeup_time.tv_nsec = current_time.tv_nsec + time_to_sleep->tv_nsec; - - /* Check if the nanosecond field has overflowed: */ - if (_thread_run->wakeup_time.tv_nsec >= 1000000000) { - /* Wrap the nanosecond field: */ - _thread_run->wakeup_time.tv_sec += 1; - _thread_run->wakeup_time.tv_nsec -= 1000000000; - } - _thread_run->interrupted = 0; - - /* Reschedule the current thread to sleep: */ - _thread_kern_sched_state(PS_SLEEP_WAIT, __FILE__, __LINE__); - - /* Get the current time: */ - gettimeofday(&tv, NULL); - TIMEVAL_TO_TIMESPEC(&tv, ¤t_time1); - - /* Calculate the remaining time to sleep: */ - remaining_time.tv_sec = time_to_sleep->tv_sec + current_time.tv_sec - current_time1.tv_sec; - remaining_time.tv_nsec = time_to_sleep->tv_nsec + current_time.tv_nsec - current_time1.tv_nsec; - - /* Check if the nanosecond field has underflowed: */ - if (remaining_time.tv_nsec < 0) { - /* Handle the underflow: */ - remaining_time.tv_sec -= 1; - remaining_time.tv_nsec += 1000000000; - } - - /* Check if the nanosecond field has overflowed: */ - if (remaining_time.tv_nsec >= 1000000000) { - /* Handle the overflow: */ - remaining_time.tv_sec += 1; - remaining_time.tv_nsec -= 1000000000; - } - - /* Check if the sleep was longer than the required time: */ - if (remaining_time.tv_sec < 0) { - /* Reset the time left: */ - remaining_time.tv_sec = 0; - remaining_time.tv_nsec = 0; - } - - /* Check if the time remaining is to be returned: */ - if (time_remaining != NULL) { - /* Return the actual time slept: */ - time_remaining->tv_sec = remaining_time.tv_sec; - time_remaining->tv_nsec = remaining_time.tv_nsec; - } - - /* Check if the sleep was interrupted: */ - if (_thread_run->interrupted) { - /* Return an EINTR error : */ - errno = EINTR; - ret = -1; - } - } - return (ret); -} -#endif diff --git a/lib/libpthread/thread/thr_once.c b/lib/libpthread/thread/thr_once.c deleted file mode 100644 index c55ba9eaf74b5..0000000000000 --- a/lib/libpthread/thread/thr_once.c +++ /dev/null @@ -1,50 +0,0 @@ -/* - * Copyright (c) 1995 John Birrell <jb@cimlogic.com.au>. - * 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 John Birrell. - * 4. Neither the name of the author nor the names of any co-contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY JOHN BIRRELL 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. - * - */ -#ifdef _THREAD_SAFE -#include <pthread.h> -#include "pthread_private.h" - -int -pthread_once(pthread_once_t * once_control, void (*init_routine) (void)) -{ - if (once_control->state == PTHREAD_NEEDS_INIT) { - pthread_mutex_lock(&(once_control->mutex)); - if (once_control->state == PTHREAD_NEEDS_INIT) { - init_routine(); - once_control->state = PTHREAD_DONE_INIT; - } - pthread_mutex_unlock(&(once_control->mutex)); - } - return (0); -} -#endif diff --git a/lib/libpthread/thread/thr_open.c b/lib/libpthread/thread/thr_open.c deleted file mode 100644 index a538a758f4613..0000000000000 --- a/lib/libpthread/thread/thr_open.c +++ /dev/null @@ -1,74 +0,0 @@ -/* - * Copyright (c) 1995-1998 John Birrell <jb@cimlogic.com.au> - * 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 John Birrell. - * 4. Neither the name of the author nor the names of any co-contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY JOHN BIRRELL 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. - * - * $Id: uthread_open.c,v 1.3 1997/05/03 03:57:21 jb Exp $ - * - */ -#include <stdarg.h> -#include <unistd.h> -#include <fcntl.h> -#include <dirent.h> -#include <errno.h> -#ifdef _THREAD_SAFE -#include <pthread.h> -#include "pthread_private.h" - -int -open(const char *path, int flags,...) -{ - int fd; - int mode = 0; - int status; - va_list ap; - - /* Check if the file is being created: */ - if (flags & O_CREAT) { - /* Get the creation mode: */ - va_start(ap, flags); - mode = va_arg(ap, int); - va_end(ap); - } - /* Open the file: */ - if ((fd = _thread_sys_open(path, flags, mode)) < 0) { - } - /* Initialise the file descriptor table entry: */ - else if (_thread_fd_table_init(fd) != 0) { - /* Quietly close the file: */ - _thread_sys_close(fd); - - /* Reset the file descriptor: */ - fd = -1; - } - - /* Return the file descriptor or -1 on error: */ - return (fd); -} -#endif diff --git a/lib/libpthread/thread/thr_private.h b/lib/libpthread/thread/thr_private.h deleted file mode 100644 index 2d7e723bbfa1e..0000000000000 --- a/lib/libpthread/thread/thr_private.h +++ /dev/null @@ -1,847 +0,0 @@ -/* - * Copyright (c) 1995-1998 John Birrell <jb@cimlogic.com.au>. - * 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 John Birrell. - * 4. Neither the name of the author nor the names of any co-contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY JOHN BIRRELL 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. - * - * Private thread definitions for the uthread kernel. - * - */ - -#ifndef _PTHREAD_PRIVATE_H -#define _PTHREAD_PRIVATE_H - -/* - * Evaluate the storage class specifier. - */ -#ifdef GLOBAL_PTHREAD_PRIVATE -#define SCLASS -#else -#define SCLASS extern -#endif - -/* - * Include files. - */ -#include <setjmp.h> -#include <signal.h> -#include <sys/queue.h> -#include <sys/types.h> -#include <sys/time.h> -#include <sched.h> -#include <spinlock.h> - -/* - * Kernel fatal error handler macro. - */ -#define PANIC(string) _thread_exit(__FILE__,__LINE__,string) - -/* Output debug messages like this: */ -#define stdout_debug(_x) _thread_sys_write(1,_x,strlen(_x)); -#define stderr_debug(_x) _thread_sys_write(2,_x,strlen(_x)); - -/* - * State change macro: - */ -#define PTHREAD_NEW_STATE(thrd, newstate) { \ - (thrd)->state = newstate; \ - (thrd)->fname = __FILE__; \ - (thrd)->lineno = __LINE__; \ -} - -/* - * Queue definitions. - */ -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 } - -/* - * Mutex definitions. - */ -union pthread_mutex_data { - void *m_ptr; - int m_count; -}; - -struct pthread_mutex { - enum pthread_mutextype m_type; - struct pthread_queue m_queue; - struct pthread *m_owner; - union pthread_mutex_data m_data; - long m_flags; - - /* - * Lock for accesses to this structure. - */ - spinlock_t lock; -}; - -/* - * 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_STATIC_INITIALIZER \ - { MUTEX_TYPE_FAST, PTHREAD_QUEUE_INITIALIZER, \ - NULL, { NULL }, MUTEX_FLAGS_INITED } - -struct pthread_mutex_attr { - enum pthread_mutextype m_type; - long m_flags; -}; - -/* - * Condition variable definitions. - */ -enum pthread_cond_type { - COND_TYPE_FAST, - COND_TYPE_MAX -}; - -struct pthread_cond { - enum pthread_cond_type c_type; - struct pthread_queue c_queue; - void *c_data; - long c_flags; - - /* - * Lock for accesses to this structure. - */ - spinlock_t lock; -}; - -struct pthread_cond_attr { - enum pthread_cond_type c_type; - long c_flags; -}; - -/* - * Flags for condition variables. - */ -#define COND_FLAGS_PRIVATE 0x01 -#define COND_FLAGS_INITED 0x02 -#define COND_FLAGS_BUSY 0x04 - -/* - * Static cond initialization values. - */ -#define PTHREAD_COND_STATIC_INITIALIZER \ - { COND_TYPE_FAST, PTHREAD_QUEUE_INITIALIZER, NULL, COND_FLAGS_INITED } - -/* - * Cleanup definitions. - */ -struct pthread_cleanup { - struct pthread_cleanup *next; - void (*routine) (); - void *routine_arg; -}; - -struct pthread_attr { - int schedparam_policy; - int prio; - int suspend; - int flags; - void *arg_attr; - void (*cleanup_attr) (); - void *stackaddr_attr; - size_t stacksize_attr; -}; - -/* - * Thread creation state attributes. - */ -#define PTHREAD_CREATE_RUNNING 0 -#define PTHREAD_CREATE_SUSPENDED 1 - -/* - * Miscellaneous definitions. - */ -#define PTHREAD_STACK_DEFAULT 65536 -#define PTHREAD_DEFAULT_PRIORITY 64 -#define PTHREAD_MAX_PRIORITY 126 -#define PTHREAD_MIN_PRIORITY 0 -#define _POSIX_THREAD_ATTR_STACKSIZE - -/* - * Clock resolution in nanoseconds. - */ -#define CLOCK_RES_NSEC 10000000 - -/* - * Number of microseconds between incremental priority updates for - * threads that are ready to run, but denied being run. - */ -#define INC_PRIO_USEC 500000 - -/* - * Time slice period in microseconds. - */ -#define TIMESLICE_USEC 100000 - -struct pthread_key { - spinlock_t lock; - volatile int allocated; - volatile int count; - void (*destructor) (); -}; - -struct pthread_rwlockattr { - int pshared; -}; - -struct pthread_rwlock { - pthread_mutex_t lock; /* monitor lock */ - int state; /* 0 = idle >0 = # of readers -1 = writer */ - pthread_cond_t read_signal; - pthread_cond_t write_signal; - int blocked_writers; -}; - -/* - * Thread states. - */ -enum pthread_state { - PS_RUNNING, - PS_SIGTHREAD, - PS_MUTEX_WAIT, - PS_COND_WAIT, - PS_FDLR_WAIT, - PS_FDLW_WAIT, - PS_FDR_WAIT, - PS_FDW_WAIT, - PS_FILE_WAIT, - PS_SELECT_WAIT, - PS_SLEEP_WAIT, - PS_WAIT_WAIT, - PS_SIGSUSPEND, - PS_SIGWAIT, - PS_JOIN, - PS_SUSPENDED, - PS_DEAD, - PS_STATE_MAX -}; - - -/* - * File descriptor locking definitions. - */ -#define FD_READ 0x1 -#define FD_WRITE 0x2 -#define FD_RDWR (FD_READ | FD_WRITE) - -/* - * File descriptor table structure. - */ -struct fd_table_entry { - /* - * Lock for accesses to this file descriptor table - * entry. This is passed to _spinlock() to provide atomic - * access to this structure. It does *not* represent the - * state of the lock on the file descriptor. - */ - spinlock_t lock; - struct pthread_queue r_queue; /* Read queue. */ - struct pthread_queue w_queue; /* Write queue. */ - struct pthread *r_owner; /* Ptr to thread owning read lock. */ - struct pthread *w_owner; /* Ptr to thread owning write lock. */ - char *r_fname; /* Ptr to read lock source file name */ - int r_lineno; /* Read lock source line number. */ - char *w_fname; /* Ptr to write lock source file name */ - int w_lineno; /* Write lock source line number. */ - int r_lockcount; /* Count for FILE read locks. */ - int w_lockcount; /* Count for FILE write locks. */ - int flags; /* Flags used in open. */ -}; - -struct pthread_select_data { - int nfds; - fd_set readfds; - fd_set writefds; - fd_set exceptfds; -}; - -union pthread_wait_data { - pthread_mutex_t *mutex; - pthread_cond_t *cond; - const sigset_t *sigwait; /* Waiting on a signal in sigwait */ - struct { - short fd; /* Used when thread waiting on fd */ - short branch; /* Line number, for debugging. */ - char *fname; /* Source file name for debugging.*/ - } fd; - struct pthread_select_data * select_data; -}; - -/* - * Thread structure. - */ -struct pthread { - /* - * Magic value to help recognize a valid thread structure - * from an invalid one: - */ -#define PTHREAD_MAGIC ((u_int32_t) 0xd09ba115) - u_int32_t magic; - char *name; - - /* - * Lock for accesses to this thread structure. - */ - spinlock_t lock; - - /* - * Pointer to the next thread in the thread linked list. - */ - struct pthread *nxt; - - /* - * Pointer to the next thread in the dead thread linked list. - */ - struct pthread *nxt_dead; - - /* - * Thread start routine, argument, stack pointer and thread - * attributes. - */ - void *(*start_routine)(void *); - void *arg; - void *stack; - struct pthread_attr attr; - -#if (defined(__FreeBSD__) || defined(__NetBSD__)) && defined(__i386__) - /* - * Saved floating point registers on systems where they are not - * saved in the signal context. - */ - char saved_fp[108]; -#endif - - /* - * Saved signal context used in call to sigreturn by - * _thread_kern_sched if sig_saved is TRUE. - */ - struct sigcontext saved_sigcontext; - - /* - * Saved jump buffer used in call to longjmp by _thread_kern_sched - * if sig_saved is FALSE. - */ - jmp_buf saved_jmp_buf; - - /* - * TRUE if the last state saved was a signal context. FALSE if the - * last state saved was a jump buffer. - */ - int sig_saved; - - /* - * Current signal mask and pending signals. - */ - sigset_t sigmask; - sigset_t sigpend; - - /* Thread state: */ - enum pthread_state state; - - /* Time that this thread was last made active. */ - struct timeval last_active; - - /* Time that this thread was last made inactive. */ - struct timeval last_inactive; - - /* - * Number of microseconds accumulated by this thread when - * time slicing is active. - */ - long slice_usec; - - /* - * Incremental priority accumulated by thread while it is ready to - * run but is denied being run. - */ - int inc_prio; - - /* - * Time to wake up thread. This is used for sleeping threads and - * for any operation which may time out (such as select). - */ - struct timespec wakeup_time; - - /* TRUE if operation has timed out. */ - int timeout; - - /* - * Error variable used instead of errno. The function __error() - * returns a pointer to this. - */ - int error; - - /* Join queue for waiting threads: */ - struct pthread_queue join_queue; - - /* - * The current thread can belong to only one queue at a time. - * - * Pointer to queue (if any) on which the current thread is waiting. - * - * XXX The queuing should be changed to use the TAILQ entry below. - * XXX For the time being, it's hybrid. - */ - struct pthread_queue *queue; - - /* Pointer to next element in queue. */ - struct pthread *qnxt; - - /* Queue entry for this thread: */ - TAILQ_ENTRY(pthread) qe; - - /* Wait data. */ - union pthread_wait_data data; - - /* - * Set to TRUE if a blocking operation was - * interrupted by a signal: - */ - int interrupted; - - /* Signal number when in state PS_SIGWAIT: */ - int signo; - - /* Miscellaneous data. */ - int flags; -#define PTHREAD_EXITING 0x0100 - char pthread_priority; - void *ret; - const void **specific_data; - int specific_data_count; - - /* Cleanup handlers Link List */ - struct pthread_cleanup *cleanup; - char *fname; /* Ptr to source file name */ - int lineno; /* Source line number. */ -}; - -/* - * Global variables for the uthread kernel. - */ - -/* Kernel thread structure used when there are no running threads: */ -SCLASS struct pthread _thread_kern_thread; - -/* Ptr to the thread structure for the running thread: */ -SCLASS struct pthread * volatile _thread_run -#ifdef GLOBAL_PTHREAD_PRIVATE -= &_thread_kern_thread; -#else -; -#endif - -/* - * Ptr to the thread running in single-threaded mode or NULL if - * running multi-threaded (default POSIX behaviour). - */ -SCLASS struct pthread * volatile _thread_single -#ifdef GLOBAL_PTHREAD_PRIVATE -= NULL; -#else -; -#endif - -/* Ptr to the first thread in the thread linked list: */ -SCLASS struct pthread * volatile _thread_link_list -#ifdef GLOBAL_PTHREAD_PRIVATE -= NULL; -#else -; -#endif - -/* - * Array of kernel pipe file descriptors that are used to ensure that - * no signals are missed in calls to _select. - */ -SCLASS int _thread_kern_pipe[2] -#ifdef GLOBAL_PTHREAD_PRIVATE -= { - -1, - -1 -}; -#else -; -#endif -SCLASS int _thread_kern_in_select -#ifdef GLOBAL_PTHREAD_PRIVATE -= 0; -#else -; -#endif -SCLASS int _thread_kern_in_sched -#ifdef GLOBAL_PTHREAD_PRIVATE -= 0; -#else -; -#endif - -/* Last time that an incremental priority update was performed: */ -SCLASS struct timeval kern_inc_prio_time -#ifdef GLOBAL_PTHREAD_PRIVATE -= { 0, 0 }; -#else -; -#endif - -/* Dead threads: */ -SCLASS struct pthread * volatile _thread_dead -#ifdef GLOBAL_PTHREAD_PRIVATE -= NULL; -#else -; -#endif - -/* Initial thread: */ -SCLASS struct pthread *_thread_initial -#ifdef GLOBAL_PTHREAD_PRIVATE -= NULL; -#else -; -#endif - -/* Default thread attributes: */ -SCLASS struct pthread_attr pthread_attr_default -#ifdef GLOBAL_PTHREAD_PRIVATE -= { SCHED_RR, PTHREAD_DEFAULT_PRIORITY, PTHREAD_CREATE_RUNNING, - PTHREAD_CREATE_JOINABLE, NULL, NULL, NULL, PTHREAD_STACK_DEFAULT }; -#else -; -#endif - -/* Default mutex attributes: */ -SCLASS struct pthread_mutex_attr pthread_mutexattr_default -#ifdef GLOBAL_PTHREAD_PRIVATE -= { MUTEX_TYPE_FAST, 0 }; -#else -; -#endif - -/* Default condition variable attributes: */ -SCLASS struct pthread_cond_attr pthread_condattr_default -#ifdef GLOBAL_PTHREAD_PRIVATE -= { COND_TYPE_FAST, 0 }; -#else -; -#endif - -/* - * Standard I/O file descriptors need special flag treatment since - * setting one to non-blocking does all on *BSD. Sigh. This array - * is used to store the initial flag settings. - */ -SCLASS int _pthread_stdio_flags[3]; - -/* File table information: */ -SCLASS struct fd_table_entry **_thread_fd_table -#ifdef GLOBAL_PTHREAD_PRIVATE -= NULL; -#else -; -#endif - -SCLASS const int dtablecount -#ifdef GLOBAL_PTHREAD_PRIVATE -= 4096/sizeof(struct fd_table_entry); -#else -; -#endif -SCLASS int _thread_dtablesize /* Descriptor table size. */ -#ifdef GLOBAL_PTHREAD_PRIVATE -= 1024; -#else -; -#endif - -/* Garbage collector mutex and condition variable. */ -SCLASS pthread_mutex_t _gc_mutex -#ifdef GLOBAL_PTHREAD_PRIVATE -= NULL -#endif -; -SCLASS pthread_cond_t _gc_cond -#ifdef GLOBAL_PTHREAD_PRIVATE -= NULL -#endif -; - -/* - * Array of signal actions for this process. - */ -struct sigaction _thread_sigact[NSIG]; - -/* Undefine the storage class specifier: */ -#undef SCLASS - -#ifdef _LOCK_DEBUG -#define _FD_LOCK(_fd,_type,_ts) _thread_fd_lock_debug(_fd, _type, \ - _ts, __FILE__, __LINE__) -#define _FD_UNLOCK(_fd,_type) _thread_fd_unlock_debug(_fd, _type, \ - __FILE__, __LINE__) -#else -#define _FD_LOCK(_fd,_type,_ts) _thread_fd_lock(_fd, _type, _ts) -#define _FD_UNLOCK(_fd,_type) _thread_fd_unlock(_fd, _type) -#endif - -/* - * Function prototype definitions. - */ -__BEGIN_DECLS -char *__ttyname_basic(int); -char *__ttyname_r_basic(int, char *, size_t); -char *ttyname_r(int, char *, size_t); -int _find_dead_thread(pthread_t); -int _find_thread(pthread_t); -int _thread_create(pthread_t *,const pthread_attr_t *,void *(*start_routine)(void *),void *,pthread_t); -int _thread_fd_lock(int, int, struct timespec *); -int _thread_fd_lock_debug(int, int, struct timespec *,char *fname,int lineno); -void _dispatch_signals(void); -void _thread_signal(pthread_t, int); -void _lock_thread(void); -void _lock_thread_list(void); -void _unlock_thread(void); -void _unlock_thread_list(void); -void _thread_exit(char *, int, char *); -void _thread_fd_unlock(int, int); -void _thread_fd_unlock_debug(int, int, char *, int); -void *_thread_cleanup(pthread_t); -void _thread_cleanupspecific(void); -void _thread_dump_info(void); -void _thread_init(void); -void _thread_kern_sched(struct sigcontext *); -void _thread_kern_sched_state(enum pthread_state,char *fname,int lineno); -void _thread_kern_sched_state_unlock(enum pthread_state state, - spinlock_t *lock, char *fname, int lineno); -void _thread_kern_set_timeout(struct timespec *); -void _thread_sig_handler(int, int, struct sigcontext *); -void _thread_start(void); -void _thread_start_sig_handler(void); -void _thread_seterrno(pthread_t,int); -void _thread_queue_init(struct pthread_queue *); -void _thread_queue_enq(struct pthread_queue *, struct pthread *); -int _thread_queue_remove(struct pthread_queue *, struct pthread *); -int _thread_fd_table_init(int fd); -struct pthread *_thread_queue_get(struct pthread_queue *); -struct pthread *_thread_queue_deq(struct pthread_queue *); -pthread_addr_t _thread_gc(pthread_addr_t); - -/* #include <signal.h> */ -int _thread_sys_sigaction(int, const struct sigaction *, struct sigaction *); -int _thread_sys_sigpending(sigset_t *); -int _thread_sys_sigprocmask(int, const sigset_t *, sigset_t *); -int _thread_sys_sigsuspend(const sigset_t *); -int _thread_sys_siginterrupt(int, int); -int _thread_sys_sigpause(int); -int _thread_sys_sigreturn(struct sigcontext *); -int _thread_sys_sigstack(const struct sigstack *, struct sigstack *); -int _thread_sys_sigvec(int, struct sigvec *, struct sigvec *); -void _thread_sys_psignal(unsigned int, const char *); -void (*_thread_sys_signal(int, void (*)(int)))(int); - -/* #include <sys/stat.h> */ -#ifdef _SYS_STAT_H_ -int _thread_sys_fchmod(int, mode_t); -int _thread_sys_fstat(int, struct stat *); -int _thread_sys_fchflags(int, u_long); -#endif - -/* #include <sys/mount.h> */ -#ifdef _SYS_MOUNT_H_ -int _thread_sys_fstatfs(int, struct statfs *); -#endif -int _thread_sys_pipe(int *); - -/* #include <sys/socket.h> */ -#ifdef _SYS_SOCKET_H_ -int _thread_sys_accept(int, struct sockaddr *, int *); -int _thread_sys_bind(int, const struct sockaddr *, int); -int _thread_sys_connect(int, const struct sockaddr *, int); -int _thread_sys_getpeername(int, struct sockaddr *, int *); -int _thread_sys_getsockname(int, struct sockaddr *, int *); -int _thread_sys_getsockopt(int, int, int, void *, int *); -int _thread_sys_listen(int, int); -int _thread_sys_setsockopt(int, int, int, const void *, int); -int _thread_sys_shutdown(int, int); -int _thread_sys_socket(int, int, int); -int _thread_sys_socketpair(int, int, int, int *); -ssize_t _thread_sys_recv(int, void *, size_t, int); -ssize_t _thread_sys_recvfrom(int, void *, size_t, int, struct sockaddr *, int *); -ssize_t _thread_sys_recvmsg(int, struct msghdr *, int); -ssize_t _thread_sys_send(int, const void *, size_t, int); -ssize_t _thread_sys_sendmsg(int, const struct msghdr *, int); -ssize_t _thread_sys_sendto(int, const void *,size_t, int, const struct sockaddr *, int); -#endif - -/* #include <stdio.h> */ -#ifdef _STDIO_H_ -FILE *_thread_sys_fdopen(int, const char *); -FILE *_thread_sys_fopen(const char *, const char *); -FILE *_thread_sys_freopen(const char *, const char *, FILE *); -FILE *_thread_sys_popen(const char *, const char *); -FILE *_thread_sys_tmpfile(void); -char *_thread_sys_ctermid(char *); -char *_thread_sys_cuserid(char *); -char *_thread_sys_fgetln(FILE *, size_t *); -char *_thread_sys_fgets(char *, int, FILE *); -char *_thread_sys_gets(char *); -char *_thread_sys_tempnam(const char *, const char *); -char *_thread_sys_tmpnam(char *); -int _thread_sys_fclose(FILE *); -int _thread_sys_feof(FILE *); -int _thread_sys_ferror(FILE *); -int _thread_sys_fflush(FILE *); -int _thread_sys_fgetc(FILE *); -int _thread_sys_fgetpos(FILE *, fpos_t *); -int _thread_sys_fileno(FILE *); -int _thread_sys_fprintf(FILE *, const char *, ...); -int _thread_sys_fpurge(FILE *); -int _thread_sys_fputc(int, FILE *); -int _thread_sys_fputs(const char *, FILE *); -int _thread_sys_fscanf(FILE *, const char *, ...); -int _thread_sys_fseek(FILE *, long, int); -int _thread_sys_fsetpos(FILE *, const fpos_t *); -int _thread_sys_getc(FILE *); -int _thread_sys_getchar(void); -int _thread_sys_getw(FILE *); -int _thread_sys_pclose(FILE *); -int _thread_sys_printf(const char *, ...); -int _thread_sys_putc(int, FILE *); -int _thread_sys_putchar(int); -int _thread_sys_puts(const char *); -int _thread_sys_putw(int, FILE *); -int _thread_sys_remove(const char *); -int _thread_sys_rename (const char *, const char *); -int _thread_sys_scanf(const char *, ...); -int _thread_sys_setlinebuf(FILE *); -int _thread_sys_setvbuf(FILE *, char *, int, size_t); -int _thread_sys_snprintf(char *, size_t, const char *, ...); -int _thread_sys_sprintf(char *, const char *, ...); -int _thread_sys_sscanf(const char *, const char *, ...); -int _thread_sys_ungetc(int, FILE *); -int _thread_sys_vfprintf(FILE *, const char *, _BSD_VA_LIST_); -int _thread_sys_vprintf(const char *, _BSD_VA_LIST_); -int _thread_sys_vscanf(const char *, _BSD_VA_LIST_); -int _thread_sys_vsnprintf(char *, size_t, const char *, _BSD_VA_LIST_); -int _thread_sys_vsprintf(char *, const char *, _BSD_VA_LIST_); -int _thread_sys_vsscanf(const char *, const char *, _BSD_VA_LIST_); -long _thread_sys_ftell(FILE *); -size_t _thread_sys_fread(void *, size_t, size_t, FILE *); -size_t _thread_sys_fwrite(const void *, size_t, size_t, FILE *); -void _thread_sys_clearerr(FILE *); -void _thread_sys_perror(const char *); -void _thread_sys_rewind(FILE *); -void _thread_sys_setbuf(FILE *, char *); -void _thread_sys_setbuffer(FILE *, char *, int); -#endif - -/* #include <unistd.h> */ -#ifdef _UNISTD_H_ -char *_thread_sys_ttyname(int); -int _thread_sys_close(int); -int _thread_sys_dup(int); -int _thread_sys_dup2(int, int); -int _thread_sys_exect(const char *, char * const *, char * const *); -int _thread_sys_execve(const char *, char * const *, char * const *); -int _thread_sys_fchdir(int); -int _thread_sys_fchown(int, uid_t, gid_t); -int _thread_sys_fsync(int); -int _thread_sys_ftruncate(int, off_t); -int _thread_sys_pause(void); -int _thread_sys_pipe(int *); -int _thread_sys_select(int, fd_set *, fd_set *, fd_set *, struct timeval *); -off_t _thread_sys_lseek(int, off_t, int); -pid_t _thread_sys_fork(void); -pid_t _thread_sys_tcgetpgrp(int); -ssize_t _thread_sys_read(int, void *, size_t); -ssize_t _thread_sys_write(int, const void *, size_t); -void _thread_sys__exit(int); -#endif - -/* #include <fcntl.h> */ -#ifdef _SYS_FCNTL_H_ -int _thread_sys_creat(const char *, mode_t); -int _thread_sys_fcntl(int, int, ...); -int _thread_sys_flock(int, int); -int _thread_sys_open(const char *, int, ...); -#endif - -/* #include <sys/ioctl.h> */ -#ifdef _SYS_IOCTL_H_ -int _thread_sys_ioctl(int, unsigned long, ...); -#endif - -/* #include <dirent.h> */ -#ifdef _DIRENT_H_ -DIR *___thread_sys_opendir2(const char *, int); -DIR *_thread_sys_opendir(const char *); -int _thread_sys_alphasort(const void *, const void *); -int _thread_sys_scandir(const char *, struct dirent ***, - int (*)(struct dirent *), int (*)(const void *, const void *)); -int _thread_sys_closedir(DIR *); -int _thread_sys_getdirentries(int, char *, int, long *); -long _thread_sys_telldir(const DIR *); -struct dirent *_thread_sys_readdir(DIR *); -void _thread_sys_rewinddir(DIR *); -void _thread_sys_seekdir(DIR *, long); -#endif - -/* #include <sys/uio.h> */ -#ifdef _SYS_UIO_H_ -ssize_t _thread_sys_readv(int, const struct iovec *, int); -ssize_t _thread_sys_writev(int, const struct iovec *, int); -#endif - -/* #include <sys/wait.h> */ -#ifdef WNOHANG -pid_t _thread_sys_wait(int *); -pid_t _thread_sys_waitpid(pid_t, int *, int); -pid_t _thread_sys_wait3(int *, int, struct rusage *); -pid_t _thread_sys_wait4(pid_t, int *, int, struct rusage *); -#endif -__END_DECLS - -#endif /* !_PTHREAD_PRIVATE_H */ diff --git a/lib/libpthread/thread/thr_read.c b/lib/libpthread/thread/thr_read.c deleted file mode 100644 index 6c4d211218768..0000000000000 --- a/lib/libpthread/thread/thr_read.c +++ /dev/null @@ -1,97 +0,0 @@ -/* - * Copyright (c) 1995-1998 John Birrell <jb@cimlogic.com.au> - * 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 John Birrell. - * 4. Neither the name of the author nor the names of any co-contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY JOHN BIRRELL 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. - * - * $Id: uthread_read.c,v 1.5 1998/06/09 23:20:53 jb Exp $ - * - */ -#include <sys/types.h> -#include <sys/fcntl.h> -#include <sys/uio.h> -#include <errno.h> -#include <unistd.h> -#ifdef _THREAD_SAFE -#include <pthread.h> -#include "pthread_private.h" - -ssize_t -read(int fd, void *buf, size_t nbytes) -{ - int ret; - int type; - - /* POSIX says to do just this: */ - if (nbytes == 0) - return (0); - - /* Lock the file descriptor for read: */ - if ((ret = _FD_LOCK(fd, FD_READ, NULL)) == 0) { - /* Get the read/write mode type: */ - type = _thread_fd_table[fd]->flags & O_ACCMODE; - - /* Check if the file is not open for read: */ - if (type != O_RDONLY && type != O_RDWR) { - /* File is not open for read: */ - errno = EBADF; - _FD_UNLOCK(fd, FD_READ); - return (-1); - } - - /* Perform a non-blocking read syscall: */ - while ((ret = _thread_sys_read(fd, buf, nbytes)) < 0) { - if ((_thread_fd_table[fd]->flags & O_NONBLOCK) == 0 && - (errno == EWOULDBLOCK || errno == EAGAIN)) { - _thread_run->data.fd.fd = fd; - _thread_kern_set_timeout(NULL); - - /* Reset the interrupted operation flag: */ - _thread_run->interrupted = 0; - - _thread_kern_sched_state(PS_FDR_WAIT, - __FILE__, __LINE__); - - /* - * Check if the operation was - * interrupted by a signal - */ - if (_thread_run->interrupted) { - errno = EINTR; - ret = -1; - break; - } - } else { - break; - } - } - _FD_UNLOCK(fd, FD_READ); - } - return (ret); -} -#endif diff --git a/lib/libpthread/thread/thr_readv.c b/lib/libpthread/thread/thr_readv.c deleted file mode 100644 index 819e20cbc257f..0000000000000 --- a/lib/libpthread/thread/thr_readv.c +++ /dev/null @@ -1,93 +0,0 @@ -/* - * Copyright (c) 1995-1998 John Birrell <jb@cimlogic.com.au> - * 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 John Birrell. - * 4. Neither the name of the author nor the names of any co-contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY JOHN BIRRELL 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. - * - * $Id: uthread_readv.c,v 1.5 1998/06/09 23:20:54 jb Exp $ - * - */ -#include <sys/types.h> -#include <sys/fcntl.h> -#include <sys/uio.h> -#include <errno.h> -#include <unistd.h> -#ifdef _THREAD_SAFE -#include <pthread.h> -#include "pthread_private.h" - -ssize_t -readv(int fd, const struct iovec * iov, int iovcnt) -{ - int ret; - int type; - - /* Lock the file descriptor for read: */ - if ((ret = _FD_LOCK(fd, FD_READ, NULL)) == 0) { - /* Get the read/write mode type: */ - type = _thread_fd_table[fd]->flags & O_ACCMODE; - - /* Check if the file is not open for read: */ - if (type != O_RDONLY && type != O_RDWR) { - /* File is not open for read: */ - errno = EBADF; - _FD_UNLOCK(fd, FD_READ); - return (-1); - } - - /* Perform a non-blocking readv syscall: */ - while ((ret = _thread_sys_readv(fd, iov, iovcnt)) < 0) { - if ((_thread_fd_table[fd]->flags & O_NONBLOCK) == 0 && - (errno == EWOULDBLOCK || errno == EAGAIN)) { - _thread_run->data.fd.fd = fd; - _thread_kern_set_timeout(NULL); - - /* Reset the interrupted operation flag: */ - _thread_run->interrupted = 0; - - _thread_kern_sched_state(PS_FDR_WAIT, - __FILE__, __LINE__); - - /* - * Check if the operation was - * interrupted by a signal - */ - if (_thread_run->interrupted) { - errno = EINTR; - ret = -1; - break; - } - } else { - break; - } - } - _FD_UNLOCK(fd, FD_READ); - } - return (ret); -} -#endif diff --git a/lib/libpthread/thread/thr_resume_np.c b/lib/libpthread/thread/thr_resume_np.c deleted file mode 100644 index 7c5f46adfcef5..0000000000000 --- a/lib/libpthread/thread/thr_resume_np.c +++ /dev/null @@ -1,54 +0,0 @@ -/* - * Copyright (c) 1995 John Birrell <jb@cimlogic.com.au>. - * 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 John Birrell. - * 4. Neither the name of the author nor the names of any co-contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY JOHN BIRRELL 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 <errno.h> -#ifdef _THREAD_SAFE -#include <pthread.h> -#include "pthread_private.h" - -/* Resume a thread: */ -int -pthread_resume_np(pthread_t thread) -{ - int ret; - - /* Find the thread in the list of active threads: */ - if ((ret = _find_thread(thread)) == 0) { - /* The thread exists. Is it suspended? */ - if (thread->state != PS_SUSPENDED) { - /* Allow the thread to run. */ - PTHREAD_NEW_STATE(thread,PS_RUNNING); - } - } - return(ret); -} -#endif diff --git a/lib/libpthread/thread/thr_rwlock.c b/lib/libpthread/thread/thr_rwlock.c deleted file mode 100644 index f398a1857d4a5..0000000000000 --- a/lib/libpthread/thread/thr_rwlock.c +++ /dev/null @@ -1,335 +0,0 @@ -/*- - * Copyright (c) 1998 Alex Nash - * 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. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR 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 AUTHOR 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. - * - * $Id: uthread_rwlock.c,v 1.2 1998/09/07 19:23:55 alex Exp $ - */ - -#ifdef _THREAD_SAFE -#include <errno.h> -#include <limits.h> -#include <stdlib.h> - -#include <pthread.h> -#include "pthread_private.h" - -/* maximum number of times a read lock may be obtained */ -#define MAX_READ_LOCKS (INT_MAX - 1) - -static int init_static (pthread_rwlock_t *rwlock); - -static spinlock_t static_init_lock = _SPINLOCK_INITIALIZER; - -static int -init_static (pthread_rwlock_t *rwlock) -{ - int ret; - - _SPINLOCK(&static_init_lock); - - if (*rwlock == NULL) - ret = pthread_rwlock_init(rwlock, NULL); - else - ret = 0; - - _SPINUNLOCK(&static_init_lock); - - return(ret); -} - -int -pthread_rwlock_destroy (pthread_rwlock_t *rwlock) -{ - int ret; - - if (rwlock == NULL) - ret = EINVAL; - else { - pthread_rwlock_t prwlock; - - prwlock = *rwlock; - - pthread_mutex_destroy(&prwlock->lock); - pthread_cond_destroy(&prwlock->read_signal); - pthread_cond_destroy(&prwlock->write_signal); - free(prwlock); - - *rwlock = NULL; - - ret = 0; - } - - return(ret); -} - -int -pthread_rwlock_init (pthread_rwlock_t *rwlock, const pthread_rwlockattr_t *attr) -{ - pthread_rwlock_t prwlock; - int ret; - - /* allocate rwlock object */ - prwlock = (pthread_rwlock_t)malloc(sizeof(struct pthread_rwlock)); - - if (prwlock == NULL) - return(ENOMEM); - - /* initialize the lock */ - if ((ret = pthread_mutex_init(&prwlock->lock, NULL)) != 0) - free(prwlock); - else { - /* initialize the read condition signal */ - ret = pthread_cond_init(&prwlock->read_signal, NULL); - - if (ret != 0) { - pthread_mutex_destroy(&prwlock->lock); - free(prwlock); - } else { - /* initialize the write condition signal */ - ret = pthread_cond_init(&prwlock->write_signal, NULL); - - if (ret != 0) { - pthread_cond_destroy(&prwlock->read_signal); - pthread_mutex_destroy(&prwlock->lock); - free(prwlock); - } else { - /* success */ - prwlock->state = 0; - prwlock->blocked_writers = 0; - - *rwlock = prwlock; - } - } - } - - return(ret); -} - -int -pthread_rwlock_rdlock (pthread_rwlock_t *rwlock) -{ - pthread_rwlock_t prwlock; - int ret; - - if (rwlock == NULL) - return(EINVAL); - - prwlock = *rwlock; - - /* check for static initialization */ - if (prwlock == NULL) { - if ((ret = init_static(rwlock)) != 0) - return(ret); - - prwlock = *rwlock; - } - - /* grab the monitor lock */ - if ((ret = pthread_mutex_lock(&prwlock->lock)) != 0) - return(ret); - - /* give writers priority over readers */ - while (prwlock->blocked_writers || prwlock->state < 0) { - ret = pthread_cond_wait(&prwlock->read_signal, &prwlock->lock); - - if (ret != 0) { - /* can't do a whole lot if this fails */ - pthread_mutex_unlock(&prwlock->lock); - return(ret); - } - } - - /* check lock count */ - if (prwlock->state == MAX_READ_LOCKS) - ret = EAGAIN; - else - ++prwlock->state; /* indicate we are locked for reading */ - - /* - * Something is really wrong if this call fails. Returning - * error won't do because we've already obtained the read - * lock. Decrementing 'state' is no good because we probably - * don't have the monitor lock. - */ - pthread_mutex_unlock(&prwlock->lock); - - return(ret); -} - -int -pthread_rwlock_tryrdlock (pthread_rwlock_t *rwlock) -{ - pthread_rwlock_t prwlock; - int ret; - - if (rwlock == NULL) - return(EINVAL); - - prwlock = *rwlock; - - /* check for static initialization */ - if (prwlock == NULL) { - if ((ret = init_static(rwlock)) != 0) - return(ret); - - prwlock = *rwlock; - } - - /* grab the monitor lock */ - if ((ret = pthread_mutex_lock(&prwlock->lock)) != 0) - return(ret); - - /* give writers priority over readers */ - if (prwlock->blocked_writers || prwlock->state < 0) - ret = EWOULDBLOCK; - else if (prwlock->state == MAX_READ_LOCKS) - ret = EAGAIN; /* too many read locks acquired */ - else - ++prwlock->state; /* indicate we are locked for reading */ - - /* see the comment on this in pthread_rwlock_rdlock */ - pthread_mutex_unlock(&prwlock->lock); - - return(ret); -} - -int -pthread_rwlock_trywrlock (pthread_rwlock_t *rwlock) -{ - pthread_rwlock_t prwlock; - int ret; - - if (rwlock == NULL) - return(EINVAL); - - prwlock = *rwlock; - - /* check for static initialization */ - if (prwlock == NULL) { - if ((ret = init_static(rwlock)) != 0) - return(ret); - - prwlock = *rwlock; - } - - /* grab the monitor lock */ - if ((ret = pthread_mutex_lock(&prwlock->lock)) != 0) - return(ret); - - if (prwlock->state != 0) - ret = EWOULDBLOCK; - else - /* indicate we are locked for writing */ - prwlock->state = -1; - - /* see the comment on this in pthread_rwlock_rdlock */ - pthread_mutex_unlock(&prwlock->lock); - - return(ret); -} - -int -pthread_rwlock_unlock (pthread_rwlock_t *rwlock) -{ - pthread_rwlock_t prwlock; - int ret; - - if (rwlock == NULL) - return(EINVAL); - - prwlock = *rwlock; - - if (prwlock == NULL) - return(EINVAL); - - /* grab the monitor lock */ - if ((ret = pthread_mutex_lock(&prwlock->lock)) != 0) - return(ret); - - if (prwlock->state > 0) { - if (--prwlock->state == 0 && prwlock->blocked_writers) - ret = pthread_cond_signal(&prwlock->write_signal); - } else if (prwlock->state < 0) { - prwlock->state = 0; - - if (prwlock->blocked_writers) - ret = pthread_cond_signal(&prwlock->write_signal); - else - ret = pthread_cond_broadcast(&prwlock->read_signal); - } else - ret = EINVAL; - - /* see the comment on this in pthread_rwlock_rdlock */ - pthread_mutex_unlock(&prwlock->lock); - - return(ret); -} - -int -pthread_rwlock_wrlock (pthread_rwlock_t *rwlock) -{ - pthread_rwlock_t prwlock; - int ret; - - if (rwlock == NULL) - return(EINVAL); - - prwlock = *rwlock; - - /* check for static initialization */ - if (prwlock == NULL) { - if ((ret = init_static(rwlock)) != 0) - return(ret); - - prwlock = *rwlock; - } - - /* grab the monitor lock */ - if ((ret = pthread_mutex_lock(&prwlock->lock)) != 0) - return(ret); - - while (prwlock->state != 0) { - ++prwlock->blocked_writers; - - ret = pthread_cond_wait(&prwlock->write_signal, &prwlock->lock); - - if (ret != 0) { - --prwlock->blocked_writers; - pthread_mutex_unlock(&prwlock->lock); - return(ret); - } - - --prwlock->blocked_writers; - } - - /* indicate we are locked for writing */ - prwlock->state = -1; - - /* see the comment on this in pthread_rwlock_rdlock */ - pthread_mutex_unlock(&prwlock->lock); - - return(ret); -} - -#endif /* _THREAD_SAFE */ diff --git a/lib/libpthread/thread/thr_rwlockattr.c b/lib/libpthread/thread/thr_rwlockattr.c deleted file mode 100644 index 50b128b928072..0000000000000 --- a/lib/libpthread/thread/thr_rwlockattr.c +++ /dev/null @@ -1,98 +0,0 @@ -/*- - * Copyright (c) 1998 Alex Nash - * 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. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR 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 AUTHOR 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. - * - * $Id: uthread_rwlockattr.c,v 1.1 1998/09/07 19:01:43 alex Exp $ - */ - -#ifdef _THREAD_SAFE -#include <errno.h> -#include <stdlib.h> - -#include <pthread.h> -#include "pthread_private.h" - -int -pthread_rwlockattr_destroy (pthread_rwlockattr_t *rwlockattr) -{ - pthread_rwlockattr_t prwlockattr; - - if (rwlockattr == NULL) - return(EINVAL); - - prwlockattr = *rwlockattr; - - if (prwlockattr == NULL) - return(EINVAL); - - free(prwlockattr); - - return(0); -} - -int -pthread_rwlockattr_getpshared (const pthread_rwlockattr_t *rwlockattr, - int *pshared) -{ - *pshared = (*rwlockattr)->pshared; - - return(0); -} - -int -pthread_rwlockattr_init (pthread_rwlockattr_t *rwlockattr) -{ - pthread_rwlockattr_t prwlockattr; - - if (rwlockattr == NULL) - return(EINVAL); - - prwlockattr = (pthread_rwlockattr_t) - malloc(sizeof(struct pthread_rwlockattr)); - - if (prwlockattr == NULL) - return(ENOMEM); - - prwlockattr->pshared = PTHREAD_PROCESS_PRIVATE; - *rwlockattr = prwlockattr; - - return(0); -} - -int -pthread_rwlockattr_setpshared (pthread_rwlockattr_t *rwlockattr, - int *pshared) -{ - int ps = *pshared; - - /* only PTHREAD_PROCESS_PRIVATE is supported */ - if (ps != PTHREAD_PROCESS_PRIVATE) - return(EINVAL); - - (*rwlockattr)->pshared = ps; - - return(0); -} - -#endif /* _THREAD_SAFE */ diff --git a/lib/libpthread/thread/thr_select.c b/lib/libpthread/thread/thr_select.c deleted file mode 100644 index d6202db01406d..0000000000000 --- a/lib/libpthread/thread/thr_select.c +++ /dev/null @@ -1,177 +0,0 @@ -/* - * Copyright (c) 1995-1998 John Birrell <jb@cimlogic.com.au> - * 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 John Birrell. - * 4. Neither the name of the author nor the names of any co-contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY JOHN BIRRELL 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 <unistd.h> -#include <errno.h> -#include <string.h> -#include <sys/types.h> -#include <sys/time.h> -#ifdef _THREAD_SAFE -#include <pthread.h> -#include "pthread_private.h" - -int -select(int numfds, fd_set * readfds, fd_set * writefds, - fd_set * exceptfds, struct timeval * timeout) -{ - fd_set read_locks, write_locks, rdwr_locks; - struct timespec ts; - struct timeval zero_timeout = {0, 0}; - int i, ret = 0, got_all_locks = 1; - struct pthread_select_data data; - - if (numfds > _thread_dtablesize) { - numfds = _thread_dtablesize; - } - /* Check if a timeout was specified: */ - if (timeout) { - /* Convert the timeval to a timespec: */ - TIMEVAL_TO_TIMESPEC(timeout, &ts); - - /* Set the wake up time: */ - _thread_kern_set_timeout(&ts); - } else { - /* Wait for ever: */ - _thread_kern_set_timeout(NULL); - } - - FD_ZERO(&read_locks); - FD_ZERO(&write_locks); - FD_ZERO(&rdwr_locks); - - /* lock readfds */ - if (readfds || writefds || exceptfds) { - for (i = 0; i < numfds; i++) { - if ((readfds && (FD_ISSET(i, readfds))) || (exceptfds && FD_ISSET(i, exceptfds))) { - if (writefds && FD_ISSET(i, writefds)) { - if ((ret = _FD_LOCK(i, FD_RDWR, NULL)) != 0) { - got_all_locks = 0; - break; - } - FD_SET(i, &rdwr_locks); - } else { - if ((ret = _FD_LOCK(i, FD_READ, NULL)) != 0) { - got_all_locks = 0; - break; - } - FD_SET(i, &read_locks); - } - } else { - if (writefds && FD_ISSET(i, writefds)) { - if ((ret = _FD_LOCK(i, FD_WRITE, NULL)) != 0) { - got_all_locks = 0; - break; - } - FD_SET(i, &write_locks); - } - } - } - } - if (got_all_locks) { - data.nfds = numfds; - FD_ZERO(&data.readfds); - FD_ZERO(&data.writefds); - FD_ZERO(&data.exceptfds); - if (readfds != NULL) { - memcpy(&data.readfds, readfds, sizeof(data.readfds)); - } - if (writefds != NULL) { - memcpy(&data.writefds, writefds, sizeof(data.writefds)); - } - if (exceptfds != NULL) { - memcpy(&data.exceptfds, exceptfds, sizeof(data.exceptfds)); - } - if ((ret = _thread_sys_select(data.nfds, &data.readfds, &data.writefds, &data.exceptfds, &zero_timeout)) == 0) { - data.nfds = numfds; - FD_ZERO(&data.readfds); - FD_ZERO(&data.writefds); - FD_ZERO(&data.exceptfds); - if (readfds != NULL) { - memcpy(&data.readfds, readfds, sizeof(data.readfds)); - } - if (writefds != NULL) { - memcpy(&data.writefds, writefds, sizeof(data.writefds)); - } - if (exceptfds != NULL) { - memcpy(&data.exceptfds, exceptfds, sizeof(data.exceptfds)); - } - _thread_run->data.select_data = &data; - _thread_run->interrupted = 0; - _thread_kern_sched_state(PS_SELECT_WAIT, __FILE__, __LINE__); - if (_thread_run->interrupted) { - errno = EINTR; - ret = -1; - } else - ret = data.nfds; - } - } - /* clean up the locks */ - for (i = 0; i < numfds; i++) - if (FD_ISSET(i, &read_locks)) - _FD_UNLOCK(i, FD_READ); - for (i = 0; i < numfds; i++) - if (FD_ISSET(i, &rdwr_locks)) - _FD_UNLOCK(i, FD_RDWR); - for (i = 0; i < numfds; i++) - if (FD_ISSET(i, &write_locks)) - _FD_UNLOCK(i, FD_WRITE); - - if (ret >= 0) { - if (readfds != NULL) { - for (i = 0; i < numfds; i++) { - if (FD_ISSET(i, readfds) && - !FD_ISSET(i, &data.readfds)) { - FD_CLR(i, readfds); - } - } - } - if (writefds != NULL) { - for (i = 0; i < numfds; i++) { - if (FD_ISSET(i, writefds) && - !FD_ISSET(i, &data.writefds)) { - FD_CLR(i, writefds); - } - } - } - if (exceptfds != NULL) { - for (i = 0; i < numfds; i++) { - if (FD_ISSET(i, exceptfds) && - !FD_ISSET(i, &data.exceptfds)) { - FD_CLR(i, exceptfds); - } - } - } - } - - return (ret); -} -#endif diff --git a/lib/libpthread/thread/thr_self.c b/lib/libpthread/thread/thr_self.c deleted file mode 100644 index a0a2d2aded6e2..0000000000000 --- a/lib/libpthread/thread/thr_self.c +++ /dev/null @@ -1,43 +0,0 @@ -/* - * Copyright (c) 1995 John Birrell <jb@cimlogic.com.au>. - * 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 John Birrell. - * 4. Neither the name of the author nor the names of any co-contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY JOHN BIRRELL 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. - * - */ -#ifdef _THREAD_SAFE -#include <pthread.h> -#include "pthread_private.h" - -pthread_t -pthread_self(void) -{ - /* Return the running thread pointer: */ - return (_thread_run); -} -#endif diff --git a/lib/libpthread/thread/thr_seterrno.c b/lib/libpthread/thread/thr_seterrno.c deleted file mode 100644 index 570807f1fc7e5..0000000000000 --- a/lib/libpthread/thread/thr_seterrno.c +++ /dev/null @@ -1,60 +0,0 @@ -/* - * Copyright (c) 1995 John Birrell <jb@cimlogic.com.au>. - * 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 John Birrell. - * 4. Neither the name of the author nor the names of any co-contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY JOHN BIRRELL 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. - * - */ -#ifdef _THREAD_SAFE -#include <pthread.h> -#include "pthread_private.h" - -/* - * This function needs to reference the global error variable which is - * normally hidden from the user. - */ -#ifdef errno -#undef errno; -#endif -extern int errno; - -void -_thread_seterrno(pthread_t thread, int error) -{ - /* Check for the initial thread: */ - if (thread == _thread_initial) - /* The initial thread always uses the global error variable: */ - errno = error; - else - /* - * Threads other than the initial thread always use the error - * field in the thread structureL - */ - thread->error = error; -} -#endif diff --git a/lib/libpthread/thread/thr_setprio.c b/lib/libpthread/thread/thr_setprio.c deleted file mode 100644 index dd89f156a50fd..0000000000000 --- a/lib/libpthread/thread/thr_setprio.c +++ /dev/null @@ -1,56 +0,0 @@ -/* - * Copyright (c) 1995 John Birrell <jb@cimlogic.com.au>. - * 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 John Birrell. - * 4. Neither the name of the author nor the names of any co-contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY JOHN BIRRELL 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 <errno.h> -#ifdef _THREAD_SAFE -#include <pthread.h> -#include "pthread_private.h" - -int -pthread_setprio(pthread_t pthread, int prio) -{ - int ret; - - /* Check if the priority is invalid: */ - if (prio < PTHREAD_MIN_PRIORITY || prio > PTHREAD_MAX_PRIORITY) - /* Return an invalid argument error: */ - ret = EINVAL; - - /* Find the thread in the list of active threads: */ - else if ((ret = _find_thread(pthread)) == 0) - /* Set the thread priority: */ - pthread->pthread_priority = prio; - - /* Return the error status: */ - return (ret); -} -#endif diff --git a/lib/libpthread/thread/thr_sig.c b/lib/libpthread/thread/thr_sig.c deleted file mode 100644 index 3e55d6505a36b..0000000000000 --- a/lib/libpthread/thread/thr_sig.c +++ /dev/null @@ -1,335 +0,0 @@ -/* - * Copyright (c) 1995-1998 John Birrell <jb@cimlogic.com.au> - * 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 John Birrell. - * 4. Neither the name of the author nor the names of any co-contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY JOHN BIRRELL 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 <signal.h> -#include <fcntl.h> -#include <unistd.h> -#include <errno.h> -#ifdef _THREAD_SAFE -#include <pthread.h> -#include "pthread_private.h" - -/* Static variables: */ -static int volatile yield_on_unlock_thread = 0; -static spinlock_t thread_link_list_lock = _SPINLOCK_INITIALIZER; - -/* Lock the thread list: */ -void -_lock_thread_list() -{ - /* Lock the thread list: */ - _SPINLOCK(&thread_link_list_lock); -} - -/* Lock the thread list: */ -void -_unlock_thread_list() -{ - /* Unlock the thread list: */ - _SPINUNLOCK(&thread_link_list_lock); - - /* - * Check if a scheduler interrupt occurred while the thread - * list was locked: - */ - if (yield_on_unlock_thread) { - /* Reset the interrupt flag: */ - yield_on_unlock_thread = 0; - - /* This thread has overstayed it's welcome: */ - sched_yield(); - } -} - -void -_thread_sig_handler(int sig, int code, struct sigcontext * scp) -{ - char c; - int i; - pthread_t pthread; - - /* - * Check if the pthread kernel has unblocked signals (or is about to) - * and was on its way into a _select when the current - * signal interrupted it: - */ - if (_thread_kern_in_select) { - /* Cast the signal number to a character variable: */ - c = sig; - - /* - * Write the signal number to the kernel pipe so that it will - * be ready to read when this signal handler returns. This - * means that the _select call will complete - * immediately. - */ - _thread_sys_write(_thread_kern_pipe[1], &c, 1); - } - - /* Check if the signal requires a dump of thread information: */ - if (sig == SIGINFO) - /* Dump thread information to file: */ - _thread_dump_info(); - - /* Check if an interval timer signal: */ - else if (sig == SIGVTALRM) { - /* Check if the scheduler interrupt has come at an - * unfortunate time which one of the threads is - * modifying the thread list: - */ - if (thread_link_list_lock.access_lock) - /* - * Set a flag so that the thread that has - * the lock yields when it unlocks the - * thread list: - */ - yield_on_unlock_thread = 1; - - /* - * Check if the kernel has not been interrupted while - * executing scheduler code: - */ - else if (!_thread_kern_in_sched) { - /* - * Schedule the next thread. This function is not - * expected to return because it will do a longjmp - * instead. - */ - _thread_kern_sched(scp); - - /* - * This point should not be reached, so abort the - * process: - */ - PANIC("Returned to signal function from scheduler"); - } - } else { - /* Check if a child has terminated: */ - if (sig == SIGCHLD) { - /* - * Go through the file list and set all files - * to non-blocking again in case the child - * set some of them to block. Sigh. - */ - for (i = 0; i < _thread_dtablesize; i++) { - /* Check if this file is used: */ - if (_thread_fd_table[i] != NULL) { - /* - * Set the file descriptor to - * non-blocking: - */ - _thread_sys_fcntl(i, F_SETFL, - _thread_fd_table[i]->flags | - O_NONBLOCK); - } - } - } - - /* - * POSIX says that pending SIGCONT signals are - * discarded when one of these signals occurs. - */ - if (sig == SIGTSTP || sig == SIGTTIN || sig == SIGTTOU) { - /* - * Enter a loop to discard pending SIGCONT - * signals: - */ - for (pthread = _thread_link_list; - pthread != NULL; - pthread = pthread->nxt) - sigdelset(&pthread->sigpend,SIGCONT); - } - - /* - * Enter a loop to process each thread in the linked - * list that is sigwait-ing on a signal. Since POSIX - * doesn't specify which thread will get the signal - * if there are multiple waiters, we'll give it to the - * first one we find. - */ - for (pthread = _thread_link_list; pthread != NULL; - pthread = pthread->nxt) { - if ((pthread->state == PS_SIGWAIT) && - sigismember(pthread->data.sigwait, sig)) { - /* Change the state of the thread to run: */ - PTHREAD_NEW_STATE(pthread,PS_RUNNING); - - /* Return the signal number: */ - pthread->signo = sig; - - /* - * Do not attempt to deliver this signal - * to other threads. - */ - return; - } - } - - /* Check if the signal is not being ignored: */ - if (_thread_sigact[sig - 1].sa_handler != SIG_IGN) - /* - * Enter a loop to process each thread in the linked - * list: - */ - for (pthread = _thread_link_list; pthread != NULL; - pthread = pthread->nxt) - _thread_signal(pthread,sig); - - /* Dispatch pending signals to the running thread: */ - _dispatch_signals(); - } - - /* Returns nothing. */ - return; -} - -/* Perform thread specific actions in response to a signal: */ -void -_thread_signal(pthread_t pthread, int sig) -{ - /* - * Flag the signal as pending. It will be dispatched later. - */ - sigaddset(&pthread->sigpend,sig); - - /* - * Process according to thread state: - */ - switch (pthread->state) { - /* - * States which do not change when a signal is trapped: - */ - case PS_COND_WAIT: - case PS_DEAD: - case PS_FDLR_WAIT: - case PS_FDLW_WAIT: - case PS_FILE_WAIT: - case PS_JOIN: - case PS_MUTEX_WAIT: - case PS_RUNNING: - case PS_STATE_MAX: - case PS_SIGTHREAD: - case PS_SIGWAIT: - case PS_SUSPENDED: - /* Nothing to do here. */ - break; - - /* - * The wait state is a special case due to the handling of - * SIGCHLD signals. - */ - case PS_WAIT_WAIT: - /* - * Check for signals other than the death of a child - * process: - */ - if (sig != SIGCHLD) - /* Flag the operation as interrupted: */ - pthread->interrupted = 1; - - /* Change the state of the thread to run: */ - PTHREAD_NEW_STATE(pthread,PS_RUNNING); - - /* Return the signal number: */ - pthread->signo = sig; - break; - - /* - * States that are interrupted by the occurrence of a signal - * other than the scheduling alarm: - */ - case PS_FDR_WAIT: - case PS_FDW_WAIT: - case PS_SLEEP_WAIT: - case PS_SELECT_WAIT: - if (sig != SIGCHLD || - _thread_sigact[sig - 1].sa_handler != SIG_DFL) { - /* Flag the operation as interrupted: */ - pthread->interrupted = 1; - - /* Change the state of the thread to run: */ - PTHREAD_NEW_STATE(pthread,PS_RUNNING); - - /* Return the signal number: */ - pthread->signo = sig; - } - break; - - case PS_SIGSUSPEND: - /* - * Only wake up the thread if the signal is unblocked - * and there is a handler installed for the signal. - */ - if (!sigismember(&pthread->sigmask, sig) && - _thread_sigact[sig - 1].sa_handler != SIG_DFL) { - /* Change the state of the thread to run: */ - PTHREAD_NEW_STATE(pthread,PS_RUNNING); - - /* Return the signal number: */ - pthread->signo = sig; - } - break; - } -} - -/* Dispatch pending signals to the running thread: */ -void -_dispatch_signals() -{ - int i; - - /* - * Check if there are pending signals for the running - * thread that aren't blocked: - */ - if ((_thread_run->sigpend & ~_thread_run->sigmask) != 0) - /* Look for all possible pending signals: */ - for (i = 1; i < NSIG; i++) - /* - * Check that a custom handler is installed - * and if the signal is not blocked: - */ - if (_thread_sigact[i - 1].sa_handler != SIG_DFL && - _thread_sigact[i - 1].sa_handler != SIG_IGN && - sigismember(&_thread_run->sigpend,i) && - !sigismember(&_thread_run->sigmask,i)) { - /* Clear the pending signal: */ - sigdelset(&_thread_run->sigpend,i); - - /* - * Dispatch the signal via the custom signal - * handler: - */ - (*(_thread_sigact[i - 1].sa_handler))(i); - } -} -#endif diff --git a/lib/libpthread/thread/thr_sigaction.c b/lib/libpthread/thread/thr_sigaction.c deleted file mode 100644 index 40f3850008e0d..0000000000000 --- a/lib/libpthread/thread/thr_sigaction.c +++ /dev/null @@ -1,104 +0,0 @@ -/* - * Copyright (c) 1995-1998 John Birrell <jb@cimlogic.com.au> - * 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 John Birrell. - * 4. Neither the name of the author nor the names of any co-contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY JOHN BIRRELL 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 <signal.h> -#include <errno.h> -#ifdef _THREAD_SAFE -#include <pthread.h> -#include "pthread_private.h" - -int -sigaction(int sig, const struct sigaction * act, struct sigaction * oact) -{ - int ret = 0; - struct sigaction gact; - - /* Check if the signal number is out of range: */ - if (sig < 1 || sig > NSIG) { - /* Return an invalid argument: */ - errno = EINVAL; - ret = -1; - } else { - /* - * Check if the existing signal action structure contents are - * to be returned: - */ - if (oact != NULL) { - /* Return the existing signal action contents: */ - oact->sa_handler = _thread_sigact[sig - 1].sa_handler; - oact->sa_mask = _thread_sigact[sig - 1].sa_mask; - oact->sa_flags = _thread_sigact[sig - 1].sa_flags; - } - - /* Check if a signal action was supplied: */ - if (act != NULL) { - /* Set the new signal handler: */ - _thread_sigact[sig - 1].sa_mask = act->sa_mask; - _thread_sigact[sig - 1].sa_flags = act->sa_flags; - _thread_sigact[sig - 1].sa_handler = act->sa_handler; - } - - /* - * Check if the kernel needs to be advised of a change - * in signal action: - */ - if (act != NULL && sig != SIGVTALRM && sig != SIGCHLD && - sig != SIGINFO) { - /* Initialise the global signal action structure: */ - gact.sa_mask = act->sa_mask; - gact.sa_flags = 0; - - /* - * Check if the signal handler is being set to - * the default or ignore handlers: - */ - if (act->sa_handler == SIG_DFL || - act->sa_handler == SIG_IGN) - /* Specify the built in handler: */ - gact.sa_handler = act->sa_handler; - else - /* - * Specify the thread kernel signal - * handler: - */ - gact.sa_handler = (void (*) ()) _thread_sig_handler; - - /* Change the signal action in the kernel: */ - if (_thread_sys_sigaction(sig,&gact,NULL) != 0) - ret = -1; - } - } - - /* Return the completion status: */ - return (ret); -} -#endif diff --git a/lib/libpthread/thread/thr_sigmask.c b/lib/libpthread/thread/thr_sigmask.c deleted file mode 100644 index 23d6b7ff2a3e2..0000000000000 --- a/lib/libpthread/thread/thr_sigmask.c +++ /dev/null @@ -1,89 +0,0 @@ -/* - * Copyright (c) 1997 John Birrell <jb@cimlogic.com.au>. - * 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 John Birrell. - * 4. Neither the name of the author nor the names of any co-contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY JOHN BIRRELL 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 <errno.h> -#include <signal.h> -#ifdef _THREAD_SAFE -#include <pthread.h> -#include "pthread_private.h" - -int -pthread_sigmask(int how, const sigset_t *set, sigset_t *oset) -{ - int ret = 0; - - /* Check if the existing signal process mask is to be returned: */ - if (oset != NULL) { - /* Return the current mask: */ - *oset = _thread_run->sigmask; - } - /* Check if a new signal set was provided by the caller: */ - if (set != NULL) { - /* Process according to what to do: */ - switch (how) { - /* Block signals: */ - case SIG_BLOCK: - /* Add signals to the existing mask: */ - _thread_run->sigmask |= *set; - break; - - /* Unblock signals: */ - case SIG_UNBLOCK: - /* Clear signals from the existing mask: */ - _thread_run->sigmask &= ~(*set); - break; - - /* Set the signal process mask: */ - case SIG_SETMASK: - /* Set the new mask: */ - _thread_run->sigmask = *set; - break; - - /* Trap invalid actions: */ - default: - /* Return an invalid argument: */ - errno = EINVAL; - ret = -1; - break; - } - - /* - * Dispatch signals to the running thread that are pending - * and now unblocked: - */ - _dispatch_signals(); - } - - /* Return the completion status: */ - return (ret); -} -#endif diff --git a/lib/libpthread/thread/thr_sigprocmask.c b/lib/libpthread/thread/thr_sigprocmask.c deleted file mode 100644 index 81b602f581c8a..0000000000000 --- a/lib/libpthread/thread/thr_sigprocmask.c +++ /dev/null @@ -1,88 +0,0 @@ -/* - * Copyright (c) 1995 John Birrell <jb@cimlogic.com.au>. - * 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 John Birrell. - * 4. Neither the name of the author nor the names of any co-contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY JOHN BIRRELL 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 <signal.h> -#include <errno.h> -#ifdef _THREAD_SAFE -#include <pthread.h> -#include "pthread_private.h" - -int -sigprocmask(int how, const sigset_t * set, sigset_t * oset) -{ - int ret = 0; - - /* Check if the existing signal process mask is to be returned: */ - if (oset != NULL) { - /* Return the current mask: */ - *oset = _thread_run->sigmask; - } - /* Check if a new signal set was provided by the caller: */ - if (set != NULL) { - /* Process according to what to do: */ - switch (how) { - /* Block signals: */ - case SIG_BLOCK: - /* Add signals to the existing mask: */ - _thread_run->sigmask |= *set; - break; - - /* Unblock signals: */ - case SIG_UNBLOCK: - /* Clear signals from the existing mask: */ - _thread_run->sigmask &= ~(*set); - break; - - /* Set the signal process mask: */ - case SIG_SETMASK: - /* Set the new mask: */ - _thread_run->sigmask = *set; - break; - - /* Trap invalid actions: */ - default: - /* Return an invalid argument: */ - errno = EINVAL; - ret = -1; - break; - } - - /* - * Dispatch signals to the running thread that are pending - * and now unblocked: - */ - _dispatch_signals(); - } - /* Return the completion status: */ - return (ret); -} -#endif diff --git a/lib/libpthread/thread/thr_sigsuspend.c b/lib/libpthread/thread/thr_sigsuspend.c deleted file mode 100644 index 0ae9a4f7b3efe..0000000000000 --- a/lib/libpthread/thread/thr_sigsuspend.c +++ /dev/null @@ -1,69 +0,0 @@ -/* - * Copyright (c) 1995 John Birrell <jb@cimlogic.com.au>. - * 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 John Birrell. - * 4. Neither the name of the author nor the names of any co-contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY JOHN BIRRELL 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 <signal.h> -#include <errno.h> -#ifdef _THREAD_SAFE -#include <pthread.h> -#include "pthread_private.h" - -int -sigsuspend(const sigset_t * set) -{ - int ret = -1; - sigset_t oset; - - /* Check if a new signal set was provided by the caller: */ - if (set != NULL) { - /* Save the current signal mask: */ - oset = _thread_run->sigmask; - - /* Change the caller's mask: */ - _thread_run->sigmask = *set; - - /* Wait for a signal: */ - _thread_kern_sched_state(PS_SIGSUSPEND, __FILE__, __LINE__); - - /* Always return an interrupted error: */ - errno = EINTR; - - /* Restore the signal mask: */ - _thread_run->sigmask = oset; - } else { - /* Return an invalid argument error: */ - errno = EINVAL; - } - - /* Return the completion status: */ - return (ret); -} -#endif diff --git a/lib/libpthread/thread/thr_sigwait.c b/lib/libpthread/thread/thr_sigwait.c deleted file mode 100644 index 590f9db463159..0000000000000 --- a/lib/libpthread/thread/thr_sigwait.c +++ /dev/null @@ -1,132 +0,0 @@ -/* - * Copyright (c) 1997 John Birrell <jb@cimlogic.com.au>. - * 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 John Birrell. - * 4. Neither the name of the author nor the names of any co-contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY JOHN BIRRELL 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 <signal.h> -#include <errno.h> -#ifdef _THREAD_SAFE -#include <pthread.h> -#include "pthread_private.h" - -int -sigwait(const sigset_t * set, int *sig) -{ - int ret = 0; - int i; - sigset_t tempset; - struct sigaction act; - - /* - * Specify the thread kernel signal handler. - */ - act.sa_handler = (void (*) ()) _thread_sig_handler; - act.sa_flags = SA_RESTART; - act.sa_mask = *set; - - /* - * These signals can't be waited on. - */ - sigdelset(&act.sa_mask, SIGKILL); - sigdelset(&act.sa_mask, SIGSTOP); - sigdelset(&act.sa_mask, SIGVTALRM); - sigdelset(&act.sa_mask, SIGCHLD); - sigdelset(&act.sa_mask, SIGINFO); - - /* Check to see if a pending signal is in the wait mask. */ - if (tempset = (_thread_run->sigpend & act.sa_mask)) { - /* Enter a loop to find a pending signal: */ - for (i = 1; i < NSIG; i++) { - if (sigismember (&tempset, i)) - break; - } - - /* Clear the pending signal: */ - sigdelset(&_thread_run->sigpend,i); - - /* Return the signal number to the caller: */ - *sig = i; - - return (0); - } - - /* - * Enter a loop to find the signals that are SIG_DFL. For - * these signals we must install a dummy signal handler in - * order for the kernel to pass them in to us. POSIX says - * that the application must explicitly install a dummy - * handler for signals that are SIG_IGN in order to sigwait - * on them. Note that SIG_IGN signals are left in the - * mask because a subsequent sigaction could enable an - * ignored signal. - */ - for (i = 1; i < NSIG; i++) { - if (sigismember(&act.sa_mask, i)) { - if (_thread_sigact[i - 1].sa_handler == SIG_DFL) - if (_thread_sys_sigaction(i,&act,NULL) != 0) - ret = -1; - } - } - if (ret == 0) { - - /* - * Save the wait signal mask. The wait signal - * mask is independent of the threads signal mask - * and requires separate storage. - */ - _thread_run->data.sigwait = &act.sa_mask; - - /* Wait for a signal: */ - _thread_kern_sched_state(PS_SIGWAIT, __FILE__, __LINE__); - - /* Return the signal number to the caller: */ - *sig = _thread_run->signo; - - /* - * Probably unnecessary, but since it's in a union struct - * we don't know how it could be used in the future. - */ - _thread_run->data.sigwait = NULL; - } - - /* Restore the sigactions: */ - act.sa_handler = SIG_DFL; - for (i = 1; i < NSIG; i++) { - if (sigismember(&act.sa_mask, i) && - (_thread_sigact[i - 1].sa_handler == SIG_DFL)) { - if (_thread_sys_sigaction(i,&act,NULL) != 0) - ret = -1; - } - } - - /* Return the completion status: */ - return (ret); -} -#endif diff --git a/lib/libpthread/thread/thr_single_np.c b/lib/libpthread/thread/thr_single_np.c deleted file mode 100644 index e36c856c63763..0000000000000 --- a/lib/libpthread/thread/thr_single_np.c +++ /dev/null @@ -1,44 +0,0 @@ -/* - * Copyright (c) 1996 John Birrell <jb@cimlogic.com.au>. - * 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 John Birrell. - * 4. Neither the name of the author nor the names of any co-contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY JOHN BIRRELL 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 <string.h> -#ifdef _THREAD_SAFE -#include <pthread.h> -#include "pthread_private.h" - -int pthread_single_np() -{ - /* Enter single-threaded (non-POSIX) scheduling mode: */ - _thread_single = _thread_run; - return(0); -} -#endif diff --git a/lib/libpthread/thread/thr_spec.c b/lib/libpthread/thread/thr_spec.c deleted file mode 100644 index 8558dff85980f..0000000000000 --- a/lib/libpthread/thread/thr_spec.c +++ /dev/null @@ -1,199 +0,0 @@ -/* - * Copyright (c) 1995 John Birrell <jb@cimlogic.com.au>. - * 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 John Birrell. - * 4. Neither the name of the author nor the names of any co-contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY JOHN BIRRELL 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 <signal.h> -#include <stdlib.h> -#include <string.h> -#include <errno.h> -#ifdef _THREAD_SAFE -#include <pthread.h> -#include "pthread_private.h" - -/* Static variables: */ -static struct pthread_key key_table[PTHREAD_KEYS_MAX]; - -int -pthread_key_create(pthread_key_t * key, void (*destructor) (void *)) -{ - for ((*key) = 0; (*key) < PTHREAD_KEYS_MAX; (*key)++) { - /* Lock the key table entry: */ - _SPINLOCK(&key_table[*key].lock); - - if (key_table[(*key)].allocated == 0) { - key_table[(*key)].allocated = 1; - key_table[(*key)].destructor = destructor; - - /* Unlock the key table entry: */ - _SPINUNLOCK(&key_table[*key].lock); - return (0); - } - - /* Unlock the key table entry: */ - _SPINUNLOCK(&key_table[*key].lock); - } - return (EAGAIN); -} - -int -pthread_key_delete(pthread_key_t key) -{ - int ret = 0; - - if (key < PTHREAD_KEYS_MAX) { - /* Lock the key table entry: */ - _SPINLOCK(&key_table[key].lock); - - if (key_table[key].allocated) - key_table[key].allocated = 0; - else - ret = EINVAL; - - /* Unlock the key table entry: */ - _SPINUNLOCK(&key_table[key].lock); - } else - ret = EINVAL; - return (ret); -} - -void -_thread_cleanupspecific(void) -{ - void *data; - int key; - int itr; - void (*destructor)( void *); - - for (itr = 0; itr < PTHREAD_DESTRUCTOR_ITERATIONS; itr++) { - for (key = 0; key < PTHREAD_KEYS_MAX; key++) { - if (_thread_run->specific_data_count) { - /* Lock the key table entry: */ - _SPINLOCK(&key_table[key].lock); - destructor = NULL; - - if (key_table[key].allocated) { - if (_thread_run->specific_data[key]) { - data = (void *) _thread_run->specific_data[key]; - _thread_run->specific_data[key] = NULL; - _thread_run->specific_data_count--; - destructor = key_table[key].destructor; - } - } - - /* Unlock the key table entry: */ - _SPINUNLOCK(&key_table[key].lock); - - /* - * If there is a destructore, call it - * with the key table entry unlocked: - */ - if (destructor) - destructor(data); - } else { - free(_thread_run->specific_data); - _thread_run->specific_data = NULL; - return; - } - } - } - _thread_run->specific_data = NULL; - free(_thread_run->specific_data); -} - -static inline const void ** -pthread_key_allocate_data(void) -{ - const void **new_data; - if ((new_data = (const void **) malloc(sizeof(void *) * PTHREAD_KEYS_MAX)) != NULL) { - memset((void *) new_data, 0, sizeof(void *) * PTHREAD_KEYS_MAX); - } - return (new_data); -} - -int -pthread_setspecific(pthread_key_t key, const void *value) -{ - pthread_t pthread; - int ret = 0; - - /* Point to the running thread: */ - pthread = _thread_run; - - if ((pthread->specific_data) || - (pthread->specific_data = pthread_key_allocate_data())) { - if (key < PTHREAD_KEYS_MAX) { - if (key_table[key].allocated) { - if (pthread->specific_data[key] == NULL) { - if (value != NULL) - pthread->specific_data_count++; - } else { - if (value == NULL) - pthread->specific_data_count--; - } - pthread->specific_data[key] = value; - ret = 0; - } else - ret = EINVAL; - } else - ret = EINVAL; - } else - ret = ENOMEM; - return (ret); -} - -void * -pthread_getspecific(pthread_key_t key) -{ - pthread_t pthread; - void *data; - - /* Point to the running thread: */ - pthread = _thread_run; - - /* Check if there is specific data: */ - if (pthread->specific_data != NULL && key < PTHREAD_KEYS_MAX) { - /* Check if this key has been used before: */ - if (key_table[key].allocated) { - /* Return the value: */ - data = (void *) pthread->specific_data[key]; - } else { - /* - * This key has not been used before, so return NULL - * instead: - */ - data = NULL; - } - } else - /* No specific data has been created, so just return NULL: */ - data = NULL; - return (data); -} -#endif diff --git a/lib/libpthread/thread/thr_spinlock.c b/lib/libpthread/thread/thr_spinlock.c deleted file mode 100644 index 9da115e5eedb7..0000000000000 --- a/lib/libpthread/thread/thr_spinlock.c +++ /dev/null @@ -1,108 +0,0 @@ -/* - * Copyright (c) 1997 John Birrell <jb@cimlogic.com.au>. - * 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 John Birrell. - * 4. Neither the name of the author nor the names of any co-contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY JOHN BIRRELL 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. - * - * $Id: uthread_spinlock.c,v 1.3 1998/06/06 07:27:06 jb Exp $ - * - */ - -#include <stdio.h> -#include <sched.h> -#include <unistd.h> -#include <pthread.h> -#include <string.h> -#include "pthread_private.h" - -extern char *__progname; - -/* - * Lock a location for the running thread. Yield to allow other - * threads to run if this thread is blocked because the lock is - * not available. Note that this function does not sleep. It - * assumes that the lock will be available very soon. - */ -void -_spinlock(spinlock_t *lck) -{ - /* - * Try to grab the lock and loop if another thread grabs - * it before we do. - */ - while(_atomic_lock(&lck->access_lock)) { - /* Give up the time slice: */ - sched_yield(); - - /* Check if already locked by the running thread: */ - if (lck->lock_owner == (long) _thread_run) - return; - } - - /* The running thread now owns the lock: */ - lck->lock_owner = (long) _thread_run; -} - -/* - * Lock a location for the running thread. Yield to allow other - * threads to run if this thread is blocked because the lock is - * not available. Note that this function does not sleep. It - * assumes that the lock will be available very soon. - * - * This function checks if the running thread has already locked the - * location, warns if this occurs and creates a thread dump before - * returning. - */ -void -_spinlock_debug(spinlock_t *lck, char *fname, int lineno) -{ - /* - * Try to grab the lock and loop if another thread grabs - * it before we do. - */ - while(_atomic_lock(&lck->access_lock)) { - /* Give up the time slice: */ - sched_yield(); - - /* Check if already locked by the running thread: */ - if (lck->lock_owner == (long) _thread_run) { - char str[256]; - snprintf(str, sizeof(str), "%s - Warning: Thread %p attempted to lock %p from %s (%d) which it had already locked in %s (%d)\n", __progname, _thread_run, lck, fname, lineno, lck->fname, lck->lineno); - _thread_sys_write(2,str,strlen(str)); - - /* Create a thread dump to help debug this problem: */ - _thread_dump_info(); - return; - } - } - - /* The running thread now owns the lock: */ - lck->lock_owner = (long) _thread_run; - lck->fname = fname; - lck->lineno = lineno; -} diff --git a/lib/libpthread/thread/thr_suspend_np.c b/lib/libpthread/thread/thr_suspend_np.c deleted file mode 100644 index 871683ad92aba..0000000000000 --- a/lib/libpthread/thread/thr_suspend_np.c +++ /dev/null @@ -1,59 +0,0 @@ -/* - * Copyright (c) 1995-1998 John Birrell <jb@cimlogic.com.au>. - * 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 John Birrell. - * 4. Neither the name of the author nor the names of any co-contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY JOHN BIRRELL 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 <errno.h> -#ifdef _THREAD_SAFE -#include <pthread.h> -#include "pthread_private.h" - -/* Suspend a thread: */ -int -pthread_suspend_np(pthread_t thread) -{ - int ret; - - /* Find the thread in the list of active threads: */ - if ((ret = _find_thread(thread)) == 0) { - /* The thread exists. Is it running? */ - if (thread->state != PS_RUNNING && - thread->state != PS_SUSPENDED) { - /* The thread operation has been interrupted */ - _thread_seterrno(thread,EINTR); - thread->interrupted = 1; - } - - /* Suspend the thread. */ - PTHREAD_NEW_STATE(thread,PS_SUSPENDED); - } - return(ret); -} -#endif diff --git a/lib/libpthread/thread/thr_vfork.c b/lib/libpthread/thread/thr_vfork.c deleted file mode 100644 index bbfcf002bc02c..0000000000000 --- a/lib/libpthread/thread/thr_vfork.c +++ /dev/null @@ -1,9 +0,0 @@ -#include <unistd.h> -#ifdef _THREAD_SAFE - -int -vfork(void) -{ - return (fork()); -} -#endif diff --git a/lib/libpthread/thread/thr_wait4.c b/lib/libpthread/thread/thr_wait4.c deleted file mode 100644 index dda8aeea61cb3..0000000000000 --- a/lib/libpthread/thread/thr_wait4.c +++ /dev/null @@ -1,61 +0,0 @@ -/* - * Copyright (c) 1995-1998 John Birrell <jb@cimlogic.com.au> - * 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 John Birrell. - * 4. Neither the name of the author nor the names of any co-contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY JOHN BIRRELL 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 <errno.h> -#include <sys/wait.h> -#ifdef _THREAD_SAFE -#include <pthread.h> -#include "pthread_private.h" - -pid_t -wait4(pid_t pid, int *istat, int options, struct rusage * rusage) -{ - pid_t ret; - - /* Perform a non-blocking wait4 syscall: */ - while ((ret = _thread_sys_wait4(pid, istat, options | WNOHANG, rusage)) == 0 && (options & WNOHANG) == 0) { - /* Reset the interrupted operation flag: */ - _thread_run->interrupted = 0; - - /* Schedule the next thread while this one waits: */ - _thread_kern_sched_state(PS_WAIT_WAIT, __FILE__, __LINE__); - - /* Check if this call was interrupted by a signal: */ - if (_thread_run->interrupted) { - errno = EINTR; - ret = -1; - break; - } - } - return (ret); -} -#endif diff --git a/lib/libpthread/thread/thr_write.c b/lib/libpthread/thread/thr_write.c deleted file mode 100644 index 23cef52b6f2da..0000000000000 --- a/lib/libpthread/thread/thr_write.c +++ /dev/null @@ -1,134 +0,0 @@ -/* - * Copyright (c) 1995-1998 John Birrell <jb@cimlogic.com.au> - * 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 John Birrell. - * 4. Neither the name of the author nor the names of any co-contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY JOHN BIRRELL 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. - * - * $Id: uthread_write.c,v 1.9 1998/06/14 09:36:11 jb Exp $ - * - */ -#include <sys/types.h> -#include <sys/fcntl.h> -#include <sys/uio.h> -#include <errno.h> -#include <unistd.h> -#ifdef _THREAD_SAFE -#include <pthread.h> -#include "pthread_private.h" - -ssize_t -write(int fd, const void *buf, size_t nbytes) -{ - int blocking; - int type; - ssize_t n; - ssize_t num = 0; - ssize_t ret; - - /* POSIX says to do just this: */ - if (nbytes == 0) - return (0); - - /* Lock the file descriptor for write: */ - if ((ret = _FD_LOCK(fd, FD_WRITE, NULL)) == 0) { - /* Get the read/write mode type: */ - type = _thread_fd_table[fd]->flags & O_ACCMODE; - - /* Check if the file is not open for write: */ - if (type != O_WRONLY && type != O_RDWR) { - /* File is not open for write: */ - errno = EBADF; - _FD_UNLOCK(fd, FD_WRITE); - return (-1); - } - - /* Check if file operations are to block */ - blocking = ((_thread_fd_table[fd]->flags & O_NONBLOCK) == 0); - - /* - * Loop while no error occurs and until the expected number - * of bytes are written if performing a blocking write: - */ - while (ret == 0) { - /* Perform a non-blocking write syscall: */ - n = _thread_sys_write(fd, buf + num, nbytes - num); - - /* Check if one or more bytes were written: */ - if (n > 0) - /* - * Keep a count of the number of bytes - * written: - */ - num += n; - - /* - * If performing a blocking write, check if the - * write would have blocked or if some bytes - * were written but there are still more to - * write: - */ - if (blocking && ((n < 0 && (errno == EWOULDBLOCK || - errno == EAGAIN)) || (n >= 0 && num < nbytes))) { - _thread_run->data.fd.fd = fd; - _thread_kern_set_timeout(NULL); - - /* Reset the interrupted operation flag: */ - _thread_run->interrupted = 0; - - _thread_kern_sched_state(PS_FDW_WAIT, - __FILE__, __LINE__); - - /* - * Check if the operation was - * interrupted by a signal - */ - if (_thread_run->interrupted) { - /* Return an error: */ - ret = -1; - } - - /* - * If performing a non-blocking write or if an - * error occurred, just return whatever the write - * syscall did: - */ - } else if (!blocking || n < 0) { - /* A non-blocking call might return zero: */ - ret = n; - break; - - /* Check if the write has completed: */ - } else if (num >= nbytes) - /* Return the number of bytes written: */ - ret = num; - } - _FD_UNLOCK(fd, FD_RDWR); - } - return (ret); -} -#endif diff --git a/lib/libpthread/thread/thr_writev.c b/lib/libpthread/thread/thr_writev.c deleted file mode 100644 index 81afcfd0e22c7..0000000000000 --- a/lib/libpthread/thread/thr_writev.c +++ /dev/null @@ -1,191 +0,0 @@ -/* - * Copyright (c) 1995-1998 John Birrell <jb@cimlogic.com.au> - * 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 John Birrell. - * 4. Neither the name of the author nor the names of any co-contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY JOHN BIRRELL 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. - * - * $Id: uthread_writev.c,v 1.9 1998/06/10 22:28:45 jb Exp $ - * - */ -#include <sys/types.h> -#include <sys/fcntl.h> -#include <sys/uio.h> -#include <errno.h> -#include <stdlib.h> -#include <string.h> -#include <unistd.h> -#ifdef _THREAD_SAFE -#include <pthread.h> -#include "pthread_private.h" - -ssize_t -writev(int fd, const struct iovec * iov, int iovcnt) -{ - int blocking; - int idx = 0; - int type; - ssize_t cnt; - ssize_t n; - ssize_t num = 0; - ssize_t ret; - struct iovec liov[20]; - struct iovec *p_iov = liov; - - /* Check if the array size exceeds to compiled in size: */ - if (iovcnt > (sizeof(liov) / sizeof(struct iovec))) { - /* Allocate memory for the local array: */ - if ((p_iov = (struct iovec *) - malloc(iovcnt * sizeof(struct iovec))) == NULL) { - /* Insufficient memory: */ - errno = ENOMEM; - return (-1); - } - } - - /* Copy the caller's array so that it can be modified locally: */ - memcpy(p_iov,iov,iovcnt * sizeof(struct iovec)); - - /* Lock the file descriptor for write: */ - if ((ret = _FD_LOCK(fd, FD_WRITE, NULL)) == 0) { - /* Get the read/write mode type: */ - type = _thread_fd_table[fd]->flags & O_ACCMODE; - - /* Check if the file is not open for write: */ - if (type != O_WRONLY && type != O_RDWR) { - /* File is not open for write: */ - errno = EBADF; - _FD_UNLOCK(fd, FD_WRITE); - return (-1); - } - - /* Check if file operations are to block */ - blocking = ((_thread_fd_table[fd]->flags & O_NONBLOCK) == 0); - - /* - * Loop while no error occurs and until the expected number - * of bytes are written if performing a blocking write: - */ - while (ret == 0) { - /* Perform a non-blocking write syscall: */ - n = _thread_sys_writev(fd, &p_iov[idx], iovcnt - idx); - - /* Check if one or more bytes were written: */ - if (n > 0) { - /* - * Keep a count of the number of bytes - * written: - */ - num += n; - - /* - * Enter a loop to check if a short write - * occurred and move the index to the - * array entry where the short write - * ended: - */ - cnt = n; - while (cnt > 0 && idx < iovcnt) { - /* - * If the residual count exceeds - * the size of this vector, then - * it was completely written: - */ - if (cnt >= p_iov[idx].iov_len) - /* - * Decrement the residual - * count and increment the - * index to the next array - * entry: - */ - cnt -= p_iov[idx++].iov_len; - else { - /* - * This entry was only - * partially written, so - * adjust it's length - * and base pointer ready - * for the next write: - */ - p_iov[idx].iov_len -= cnt; - p_iov[idx].iov_base += cnt; - cnt = 0; - } - } - } - - /* - * If performing a blocking write, check if the - * write would have blocked or if some bytes - * were written but there are still more to - * write: - */ - if (blocking && ((n < 0 && (errno == EWOULDBLOCK || - errno == EAGAIN)) || (n >= 0 && idx < iovcnt))) { - _thread_run->data.fd.fd = fd; - _thread_kern_set_timeout(NULL); - - /* Reset the interrupted operation flag: */ - _thread_run->interrupted = 0; - - _thread_kern_sched_state(PS_FDW_WAIT, - __FILE__, __LINE__); - - /* - * Check if the operation was - * interrupted by a signal - */ - if (_thread_run->interrupted) { - /* Return an error: */ - ret = -1; - } - - /* - * If performing a non-blocking write or if an - * error occurred, just return whatever the write - * syscall did: - */ - } else if (!blocking || n < 0) { - /* A non-blocking call might return zero: */ - ret = n; - break; - - /* Check if the write has completed: */ - } else if (idx == iovcnt) - /* Return the number of bytes written: */ - ret = num; - } - _FD_UNLOCK(fd, FD_RDWR); - } - - /* If memory was allocated for the array, free it: */ - if (p_iov != liov) - free(p_iov); - - return (ret); -} -#endif diff --git a/lib/libpthread/thread/thr_yield.c b/lib/libpthread/thread/thr_yield.c deleted file mode 100644 index 877f5e6b0e856..0000000000000 --- a/lib/libpthread/thread/thr_yield.c +++ /dev/null @@ -1,63 +0,0 @@ -/* - * Copyright (c) 1995 John Birrell <jb@cimlogic.com.au>. - * 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 John Birrell. - * 4. Neither the name of the author nor the names of any co-contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY JOHN BIRRELL 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. - * - */ -#ifdef _THREAD_SAFE -#include <pthread.h> -#include "pthread_private.h" - -int -sched_yield(void) -{ - /* Reset the accumulated time slice value for the current thread: */ - _thread_run->slice_usec = -1; - - /* Schedule the next thread: */ - _thread_kern_sched(NULL); - - /* Always return no error. */ - return(0); -} - -/* Draft 4 yield */ -void -pthread_yield(void) -{ - /* Reset the accumulated time slice value for the current thread: */ - _thread_run->slice_usec = -1; - - /* Schedule the next thread: */ - _thread_kern_sched(NULL); - - /* Nothing to return. */ - return; -} -#endif diff --git a/lib/libstand/gzipfs.c b/lib/libstand/gzipfs.c deleted file mode 100644 index fb64665cc3a22..0000000000000 --- a/lib/libstand/gzipfs.c +++ /dev/null @@ -1,318 +0,0 @@ -/* - * Copyright (c) 1998 Michael Smith. - * 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. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR 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 AUTHOR 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. - * - * $Id: zipfs.c,v 1.2 1998/09/18 22:58:01 msmith Exp $ - * - */ - -#include "stand.h" - -#include <sys/stat.h> -#include <string.h> -#include <zlib.h> - -#define Z_BUFSIZE 2048 /* XXX larger? */ - -struct z_file -{ - int zf_rawfd; - z_stream zf_zstream; - char zf_buf[Z_BUFSIZE]; -}; - -static int zf_fill(struct z_file *z); -static int zf_open(const char *path, struct open_file *f); -static int zf_close(struct open_file *f); -static int zf_read(struct open_file *f, void *buf, size_t size, size_t *resid); -static off_t zf_seek(struct open_file *f, off_t offset, int where); -static int zf_stat(struct open_file *f, struct stat *sb); - -struct fs_ops zipfs_fsops = { - "zip", - zf_open, - zf_close, - zf_read, - null_write, - zf_seek, - zf_stat -}; - -#if 0 -void * -calloc(int items, size_t size) -{ - return(malloc(items * size)); -} -#endif - -static int -zf_fill(struct z_file *zf) -{ - int result; - int req; - - req = Z_BUFSIZE - zf->zf_zstream.avail_in; - result = 0; - - /* If we need more */ - if (req > 0) { - /* move old data to bottom of buffer */ - if (req < Z_BUFSIZE) - bcopy(zf->zf_buf + req, zf->zf_buf, Z_BUFSIZE - req); - - /* read to fill buffer and update availibility data */ - result = read(zf->zf_rawfd, zf->zf_buf + zf->zf_zstream.avail_in, req); - zf->zf_zstream.next_in = zf->zf_buf; - if (result >= 0) - zf->zf_zstream.avail_in += result; - } - return(result); -} - -/* - * Adapted from get_byte/check_header in libz - * - * Returns 0 if the header is OK, nonzero if not. - */ -static int -get_byte(struct z_file *zf) -{ - if ((zf->zf_zstream.avail_in == 0) && (zf_fill(zf) == -1)) - return(-1); - zf->zf_zstream.avail_in--; - return(*(zf->zf_zstream.next_in)++); -} - -static int gz_magic[2] = {0x1f, 0x8b}; /* gzip magic header */ - -/* gzip flag byte */ -#define ASCII_FLAG 0x01 /* bit 0 set: file probably ascii text */ -#define HEAD_CRC 0x02 /* bit 1 set: header CRC present */ -#define EXTRA_FIELD 0x04 /* bit 2 set: extra field present */ -#define ORIG_NAME 0x08 /* bit 3 set: original file name present */ -#define COMMENT 0x10 /* bit 4 set: file comment present */ -#define RESERVED 0xE0 /* bits 5..7: reserved */ - -static int -check_header(struct z_file *zf) -{ - int method; /* method byte */ - int flags; /* flags byte */ - uInt len; - int c; - - /* Check the gzip magic header */ - for (len = 0; len < 2; len++) { - c = get_byte(zf); - if (c != gz_magic[len]) { - return(1); - } - } - method = get_byte(zf); - flags = get_byte(zf); - if (method != Z_DEFLATED || (flags & RESERVED) != 0) { - return(1); - } - - /* Discard time, xflags and OS code: */ - for (len = 0; len < 6; len++) (void)get_byte(zf); - - if ((flags & EXTRA_FIELD) != 0) { /* skip the extra field */ - len = (uInt)get_byte(zf); - len += ((uInt)get_byte(zf))<<8; - /* len is garbage if EOF but the loop below will quit anyway */ - while (len-- != 0 && get_byte(zf) != -1) ; - } - if ((flags & ORIG_NAME) != 0) { /* skip the original file name */ - while ((c = get_byte(zf)) != 0 && c != -1) ; - } - if ((flags & COMMENT) != 0) { /* skip the .gz file comment */ - while ((c = get_byte(zf)) != 0 && c != -1) ; - } - if ((flags & HEAD_CRC) != 0) { /* skip the header crc */ - for (len = 0; len < 2; len++) c = get_byte(zf); - } - /* if there's data left, we're in business */ - return((c == -1) ? 1 : 0); -} - -static int -zf_open(const char *fname, struct open_file *f) -{ - static char *zfname; - int rawfd; - struct z_file *zf; - char *cp; - int error; - struct stat sb; - - /* Have to be in "just read it" mode */ - if (f->f_flags != F_READ) - return(EPERM); - - /* If the name already ends in .gz, ignore it */ - if ((cp = strrchr(fname, '.')) && !strcmp(cp, ".gz")) - return(ENOENT); - - /* Construct new name */ - zfname = malloc(strlen(fname) + 4); - sprintf(zfname, "%s.gz", fname); - - /* Try to open the compressed datafile */ - rawfd = open(zfname, O_RDONLY); - free(zfname); - if (rawfd == -1) - return(ENOENT); - - if (fstat(rawfd, &sb) < 0) { - printf("zf_open: stat failed\n"); - close(rawfd); - return(ENOENT); - } - if (!S_ISREG(sb.st_mode)) { - printf("zf_open: not a file\n"); - close(rawfd); - return(EISDIR); /* best guess */ - } - - /* Allocate a z_file structure, populate it */ - zf = malloc(sizeof(struct z_file)); - bzero(zf, sizeof(struct z_file)); - zf->zf_rawfd = rawfd; - - /* Verify that the file is gzipped (XXX why do this afterwards?) */ - if (check_header(zf)) { - close(zf->zf_rawfd); - inflateEnd(&(zf->zf_zstream)); - free(zf); - return(EFTYPE); - } - - /* Initialise the inflation engine */ - if ((error = inflateInit2(&(zf->zf_zstream), -15)) != Z_OK) { - printf("zf_open: inflateInit returned %d : %s\n", error, zf->zf_zstream.msg); - close(zf->zf_rawfd); - free(zf); - return(EIO); - } - - /* Looks OK, we'll take it */ - f->f_fsdata = zf; - return(0); -} - -static int -zf_close(struct open_file *f) -{ - struct z_file *zf = (struct z_file *)f->f_fsdata; - - inflateEnd(&(zf->zf_zstream)); - close(zf->zf_rawfd); - free(zf); - return(0); -} - -static int -zf_read(struct open_file *f, void *buf, size_t size, size_t *resid) -{ - struct z_file *zf = (struct z_file *)f->f_fsdata; - int error; - - zf->zf_zstream.next_out = buf; /* where and how much */ - zf->zf_zstream.avail_out = size; - - while (zf->zf_zstream.avail_out) { - if ((zf->zf_zstream.avail_in == 0) && (zf_fill(zf) == -1)) { - printf("zf_read: fill error\n"); - return(-1); - } - if (zf->zf_zstream.avail_in == 0) { /* oops, unexpected EOF */ - printf("zf_read: unexpected EOF\n"); - break; - } - - error = inflate(&zf->zf_zstream, Z_SYNC_FLUSH); /* decompression pass */ - if (error == Z_STREAM_END) { /* EOF, all done */ - break; - } - if (error != Z_OK) { /* argh, decompression error */ - printf("inflate: %s\n", zf->zf_zstream.msg); - errno = EIO; - return(-1); - } - } - if (resid != NULL) - *resid = zf->zf_zstream.avail_out; - return(0); -} - -static off_t -zf_seek(struct open_file *f, off_t offset, int where) -{ - struct z_file *zf = (struct z_file *)f->f_fsdata; - off_t target; - char discard[16]; - - switch (where) { - case SEEK_SET: - target = offset; - break; - case SEEK_CUR: - target = offset + zf->zf_zstream.total_out; - break; - default: - target = -1; - } - - /* Can we get there from here? */ - if (target < zf->zf_zstream.total_out) { - errno = EOFFSET; - return -1; - } - - /* skip forwards if required */ - while (target > zf->zf_zstream.total_out) { - if (zf_read(f, discard, min(sizeof(discard), target - zf->zf_zstream.total_out), NULL) == -1) - return(-1); - } - /* This is where we are (be honest if we overshot) */ - return (zf->zf_zstream.total_out); -} - - -static int -zf_stat(struct open_file *f, struct stat *sb) -{ - struct z_file *zf = (struct z_file *)f->f_fsdata; - int result; - - /* stat as normal, but indicate that size is unknown */ - if ((result = fstat(zf->zf_rawfd, sb)) == 0) - sb->st_size = -1; - return(result); -} - - - diff --git a/lib/libutil/pw_util.c b/lib/libutil/pw_util.c deleted file mode 100644 index 2003cd6ed1ff1..0000000000000 --- a/lib/libutil/pw_util.c +++ /dev/null @@ -1,256 +0,0 @@ -/*- - * Copyright (c) 1990, 1993, 1994 - * 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. - */ - -#ifndef lint -#if 0 -static const char sccsid[] = "@(#)pw_util.c 8.3 (Berkeley) 4/2/94"; -#endif -static const char rcsid[] = - "$Id: pw_util.c,v 1.12 1998/12/13 01:36:45 dillon Exp $"; -#endif /* not lint */ - -/* - * This file is used by all the "password" programs; vipw(8), chpass(1), - * and passwd(1). - */ - -#include <sys/param.h> -#include <sys/errno.h> -#include <sys/time.h> -#include <sys/resource.h> -#include <sys/stat.h> -#include <sys/wait.h> - -#include <err.h> -#include <fcntl.h> -#include <paths.h> -#include <pwd.h> -#include <signal.h> -#include <stdio.h> -#include <stdlib.h> -#include <string.h> -#include <unistd.h> - -#include "pw_util.h" - -extern char *tempname; -static pid_t editpid = -1; -static int lockfd; - -void -pw_cont(sig) - int sig; -{ - - if (editpid != -1) - kill(editpid, sig); -} - -void -pw_init() -{ - struct rlimit rlim; - - /* Unlimited resource limits. */ - rlim.rlim_cur = rlim.rlim_max = RLIM_INFINITY; - (void)setrlimit(RLIMIT_CPU, &rlim); - (void)setrlimit(RLIMIT_FSIZE, &rlim); - (void)setrlimit(RLIMIT_STACK, &rlim); - (void)setrlimit(RLIMIT_DATA, &rlim); - (void)setrlimit(RLIMIT_RSS, &rlim); - - /* Don't drop core (not really necessary, but GP's). */ - rlim.rlim_cur = rlim.rlim_max = 0; - (void)setrlimit(RLIMIT_CORE, &rlim); - - /* Turn off signals. */ - (void)signal(SIGALRM, SIG_IGN); - (void)signal(SIGHUP, SIG_IGN); - (void)signal(SIGINT, SIG_IGN); - (void)signal(SIGPIPE, SIG_IGN); - (void)signal(SIGQUIT, SIG_IGN); - (void)signal(SIGTERM, SIG_IGN); - (void)signal(SIGCONT, pw_cont); - - /* Create with exact permissions. */ - (void)umask(0); -} - -int -pw_lock() -{ - /* - * If the master password file doesn't exist, the system is hosed. - * Might as well try to build one. Set the close-on-exec bit so - * that users can't get at the encrypted passwords while editing. - * Open should allow flock'ing the file; see 4.4BSD. XXX - */ - for (;;) { - struct stat st; - - lockfd = open(_PATH_MASTERPASSWD, O_RDONLY, 0); - if (lockfd < 0 || fcntl(lockfd, F_SETFD, 1) == -1) - err(1, "%s", _PATH_MASTERPASSWD); - if (flock(lockfd, LOCK_EX|LOCK_NB)) - errx(1, "the password db file is busy"); - - /* - * If the password file was replaced while we were trying to - * get the lock, our hardlink count will be 0 and we have to - * close and retry. - */ - if (fstat(lockfd, &st) < 0) - errx(1, "fstat() failed"); - if (st.st_nlink != 0) - break; - close(lockfd); - lockfd = -1; - } - return (lockfd); -} - -int -pw_tmp() -{ - static char path[MAXPATHLEN] = _PATH_MASTERPASSWD; - int fd; - char *p; - - if ((p = strrchr(path, '/'))) - ++p; - else - p = path; - strcpy(p, "pw.XXXXXX"); - if ((fd = mkstemp(path)) == -1) - err(1, "%s", path); - tempname = path; - return (fd); -} - -int -pw_mkdb(username) -char *username; -{ - int pstat; - pid_t pid; - - (void)fflush(stderr); - if (!(pid = fork())) { - if(!username) { - warnx("rebuilding the database..."); - execl(_PATH_PWD_MKDB, "pwd_mkdb", "-p", tempname, NULL); - } else { - warnx("updating the database..."); - execl(_PATH_PWD_MKDB, "pwd_mkdb", "-p", "-u", - username, tempname, NULL); - } - pw_error(_PATH_PWD_MKDB, 1, 1); - } - pid = waitpid(pid, &pstat, 0); - if (pid == -1 || !WIFEXITED(pstat) || WEXITSTATUS(pstat) != 0) - return (0); - warnx("done"); - return (1); -} - -void -pw_edit(notsetuid) - int notsetuid; -{ - int pstat; - char *p, *editor; - - if (!(editor = getenv("EDITOR"))) - editor = _PATH_VI; - if ((p = strrchr(editor, '/'))) - ++p; - else - p = editor; - - if (!(editpid = fork())) { - if (notsetuid) { - (void)setgid(getgid()); - (void)setuid(getuid()); - } - errno = 0; - execlp(editor, p, tempname, NULL); - _exit(errno); - } - for (;;) { - editpid = waitpid(editpid, (int *)&pstat, WUNTRACED); - errno = WEXITSTATUS(pstat); - if (editpid == -1) - pw_error(editor, 1, 1); - else if (WIFSTOPPED(pstat)) - raise(WSTOPSIG(pstat)); - else if (WIFEXITED(pstat) && errno == 0) - break; - else - pw_error(editor, 1, 1); - } - editpid = -1; -} - -void -pw_prompt() -{ - int c, first; - - (void)printf("re-edit the password file? [y]: "); - (void)fflush(stdout); - first = c = getchar(); - while (c != '\n' && c != EOF) - c = getchar(); - if (first == 'n') - pw_error(NULL, 0, 0); -} - -void -pw_error(name, err, eval) - char *name; - int err, eval; -{ -#ifdef YP - extern int _use_yp; -#endif /* YP */ - if (err) - warn(name); -#ifdef YP - if (_use_yp) - warnx("NIS information unchanged"); - else -#endif /* YP */ - warnx("%s: unchanged", _PATH_MASTERPASSWD); - (void)unlink(tempname); - exit(eval); -} diff --git a/lib/libutil/stat_flags.c b/lib/libutil/stat_flags.c deleted file mode 100644 index 1f22f5a8ad963..0000000000000 --- a/lib/libutil/stat_flags.c +++ /dev/null @@ -1,174 +0,0 @@ -/*- - * Copyright (c) 1993 - * 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. - */ - -#ifndef lint -#if 0 -static char sccsid[] = "@(#)stat_flags.c 8.1 (Berkeley) 5/31/93"; -#else -static const char rcsid[] = - "$Id: stat_flags.c,v 1.8 1997/08/07 22:28:25 steve Exp $"; -#endif -#endif /* not lint */ - -#include <sys/types.h> -#include <sys/stat.h> - -#include <stddef.h> -#include <string.h> - -#define SAPPEND(s) { \ - if (prefix != NULL) \ - (void)strcat(string, prefix); \ - (void)strcat(string, s); \ - prefix = ","; \ -} - -/* - * flags_to_string -- - * Convert stat flags to a comma-separated string. If no flags - * are set, return the default string. - */ -char * -flags_to_string(flags, def) - u_long flags; - char *def; -{ - static char string[128]; - char *prefix; - - string[0] = '\0'; - prefix = NULL; - if (flags & UF_APPEND) - SAPPEND("uappnd"); - if (flags & UF_IMMUTABLE) - SAPPEND("uchg"); -#ifdef UF_NOUNLINK - if (flags & UF_NOUNLINK) - SAPPEND("uunlnk"); -#endif - if (flags & UF_NODUMP) - SAPPEND("nodump"); - if (flags & UF_OPAQUE) - SAPPEND("opaque"); - if (flags & SF_APPEND) - SAPPEND("sappnd"); - if (flags & SF_ARCHIVED) - SAPPEND("arch"); - if (flags & SF_IMMUTABLE) - SAPPEND("schg"); -#ifdef SF_NOUNLINK - if (flags & SF_NOUNLINK) - SAPPEND("sunlnk"); -#endif - return (prefix == NULL && def != NULL ? def : string); -} - -#define TEST(a, b, f) { \ - if (!memcmp(a, b, sizeof(b))) { \ - if (clear) { \ - if (clrp) \ - *clrp |= (f); \ - } else if (setp) \ - *setp |= (f); \ - break; \ - } \ -} - -/* - * string_to_flags -- - * Take string of arguments and return stat flags. Return 0 on - * success, 1 on failure. On failure, stringp is set to point - * to the offending token. - */ -int -string_to_flags(stringp, setp, clrp) - char **stringp; - u_long *setp, *clrp; -{ - int clear; - char *string, *p; - - clear = 0; - if (setp) - *setp = 0; - if (clrp) - *clrp = 0; - string = *stringp; - while ((p = strsep(&string, "\t ,")) != NULL) { - *stringp = p; - if (*p == '\0') - continue; - if (p[0] == 'n' && p[1] == 'o') { - clear = 1; - p += 2; - } - switch (p[0]) { - case 'a': - TEST(p, "arch", SF_ARCHIVED); - TEST(p, "archived", SF_ARCHIVED); - return (1); - case 'd': - clear = !clear; - TEST(p, "dump", UF_NODUMP); - return (1); - case 'o': - TEST(p, "opaque", UF_OPAQUE); - return (1); - case 's': - TEST(p, "sappnd", SF_APPEND); - TEST(p, "sappend", SF_APPEND); - TEST(p, "schg", SF_IMMUTABLE); - TEST(p, "schange", SF_IMMUTABLE); - TEST(p, "simmutable", SF_IMMUTABLE); -#ifdef SF_NOUNLINK - TEST(p, "sunlnk", SF_NOUNLINK); - TEST(p, "sunlink", SF_NOUNLINK); -#endif - return (1); - case 'u': - TEST(p, "uappnd", UF_APPEND); - TEST(p, "uappend", UF_APPEND); - TEST(p, "uchg", UF_IMMUTABLE); - TEST(p, "uchange", UF_IMMUTABLE); - TEST(p, "uimmutable", UF_IMMUTABLE); -#ifdef UF_NOUNLINK - TEST(p, "uunlnk", UF_NOUNLINK); - TEST(p, "uunlink", UF_NOUNLINK); -#endif - /* FALLTHROUGH */ - default: - return (1); - } - } - return (0); -} diff --git a/lib/msun/bsdsrc/b_exp.c b/lib/msun/bsdsrc/b_exp.c deleted file mode 100644 index fa6ea75735c5d..0000000000000 --- a/lib/msun/bsdsrc/b_exp.c +++ /dev/null @@ -1,203 +0,0 @@ -/* - * Copyright (c) 1985, 1993 - * 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. - */ - -#ifndef lint -static char sccsid[] = "@(#)exp.c 8.1 (Berkeley) 6/4/93"; -#endif /* not lint */ - -/* EXP(X) - * RETURN THE EXPONENTIAL OF X - * DOUBLE PRECISION (IEEE 53 bits, VAX D FORMAT 56 BITS) - * CODED IN C BY K.C. NG, 1/19/85; - * REVISED BY K.C. NG on 2/6/85, 2/15/85, 3/7/85, 3/24/85, 4/16/85, 6/14/86. - * - * Required system supported functions: - * scalb(x,n) - * copysign(x,y) - * finite(x) - * - * Method: - * 1. Argument Reduction: given the input x, find r and integer k such - * that - * x = k*ln2 + r, |r| <= 0.5*ln2 . - * r will be represented as r := z+c for better accuracy. - * - * 2. Compute exp(r) by - * - * exp(r) = 1 + r + r*R1/(2-R1), - * where - * R1 = x - x^2*(p1+x^2*(p2+x^2*(p3+x^2*(p4+p5*x^2)))). - * - * 3. exp(x) = 2^k * exp(r) . - * - * Special cases: - * exp(INF) is INF, exp(NaN) is NaN; - * exp(-INF)= 0; - * for finite argument, only exp(0)=1 is exact. - * - * Accuracy: - * exp(x) returns the exponential of x nearly rounded. In a test run - * with 1,156,000 random arguments on a VAX, the maximum observed - * error was 0.869 ulps (units in the last place). - * - * Constants: - * The hexadecimal values are the intended ones for the following constants. - * The decimal values may be used, provided that the compiler will convert - * from decimal to binary accurately enough to produce the hexadecimal values - * shown. - */ - -#include "mathimpl.h" - -vc(ln2hi, 6.9314718055829871446E-1 ,7217,4031,0000,f7d0, 0, .B17217F7D00000) -vc(ln2lo, 1.6465949582897081279E-12 ,bcd5,2ce7,d9cc,e4f1, -39, .E7BCD5E4F1D9CC) -vc(lnhuge, 9.4961163736712506989E1 ,ec1d,43bd,9010,a73e, 7, .BDEC1DA73E9010) -vc(lntiny,-9.5654310917272452386E1 ,4f01,c3bf,33af,d72e, 7,-.BF4F01D72E33AF) -vc(invln2, 1.4426950408889634148E0 ,aa3b,40b8,17f1,295c, 1, .B8AA3B295C17F1) -vc(p1, 1.6666666666666602251E-1 ,aaaa,3f2a,a9f1,aaaa, -2, .AAAAAAAAAAA9F1) -vc(p2, -2.7777777777015591216E-3 ,0b60,bc36,ec94,b5f5, -8,-.B60B60B5F5EC94) -vc(p3, 6.6137563214379341918E-5 ,b355,398a,f15f,792e, -13, .8AB355792EF15F) -vc(p4, -1.6533902205465250480E-6 ,ea0e,b6dd,5f84,2e93, -19,-.DDEA0E2E935F84) -vc(p5, 4.1381367970572387085E-8 ,bb4b,3431,2683,95f5, -24, .B1BB4B95F52683) - -#ifdef vccast -#define ln2hi vccast(ln2hi) -#define ln2lo vccast(ln2lo) -#define lnhuge vccast(lnhuge) -#define lntiny vccast(lntiny) -#define invln2 vccast(invln2) -#define p1 vccast(p1) -#define p2 vccast(p2) -#define p3 vccast(p3) -#define p4 vccast(p4) -#define p5 vccast(p5) -#endif - -ic(p1, 1.6666666666666601904E-1, -3, 1.555555555553E) -ic(p2, -2.7777777777015593384E-3, -9, -1.6C16C16BEBD93) -ic(p3, 6.6137563214379343612E-5, -14, 1.1566AAF25DE2C) -ic(p4, -1.6533902205465251539E-6, -20, -1.BBD41C5D26BF1) -ic(p5, 4.1381367970572384604E-8, -25, 1.6376972BEA4D0) -ic(ln2hi, 6.9314718036912381649E-1, -1, 1.62E42FEE00000) -ic(ln2lo, 1.9082149292705877000E-10,-33, 1.A39EF35793C76) -ic(lnhuge, 7.1602103751842355450E2, 9, 1.6602B15B7ECF2) -ic(lntiny,-7.5137154372698068983E2, 9, -1.77AF8EBEAE354) -ic(invln2, 1.4426950408889633870E0, 0, 1.71547652B82FE) - -double exp(x) -double x; -{ - double z,hi,lo,c; - int k; - -#if !defined(vax)&&!defined(tahoe) - if(x!=x) return(x); /* x is NaN */ -#endif /* !defined(vax)&&!defined(tahoe) */ - if( x <= lnhuge ) { - if( x >= lntiny ) { - - /* argument reduction : x --> x - k*ln2 */ - - k=invln2*x+copysign(0.5,x); /* k=NINT(x/ln2) */ - - /* express x-k*ln2 as hi-lo and let x=hi-lo rounded */ - - hi=x-k*ln2hi; - x=hi-(lo=k*ln2lo); - - /* return 2^k*[1+x+x*c/(2+c)] */ - z=x*x; - c= x - z*(p1+z*(p2+z*(p3+z*(p4+z*p5)))); - return scalb(1.0+(hi-(lo-(x*c)/(2.0-c))),k); - - } - /* end of x > lntiny */ - - else - /* exp(-big#) underflows to zero */ - if(finite(x)) return(scalb(1.0,-5000)); - - /* exp(-INF) is zero */ - else return(0.0); - } - /* end of x < lnhuge */ - - else - /* exp(INF) is INF, exp(+big#) overflows to INF */ - return( finite(x) ? scalb(1.0,5000) : x); -} - -/* returns exp(r = x + c) for |c| < |x| with no overlap. */ - -double __exp__D(x, c) -double x, c; -{ - double z,hi,lo, t; - int k; - -#if !defined(vax)&&!defined(tahoe) - if (x!=x) return(x); /* x is NaN */ -#endif /* !defined(vax)&&!defined(tahoe) */ - if ( x <= lnhuge ) { - if ( x >= lntiny ) { - - /* argument reduction : x --> x - k*ln2 */ - z = invln2*x; - k = z + copysign(.5, x); - - /* express (x+c)-k*ln2 as hi-lo and let x=hi-lo rounded */ - - hi=(x-k*ln2hi); /* Exact. */ - x= hi - (lo = k*ln2lo-c); - /* return 2^k*[1+x+x*c/(2+c)] */ - z=x*x; - c= x - z*(p1+z*(p2+z*(p3+z*(p4+z*p5)))); - c = (x*c)/(2.0-c); - - return scalb(1.+(hi-(lo - c)), k); - } - /* end of x > lntiny */ - - else - /* exp(-big#) underflows to zero */ - if(finite(x)) return(scalb(1.0,-5000)); - - /* exp(-INF) is zero */ - else return(0.0); - } - /* end of x < lnhuge */ - - else - /* exp(INF) is INF, exp(+big#) overflows to INF */ - return( finite(x) ? scalb(1.0,5000) : x); -} diff --git a/lib/msun/bsdsrc/b_log.c b/lib/msun/bsdsrc/b_log.c deleted file mode 100644 index 908b8544f93ce..0000000000000 --- a/lib/msun/bsdsrc/b_log.c +++ /dev/null @@ -1,486 +0,0 @@ -/* - * Copyright (c) 1992, 1993 - * 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. - */ - -#ifndef lint -static char sccsid[] = "@(#)log.c 8.2 (Berkeley) 11/30/93"; -#endif /* not lint */ - -#include <math.h> -#include <errno.h> - -#include "mathimpl.h" - -/* Table-driven natural logarithm. - * - * This code was derived, with minor modifications, from: - * Peter Tang, "Table-Driven Implementation of the - * Logarithm in IEEE Floating-Point arithmetic." ACM Trans. - * Math Software, vol 16. no 4, pp 378-400, Dec 1990). - * - * Calculates log(2^m*F*(1+f/F)), |f/j| <= 1/256, - * where F = j/128 for j an integer in [0, 128]. - * - * log(2^m) = log2_hi*m + log2_tail*m - * since m is an integer, the dominant term is exact. - * m has at most 10 digits (for subnormal numbers), - * and log2_hi has 11 trailing zero bits. - * - * log(F) = logF_hi[j] + logF_lo[j] is in tabular form in log_table.h - * logF_hi[] + 512 is exact. - * - * log(1+f/F) = 2*f/(2*F + f) + 1/12 * (2*f/(2*F + f))**3 + ... - * the leading term is calculated to extra precision in two - * parts, the larger of which adds exactly to the dominant - * m and F terms. - * There are two cases: - * 1. when m, j are non-zero (m | j), use absolute - * precision for the leading term. - * 2. when m = j = 0, |1-x| < 1/256, and log(x) ~= (x-1). - * In this case, use a relative precision of 24 bits. - * (This is done differently in the original paper) - * - * Special cases: - * 0 return signalling -Inf - * neg return signalling NaN - * +Inf return +Inf -*/ - -#if defined(vax) || defined(tahoe) -#define _IEEE 0 -#define TRUNC(x) x = (double) (float) (x) -#else -#define _IEEE 1 -#define endian (((*(int *) &one)) ? 1 : 0) -#define TRUNC(x) *(((int *) &x) + endian) &= 0xf8000000 -#define infnan(x) 0.0 -#endif - -#define N 128 - -/* Table of log(Fj) = logF_head[j] + logF_tail[j], for Fj = 1+j/128. - * Used for generation of extend precision logarithms. - * The constant 35184372088832 is 2^45, so the divide is exact. - * It ensures correct reading of logF_head, even for inaccurate - * decimal-to-binary conversion routines. (Everybody gets the - * right answer for integers less than 2^53.) - * Values for log(F) were generated using error < 10^-57 absolute - * with the bc -l package. -*/ -static double A1 = .08333333333333178827; -static double A2 = .01250000000377174923; -static double A3 = .002232139987919447809; -static double A4 = .0004348877777076145742; - -static double logF_head[N+1] = { - 0., - .007782140442060381246, - .015504186535963526694, - .023167059281547608406, - .030771658666765233647, - .038318864302141264488, - .045809536031242714670, - .053244514518837604555, - .060624621816486978786, - .067950661908525944454, - .075223421237524235039, - .082443669210988446138, - .089612158689760690322, - .096729626458454731618, - .103796793681567578460, - .110814366340264314203, - .117783035656430001836, - .124703478501032805070, - .131576357788617315236, - .138402322859292326029, - .145182009844575077295, - .151916042025732167530, - .158605030176659056451, - .165249572895390883786, - .171850256926518341060, - .178407657472689606947, - .184922338493834104156, - .191394852999565046047, - .197825743329758552135, - .204215541428766300668, - .210564769107350002741, - .216873938300523150246, - .223143551314024080056, - .229374101064877322642, - .235566071312860003672, - .241719936886966024758, - .247836163904594286577, - .253915209980732470285, - .259957524436686071567, - .265963548496984003577, - .271933715484010463114, - .277868451003087102435, - .283768173130738432519, - .289633292582948342896, - .295464212893421063199, - .301261330578199704177, - .307025035294827830512, - .312755710004239517729, - .318453731118097493890, - .324119468654316733591, - .329753286372579168528, - .335355541920762334484, - .340926586970454081892, - .346466767346100823488, - .351976423156884266063, - .357455888922231679316, - .362905493689140712376, - .368325561158599157352, - .373716409793814818840, - .379078352934811846353, - .384411698910298582632, - .389716751140440464951, - .394993808240542421117, - .400243164127459749579, - .405465108107819105498, - .410659924985338875558, - .415827895143593195825, - .420969294644237379543, - .426084395310681429691, - .431173464818130014464, - .436236766774527495726, - .441274560805140936281, - .446287102628048160113, - .451274644139630254358, - .456237433481874177232, - .461175715122408291790, - .466089729924533457960, - .470979715219073113985, - .475845904869856894947, - .480688529345570714212, - .485507815781602403149, - .490303988045525329653, - .495077266798034543171, - .499827869556611403822, - .504556010751912253908, - .509261901790523552335, - .513945751101346104405, - .518607764208354637958, - .523248143765158602036, - .527867089620485785417, - .532464798869114019908, - .537041465897345915436, - .541597282432121573947, - .546132437597407260909, - .550647117952394182793, - .555141507540611200965, - .559615787935399566777, - .564070138285387656651, - .568504735352689749561, - .572919753562018740922, - .577315365035246941260, - .581691739635061821900, - .586049045003164792433, - .590387446602107957005, - .594707107746216934174, - .599008189645246602594, - .603290851438941899687, - .607555250224322662688, - .611801541106615331955, - .616029877215623855590, - .620240409751204424537, - .624433288012369303032, - .628608659422752680256, - .632766669570628437213, - .636907462236194987781, - .641031179420679109171, - .645137961373620782978, - .649227946625615004450, - .653301272011958644725, - .657358072709030238911, - .661398482245203922502, - .665422632544505177065, - .669430653942981734871, - .673422675212350441142, - .677398823590920073911, - .681359224807238206267, - .685304003098281100392, - .689233281238557538017, - .693147180560117703862 -}; - -static double logF_tail[N+1] = { - 0., - -.00000000000000543229938420049, - .00000000000000172745674997061, - -.00000000000001323017818229233, - -.00000000000001154527628289872, - -.00000000000000466529469958300, - .00000000000005148849572685810, - -.00000000000002532168943117445, - -.00000000000005213620639136504, - -.00000000000001819506003016881, - .00000000000006329065958724544, - .00000000000008614512936087814, - -.00000000000007355770219435028, - .00000000000009638067658552277, - .00000000000007598636597194141, - .00000000000002579999128306990, - -.00000000000004654729747598444, - -.00000000000007556920687451336, - .00000000000010195735223708472, - -.00000000000017319034406422306, - -.00000000000007718001336828098, - .00000000000010980754099855238, - -.00000000000002047235780046195, - -.00000000000008372091099235912, - .00000000000014088127937111135, - .00000000000012869017157588257, - .00000000000017788850778198106, - .00000000000006440856150696891, - .00000000000016132822667240822, - -.00000000000007540916511956188, - -.00000000000000036507188831790, - .00000000000009120937249914984, - .00000000000018567570959796010, - -.00000000000003149265065191483, - -.00000000000009309459495196889, - .00000000000017914338601329117, - -.00000000000001302979717330866, - .00000000000023097385217586939, - .00000000000023999540484211737, - .00000000000015393776174455408, - -.00000000000036870428315837678, - .00000000000036920375082080089, - -.00000000000009383417223663699, - .00000000000009433398189512690, - .00000000000041481318704258568, - -.00000000000003792316480209314, - .00000000000008403156304792424, - -.00000000000034262934348285429, - .00000000000043712191957429145, - -.00000000000010475750058776541, - -.00000000000011118671389559323, - .00000000000037549577257259853, - .00000000000013912841212197565, - .00000000000010775743037572640, - .00000000000029391859187648000, - -.00000000000042790509060060774, - .00000000000022774076114039555, - .00000000000010849569622967912, - -.00000000000023073801945705758, - .00000000000015761203773969435, - .00000000000003345710269544082, - -.00000000000041525158063436123, - .00000000000032655698896907146, - -.00000000000044704265010452446, - .00000000000034527647952039772, - -.00000000000007048962392109746, - .00000000000011776978751369214, - -.00000000000010774341461609578, - .00000000000021863343293215910, - .00000000000024132639491333131, - .00000000000039057462209830700, - -.00000000000026570679203560751, - .00000000000037135141919592021, - -.00000000000017166921336082431, - -.00000000000028658285157914353, - -.00000000000023812542263446809, - .00000000000006576659768580062, - -.00000000000028210143846181267, - .00000000000010701931762114254, - .00000000000018119346366441110, - .00000000000009840465278232627, - -.00000000000033149150282752542, - -.00000000000018302857356041668, - -.00000000000016207400156744949, - .00000000000048303314949553201, - -.00000000000071560553172382115, - .00000000000088821239518571855, - -.00000000000030900580513238244, - -.00000000000061076551972851496, - .00000000000035659969663347830, - .00000000000035782396591276383, - -.00000000000046226087001544578, - .00000000000062279762917225156, - .00000000000072838947272065741, - .00000000000026809646615211673, - -.00000000000010960825046059278, - .00000000000002311949383800537, - -.00000000000058469058005299247, - -.00000000000002103748251144494, - -.00000000000023323182945587408, - -.00000000000042333694288141916, - -.00000000000043933937969737844, - .00000000000041341647073835565, - .00000000000006841763641591466, - .00000000000047585534004430641, - .00000000000083679678674757695, - -.00000000000085763734646658640, - .00000000000021913281229340092, - -.00000000000062242842536431148, - -.00000000000010983594325438430, - .00000000000065310431377633651, - -.00000000000047580199021710769, - -.00000000000037854251265457040, - .00000000000040939233218678664, - .00000000000087424383914858291, - .00000000000025218188456842882, - -.00000000000003608131360422557, - -.00000000000050518555924280902, - .00000000000078699403323355317, - -.00000000000067020876961949060, - .00000000000016108575753932458, - .00000000000058527188436251509, - -.00000000000035246757297904791, - -.00000000000018372084495629058, - .00000000000088606689813494916, - .00000000000066486268071468700, - .00000000000063831615170646519, - .00000000000025144230728376072, - -.00000000000017239444525614834 -}; - -double -#ifdef _ANSI_SOURCE -log(double x) -#else -log(x) double x; -#endif -{ - int m, j; - double F, f, g, q, u, u2, v, zero = 0.0, one = 1.0; - volatile double u1; - - /* Catch special cases */ - if (x <= 0) - if (_IEEE && x == zero) /* log(0) = -Inf */ - return (-one/zero); - else if (_IEEE) /* log(neg) = NaN */ - return (zero/zero); - else if (x == zero) /* NOT REACHED IF _IEEE */ - return (infnan(-ERANGE)); - else - return (infnan(EDOM)); - else if (!finite(x)) - if (_IEEE) /* x = NaN, Inf */ - return (x+x); - else - return (infnan(ERANGE)); - - /* Argument reduction: 1 <= g < 2; x/2^m = g; */ - /* y = F*(1 + f/F) for |f| <= 2^-8 */ - - m = logb(x); - g = ldexp(x, -m); - if (_IEEE && m == -1022) { - j = logb(g), m += j; - g = ldexp(g, -j); - } - j = N*(g-1) + .5; - F = (1.0/N) * j + 1; /* F*128 is an integer in [128, 512] */ - f = g - F; - - /* Approximate expansion for log(1+f/F) ~= u + q */ - g = 1/(2*F+f); - u = 2*f*g; - v = u*u; - q = u*v*(A1 + v*(A2 + v*(A3 + v*A4))); - - /* case 1: u1 = u rounded to 2^-43 absolute. Since u < 2^-8, - * u1 has at most 35 bits, and F*u1 is exact, as F has < 8 bits. - * It also adds exactly to |m*log2_hi + log_F_head[j] | < 750 - */ - if (m | j) - u1 = u + 513, u1 -= 513; - - /* case 2: |1-x| < 1/256. The m- and j- dependent terms are zero; - * u1 = u to 24 bits. - */ - else - u1 = u, TRUNC(u1); - u2 = (2.0*(f - F*u1) - u1*f) * g; - /* u1 + u2 = 2f/(2F+f) to extra precision. */ - - /* log(x) = log(2^m*F*(1+f/F)) = */ - /* (m*log2_hi+logF_head[j]+u1) + (m*log2_lo+logF_tail[j]+q); */ - /* (exact) + (tiny) */ - - u1 += m*logF_head[N] + logF_head[j]; /* exact */ - u2 = (u2 + logF_tail[j]) + q; /* tiny */ - u2 += logF_tail[N]*m; - return (u1 + u2); -} - -/* - * Extra precision variant, returning struct {double a, b;}; - * log(x) = a+b to 63 bits, with a is rounded to 26 bits. - */ -struct Double -#ifdef _ANSI_SOURCE -__log__D(double x) -#else -__log__D(x) double x; -#endif -{ - int m, j; - double F, f, g, q, u, v, u2, one = 1.0; - volatile double u1; - struct Double r; - - /* Argument reduction: 1 <= g < 2; x/2^m = g; */ - /* y = F*(1 + f/F) for |f| <= 2^-8 */ - - m = logb(x); - g = ldexp(x, -m); - if (_IEEE && m == -1022) { - j = logb(g), m += j; - g = ldexp(g, -j); - } - j = N*(g-1) + .5; - F = (1.0/N) * j + 1; - f = g - F; - - g = 1/(2*F+f); - u = 2*f*g; - v = u*u; - q = u*v*(A1 + v*(A2 + v*(A3 + v*A4))); - if (m | j) - u1 = u + 513, u1 -= 513; - else - u1 = u, TRUNC(u1); - u2 = (2.0*(f - F*u1) - u1*f) * g; - - u1 += m*logF_head[N] + logF_head[j]; - - u2 += logF_tail[j]; u2 += q; - u2 += logF_tail[N]*m; - r.a = u1 + u2; /* Only difference is here */ - TRUNC(r.a); - r.b = (u1 - r.a) + u2; - return (r); -} diff --git a/lib/msun/bsdsrc/b_tgamma.c b/lib/msun/bsdsrc/b_tgamma.c deleted file mode 100644 index 5d270f05170ef..0000000000000 --- a/lib/msun/bsdsrc/b_tgamma.c +++ /dev/null @@ -1,336 +0,0 @@ -/*- - * Copyright (c) 1992, 1993 - * 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. - */ - -#ifndef lint -static char sccsid[] = "@(#)gamma.c 8.1 (Berkeley) 6/4/93"; -#endif /* not lint */ - -/* - * This code by P. McIlroy, Oct 1992; - * - * The financial support of UUNET Communications Services is greatfully - * acknowledged. - */ - -#include <math.h> -#include "mathimpl.h" -#include <errno.h> - -/* METHOD: - * x < 0: Use reflection formula, G(x) = pi/(sin(pi*x)*x*G(x)) - * At negative integers, return +Inf, and set errno. - * - * x < 6.5: - * Use argument reduction G(x+1) = xG(x) to reach the - * range [1.066124,2.066124]. Use a rational - * approximation centered at the minimum (x0+1) to - * ensure monotonicity. - * - * x >= 6.5: Use the asymptotic approximation (Stirling's formula) - * adjusted for equal-ripples: - * - * log(G(x)) ~= (x-.5)*(log(x)-1) + .5(log(2*pi)-1) + 1/x*P(1/(x*x)) - * - * Keep extra precision in multiplying (x-.5)(log(x)-1), to - * avoid premature round-off. - * - * Special values: - * non-positive integer: Set overflow trap; return +Inf; - * x > 171.63: Set overflow trap; return +Inf; - * NaN: Set invalid trap; return NaN - * - * Accuracy: Gamma(x) is accurate to within - * x > 0: error provably < 0.9ulp. - * Maximum observed in 1,000,000 trials was .87ulp. - * x < 0: - * Maximum observed error < 4ulp in 1,000,000 trials. - */ - -static double neg_gam __P((double)); -static double small_gam __P((double)); -static double smaller_gam __P((double)); -static struct Double large_gam __P((double)); -static struct Double ratfun_gam __P((double, double)); - -/* - * Rational approximation, A0 + x*x*P(x)/Q(x), on the interval - * [1.066.., 2.066..] accurate to 4.25e-19. - */ -#define LEFT -.3955078125 /* left boundary for rat. approx */ -#define x0 .461632144968362356785 /* xmin - 1 */ - -#define a0_hi 0.88560319441088874992 -#define a0_lo -.00000000000000004996427036469019695 -#define P0 6.21389571821820863029017800727e-01 -#define P1 2.65757198651533466104979197553e-01 -#define P2 5.53859446429917461063308081748e-03 -#define P3 1.38456698304096573887145282811e-03 -#define P4 2.40659950032711365819348969808e-03 -#define Q0 1.45019531250000000000000000000e+00 -#define Q1 1.06258521948016171343454061571e+00 -#define Q2 -2.07474561943859936441469926649e-01 -#define Q3 -1.46734131782005422506287573015e-01 -#define Q4 3.07878176156175520361557573779e-02 -#define Q5 5.12449347980666221336054633184e-03 -#define Q6 -1.76012741431666995019222898833e-03 -#define Q7 9.35021023573788935372153030556e-05 -#define Q8 6.13275507472443958924745652239e-06 -/* - * Constants for large x approximation (x in [6, Inf]) - * (Accurate to 2.8*10^-19 absolute) - */ -#define lns2pi_hi 0.418945312500000 -#define lns2pi_lo -.000006779295327258219670263595 -#define Pa0 8.33333333333333148296162562474e-02 -#define Pa1 -2.77777777774548123579378966497e-03 -#define Pa2 7.93650778754435631476282786423e-04 -#define Pa3 -5.95235082566672847950717262222e-04 -#define Pa4 8.41428560346653702135821806252e-04 -#define Pa5 -1.89773526463879200348872089421e-03 -#define Pa6 5.69394463439411649408050664078e-03 -#define Pa7 -1.44705562421428915453880392761e-02 - -static const double zero = 0., one = 1.0, tiny = 1e-300; -static int endian; -/* - * TRUNC sets trailing bits in a floating-point number to zero. - * is a temporary variable. - */ -#if defined(vax) || defined(tahoe) -#define _IEEE 0 -#define TRUNC(x) x = (double) (float) (x) -#else -#define _IEEE 1 -#define TRUNC(x) *(((int *) &x) + endian) &= 0xf8000000 -#define infnan(x) 0.0 -#endif - -double -gamma(x) - double x; -{ - struct Double u; - endian = (*(int *) &one) ? 1 : 0; - - if (x >= 6) { - if(x > 171.63) - return(one/zero); - u = large_gam(x); - return(__exp__D(u.a, u.b)); - } else if (x >= 1.0 + LEFT + x0) - return (small_gam(x)); - else if (x > 1.e-17) - return (smaller_gam(x)); - else if (x > -1.e-17) { - if (x == 0.0) - if (!_IEEE) return (infnan(ERANGE)); - else return (one/x); - one+1e-20; /* Raise inexact flag. */ - return (one/x); - } else if (!finite(x)) { - if (_IEEE) /* x = NaN, -Inf */ - return (x*x); - else - return (infnan(EDOM)); - } else - return (neg_gam(x)); -} -/* - * Accurate to max(ulp(1/128) absolute, 2^-66 relative) error. - */ -static struct Double -large_gam(x) - double x; -{ - double z, p; - int i; - struct Double t, u, v; - - z = one/(x*x); - p = Pa0+z*(Pa1+z*(Pa2+z*(Pa3+z*(Pa4+z*(Pa5+z*(Pa6+z*Pa7)))))); - p = p/x; - - u = __log__D(x); - u.a -= one; - v.a = (x -= .5); - TRUNC(v.a); - v.b = x - v.a; - t.a = v.a*u.a; /* t = (x-.5)*(log(x)-1) */ - t.b = v.b*u.a + x*u.b; - /* return t.a + t.b + lns2pi_hi + lns2pi_lo + p */ - t.b += lns2pi_lo; t.b += p; - u.a = lns2pi_hi + t.b; u.a += t.a; - u.b = t.a - u.a; - u.b += lns2pi_hi; u.b += t.b; - return (u); -} -/* - * Good to < 1 ulp. (provably .90 ulp; .87 ulp on 1,000,000 runs.) - * It also has correct monotonicity. - */ -static double -small_gam(x) - double x; -{ - double y, ym1, t, x1; - struct Double yy, r; - y = x - one; - ym1 = y - one; - if (y <= 1.0 + (LEFT + x0)) { - yy = ratfun_gam(y - x0, 0); - return (yy.a + yy.b); - } - r.a = y; - TRUNC(r.a); - yy.a = r.a - one; - y = ym1; - yy.b = r.b = y - yy.a; - /* Argument reduction: G(x+1) = x*G(x) */ - for (ym1 = y-one; ym1 > LEFT + x0; y = ym1--, yy.a--) { - t = r.a*yy.a; - r.b = r.a*yy.b + y*r.b; - r.a = t; - TRUNC(r.a); - r.b += (t - r.a); - } - /* Return r*gamma(y). */ - yy = ratfun_gam(y - x0, 0); - y = r.b*(yy.a + yy.b) + r.a*yy.b; - y += yy.a*r.a; - return (y); -} -/* - * Good on (0, 1+x0+LEFT]. Accurate to 1ulp. - */ -static double -smaller_gam(x) - double x; -{ - double t, d; - struct Double r, xx; - if (x < x0 + LEFT) { - t = x, TRUNC(t); - d = (t+x)*(x-t); - t *= t; - xx.a = (t + x), TRUNC(xx.a); - xx.b = x - xx.a; xx.b += t; xx.b += d; - t = (one-x0); t += x; - d = (one-x0); d -= t; d += x; - x = xx.a + xx.b; - } else { - xx.a = x, TRUNC(xx.a); - xx.b = x - xx.a; - t = x - x0; - d = (-x0 -t); d += x; - } - r = ratfun_gam(t, d); - d = r.a/x, TRUNC(d); - r.a -= d*xx.a; r.a -= d*xx.b; r.a += r.b; - return (d + r.a/x); -} -/* - * returns (z+c)^2 * P(z)/Q(z) + a0 - */ -static struct Double -ratfun_gam(z, c) - double z, c; -{ - int i; - double p, q; - struct Double r, t; - - q = Q0 +z*(Q1+z*(Q2+z*(Q3+z*(Q4+z*(Q5+z*(Q6+z*(Q7+z*Q8))))))); - p = P0 + z*(P1 + z*(P2 + z*(P3 + z*P4))); - - /* return r.a + r.b = a0 + (z+c)^2*p/q, with r.a truncated to 26 bits. */ - p = p/q; - t.a = z, TRUNC(t.a); /* t ~= z + c */ - t.b = (z - t.a) + c; - t.b *= (t.a + z); - q = (t.a *= t.a); /* t = (z+c)^2 */ - TRUNC(t.a); - t.b += (q - t.a); - r.a = p, TRUNC(r.a); /* r = P/Q */ - r.b = p - r.a; - t.b = t.b*p + t.a*r.b + a0_lo; - t.a *= r.a; /* t = (z+c)^2*(P/Q) */ - r.a = t.a + a0_hi, TRUNC(r.a); - r.b = ((a0_hi-r.a) + t.a) + t.b; - return (r); /* r = a0 + t */ -} - -static double -neg_gam(x) - double x; -{ - int sgn = 1; - struct Double lg, lsine; - double y, z; - - y = floor(x + .5); - if (y == x) /* Negative integer. */ - if(!_IEEE) - return (infnan(ERANGE)); - else - return (one/zero); - z = fabs(x - y); - y = .5*ceil(x); - if (y == ceil(y)) - sgn = -1; - if (z < .25) - z = sin(M_PI*z); - else - z = cos(M_PI*(0.5-z)); - /* Special case: G(1-x) = Inf; G(x) may be nonzero. */ - if (x < -170) { - if (x < -190) - return ((double)sgn*tiny*tiny); - y = one - x; /* exact: 128 < |x| < 255 */ - lg = large_gam(y); - lsine = __log__D(M_PI/z); /* = TRUNC(log(u)) + small */ - lg.a -= lsine.a; /* exact (opposite signs) */ - lg.b -= lsine.b; - y = -(lg.a + lg.b); - z = (y + lg.a) + lg.b; - y = __exp__D(y, z); - if (sgn < 0) y = -y; - return (y); - } - y = one-x; - if (one-y == x) - y = gamma(y); - else /* 1-x is inexact */ - y = -x*gamma(-x); - if (sgn < 0) y = -y; - return (M_PI / (y*z)); -} diff --git a/lib/msun/bsdsrc/mathimpl.h b/lib/msun/bsdsrc/mathimpl.h deleted file mode 100644 index 6a2a37d9f8113..0000000000000 --- a/lib/msun/bsdsrc/mathimpl.h +++ /dev/null @@ -1,98 +0,0 @@ -/* - * Copyright (c) 1988, 1993 - * 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. - * - * @(#)mathimpl.h 8.1 (Berkeley) 6/4/93 - */ - -#include <sys/cdefs.h> -#include <math.h> - -#if defined(vax)||defined(tahoe) - -/* Deal with different ways to concatenate in cpp */ -# ifdef __STDC__ -# define cat3(a,b,c) a ## b ## c -# else -# define cat3(a,b,c) a/**/b/**/c -# endif - -/* Deal with vax/tahoe byte order issues */ -# ifdef vax -# define cat3t(a,b,c) cat3(a,b,c) -# else -# define cat3t(a,b,c) cat3(a,c,b) -# endif - -# define vccast(name) (*(const double *)(cat3(name,,x))) - - /* - * Define a constant to high precision on a Vax or Tahoe. - * - * Args are the name to define, the decimal floating point value, - * four 16-bit chunks of the float value in hex - * (because the vax and tahoe differ in float format!), the power - * of 2 of the hex-float exponent, and the hex-float mantissa. - * Most of these arguments are not used at compile time; they are - * used in a post-check to make sure the constants were compiled - * correctly. - * - * People who want to use the constant will have to do their own - * #define foo vccast(foo) - * since CPP cannot do this for them from inside another macro (sigh). - * We define "vccast" if this needs doing. - */ -# define vc(name, value, x1,x2,x3,x4, bexp, xval) \ - const static long cat3(name,,x)[] = {cat3t(0x,x1,x2), cat3t(0x,x3,x4)}; - -# define ic(name, value, bexp, xval) ; - -#else /* vax or tahoe */ - - /* Hooray, we have an IEEE machine */ -# undef vccast -# define vc(name, value, x1,x2,x3,x4, bexp, xval) ; - -# define ic(name, value, bexp, xval) \ - const static double name = value; - -#endif /* defined(vax)||defined(tahoe) */ - - -/* - * Functions internal to the math package, yet not static. - */ -extern double __exp__E(); -extern double __log__L(); - -struct Double {double a, b;}; -double __exp__D __P((double, double)); -struct Double __log__D __P((double)); diff --git a/lib/ncurses/ncurses/Makefile b/lib/ncurses/ncurses/Makefile deleted file mode 100644 index 949d61759e8d2..0000000000000 --- a/lib/ncurses/ncurses/Makefile +++ /dev/null @@ -1,205 +0,0 @@ -# Makefile for ncurses -# $Id: Makefile,v 1.24 1997/10/20 17:53:54 ache Exp $ - -LIB= ncurses -SHLIB_MAJOR= 3 -SHLIB_MINOR= 1 -SRCS= lib_kernel.c lib_pad.c lib_bkgd.c \ - lib_unctrl.c lib_raw.c lib_vidattr.c lib_trace.c lib_beep.c \ - lib_doupdate.c lib_refresh.c lib_initscr.c lib_newwin.c lib_addch.c \ - lib_addstr.c lib_scroll.c lib_clreol.c lib_touch.c lib_mvcur.c \ - lib_keyname.c keys.tries.h \ - lib_delwin.c lib_endwin.c lib_clrbot.c lib_move.c lib_printw.c \ - lib_scanw.c lib_erase.c lib_getch.c lib_options.c lib_acs.c lib_slk.c\ - lib_box.c lib_clear.c lib_delch.c lib_insch.c lib_instr.c \ - lib_getstr.c lib_mvwin.c lib_longname.c lib_tstp.c \ - lib_newterm.c lib_set_term.c lib_overlay.c lib_scrreg.c lib_color.c \ - lib_insstr.c lib_insdel.c lib_twait.c lib_window.c copyright.c - -CFLAGS+= -I. -I${.CURDIR} -Wall -DMYTINFO #-DTRACE -DPADD= ${LIBMYTINFO} -LDADD= -lmytinfo - -CLEANFILES+= lib_keyname.c keys.tries.h - -beforeinstall: - ${INSTALL} -C -m 444 -o $(BINOWN) -g $(BINGRP) ${.CURDIR}/unctrl.h \ - ${DESTDIR}/usr/include - ${INSTALL} -C -m 444 -o $(BINOWN) -g $(BINGRP) ${.CURDIR}/curses.h \ - ${DESTDIR}/usr/include/ncurses.h - -keys.tries.h: ${.CURDIR}/keys.list ${.CURDIR}/MKkeys.awk - awk -f ${.CURDIR}/MKkeys.awk ${.CURDIR}/keys.list > keys.tries.h - -lib_keyname.c: ${.CURDIR}/keys.list ${.CURDIR}/MKkeyname.awk - awk -f ${.CURDIR}/MKkeyname.awk ${.CURDIR}/keys.list > lib_keyname.c - -MAN3 = curs_addch.3 \ - curs_addchst.3 \ - curs_addstr.3 \ - curs_attr.3 \ - curs_beep.3 \ - curs_bkgd.3 \ - curs_border.3 \ - curs_clear.3 \ - curs_color.3 \ - curs_delch.3 \ - curs_delln.3 \ - curs_getch.3 \ - curs_getstr.3 \ - curs_getyx.3 \ - curs_inch.3 \ - curs_inchstr.3 \ - curs_initscr.3 \ - curs_inopts.3 \ - curs_insch.3 \ - curs_insstr.3 \ - curs_instr.3 \ - curs_kernel.3 \ - curs_move.3 \ - curs_outopts.3 \ - curs_overlay.3 \ - curs_pad.3 \ - curs_printw.3 \ - curs_refresh.3 \ - curs_scanw.3 \ - curs_scr_dmp.3 \ - curs_scroll.3 \ - curs_slk.3 \ - curs_termatt.3 \ - curs_termin.3 \ - curs_touch.3 \ - curs_util.3 \ - curs_window.3 \ - ncurses.3 - -MAN5 = term.5 - -MLINKS+=curs_addch.3 addch.3 curs_addch.3 waddch.3 curs_addch.3 echochar.3 \ - curs_addch.3 wechochar.3 curs_addch.3 mvaddch.3 \ - curs_addch.3 mvwaddch.3 -MLINKS+=curs_addchst.3 addchstr.3 curs_addchst.3 addchnstr.3 \ - curs_addchst.3 waddchstr.3 curs_addchst.3 waddchnstr.3 \ - curs_addchst.3 mvaddchstr.3 curs_addchst.3 mvaddchnstr.3 \ - curs_addchst.3 mvwaddchstr.3 curs_addchst.3 mvwaddchnstr.3 -MLINKS+=curs_addstr.3 addstr.3 curs_addstr.3 addnstr.3 \ - curs_addstr.3 waddstr.3 curs_addstr.3 waddnstr.3 \ - curs_addstr.3 mvaddstr.3 curs_addstr.3 mvaddnstr.3 \ - curs_addstr.3 mvwaddstr.3 curs_addstr.3 mvwaddnstr.3 -MLINKS+=curs_attr.3 attroff.3 curs_attr.3 wattroff.3 \ - curs_attr.3 attron.3 curs_attr.3 wattron.3 \ - curs_attr.3 attrset.3 curs_attr.3 wattrset.3 \ - curs_attr.3 standend.3 curs_attr.3 wstandend.3 \ - curs_attr.3 standout.3 curs_attr.3 wstandout.3 -MLINKS+=curs_beep.3 beep.3 curs_beep.3 flash.3 -MLINKS+=curs_bkgd.3 bkgdset.3 curs_bkgd.3 wbkgdset.3 \ - curs_bkgd.3 bkgd.3 curs_bkgd.3 wbkgd.3 -MLINKS+=curs_border.3 border.3 curs_border.3 wborder.3 curs_border.3 box.3 \ - curs_border.3 hline.3 curs_border.3 whline.3 \ - curs_border.3 vline.3 curs_border.3 wvline.3 -MLINKS+=curs_clear.3 erase.3 curs_clear.3 werase.3 curs_clear.3 clear.3 \ - curs_clear.3 wclear.3 curs_clear.3 clrtobot.3 \ - curs_clear.3 wclrtobot.3 curs_clear.3 clrtoeol.3 \ - curs_clear.3 wclrtoeol.3 -MLINKS+=curs_color.3 start_color.3 curs_color.3 init_pair.3 \ - curs_color.3 init_color.3 curs_color.3 has_colors.3 \ - curs_color.3 can_change_color.3 curs_color.3 color_content.3 \ - curs_color.3 pair_content.3 -MLINKS+=curs_delch.3 delch.3 curs_delch.3 wdelch.3 curs_delch.3 mvdelch.3 \ - curs_delch.3 mvwdelch.3 -MLINKS+=curs_delln.3 deleteln.3 curs_delln.3 wdeleteln.3 \ - curs_delln.3 insdelln.3 curs_delln.3 winsdelln.3 \ - curs_delln.3 insertln.3 curs_delln.3 winsertln.3 -MLINKS+=curs_getch.3 getch.3 curs_getch.3 wgetch.3 curs_getch.3 mvgetch.3 \ - curs_getch.3 mvwgetch.3 curs_getch.3 ungetch.3 -MLINKS+=curs_getstr.3 getstr.3 curs_getstr.3 wgetstr.3 \ - curs_getstr.3 mvgetstr.3 curs_getstr.3 mvwgetstr.3 \ - curs_getstr.3 wgetnstr.3 -MLINKS+=curs_getyx.3 getyx.3 curs_getyx.3 pgetparyx.3 curs_getyx.3 getbegyx.3 \ - curs_getyx.3 getmaxyx.3 -MLINKS+=curs_inch.3 inch.3 curs_inch.3 winch.3 curs_inch.3 mvinch.3 \ - curs_inch.3 mvwinch.3 -MLINKS+=curs_inchstr.3 inchstr.3 curs_inchstr.3 inchnstr.3 \ - curs_inchstr.3 winchstr.3 curs_inchstr.3 winchnstr.3 \ - curs_inchstr.3 mvinchstr.3 curs_inchstr.3 mvinchnstr.3 \ - curs_inchstr.3 mvwinchstr.3 curs_inchstr.3 mvwinchnstr.3 -MLINKS+=curs_initscr.3 initscr.3 curs_initscr.3 newterm.3 \ - curs_initscr.3 endwin.3 curs_initscr.3 isendwin.3 \ - curs_initscr.3 set_term.3 curs_initscr.3 delscreen.3 -MLINKS+=curs_inopts.3 cbreak.3 curs_inopts.3 nocbreak.3 curs_inopts.3 echo.3 \ - curs_inopts.3 noecho.3 curs_inopts.3 halfdelay.3 \ - curs_inopts.3 intrflush.3 curs_inopts.3 keypad.3 curs_inopts.3 meta.3 \ - curs_inopts.3 nodelay.3 curs_inopts.3 notimeout.3 curs_inopts.3 raw.3 \ - curs_inopts.3 noraw.3 curs_inopts.3 noqiflush.3 \ - curs_inopts.3 qiflush.3 curs_inopts.3 timeout.3 \ - curs_inopts.3 wtimeout.3 curs_inopts.3 typeahead.3 -MLINKS+=curs_insch.3 insch.3 curs_insch.3 winsch.3 curs_insch.3 mvinsch.3 \ - curs_insch.3 mvwinsch.3 -MLINKS+=curs_insstr.3 insstr.3 curs_insstr.3 insnstr.3 \ - curs_insstr.3 winsstr.3 curs_insstr.3 winsnstr.3 \ - curs_insstr.3 mvinsstr.3 curs_insstr.3 mvinsnstr.3 \ - curs_insstr.3 mvwinsstr.3 curs_insstr.3 mvwinsnstr.3 -MLINKS+=curs_instr.3 instr.3 curs_instr.3 innstr.3 curs_instr.3 winstr.3 \ - curs_instr.3 winnstr.3 curs_instr.3 mvinstr.3 curs_instr.3 mvinnstr.3 \ - curs_instr.3 mvwinstr.3 curs_instr.3 mvwinnstr.3 -MLINKS+=curs_kernel.3 def_prog_mode.3 curs_kernel.3 def_shell_mode.3 \ - curs_kernel.3 reset_prog_mode.3 curs_kernel.3 reset_shell_mode.3 \ - curs_kernel.3 resetty.3 curs_kernel.3 savetty.3 \ - curs_kernel.3 getsyx.3 curs_kernel.3 setsyx.3 \ - curs_kernel.3 ripoffline.3 curs_kernel.3 curs_set.3 \ - curs_kernel.3 napms.3 -MLINKS+=curs_move.3 move.3 curs_move.3 wmove.3 -MLINKS+=curs_outopts.3 clearok.3 curs_outopts.3 idlok.3 \ - curs_outopts.3 idcok.3 curs_outopts.3 immedok.3 \ - curs_outopts.3 leaveok.3 curs_outopts.3 setscrreg.3 \ - curs_outopts.3 wsetscrreg.3 curs_outopts.3 scrollok.3 \ - curs_outopts.3 nl.3 curs_outopts.3 nonl.3 -MLINKS+=curs_overlay.3 overlay.3 curs_overlay.3 overwrite.3 \ - curs_overlay.3 copywin.3 -MLINKS+=curs_pad.3 newpad.3 curs_pad.3 subpad.3 curs_pad.3 prefresh.3 \ - curs_pad.3 pnoutrefresh.3 curs_pad.3 pechochar.3 -MLINKS+=curs_printw.3 printw.3 curs_printw.3 wprintw.3 \ - curs_printw.3 mvprintw.3 curs_printw.3 mvwprintw.3 \ - curs_printw.3 vwprintw.3 -MLINKS+=curs_refresh.3 refresh.3 curs_refresh.3 wrefresh.3 \ - curs_refresh.3 wnoutrefresh.3 curs_refresh.3 doupdate.3 \ - curs_refresh.3 redrawwin.3 curs_refresh.3 wredrawln.3 -MLINKS+=curs_scanw.3 scanw.3 curs_scanw.3 wscanw.3 curs_scanw.3 mvscanw.3 \ - curs_scanw.3 mvwscanw.3 curs_scanw.3 vwscanw.3 -MLINKS+=curs_scr_dmp.3 scr_dump.3 curs_scr_dmp.3 scr_restore.3 \ - curs_scr_dmp.3 scr_init.3 curs_scr_dmp.3 scr_set.3 -MLINKS+=curs_scroll.3 scroll.3 curs_scroll.3 scrl.3 curs_scroll.3 wscrl.3 -MLINKS+=curs_slk.3 slk_init.3 curs_slk.3 slk_set.3 curs_slk.3 slk_refresh.3 \ - curs_slk.3 slk_noutrefresh.3 curs_slk.3 slk_label.3 \ - curs_slk.3 slk_clear.3 curs_slk.3 slk_restore.3 \ - curs_slk.3 slk_touch.3 curs_slk.3 slk_attron.3 \ - curs_slk.3 slk_attrset.3 curs_slk.3 slk_attroff.3 -MLINKS+=curs_termatt.3 baudrate.3 curs_termatt.3 erasechar.3 \ - curs_termatt.3 has_ic.3 curs_termatt.3 has_il.3 \ - curs_termatt.3 killchar.3 curs_termatt.3 longname.3 \ - curs_termatt.3 termattrs.3 curs_termatt.3 termname.3 - -# XXX name clash with termcap(3) -# MLINKS+= curs_termin.3 tparm.3 -MLINKS+=curs_termin.3 setupterm.3 curs_termin.3 setterm.3 \ - curs_termin.3 set_curterm.3 curs_termin.3 del_curterm.3 \ - curs_termin.3 restartterm.3 \ - curs_termin.3 putp.3 curs_termin.3 vidputs.3 \ - curs_termin.3 vidattr.3 curs_termin.3 mvcur.3 \ - curs_termin.3 tigetflag.3 curs_termin.3 tigetnum.3 \ - curs_termin.3 tigetstr.3 -MLINKS+=curs_touch.3 touchwin.3 curs_touch.3 touchline.3 \ - curs_touch.3 untouchwin.3 curs_touch.3 wtouchln.3 \ - curs_touch.3 is_linetouched.3 curs_touch.3 is_wintouched.3 -MLINKS+=curs_util.3 unctrl.3 curs_util.3 keyname.3 \ - curs_util.3 filter.3 curs_util.3 use_env.3 \ - curs_util.3 putwin.3 curs_util.3 getwin.3 \ - curs_util.3 delay_output.3 curs_util.3 flushinp.3 -MLINKS+=curs_window.3 newwin.3 curs_window.3 delwin.3 \ - curs_window.3 mvwin.3 curs_window.3 subwin.3 \ - curs_window.3 derwin.3 curs_window.3 mvderwin.3 \ - curs_window.3 dupwin.3 curs_window.3 wsyncup.3 \ - curs_window.3 syncok.3 curs_window.3 wcursyncup.3 \ - curs_window.3 wsyncdown.3 - -.include <bsd.lib.mk> |