[BACK]Return to patch-au CVS log [TXT][DIR] Up to [cvs.NetBSD.org] / pkgsrc / lang / sr / patches

File: [cvs.NetBSD.org] / pkgsrc / lang / sr / patches / Attic / patch-au (download)

Revision 1.3, Wed Mar 2 13:21:34 2005 UTC (18 years ago) by is
Branch: MAIN
CVS Tags: pkgsrc-2018Q1-base, pkgsrc-2018Q1, pkgsrc-2017Q4-base, pkgsrc-2017Q4, pkgsrc-2017Q3-base, pkgsrc-2017Q3, pkgsrc-2017Q2-base, pkgsrc-2017Q2, pkgsrc-2017Q1-base, pkgsrc-2017Q1, pkgsrc-2016Q4-base, pkgsrc-2016Q4, pkgsrc-2016Q3-base, pkgsrc-2016Q3, pkgsrc-2016Q2-base, pkgsrc-2016Q2, pkgsrc-2016Q1-base, pkgsrc-2016Q1, pkgsrc-2015Q4-base, pkgsrc-2015Q4, pkgsrc-2015Q3-base, pkgsrc-2015Q3, pkgsrc-2015Q2-base, pkgsrc-2015Q2, pkgsrc-2015Q1-base, pkgsrc-2015Q1, pkgsrc-2014Q4-base, pkgsrc-2014Q4, pkgsrc-2014Q3-base, pkgsrc-2014Q3, pkgsrc-2014Q2-base, pkgsrc-2014Q2, pkgsrc-2014Q1-base, pkgsrc-2014Q1, pkgsrc-2013Q4-base, pkgsrc-2013Q4, pkgsrc-2013Q3-base, pkgsrc-2013Q3, pkgsrc-2013Q2-base, pkgsrc-2013Q2, pkgsrc-2013Q1-base, pkgsrc-2013Q1, pkgsrc-2012Q4-base, pkgsrc-2012Q4, pkgsrc-2012Q3-base, pkgsrc-2012Q3, pkgsrc-2012Q2-base, pkgsrc-2012Q2, pkgsrc-2012Q1-base, pkgsrc-2012Q1, pkgsrc-2011Q4-base, pkgsrc-2011Q4, pkgsrc-2011Q3-base, pkgsrc-2011Q3, pkgsrc-2011Q2-base, pkgsrc-2011Q2, pkgsrc-2011Q1-base, pkgsrc-2011Q1, pkgsrc-2010Q4-base, pkgsrc-2010Q4, pkgsrc-2010Q3-base, pkgsrc-2010Q3, pkgsrc-2010Q2-base, pkgsrc-2010Q2, pkgsrc-2010Q1-base, pkgsrc-2010Q1, pkgsrc-2009Q4-base, pkgsrc-2009Q4, pkgsrc-2009Q3-base, pkgsrc-2009Q3, pkgsrc-2009Q2-base, pkgsrc-2009Q2, pkgsrc-2009Q1-base, pkgsrc-2009Q1, pkgsrc-2008Q4-base, pkgsrc-2008Q4, pkgsrc-2008Q3-base, pkgsrc-2008Q3, pkgsrc-2008Q2-base, pkgsrc-2008Q2, pkgsrc-2008Q1-base, pkgsrc-2008Q1, pkgsrc-2007Q4-base, pkgsrc-2007Q4, pkgsrc-2007Q3-base, pkgsrc-2007Q3, pkgsrc-2007Q2-base, pkgsrc-2007Q2, pkgsrc-2007Q1-base, pkgsrc-2007Q1, pkgsrc-2006Q4-base, pkgsrc-2006Q4, pkgsrc-2006Q3-base, pkgsrc-2006Q3, pkgsrc-2006Q2-base, pkgsrc-2006Q2, pkgsrc-2006Q1-base, pkgsrc-2006Q1, pkgsrc-2005Q4-base, pkgsrc-2005Q4, pkgsrc-2005Q3-base, pkgsrc-2005Q3, pkgsrc-2005Q2-base, pkgsrc-2005Q2, pkgsrc-2005Q1-base, pkgsrc-2005Q1, cwrapper, cube-native-xorg-base, cube-native-xorg
Changes since 1.2: +11 -15 lines

