amd64 fixes

This commit is contained in:
Russ Cox 2006-05-21 16:32:29 +00:00
parent af11a9e129
commit 5797fdc0c0
28 changed files with 116 additions and 66 deletions

View File

@ -434,7 +434,7 @@ slave(Fsrpc *f)
if(p->busy == 0) { if(p->busy == 0) {
f->pid = p->pid; f->pid = p->pid;
p->busy = 1; p->busy = 1;
pid = rendezvous(p->pid, (ulong)f); pid = (uintptr)rendezvous((void*)(uintptr)p->pid, f);
if(pid != p->pid) if(pid != p->pid)
fatal("rendezvous sync fail"); fatal("rendezvous sync fail");
return; return;
@ -459,7 +459,7 @@ slave(Fsrpc *f)
Proclist = p; Proclist = p;
DEBUG(DFD, "parent %d rendez\n", pid); DEBUG(DFD, "parent %d rendez\n", pid);
rendezvous(pid, (ulong)p); rendezvous((void*)(uintptr)pid, p);
DEBUG(DFD, "parent %d went\n", pid); DEBUG(DFD, "parent %d went\n", pid);
} }
} }
@ -479,12 +479,12 @@ blockingslave(void *x)
pid = getpid(); pid = getpid();
DEBUG(DFD, "blockingslave %d rendez\n", pid); DEBUG(DFD, "blockingslave %d rendez\n", pid);
m = (Proc*)rendezvous(pid, 0); m = (Proc*)rendezvous((void*)(uintptr)pid, 0);
DEBUG(DFD, "blockingslave %d rendez got %p\n", pid, m); DEBUG(DFD, "blockingslave %d rendez got %p\n", pid, m);
for(;;) { for(;;) {
p = (Fsrpc*)rendezvous(pid, pid); p = rendezvous((void*)(uintptr)pid, (void*)(uintptr)pid);
if((int)p == ~0) /* Interrupted */ if((uintptr)p == ~(uintptr)0) /* Interrupted */
continue; continue;
DEBUG(DFD, "\tslave: %d %F b %d p %d\n", pid, &p->work, p->busy, p->pid); DEBUG(DFD, "\tslave: %d %F b %d p %d\n", pid, &p->work, p->busy, p->pid);

View File

@ -566,6 +566,8 @@ initmap(Window w)
* some displays say MSB even though they run on LSB. * some displays say MSB even though they run on LSB.
* Besides, this is more anal. * Besides, this is more anal.
*/ */
if(xscreendepth != DefaultDepth(xdisplay, DefaultScreen(xdisplay)))
xcmap = XCreateColormap(xdisplay, w, xvis, AllocNone);
c = map[19]; c = map[19];
/* find out index into colormap for our RGB */ /* find out index into colormap for our RGB */

View File

@ -31,7 +31,7 @@ struct Xmem
int dirty; int dirty;
Rectangle dirtyr; Rectangle dirtyr;
Rectangle r; Rectangle r;
ulong pc; /* who wrote into xi */ uintptr pc; /* who wrote into xi */
}; };
extern int xtblbit; extern int xtblbit;

View File

@ -236,7 +236,7 @@ extern int fmtprint(Fmt*, char*, ...);
extern int fmtvprint(Fmt*, char*, va_list); extern int fmtvprint(Fmt*, char*, va_list);
extern void* mallocz(ulong, int); extern void* mallocz(ulong, int);
extern ulong getcallerpc(void*); extern uintptr getcallerpc(void*);
extern char* cleanname(char*); extern char* cleanname(char*);
extern void sysfatal(char*, ...); extern void sysfatal(char*, ...);
extern char* strecpy(char*, char*, char*); extern char* strecpy(char*, char*, char*);
@ -250,6 +250,7 @@ extern int dec64(uchar*, int, char*, int);
extern int enc64(char*, int, uchar*, int); extern int enc64(char*, int, uchar*, int);
extern int dec32(uchar*, int, char*, int); extern int dec32(uchar*, int, char*, int);
extern int enc32(char*, int, uchar*, int); extern int enc32(char*, int, uchar*, int);
extern int enc16(char*, int, uchar*, int);
void hnputs(void *p, unsigned short v); void hnputs(void *p, unsigned short v);
extern int dofmt(Fmt*, char*); extern int dofmt(Fmt*, char*);
extern double __NaN(void); extern double __NaN(void);

