various forgotten files

This commit is contained in:
rsc 2004-09-20 15:08:57 +00:00
parent dcc9531c5a
commit e5c26b01f7
9 changed files with 219 additions and 7 deletions

View file

@ -879,6 +879,20 @@ key(Rune r)
return;
}
switch(r) {
case 0x03: /* ^C: send interrupt */
case 0x7F: /* DEL: send interrupt */
t.qh = t.q0 = t.q1 = t.nr;
show(t.q0);
{int x; x=tcgetpgrp(rcfd);
print("postnote %d pgrp %d\n", rcpid, x);
postnote(PNGROUP, x, "interrupt");
if(x >= 2) killpg(x, 2);
}
// write(rcfd, "\x7F", 1);
return;
}
if(rawon() && t.q0==t.nr){
addraw(&r, 1);
consread();
@ -898,12 +912,6 @@ key(Rune r)
snarf();
switch(r) {
case 0x03: /* ^C: send interrupt */
case 0x7F: /* DEL: send interrupt */
t.qh = t.q0 = t.q1 = t.nr;
show(t.q0);
write(rcfd, "\x7F", 1);
break;
case 0x06: /* ^F: file name completion */
case Kins: /* Insert: file name completion */
rp = namecomplete();

View file

@ -138,6 +138,9 @@ spawn(ScreenInfo *s)
close(ConnectionNumber(dpy));
if (s->display[0] != '\0')
putenv(s->display);
signal(SIGINT, SIG_DFL);
signal(SIGTERM, SIG_DFL);
signal(SIGHUP, SIG_DFL);
if (termprog != NULL) {
execl(shell, shell, "-c", termprog, 0);
fprintf(stderr, "rio: exec %s", shell);

View file

@ -0,0 +1,11 @@
#include <lib9.h>
ulong
getcallerpc(void *x)
{
ulong *lp;
lp = x;
return lp[-1];
}

42
src/lib9/tas-power.c Normal file
View file

@ -0,0 +1,42 @@
#include "u.h"
#include "libc.h"
/*
* first argument (l) is in r3 at entry.
* r3 contains return value upon return.
*/
int
_tas(int *x)
{
int v;
int tmp, tmp2, tmp3;
/*
* this __asm__ works with gcc on linux
*/
__asm__("\n sync\n"
" li %1,0\n"
" mr %2,%4 /* &x->val */\n"
" lis %3,0xdead /* assemble constant 0xdeaddead */\n"
" ori %3,%3,0xdead /* \" */\n"
"tas1:\n"
" dcbf %2,%1 /* cache flush; \"fix for 603x bug\" */\n"
" lwarx %0,%2,%1 /* v = x->val with reservation */\n"
" cmp cr0,0,%0,%1 /* v == 0 */\n"
" bne tas0\n"
" stwcx. %3,%2,%1 /* if (x->val same) x->val = 0xdeaddead */\n"
" bne tas1\n"
"tas0:\n"
" sync\n"
" isync\n"
: "=r" (v), "=&r" (tmp), "=&r"(tmp2), "=&r"(tmp3)
: "r" (x)
: "cr0", "memory"
);
switch(v) {
case 0: return 0;
case 0xdeaddead: return 1;
default: fprint(2, "tas: corrupted 0x%lux\n", v);
}
return 0;
}

View file

@ -0,0 +1,80 @@
/* get FPR and VR use flags with sc 0x7FF3 */
/* get vsave with mfspr reg, 256 */
.text
.align 2
.globl _setlabel
_setlabel: /* xxx: instruction scheduling */
mflr 0
mfcr 5
mfctr 6
mfxer 7
stw 0, 0*4(3)
stw 5, 1*4(3)
stw 6, 2*4(3)
stw 7, 3*4(3)
stw 1, 4*4(3)
stw 2, 5*4(3)
stw 13, (0+6)*4(3) /* callee-save GPRs */
stw 14, (1+6)*4(3) /* xxx: block move */
stw 15, (2+6)*4(3)
stw 16, (3+6)*4(3)
stw 17, (4+6)*4(3)
stw 18, (5+6)*4(3)
stw 19, (6+6)*4(3)
stw 20, (7+6)*4(3)
stw 21, (8+6)*4(3)
stw 22, (9+6)*4(3)
stw 23, (10+6)*4(3)
stw 24, (11+6)*4(3)
stw 25, (12+6)*4(3)
stw 26, (13+6)*4(3)
stw 27, (14+6)*4(3)
stw 28, (15+6)*4(3)
stw 29, (16+6)*4(3)
stw 30, (17+6)*4(3)
stw 31, (18+6)*4(3)
li 3, 0 /* return */
blr
.globl _gotolabel
_gotolabel:
lwz 13, (0+6)*4(3) /* callee-save GPRs */
lwz 14, (1+6)*4(3) /* xxx: block move */
lwz 15, (2+6)*4(3)
lwz 16, (3+6)*4(3)
lwz 17, (4+6)*4(3)
lwz 18, (5+6)*4(3)
lwz 19, (6+6)*4(3)
lwz 20, (7+6)*4(3)
lwz 21, (8+6)*4(3)
lwz 22, (9+6)*4(3)
lwz 23, (10+6)*4(3)
lwz 24, (11+6)*4(3)
lwz 25, (12+6)*4(3)
lwz 26, (13+6)*4(3)
lwz 27, (14+6)*4(3)
lwz 28, (15+6)*4(3)
lwz 29, (16+6)*4(3)
lwz 30, (17+6)*4(3)
lwz 31, (18+6)*4(3)
lwz 1, 4*4(3)
lwz 2, 5*4(3)
lwz 0, 0*4(3)
mtlr 0
lwz 0, 1*4(3)
mtcr 0 /* mtcrf 0xFF, r0 */
lwz 0, 2*4(3)
mtctr 0
lwz 0, 3*4(3)
mtxer 0
li 3, 1
blr

40
src/libthread/power.c Normal file
View file

@ -0,0 +1,40 @@
#include "threadimpl.h"
static void
launcherpower(int a0, int a1, int a2, int a3, int a4, int a5, int a6, int a7,
void (*f)(void *arg), void *arg)
{
(*f)(arg);
threadexits(nil);
}
void
_threadinitstack(Thread *t, void (*f)(void*), void *arg)
{
ulong *tos, *stk;
tos = (ulong*)&t->stk[t->stksize&~7];
stk = tos;
--stk;
--stk;
--stk;
--stk;
*--stk = (ulong)arg;
*--stk = (ulong)f;
t->sched.pc = (ulong)launcherpower+LABELDPC;
t->sched.sp = ((ulong)stk)-8;
*((ulong *)t->sched.sp) = 0;
}
void
_threadinswitch(int enter)
{
USED(enter);
}
void
_threadstacklimit(void *addr, void *addr2)
{
USED(addr);
}

View file

@ -26,7 +26,6 @@ _schedinit(void *arg)
Proc *p;
Thread *t;
extern void ignusr1(int), _threaddie(int);
ignusr1(1);
signal(SIGTERM, _threaddie);
p = arg;

23
src/libthread/tfork.c Normal file
View file

@ -0,0 +1,23 @@
#include <u.h>
#include <libc.h>
#include <thread.h>
Channel *c;
void
f(void *v)
{
recvp(c);
}
void
threadmain(int argc, char **argv)
{
int i;
c = chancreate(sizeof(ulong), 0);
for(i=0;; i++){
print("%d\n", i);
proccreate(f, nil, 8192);
}
}

View file

@ -0,0 +1,6 @@
CC=gcc
CFLAGS+=-Wall -Wno-missing-braces -Wno-parentheses -Wno-switch -O2 -g -c -I.
O=o
AR=ar
ARFLAGS=rvc
NAN=nan64.$O