ref: 4fb336e4ff1334afaef71baa4d7d4d6aa77e51ed
parent: f9deac96f486835bdef70ec5c6f7353cb7269c67
author: joe9 <[email protected]>
date: Wed Jul 7 17:29:07 EDT 2021
changes for a working wm/wm
--- a/FreeBSD/386/include/lib9.h
+++ b/FreeBSD/386/include/lib9.h
@@ -41,7 +41,7 @@
typedef unsigned int Rune;
typedef long long int vlong;
typedef unsigned long long int uvlong;
-typedef unsigned int u32int;
+typedef unsigned int u32;
typedef uvlong u64int;
typedef unsigned int mpdigit; /* for /sys/include/mp.h */
--- a/emu/port/dat.h
+++ b/emu/port/dat.h
@@ -388,7 +388,7 @@
int type; /* interpreter or not */
char text[KNAMELEN];
Proc* qnext; /* list of processes waiting on a Qlock */
- long pid;
+ u32 pid;
Proc* next; /* list of created processes */
Proc* prev;
Lock rlock; /* sync between sleep/swiproc for r */
@@ -417,8 +417,9 @@
void *os; /* host os specific data */
};
-#define poperror() up->nerr--
-#define waserror() (up->nerr++, ossetjmp(up->estack[up->nerr-1]))
+extern void showjmpbuf(char *);
+#define poperror() (up->nerr--, showjmpbuf("poperror"))
+#define waserror() (showjmpbuf("waserror"), up->nerr++, ossetjmp(up->estack[up->nerr-1]))
enum
{
--- a/emu/port/devmnt.c
+++ b/emu/port/devmnt.c
@@ -759,7 +759,7 @@
cn = "?";
if(r->c != nil && r->c->name != nil)
cn = r->c->name->s;
- print("mnt: proc %s %lud: mismatch from %s %s rep 0x%p tag %d fid %d T%d R%d rp %d\n",
+ print("mnt: proc %s %ud: mismatch from %s %s rep 0x%p tag %d fid %d T%d R%d rp %d\n",
up->text, up->pid, sn, cn,
r, r->request.tag, r->request.fid, r->request.type,
r->reply.type, r->reply.tag);
--- a/emu/port/devprof.c
+++ b/emu/port/devprof.c
@@ -332,7 +332,7 @@
static long
profread(Chan *c, void *va, long n, vlong offset)
{
- int i;
+ intptr i;
Record *r;
char *a = va;
@@ -349,7 +349,7 @@
case Qpath:
return readstr(offset, va, n, r->path);
case Qhist:
- i = (int)c->aux;
+ i = (intptr)c->aux;
while(i < r->size && r->bucket[i] == 0)
i++;
if(i >= r->size)
--- a/emu/port/exception.c
+++ b/emu/port/exception.c
@@ -7,6 +7,8 @@
#include "kernel.h"
#include "raise.h"
+#define DP if(0){}else print
+
static int
ematch(char *pat, char *exp)
{
@@ -89,8 +91,8 @@
Prog *p;
Modlink *m, *mr;
int str, ne;
- ulong pc, newpc;
- long eoff;
+ intptr pc, newpc;
+ intptr eoff;
uchar *fp, **eadr;
Frame *f;
Type *t, *zt;
@@ -99,14 +101,16 @@
void *v;
p = currun();
- if(*estr == 0 || p == nil)
+ if(*estr == 0 || p == nil){
return 0;
+ }
str = p->exval == H || D2H(p->exval)->t == &Tstring;
m = R.M;
- if(m->compiled)
- pc = (ulong)R.PC-(ulong)m->prog;
- else
+ if(m->compiled){
+ pc = (uintptr)R.PC-(uintptr)m->prog;
+ }else{
pc = R.PC-m->prog;
+ }
pc--;
fp = R.FP;
@@ -140,7 +144,7 @@
if(f->mr != nil)
m = f->mr;
if(m->compiled)
- pc = (ulong)f->lr-(ulong)m->prog;
+ pc = (uintptr)f->lr-(uintptr)m->prog;
else
pc = f->lr-m->prog;
pc--;
@@ -158,7 +162,7 @@
n = 10+1+strlen(name)+1+strlen(estr)+1;
p->exstr = realloc(p->exstr, n);
if(p->exstr != nil)
- snprint(p->exstr, n, "%lud %s %s", pc, name, estr);
+ snprint(p->exstr, n, "%zd %s %s", pc, name, estr);
}
/*
@@ -203,7 +207,7 @@
*eadr = p->exval;
}
if(m->compiled)
- R.PC = (Inst*)((ulong)m->prog+newpc);
+ R.PC = (Inst*)((uintptr)m->prog+newpc);
else
R.PC = m->prog+newpc;
memmove(&p->R, &R, sizeof(R));
--- a/emu/port/exportfs.c
+++ b/emu/port/exportfs.c
@@ -287,7 +287,7 @@
}
if(exdebug)
- print("export %ld <- %F\n", up->pid, &q->in);
+ print("export %d <- %F\n", up->pid, &q->in);
q->out.type = type+1;
q->out.tag = q->in.tag;
@@ -339,9 +339,9 @@
if(exdebug){
if(n < 0)
- print("exportproc %ld shut down: %s\n", up->pid, up->env->errstr);
+ print("exportproc %d shut down: %s\n", up->pid, up->env->errstr);
else
- print("exportproc %ld shut down\n", up->pid);
+ print("exportproc %d shut down\n", up->pid);
}
free(q);
@@ -471,7 +471,7 @@
exfree(Export *fs)
{
if(exdebug)
- print("export p/s %ld free %p ref %ld\n", up->pid, fs, fs->r.ref);
+ print("export p/s %d free %p ref %ld\n", up->pid, fs, fs->r.ref);
if(decref(&fs->r) != 0)
return;
closepgrp(fs->pgrp);
@@ -543,10 +543,10 @@
kstrdup(&up->env->user, q->export->user);
if(exdebug > 1)
- print("exslave %ld dispatch %F\n", up->pid, &q->in);
+ print("exslave %d dispatch %F\n", up->pid, &q->in);
if(waserror()){
- print("exslave %ld err %s\n", up->pid, up->env->errstr); /* shouldn't happen */
+ print("exslave %d err %s\n", up->pid, up->env->errstr); /* shouldn't happen */
err = up->env->errstr;
}else{
if(q->in.type >= Tmax || !fcalls[q->in.type]){
@@ -633,7 +633,7 @@
}
if(exdebug)
- print("%s %ld -> %F\n", who, up->pid, r);
+ print("%s %d -> %F\n", who, up->pid, r);
if(!waserror()){
devtab[fs->io->type]->write(fs->io, q->buf, n, 0);
--- a/emu/port/kproc-pthreads.c
+++ b/emu/port/kproc-pthreads.c
@@ -2,6 +2,8 @@
#include "fns.h"
#include "error.h"
+#define DP if(1){}else print
+
#undef _POSIX_C_SOURCE
#undef getwd
@@ -189,10 +191,13 @@
osblock(void)
{
Osdep *os;
+ int i;
+ DP("osblock %d %s\n", errno, strerror(errno));
os = up->os;
- while(sem_wait(&os->sem))
- {} /* retry on signals (which shouldn't happen) */
+ while(i=sem_wait(&os->sem)){
+ DP("osblock sem_wait returned %d, errno %d %s\n",i, errno, strerror(errno));
+ } /* retry on signals (which shouldn't happen) */
}
void
--- a/emu/port/qio.c
+++ b/emu/port/qio.c
@@ -412,7 +412,7 @@
return 0;
memset(b, 0, sizeof(Block));
- addr = (ulong)b + sizeof(Block);
+ addr = (uintptr)b + sizeof(Block);
b->base = (uchar*)addr;
b->lim = b->base + size;
b->rp = b->base;
--- a/emu/port/random.c
+++ b/emu/port/random.c
@@ -113,7 +113,7 @@
p = xp;
-if(0)print("A%ld.%d.%lux|", n, rb.target, getcallerpc(&xp));
+if(0)print("A%ld.%d.%zx|", n, rb.target, getcallerpc(&xp));
if(waserror()){
qunlock(&rb.l);
nexterror();
--- a/emu/port/sysfile.c
+++ b/emu/port/sysfile.c
@@ -438,6 +438,7 @@
c0.c = nil;
if(waserror()) {
+ print("kbind error new %s\n", new);
cclose(c0.c);
return -1;
}
--- a/include/draw.h
+++ b/include/draw.h
@@ -147,14 +147,14 @@
Ncomp = 12,
} Drawop;
-extern char* chantostr(char*, u32);
-extern u32 strtochan(char*);
-extern int chantodepth(u32);
+extern char* chantostr(char*, u32int);
+extern u32int strtochan(char*);
+extern int chantodepth(u32int);
struct Point
{
- s32 x;
- s32 y;
+ s32int x;
+ s32int y;
};
struct Rectangle
@@ -168,7 +168,7 @@
struct Screen
{
Display *display; /* display holding data */
- s32 id; /* id of system-held Screen */
+ s32int id; /* id of system-held Screen */
Image *image; /* unused; for reference only */
Image *fill; /* color to paint behind windows */
};
@@ -184,20 +184,20 @@
struct Display
{
void* qlock;
- s32 locking; /*program is using lockdisplay */
- s32 dirno;
+ s32int locking; /*program is using lockdisplay */
+ s32int dirno;
void *datachan;
void *refchan;
void *ctlchan;
- s32 imageid;
- s32 local;
- s32 depth;
- u32 chan;
+ s32int imageid;
+ s32int local;
+ s32int depth;
+ u32int chan;
void (*error)(Display*, char*);
char *devdir;
char *windir;
char oldlabel[64];
- u32 dataqid;
+ u32int dataqid;
Image *white;
Image *black;
Image *image;
@@ -204,7 +204,7 @@
Image *opaque;
Image *transparent;
uchar buf[Displaybufsize+1]; /* +1 for flush message */
- s32 bufsize;
+ s32int bufsize;
uchar *bufp;
Font *defaultfont;
Subfont *defaultsubfont;
@@ -217,12 +217,12 @@
struct Image
{
Display *display; /* display holding data */
- s32 id; /* id of system-held Image */
+ s32int id; /* id of system-held Image */
Rectangle r; /* rectangle in data area, local coords */
Rectangle clipr; /* clipping region */
- s32 depth; /* number of bits per pixel */
- u32 chan;
- s32 repl; /* flag: data replicates to tile clipr */
+ s32int depth; /* number of bits per pixel */
+ u32int chan;
+ s32int repl; /* flag: data replicates to tile clipr */
Screen *screen; /* 0 if not a window */
Image *next; /* next in list of windows */
Reffn reffn;
@@ -231,15 +231,15 @@
struct RGB
{
- u32 red;
- u32 green;
- u32 blue;
+ u32int red;
+ u32int green;
+ u32int blue;
};
/*
* Subfonts
*
- * given char c, Subfont *f, Fontchar *i, and Pos32 p, one says
+ * given char c, Subfont *f, Fontchar *i, and Pos32int p, one says
* i = f->info+c;
* draw(b, Rect(p.x+i->left, p.y+i->top,
* p.x+i->left+((i+1)->x-i->x), p.y+i->bottom),
@@ -250,7 +250,7 @@
struct Fontchar
{
- s32 x; /* left edge of bits */
+ s32int x; /* left edge of bits */
uchar top; /* first non-zero scan-line */
uchar bottom; /* last non-zero scan-line + 1 */
char left; /* offset of baseline */
@@ -265,7 +265,7 @@
char ascent; /* top of image to baseline */
Fontchar *info; /* n+1 character descriptors */
Image *bits; /* of font */
- s32 ref;
+ s32int ref;
};
enum
@@ -289,7 +289,7 @@
{
Rune min; /* lowest rune value to be taken from subfont */
Rune max; /* highest rune value+1 to be taken from subfont */
- s32 offset; /* position in subfont of character at min */
+ s32int offset; /* position in subfont of character at min */
char *name; /* stored in font */
char *subfontname; /* to access subfont */
};
@@ -305,7 +305,7 @@
struct Cachesubf
{
- u32 age; /* for replacement */
+ u32int age; /* for replacement */
Cachefont *cf; /* font info that owns us */
Subfont *f; /* attached subfont */
};
@@ -318,10 +318,10 @@
s16int ascent; /* top of image to baseline */
s16int width; /* widest so far; used in caching only */
s16int nsub; /* number of subfonts */
- u32 age; /* increasing counter; used for LRU */
- s32 maxdepth; /* maximum depth of all loaded subfonts */
- s32 ncache; /* size of cache */
- s32 nsubf; /* size of subfont list */
+ u32int age; /* increasing counter; used for LRU */
+ s32int maxdepth; /* maximum depth of all loaded subfonts */
+ s32int ncache; /* size of cache */
+ s32int nsubf; /* size of subfont list */
Cacheinfo *cache;
Cachesubf *subf;
Cachefont **sub; /* as read from file */
@@ -334,8 +334,8 @@
/*
* Image management
*/
-extern Image* _allocimage(Image*, Display*, Rectangle, u32, int, u32, int, int);
-extern Image* allocimage(Display*, Rectangle, u32, int, u32);
+extern Image* _allocimage(Image*, Display*, Rectangle, u32int, int, u32int, int, int);
+extern Image* allocimage(Display*, Rectangle, u32int, int, u32int);
extern uchar* bufimage(Display*, int);
extern int bytesperline(Rectangle, int);
extern void closedisplay(Display*);
@@ -358,7 +358,7 @@
extern int writeimage(int, Image*, int);
extern Image* namedimage(Display*, char*);
extern int nameimage(Image*, char*, int);
-extern Image* allocimagemix(Display*, u32, u32);
+extern Image* allocimagemix(Display*, u32int, u32int);
/*
* Colors
@@ -365,18 +365,18 @@
*/
extern void readcolmap(Display*, RGB*);
extern void writecolmap(Display*, RGB*);
-extern u32 setalpha(u32, uchar);
+extern u32int setalpha(u32int, uchar);
/*
* Windows
*/
extern Screen* allocscreen(Image*, Image*, int);
-extern Image* _allocwindow(Image*, Screen*, Rectangle, int, u32);
-extern Image* allocwindow(Screen*, Rectangle, int, u32);
+extern Image* _allocwindow(Image*, Screen*, Rectangle, int, u32int);
+extern Image* allocwindow(Screen*, Rectangle, int, u32int);
extern void bottomnwindows(Image**, int);
extern void bottomwindow(Image*);
extern int freescreen(Screen*);
-extern Screen* publicscreen(Display*, int, u32);
+extern Screen* publicscreen(Display*, int, u32int);
extern void topnwindows(Image**, int);
extern void topwindow(Image*);
extern int originwindow(Image*, Point, Point);
@@ -384,8 +384,8 @@
/*
* Geometry
*/
-extern Point Pt(s32, s32);
-extern Rectangle Rect(s32, s32, s32, s32);
+extern Point Pt(s32int, s32int);
+extern Rectangle Rect(s32int, s32int, s32int, s32int);
extern Rectangle Rpt(Point, Point);
extern Point addpt(Point, Point);
extern Point subpt(Point, Point);
@@ -408,8 +408,8 @@
extern int rgb2cmap(int, int, int);
extern int cmap2rgb(int);
extern int cmap2rgba(int);
-extern void icossin(int, s32*, s32*);
-extern void icossin2(s32, s32, s32*, s32*);
+extern void icossin(int, s32int*, s32int*);
+extern void icossin2(s32int, s32int, s32int*, s32int*);
/*
* Graphics
@@ -513,9 +513,9 @@
extern int _drawdebug; /* set to 1 to see errors from flushimage */
#define BG16INT(p) (((p)[0]<<0) | ((p)[1]<<8))
-#define BG32INT(p) ((s32)((BG16INT(p)<<0) | (BG16INT(p+2)<<16)))
+#define BG32INT(p) ((s32int)((BG16INT(p)<<0) | (BG16INT(p+2)<<16)))
#define BP16INT(p, v) ((p)[0]=(v), (p)[1]=((v)>>8))
-#define BP32INT(p, v) (BP16INT(p, ((s32)v)), BP16INT(p+2, ((s32)v)>>16))
+#define BP32INT(p, v) (BP16INT(p, ((s32int)v)), BP16INT(p+2, ((s32int)v)>>16))
/*
* Compressed image file parameters
@@ -529,7 +529,7 @@
extern int _compblocksize(Rectangle, int);
/* XXX backwards helps; should go */
-extern u32 drawld2chan[];
+extern u32int drawld2chan[];
extern void drawsetdebug(int);
/*
@@ -549,7 +549,7 @@
*/
#define IRECT(r) ((Rectangle){IPOINT((r).min),IPOINT((r).max)})
#define DRECT(r) ((Draw_Rect){DPOINT((r).min),DPOINT((r).max)})
-#define IPOINT(p) ((Point){(s32)((p).x),(s32)((p).y)})
+#define IPOINT(p) ((Point){(s32int)((p).x),(s32int)((p).y)})
#define DPOINT(p) ((Draw_Point){(p).x,(p).y})
#define P2P(p1, p2) (p1).x = (p2).x, (p1).y = (p2).y
--- a/include/dynld.h
+++ b/include/dynld.h
@@ -38,7 +38,7 @@
extern Dynobj* dynloadgen(void*, long (*r)(void*,void*,long), vlong (*s)(void*,vlong,int), void (*e)(char*), Dynsym*, int, ulong);
extern long dynmagic(void);
extern void dynobjfree(Dynobj*);
-extern char* dynreloc(uchar*, ulong, int, Dynsym**, int);
+extern char* dynreloc(uchar*, uintptr, int, Dynsym**, int);
extern int dyntabsize(Dynsym*);
extern Dynsym _exporttab[]; /* created by linker -x (when desired) */
--- a/include/memdraw.h
+++ b/include/memdraw.h
@@ -21,9 +21,9 @@
{
uintptr *base; /* allocated data pointer */
uchar *bdata; /* pointer to first byte of actual data; word-aligned */
- s32 ref; /* number of Memimages using this data */
+ s32int ref; /* number of Memimages using this data */
void* imref;
- s32 allocd; /* is this malloc'd? */
+ s32int allocd; /* is this malloc'd? */
};
enum {
@@ -39,20 +39,20 @@
{
Rectangle r; /* rectangle in data area, local coords */
Rectangle clipr; /* clipping region */
- s32 depth; /* number of bits of storage per pixel */
- s32 nchan; /* number of channels */
- u32 chan; /* channel descriptions */
+ s32int depth; /* number of bits of storage per pixel */
+ s32int nchan; /* number of channels */
+ u32int chan; /* channel descriptions */
Memcmap *cmap;
Memdata *data; /* pointer to data; shared by windows in this image */
- s32 zero; /* data->bdata+zero==&byte containing (0,0) */
- u32 width; /* width in words of a single scan line */
+ s32int zero; /* data->bdata+zero==&byte containing (0,0) */
+ u32int width; /* width in words of a single scan line */
Memlayer *layer; /* nil if not a layer*/
- u32 flags;
+ u32int flags;
- s32 shift[NChan];
- s32 mask[NChan];
- s32 nbits[NChan];
+ s32int shift[NChan];
+ s32int mask[NChan];
+ s32int nbits[NChan];
};
struct Memcmap
@@ -101,14 +101,14 @@
Rectangle sr;
Memimage *mask;
Rectangle mr;
- s32 op;
+ s32int op;
- u32 state;
- u32 mval; /* if Simplemask, the mask pixel in mask format */
- u32 mrgba; /* mval in rgba */
- u32 sval; /* if Simplesrc, the source pixel in src format */
- u32 srgba; /* sval in rgba */
- u32 sdval; /* sval in dst format */
+ u32int state;
+ u32int mval; /* if Simplemask, the mask pixel in mask format */
+ u32int mrgba; /* mval in rgba */
+ u32int sval; /* if Simplesrc, the source pixel in src format */
+ u32int srgba; /* sval in rgba */
+ u32int sdval; /* sval in dst format */
};
/*
@@ -115,8 +115,8 @@
* Memimage management
*/
-extern Memimage* allocmemimage(Rectangle, u32);
-extern Memimage* allocmemimaged(Rectangle, u32, Memdata*);
+extern Memimage* allocmemimage(Rectangle, u32int);
+extern Memimage* allocmemimaged(Rectangle, u32int, Memdata*);
extern Memimage* readmemimage(int);
extern Memimage* creadmemimage(int);
extern int writememimage(int, Memimage*);
@@ -124,11 +124,11 @@
extern int loadmemimage(Memimage*, Rectangle, uchar*, int);
extern int cloadmemimage(Memimage*, Rectangle, uchar*, int);
extern int unloadmemimage(Memimage*, Rectangle, uchar*, int);
-extern u32* u32addr(Memimage*, Point);
+extern u32int* u32addr(Memimage*, Point);
extern uchar* byteaddr(Memimage*, Point);
extern int drawclip(Memimage*, Rectangle*, Memimage*, Point*, Memimage*, Point*, Rectangle*, Rectangle*);
-extern void memfillcolor(Memimage*, u32);
-extern int memsetchan(Memimage*, u32);
+extern void memfillcolor(Memimage*, u32int);
+extern int memsetchan(Memimage*, u32int);
/*
* Graphics
--- a/include/memlayer.h
+++ b/include/memlayer.h
@@ -18,7 +18,7 @@
Memscreen *screen; /* screen this layer belongs to */
Memimage *front; /* window in front of this one */
Memimage *rear; /* window behind this one*/
- s32 clear; /* layer is fully visible */
+ s32int clear; /* layer is fully visible */
Memimage *save; /* save area for obscured parts */
Refreshfn refreshfn; /* function to call to refresh obscured parts if save==nil */
void *refreshptr; /* argument to refreshfn */
@@ -34,7 +34,7 @@
* All these functions accept screen coordinates, not local ones.
*/
void _memlayerop(void (*fn)(Memimage*, Rectangle, Rectangle, void*, int), Memimage*, Rectangle, Rectangle, void*);
-Memimage* memlalloc(Memscreen*, Rectangle, Refreshfn, void*, u32);
+Memimage* memlalloc(Memscreen*, Rectangle, Refreshfn, void*, u32int);
void memldelete(Memimage*);
void memlfree(Memimage*);
void memltofront(Memimage*);
--- a/include/pool.h
+++ b/include/pool.h
@@ -17,7 +17,7 @@
struct Bhdr
{
u32 magic;
- u32 size;
+ uintptr size;
union {
uchar data[1];
struct {
@@ -31,7 +31,7 @@
#define csize u.l.size
struct {
Bhdr* link;
- int size;
+ intptr size;
} l;
} u;
};
--- a/include/tk.h
+++ b/include/tk.h
@@ -131,12 +131,12 @@
TkBlinkinterval = 500
};
-#define TKSTRUCTALIGN 4
+#define TKSTRUCTALIGN (sizeof(intptr)) /*4*/
#define TKI2F(i) ((i)*Tkfpscalar)
extern int TKF2I(int);
/*#define TKF2I(f) (((f) + Tkfpscalar/2)/Tkfpscalar)*/
#define IAUX(i) ((void*)i)
-#define AUXI(i) ((int)i)
+#define AUXI(i) ((intptr)i)
#define TKKEY(i) ((i)&0xFFFF)
typedef struct Tk Tk;
@@ -563,6 +563,10 @@
void* wreq; /* really chan of string */
void* di; /* really Draw_Image* */
void* wmctxt; /* really Draw_Wmcontext */
+ intptr screenr_min_x; /* for Draw_Rect fields due to the sleaze below */
+ intptr screenr_min_y;
+ intptr screenr_max_x;
+ intptr screenr_max_y;
Rectangle screenr; /* XXX sleazy equiv to Draw_Rect, but what else? */
/* Private from here on */
@@ -756,8 +760,8 @@
extern Point tkscrn2local(Tk*, Point);
extern int tkvisiblerect(Tk *tk, Rectangle *rr);
extern Point tkanchorpoint(Rectangle, Point, int);
-extern char* tkfrac(char**, int*, TkEnv*);
-extern char* tkfracword(TkTop*, char**, int*, TkEnv*);
+extern char* tkfrac(char**, s32int*, TkEnv*);
+extern char* tkfracword(TkTop*, char**, s32int*, TkEnv*);
extern char* tkfprint(char*, int);
extern char* tkvalue(char**, char*, ...);
extern void tkdirty(Tk *);
--- a/lib9/dofmt.c
+++ b/lib9/dofmt.c
@@ -334,7 +334,11 @@
vu = 0;
u = 0;
if(f->r == 'p'){
- u = (ulong)va_arg(f->args, void*);
+ if(sizeof(void*) == sizeof(uvlong)){
+ isv = 1;
+ vu = (uvlong)va_arg(f->args, void*);
+ } else
+ u = (ulong)va_arg(f->args, void*);
f->r = 'x';
fl |= FmtUnsigned;
}else if(fl & FmtVLong){
@@ -511,6 +515,11 @@
if(f->flags & FmtLong)
f->flags |= FmtVLong;
f->flags |= FmtLong;
+ break;
+ case 'z':
+ f->flags |= FmtLong;
+ if(sizeof(intptr) == sizeof(vlong))
+ f->flags |= FmtVLong;
break;
}
return 1;
--- a/lib9/fmt.c
+++ b/lib9/fmt.c
@@ -55,6 +55,7 @@
's', _strfmt,
'u', _flagfmt,
'x', _ifmt,
+ 'z', _flagfmt,
0, nil,
};
--- a/libdraw/allocimagemix.c
+++ b/libdraw/allocimagemix.c
@@ -2,7 +2,7 @@
#include "draw.h"
Image*
-allocimagemix(Display *d, u32int color1, u32int color3)
+allocimagemix(Display *d, u32 color1, u32 color3)
{
Image *t, *b;
static Image *qmask;
--- a/libdraw/arith.c
+++ b/libdraw/arith.c
@@ -2,7 +2,7 @@
#include "draw.h"
Point
-Pt(s32int x, s32int y)
+Pt(s32 x, s32 y)
{
Point p;
@@ -12,7 +12,7 @@
}
Rectangle
-Rect(s32int x, s32int y, s32int bx, s32int by)
+Rect(s32 x, s32 y, s32 bx, s32 by)
{
Rectangle r;
@@ -158,7 +158,7 @@
r1->max.y = r2.max.y;
}
-u32int
+u32
drawld2chan[] = {
GREY1,
GREY2,
@@ -166,8 +166,8 @@
CMAP8,
};
-u32int
-setalpha(u32int color, uchar alpha)
+u32
+setalpha(u32 color, uchar alpha)
{
int red, green, blue;
--- a/libdraw/bytesperline.c
+++ b/libdraw/bytesperline.c
@@ -5,7 +5,7 @@
int
unitsperline(Rectangle r, int d, int bitsperunit)
{
- ulong l, t;
+ u32 l, t;
if(r.min.x >= 0){
l = (r.max.x*d+bitsperunit-1)/bitsperunit;
@@ -20,7 +20,7 @@
int
wordsperline(Rectangle r, int d)
{
- return unitsperline(r, d, 8*sizeof(ulong));
+ return unitsperline(r, d, 8*sizeof(u32));
}
int
--- a/libdraw/chan.c
+++ b/libdraw/chan.c
@@ -3,9 +3,9 @@
static char channames[] = "rgbkamx";
char*
-chantostr(char *buf, u32int cc)
+chantostr(char *buf, u32 cc)
{
- u32int c, rc;
+ u32 c, rc;
char *p;
if(chantodepth(cc) == 0)
@@ -35,11 +35,11 @@
return c==' ' || c== '\t' || c=='\r' || c=='\n';
}
-u32int
+u32
strtochan(char *s)
{
char *p, *q;
- u32int c;
+ u32 c;
int t, n;
c = 0;
@@ -61,7 +61,7 @@
}
int
-chantodepth(u32int c)
+chantodepth(u32 c)
{
int n;
--- a/libdraw/creadimage.c
+++ b/libdraw/creadimage.c
@@ -10,7 +10,7 @@
int m, nb, miny, maxy, new, ldepth, ncblock;
uchar *buf, *a;
Image *i;
- u32int chan;
+ u32 chan;
int font;
font = dolock&2;
--- a/libdraw/getdefont.c
+++ b/libdraw/getdefont.c
@@ -15,7 +15,7 @@
/*
* make sure data is word-aligned. this is true with Plan 9 compilers
* but not in general. the byte order is right because the data is
- * declared as char*, not u32int*.
+ * declared as char*, not u32*.
*/
p = (char*)defontdata;
n = (uintptr)p & 3;
--- a/libdraw/init.c
+++ b/libdraw/init.c
@@ -65,7 +65,7 @@
Image *image;
Dir *dir;
void *q;
- ulong chan;
+ u32 chan;
fmtinstall('P', Pfmt);
fmtinstall('R', Rfmt);
@@ -74,7 +74,7 @@
if(win == 0)
win = "/dev";
if(strlen(dev)>sizeof buf-25 || strlen(win)>sizeof buf-25){
- kwerrstr("initdisplay: directory name too long");
+ kwerrstr("initdisplay: directory name too short");
return nil;
}
t = strdup(win);
--- a/libdraw/loadimage.c
+++ b/libdraw/loadimage.c
@@ -5,7 +5,7 @@
int
loadimage(Image *i, Rectangle r, uchar *data, int ndata)
{
- s32int dy;
+ s32 dy;
int n, bpl, roff, dstroff, lskip, llen, y;
uchar *a;
int chunk;
--- a/libdraw/readcolmap.c
+++ b/libdraw/readcolmap.c
@@ -2,10 +2,10 @@
#include "draw.h"
#include "bio.h"
-static ulong
+static u32
getval(char **p)
{
- ulong v;
+ u32 v;
char *q;
v = strtoul(*p, &q, 0);
--- a/libdraw/readimage.c
+++ b/libdraw/readimage.c
@@ -13,7 +13,7 @@
int miny, maxy;
Rectangle r;
int ldepth;
- ulong chan;
+ u32 chan;
uchar *tmp;
Image *i;
--- a/libdraw/rectclip.c
+++ b/libdraw/rectclip.c
@@ -1,6 +1,8 @@
#include "lib9.h"
#include "draw.h"
+#define DP if(1){}else print
+
int
rectclip(Rectangle *rp, Rectangle b) /* first by reference, second by value */
{
@@ -8,6 +10,22 @@
/*
* Expand rectXrect() in line for speed
*/
+ DP("rectclip rp->min.x %d < bp->max.x %d &&\n"
+ "\tbp->min.x %d<rp->max.x %d &&\n"
+ "\trp->min.y %d<bp->max.y %d &&\n"
+ "\tbp->min.y %d<rp->max.y %d,"
+ "\tcond %d %d %d %d\n\t%d %d\n\t%d\n",
+ rp->min.x,bp->max.x , bp->min.x,rp->max.x ,
+ rp->min.y,bp->max.y , bp->min.y,rp->max.y,
+
+ rp->min.x<bp->max.x, bp->min.x<rp->max.x,
+ rp->min.y<bp->max.y, bp->min.y<rp->max.y,
+
+ rp->min.x<bp->max.x && bp->min.x<rp->max.x,
+ rp->min.y<bp->max.y && bp->min.y<rp->max.y,
+
+ rp->min.x<bp->max.x && bp->min.x<rp->max.x &&
+ rp->min.y<bp->max.y && bp->min.y<rp->max.y);
if((rp->min.x<bp->max.x && bp->min.x<rp->max.x &&
rp->min.y<bp->max.y && bp->min.y<rp->max.y)==0)
return 0;
--- a/libdraw/rgb.c
+++ b/libdraw/rgb.c
@@ -46,7 +46,7 @@
rgb2cmap(int cr, int cg, int cb)
{
int i, r, g, b, sq;
- ulong rgb;
+ u32 rgb;
int best, bestsq;
best = 0;
--- a/libdraw/writecolmap.c
+++ b/libdraw/writecolmap.c
@@ -13,7 +13,7 @@
{
int i, n, fd;
char buf[64], *t;
- ulong r, g, b;
+ u32 r, g, b;
sprint(buf, "/dev/draw/%d/colormap", d->dirno);
fd = open(buf, OWRITE);
@@ -27,7 +27,7 @@
r = m[i].red>>24;
g = m[i].green>>24;
b = m[i].blue>>24;
- n += sprint(t+n, "%d %lud %lud %lud\n", 255-i, r, g, b);
+ n += sprint(t+n, "%d %d %d %d\n", 255-i, r, g, b);
}
i = libwrite(fd, t, n);
free(t);
--- a/libdraw/writeimage.c
+++ b/libdraw/writeimage.c
@@ -23,8 +23,8 @@
int h; /* hash value */
uchar *line, *eline; /* input line, end pointer */
uchar *data, *edata; /* input buffer, end pointer */
- ulong n; /* length of input buffer */
- ulong nb; /* # of bytes returned by unloadimage */
+ uintptr n; /* length of input buffer */
+ u32 nb; /* # of bytes returned by unloadimage */
int bpl; /* input line length */
int offs, runlen; /* offset, length of consumed data */
uchar dumpbuf[NDUMP]; /* dump accumulator */
@@ -172,7 +172,7 @@
if(loutp == outbuf)
goto ErrOut;
n = loutp-outbuf;
- sprint(hdr, "%11d %11ld ", r.max.y, n);
+ sprint(hdr, "%11d %11lzd ", r.max.y, n);
libwrite(fd, hdr, 2*12);
libwrite(fd, outbuf, n);
r.min.y = r.max.y;
--- a/libdynld/dynld-amd64.c
+++ b/libdynld/dynld-amd64.c
@@ -11,17 +11,17 @@
}
char*
-dynreloc(uchar *b, ulong p, int m, Dynsym **tab, int ntab)
+dynreloc(uchar *b, uintptr p, int m, Dynsym **tab, int ntab)
{
int i;
- ulong v, *pp;
+ uintptr v, *pp;
- p += (ulong)b;
- pp = (ulong*)p;
+ p += (uintptr)b;
+ pp = (uintptr*)p;
v = *pp;
switch(m){
case 0:
- v += (ulong)b;
+ v += (uintptr)b;
break;
case 1:
i = v>>22;
--- a/libinterp/draw.c
+++ b/libinterp/draw.c
@@ -1819,7 +1819,7 @@
Draw_icossin(void *fp)
{
F_Draw_icossin *f;
- s32int s, c;
+ s32 s, c;
f = fp;
icossin(f->deg, &s, &c);
@@ -1831,7 +1831,7 @@
Draw_icossin2(void *fp)
{
F_Draw_icossin2 *f;
- s32int s, c;
+ s32 s, c;
f = fp;
icossin2(f->p.x, f->p.y, &s, &c);
--- a/libinterp/heapaudit.c
+++ b/libinterp/heapaudit.c
@@ -98,7 +98,7 @@
{
Audit **h, *a;
- for(h = &ahash[((ulong)t>>2)%nelem(ahash)]; (a = *h) != nil; h = &a->hash)
+ for(h = &ahash[((uintptr)t>>2)%nelem(ahash)]; (a = *h) != nil; h = &a->hash)
if(a->t == t)
break;
return h;
--- a/libinterp/tk.c
+++ b/libinterp/tk.c
@@ -83,6 +83,7 @@
Tk *tk;
Heap *h;
TkTop *t;
+ Tk_Toplevel *tl;
TkWin *tkw;
TkCtxt *ctxt;
Display *disp;
@@ -96,6 +97,7 @@
h = heapz(fakeTkTop);
t = H2D(TkTop*, h);
+ tl = (Tk_Toplevel*)t;
poolimmutable(h);
t->dd = f->d;
@@ -137,6 +139,7 @@
}
t->ctxt = ctxt;
t->screenr = disp->image->r;
+ tl->screenr = DRECT(t->screenr);
tkw->next = t->windows;
t->windows = tk;
@@ -151,15 +154,18 @@
Tk_cmd(void *a)
{
TkTop *t;
+ Tk_Toplevel *tl;
char *val, *e;
F_Tk_cmd *f = a;
t = (TkTop*)f->t;
+ tl = (Tk_Toplevel*)t;
if(t == H || D2H(t)->t != fakeTkTop) {
retstr(TkNotop, f->ret);
return;
}
lockctxt(t->ctxt);
+ t->screenr = IRECT(tl->screenr);
val = nil;
e = tkexec(t, string2c(f->arg), &val);
unlockctxt(t->ctxt);
@@ -177,6 +183,7 @@
retstr(e == nil ? val : e, f->ret);
if(tkwiretap != nil)
tkwiretap(t, string2c(f->arg), val, nil, nil);
+ tl->screenr = DRECT(t->screenr);
free(val);
}
@@ -197,19 +204,22 @@
F_Tk_rect *f = fp;
Tk *tk;
TkTop *t;
+ Tk_Toplevel *tl;
Rectangle r;
Point o;
int bd, flags, w, h;
t = (TkTop*)f->t;
+ tl = (Tk_Toplevel*)t;
if(t == H || D2H(t)->t != fakeTkTop){
- *(Rectangle*)f->ret = ZR;
+ *f->ret = DRECT(ZR);
return;
}
lockctxt(t->ctxt);
+ t->screenr = IRECT(tl->screenr);
tk = tklook(t, string2c(f->name), 0);
if(tk == nil){
- *(Rectangle*)f->ret = ZR;
+ *f->ret = DRECT(ZR);
unlockctxt(t->ctxt);
return;
}
@@ -242,7 +252,8 @@
r.max.x = r.min.x + w;
r.max.y = r.min.y + h;
}
- *(Rectangle*)f->ret = r;
+ *f->ret = DRECT(r);
+ tl->screenr = DRECT(t->screenr);
}
int
@@ -325,11 +336,13 @@
TkMouse m;
TkCtxt *c;
TkTop *t, *ot;
+ Tk_Toplevel *tl;
int d, dtype, etype;
F_Tk_pointer *f = a;
int b, lastb, inside;
t = (TkTop*)f->t;
+ tl = (Tk_Toplevel*)t;
if(t == H || D2H(t)->t != fakeTkTop)
return;
@@ -347,6 +360,7 @@
* target is the widget that we're deliver the mouse event to.
* inside is true if the mouse point is located inside target.
*/
+ t->screenr = IRECT(tl->screenr);
inside = 1;
if (c->mgrab != nil && (c->mgrab->flag & Tknograb)) {
fw = tkfindfocus(t, f->p.xy.x, f->p.xy.y, 1);
@@ -464,6 +478,7 @@
c->focused = 0;
tkenterleave(t);
}
+ tl->screenr = DRECT(t->screenr);
unlockctxt(c);
}
@@ -472,10 +487,12 @@
{
Tk *grab;
TkTop *t;
+ Tk_Toplevel *tl;
TkCtxt *c;
F_Tk_keyboard *f = a;
t = (TkTop*)f->t;
+ tl = (Tk_Toplevel*)t;
if(t == H || D2H(t)->t != fakeTkTop)
return;
c = t->ctxt;
@@ -482,6 +499,7 @@
if (c == nil)
return;
lockctxt(c);
+ t->screenr = IRECT(tl->screenr);
if (c->tkmenu != nil)
grab = c->tkmenu;
else
@@ -494,6 +512,7 @@
t = grab->env->top;
tkdeliver(grab, TkKey|TKKEY(f->key), nil);
tkupdate(t);
+ tl->screenr = DRECT(t->screenr);
unlockctxt(c);
}
@@ -555,10 +574,12 @@
Heap *h;
TkVar *v;
TkTop *t;
+ Tk_Toplevel *tl;
char *name;
F_Tk_namechan *f = a;
t = (TkTop*)f->t;
+ tl = (Tk_Toplevel*)t;
if(t == H || D2H(t)->t != fakeTkTop) {
retstr(TkNotop, f->ret);
return;
@@ -574,6 +595,7 @@
}
lockctxt(t->ctxt);
+ t->screenr = IRECT(tl->screenr);
v = tkmkvar(t, name, TkVchan);
if(v == nil) {
unlockctxt(t->ctxt);
@@ -587,6 +609,7 @@
}
destroy(v->value);
v->value = f->c;
+ tl->screenr = DRECT(t->screenr);
unlockctxt(t->ctxt);
h = D2H(v->value);
h->ref++;
@@ -767,6 +790,7 @@
Tk_putimage(void *a)
{
TkTop *t;
+ Tk_Toplevel *tl;
TkImg *tki;
Image *i, *m, *oldi, *oldm;
int locked, found, reqid, n;
@@ -784,6 +808,7 @@
destroy(r);
t = (TkTop*)f->t;
+ tl = (Tk_Toplevel*)t;
if(t == H || D2H(t)->t != fakeTkTop) {
retstr(TkNotop, f->ret);
return;
@@ -796,6 +821,7 @@
name = string2c(f->name);
lockctxt(t->ctxt);
+ t->screenr = IRECT(tl->screenr);
e = nil;
found = 0;
if(name[0] == '.'){
@@ -858,6 +884,7 @@
tksizeimage(t->root, tki);
}
Error:
+ tl->screenr = DRECT(t->screenr);
unlockctxt(t->ctxt);
if(e != nil)
retstr(e, f->ret);
@@ -898,6 +925,7 @@
char *n;
TkImg *i;
TkTop *t;
+ Tk_Toplevel *tl;
int locked;
Display *d;
F_Tk_getimage *f;
@@ -918,6 +946,7 @@
destroy(r);
t = (TkTop*)f->t;
+ tl = (Tk_Toplevel*)t;
if(t == H || D2H(t)->t != fakeTkTop) {
retstr(TkNotop, &f->ret->t2);
return;
@@ -925,6 +954,7 @@
d = t->ctxt->display;
n = string2c(f->name);
lockctxt(t->ctxt);
+ t->screenr = IRECT(tl->screenr);
i = tkname2img(t, n);
if (i != nil) {
image = i->img;
@@ -944,6 +974,7 @@
f->ret->t1 = tkimgcopy(t, mask);
if (locked)
unlockdisplay(d);
+ tl->screenr = DRECT(t->screenr);
unlockctxt(t->ctxt);
}
--- a/libmath/dtoa.c
+++ b/libmath/dtoa.c
@@ -36,11 +36,11 @@
#define word1(x) ((FPdbleword*)&x)->lo
#else
#ifdef __LITTLE_ENDIAN
-#define word0(x) ((u32 *)&x)[1]
-#define word1(x) ((u32 *)&x)[0]
+#define word0(x) ((u32int *)&x)[1]
+#define word1(x) ((u32int *)&x)[0]
#else
-#define word0(x) ((u32 *)&x)[0]
-#define word1(x) ((u32 *)&x)[1]
+#define word0(x) ((u32int *)&x)[0]
+#define word1(x) ((u32int *)&x)[1]
#endif
#endif
@@ -89,7 +89,7 @@
Bigint {
struct Bigint *next;
int k, maxwds, sign, wds;
- u32 x[1];
+ u32int x[1];
};
typedef struct Bigint Bigint;
@@ -107,7 +107,7 @@
freelist[k] = rv->next;
} else {
x = 1 << k;
- rv = (Bigint * )malloc(sizeof(Bigint) + (x - 1) * sizeof(u32));
+ rv = (Bigint * )malloc(sizeof(Bigint) + (x - 1) * sizeof(u32int));
if(rv == nil)
return nil;
rv->k = k;
@@ -130,14 +130,14 @@
}
#define Bcopy(x,y) memmove((char *)&x->sign, (char *)&y->sign, \
-y->wds*sizeof(s32) + 2*sizeof(s32))
+y->wds*sizeof(s32int) + 2*sizeof(s32int))
static Bigint *
multadd(Bigint *b, int m, int a) /* multiply by m and add a */
{
int i, wds;
- u32 * x, y;
- u32 xi, z;
+ u32int * x, y;
+ u32int xi, z;
Bigint * b1;
wds = b->wds;
@@ -164,11 +164,11 @@
}
static Bigint *
-s2b(const char *s, int nd0, int nd, u32 y9)
+s2b(const char *s, int nd0, int nd, u32int y9)
{
Bigint * b;
int i, k;
- s32 x, y;
+ s32int x, y;
x = (nd + 8) / 9;
for (k = 0, y = 1; x > y; y <<= 1, k++)
@@ -192,7 +192,7 @@
}
static int
-hi0bits(register u32 x)
+hi0bits(register u32int x)
{
register int k = 0;
@@ -221,10 +221,10 @@
}
static int
-lo0bits(u32 *y)
+lo0bits(u32int *y)
{
register int k;
- register u32 x = *y;
+ register u32int x = *y;
if (x & 7) {
if (x & 1)
@@ -279,9 +279,9 @@
{
Bigint * c;
int k, wa, wb, wc;
- u32 carry, y, z;
- u32 * x, *xa, *xae, *xb, *xbe, *xc, *xc0;
- u32 z2;
+ u32int carry, y, z;
+ u32int * x, *xa, *xae, *xb, *xbe, *xc, *xc0;
+ u32int z2;
if (a->wds < b->wds) {
c = a;
@@ -387,7 +387,7 @@
{
int i, k1, n, n1;
Bigint * b1;
- u32 * x, *x1, *xe, z;
+ u32int * x, *x1, *xe, z;
n = k >> 5;
k1 = b->k;
@@ -421,7 +421,7 @@
static int
cmp(Bigint *a, Bigint *b)
{
- u32 * xa, *xa0, *xb, *xb0;
+ u32int * xa, *xa0, *xb, *xb0;
int i, j;
i = a->wds;
@@ -446,9 +446,9 @@
{
Bigint * c;
int i, wa, wb;
- s32 borrow, y; /* We need signed shifts here. */
- u32 * xa, *xae, *xb, *xbe, *xc;
- s32 z;
+ s32int borrow, y; /* We need signed shifts here. */
+ u32int * xa, *xae, *xb, *xbe, *xc;
+ s32int z;
i = cmp(a, b);
if (!i) {
@@ -501,7 +501,7 @@
static double
ulp(double x)
{
- register s32 L;
+ register s32int L;
double a;
L = (word0(x) & Exp_mask) - (P - 1) * Exp_msk1;
@@ -529,7 +529,7 @@
static double
b2d(Bigint *a, int *e)
{
- u32 * xa, *xa0, w, y, z;
+ u32int * xa, *xa0, w, y, z;
int k;
double d;
#define d0 word0(d)
@@ -566,7 +566,7 @@
{
Bigint * b;
int de, i, k;
- u32 * x, y, z;
+ u32int * x, y, z;
#define d0 word0(d)
#define d1 word1(d)
@@ -679,8 +679,8 @@
e, e1, esign, i, j, k, nd, nd0, nf, nz, nz0, sign;
const char * s, *s0, *s1;
double aadj, aadj1, adj, rv, rv0;
- s32 L;
- u32 y, z;
+ s32int L;
+ u32int y, z;
Bigint * bb, *bb1, *bd, *bd0, *bs, *delta;
sign = nz0 = nz = 0;
rv = 0.;
@@ -1163,11 +1163,11 @@
quorem(Bigint *b, Bigint *S)
{
int n;
- s32 borrow, y;
- u32 carry, q, ys;
- u32 * bx, *bxe, *sx, *sxe;
- s32 z;
- u32 si, zs;
+ s32int borrow, y;
+ u32int carry, q, ys;
+ u32int * bx, *bxe, *sx, *sxe;
+ s32int z;
+ u32int si, zs;
n = S->wds;
if (b->wds < n)
@@ -1235,9 +1235,9 @@
{
int j, k, *r;
- j = sizeof(u32);
+ j = sizeof(u32int);
for (k = 0;
- sizeof(Bigint) - sizeof(u32) - sizeof(int) + j <= i;
+ sizeof(Bigint) - sizeof(u32int) - sizeof(int) + j <= i;
j <<= 1)
k++;
r = (int * )Balloc(k);
@@ -1347,10 +1347,10 @@
int bbits, b2, b5, be, dig, i, ieps, ilim, ilim0, ilim1,
j, j1, k, k0, k_check, leftright, m2, m5, s2, s5,
spec_case, try_quick;
- s32 L;
+ s32int L;
#ifndef Sudden_Underflow
int denorm;
- u32 x;
+ u32int x;
#endif
Bigint * b, *b1, *delta, *mlo, *mhi, *S;
double d2, ds, eps;
--- a/libtk/canvs.c
+++ b/libtk/canvs.c
@@ -580,7 +580,7 @@
tkcvstags(Tk *tk, char *arg, char **val, int af)
{
TkTop *o;
- int x, y;
+ s32 x, y;
TkName *f;
TkCtag *t, *tt;
char *fmt;
@@ -1719,7 +1719,7 @@
tkcvsmove(Tk *tk, char *arg, char **val)
{
TkCtag *t;
- int fx, fy;
+ s32 fx, fy;
TkTop *top;
TkCpoints *p;
TkName *tag;
@@ -1856,10 +1856,10 @@
}
static char*
-tkcvsview(Tk *tk, char *arg, char **val, int nl, int *posn, int min, int max, int inc)
+tkcvsview(Tk *tk, char *arg, char **val, s32 nl, s32 *posn, s32 min, s32 max, int inc)
{
TkTop *t;
- int top, bot, diff, amount;
+ s32 top, bot, diff, amount;
char *e;
char buf[Tkmaxitem], *v;
@@ -1950,7 +1950,7 @@
* fits these criteria.
*/
static int
-tkadjustvis(int *posn, int c0, int c1, int s0, int s1, int spref)
+tkadjustvis(s32 *posn, s32 c0, s32 c1, s32 s0, s32 s1, int spref)
{
int d, v;
@@ -2028,7 +2028,8 @@
tkcvssee(Tk *tk, char *arg, char **val)
{
Rectangle r;
- int n, coords[4];
+ int n;
+ s32 coords[4];
char *e;
USED(val);
--- a/libtk/carcs.c
+++ b/libtk/carcs.c
@@ -189,7 +189,8 @@
TkCarc *a;
Rectangle d;
int w, dx, dy;
- int s, ext, s0, s1, e0, e1, l;
+ int s, ext, l;
+ s32 s0, s1, e0, e1;
Image *pen, *col, *tmp;
Point p0, p1, c;
extern void drawarc(Point,int,int,int,int,int,Image *,Image *,Image *);
--- a/libtk/ebind.c
+++ b/libtk/ebind.c
@@ -261,7 +261,7 @@
else if((event & (TkEmouse|TkEnter)))
c += snprint(c, len, "%d", m->b);
else if((event & TkFocusin))
- c += snprint(c, len, "%d", (int)data);
+ c += snprint(c, len, "%zd", (intptr)data);
else
goto def;
break;
--- a/libtk/listb.c
+++ b/libtk/listb.c
@@ -716,7 +716,7 @@
static char*
tklistbview(Tk *tk, char *arg, char **val, int nl, int *posn, int max)
{
- int top, bot, amount;
+ s32 top, bot, amount;
char buf[Tkmaxitem];
char *v, *e;
--- a/libtk/panel.c
+++ b/libtk/panel.c
@@ -228,7 +228,7 @@
}
static char*
-tkpanelcvt(Tk *tk, char *arg, int rel, int *p)
+tkpanelcvt(Tk *tk, char *arg, s32 rel, s32 *p)
{
char buf[Tkmaxitem];
@@ -334,7 +334,8 @@
tkpaneldirty(Tk *tk, char *arg, char **val)
{
char buf[Tkmaxitem];
- int n, coords[4];
+ int n;
+ s32 coords[4];
Rectangle r;
char *e, *p;
TkPanel *tkp = TKobj(TkPanel, tk);
--- a/libtk/parse.c
+++ b/libtk/parse.c
@@ -467,7 +467,7 @@
static char*
pdist(TkTop *t, TkOption *o, void *place, char **str, char *buf, char *ebuf)
{
- s32int d;
+ s32 d;
char *e;
TkEnv *env;
@@ -513,7 +513,7 @@
{
Tk *tk;
char *e;
- s32int d, off;
+ s32 d, off;
USED(ebuf);
e = tkfracword(t, str, &d, OPTION(place, TkEnv*, AUXI(o->aux)));
@@ -832,7 +832,7 @@
char *p, *q, *e;
int R, G, B, A;
int i, len, alen;
- s32int alpha;
+ s32 alpha;
/*
* look for alpha modifier in *#AA or *0.5 format
*/
@@ -1005,7 +1005,7 @@
{
char *p, *e;
int i, *v;
- s32int n, d;
+ s32 n, d;
*str = tkword(t, *str, buf, ebuf, nil);
--- a/libtk/scale.c
+++ b/libtk/scale.c
@@ -9,7 +9,7 @@
typedef struct TkScale TkScale;
struct TkScale
{
- int value;
+ s32 value;
int bigi;
int digits;
int digwidth;
@@ -589,7 +589,7 @@
char*
tkscaleposn(TkEnv *env, Tk *tk, char *arg, int *z)
{
- int x, y;
+ s32 x, y;
TkScale *tks = TKobj(TkScale, tk);
char *e;
@@ -640,7 +640,8 @@
static char*
tkscalecoords(Tk *tk, char *arg, char **val)
{
- int p, x, y, l, value;
+ int p, x, y, l;
+ s32 value;
TkScale *tks = TKobj(TkScale, tk);
char *e;
@@ -673,7 +674,8 @@
static char*
tkscaleget(Tk *tk, char *arg, char **val)
{
- int x, y, value, v, l;
+ s32 x, y;
+ int value, v, l;
char buf[Tkminitem], *e;
TkScale *tks = TKobj(TkScale, tk);
@@ -754,7 +756,7 @@
static char*
tkscaledrag(Tk *tk, char *arg, char **val)
{
- int x, y, v;
+ s32 x, y, v;
char *e, buf[Tkmaxitem], f[32];
TkScale *tks = TKobj(TkScale, tk);
--- a/libtk/scrol.c
+++ b/libtk/scrol.c
@@ -22,12 +22,12 @@
int dragbot;
int jump; /* Jump scroll enable */
int flag; /* Display flags */
- int top; /* Top fraction */
- int bot; /* Bottom fraction */
- int a1; /* Pixel top/left arrow1 */
- int t1; /* Pixel top/left trough */
- int t2; /* Pixel top/left lower trough */
- int a2; /* Pixel top/left arrow2 */
+ s32 top; /* Top fraction */
+ s32 bot; /* Bottom fraction */
+ s32 a1; /* Pixel top/left arrow1 */
+ s32 t1; /* Pixel top/left trough */
+ s32 t2; /* Pixel top/left lower trough */
+ s32 a2; /* Pixel top/left arrow2 */
char* cmd;
};
--- a/libtk/textw.c
+++ b/libtk/textw.c
@@ -130,7 +130,7 @@
static void tktextcursordraw(Tk *, int);
static char* tktsetscroll(Tk*, int);
static void tktsetclip(Tk *);
-static char* tktview(Tk*, char*, char**, int, int*, int, int);
+static char* tktview(Tk*, char*, char**, int, s32*, int, int);
static Interval tkttranslate(Tk*, Interval, int);
static void tktfixscroll(Tk*, Point);
static void tktnotdrawn(Tk*, int, int, int);
@@ -1770,9 +1770,10 @@
}
static char*
-tktview(Tk *tk, char *arg, char **val, int nl, int *posn, int max, int orient)
+tktview(Tk *tk, char *arg, char **val, int nl, s32 *posn, int max, int orient)
{
- int top, bot, amount, n;
+ s32 top, bot, amount;
+ int n;
char buf[Tkminitem], *v, *e;
if(*arg == '\0') {
@@ -3570,7 +3571,7 @@
}
static void
-tkadjpage(Tk *tk, int ody, int *dy)
+tkadjpage(Tk *tk, s32 ody, s32 *dy)
{
int y, a, b, d;
TkTindex ix;
--- a/libtk/utils.c
+++ b/libtk/utils.c
@@ -1394,7 +1394,7 @@
* Parse a floating point number into a decimal fixed point representation
*/
char*
-tkfrac(char **arg, s32int *f, TkEnv *env)
+tkfrac(char **arg, s32 *f, TkEnv *env)
{
int c, minus, i, fscale, seendigit;
char *p, *e;
@@ -1446,7 +1446,7 @@
}
char*
-tkfracword(TkTop *t, char **arg, s32int *f, TkEnv *env)
+tkfracword(TkTop *t, char **arg, s32 *f, TkEnv *env)
{
char *p;
char buf[Tkminitem];
--- a/libtk/windw.c
+++ b/libtk/windw.c
@@ -498,7 +498,7 @@
}
static void
-tkfintervalintersect(int min1, int max1, int min2, int max2, int *min, int *max)
+tkfintervalintersect(s32 min1, s32 max1, s32 min2, s32 max2, s32 *min, s32 *max)
{
if (min1 < min2)
min1 = min2;
--- a/limbo/asm.c
+++ b/limbo/asm.c
@@ -81,17 +81,17 @@
Case *c;
Label *lab;
Decl *id;
- u32int dv[2];
- s32int e, last, esz, dotlen, idlen;
+ u32 dv[2];
+ s32 e, last, esz, dotlen, idlen;
int i;
switch(n->ty->kind){
case Tbyte:
- Bprint(bout, "\tbyte\t@mp+%ld,%d\n", offset, (s32int)n->val & 0xff);
+ Bprint(bout, "\tbyte\t@mp+%ld,%d\n", offset, (s32)n->val & 0xff);
break;
case Tint:
case Tfix:
- Bprint(bout, "\tword\t@mp+%ld,%d\n", offset, (s32int)n->val);
+ Bprint(bout, "\tword\t@mp+%ld,%d\n", offset, (s32)n->val);
break;
case Tbig:
Bprint(bout, "\tlong\t@mp+%ld,%lld # %.16llux\n", offset, n->val, n->val);
@@ -117,7 +117,7 @@
Bprint(bout, "\tword\t@mp+%ld,%d", offset, c->nlab);
for(i = 0; i < c->nlab; i++){
lab = &c->labs[i];
- Bprint(bout, ",%d,%d,%zd", (s32int)lab->start->val, (s32int)lab->stop->val+1, lab->inst->pc);
+ Bprint(bout, ",%d,%d,%zd", (s32)lab->start->val, (s32)lab->stop->val+1, lab->inst->pc);
}
Bprint(bout, ",%zd\n", c->iwild ? c->iwild->pc : -1);
break;
@@ -159,7 +159,7 @@
case Tany:
break;
case Tarray:
- Bprint(bout, "\tarray\t@mp+%ld,$%d,%d\n", offset, n->ty->tof->decl->desc->id, (s32int)n->left->val);
+ Bprint(bout, "\tarray\t@mp+%ld,$%d,%d\n", offset, n->ty->tof->decl->desc->id, (s32)n->left->val);
if(n->right == nil)
break;
Bprint(bout, "\tindir\t@mp+%ld,0\n", offset);
@@ -188,9 +188,9 @@
break;
case Tiface:
if(LDT)
- Bprint(bout, "\tword\t@ldt+%ld,%d\n", offset, (s32int)n->val);
+ Bprint(bout, "\tword\t@ldt+%ld,%d\n", offset, (s32)n->val);
else
- Bprint(bout, "\tword\t@mp+%ld,%d\n", offset, (s32int)n->val);
+ Bprint(bout, "\tword\t@mp+%ld,%d\n", offset, (s32)n->val);
offset += IBY2WD;
for(id = n->decl->ty->ids; id != nil; id = id->next){
offset = align(offset, IBY2WD);
--- a/limbo/dis.c
+++ b/limbo/dis.c
@@ -440,7 +440,7 @@
static void
disbig(long off, Long v)
{
- u32int iv;
+ u32 iv;
disflush(DEFL, off, IBY2LG);
iv = v >> 32;
@@ -459,8 +459,8 @@
static void
disreal(long off, Real v)
{
- u32int bv[2];
- u32int iv;
+ u32 bv[2];
+ u32 iv;
disflush(DEFF, off, IBY2LG);
dtocanon(v, bv);
--- a/limbo/dtocanon.c
+++ b/limbo/dtocanon.c
@@ -1,9 +1,9 @@
#include "limbo.h"
void
-dtocanon(double f, u32int v[])
+dtocanon(double f, u32 v[])
{
- union { double d; u32int ul[2]; } a;
+ union { double d; u32 ul[2]; } a;
a.d = 1.;
if(a.ul[0]){
@@ -18,9 +18,9 @@
}
double
-canontod(u32int v[2])
+canontod(u32 v[2])
{
- union { double d; u32int ul[2]; } a;
+ union { double d; u32 ul[2]; } a;
a.d = 1.;
if(a.ul[0]) {
--- a/limbo/ecom.c
+++ b/limbo/ecom.c
@@ -2458,7 +2458,7 @@
Decl *d;
Sym *s;
char buf[32];
- u32int dv[2];
+ u32 dv[2];
dtocanon(n->rval, dv);
seprint(buf, buf+sizeof(buf), ".f.%.8ux.%8ux", dv[0], dv[1]);
--- a/limbo/fns.h
+++ b/limbo/fns.h
@@ -37,7 +37,7 @@
Ok callcast(Node*, int, int);
void callcom(Src*, int, Node*, Node*);
Type* calltype(Type*, Node*, Type*);
-double canontod(u32int v[2]);
+double canontod(u32 v[2]);
void casecheck(Node *cn, Type *ret);
int casecmp(Type*, Node*, Node*);
void casecom(Node*);
@@ -86,7 +86,7 @@
int dotconv(Fmt*);
char *dotprint(char*, char*, Decl*, int);
Type *dottype(Type*, Decl*);
-void dtocanon(double, u32int[2]);
+void dtocanon(double, u32[2]);
Decl *dupdecl(Decl*);
Decl *dupdecls(Decl*);
Node *dupn(int, Src*, Node*);
@@ -313,7 +313,7 @@
#pragma varargck argpos seprint 3
void shareloc(Decl*);
int shiftchk(Node*);
-u32int sign(Decl*);
+u32 sign(Decl*);
Node *simplify(Node*);
Szal sizeids(Decl*, long);
void sizetype(Type*);
--- a/limbo/limbo.h
+++ b/limbo/limbo.h
@@ -40,7 +40,7 @@
typedef struct Typelist Typelist;
typedef double Real;
-typedef vlong Long;
+typedef s64int Long;
enum
{
@@ -138,7 +138,7 @@
{
Src src;
ushort op;
- long pc;
+ intptr pc;
uchar reach; /* could a control path reach this instruction? */
uchar sm; /* operand addressing modes */
uchar mm;
@@ -420,9 +420,9 @@
#define PARENS 1
#define TEMP 2
-#define FNPTRA 4 /* argument */
-#define FNPTR2 8 /* 2nd parameter */
-#define FNPTRN 16 /* use -ve offset */
+#define FNPTRA 8/*4*/ /* argument */
+#define FNPTR2 16/*8*/ /* 2nd parameter */
+#define FNPTRN 32/*16*/ /* use -ve offset */
#define FNPTR (FNPTRA|FNPTR2|FNPTRN)
struct Node
@@ -526,7 +526,7 @@
uchar align; /* alignment in bytes */
uchar flags;
int sbl; /* slot in .sbl adt table */
- long sig; /* signature for dynamic type check */
+ u32 sig; /* signature for dynamic type check */
long size; /* storage required, in bytes */
Decl *decl;
Type *tof;
--- a/limbo/optim.c
+++ b/limbo/optim.c
@@ -768,7 +768,7 @@
long reg;
if(br != nil){
- print("$%ld", br->pc);
+ print("$%zd", br->pc);
return;
}
reg = a->reg;
@@ -815,7 +815,7 @@
pins(Inst *i)
{
/* print("%L %ld ", i->src.start, i->pc); */
- print(" %ld ", i->pc);
+ print(" %zd ", i->pc);
if(i->op < MAXDIS)
print("%s", instname[i->op]);
else
@@ -1734,17 +1734,17 @@
k = SS(o->size) != 0;
if(j != k){
if(!(j == 0 && k == 1 && i == ILEA))
- fatal("S %ld %s\n", o-opflags, instname[i]);
+ fatal("S %zd %s\n", o-opflags, instname[i]);
}
j = (o->flags&(Muse|Mdef)) != 0;
k = SM(o->size) != 0;
if(j != k)
- fatal("M %ld %s\n", o-opflags, instname[i]);
+ fatal("M %zd %s\n", o-opflags, instname[i]);
j = (o->flags&(Duse|Ddef)) != 0;
k = SD(o->size) != 0;
if(j != k){
if(!(j == 1 && k == 0 && (i == IGOTO || i == ICASE || i == ICASEC || i == ICASEL)))
- fatal("D %ld %s\n", o-opflags, instname[i]);
+ fatal("D %zd %s\n", o-opflags, instname[i]);
}
o++;
}
--- a/limbo/sbl.c
+++ b/limbo/sbl.c
@@ -213,9 +213,9 @@
if(ispoly(f))
rmfnptrs(f);
if(f->dot != nil && f->dot->ty->kind == Tadt)
- Bprint(bsym, "%ld:%s.%s\n", f->pc->pc, f->dot->sym->name, f->sym->name);
+ Bprint(bsym, "%zd:%s.%s\n", f->pc->pc, f->dot->sym->name, f->sym->name);
else
- Bprint(bsym, "%ld:%s\n", f->pc->pc, f->sym->name);
+ Bprint(bsym, "%zd:%s\n", f->pc->pc, f->sym->name);
sbldecl(f->ty->ids, Darg);
sbldecl(f->locals, Dlocal);
sbltype(f->ty->tof, 0);
--- a/limbo/types.c
+++ b/limbo/types.c
@@ -3537,7 +3537,7 @@
* sign the same information used
* for testing type equality
*/
-u32int
+u32
sign(Decl *d)
{
Type *t;
--- a/os/boot/rpcg/libg.h
+++ b/os/boot/rpcg/libg.h
@@ -383,9 +383,9 @@
extern int _cursorfd;
#define BGSHORT(p) (((p)[0]<<0) | ((p)[1]<<8))
-#define BGLONG(p) ((BGSHORT(p)<<0) | (BGSHORT(p+2)<<16))
+#define BG32INT(p) ((s32int)((BGSHORT(p)<<0) | (BGSHORT(p+2)<<16)))
#define BPSHORT(p, v) ((p)[0]=(v), (p)[1]=((v)>>8))
-#define BPLONG(p, v) (BPSHORT(p, (v)), BPSHORT(p+2, (v)>>16))
+#define BP32INT(p, v) (BPSHORT(p, ((s32int)v)), BPSHORT(p+2, ((s32int)v)>>16))
ulong *wordaddr(Bitmap*, Point);
uchar *byteaddr(Bitmap*, Point);