summaryrefslogtreecommitdiff
path: root/devel/mit-pthreads/patches
diff options
context:
space:
mode:
authorbad <bad>1998-12-28 22:21:59 +0000
committerbad <bad>1998-12-28 22:21:59 +0000
commit038570b742aeea4116f83ca3a981122a3af38704 (patch)
treedf07ba8bb41c055977fcbc124099661e4680aec6 /devel/mit-pthreads/patches
parentf3a8e9f9dcc2115d697587adfdba5834ffc3cdab (diff)
downloadpkgsrc-038570b742aeea4116f83ca3a981122a3af38704.tar.gz
Make this work on alpha, arm32, i386, and sparc on 1.3 and up.
Diffstat (limited to 'devel/mit-pthreads/patches')
-rw-r--r--devel/mit-pthreads/patches/patch-aa54
-rw-r--r--devel/mit-pthreads/patches/patch-ad339
-rw-r--r--devel/mit-pthreads/patches/patch-ae257
-rw-r--r--devel/mit-pthreads/patches/patch-af439
-rw-r--r--devel/mit-pthreads/patches/patch-ag167
-rw-r--r--devel/mit-pthreads/patches/patch-aj81
-rw-r--r--devel/mit-pthreads/patches/patch-ak81
-rw-r--r--devel/mit-pthreads/patches/patch-an22
-rw-r--r--devel/mit-pthreads/patches/patch-ao13
-rw-r--r--devel/mit-pthreads/patches/patch-ap13
-rw-r--r--devel/mit-pthreads/patches/patch-aq12
-rw-r--r--devel/mit-pthreads/patches/patch-ar25
-rw-r--r--devel/mit-pthreads/patches/patch-as111
-rw-r--r--devel/mit-pthreads/patches/patch-at237
-rw-r--r--devel/mit-pthreads/patches/patch-au176
-rw-r--r--devel/mit-pthreads/patches/patch-av52
-rw-r--r--devel/mit-pthreads/patches/patch-aw230
-rw-r--r--devel/mit-pthreads/patches/patch-ax103
-rw-r--r--devel/mit-pthreads/patches/patch-ay205
-rw-r--r--devel/mit-pthreads/patches/patch-az61
-rw-r--r--devel/mit-pthreads/patches/patch-ba107
-rw-r--r--devel/mit-pthreads/patches/patch-bb200
-rw-r--r--devel/mit-pthreads/patches/patch-bc198
-rw-r--r--devel/mit-pthreads/patches/patch-bd60
24 files changed, 2604 insertions, 639 deletions
diff --git a/devel/mit-pthreads/patches/patch-aa b/devel/mit-pthreads/patches/patch-aa
index d40e870a349..ecd6abc731d 100644
--- a/devel/mit-pthreads/patches/patch-aa
+++ b/devel/mit-pthreads/patches/patch-aa
@@ -1,23 +1,37 @@
-$NetBSD: patch-aa,v 1.7 1998/08/23 06:22:17 garbled Exp $
---- machdep/syscall-i386-netbsd-1.1.S 1998/03/09 00:14:35 1.1
-+++ machdep/syscall-i386-netbsd-1.1.S 1998/03/09 00:16:17
-@@ -160,3 +160,19 @@
- xorl %eax,%eax
- ret
+$NetBSD: patch-aa,v 1.8 1998/12/28 22:21:59 bad Exp $
+
+--- stdlib/strtod.c.orig Mon Sep 25 09:30:57 1995
++++ stdlib/strtod.c Sun Dec 27 23:39:16 1998
+@@ -93,12 +93,23 @@
+ static char *rcsid = "$Id: patch-aa,v 1.8 1998/12/28 22:21:59 bad Exp $";
+ #endif /* LIBC_SCCS and not lint */
++#ifndef __arm32__
+ #include <endian.h>
+ #if BYTE_ORDER == BIG_ENDIAN
+ #define IEEE_BIG_ENDIAN 1
+ #else
+ #define IEEE_LITTLE_ENDIAN 1
+ #endif
++#endif
+
-+/* ==========================================================================
-+ * machdep_sys_fstat()
++#ifdef __arm32__
++/*
++ * Although the CPU is little endian the FP has different
++ * byte and word endianness. The byte order is still little endian
++ * but the word order is big endian.
+ */
-+ .globl _machdep_sys_fstat;
-+
-+_machdep_sys_fstat:;
-+
-+ movl $(SYS___fstat13), %eax;
-+ .byte 0x9a; .long 0; .word 7;
-+ cmpl $0, %edx
-+ je 2f
-+ movl $0, %eax
-+2:
-+ ret
-+
++#define IEEE_BIG_ENDIAN
++#endif
+
+ #include <pthread/ac-types.h>
+ /*
+@@ -222,7 +233,7 @@
+ * An alternative that might be better on some machines is
+ * #define Storeinc(a,b,c) (*a++ = b << 16 | c & 0xffff)
+ */
+-#if defined(IEEE_LITTLE_ENDIAN) + defined(VAX)
++#if defined(IEEE_LITTLE_ENDIAN) + defined(VAX) + defined(__arm32__)
+ #define Storeinc(a,b,c) (((unsigned short *)a)[1] = (unsigned short)b, \
+ ((unsigned short *)a)[0] = (unsigned short)c, a++)
+ #else
diff --git a/devel/mit-pthreads/patches/patch-ad b/devel/mit-pthreads/patches/patch-ad
index 20e21c63e42..0f3d5a5cf26 100644
--- a/devel/mit-pthreads/patches/patch-ad
+++ b/devel/mit-pthreads/patches/patch-ad
@@ -1,228 +1,117 @@
-$NetBSD: patch-ad,v 1.1 1998/08/23 06:22:17 garbled Exp $
---- /dev/null Sat Jul 18 04:38:07 1998
-+++ machdep/syscall-alpha-netbsd-1.3.S Sat Jul 18 04:38:20 1998
-@@ -0,0 +1,224 @@
-+#include <machine/asm.h>
-+#define CHMK() call_pal 0x83
-+#define COMPAT_43
-+#include <sys/syscall.h>
-+#ifndef __CONCAT
+$NetBSD: patch-ad,v 1.2 1998/12/28 22:21:59 bad Exp $
+
+--- /dev/null Sun Dec 27 17:07:36 1998
++++ machdep/engine-alpha-netbsd-1.3.h Sun Dec 27 17:21:40 1998
+@@ -0,0 +1,112 @@
++/* ==== machdep.h ============================================================
++ * Copyright (c) 1994 Chris Provenzano (proven@athena.mit.edu) and
++ * Ken Raeburn (raeburn@mit.edu).
++ *
++ * engine-alpha-osf1.h,v 1.4.4.1 1995/12/13 05:41:42 proven Exp
++ *
++ */
++
++#include <unistd.h>
++#include <setjmp.h>
++#include <sys/time.h>
+#include <sys/cdefs.h>
-+#endif
-+#define CONCAT __CONCAT
-+
-+#undef SYSCALL
-+
-+/* Kernel syscall interface:
-+ Input:
-+ v0 - system call number
-+ a* - arguments, as in C
-+ Output:
-+ a3 - zero iff successful
-+ v0 - errno value on failure, else result
-+
-+ This macro is similar to SYSCALL in asm.h, but not completely.
-+ There's room for optimization, if we assume this will continue to
-+ be assembled as one file.
-+
-+ This macro expansions does not include the return instruction.
-+ If there's no other work to be done, use something like:
-+ SYSCALL(foo) ; ret
-+ If there is other work to do (in fork, maybe?), do it after the
-+ SYSCALL invocation. */
-+
-+#define SYSCALL(x) \
-+ .align 4 ;\
-+ .globl CONCAT(machdep_sys_,x) ;\
-+ .ent CONCAT(machdep_sys_,x), 0 ;\
-+CONCAT(machdep_sys_,x): ;\
-+ .frame sp,0,ra ;\
-+ ldiq v0, CONCAT(SYS_,x) ;\
-+ CHMK() ;\
-+ beq a3, CONCAT(Lsys_noerr_,x) ;\
-+ br gp, CONCAT(Lsys_err_,x) ;\
-+CONCAT(Lsys_err_,x): ;\
-+ /* Load gp so we can find cerror to jump to. */;\
-+ ldgp gp, 0(gp) ;\
-+ jmp zero, machdep_cerror ;\
-+CONCAT(Lsys_noerr_,x):
-+
-+#define XSYSCALL(x) SYSCALL(x) ; RET ; .end CONCAT(machdep_sys_,x)
-+
-+ .globl machdep_cerror
-+machdep_cerror:
-+ br t0, Lmachdep_cerror_setgp
-+Lmachdep_cerror_setgp:
-+ ldgp gp, 0(t0)
-+ stl v0, errno
++#include <sys/signal.h> /* for _NSIG */
++
++/* The first machine dependent functions are the SEMAPHORES needing
++ the test and set instruction.
++
++ On the Alpha, the actual values here are irrelevant; they just have
++ to be different. */
++#define SEMAPHORE_CLEAR 0
++#define SEMAPHORE_SET 1
++
+#if 0
-+ ldiq v0, -1
-+#else
-+ subq zero, v0, v0
++#define SEMAPHORE_TEST_AND_SET(lock) \
++({ int *_sem_lock = (lock), locked, old; \
++ asm ("mb" : : : "memory"); \
++ do { asm ("ldl_l %0,%1" : "=r" (old) : "m" (*_sem_lock)); \
++ /* ?? if (old != SEMAPHORE_CLEAR) break; */ \
++ asm ("stl_c %0,%1" : "=r" (locked), "=m" (*_sem_lock) \
++ : "0" (SEMAPHORE_SET)); \
++ } while (!locked); \
++ asm ("mb" : : : "memory"); \
++ old == SEMAPHORE_CLEAR; })
++
++#define SEMAPHORE_RESET(lock) \
++({ int *_sem_lock = (lock); \
++ *_sem_lock = SEMAPHORE_CLEAR; \
++ asm ("mb" : : : "memory"); })
+#endif
-+ RET
-+
-+/* The fork system call is special... */
-+SYSCALL(fork)
-+ cmovne a4, 0, v0
-+ RET
-+ .end machdep_sys_fork
-+
-+/* The pipe system call is special... */
-+SYSCALL(pipe)
-+ stl v0, 0(a0)
-+ stl a4, 4(a0)
-+ mov zero, v0
-+ RET
-+ .end machdep_sys_pipe
-+
-+/* The sigsuspend system call is special... */
-+ .align 4
-+ .globl machdep_sys_sigsuspend
-+ .ent machdep_sys_sigsuspend, 0
-+machdep_sys_sigsuspend:
-+ ldl a0, 0(a0) /* pass *mask instead of mask */
-+ ldiq v0, SYS_sigsuspend
-+ CHMK()
-+ mov zero, v0 /* shouldn't need; just in case... */
-+ RET
-+ .end machdep_sys_sigsuspend
-+
-+/* The sigprocmask system call is special... */
-+ .align 4
-+ .globl machdep_sys_sigprocmask
-+ .ent machdep_sys_sigprocmask, 0
-+machdep_sys_sigprocmask:
-+ mov a2, a5 /* safe */
-+ cmoveq a1, 1, a0 /* if set == NULL, how = SIG_BLOCK */
-+ beq a1, Ldoit /* and set = 0, and do it. */
-+ ldl a1, 0(a1) /* load the set from *set */
-+Ldoit: ldiq v0, SYS_sigprocmask
-+ CHMK()
-+ beq a5, Lret /* if they don't want old mask, done */
-+ stl v0, 0(a5) /* otherwise, give it to them. */
-+Lret: mov zero, v0
-+ RET
-+ .end machdep_sys_sigprocmask
-+
-+/* More stuff ... */
-+ .align 4
-+ .global __machdep_save_int_state
-+ .ent __machdep_save_int_state, 0
-+__machdep_save_int_state:
-+ .frame sp, 16, ra
-+ ldgp gp, 0(t12)
-+ lda sp, -16(sp)
-+ stq ra, 0(sp)
-+
-+ /* save integer registers */
-+ stq ra, ( 0 * 8)(a0) /* return address */
-+ stq s0, ( 1 * 8)(a0) /* callee-saved registers */
-+ stq s1, ( 2 * 8)(a0)
-+ stq s2, ( 3 * 8)(a0)
-+ stq s3, ( 4 * 8)(a0)
-+ stq s4, ( 5 * 8)(a0)
-+ stq s5, ( 6 * 8)(a0)
-+ stq s6, ( 7 * 8)(a0)
-+ stq sp, ( 9 * 8)(a0)
-+ stq ra, ( 8 * 8)(a0) /* RA on return */
-+ stq pv, (10 * 8)(a0) /* and PV; we restore it */
-+
-+ mov zero, v0
-+ lda sp, 16(sp)
-+ RET
-+ .end __machdep_save_int_state
-+
-+ .align 4
-+ .global __machdep_restore_int_state
-+ .ent __machdep_restore_int_state, 0
-+__machdep_restore_int_state:
-+ .frame sp, 16, ra
-+ ldgp gp, 0(t12)
-+ lda sp, -16(sp)
-+ stq ra, 0(sp)
-+
-+ /* restore integer registers */
-+ ldq t0, ( 0 * 8)(a0) /* return address */
-+ ldq s0, ( 1 * 8)(a0) /* callee-saved registers */
-+ ldq s1, ( 2 * 8)(a0)
-+ ldq s2, ( 3 * 8)(a0)
-+ ldq s3, ( 4 * 8)(a0)
-+ ldq s4, ( 5 * 8)(a0)
-+ ldq s5, ( 6 * 8)(a0)
-+ ldq s6, ( 7 * 8)(a0)
-+ ldq ra, ( 8 * 8)(a0) /* RA after return */
-+ ldq sp, ( 9 * 8)(a0)
-+ ldq pv, (10 * 8)(a0) /* and PV; we restore it */
-+
-+ ldiq v0, 1
-+ ret zero,(t0),1
-+ .end __machdep_restore_int_state
-+
-+ .align 4
-+ .global __machdep_save_fp_state
-+ .ent __machdep_save_fp_state, 0
-+__machdep_save_fp_state:
-+ .frame sp, 16, ra
-+ ldgp gp, 0(t12)
-+ lda sp, -16(sp)
-+ stq ra, 0(sp)
-+
-+ /* save FP registers */
-+ stt fs0, (0 * 8)(a0) /* callee-saved registers */
-+ stt fs1, (1 * 8)(a0)
-+ stt fs2, (2 * 8)(a0)
-+ stt fs3, (3 * 8)(a0)
-+ stt fs4, (4 * 8)(a0)
-+ stt fs5, (5 * 8)(a0)
-+ stt fs6, (6 * 8)(a0)
-+ stt fs7, (7 * 8)(a0)
-+ mf_fpcr ft0 /* and FP control reg */
-+ stt ft0, (8 * 8)(a0)
-+
-+ lda sp, 16(sp)
-+ RET
-+ .end __machdep_save_fp_state
-+
-+ .align 4
-+ .global __machdep_restore_fp_state
-+ .ent __machdep_restore_fp_state, 0
-+__machdep_restore_fp_state:
-+ .frame sp, 16, ra
-+ ldgp gp, 0(t12)
-+ lda sp, -16(sp)
-+ stq ra, 0(sp)
-+
-+ /* restore FP registers */
-+ ldt fs0, (0 * 8)(a0) /* callee-saved registers */
-+ ldt fs1, (1 * 8)(a0)
-+ ldt fs2, (2 * 8)(a0)
-+ ldt fs3, (3 * 8)(a0)
-+ ldt fs4, (4 * 8)(a0)
-+ ldt fs5, (5 * 8)(a0)
-+ ldt fs6, (6 * 8)(a0)
-+ ldt fs7, (7 * 8)(a0)
-+ ldt ft0, (8 * 8)(a0)
-+ mt_fpcr ft0 /* and FP control reg */
-+
-+ lda sp, 16(sp)
-+ RET
-+ .end __machdep_restore_fp_state
-+
-+/* For fstat() we actually syscall fstat13. */
-+ .align 4
-+ .globl machdep_sys_fstat
-+ .ent machdep_sys_fstat, 0
-+machdep_sys_fstat:
-+ .frame sp,0,ra
-+ ldiq v0, SYS___fstat13
-+ CHMK()
-+ beq a3, Lsys_noerr_fstat
-+ br gp, Lsys_err_fstat
-+Lsys_err_fstat:
-+ /* Load gp so we can find cerror to jump to. */
-+ ldgp gp, 0(gp)
-+ jmp zero, machdep_cerror
-+Lsys_noerr_fstat:
-+ RET
-+ .end machdep_sys_fstat
++
++/*
++ * New types
++ */
++typedef int semaphore;
++
++/*
++ * sigset_t macros
++ */
++#define SIG_ANY(sig) (sig)
++#define SIGMAX (_NSIG-1)
++
++/*
++ * New Strutures
++ */
++struct machdep_pthread {
++ void *(*start_routine)(void *);
++ void *start_argument;
++ void *machdep_stack;
++ struct itimerval machdep_timer;
++ unsigned long machdep_istate[11];
++ unsigned long machdep_fstate[9];
++};
++
++/*
++ * Static machdep_pthread initialization values.
++ * For initial thread only.
++ */
++#define MACHDEP_PTHREAD_INIT \
++ { NULL, NULL, NULL, { { 0, 0 }, { 0, 100000 } }, 0 }
++
++/*
++ * Minimum stack size
++ */
++#define PTHREAD_STACK_MIN 2048
++
++/*
++ * Some fd flag defines that are necessary to distinguish between posix
++ * behavior and bsd4.3 behavior.
++ */
++#define __FD_NONBLOCK O_NONBLOCK
++
++/*
++ * New functions
++ */
++
++__BEGIN_DECLS
++
++#if defined(PTHREAD_KERNEL)
++
++#define __machdep_stack_get(x) (x)->machdep_stack
++#define __machdep_stack_set(x, y) (x)->machdep_stack = y
++#define __machdep_stack_repl(x, y) \
++{ \
++ if (stack = __machdep_stack_get(x)) { \
++ __machdep_stack_free(stack); \
++ } \
++ __machdep_stack_set(x, y); \
++}
++
++void * __machdep_stack_alloc __P_((size_t));
++void __machdep_stack_free __P_((void *));
++
++int machdep_save_state __P_((void));
++
++int __machdep_save_int_state __P_((unsigned long *));
++void __machdep_restore_int_state __P_((unsigned long *));
++void __machdep_save_fp_state __P_((unsigned long *));
++void __machdep_restore_fp_state __P_((unsigned long *));
++
++#endif
++
++__END_DECLS
diff --git a/devel/mit-pthreads/patches/patch-ae b/devel/mit-pthreads/patches/patch-ae
index 16f02e28194..7b519e4e439 100644
--- a/devel/mit-pthreads/patches/patch-ae
+++ b/devel/mit-pthreads/patches/patch-ae
@@ -1,50 +1,209 @@
-$NetBSD: patch-ae,v 1.1 1998/08/23 06:22:17 garbled Exp $
---- /dev/null Sat Jul 18 04:39:35 1998
-+++ machdep/syscall-template-alpha-netbsd-1.3.S Sat Jul 18 04:41:03 1998
-@@ -0,0 +1,46 @@
-+#include <machine/asm.h>
-+#define COMPAT_43
+$NetBSD: patch-ae,v 1.2 1998/12/28 22:22:00 bad Exp $
+
+--- /dev/null Sun Dec 27 17:45:54 1998
++++ machdep/engine-alpha-netbsd-1.3.c Mon Mar 9 11:30:59 1998
+@@ -0,0 +1,204 @@
++/* ==== machdep.c ============================================================
++ * Copyright (c) 1993, 1994 Chris Provenzano, proven@athena.mit.edu
++ *
++ * Description : Machine dependent functions for NetBSD/Alpha 1.1(+)
++ *
++ * 1.00 93/08/04 proven
++ * -Started coding this file.
++ *
++ * 95/04/22 cgd
++ * -Modified to make it go with NetBSD/Alpha
++ */
++
++#ifndef lint
++static const char rcsid[] = "engine-alpha-osf1.c,v 1.4.4.1 1995/12/13 05:41:37 proven Exp";
++#endif
++
++#include <pthread.h>
++#include <sys/types.h>
++#include <sys/socket.h>
+#include <sys/syscall.h>
-+#define CHMK() call_pal 0x83
-+
-+#undef SYSCALL
-+
-+/* Kernel syscall interface:
-+ Input:
-+ v0 - system call number
-+ a* - arguments, as in C
-+ Output:
-+ a3 - zero iff successful
-+ v0 - errno value on failure, else result
-+
-+ This macro is similar to SYSCALL in asm.h, but not completely.
-+ There's room for optimization, if we assume this will continue to
-+ be assembled as one file.
-+
-+ This macro expansions does not include the return instruction.
-+ If there's no other work to be done, use something like:
-+ SYSCALL(foo) ; ret
-+ If there is other work to do (in fork, maybe?), do it after the
-+ SYSCALL invocation. */
-+
-+#define SYSCALL(x) \
-+ .align 4 ;\
-+ .globl machdep_sys_##x ;\
-+ .ent machdep_sys_##x, 0 ;\
-+machdep_sys_##x: ;\
-+ .frame sp,0,ra ;\
-+ ldiq v0, SYS_##x ;\
-+ CHMK() ;\
-+ beq a3, Lsys_noerr_##x ;\
-+ br gp, Lsys_err_##x ;\
-+Lsys_err_##x: ;\
-+ /* Load gp so we can find cerror to jump to. */;\
-+ ldgp gp, 0(gp) ;\
-+ jmp zero, machdep_cerror ;\
-+Lsys_noerr_##x:
-+
-+#define SIMPLE_SYSCALL(x) SYSCALL(x) ; ret ; .end machdep_sys_##x
-+
-+#define XSYSCALL(x) SIMPLE_SYSCALL(x)
-+
-+XSYSCALL(SYSCALL_NAME)
++#include <stdlib.h>
++#include <fcntl.h>
++#include <stdio.h>
++
++/* ==========================================================================
++ * machdep_save_state()
++ */
++int machdep_save_state(void)
++{
++ return __machdep_save_int_state(pthread_run->machdep_data.machdep_istate);
++}
++
++void machdep_restore_state(void)
++{
++ __machdep_restore_int_state(pthread_run->machdep_data.machdep_istate);
++}
++
++void machdep_save_float_state (void)
++{
++ __machdep_save_fp_state(pthread_run->machdep_data.machdep_fstate);
++}
++
++void machdep_restore_float_state (void)
++{
++ __machdep_restore_fp_state(pthread_run->machdep_data.machdep_fstate);
++}
++
++/* ==========================================================================
++ * machdep_set_thread_timer()
++ */
++void machdep_set_thread_timer(struct machdep_pthread *machdep_pthread)
++{
++ if (setitimer(ITIMER_VIRTUAL, &(machdep_pthread->machdep_timer), NULL)) {
++ PANIC();
++ }
++}
++
++/* ==========================================================================
++ * machdep_unset_thread_timer()
++ */
++void machdep_unset_thread_timer(struct machdep_pthread *machdep_pthread)
++{
++ struct itimerval zeroval = { { 0, 0 }, { 0, 0} };
++
++ if (setitimer(ITIMER_VIRTUAL, &zeroval, NULL)) {
++ PANIC();
++ }
++}
++
++/* ==========================================================================
++ * machdep_pthread_cleanup()
++ */
++void *machdep_pthread_cleanup(struct machdep_pthread *machdep_pthread)
++{
++ return(machdep_pthread->machdep_stack);
++}
++
++/* ==========================================================================
++ * machdep_pthread_start()
++ */
++void machdep_pthread_start(void)
++{
++ context_switch_done();
++ pthread_sched_resume ();
++
++ /* Run current threads start routine with argument */
++ pthread_exit(pthread_run->machdep_data.start_routine
++ (pthread_run->machdep_data.start_argument));
++
++ /* should never reach here */
++ PANIC();
++}
++
++/* ==========================================================================
++ * __machdep_stack_free()
++ */
++void __machdep_stack_free(void * stack)
++{
++ free(stack);
++}
++
++/* ==========================================================================
++ * __machdep_stack_alloc()
++ */
++void * __machdep_stack_alloc(size_t size)
++{
++ void * stack;
++
++ return(malloc(size));
++}
++
++/* ==========================================================================
++ * __machdep_pthread_create()
++ */
++void __machdep_pthread_create(struct machdep_pthread *machdep_pthread,
++ void *(* start_routine)(), void *start_argument,
++ long stack_size, long nsec, long flags)
++{
++ machdep_pthread->start_routine = start_routine;
++ machdep_pthread->start_argument = start_argument;
++
++ machdep_pthread->machdep_timer.it_value.tv_sec = 0;
++ machdep_pthread->machdep_timer.it_interval.tv_sec = 0;
++ machdep_pthread->machdep_timer.it_interval.tv_usec = 0;
++ machdep_pthread->machdep_timer.it_value.tv_usec = nsec / 1000;
++
++ /* Set up new stack frame so that it looks like it returned from a
++ longjmp() to the beginning of machdep_pthread_start(). */
++ machdep_pthread->machdep_istate[8/*ISTATE_RA*/] = 0;
++ machdep_pthread->machdep_istate[0/*ISTATE_PC*/] = (long)machdep_pthread_start;
++ machdep_pthread->machdep_istate[10/*ISTATE_PV*/] = (long)machdep_pthread_start;
++
++ /* Alpha stack starts high and builds down. */
++ {
++ long stk_addr = (long) machdep_pthread->machdep_stack;
++ stk_addr += stack_size - 1024;
++ stk_addr &= ~15;
++ machdep_pthread->machdep_istate[9/*ISTATE_SP*/] = stk_addr;
++ }
++}
++
++int safe_store (loc, new)
++ int *loc;
++ int new;
++{
++ int locked, old;
++ asm ("mb" : : : "memory");
++ do {
++ asm ("ldl_l %0,%1" : "=r" (old) : "m" (*loc));
++ asm ("stl_c %0,%1" : "=r" (locked), "=m" (*loc) : "0" (new));
++ } while (!locked);
++ asm ("mb" : : : "memory");
++ return old;
++}
++
++/* ==========================================================================
++ * machdep_sys_creat()
++ */
++machdep_sys_creat(char * path, int mode)
++{
++ return(machdep_sys_open(path, O_WRONLY | O_CREAT | O_TRUNC, mode));
++}
++
++/* ==========================================================================
++ * machdep_sys_wait3()
++ */
++machdep_sys_wait3(int * b, int c, int * d)
++{
++ return(machdep_sys_wait4(0, b, c, d));
++}
++
++/* ==========================================================================
++ * machdep_sys_waitpid()
++ */
++machdep_sys_waitpid(int a, int * b, int c)
++{
++ return(machdep_sys_wait4(a, b, c, NULL));
++}
++
++/* ==========================================================================
++ * machdep_sys_getdtablesize()
++ */
++machdep_sys_getdtablesize()
++{
++ return(sysconf(_SC_OPEN_MAX));
++}
++
++/* ==========================================================================
++ * machdep_sys_lseek()
++ */
++off_t machdep_sys_lseek(int fd, off_t offset, int whence)
++{
++ extern off_t __syscall();
++
++ return(__syscall((quad_t)SYS_lseek, fd, 0, offset, whence));
++}
++
++/* ==========================================================================
++ * machdep_sys_getdirentries()
++ */
++machdep_sys_getdirentries(int fd, char * buf, int len, int * seek)
++{
++ return(machdep_sys_getdents(fd, buf, len));
++}
diff --git a/devel/mit-pthreads/patches/patch-af b/devel/mit-pthreads/patches/patch-af
index 8e9ccd2eddc..632318c8943 100644
--- a/devel/mit-pthreads/patches/patch-af
+++ b/devel/mit-pthreads/patches/patch-af
@@ -1,208 +1,233 @@
-$NetBSD: patch-af,v 1.1 1998/08/23 06:22:17 garbled Exp $
---- /dev/null Sat Jul 18 04:39:35 1998
-+++ machdep/engine-alpha-netbsd-1.3.c Sat Jul 18 04:41:03 1998
-@@ -0,0 +1,204 @@
-+/* ==== machdep.c ============================================================
-+ * Copyright (c) 1993, 1994 Chris Provenzano, proven@athena.mit.edu
-+ *
-+ * Description : Machine dependent functions for NetBSD/Alpha 1.1(+)
-+ *
-+ * 1.00 93/08/04 proven
-+ * -Started coding this file.
-+ *
-+ * 95/04/22 cgd
-+ * -Modified to make it go with NetBSD/Alpha
-+ */
-+
-+#ifndef lint
-+static const char rcsid[] = "engine-alpha-osf1.c,v 1.4.4.1 1995/12/13 05:41:37 proven Exp";
-+#endif
-+
-+#include <pthread.h>
-+#include <sys/types.h>
-+#include <sys/socket.h>
+$NetBSD: patch-af,v 1.2 1998/12/28 22:22:00 bad Exp $
+
+--- /dev/null Sun Dec 27 17:07:36 1998
++++ machdep/syscall-alpha-netbsd-1.3.S Sun Dec 27 17:21:40 1998
+@@ -0,0 +1,228 @@
++#include <machine/asm.h>
++#define CHMK() call_pal 0x83
++#define COMPAT_43
+#include <sys/syscall.h>
-+#include <stdlib.h>
-+#include <fcntl.h>
-+#include <stdio.h>
-+
-+/* ==========================================================================
-+ * machdep_save_state()
-+ */
-+int machdep_save_state(void)
-+{
-+ return __machdep_save_int_state(pthread_run->machdep_data.machdep_istate);
-+}
-+
-+void machdep_restore_state(void)
-+{
-+ __machdep_restore_int_state(pthread_run->machdep_data.machdep_istate);
-+}
-+
-+void machdep_save_float_state (void)
-+{
-+ __machdep_save_fp_state(pthread_run->machdep_data.machdep_fstate);
-+}
-+
-+void machdep_restore_float_state (void)
-+{
-+ __machdep_restore_fp_state(pthread_run->machdep_data.machdep_fstate);
-+}
-+
-+/* ==========================================================================
-+ * machdep_set_thread_timer()
-+ */
-+void machdep_set_thread_timer(struct machdep_pthread *machdep_pthread)
-+{
-+ if (setitimer(ITIMER_VIRTUAL, &(machdep_pthread->machdep_timer), NULL)) {
-+ PANIC();
-+ }
-+}
-+
-+/* ==========================================================================
-+ * machdep_unset_thread_timer()
-+ */
-+void machdep_unset_thread_timer(struct machdep_pthread *machdep_pthread)
-+{
-+ struct itimerval zeroval = { { 0, 0 }, { 0, 0} };
-+
-+ if (setitimer(ITIMER_VIRTUAL, &zeroval, NULL)) {
-+ PANIC();
-+ }
-+}
-+
-+/* ==========================================================================
-+ * machdep_pthread_cleanup()
-+ */
-+void *machdep_pthread_cleanup(struct machdep_pthread *machdep_pthread)
-+{
-+ return(machdep_pthread->machdep_stack);
-+}
-+
-+/* ==========================================================================
-+ * machdep_pthread_start()
-+ */
-+void machdep_pthread_start(void)
-+{
-+ context_switch_done();
-+ pthread_sched_resume ();
-+
-+ /* Run current threads start routine with argument */
-+ pthread_exit(pthread_run->machdep_data.start_routine
-+ (pthread_run->machdep_data.start_argument));
-+
-+ /* should never reach here */
-+ PANIC();
-+}
-+
-+/* ==========================================================================
-+ * __machdep_stack_free()
-+ */
-+void __machdep_stack_free(void * stack)
-+{
-+ free(stack);
-+}
-+
-+/* ==========================================================================
-+ * __machdep_stack_alloc()
-+ */
-+void * __machdep_stack_alloc(size_t size)
-+{
-+ void * stack;
-+
-+ return(malloc(size));
-+}
-+
-+/* ==========================================================================
-+ * __machdep_pthread_create()
-+ */
-+void __machdep_pthread_create(struct machdep_pthread *machdep_pthread,
-+ void *(* start_routine)(), void *start_argument,
-+ long stack_size, long nsec, long flags)
-+{
-+ machdep_pthread->start_routine = start_routine;
-+ machdep_pthread->start_argument = start_argument;
-+
-+ machdep_pthread->machdep_timer.it_value.tv_sec = 0;
-+ machdep_pthread->machdep_timer.it_interval.tv_sec = 0;
-+ machdep_pthread->machdep_timer.it_interval.tv_usec = 0;
-+ machdep_pthread->machdep_timer.it_value.tv_usec = nsec / 1000;
-+
-+ /* Set up new stack frame so that it looks like it returned from a
-+ longjmp() to the beginning of machdep_pthread_start(). */
-+ machdep_pthread->machdep_istate[8/*ISTATE_RA*/] = 0;
-+ machdep_pthread->machdep_istate[0/*ISTATE_PC*/] = (long)machdep_pthread_start;
-+ machdep_pthread->machdep_istate[10/*ISTATE_PV*/] = (long)machdep_pthread_start;
-+
-+ /* Alpha stack starts high and builds down. */
-+ {
-+ long stk_addr = (long) machdep_pthread->machdep_stack;
-+ stk_addr += stack_size - 1024;
-+ stk_addr &= ~15;
-+ machdep_pthread->machdep_istate[9/*ISTATE_SP*/] = stk_addr;
-+ }
-+}
-+
-+int safe_store (loc, new)
-+ int *loc;
-+ int new;
-+{
-+ int locked, old;
-+ asm ("mb" : : : "memory");
-+ do {
-+ asm ("ldl_l %0,%1" : "=r" (old) : "m" (*loc));
-+ asm ("stl_c %0,%1" : "=r" (locked), "=m" (*loc) : "0" (new));
-+ } while (!locked);
-+ asm ("mb" : : : "memory");
-+ return old;
-+}
-+
-+/* ==========================================================================
-+ * machdep_sys_creat()
-+ */
-+machdep_sys_creat(char * path, int mode)
-+{
-+ return(machdep_sys_open(path, O_WRONLY | O_CREAT | O_TRUNC, mode));
-+}
-+
-+/* ==========================================================================
-+ * machdep_sys_wait3()
-+ */
-+machdep_sys_wait3(int * b, int c, int * d)
-+{
-+ return(machdep_sys_wait4(0, b, c, d));
-+}
-+
-+/* ==========================================================================
-+ * machdep_sys_waitpid()
-+ */
-+machdep_sys_waitpid(int a, int * b, int c)
-+{
-+ return(machdep_sys_wait4(a, b, c, NULL));
-+}
-+
-+/* ==========================================================================
-+ * machdep_sys_getdtablesize()
-+ */
-+machdep_sys_getdtablesize()
-+{
-+ return(sysconf(_SC_OPEN_MAX));
-+}
-+
-+/* ==========================================================================
-+ * machdep_sys_lseek()
-+ */
-+off_t machdep_sys_lseek(int fd, off_t offset, int whence)
-+{
-+ extern off_t __syscall();
-+
-+ return(__syscall((quad_t)SYS_lseek, fd, 0, offset, whence));
-+}
-+
-+/* ==========================================================================
-+ * machdep_sys_getdirentries()
-+ */
-+machdep_sys_getdirentries(int fd, char * buf, int len, int * seek)
-+{
-+ return(machdep_sys_getdents(fd, buf, len));
-+}
++#ifndef __CONCAT
++#include <sys/cdefs.h>
++#endif
++#define CONCAT __CONCAT
++
++#undef SYSCALL
++
++/* Kernel syscall interface:
++ Input:
++ v0 - system call number
++ a* - arguments, as in C
++ Output:
++ a3 - zero iff successful
++ v0 - errno value on failure, else result
++
++ This macro is similar to SYSCALL in asm.h, but not completely.
++ There's room for optimization, if we assume this will continue to
++ be assembled as one file.
++
++ This macro expansions does not include the return instruction.
++ If there's no other work to be done, use something like:
++ SYSCALL(foo) ; ret
++ If there is other work to do (in fork, maybe?), do it after the
++ SYSCALL invocation. */
++
++#define SYSCALL(x) \
++ .align 4 ;\
++ .globl CONCAT(machdep_sys_,x) ;\
++ .ent CONCAT(machdep_sys_,x), 0 ;\
++CONCAT(machdep_sys_,x): ;\
++ .frame sp,0,ra ;\
++ ldiq v0, CONCAT(SYS_,x) ;\
++ CHMK() ;\
++ beq a3, CONCAT(Lsys_noerr_,x) ;\
++ br gp, CONCAT(Lsys_err_,x) ;\
++CONCAT(Lsys_err_,x): ;\
++ /* Load gp so we can find cerror to jump to. */;\
++ ldgp gp, 0(gp) ;\
++ jmp zero, machdep_cerror ;\
++CONCAT(Lsys_noerr_,x):
++
++#define XSYSCALL(x) SYSCALL(x) ; RET ; .end CONCAT(machdep_sys_,x)
++
++ .globl machdep_cerror
++machdep_cerror:
++ br t0, Lmachdep_cerror_setgp
++Lmachdep_cerror_setgp:
++ ldgp gp, 0(t0)
++ stl v0, errno
++#if 0
++ ldiq v0, -1
++#else
++ subq zero, v0, v0
++#endif
++ RET
++
++/* The fork system call is special... */
++SYSCALL(fork)
++ cmovne a4, 0, v0
++ RET
++ .end machdep_sys_fork
++
++/* The pipe system call is special... */
++SYSCALL(pipe)
++ stl v0, 0(a0)
++ stl a4, 4(a0)
++ mov zero, v0
++ RET
++ .end machdep_sys_pipe
++
++#ifndef SYS___sigsuspend14
++/* The sigsuspend system call is special... */
++ .align 4
++ .globl machdep_sys_sigsuspend
++ .ent machdep_sys_sigsuspend, 0
++machdep_sys_sigsuspend:
++ ldl a0, 0(a0) /* pass *mask instead of mask */
++ ldiq v0, SYS_sigsuspend
++ CHMK()
++ mov zero, v0 /* shouldn't need; just in case... */
++ RET
++ .end machdep_sys_sigsuspend
++#endif /* SYS_sigsuspend14 */
++
++#ifndef SYS___sigprocmask14
++/* The sigprocmask system call is special... */
++ .align 4
++ .globl machdep_sys_sigprocmask
++ .ent machdep_sys_sigprocmask, 0
++machdep_sys_sigprocmask:
++ mov a2, a5 /* safe */
++ cmoveq a1, 1, a0 /* if set == NULL, how = SIG_BLOCK */
++ beq a1, Ldoit /* and set = 0, and do it. */
++ ldl a1, 0(a1) /* load the set from *set */
++Ldoit: ldiq v0, SYS_sigprocmask
++ CHMK()
++ beq a5, Lret /* if they don't want old mask, done */
++ stl v0, 0(a5) /* otherwise, give it to them. */
++Lret: mov zero, v0
++ RET
++ .end machdep_sys_sigprocmask
++#endif /* SYS_sigprocmask14 */
++
++/* More stuff ... */
++ .align 4
++ .global __machdep_save_int_state
++ .ent __machdep_save_int_state, 0
++__machdep_save_int_state:
++ .frame sp, 16, ra
++ ldgp gp, 0(t12)
++ lda sp, -16(sp)
++ stq ra, 0(sp)
++
++ /* save integer registers */
++ stq ra, ( 0 * 8)(a0) /* return address */
++ stq s0, ( 1 * 8)(a0) /* callee-saved registers */
++ stq s1, ( 2 * 8)(a0)
++ stq s2, ( 3 * 8)(a0)
++ stq s3, ( 4 * 8)(a0)
++ stq s4, ( 5 * 8)(a0)
++ stq s5, ( 6 * 8)(a0)
++ stq s6, ( 7 * 8)(a0)
++ stq sp, ( 9 * 8)(a0)
++ stq ra, ( 8 * 8)(a0) /* RA on return */
++ stq pv, (10 * 8)(a0) /* and PV; we restore it */
++
++ mov zero, v0
++ lda sp, 16(sp)
++ RET
++ .end __machdep_save_int_state
++
++ .align 4
++ .global __machdep_restore_int_state
++ .ent __machdep_restore_int_state, 0
++__machdep_restore_int_state:
++ .frame sp, 16, ra
++ ldgp gp, 0(t12)
++ lda sp, -16(sp)
++ stq ra, 0(sp)
++
++ /* restore integer registers */
++ ldq t0, ( 0 * 8)(a0) /* return address */
++ ldq s0, ( 1 * 8)(a0) /* callee-saved registers */
++ ldq s1, ( 2 * 8)(a0)
++ ldq s2, ( 3 * 8)(a0)
++ ldq s3, ( 4 * 8)(a0)
++ ldq s4, ( 5 * 8)(a0)
++ ldq s5, ( 6 * 8)(a0)
++ ldq s6, ( 7 * 8)(a0)
++ ldq ra, ( 8 * 8)(a0) /* RA after return */
++ ldq sp, ( 9 * 8)(a0)
++ ldq pv, (10 * 8)(a0) /* and PV; we restore it */
++
++ ldiq v0, 1
++ ret zero,(t0),1
++ .end __machdep_restore_int_state
++
++ .align 4
++ .global __machdep_save_fp_state
++ .ent __machdep_save_fp_state, 0
++__machdep_save_fp_state:
++ .frame sp, 16, ra
++ ldgp gp, 0(t12)
++ lda sp, -16(sp)
++ stq ra, 0(sp)
++
++ /* save FP registers */
++ stt fs0, (0 * 8)(a0) /* callee-saved registers */
++ stt fs1, (1 * 8)(a0)
++ stt fs2, (2 * 8)(a0)
++ stt fs3, (3 * 8)(a0)
++ stt fs4, (4 * 8)(a0)
++ stt fs5, (5 * 8)(a0)
++ stt fs6, (6 * 8)(a0)
++ stt fs7, (7 * 8)(a0)
++ mf_fpcr ft0 /* and FP control reg */
++ stt ft0, (8 * 8)(a0)
++
++ lda sp, 16(sp)
++ RET
++ .end __machdep_save_fp_state
++
++ .align 4
++ .global __machdep_restore_fp_state
++ .ent __machdep_restore_fp_state, 0
++__machdep_restore_fp_state:
++ .frame sp, 16, ra
++ ldgp gp, 0(t12)
++ lda sp, -16(sp)
++ stq ra, 0(sp)
++
++ /* restore FP registers */
++ ldt fs0, (0 * 8)(a0) /* callee-saved registers */
++ ldt fs1, (1 * 8)(a0)
++ ldt fs2, (2 * 8)(a0)
++ ldt fs3, (3 * 8)(a0)
++ ldt fs4, (4 * 8)(a0)
++ ldt fs5, (5 * 8)(a0)
++ ldt fs6, (6 * 8)(a0)
++ ldt fs7, (7 * 8)(a0)
++ ldt ft0, (8 * 8)(a0)
++ mt_fpcr ft0 /* and FP control reg */
++
++ lda sp, 16(sp)
++ RET
++ .end __machdep_restore_fp_state
++
++/* For fstat() we actually syscall fstat13. */
++ .align 4
++ .globl machdep_sys_fstat
++ .ent machdep_sys_fstat, 0
++machdep_sys_fstat:
++ .frame sp,0,ra
++ ldiq v0, SYS___fstat13
++ CHMK()
++ beq a3, Lsys_noerr_fstat
++ br gp, Lsys_err_fstat
++Lsys_err_fstat:
++ /* Load gp so we can find cerror to jump to. */
++ ldgp gp, 0(gp)
++ jmp zero, machdep_cerror
++Lsys_noerr_fstat:
++ RET
++ .end machdep_sys_fstat
diff --git a/devel/mit-pthreads/patches/patch-ag b/devel/mit-pthreads/patches/patch-ag
index de8966754f8..da52e589e5b 100644
--- a/devel/mit-pthreads/patches/patch-ag
+++ b/devel/mit-pthreads/patches/patch-ag
@@ -1,115 +1,58 @@
-$NetBSD: patch-ag,v 1.1 1998/08/23 06:22:17 garbled Exp $
---- /dev/null Sat Jul 18 04:39:35 1998
-+++ machdep/engine-alpha-netbsd-1.3.h Sat Jul 18 04:41:03 1998
-@@ -0,0 +1,111 @@
-+/* ==== machdep.h ============================================================
-+ * Copyright (c) 1994 Chris Provenzano (proven@athena.mit.edu) and
-+ * Ken Raeburn (raeburn@mit.edu).
-+ *
-+ * engine-alpha-osf1.h,v 1.4.4.1 1995/12/13 05:41:42 proven Exp
-+ *
-+ */
-+
-+#include <unistd.h>
-+#include <setjmp.h>
-+#include <sys/time.h>
-+#include <sys/cdefs.h>
-+
-+/* The first machine dependent functions are the SEMAPHORES needing
-+ the test and set instruction.
-+
-+ On the Alpha, the actual values here are irrelevant; they just have
-+ to be different. */
-+#define SEMAPHORE_CLEAR 0
-+#define SEMAPHORE_SET 1
-+
-+#if 0
-+#define SEMAPHORE_TEST_AND_SET(lock) \
-+({ int *_sem_lock = (lock), locked, old; \
-+ asm ("mb" : : : "memory"); \
-+ do { asm ("ldl_l %0,%1" : "=r" (old) : "m" (*_sem_lock)); \
-+ /* ?? if (old != SEMAPHORE_CLEAR) break; */ \
-+ asm ("stl_c %0,%1" : "=r" (locked), "=m" (*_sem_lock) \
-+ : "0" (SEMAPHORE_SET)); \
-+ } while (!locked); \
-+ asm ("mb" : : : "memory"); \
-+ old == SEMAPHORE_CLEAR; })
-+
-+#define SEMAPHORE_RESET(lock) \
-+({ int *_sem_lock = (lock); \
-+ *_sem_lock = SEMAPHORE_CLEAR; \
-+ asm ("mb" : : : "memory"); })
+$NetBSD: patch-ag,v 1.2 1998/12/28 22:22:00 bad Exp $
+
+--- /dev/null Sun Dec 27 17:07:36 1998
++++ machdep/syscall-template-alpha-netbsd-1.3.S Sun Dec 27 17:21:40 1998
+@@ -0,0 +1,53 @@
++#include <machine/asm.h>
++#define COMPAT_43
++#include <sys/syscall.h>
++#define CHMK() call_pal 0x83
++
++#ifdef SYS___sigsuspend14
++#define SYS_sigsuspend SYS___sigsuspend14
+#endif
-+
-+/*
-+ * New types
-+ */
-+typedef int semaphore;
-+
-+/*
-+ * sigset_t macros
-+ */
-+#define SIG_ANY(sig) (sig)
-+#define SIGMAX 31
-+
-+/*
-+ * New Strutures
-+ */
-+struct machdep_pthread {
-+ void *(*start_routine)(void *);
-+ void *start_argument;
-+ void *machdep_stack;
-+ struct itimerval machdep_timer;
-+ unsigned long machdep_istate[11];
-+ unsigned long machdep_fstate[9];
-+};
-+
-+/*
-+ * Static machdep_pthread initialization values.
-+ * For initial thread only.
-+ */
-+#define MACHDEP_PTHREAD_INIT \
-+ { NULL, NULL, NULL, { { 0, 0 }, { 0, 100000 } }, 0 }
-+
-+/*
-+ * Minimum stack size
-+ */
-+#define PTHREAD_STACK_MIN 2048
-+
-+/*
-+ * Some fd flag defines that are necessary to distinguish between posix
-+ * behavior and bsd4.3 behavior.
-+ */
-+#define __FD_NONBLOCK O_NONBLOCK
-+
-+/*
-+ * New functions
-+ */
-+
-+__BEGIN_DECLS
-+
-+#if defined(PTHREAD_KERNEL)
-+
-+#define __machdep_stack_get(x) (x)->machdep_stack
-+#define __machdep_stack_set(x, y) (x)->machdep_stack = y
-+#define __machdep_stack_repl(x, y) \
-+{ \
-+ if (stack = __machdep_stack_get(x)) { \
-+ __machdep_stack_free(stack); \
-+ } \
-+ __machdep_stack_set(x, y); \
-+}
-+
-+void * __machdep_stack_alloc __P_((size_t));
-+void __machdep_stack_free __P_((void *));
-+
-+int machdep_save_state __P_((void));
-+
-+int __machdep_save_int_state __P_((unsigned long *));
-+void __machdep_restore_int_state __P_((unsigned long *));
-+void __machdep_save_fp_state __P_((unsigned long *));
-+void __machdep_restore_fp_state __P_((unsigned long *));
-+
++#ifdef SYS___sigprocmask14
++#define SYS_sigprocmask SYS___sigprocmask14
+#endif
+
-+__END_DECLS
++#undef SYSCALL
++
++/* Kernel syscall interface:
++ Input:
++ v0 - system call number
++ a* - arguments, as in C
++ Output:
++ a3 - zero iff successful
++ v0 - errno value on failure, else result
++
++ This macro is similar to SYSCALL in asm.h, but not completely.
++ There's room for optimization, if we assume this will continue to
++ be assembled as one file.
++
++ This macro expansions does not include the return instruction.
++ If there's no other work to be done, use something like:
++ SYSCALL(foo) ; ret
++ If there is other work to do (in fork, maybe?), do it after the
++ SYSCALL invocation. */
++
++#define SYSCALL(x) \
++ .align 4 ;\
++ .globl machdep_sys_##x ;\
++ .ent machdep_sys_##x, 0 ;\
++machdep_sys_##x: ;\
++ .frame sp,0,ra ;\
++ ldiq v0, SYS_##x ;\
++ CHMK() ;\
++ beq a3, Lsys_noerr_##x ;\
++ br gp, Lsys_err_##x ;\
++Lsys_err_##x: ;\
++ /* Load gp so we can find cerror to jump to. */;\
++ ldgp gp, 0(gp) ;\
++ jmp zero, machdep_cerror ;\
++Lsys_noerr_##x:
++
++#define SIMPLE_SYSCALL(x) SYSCALL(x) ; ret ; .end machdep_sys_##x
++
++#define XSYSCALL(x) SIMPLE_SYSCALL(x)
++
++XSYSCALL(SYSCALL_NAME)
diff --git a/devel/mit-pthreads/patches/patch-aj b/devel/mit-pthreads/patches/patch-aj
index 2428a397a54..49771cd5a5a 100644
--- a/devel/mit-pthreads/patches/patch-aj
+++ b/devel/mit-pthreads/patches/patch-aj
@@ -1,21 +1,76 @@
-$NetBSD: patch-aj,v 1.1 1998/08/23 06:22:18 garbled Exp $
---- config/configure.orig Wed Nov 13 14:03:02 1996
-+++ config/configure Sat Jul 18 04:51:25 1998
-@@ -1056,2 +1056,7 @@
- ;;
-+ alpha-*-netbsd1.3*)
+$NetBSD: patch-aj,v 1.2 1998/12/28 22:22:00 bad Exp $
+
+--- config/configure.orig Wed Nov 13 22:03:02 1996
++++ config/configure Sun Dec 27 17:37:18 1998
+@@ -1049,6 +1049,17 @@
+ name=$host_cpu-$host_os
+
+ case $host in
++ alpha-*-netbsd1.3[H-Z])
++ name=alpha-netbsd-1.3
++ sysincludes=netbsd-1.1
++ except="fork lseek pipe fstat"
++ available_syscalls="sigsuspend sigprocmask"
++ ;;
++ alpha-*-netbsd1.3*)
+ name=alpha-netbsd-1.3
+ sysincludes=netbsd-1.1
+ except="fork lseek pipe sigsuspend sigprocmask fstat"
+ ;;
- alpha-*-osf*)
-@@ -1094,3 +1099,3 @@
+ alpha-*-netbsd1.1* | alpha-*-netbsd1.2*)
+ name=alpha-netbsd-1.1
+ sysincludes=netbsd-1.1
+@@ -1062,6 +1073,17 @@
+ CFLAGS="$CFLAGS -std"
+ fi
+ ;;
++ arm32-*-netbsd1.3[H-Z])
++ name=arm32-netbsd-1.3
++ sysincludes=netbsd-1.1
++ except="fork pipe lseek ftruncate fstat"
++ available_syscalls="sigsuspend sigprocmask"
++ ;;
++ arm32-*-netbsd1.3*)
++ name=arm32-netbsd-1.3
++ sysincludes=netbsd-1.1
++ except="fork pipe lseek ftruncate sigsuspend sigprocmask fstat"
++ ;;
+ hppa1.1-*-hpux*)
+ name=hppa-hpux-9.03
+ sysincludes=hpux-9.03
+@@ -1092,6 +1114,17 @@
+ EOF
+
;;
-- sparc-*-netbsd1.0A | sparc-*-netbsd1.1* | sparc-*-netbsd1.2*)
-+ sparc-*-netbsd1.0A | sparc-*-netbsd1.1* | sparc-*-netbsd1.2* | sparc-*-netbsd1.3*)
++ sparc-*-netbsd1.3[H-Z])
++ name=sparc-netbsd-1.3
++ sysincludes=netbsd-1.1
++ except="pipe fork lseek ftruncate fstat"
++ available_syscalls="sigprocmask sigsuspend"
++ ;;
++ sparc-*-netbsd1.3*)
++ name=sparc-netbsd-1.3
++ sysincludes=netbsd-1.1
++ except="pipe fork lseek ftruncate sigprocmask sigsuspend fstat"
++ ;;
+ sparc-*-netbsd1.0A | sparc-*-netbsd1.1* | sparc-*-netbsd1.2*)
name=sparc-sunos-4.1.3
-@@ -1114,3 +1119,3 @@
+ sysincludes=netbsd-1.0
+@@ -1111,6 +1144,17 @@
+ sysincludes=bsdi-2.0
+ syscall=i386-bsdi-2.0
+ except="fork lseek sigsuspend"
++ ;;
++ i386-*-netbsd1.3[H-Z])
++ name=i386-netbsd-1.3
++ sysincludes=netbsd-1.1
++ except="fork lseek ftruncate pipe fstat"
++ available_syscalls="sigsuspend sigprocmask"
++ ;;
++ i386-*-netbsd1.3*)
++ name=i386-netbsd-1.3
++ sysincludes=netbsd-1.1
++ except="fork lseek ftruncate pipe sigsuspend sigprocmask fstat"
;;
-- i386-*-netbsd1.1* | i386-*-netbsd1.2*)
-+ i386-*-netbsd1.1* | i386-*-netbsd1.2* | i386-*-netbsd1.3*)
+ i386-*-netbsd1.1* | i386-*-netbsd1.2*)
name=i386-netbsd-1.0
diff --git a/devel/mit-pthreads/patches/patch-ak b/devel/mit-pthreads/patches/patch-ak
index ec57bba4fe2..066ed45a9e6 100644
--- a/devel/mit-pthreads/patches/patch-ak
+++ b/devel/mit-pthreads/patches/patch-ak
@@ -1,21 +1,76 @@
-$NetBSD: patch-ak,v 1.1 1998/08/23 06:22:18 garbled Exp $
---- config/configure.in.orig Wed Nov 13 14:03:08 1996
-+++ config/configure.in Sat Jul 18 04:48:33 1998
-@@ -131,2 +131,7 @@
- ;;
-+ alpha-*-netbsd1.3*)
+$NetBSD: patch-ak,v 1.2 1998/12/28 22:22:00 bad Exp $
+
+--- config/configure.in.orig Wed Nov 13 22:03:08 1996
++++ config/configure.in Mon Dec 28 22:16:39 1998
+@@ -124,6 +124,17 @@
+ name=$host_cpu-$host_os
+
+ case $host in
++ alpha-*-netbsd1.3[H-Z])
++ name=alpha-netbsd-1.3
++ sysincludes=netbsd-1.1
++ except="fork lseek pipe fstat"
++ available_syscalls="sigsuspend sigprocmask"
++ ;;
++ alpha-*-netbsd1.3*)
+ name=alpha-netbsd-1.3
+ sysincludes=netbsd-1.1
+ except="fork lseek pipe sigsuspend sigprocmask fstat"
+ ;;
- alpha-*-osf*)
-@@ -160,3 +165,3 @@
+ alpha-*-netbsd1.1* | alpha-*-netbsd1.2*)
+ name=alpha-netbsd-1.1
+ sysincludes=netbsd-1.1
+@@ -137,6 +148,17 @@
+ CFLAGS="$CFLAGS -std"
+ fi
+ ;;
++ arm32-*-netbsd1.3[H-Z])
++ name=arm32-netbsd-1.3
++ sysincludes=netbsd-1.1
++ except="fork pipe lseek ftruncate fstat"
++ available_syscalls="sigsuspend sigprocmask"
++ ;;
++ arm32-*-netbsd1.3*)
++ name=arm32-netbsd-1.3
++ sysincludes=netbsd-1.1
++ except="fork pipe lseek ftruncate sigsuspend sigprocmask fstat"
++ ;;
+ hppa1.1-*-hpux*)
+ name=hppa-hpux-9.03
+ sysincludes=hpux-9.03
+@@ -158,6 +180,17 @@
+ AC_DEFINE(LD_LINKS_STATIC_DATA)
+ AC_DEFINE(BROKEN_SIGNALS)
;;
-- sparc-*-netbsd1.0A | sparc-*-netbsd1.1* | sparc-*-netbsd1.2*)
-+ sparc-*-netbsd1.0A | sparc-*-netbsd1.1* | sparc-*-netbsd1.2* | sparc-*-netbsd1.3*)
++ sparc-*-netbsd1.3[H-Z])
++ name=sparc-netbsd-1.3
++ sysincludes=netbsd-1.1
++ except="pipe fork lseek ftruncate fstat"
++ available_syscalls="sigprocmask sigsuspend"
++ ;;
++ sparc-*-netbsd1.3*)
++ name=sparc-netbsd-1.3
++ sysincludes=netbsd-1.1
++ except="pipe fork lseek ftruncate sigprocmask sigsuspend fstat"
++ ;;
+ sparc-*-netbsd1.0A | sparc-*-netbsd1.1* | sparc-*-netbsd1.2*)
name=sparc-sunos-4.1.3
-@@ -180,3 +185,3 @@
+ sysincludes=netbsd-1.0
+@@ -177,6 +210,17 @@
+ sysincludes=bsdi-2.0
+ syscall=i386-bsdi-2.0
+ except="fork lseek sigsuspend"
++ ;;
++ i386-*-netbsd1.3[H-Z])
++ name=i386-netbsd-1.3
++ sysincludes=netbsd-1.1
++ except="fork lseek ftruncate pipe fstat"
++ available_syscalls="sigsuspend sigprocmask"
++ ;;
++ i386-*-netbsd1.3*)
++ name=i386-netbsd-1.3
++ sysincludes=netbsd-1.1
++ except="fork lseek ftruncate pipe sigsuspend sigprocmask fstat"
;;
-- i386-*-netbsd1.1* | i386-*-netbsd1.2*)
-+ i386-*-netbsd1.1* | i386-*-netbsd1.2* | i386-*-netbsd1.3*)
+ i386-*-netbsd1.1* | i386-*-netbsd1.2*)
name=i386-netbsd-1.0
diff --git a/devel/mit-pthreads/patches/patch-an b/devel/mit-pthreads/patches/patch-an
new file mode 100644
index 00000000000..a3978277a23
--- /dev/null
+++ b/devel/mit-pthreads/patches/patch-an
@@ -0,0 +1,22 @@
+$NetBSD: patch-an,v 1.1 1998/12/28 22:22:00 bad Exp $
+
+--- config/config.sub.orig Fri Jan 23 23:07:31 1998
++++ config/config.sub Sun Oct 25 18:54:55 1998
+@@ -119,7 +119,7 @@
+ case $basic_machine in
+ # Recognize the basic CPU types without company name.
+ # Some are omitted here because they have special meanings below.
+- tahoe | i[3456]86 | i860 | m68k | m68000 | m88k | ns32k | arm | pyramid \
++ tahoe | i[3456]86 | i860 | m68k | m68000 | m88k | ns32k | arm | arm32 | pyramid \
+ | tron | a29k | 580 | i960 | h8300 | hppa1.0 | hppa1.1 \
+ | alpha | we32k | ns16k | clipper | sparclite | i370 | sh \
+ | powerpc | sparc64 | 1750a | dsp16xx | mips64 | mipsel \
+@@ -133,7 +133,7 @@
+ ;;
+ # Recognize the basic CPU types with company name.
+ vax-* | tahoe-* | i[3456]86-* | i860-* | m68k-* | m68000-* | m88k-* \
+- | sparc-* | ns32k-* | fx80-* | arm-* | c[123]* \
++ | sparc-* | ns32k-* | fx80-* | arm-* | arm32-* | c[123]* \
+ | mips-* | pyramid-* | tron-* | a29k-* | romp-* | rs6000-* \
+ | none-* | 580-* | cray2-* | h8300-* | i960-* | xmp-* | ymp-* \
+ | hppa1.0-* | hppa1.1-* | alpha-* | we32k-* | cydra-* | ns16k-* \
diff --git a/devel/mit-pthreads/patches/patch-ao b/devel/mit-pthreads/patches/patch-ao
new file mode 100644
index 00000000000..0ac53bedfc9
--- /dev/null
+++ b/devel/mit-pthreads/patches/patch-ao
@@ -0,0 +1,13 @@
+$NetBSD: patch-ao,v 1.1 1998/12/28 22:22:00 bad Exp $
+
+--- include/endian.h.orig Tue May 30 16:30:57 1995
++++ include/endian.h Sun Dec 27 18:30:25 1998
+@@ -66,7 +66,7 @@
+
+ #if defined(vax) || defined(ns32000) || defined(sun386) || defined(i386) || \
+ defined(MIPSEL) || defined(_MIPSEL) || defined(BIT_ZERO_ON_RIGHT) || \
+- defined(__alpha__) || defined(__alpha)
++ defined(__alpha__) || defined(__alpha) || defined(__arm32__)
+ #define BYTE_ORDER LITTLE_ENDIAN
+ #define __BYTE_ORDER LITTLE_ENDIAN
+ #endif
diff --git a/devel/mit-pthreads/patches/patch-ap b/devel/mit-pthreads/patches/patch-ap
new file mode 100644
index 00000000000..b5225c533af
--- /dev/null
+++ b/devel/mit-pthreads/patches/patch-ap
@@ -0,0 +1,13 @@
+$NetBSD: patch-ap,v 1.1 1998/12/28 22:22:00 bad Exp $
+
+--- pthreads/fd.c.orig Tue Jan 13 14:28:04 1998
++++ pthreads/fd.c Sat Oct 24 22:24:28 1998
+@@ -702,7 +702,7 @@
+ */
+ off_t lseek(int fd, off_t offset, int whence)
+ {
+- int ret;
++ off_t ret;
+
+ if ((ret = fd_lock(fd, FD_RDWR, NULL)) == OK) {
+ ret = fd_table[fd]->ops->seek(fd_table[fd]->fd,
diff --git a/devel/mit-pthreads/patches/patch-aq b/devel/mit-pthreads/patches/patch-aq
new file mode 100644
index 00000000000..138a8176499
--- /dev/null
+++ b/devel/mit-pthreads/patches/patch-aq
@@ -0,0 +1,12 @@
+$NetBSD: patch-aq,v 1.1 1998/12/28 22:22:01 bad Exp $
+
+--- pthreads/fd_kern.c.orig Tue Oct 1 20:26:48 1996
++++ pthreads/fd_kern.c Sun Dec 27 17:41:24 1998
+@@ -582,6 +582,7 @@
+ off_t __fd_kern_lseek(union fd_data fd_data, int f, off_t offset, int whence)
+ {
+ int fd = fd_data.i;
++ extern off_t machdep_sys_lseek(int, off_t, int);
+
+ return(machdep_sys_lseek(fd, offset, whence));
+ }
diff --git a/devel/mit-pthreads/patches/patch-ar b/devel/mit-pthreads/patches/patch-ar
new file mode 100644
index 00000000000..7379ee0e35b
--- /dev/null
+++ b/devel/mit-pthreads/patches/patch-ar
@@ -0,0 +1,25 @@
+$NetBSD: patch-ar,v 1.1 1998/12/28 22:22:01 bad Exp $
+
+--- machdep/netbsd-1.1/__signal.h.orig Tue Apr 23 08:11:39 1996
++++ machdep/netbsd-1.1/__signal.h Sat Oct 17 21:41:52 1998
+@@ -1,8 +1,20 @@
+ #include <sys/signal.h>
+
++#if NSIG <= 32
+ #define __SIGEMPTYSET 0
+ #define __SIGFILLSET 0xffffffff
+ #define __SIGADDSET(s, n) (*(s) |= 1 << ((n) - 1), 0)
+ #define __SIGDELSET(s, n) (*(s) &= ~(1 << ((n) - 1)), 0)
+ #define __SIGISMEMBER(s, n) ((*(s) & (1 << ((n) - 1))) != 0)
+
++#else /* XXX Netbsd >= 1.3H */
++#define __SIGEMPTYSET { 0, 0, 0, 0}
++#define __SIGFILLSET { 0xffffffff, 0xffffffff, \
++ 0xffffffff, 0xffffffff }
++#define __SIGMASK(n) (1 << (((n) - 1) & 31))
++#define __SIGWORD(n) (((n) - 1) >> 5)
++#define __SIGADDSET(s, n) ((s)->__bits[__SIGWORD(n)] |= __SIGMASK(n))
++#define __SIGDELSET(s, n) ((s)->__bits[__SIGWORD(n)] &= ~__SIGMASK(n))
++#define __SIGISMEMBER(s, n) (((s)->__bits[__SIGWORD(n)] & __SIGMASK(n)) != 0)
++
++#endif
diff --git a/devel/mit-pthreads/patches/patch-as b/devel/mit-pthreads/patches/patch-as
new file mode 100644
index 00000000000..5664bd31583
--- /dev/null
+++ b/devel/mit-pthreads/patches/patch-as
@@ -0,0 +1,111 @@
+$NetBSD: patch-as,v 1.1 1998/12/28 22:22:01 bad Exp $
+
+--- /dev/null Thu Oct 22 03:18:30 1998
++++ machdep/engine-sparc-netbsd-1.3.h Thu Oct 22 18:29:44 1998
+@@ -0,0 +1,106 @@
++/* ==== machdep.h ============================================================
++ * Copyright (c) 1994 Chris Provenzano, proven@athena.mit.edu
++ *
++ * engine-sparc-sunos-4.1.3.h,v 1.52.4.1 1995/12/13 05:42:33 proven Exp
++ *
++ */
++
++#include <unistd.h>
++#include <setjmp.h>
++#include <sys/time.h>
++#include <sys/cdefs.h>
++#include <sys/signal.h> /* for _NSIG */
++
++/*
++ * The first machine dependent functions are the SEMAPHORES
++ * needing the test and set instruction.
++ */
++#define SEMAPHORE_CLEAR 0
++#define SEMAPHORE_SET 0xff
++
++#define SEMAPHORE_TEST_AND_SET(lock) \
++({ \
++char *p = lock; \
++long temp; \
++ \
++__asm__ volatile("ldstub %1,%0" \
++ :"=r" (temp) \
++ :"m" (*p) \
++ :"memory"); \
++temp; \
++})
++
++#define SEMAPHORE_RESET(lock) \
++{ \
++__asm__ volatile("stb %1, %0" \
++ :"=m" (*lock) \
++ :"r" (SEMAPHORE_CLEAR) \
++ :"memory"); \
++}
++
++/*
++ * New types
++ */
++typedef char semaphore;
++
++/*
++ * sigset_t macros
++ */
++#define SIG_ANY(sig) (sig)
++#define SIGMAX (_NSIG-1)
++
++/*
++ * New Strutures
++ */
++struct machdep_pthread {
++ void *(*start_routine)(void *);
++ void *start_argument;
++ void *machdep_stack;
++ struct itimerval machdep_timer;
++ jmp_buf machdep_state;
++};
++
++/*
++ * Static machdep_pthread initialization values.
++ * For initial thread only.
++ */
++#define MACHDEP_PTHREAD_INIT \
++{ NULL, NULL, NULL, { { 0, 0 }, { 0, 100000 } }, 0 }
++
++/*
++ * Minimum stack size
++ */
++#define PTHREAD_STACK_MIN 1024
++
++/*
++ * Some fd flag defines that are necessary to distinguish between posix
++ * behavior and bsd4.3 behavior.
++ */
++#define __FD_NONBLOCK (O_NONBLOCK | O_NDELAY)
++
++/*
++ * New functions
++ */
++
++__BEGIN_DECLS
++
++#if defined(PTHREAD_KERNEL)
++
++#define __machdep_stack_get(x) (x)->machdep_stack
++#define __machdep_stack_set(x, y) (x)->machdep_stack = y
++#define __machdep_stack_repl(x, y) \
++{ \
++ if (stack = __machdep_stack_get(x)) { \
++ __machdep_stack_free(stack); \
++ } \
++ __machdep_stack_set(x, y); \
++}
++
++void * __machdep_stack_alloc __P_((size_t));
++void __machdep_stack_free __P_((void *));
++
++int machdep_save_state __P_((void));
++
++#endif
++
++__END_DECLS
diff --git a/devel/mit-pthreads/patches/patch-at b/devel/mit-pthreads/patches/patch-at
new file mode 100644
index 00000000000..1a50963143b
--- /dev/null
+++ b/devel/mit-pthreads/patches/patch-at
@@ -0,0 +1,237 @@
+$NetBSD: patch-at,v 1.1 1998/12/28 22:22:01 bad Exp $
+
+--- /dev/null Sun Oct 25 03:18:33 1998
++++ machdep/engine-sparc-netbsd-1.3.c Sun Oct 25 18:26:20 1998
+@@ -0,0 +1,232 @@
++/* ==== machdep.c ============================================================
++ * Copyright (c) 1993, 1994 Chris Provenzano, proven@athena.mit.edu
++ *
++ * Description : Machine dependent functions for SunOS-4.1.3 on sparc
++ *
++ * 1.00 93/08/04 proven
++ * -Started coding this file.
++ *
++ * 98/10/22 bad
++ * -update for fat sigset_t in NetBSD 1.3H
++ */
++
++#ifndef lint
++static const char rcsid[] = "$Id: patch-at,v 1.1 1998/12/28 22:22:01 bad Exp $";
++#endif
++
++#include "config.h"
++#include <pthread.h>
++#include <stdlib.h>
++#include <errno.h>
++
++/* ==========================================================================
++ * machdep_save_state()
++ */
++int machdep_save_state(void)
++{
++ /* Save register windows onto stackframe */
++ __asm__ ("ta 3");
++
++ return(setjmp(pthread_run->machdep_data.machdep_state));
++}
++
++/* ==========================================================================
++ * machdep_restore_state()
++ */
++void machdep_restore_state(void)
++{
++ longjmp(pthread_run->machdep_data.machdep_state, 1);
++}
++/* ==========================================================================
++ * machdep_save_float_state()
++ */
++void machdep_save_float_state(struct pthread * pthread)
++{
++ return;
++}
++
++/* ==========================================================================
++ * machdep_restore_float_state()
++ */
++void machdep_restore_float_state(void)
++{
++ return;
++}
++
++/* ==========================================================================
++ * machdep_set_thread_timer()
++ */
++void machdep_set_thread_timer(struct machdep_pthread *machdep_pthread)
++{
++ if (setitimer(ITIMER_VIRTUAL, &(machdep_pthread->machdep_timer), NULL)) {
++ PANIC();
++ }
++}
++
++/* ==========================================================================
++ * machdep_unset_thread_timer()
++ */
++void machdep_unset_thread_timer(struct machdep_pthread *machdep_pthread)
++{
++ struct itimerval zeroval = { { 0, 0 }, { 0, 0} };
++
++ if (setitimer(ITIMER_VIRTUAL, &zeroval, NULL)) {
++ PANIC();
++ }
++}
++
++/* ==========================================================================
++ * machdep_pthread_cleanup()
++ */
++void *machdep_pthread_cleanup(struct machdep_pthread *machdep_pthread)
++{
++ return(machdep_pthread->machdep_stack);
++}
++
++/* ==========================================================================
++ * machdep_pthread_start()
++ */
++void machdep_pthread_start(void)
++{
++ context_switch_done();
++ pthread_sched_resume ();
++
++ /* Run current threads start routine with argument */
++ pthread_exit(pthread_run->machdep_data.start_routine
++ (pthread_run->machdep_data.start_argument));
++
++ /* should never reach here */
++ PANIC();
++}
++
++/* ==========================================================================
++ * __machdep_stack_free()
++ */
++void __machdep_stack_free(void * stack)
++{
++ free(stack);
++}
++
++/* ==========================================================================
++ * __machdep_stack_alloc()
++ */
++void * __machdep_stack_alloc(size_t size)
++{
++ void * stack;
++
++ return(malloc(size));
++}
++
++/* ==========================================================================
++ * __machdep_pthread_create()
++ */
++void __machdep_pthread_create(struct machdep_pthread *machdep_pthread,
++ void *(* start_routine)(), void *start_argument,
++ long stack_size, long nsec, long flags)
++{
++ machdep_pthread->start_routine = start_routine;
++ machdep_pthread->start_argument = start_argument;
++
++ machdep_pthread->machdep_timer.it_value.tv_sec = 0;
++ machdep_pthread->machdep_timer.it_interval.tv_sec = 0;
++ machdep_pthread->machdep_timer.it_interval.tv_usec = 0;
++ machdep_pthread->machdep_timer.it_value.tv_usec = nsec / 1000;
++
++ /* Save register windows onto stackframe */
++ __asm__ ("ta 3");
++
++ setjmp(machdep_pthread->machdep_state);
++ /*
++ * Set up new stact frame so that it looks like it
++ * returned from a longjmp() to the beginning of
++ * machdep_pthread_start().
++ */
++ machdep_pthread->machdep_state[3] = (int)machdep_pthread_start;
++ machdep_pthread->machdep_state[4] = (int)machdep_pthread_start;
++
++ /* Sparc stack starts high and builds down. */
++ machdep_pthread->machdep_state[2] =
++ (int)machdep_pthread->machdep_stack + stack_size - 1024;
++ machdep_pthread->machdep_state[2] &= ~7;
++
++}
++
++#if defined(HAVE_SYSCALL_GETDENTS)
++/* ==========================================================================
++ * machdep_sys_getdirentries()
++ *
++ * Always use getdents in place of getdirentries if possible --proven
++ */
++int machdep_sys_getdirentries(int fd, char * buf, int len, int * seek)
++{
++ return(machdep_sys_getdents(fd, buf, len));
++}
++#endif
++
++/* ==========================================================================
++ * machdep_sys_wait3()
++ */
++machdep_sys_wait3(int * b, int c, int * d)
++{
++ return(machdep_sys_wait4(0, b, c, d));
++}
++
++/* ==========================================================================
++ * machdep_sys_waitpid()
++ */
++machdep_sys_waitpid(int pid, int * statusp, int options)
++{
++ if (pid == -1)
++ pid = 0;
++ else if (pid == 0)
++ pid = - getpgrp ();
++ return machdep_sys_wait4 (pid, statusp, options, NULL);
++}
++
++#if !defined(HAVE_SYSCALL_SIGPROCMASK)
++#if 0
++/* ==========================================================================
++ * machdep_sys_sigprocmask()
++ * This isn't a real implementation; we can make the assumption that the
++ * pthreads library is not using oset, and that it is always blocking or
++ * unblocking all signals at once.
++ */
++int machdep_sys_sigprocmask(int how, const sigset_t *set, sigset_t *oset)
++{
++ switch(how) {
++ case SIG_BLOCK:
++ sigblock(*set);
++ break;
++ case SIG_UNBLOCK:
++ sigsetmask(~*set);
++ break;
++ case SIG_SETMASK:
++ sigsetmask(*set);
++ break;
++ default:
++ return -EINVAL;
++ }
++ return(OK);
++}
++
++/* ==========================================================================
++ * sigaction()
++ *
++ * Temporary until I do machdep_sys_sigaction()
++ */
++int sigaction(int sig, const struct sigaction *act, struct sigaction *oldact)
++{
++ return(sigvec(sig, (struct sigvec *)act, (struct sigvec *)oldact));
++}
++#endif
++#endif
++
++#if !defined(HAVE_SYSCALL_GETDTABLESIZE)
++/* ==========================================================================
++ * machdep_sys_getdtablesize()
++ */
++machdep_sys_getdtablesize()
++{
++ return(sysconf(_SC_OPEN_MAX));
++}
++#endif
diff --git a/devel/mit-pthreads/patches/patch-au b/devel/mit-pthreads/patches/patch-au
new file mode 100644
index 00000000000..5394a41eb5e
--- /dev/null
+++ b/devel/mit-pthreads/patches/patch-au
@@ -0,0 +1,176 @@
+$NetBSD: patch-au,v 1.1 1998/12/28 22:22:02 bad Exp $
+
+--- /dev/null Sun Oct 25 03:17:31 1998
++++ machdep/syscall-sparc-netbsd-1.3.S Sat Oct 24 21:39:15 1998
+@@ -0,0 +1,171 @@
++/* ==== syscall.S ============================================================
++ * Copyright (c) 1994 Chris Provenzano, proven@mit.edu
++ * All rights reserved.
++ *
++ */
++
++#ifndef lint
++ .text
++ .asciz "$Id: patch-au,v 1.1 1998/12/28 22:22:02 bad Exp $";
++#endif
++
++#include <sys/syscall.h>
++
++#define SYSCALL(x) \
++ .globl _machdep_sys_##x; \
++ \
++_machdep_sys_##x:; \
++ \
++ mov SYS_##x, %g1; \
++ ta 0; \
++ bcs,a 2b; \
++ sub %r0,%o0,%o0; \
++ retl
++
++
++/*
++ * Initial asm stuff for all functions.
++ */
++ .text
++ .align 4
++
++/* ==========================================================================
++ * error code for all syscalls. The error value is returned as the negative
++ * of the errno value.
++ */
++
++1:
++ sub %r0, %o0, %o0
++2:
++ retl
++ nop
++
++/* ==========================================================================
++ * machdep_sys_pipe()
++ */
++ .globl _machdep_sys_pipe
++
++_machdep_sys_pipe:
++ mov %o0, %o2
++ mov SYS_pipe, %g1
++ ta 0
++ bcs 1b
++ nop
++ st %o0, [ %o2 ]
++ st %o1, [ %o2 + 4 ]
++ retl
++ mov %g0, %o0
++
++/* ==========================================================================
++ * machdep_sys_fork()
++ */
++ .globl _machdep_sys_fork;
++
++_machdep_sys_fork:;
++
++ mov SYS_fork, %g1;
++ ta 0;
++ bcs 1b;
++ nop;
++ dec %o1;
++ retl;
++ and %o0, %o1, %o0; ! return 0 in child, pid in parent
++
++#ifndef SYS___sigprocmask14
++/* ==========================================================================
++ * machdep_sys_sigprocmask()
++ */
++ .globl _machdep_sys_sigprocmask;
++
++_machdep_sys_sigprocmask:;
++
++ ld [%o1], %o1;
++ mov SYS_sigprocmask, %g1;
++ ta 0;
++ bcs 1b;
++ nop;
++ retl
++ nop
++#endif
++
++#ifndef SYS___sigsuspend14
++/* ==========================================================================
++ * machdep_sys_sigsuspend()
++ */
++ .globl _machdep_sys_sigsuspend;
++
++_machdep_sys_sigsuspend:;
++
++ ld [%o0], %o0;
++ mov SYS_sigsuspend, %g1;
++ ta 0;
++ bcs 1b;
++ nop;
++ retl
++ nop
++#endif
++
++/* ==========================================================================
++ * machdep_sys_fstat()
++ */
++ .globl _machdep_sys_fstat;
++
++_machdep_sys_fstat:;
++
++ mov SYS___fstat13, %g1;
++ ta 0;
++ bcs 1b;
++ nop;
++ retl
++ nop
++
++/* ==========================================================================
++ * machdep_sys___syscall()
++ */
++_machdep_sys___syscall:;
++
++ mov SYS___syscall, %g1;
++ ta 0;
++ bcs 1b;
++ nop;
++ retl
++ nop
++
++/* ==========================================================================
++ * machdep_sys_lseek()
++ */
++ .global _machdep_sys_lseek
++
++_machdep_sys_lseek:
++ save %sp,-112,%sp
++ mov %i1,%o4
++ mov %i2,%o5
++ st %i3,[%sp+92]
++ mov 0,%o0
++ mov SYS_lseek,%o1
++ mov %i0,%o2
++ call _machdep_sys___syscall,0
++ mov 0,%o3
++ mov %o0,%i0
++ mov %o1,%i1
++ ret
++ restore
++
++/* ==========================================================================
++ * machdep_sys_ftruncate()
++ */
++ .global _machdep_sys_ftruncate
++
++_machdep_sys_ftruncate:
++ save %sp,-104,%sp
++ mov %i1,%o4
++ mov %i2,%o5
++ mov 0,%o0
++ mov SYS_ftruncate,%o1
++ mov %i0,%o2
++ call _machdep_sys___syscall,0
++ mov 0,%o3
++ mov %o0,%o1
++ sra %o0,31,%o0
++ ret
++ restore %g0,%o1,%o0
diff --git a/devel/mit-pthreads/patches/patch-av b/devel/mit-pthreads/patches/patch-av
new file mode 100644
index 00000000000..26cc6475b55
--- /dev/null
+++ b/devel/mit-pthreads/patches/patch-av
@@ -0,0 +1,52 @@
+$NetBSD: patch-av,v 1.1 1998/12/28 22:22:02 bad Exp $
+
+--- /dev/null Mon Oct 19 22:21:39 1998
++++ machdep/syscall-template-sparc-netbsd-1.3.S Mon Oct 19 22:36:44 1998
+@@ -0,0 +1,47 @@
++/* ==== syscall.S ============================================================
++ * Copyright (c) 1994 Chris Provenzano, proven@mit.edu
++ * All rights reserved.
++ *
++ */
++
++#include <sys/syscall.h>
++
++#ifdef SYS___sigsuspend14
++#define SYS_sigsuspend SYS___sigsuspend14
++#endif
++#ifdef SYS___sigprocmask14
++#define SYS_sigprocmask SYS___sigprocmask14
++#endif
++
++#define SYSCALL(x) \
++ .globl _machdep_sys_##x; \
++ \
++_machdep_sys_##x:; \
++ \
++ mov SYS_##x, %g1; \
++ ta 0; \
++ bcs,a 2b; \
++ sub %r0,%o0,%o0; \
++ retl; \
++ nop
++
++/*
++ * Initial asm stuff for all functions.
++ */
++ .text
++ .align 4
++
++/* ==========================================================================
++ * error code for all syscalls. The error value is returned as the negative
++ * of the errno value.
++ */
++
++1:
++ sub %r0, %o0, %o0
++2:
++ retl
++ nop
++
++#define XSYSCALL(NAME) SYSCALL(NAME)
++
++XSYSCALL(SYSCALL_NAME)
diff --git a/devel/mit-pthreads/patches/patch-aw b/devel/mit-pthreads/patches/patch-aw
new file mode 100644
index 00000000000..85bdcc3464e
--- /dev/null
+++ b/devel/mit-pthreads/patches/patch-aw
@@ -0,0 +1,230 @@
+$NetBSD: patch-aw,v 1.1 1998/12/28 22:22:02 bad Exp $
+
+--- /dev/null Sun Dec 27 17:45:54 1998
++++ machdep/engine-i386-netbsd-1.3.c Mon Mar 2 19:44:34 1998
+@@ -0,0 +1,225 @@
++/* ==== machdep.c ============================================================
++ * Copyright (c) 1993, 1994 Chris Provenzano, proven@athena.mit.edu
++ *
++ * Copyright (c) 1993 by Chris Provenzano, proven@mit.edu
++ * All rights reserved.
++ *
++ * Redistribution and use in source and binary forms, with or without
++ * modification, are permitted provided that the following conditions
++ * are met:
++ * 1. Redistributions of source code must retain the above copyright
++ * notice, this list of conditions and the following disclaimer.
++ * 2. Redistributions in binary form must reproduce the above copyright
++ * notice, this list of conditions and the following disclaimer in the
++ * documentation and/or other materials provided with the distribution.
++ * 3. All advertising materials mentioning features or use of this software
++ * must display the following acknowledgement:
++ * This product includes software developed by Chris Provenzano.
++ * 4. The name of Chris Provenzano may not be used to endorse or promote
++ * products derived from this software without specific prior written
++ * permission.
++ *
++ * THIS SOFTWARE IS PROVIDED BY CHRIS PROVENZANO ``AS IS'' AND
++ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
++ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
++ * ARE DISCLAIMED. IN NO EVENT SHALL CHRIS PROVENZANO BE LIABLE FOR ANY
++ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
++ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
++ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
++ * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
++ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
++ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
++ * SUCH DAMAGE.
++ *
++ * Description : Machine dependent functions for NetBSD on i386
++ *
++ * 1.00 93/08/04 proven
++ * -Started coding this file.
++ */
++
++#ifndef lint
++static const char rcsid[] = "$Id: patch-aw,v 1.1 1998/12/28 22:22:02 bad Exp $";
++#endif
++
++#include <pthread.h>
++#include <sys/types.h>
++#include <sys/socket.h>
++#include <stdlib.h>
++#include <fcntl.h>
++#include <stdio.h>
++
++/* ==========================================================================
++ * machdep_save_state()
++ */
++int machdep_save_state(void)
++{
++ return(_setjmp(pthread_run->machdep_data.machdep_state));
++}
++
++/* ==========================================================================
++ * machdep_save_state()
++ */
++int machdep_save_float_state(struct pthread * pthread)
++{
++ char * fdata = (char *)pthread->machdep_data.machdep_float_state;
++
++ __asm__ ("fsave %0"::"m" (*fdata));
++}
++
++/* ==========================================================================
++ * machdep_restore_state()
++ */
++void machdep_restore_state(void)
++{
++ _longjmp(pthread_run->machdep_data.machdep_state, 1);
++}
++
++/* ==========================================================================
++ * machdep_restore_float_state()
++ */
++int machdep_restore_float_state(void)
++{
++ char * fdata = (char *)pthread_run->machdep_data.machdep_float_state;
++
++ __asm__ ("frstor %0"::"m" (*fdata));
++}
++
++/* ==========================================================================
++ * machdep_set_thread_timer()
++ */
++void machdep_set_thread_timer(struct machdep_pthread *machdep_pthread)
++{
++ if (setitimer(ITIMER_VIRTUAL, &(machdep_pthread->machdep_timer), NULL)) {
++ PANIC();
++ }
++}
++
++/* ==========================================================================
++ * machdep_unset_thread_timer()
++ */
++void machdep_unset_thread_timer(struct machdep_pthread *machdep_pthread)
++{
++ struct itimerval zeroval = { { 0, 0 }, { 0, 0 } };
++ int ret;
++
++ if (machdep_pthread) {
++ ret = setitimer(ITIMER_VIRTUAL, &zeroval,
++ &(machdep_pthread->machdep_timer));
++ } else {
++ ret = setitimer(ITIMER_VIRTUAL, &zeroval, NULL);
++ }
++
++ if (ret) {
++ PANIC();
++ }
++}
++
++/* ==========================================================================
++ * machdep_pthread_cleanup()
++ */
++void *machdep_pthread_cleanup(struct machdep_pthread *machdep_pthread)
++{
++ return(machdep_pthread->machdep_stack);
++}
++
++/* ==========================================================================
++ * machdep_pthread_start()
++ */
++void machdep_pthread_start(void)
++{
++ context_switch_done();
++ pthread_sched_resume();
++
++ /* Run current threads start routine with argument */
++ pthread_exit(pthread_run->machdep_data.start_routine
++ (pthread_run->machdep_data.start_argument));
++
++ /* should never reach here */
++ PANIC();
++}
++
++/* ==========================================================================
++ * __machdep_stack_free()
++ */
++void __machdep_stack_free(void * stack)
++{
++ free(stack);
++}
++
++/* ==========================================================================
++ * __machdep_stack_alloc()
++ */
++void * __machdep_stack_alloc(size_t size)
++{
++ void * stack;
++
++ return(malloc(size));
++}
++
++/* ==========================================================================
++ * __machdep_pthread_create()
++ */
++void __machdep_pthread_create(struct machdep_pthread *machdep_pthread,
++ void *(* start_routine)(), void *start_argument,
++ long stack_size, long nsec, long flags)
++{
++ machdep_pthread->start_routine = start_routine;
++ machdep_pthread->start_argument = start_argument;
++
++ machdep_pthread->machdep_timer.it_value.tv_sec = 0;
++ machdep_pthread->machdep_timer.it_interval.tv_sec = 0;
++ machdep_pthread->machdep_timer.it_interval.tv_usec = 0;
++ machdep_pthread->machdep_timer.it_value.tv_usec = nsec / 1000;
++
++ _setjmp(machdep_pthread->machdep_state);
++ /*
++ * Set up new stact frame so that it looks like it
++ * returned from a longjmp() to the beginning of
++ * machdep_pthread_start().
++ */
++ machdep_pthread->machdep_state[0] = (int)machdep_pthread_start;
++
++ /* Stack starts high and builds down. */
++ machdep_pthread->machdep_state[2] =
++ (int)machdep_pthread->machdep_stack + stack_size;
++}
++
++/* ==========================================================================
++ * machdep_sys_creat()
++ */
++machdep_sys_creat(char * path, int mode)
++{
++ return(machdep_sys_open(path, O_WRONLY | O_CREAT | O_TRUNC, mode));
++}
++
++/* ==========================================================================
++ * machdep_sys_wait3()
++ */
++machdep_sys_wait3(int * b, int c, int * d)
++{
++ return(machdep_sys_wait4(0, b, c, d));
++}
++
++/* ==========================================================================
++ * machdep_sys_waitpid()
++ */
++machdep_sys_waitpid(int a, int * b, int c)
++{
++ return(machdep_sys_wait4(a, b, c, NULL));
++}
++
++/* ==========================================================================
++ * machdep_sys_getdtablesize()
++ */
++machdep_sys_getdtablesize()
++{
++ return(sysconf(_SC_OPEN_MAX));
++}
++
++/* ==========================================================================
++ * machdep_sys_getdirentries()
++ */
++machdep_sys_getdirentries(int fd, char * buf, int len, int * seek)
++{
++ return(machdep_sys_getdents(fd, buf, len));
++}
diff --git a/devel/mit-pthreads/patches/patch-ax b/devel/mit-pthreads/patches/patch-ax
new file mode 100644
index 00000000000..6d5ba7c7c9f
--- /dev/null
+++ b/devel/mit-pthreads/patches/patch-ax
@@ -0,0 +1,103 @@
+$NetBSD: patch-ax,v 1.1 1998/12/28 22:22:02 bad Exp $
+
+--- /dev/null Sun Dec 27 17:07:36 1998
++++ machdep/engine-i386-netbsd-1.3.h Sun Dec 27 17:21:41 1998
+@@ -0,0 +1,98 @@
++/* ==== machdep.h ============================================================
++ * Copyright (c) 1993 Chris Provenzano, proven@athena.mit.edu
++ *
++ * $Id: patch-ax,v 1.1 1998/12/28 22:22:02 bad Exp $
++ *
++ */
++
++#include <unistd.h>
++#include <setjmp.h>
++#include <sys/time.h>
++#include <sys/signal.h> /* for _NSIG */
++
++/*
++ * The first machine dependent functions are the SEMAPHORES
++ * needing the test and set instruction.
++ */
++#define SEMAPHORE_CLEAR 0
++#define SEMAPHORE_SET 1
++
++#define SEMAPHORE_TEST_AND_SET(lock) \
++({ \
++long temp = SEMAPHORE_SET; \
++ \
++__asm__ volatile ("xchgl %0,(%2)" \
++ :"=r" (temp) \
++ :"0" (temp),"r" (lock)); \
++temp; \
++})
++
++#define SEMAPHORE_RESET(lock) *lock = SEMAPHORE_CLEAR
++
++/*
++ * New types
++ */
++typedef long semaphore;
++
++/*
++ * sigset_t macros
++ */
++#define SIG_ANY(sig) (sig)
++#define SIGMAX (_NSIG-1)
++
++/*
++ * New Strutures
++ */
++struct machdep_pthread {
++ void *(*start_routine)(void *);
++ void *start_argument;
++ void *machdep_stack;
++ struct itimerval machdep_timer;
++ jmp_buf machdep_state;
++ char machdep_float_state[108];
++};
++
++/*
++ * Static machdep_pthread initialization values.
++ * For initial thread only.
++ */
++#define MACHDEP_PTHREAD_INIT \
++{ NULL, NULL, NULL, { { 0, 0 }, { 0, 100000 } }, 0 }
++
++/*
++ * Minimum stack size
++ */
++#define PTHREAD_STACK_MIN 1024
++
++/*
++ * Some fd flag defines that are necessary to distinguish between posix
++ * behavior and bsd4.3 behavior.
++ */
++#define __FD_NONBLOCK O_NONBLOCK
++
++/*
++ * New functions
++ */
++
++__BEGIN_DECLS
++
++#if defined(PTHREAD_KERNEL)
++
++#define __machdep_stack_get(x) (x)->machdep_stack
++#define __machdep_stack_set(x, y) (x)->machdep_stack = y
++#define __machdep_stack_repl(x, y) \
++{ \
++ if (stack = __machdep_stack_get(x)) { \
++ __machdep_stack_free(stack); \
++ } \
++ __machdep_stack_set(x, y); \
++}
++
++void * __machdep_stack_alloc __P_((size_t));
++void __machdep_stack_free __P_((void *));
++
++int machdep_save_state __P_((void));
++
++#endif
++
++__END_DECLS
diff --git a/devel/mit-pthreads/patches/patch-ay b/devel/mit-pthreads/patches/patch-ay
new file mode 100644
index 00000000000..caa1f28c4cd
--- /dev/null
+++ b/devel/mit-pthreads/patches/patch-ay
@@ -0,0 +1,205 @@
+$NetBSD: patch-ay,v 1.1 1998/12/28 22:22:02 bad Exp $
+
+--- /dev/null Sun Dec 27 17:07:36 1998
++++ machdep/syscall-i386-netbsd-1.3.S Sun Dec 27 17:21:41 1998
+@@ -0,0 +1,200 @@
++/* ==== syscall.S ============================================================
++ * Copyright (c) 1990 The Regents of the University of California.
++ * Copyright (c) 1993 Chris Provenzano, proven@mit.edu
++ * 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.
++ *
++ * Description : Machine dependent syscalls for i386/i486/i586
++ *
++ * 1.00 93/08/26 proven
++ * -Started coding this file.
++ *
++ * 1.01 93/11/13 proven
++ * -The functions readv() and writev() added.
++ */
++
++#ifndef lint
++ .text
++ .asciz "$Id: patch-ay,v 1.1 1998/12/28 22:22:02 bad Exp $";
++#endif
++
++#if defined(SYSLIBC_SCCS) && !defined(lint)
++ .asciz "@(#)syscall.s 5.1 (Berkeley) 4/23/90"
++#endif /* SYSLIBC_SCCS and not lint */
++
++#include <machine/asm.h>
++#include <sys/syscall.h>
++
++/*
++ * Initial asm stuff for all functions.
++ */
++ .text
++ .align 2
++
++
++/* ==========================================================================
++ * machdep_sys_fork()
++ */
++ .globl _machdep_sys_fork;
++
++_machdep_sys_fork:;
++
++ movl $(SYS_fork), %eax;
++ .byte 0x9a; .long 0; .word 7;
++ cmpl $0, %edx
++ je 2f
++ movl $0, %eax
++2:
++ ret;
++
++/* ==========================================================================
++ * machdep_sys___syscall()
++ */
++
++_machdep_sys___syscall:;
++
++ movl $(SYS___syscall), %eax;
++ int $0x80;
++ jb 3f;
++ ret
++
++#ifndef SYS___sigsuspend14
++/* ==========================================================================
++ * machdep_sys_sigsuspend()
++ */
++ .globl _machdep_sys_sigsuspend;
++
++_machdep_sys_sigsuspend:;
++
++ movl 4(%esp),%eax # fetch mask arg
++ movl (%eax),%eax # indirect to mask arg
++ movl %eax,4(%esp)
++ movl $(SYS_sigsuspend), %eax;
++ int $0x80;
++ jb 3f;
++ ret
++#endif
++
++3:
++
++ neg %eax
++ movl $0xffffffff,%edx
++ ret
++
++/* ==========================================================================
++ * machdep_sys_lseek()
++ */
++ .globl _machdep_sys_lseek;
++
++_machdep_sys_lseek:;
++
++ pushl %ebp;
++ movl %esp,%ebp;
++ pushl 0x14(%ebp);
++ pushl 0x10(%ebp);
++ pushl 0xc(%ebp);
++ pushl $0x0;
++ pushl 0x8(%ebp);
++ pushl $0x0;
++ pushl $(SYS_lseek);
++ call _machdep_sys___syscall;
++ leave
++ ret
++
++/* ==========================================================================
++ * machdep_sys_ftruncate() ; Added by Monty
++ */
++ .globl _machdep_sys_ftruncate;
++
++_machdep_sys_ftruncate:;
++
++ pushl %ebp;
++ movl %esp,%ebp;
++ pushl 0x10(%ebp);
++ pushl 0xc(%ebp);
++ pushl $0x0; # Why this?
++ pushl 0x8(%ebp);
++ pushl $0x0; # And this?
++ pushl $(SYS_ftruncate);
++ call _machdep_sys___syscall;
++ leave
++ ret
++
++#ifndef SYS___sigprocmask14
++/* ==========================================================================
++ * machdep_sys_sigprocmask()
++ */
++ .globl _machdep_sys_sigprocmask;
++
++_machdep_sys_sigprocmask:;
++
++ movl 8(%esp),%ecx
++ movl (%ecx),%ecx
++ movl %ecx,8(%esp)
++ movl $(SYS_sigprocmask), %eax;
++ int $0x80;
++ jb 3b;
++ ret
++#endif
++
++/* ==========================================================================
++ * machdep_sys_pipe()
++ */
++ .globl _machdep_sys_pipe;
++
++_machdep_sys_pipe:;
++
++ movl $(SYS_pipe), %eax;
++ int $0x80;
++ jb 3b;
++ movl 4(%esp),%ecx
++ movl %eax,(%ecx)
++ movl %edx,4(%ecx)
++ xorl %eax,%eax
++ ret
++
++/* ==========================================================================
++ * machdep_sys_fstat()
++ */
++ .globl _machdep_sys_fstat;
++
++_machdep_sys_fstat:;
++ movl $(SYS___fstat13), %eax;
++ int $0x80;
++ jb 4f;
++ ret
++4:
++ neg %eax
++ movl $0xffffffff,%edx
++ ret
++
diff --git a/devel/mit-pthreads/patches/patch-az b/devel/mit-pthreads/patches/patch-az
new file mode 100644
index 00000000000..ebff9024742
--- /dev/null
+++ b/devel/mit-pthreads/patches/patch-az
@@ -0,0 +1,61 @@
+$NetBSD: patch-az,v 1.1 1998/12/28 22:22:03 bad Exp $
+
+--- /dev/null Sun Dec 27 17:07:36 1998
++++ machdep/syscall-template-i386-netbsd-1.3.S Sun Dec 27 17:21:41 1998
+@@ -0,0 +1,56 @@
++#include <machine/asm.h>
++#include <sys/syscall.h>
++
++#ifdef SYS___sigsuspend14
++#define SYS_sigsuspend SYS___sigsuspend14
++#endif
++#ifdef SYS___sigprocmask14
++#define SYS_sigprocmask SYS___sigprocmask14
++#endif
++
++#ifdef __STDC__
++
++#define SYSCALL(x) \
++ .globl _machdep_sys_##x; \
++ \
++_machdep_sys_##x:; \
++ \
++ movl $(SYS_##x), %eax; \
++ int $0x80; \
++ jb 1b; \
++ ret;
++
++#else
++
++#define SYSCALL(x) \
++ .globl _machdep_sys_/**/x; \
++ \
++_machdep_sys_/**/x:; \
++ \
++ movl $(SYS_/**/x), %eax; \
++ int $0x80; \
++ jb 1b; \
++ ret;
++
++#endif
++
++
++/*
++ * Initial asm stuff for all functions.
++ */
++ .text
++ .align 2
++
++
++/* ==========================================================================
++ * error code for all syscalls. The error value is returned as the negative
++ * of the errno value.
++ */
++
++1:
++ neg %eax
++ ret
++
++#define XSYSCALL(NAME) SYSCALL(NAME)
++
++XSYSCALL(SYSCALL_NAME)
diff --git a/devel/mit-pthreads/patches/patch-ba b/devel/mit-pthreads/patches/patch-ba
new file mode 100644
index 00000000000..c3cb5c8c1b9
--- /dev/null
+++ b/devel/mit-pthreads/patches/patch-ba
@@ -0,0 +1,107 @@
+$NetBSD: patch-ba,v 1.1 1998/12/28 22:22:03 bad Exp $
+
+--- /dev/null Thu Oct 22 03:18:30 1998
++++ machdep/engine-arm32-netbsd-1.3.h Thu Oct 22 19:39:30 1998
+@@ -0,0 +1,102 @@
++/* ==== machdep.h ============================================================
++ * Copyright (c) 1993 Chris Provenzano, proven@athena.mit.edu
++ *
++ * Id: engine-i386-netbsd-1.3.h,v 1.1 1998/02/28 04:53:15 cjs Exp
++ *
++ */
++
++#include <unistd.h>
++#include <setjmp.h>
++#include <sys/time.h>
++#include <sys/signal.h> /* for _NSIG */
++
++/*
++ * The first machine dependent functions are the SEMAPHORES
++ * needing the test and set instruction.
++ */
++#define SEMAPHORE_CLEAR 0
++#define SEMAPHORE_SET 1
++
++#if 0
++#define SEMAPHORE_TEST_AND_SET(lock) \
++({ \
++long temp = SEMAPHORE_SET; \
++ \
++__asm__ volatile ("xchgl %0,(%2)" \
++ :"=r" (temp) \
++ :"0" (temp),"r" (lock)); \
++temp; \
++})
++
++#define SEMAPHORE_RESET(lock) *lock = SEMAPHORE_CLEAR
++#endif
++
++/*
++ * New types
++ */
++typedef long semaphore;
++
++/*
++ * sigset_t macros
++ */
++#define SIG_ANY(sig) (sig)
++#define SIGMAX (_NSIG-1)
++
++/*
++ * New Strutures
++ */
++struct machdep_pthread {
++ void *(*start_routine)(void *);
++ void *start_argument;
++ void *machdep_stack;
++ struct itimerval machdep_timer;
++ jmp_buf machdep_state;
++#if 0
++ char machdep_float_state[108];
++#endif
++};
++
++/*
++ * Static machdep_pthread initialization values.
++ * For initial thread only.
++ */
++#define MACHDEP_PTHREAD_INIT \
++{ NULL, NULL, NULL, { { 0, 0 }, { 0, 100000 } }, 0 }
++
++/*
++ * Minimum stack size
++ */
++#define PTHREAD_STACK_MIN 1024
++
++/*
++ * Some fd flag defines that are necessary to distinguish between posix
++ * behavior and bsd4.3 behavior.
++ */
++#define __FD_NONBLOCK O_NONBLOCK
++
++/*
++ * New functions
++ */
++
++__BEGIN_DECLS
++
++#if defined(PTHREAD_KERNEL)
++
++#define __machdep_stack_get(x) (x)->machdep_stack
++#define __machdep_stack_set(x, y) (x)->machdep_stack = y
++#define __machdep_stack_repl(x, y) \
++{ \
++ if (stack = __machdep_stack_get(x)) { \
++ __machdep_stack_free(stack); \
++ } \
++ __machdep_stack_set(x, y); \
++}
++
++void * __machdep_stack_alloc __P_((size_t));
++void __machdep_stack_free __P_((void *));
++
++int machdep_save_state __P_((void));
++
++#endif
++
++__END_DECLS
diff --git a/devel/mit-pthreads/patches/patch-bb b/devel/mit-pthreads/patches/patch-bb
new file mode 100644
index 00000000000..219ca523a29
--- /dev/null
+++ b/devel/mit-pthreads/patches/patch-bb
@@ -0,0 +1,200 @@
+$NetBSD: patch-bb,v 1.1 1998/12/28 22:22:03 bad Exp $
+
+--- /dev/null Sun Oct 25 03:15:17 1998
++++ machdep/engine-arm32-netbsd-1.3.c Sun Oct 25 18:38:54 1998
+@@ -0,0 +1,195 @@
++/* ==== machdep.c ============================================================
++ * Copyright (c) 1993, 1994 Chris Provenzano, proven@athena.mit.edu
++ *
++ * Description : Machine dependent functions for NetBSD on arm32
++ *
++ * 1.00 93/08/04 proven
++ * -Started coding this file.
++ *
++ * 98/10/22 bad
++ * -adapt from i386 version
++ */
++
++#ifndef lint
++static const char rcsid[] = "$Id: patch-bb,v 1.1 1998/12/28 22:22:03 bad Exp $";
++#endif
++
++#include <pthread.h>
++#include <sys/types.h>
++#include <sys/socket.h>
++#include <sys/syscall.h>
++#include <stdlib.h>
++#include <fcntl.h>
++#include <stdio.h>
++
++/* ==========================================================================
++ * machdep_save_state()
++ */
++int machdep_save_state(void)
++{
++ return(_setjmp(pthread_run->machdep_data.machdep_state));
++}
++
++/* ==========================================================================
++ * machdep_save_state()
++ */
++int machdep_save_float_state(struct pthread * pthread)
++{
++ return;
++}
++
++/* ==========================================================================
++ * machdep_restore_state()
++ */
++void machdep_restore_state(void)
++{
++ _longjmp(pthread_run->machdep_data.machdep_state, 1);
++}
++
++/* ==========================================================================
++ * machdep_restore_float_state()
++ */
++int machdep_restore_float_state(void)
++{
++ return;
++}
++
++/* ==========================================================================
++ * machdep_set_thread_timer()
++ */
++void machdep_set_thread_timer(struct machdep_pthread *machdep_pthread)
++{
++ if (setitimer(ITIMER_VIRTUAL, &(machdep_pthread->machdep_timer), NULL)) {
++ PANIC();
++ }
++}
++
++/* ==========================================================================
++ * machdep_unset_thread_timer()
++ */
++void machdep_unset_thread_timer(struct machdep_pthread *machdep_pthread)
++{
++ struct itimerval zeroval = { { 0, 0 }, { 0, 0 } };
++ int ret;
++
++ if (machdep_pthread) {
++ ret = setitimer(ITIMER_VIRTUAL, &zeroval,
++ &(machdep_pthread->machdep_timer));
++ } else {
++ ret = setitimer(ITIMER_VIRTUAL, &zeroval, NULL);
++ }
++
++ if (ret) {
++ PANIC();
++ }
++}
++
++/* ==========================================================================
++ * machdep_pthread_cleanup()
++ */
++void *machdep_pthread_cleanup(struct machdep_pthread *machdep_pthread)
++{
++ return(machdep_pthread->machdep_stack);
++}
++
++/* ==========================================================================
++ * machdep_pthread_start()
++ */
++void machdep_pthread_start(void)
++{
++ context_switch_done();
++ pthread_sched_resume();
++
++ /* Run current threads start routine with argument */
++ pthread_exit(pthread_run->machdep_data.start_routine
++ (pthread_run->machdep_data.start_argument));
++
++ /* should never reach here */
++ PANIC();
++}
++
++/* ==========================================================================
++ * __machdep_stack_free()
++ */
++void __machdep_stack_free(void * stack)
++{
++ free(stack);
++}
++
++/* ==========================================================================
++ * __machdep_stack_alloc()
++ */
++void * __machdep_stack_alloc(size_t size)
++{
++ void * stack;
++
++ return(malloc(size));
++}
++
++/* ==========================================================================
++ * __machdep_pthread_create()
++ */
++void __machdep_pthread_create(struct machdep_pthread *machdep_pthread,
++ void *(* start_routine)(), void *start_argument,
++ long stack_size, long nsec, long flags)
++{
++ machdep_pthread->start_routine = start_routine;
++ machdep_pthread->start_argument = start_argument;
++
++ machdep_pthread->machdep_timer.it_value.tv_sec = 0;
++ machdep_pthread->machdep_timer.it_interval.tv_sec = 0;
++ machdep_pthread->machdep_timer.it_interval.tv_usec = 0;
++ machdep_pthread->machdep_timer.it_value.tv_usec = nsec / 1000;
++
++ _setjmp(machdep_pthread->machdep_state);
++ /*
++ * Set up new stact frame so that it looks like it
++ * returned from a longjmp() to the beginning of
++ * machdep_pthread_start().
++ */
++ machdep_pthread->machdep_state[JMPBUF_REG_R14] = (int)machdep_pthread_start;
++
++ /* Stack starts high and builds down. */
++ machdep_pthread->machdep_state[JMPBUF_REG_R13] =
++ (int)machdep_pthread->machdep_stack + stack_size;
++}
++
++/* ==========================================================================
++ * machdep_sys_creat()
++ */
++machdep_sys_creat(char * path, int mode)
++{
++ return(machdep_sys_open(path, O_WRONLY | O_CREAT | O_TRUNC, mode));
++}
++
++/* ==========================================================================
++ * machdep_sys_wait3()
++ */
++machdep_sys_wait3(int * b, int c, int * d)
++{
++ return(machdep_sys_wait4(0, b, c, d));
++}
++
++/* ==========================================================================
++ * machdep_sys_waitpid()
++ */
++machdep_sys_waitpid(int a, int * b, int c)
++{
++ return(machdep_sys_wait4(a, b, c, NULL));
++}
++
++/* ==========================================================================
++ * machdep_sys_getdtablesize()
++ */
++machdep_sys_getdtablesize()
++{
++ return(sysconf(_SC_OPEN_MAX));
++}
++
++/* ==========================================================================
++ * machdep_sys_getdirentries()
++ */
++machdep_sys_getdirentries(int fd, char * buf, int len, int * seek)
++{
++ return(machdep_sys_getdents(fd, buf, len));
++}
diff --git a/devel/mit-pthreads/patches/patch-bc b/devel/mit-pthreads/patches/patch-bc
new file mode 100644
index 00000000000..1a1415063d4
--- /dev/null
+++ b/devel/mit-pthreads/patches/patch-bc
@@ -0,0 +1,198 @@
+$NetBSD: patch-bc,v 1.1 1998/12/28 22:22:03 bad Exp $
+
+--- /dev/null Sun Oct 25 03:15:17 1998
++++ machdep/syscall-arm32-netbsd-1.3.S Sun Oct 25 18:49:24 1998
+@@ -0,0 +1,193 @@
++/* ==== syscall.S ============================================================
++ * Copyright (c) 1990 The Regents of the University of California.
++ * Copyright (c) 1993 Chris Provenzano, proven@mit.edu
++ * 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.
++ *
++ * Description : Machine dependent syscalls for i386/i486/i586
++ *
++ * 1.00 93/08/26 proven
++ * -Started coding this file.
++ *
++ * 1.01 93/11/13 proven
++ * -The functions readv() and writev() added.
++ */
++
++#ifndef lint
++ .text
++ .asciz "$Id: patch-bc,v 1.1 1998/12/28 22:22:03 bad Exp $";
++#endif
++
++#if defined(SYSLIBC_SCCS) && !defined(lint)
++ .asciz "@(#)syscall.s 5.1 (Berkeley) 4/23/90"
++#endif /* SYSLIBC_SCCS and not lint */
++
++#include <machine/asm.h>
++#include <sys/syscall.h>
++
++/*
++ * Initial asm stuff for all functions.
++ */
++ .text
++ .align 0
++
++
++/* ==========================================================================
++ * machdep_sys_fork()
++ */
++ .globl _machdep_sys_fork;
++
++_machdep_sys_fork:;
++
++ swi SYS_fork
++ bcs 1f
++ sub r1, r1, #0x00000001
++ and r0, r0, r1
++ mov r15, r14
++
++
++
++/* ==========================================================================
++ * machdep_sys_fstat()
++ */
++ .globl _machdep_sys_fstat;
++
++_machdep_sys_fstat:;
++
++ swi SYS___fstat13
++ bcs 1f
++ mov r15, r14
++
++/* ==========================================================================
++ * machdep_sys___syscall()
++ */
++
++_machdep_sys___syscall:;
++
++ swi SYS___syscall
++ bcs 1f
++ mov r15, r14
++
++
++#ifndef SYS___sigsuspend14
++/* ==========================================================================
++ * machdep_sys_sigsuspend()
++ */
++ .globl _machdep_sys_sigsuspend;
++
++_machdep_sys_sigsuspend:;
++
++ ldr r0, [r0]
++ swi SYS_sigsuspend
++ bcs 1f
++ mov r0, #0x00000000
++ mov r15, r14
++
++#endif
++
++#ifndef SYS___sigprocmask14
++/* ==========================================================================
++ * machdep_sys_sigprocmask()
++ */
++ .globl _machdep_sys_sigprocmask;
++
++_machdep_sys_sigprocmask:;
++
++ teq r1, #0x00000000
++ moveq r0, #0x00000001
++ moveq r1, #0x00000000
++ ldrne r1, [r1]
++ swi SYS_sigprocmask
++ bcs 1f
++ teq r2, #0x00000000
++ strne r0, [r2]
++ mov r0, #0x00000000
++ mov r15, r14
++#endif
++
++/* ==========================================================================
++ * machdep_sys_ftruncate()
++ */
++ .global _machdep_sys_ftruncate
++_machdep_sys_ftruncate:
++ mov r12, r13
++ stmfd r13!, {r11, r12, r14, r15}
++ sub r13, r13, #8
++ stmia r13, {r1-r2}
++ mov r3, #0
++ sub r11, r12, #4
++ mov r2, r0
++ mov r1, #0
++ mov r0, #201
++ bl _machdep_sys___syscall
++ ldmea r11, {r11, r13, r15}
++
++/* ==========================================================================
++ * machdep_sys_lseek()
++ */
++ .global _machdep_sys_lseek
++
++_machdep_sys_lseek:
++ mov r12, r13
++ stmfd r13!, {r11, r12, r14, r15}
++ str r3, [r13, #-4]!
++ sub r13, r13, #8
++ stmia r13, {r1-r2}
++ sub r11, r12, #4
++ mov r3, #0
++ mov r2, r0
++ mov r1, #0
++ mov r0, #SYS_lseek
++ bl _machdep_sys___syscall
++ ldmea r11, {r11, r13, r15}
++
++/* ==========================================================================
++ * machdep_sys_pipe()
++ */
++ .globl _machdep_sys_pipe;
++
++_machdep_sys_pipe:;
++
++ mov r2, r0
++ swi SYS_pipe
++ bcs 1f
++ str r0, [r2, #0x0000]
++ str r1, [r2, #0x0004]
++ mov r0, #0x00000000
++ mov r15, r14
++
++
++1:
++ rsb r0, r0, #0x00000000
++ mvn r1, #0x00000000
++ mov r15, r14
diff --git a/devel/mit-pthreads/patches/patch-bd b/devel/mit-pthreads/patches/patch-bd
new file mode 100644
index 00000000000..56b3456b06b
--- /dev/null
+++ b/devel/mit-pthreads/patches/patch-bd
@@ -0,0 +1,60 @@
+$NetBSD: patch-bd,v 1.1 1998/12/28 22:22:04 bad Exp $
+
+--- /dev/null Sun Oct 25 20:12:14 1998
++++ machdep/syscall-template-arm32-netbsd-1.3.S Sun Oct 25 20:18:57 1998
+@@ -0,0 +1,55 @@
++#include <machine/asm.h>
++#include <sys/syscall.h>
++
++#ifdef SYS___sigsuspend14
++#define SYS_sigsuspend SYS___sigsuspend14
++#endif
++#ifdef SYS___sigprocmask14
++#define SYS_sigprocmask SYS___sigprocmask14
++#endif
++
++#ifdef __STDC__
++
++#define SYSCALL(x) \
++ .globl _machdep_sys_##x; \
++ \
++_machdep_sys_##x:; \
++ \
++ swi SYS_##x; \
++ bcs 1b; \
++ mov r15, r14;
++
++#else
++
++#define SYSCALL(x) \
++ .globl _machdep_sys_/**/x; \
++ \
++_machdep_sys_/**/x:; \
++ \
++ swi SYS_/**/x; \
++ bcs 1b; \
++ mov r15, r14;
++
++#endif
++
++
++/*
++ * Initial asm stuff for all functions.
++ */
++ .text
++ .align 0
++
++
++/* ==========================================================================
++ * error code for all syscalls. The error value is returned as the negative
++ * of the errno value.
++ */
++
++1:
++ rsb r0, r0, #0x00000000
++ mvn r1, #0x00000000
++ mov r15, r14
++
++#define XSYSCALL(NAME) SYSCALL(NAME)
++
++XSYSCALL(SYSCALL_NAME)