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) {
f->pid = p->pid;
p->busy = 1;
pid = rendezvous(p->pid, (ulong)f);
pid = (uintptr)rendezvous((void*)(uintptr)p->pid, f);
if(pid != p->pid)
fatal("rendezvous sync fail");
return;
@ -459,7 +459,7 @@ slave(Fsrpc *f)
Proclist = p;
DEBUG(DFD, "parent %d rendez\n", pid);
rendezvous(pid, (ulong)p);
rendezvous((void*)(uintptr)pid, p);
DEBUG(DFD, "parent %d went\n", pid);
}
}
@ -479,12 +479,12 @@ blockingslave(void *x)
pid = getpid();
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);
for(;;) {
p = (Fsrpc*)rendezvous(pid, pid);
if((int)p == ~0) /* Interrupted */
p = rendezvous((void*)(uintptr)pid, (void*)(uintptr)pid);
if((uintptr)p == ~(uintptr)0) /* Interrupted */
continue;
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.
* Besides, this is more anal.
*/
if(xscreendepth != DefaultDepth(xdisplay, DefaultScreen(xdisplay)))
xcmap = XCreateColormap(xdisplay, w, xvis, AllocNone);
c = map[19];
/* find out index into colormap for our RGB */

View File

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

View File

@ -236,7 +236,7 @@ extern int fmtprint(Fmt*, char*, ...);
extern int fmtvprint(Fmt*, char*, va_list);
extern void* mallocz(ulong, int);
extern ulong getcallerpc(void*);
extern uintptr getcallerpc(void*);
extern char* cleanname(char*);
extern void sysfatal(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 dec32(uchar*, int, char*, int);
extern int enc32(char*, int, uchar*, int);
extern int enc16(char*, int, uchar*, int);
void hnputs(void *p, unsigned short v);
extern int dofmt(Fmt*, char*);
extern double __NaN(void);

View File

@ -74,13 +74,13 @@ extern int pushssl(int, char*, char*, char*, int*);
extern int iounit(int);
extern long pread(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 getpid(void);
extern void panic(char*, ...);
extern void sleep(int);
extern void osyield(void);
extern void setmalloctag(void*, ulong);
extern void setmalloctag(void*, uintptr);
extern int errstr(char*, uint);
extern int rerrstr(char*, uint);
extern int encrypt(void*, void*, int);

View File

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

View File

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

View File

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

View File

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

View File

@ -867,12 +867,17 @@ drawpoint(Point *p, uchar *a)
p->y = BGLONG(a+1*4);
}
#define isvgascreen(dst) 1
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;
Rectangle r;
Point sp1;
static Memimage *tmp;
fc = &font->fchar[index];
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);
sp1.x = sp->x+fc->left;
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;
sp->x += fc->width;
return p;
@ -1873,6 +1902,7 @@ drawmesg(Client *client, void *av, int n)
clipr = dst->clipr;
dst->clipr = r;
op = drawclientop(client);
l = dst;
if(*a == 'x'){
/* paint background */
l = drawimage(client, a+47);
@ -1901,7 +1931,7 @@ drawmesg(Client *client, void *av, int n)
dst->clipr = clipr;
error(Eindex);
}
q = drawchar(dst, q, src, &sp, font, ci, op);
q = drawchar(dst, l, q, src, &sp, font, ci, op);
u += 2;
}
dst->clipr = clipr;

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -333,7 +333,11 @@ __ifmt(Fmt *f)
break;
}
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';
fl |= FmtUnsigned;
}else if(fl & FmtVLong){

View File

@ -38,7 +38,7 @@ lock(Lock *lk)
for(;;) {
if(canlock(lk))
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);
}
}

View File

@ -224,7 +224,7 @@ fmtstrtod(const char *as, char **aas)
/* close approx by naive conversion */
mid[0] = 0;
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[1] = mid[1]*10;
if(i >= 8)

View File

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

View File

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

Binary file not shown.

View File

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

View File

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

View File

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