aboutsummaryrefslogtreecommitdiff
path: root/src/cmd/acid
diff options
context:
space:
mode:
authorrsc <devnull@localhost>2005-02-11 00:01:49 +0000
committerrsc <devnull@localhost>2005-02-11 00:01:49 +0000
commit281c90a5be6b1ab2280ffa23885fe41e7af80bce (patch)
treec26a67c58f869a3a6821f1a0ae980af03d4eb430 /src/cmd/acid
parentce2a378d46c0bcd00ec08b9bc4ad861c8aa28a2f (diff)
downloadplan9port-281c90a5be6b1ab2280ffa23885fe41e7af80bce.tar.gz
plan9port-281c90a5be6b1ab2280ffa23885fe41e7af80bce.tar.bz2
plan9port-281c90a5be6b1ab2280ffa23885fe41e7af80bce.zip
more pthread
Diffstat (limited to 'src/cmd/acid')
-rw-r--r--src/cmd/acid/acid.h6
-rw-r--r--src/cmd/acid/builtin.c32
-rw-r--r--src/cmd/acid/expr.c6
-rw-r--r--src/cmd/acid/util.c3
4 files changed, 33 insertions, 14 deletions
diff --git a/src/cmd/acid/acid.h b/src/cmd/acid/acid.h
index 866816e8..95f768e8 100644
--- a/src/cmd/acid/acid.h
+++ b/src/cmd/acid/acid.h
@@ -132,7 +132,10 @@ struct Store
String* string;
List* l;
Node* cc;
- char* reg;
+ struct {
+ char *name;
+ uint thread;
+ } reg;
Node* con;
} u;
};
@@ -258,6 +261,7 @@ String* strnode(char*);
String* strnodlen(char*, int);
#define system acidsystem
char* system(void);
+Regs* threadregs(uint);
int trlist(Map*, Regs*, ulong, ulong, Symbol*, int);
void unwind(void);
void userinit(void);
diff --git a/src/cmd/acid/builtin.c b/src/cmd/acid/builtin.c
index 316c4921..8dbc1765 100644
--- a/src/cmd/acid/builtin.c
+++ b/src/cmd/acid/builtin.c
@@ -325,22 +325,33 @@ xkill(Node *r, Node *args)
void
xregister(Node *r, Node *args)
{
+ int tid;
Regdesc *rp;
- Node res;
+ Node res, resid;
+ Node *av[Maxarg];
- if(args == 0)
- error("register(string): arg count");
- expr(args, &res);
- if(res.type != TSTRING)
- error("register(string): arg type");
+ na = 0;
+ flatten(av, args);
+ if(na != 1 && na != 2)
+ error("register(name[, threadid]): arg count");
+ expr(av[0], &res);
+ if(res.type != TSTRING)
+ error("register(name[, threadid]): arg type: name should be string");
+ tid = 0;
+ if(na == 2){
+ expr(av[1], &resid);
+ if(resid.type != TINT)
+ error("register(name[, threadid]): arg type: threadid should be int");
+ tid = resid.store.u.ival;
+ }
if((rp = regdesc(res.store.u.string->string)) == nil)
error("no such register");
-
r->op = OCONST;
r->type = TREG;
r->store.fmt = rp->format;
- r->store.u.reg = rp->name;
+ r->store.u.reg.name = rp->name;
+ r->store.u.reg.thread = tid;
}
void
@@ -1127,7 +1138,10 @@ patom(char type, Store *res)
switch(type){
case TREG:
- Bprint(bout, "register(\"%s\")", res->u.reg);
+ if(res->u.reg.thread)
+ Bprint(bout, "register(\"%s\", 0x%ux)", res->u.reg.name, res->u.reg.thread);
+ else
+ Bprint(bout, "register(\"%s\")", res->u.reg.name);
return;
case TCON:
Bprint(bout, "refconst(");
diff --git a/src/cmd/acid/expr.c b/src/cmd/acid/expr.c
index 6a0430dc..822d7bb8 100644
--- a/src/cmd/acid/expr.c
+++ b/src/cmd/acid/expr.c
@@ -135,7 +135,7 @@ oindm(Node *n, Node *res)
res->store.comt = l.store.comt;
break;
case TREG:
- indirreg(correg, l.store.u.reg, l.store.fmt, res);
+ indirreg(threadregs(l.store.u.reg.thread), l.store.u.reg.name, l.store.fmt, res);
res->store.comt = l.store.comt;
break;
case TCON:
@@ -334,7 +334,7 @@ oasgn(Node *n, Node *res)
case OINDM:
expr(lp->left, &aes);
if(aes.type == TREG)
- windirreg(correg, aes.store.u.reg, n->right, res);
+ windirreg(threadregs(aes.store.u.reg.thread), aes.store.u.reg.name, n->right, res);
else
windir(cormap, aes, n->right, res);
break;
@@ -1097,7 +1097,7 @@ acidregsrw(Regs *r, char *name, ulong *u, int isr)
werrstr("*%s: register %s not mapped", name, v->store.u.reg);
return -1;
}
- return rget(correg, v->store.u.reg, u);
+ return rget(threadregs(v->store.u.reg.thread), v->store.u.reg.name, u);
case TCON:
n = v->store.u.con;
if(n->op != OCONST || n->type != TINT){
diff --git a/src/cmd/acid/util.c b/src/cmd/acid/util.c
index 3ea3c4c0..3e6a313d 100644
--- a/src/cmd/acid/util.c
+++ b/src/cmd/acid/util.c
@@ -216,7 +216,8 @@ varreg(void)
l = mkvar(r->name);
v = l->v;
v->set = 1;
- v->store.u.reg = r->name;
+ v->store.u.reg.name = r->name;
+ v->store.u.reg.thread = 0;
v->store.fmt = r->format;
v->type = TREG;