Be more careful when abusing libpthread internals. Should help SR on
RISC machines. Version bump to 2.3.3nb1.

$NetBSD: patch-au,v 1.3 2005/03/02 13:21:34 is Exp $

--- csw/netbsd.c.orig	2005-03-02 13:00:06.000000000 +0000
+++ csw/netbsd.c
@@ -0,0 +1,112 @@
+/*
+ *  netbsd.c -- context switch code for NetBSD 2.
+ *
+ *  Some Makefile changes are needed to use this code.
+ */
+
+#include <ucontext.h>
+
+void sr_stk_underflow(void);
+void sr_stk_corrupted(void);
+
+static void startup(void (*)(void), unsigned long, unsigned long, unsigned long, unsigned long);
+
+#ifdef __i386__
+void pthread__i386_init(void);
+
+#define _setcontext_u(uc)	(*_md_setcontext_u)(uc)
+#define _swapcontext_u(oc,nc)	(*_md_swapcontext_u)(oc,nc)
+
+static void sr_setcontext_u(ucontext_t *);
+static void sr_swapcontext_u(ucontext_t *, ucontext_t *);
+
+void (*_md_getcontext_u) (ucontext_t *);
+void (*_md_setcontext_u) (ucontext_t *)			= sr_setcontext_u;
+void (*_md_swapcontext_u)(ucontext_t *, ucontext_t *)	= sr_swapcontext_u;
+
+static void
+sr_setcontext_u(ucontext_t *uc) {
+	pthread__i386_init();
+	_setcontext_u(uc);
+}
+
+static void
+sr_swapcontext_u(ucontext_t *oldc, ucontext_t *newc) {
+	pthread__i386_init();
+	_swapcontext_u(oldc, newc);
+}
+#endif
+
+
+/*
+ *  sr_build_context (func, buf, bufsize, arg1, arg2, arg3, arg4)
+ *
+ *  Build a context that will call func(arg1,arg2,arg3,arg4) when activated
+ *  and will catch an underflow error if func returns.  We use an intermediary
+ *  in order to catch that return.
+ */
+void
+sr_build_context (func, buf, bufsize, arg1, arg2, arg3, arg4)
+void (*func)();
+char *buf;
+int bufsize;
+unsigned long arg1, arg2, arg3, arg4;
+{
+    ucontext_t *uc = (ucontext_t *) buf;	/* put header at front of buf */
+
+    if (0 != getcontext(uc)) {			/* initialize context */
+	sr_stk_corrupted();
+    }
+
+    uc->uc_stack.ss_sp = buf + sizeof (ucontext_t);
+    uc->uc_stack.ss_size = bufsize - sizeof (ucontext_t);
+
+    makecontext (uc, startup, 5, func, arg1, arg2, arg3, arg4);
+    uc->uc_stack.ss_flags = 0;
+}
+
+/*
+ *  startup (func, a,b,c,d) -- intermediary for startup and underflow detection.
+ */
+static void
+startup (func, arg1, arg2, arg3, arg4)
+void (*func)();
+unsigned long arg1, arg2, arg3, arg4;
+{
+    (*func) (arg1, arg2, arg3, arg4);
+    sr_stk_underflow();
+}
+
+
+
+/*
+ *  sr_chg_context (newctx, oldctx) -- change contexts.
+ */
+void
+sr_chg_context (new, old)
+char *new, *old;
+{
+    ucontext_t *oldu, *newu;
+    newu = (ucontext_t *)new;
+
+    if (old) {
+	oldu = (ucontext_t *)old;
+	_swapcontext_u(oldu, newu);
+    } else {
+	_setcontext_u(newu);
+    }
+}
+
+
+
+/*
+ *  sr_check_stk (stk) -- check for stack overflow.
+ *
+ *  We have no idea of how to do that, so we do nothing.
+ */
+void
+sr_check_stk(stk)
+char *stk;
+{
+    /* nothing */
+}