View File

@ -74,13 +74,13 @@ extern int pushssl(int, char*, char*, char*, int*);
extern int iounit(int); extern int iounit(int);
extern long pread(int, void*, long, vlong); extern long pread(int, void*, long, vlong);
extern long pwrite(int, void*, long, vlong); extern long pwrite(int, void*, long, vlong);
extern ulong rendezvous(ulong, ulong); extern void* rendezvous(void*, void*);
extern int kproc(char*, void(*)(void*), void*); extern int kproc(char*, void(*)(void*), void*);
extern int getpid(void); extern int getpid(void);
extern void panic(char*, ...); extern void panic(char*, ...);
extern void sleep(int); extern void sleep(int);
extern void osyield(void); extern void osyield(void);
extern void setmalloctag(void*, ulong); extern void setmalloctag(void*, uintptr);
extern int errstr(char*, uint); extern int errstr(char*, uint);
extern int rerrstr(char*, uint); extern int rerrstr(char*, uint);
extern int encrypt(void*, void*, int); extern int encrypt(void*, void*, int);

View File

@ -20,7 +20,7 @@ static Block*
_allocb(int size) _allocb(int size)
{ {
Block *b; Block *b;
ulong addr; uintptr addr;
if((b = mallocz(sizeof(Block)+size+Hdrspc, 0)) == nil) if((b = mallocz(sizeof(Block)+size+Hdrspc, 0)) == nil)
return nil; return nil;
@ -31,13 +31,13 @@ _allocb(int size)
b->flag = 0; b->flag = 0;
/* align start of data portion by rounding up */ /* align start of data portion by rounding up */
addr = (ulong)b; addr = (uintptr)b;
addr = ROUND(addr + sizeof(Block), BLOCKALIGN); addr = ROUND(addr + sizeof(Block), BLOCKALIGN);
b->base = (uchar*)addr; b->base = (uchar*)addr;
/* align end of data portion by rounding down */ /* align end of data portion by rounding down */
b->lim = ((uchar*)b) + sizeof(Block)+size+Hdrspc; b->lim = ((uchar*)b) + sizeof(Block)+size+Hdrspc;
addr = (ulong)(b->lim); addr = (uintptr)(b->lim);
addr = addr & ~(BLOCKALIGN-1); addr = addr & ~(BLOCKALIGN-1);
b->lim = (uchar*)addr; b->lim = (uchar*)addr;
@ -60,7 +60,7 @@ allocb(int size)
* Can still error out of here, though. * Can still error out of here, though.
*/ */
if(up == nil) if(up == nil)
panic("allocb without up: %luX\n", getcallerpc(&size)); panic("allocb without up: %p\n", getcallerpc(&size));
if((b = _allocb(size)) == nil){ if((b = _allocb(size)) == nil){
panic("allocb: no memory for %d bytes\n", size); panic("allocb: no memory for %d bytes\n", size);
} }

View File

@ -112,7 +112,7 @@ decref(Ref *r)
x = --r->ref; x = --r->ref;
unlock(&r->lk); unlock(&r->lk);
if(x < 0) if(x < 0)
panic("decref, pc=0x%lux", getcallerpc(&r)); panic("decref, pc=0x%p", getcallerpc(&r));
return x; return x;
} }
@ -354,7 +354,7 @@ void
cclose(Chan *c) cclose(Chan *c)
{ {
if(c->flag&CFREE) if(c->flag&CFREE)
panic("cclose %lux", getcallerpc(&c)); panic("cclose %p", getcallerpc(&c));
if(decref(&c->ref)) if(decref(&c->ref))
return; return;

View File

@ -401,8 +401,8 @@ struct Proc
int notepending; /* note issued but not acted on */ int notepending; /* note issued but not acted on */
int kp; /* true if a kernel process */ int kp; /* true if a kernel process */
ulong rendtag; /* Tag for rendezvous */ void* rendtag; /* Tag for rendezvous */
ulong rendval; /* Value for rendezvous */ void* rendval; /* Value for rendezvous */
Proc *rendhash; /* Hash list for tag values */ Proc *rendhash; /* Hash list for tag values */
int nerrlab; int nerrlab;

View File

@ -179,4 +179,5 @@ int
audiodevread(void *v, int n) audiodevread(void *v, int n)
{ {
error("no reading"); error("no reading");
return -1;
} }

View File

@ -867,12 +867,17 @@ drawpoint(Point *p, uchar *a)
p->y = BGLONG(a+1*4); p->y = BGLONG(a+1*4);
} }
#define isvgascreen(dst) 1
Point Point
drawchar(Memimage *dst, Point p, Memimage *src, Point *sp, DImage *font, int index, int op) drawchar(Memimage *dst, Memimage *rdst, Point p,
Memimage *src, Point *sp, DImage *font, int index, int op)
{ {
FChar *fc; FChar *fc;
Rectangle r; Rectangle r;
Point sp1; Point sp1;
static Memimage *tmp;
fc = &font->fchar[index]; fc = &font->fchar[index];
r.min.x = p.x+fc->left; r.min.x = p.x+fc->left;
@ -881,7 +886,31 @@ drawchar(Memimage *dst, Point p, Memimage *src, Point *sp, DImage *font, int ind
r.max.y = r.min.y+(fc->maxy-fc->miny); r.max.y = r.min.y+(fc->maxy-fc->miny);
sp1.x = sp->x+fc->left; sp1.x = sp->x+fc->left;
sp1.y = sp->y+fc->miny; sp1.y = sp->y+fc->miny;
memdraw(dst, r, src, sp1, font->image, Pt(fc->minx, fc->miny), op);
/*
* If we're drawing greyscale fonts onto a VGA screen,
* it's very costly to read the screen memory to do the
* alpha blending inside memdraw. If this is really a stringbg,
* then rdst is the bg image (in main memory) which we can
* refer to for the underlying dst pixels instead of reading dst
* directly.
*/
if(1 || (isvgascreen(dst) && !isvgascreen(rdst) /*&& font->image->depth > 1*/)){
if(tmp == nil || tmp->chan != dst->chan || Dx(tmp->r) < Dx(r) || Dy(tmp->r) < Dy(r)){
if(tmp)
freememimage(tmp);
tmp = allocmemimage(Rect(0,0,Dx(r),Dy(r)), dst->chan);
if(tmp == nil)
goto fallback;
}
memdraw(tmp, Rect(0,0,Dx(r),Dy(r)), rdst, r.min, memopaque, ZP, S);
memdraw(tmp, Rect(0,0,Dx(r),Dy(r)), src, sp1, font->image, Pt(fc->minx, fc->miny), op);
memdraw(dst, r, tmp, ZP, memopaque, ZP, S);
}else{
fallback:
memdraw(dst, r, src, sp1, font->image, Pt(fc->minx, fc->miny), op);
}
p.x += fc->width; p.x += fc->width;
sp->x += fc->width; sp->x += fc->width;
return p; return p;
@ -1873,6 +1902,7 @@ drawmesg(Client *client, void *av, int n)
clipr = dst->clipr; clipr = dst->clipr;
dst->clipr = r; dst->clipr = r;
op = drawclientop(client); op = drawclientop(client);
l = dst;
if(*a == 'x'){ if(*a == 'x'){
/* paint background */ /* paint background */
l = drawimage(client, a+47); l = drawimage(client, a+47);
@ -1901,7 +1931,7 @@ drawmesg(Client *client, void *av, int n)
dst->clipr = clipr; dst->clipr = clipr;
error(Eindex); error(Eindex);
} }
q = drawchar(dst, q, src, &sp, font, ci, op); q = drawchar(dst, l, q, src, &sp, font, ci, op);
u += 2; u += 2;
} }
dst->clipr = clipr; dst->clipr = clipr;

View File

@ -15,7 +15,7 @@ lfdchan(int fd)
c = newchan(); c = newchan();
c->type = devno('L', 0); c->type = devno('L', 0);
c->aux = (void*)fd; c->aux = (void*)(uintptr)fd;
c->name = newcname("fd"); c->name = newcname("fd");
c->mode = ORDWR; c->mode = ORDWR;
c->qid.type = 0; c->qid.type = 0;
@ -76,14 +76,14 @@ lfdopen(Chan *c, int omode)
static void static void
lfdclose(Chan *c) lfdclose(Chan *c)
{ {
close((int)c->aux); close((int)(uintptr)c->aux);
} }
static long static long
lfdread(Chan *c, void *buf, long n, vlong off) lfdread(Chan *c, void *buf, long n, vlong off)
{ {
USED(off); /* can't pread on pipes */ USED(off); /* can't pread on pipes */
n = read((int)c->aux, buf, n); n = read((int)(uintptr)c->aux, buf, n);
if(n < 0){ if(n < 0){
iprint("error %d\n", errno); iprint("error %d\n", errno);
oserror(); oserror();
@ -96,7 +96,7 @@ lfdwrite(Chan *c, void *buf, long n, vlong off)
{ {
USED(off); /* can't pread on pipes */ USED(off); /* can't pread on pipes */
n = write((int)c->aux, buf, n); n = write((int)(uintptr)c->aux, buf, n);
if(n < 0){ if(n < 0){
iprint("error %d\n", errno); iprint("error %d\n", errno);
oserror(); oserror();

View File

@ -1037,7 +1037,7 @@ alloctag(void)
for(i = 0; i < NMASK; i++){ for(i = 0; i < NMASK; i++){
v = mntalloc.tagmask[i]; v = mntalloc.tagmask[i];
if(v == ~0UL) if(v == ~0)
continue; continue;
for(j = 0; j < 1<<TAGSHIFT; j++) for(j = 0; j < 1<<TAGSHIFT; j++)
if((v & (1<<j)) == 0){ if((v & (1<<j)) == 0){

View File

@ -358,7 +358,7 @@ sslwstat(Chan *c, uchar *db, int n)
if(!emptystr(dir->uid)) if(!emptystr(dir->uid))
kstrdup(&s->user, dir->uid); kstrdup(&s->user, dir->uid);
if(dir->mode != ~0UL) if(dir->mode != ~0)
s->perm = dir->mode; s->perm = dir->mode;
free(dir); free(dir);

View File

@ -224,7 +224,7 @@ static void put64(uchar *p, vlong x);
static void put32(uchar *p, u32int); static void put32(uchar *p, u32int);
static void put24(uchar *p, int); static void put24(uchar *p, int);
static void put16(uchar *p, int); static void put16(uchar *p, int);
static u32int get32(uchar *p); /* static u32int get32(uchar *p); */
static int get16(uchar *p); static int get16(uchar *p);
static void tlsSetState(TlsRec *tr, int new, int old); static void tlsSetState(TlsRec *tr, int new, int old);
static void rcvAlert(TlsRec *tr, int err); static void rcvAlert(TlsRec *tr, int err);
@ -241,14 +241,18 @@ static char *tlsstate(int s);
static void pdump(int, void*, char*); static void pdump(int, void*, char*);
static char *tlsnames[] = { static char *tlsnames[] = {
[Qclonus] "clone", /* unused */ 0,
[Qencalgs] "encalgs", /* topdir */ 0,
[Qhashalgs] "hashalgs", /* protodir */ 0,
[Qdata] "data", "clone",
[Qctl] "ctl", "encalgs",
[Qhand] "hand", "hashalgs",
[Qstatus] "status", /* convdir */ 0,
[Qstats] "stats", "data",
"ctl",
"hand",
"status",
"stats",
}; };
static int convdir[] = { Qctl, Qdata, Qhand, Qstatus, Qstats }; static int convdir[] = { Qctl, Qdata, Qhand, Qstatus, Qstats };
@ -2132,11 +2136,13 @@ put16(uchar *p, int x)
p[1] = x; p[1] = x;
} }
/*
static u32int static u32int
get32(uchar *p) get32(uchar *p)
{ {
return (p[0]<<24)|(p[1]<<16)|(p[2]<<8)|p[3]; return (p[0]<<24)|(p[1]<<16)|(p[2]<<8)|p[3];
} }
*/
static int static int
get16(uchar *p) get16(uchar *p)

View File

@ -6,6 +6,7 @@
#include <pthread.h> #include <pthread.h>
#include <time.h> #include <time.h>
#include <sys/time.h> #include <sys/time.h>
#include <sys/select.h>
#include <signal.h> #include <signal.h>
#include <pwd.h> #include <pwd.h>
#include <errno.h> #include <errno.h>

View File

@ -96,7 +96,7 @@ padblock(Block *bp, int size)
} }
if(bp->next) if(bp->next)
panic("padblock 0x%luX", getcallerpc(&bp)); panic("padblock 0x%p", getcallerpc(&bp));
n = BLEN(bp); n = BLEN(bp);
padblockcnt++; padblockcnt++;
nbp = allocb(size+n); nbp = allocb(size+n);
@ -110,7 +110,7 @@ padblock(Block *bp, int size)
size = -size; size = -size;
if(bp->next) if(bp->next)
panic("padblock 0x%luX", getcallerpc(&bp)); panic("padblock 0x%p", getcallerpc(&bp));
if(bp->lim - bp->wp >= size) if(bp->lim - bp->wp >= size)
return bp; return bp;
@ -1270,7 +1270,7 @@ qwrite(Queue *q, void *vp, int len)
uchar *p = vp; uchar *p = vp;
QDEBUG if(!islo()) QDEBUG if(!islo())
print("qwrite hi %lux\n", getcallerpc(&q)); print("qwrite hi %p\n", getcallerpc(&q));
sofar = 0; sofar = 0;
do { do {

View File

@ -139,7 +139,7 @@ rdb(void)
} }
void void
setmalloctag(void *v, ulong tag) setmalloctag(void *v, uintptr tag)
{ {
USED(v); USED(v);
USED(tag); USED(tag);

View File

@ -1189,15 +1189,15 @@ rerrstr(char *buf, uint n)
return strlen(buf); return strlen(buf);
} }
ulong void*
_sysrendezvous(ulong arg0, ulong arg1) _sysrendezvous(void* arg0, void* arg1)
{ {
ulong tag, val; void *tag, *val;
Proc *p, **l; Proc *p, **l;
tag = arg0; tag = arg0;
l = &REND(up->rgrp, tag); l = &REND(up->rgrp, (uintptr)tag);
up->rendval = ~0UL; up->rendval = (void*)~0;
lock(&up->rgrp->ref.lk); lock(&up->rgrp->ref.lk);
for(p = *l; p; p = p->rendhash) { for(p = *l; p; p = p->rendhash) {
@ -1228,15 +1228,15 @@ _sysrendezvous(ulong arg0, ulong arg1)
return up->rendval; return up->rendval;
} }
ulong void*
sysrendezvous(ulong tag, ulong val) sysrendezvous(void *tag, void *val)
{ {
ulong n; void *n;
starterror(); starterror();
if(waserror()){ if(waserror()){
_syserror(); _syserror();
return -1; return (void*)~0;
} }
n = _sysrendezvous(tag, val); n = _sysrendezvous(tag, val);
enderror(); enderror();

View File

@ -90,6 +90,7 @@ auth_getinfo(AuthRpc *rpc)
if(auth_rpc(rpc, "authinfo", nil, 0) != ARok) if(auth_rpc(rpc, "authinfo", nil, 0) != ARok)
return nil; return nil;
a = nil;
if(convM2AI((uchar*)rpc->arg, rpc->narg, &a) == nil){ if(convM2AI((uchar*)rpc->arg, rpc->narg, &a) == nil){
werrstr("bad auth info from factotum"); werrstr("bad auth info from factotum");
return nil; return nil;

View File

@ -333,7 +333,11 @@ __ifmt(Fmt *f)
break; break;
} }
if(f->r == 'p'){ if(f->r == 'p'){
u = (ulong)va_arg(f->args, void*); if(sizeof(void*) == sizeof(uvlong)){
isv = 1;
vu = (uvlong)va_arg(f->args, uvlong);
}else
u = (ulong)va_arg(f->args, ulong);
f->r = 'x'; f->r = 'x';
fl |= FmtUnsigned; fl |= FmtUnsigned;
}else if(fl & FmtVLong){ }else if(fl & FmtVLong){

View File

@ -38,7 +38,7 @@ lock(Lock *lk)
for(;;) { for(;;) {
if(canlock(lk)) if(canlock(lk))
return; return;
iprint("lock loop %ld: val=%d &lock=%ux pc=%ux\n", getpid(), lk->key, lk, getcallerpc(&lk)); iprint("lock loop %ld: val=%d &lock=%ux pc=%p\n", getpid(), lk->key, lk, getcallerpc(&lk));
osmsleep(1000); osmsleep(1000);
} }
} }

View File

@ -224,7 +224,7 @@ fmtstrtod(const char *as, char **aas)
/* close approx by naive conversion */ /* close approx by naive conversion */
mid[0] = 0; mid[0] = 0;
mid[1] = 1; mid[1] = 1;
for(i=0; c=a[i]; i++) { for(i=0; (c=a[i]); i++) {
mid[0] = mid[0]*10 + (c-'0'); mid[0] = mid[0]*10 + (c-'0');
mid[1] = mid[1]*10; mid[1] = mid[1]*10;
if(i >= 8) if(i >= 8)

View File

@ -19,7 +19,7 @@ memimagemove(void *from, void *to)
md->base = to; md->base = to;
/* if allocmemimage changes this must change too */ /* if allocmemimage changes this must change too */
md->bdata = (uchar*)&md->base[2]; md->bdata = (uchar*)md->base+sizeof(Memdata*)+sizeof(ulong);
} }
Memimage* Memimage*
@ -70,7 +70,8 @@ Memimage*
_allocmemimage(Rectangle r, ulong chan) _allocmemimage(Rectangle r, ulong chan)
{ {
int d; int d;
ulong l, nw; u32int l, nw;
uchar *p;
Memdata *md; Memdata *md;
Memimage *i; Memimage *i;
@ -86,18 +87,21 @@ _allocmemimage(Rectangle r, ulong chan)
return nil; return nil;
md->ref = 1; md->ref = 1;
md->base = poolalloc(imagmem, (2+nw)*sizeof(ulong)); md->base = poolalloc(imagmem, sizeof(Memdata*)+(1+nw)*sizeof(ulong));
if(md->base == nil){ if(md->base == nil){
free(md); free(md);
return nil; return nil;
} }
md->base[0] = (ulong)md; p = (uchar*)md->base;
md->base[1] = getcallerpc(&r); *(Memdata**)p = md;
p += sizeof(Memdata*);
*(ulong*)p = getcallerpc(&r);
p += sizeof(ulong);
/* if this changes, memimagemove must change too */ /* if this changes, memimagemove must change too */
md->bdata = (uchar*)&md->base[2]; md->bdata = p;
md->allocd = 1; md->allocd = 1;
i = allocmemimaged(r, chan, md, nil); i = allocmemimaged(r, chan, md, nil);
@ -129,7 +133,7 @@ _freememimage(Memimage *i)
ulong* ulong*
wordaddr(Memimage *i, Point p) wordaddr(Memimage *i, Point p)
{ {
return (ulong*) ((ulong)byteaddr(i, p) & ~(sizeof(ulong)-1)); return (ulong*) ((uintptr)byteaddr(i, p) & ~(sizeof(ulong)-1));
} }
uchar* uchar*

View File

@ -21,7 +21,7 @@ getmemdefont(void)
* declared as char*, not ulong*. * declared as char*, not ulong*.
*/ */
p = (char*)defontdata; p = (char*)defontdata;
n = (ulong)p & 3; n = (uintptr)p & 3;
if(n != 0){ if(n != 0){
memmove(p+(4-n), p, sizeofdefont-n); memmove(p+(4-n), p, sizeofdefont-n);
p += 4-n; p += 4-n;

Binary file not shown.

View File

@ -1,8 +1,8 @@
#include "u.h" #include "u.h"
#include "libc.h" #include "libc.h"
ulong uintptr
getcallerpc(void *a) getcallerpc(void *a)
{ {
return ((ulong*)a)[-1]; return ((uintptr*)a)[-1];
} }

View File

@ -1,8 +1,8 @@
#include "u.h" #include "u.h"
#include "libc.h" #include "libc.h"
ulong uintptr
getcallerpc(void *a) getcallerpc(void *a)
{ {
return ((ulong*)a)[-1]; return ((uintptr*)a)[-1];
} }

View File

@ -1,8 +1,8 @@
#include "u.h" #include "u.h"
#include "libc.h" #include "libc.h"
ulong uintptr
getcallerpc(void *a) getcallerpc(void *a)
{ {
return ((ulong*)a)[-1]; return ((uintptr*)a)[-1];
} }