ref: 446c14eaf9e886016e86a574e5cb7685f39ff851
parent: f6da1ab12d14fe4db7a76f390d6dfc85de660f1c
author: halfwit <michaelmisch1985@gmail.com>
date: Sun Nov 23 17:24:59 EST 2025
Updates to fix build warnings
--- a/include/lib.h
+++ b/include/lib.h
@@ -233,6 +233,16 @@
typedef struct Tos Tos;
typedef struct Plink Plink;
+struct Plink
+{+ Plink *old;
+ Plink *down;
+ Plink *link;
+ long pc;
+ long count;
+ vlong time;
+};
+
struct Tos {struct /* Per process profiling */
{@@ -240,14 +250,14 @@
Plink *next; /* known to be 4(ptr) */
Plink *last;
Plink *first;
- u32int pid;
- u32int what;
+ ulong pid;
+ ulong what;
} prof;
- u64int cyclefreq; /* cycle clock frequency if there is one, 0 otherwise */
- ulong kcycles; /* cycles spent in kernel */
- ulong pcycles; /* cycles spent in process (kernel + user) */
- u32int pid; /* might as well put the pid here */
- u32int clock;
+ uvlong cyclefreq; /* cycle clock frequency if there is one, 0 otherwise */
+ vlong kcycles; /* cycles spent in kernel */
+ vlong pcycles; /* cycles spent in process (kernel + user) */
+ ulong pid; /* might as well put the pid here */
+ ulong clock;
/* top of stack is here */
};
#pragma pack(pop)
--- a/kern/arm.c
+++ b/kern/arm.c
@@ -110,7 +110,7 @@
offset = - offset;
Rn = up->R + ((instr >> 16) & 15);
Rd = up->R + ((instr >> 12) & 15);
- if (debug)
+ if(debug > 1)
print("single: Rn=%d Rd=%d offset=%.8ux pid=%d\n", ((instr >> 16) & 15), ((instr >> 12) & 15), offset, up->pid);if((instr & (fW | fP)) == fW)
invalid(instr);
@@ -160,7 +160,7 @@
Rm = up->R + (instr & 15);
Rd = up->R + ((instr >> 12) & 15);
Rn = up->R + ((instr >> 16) & 15);
- if(debug)
+ if(debug > 1)
print("swap: Rm=%d Rd=%d Rn=%d pid=%d\n", (instr & 15), ((instr >> 12) & 15), ((instr >> 16) & 15), up->pid);if(Rm == up->R + 15 || Rd == up->R + 15 || Rn == up->R + 15)
invalid(instr);
@@ -253,7 +253,7 @@
case 15: result = ~operand; break;
default: result = 0; /* never happens */
}
- if(debug)
+ if(debug > 1)
print("alu: Rn=%d Rd=%d op=%d operand=%.8ux pid=%d\n", ((instr >> 16) & 15), ((instr >> 12) & 15), ((instr >> 21) & 15), operand, up->pid); if(instr & fS) {up->CPSR &= ~FLAGS;
@@ -279,7 +279,7 @@
if(offset & (1<<23))
offset |= ~((1 << 24) - 1);
offset *= 4;
- if(debug)
+ if(debug > 1)
print("branch: offset=%.8ux pid=%d\n", offset, up->pid);if(instr & fLi)
up->R[14] = up->R[15];
@@ -305,7 +305,7 @@
invalid(instr);
Rn = up->R + ((instr >> 16) & 15);
Rd = up->R + ((instr >> 12) & 15);
- if(debug)
+ if(debug > 1)
print("halfword: Rn=%d, Rd=%d pid=%d\n", ((instr >> 16) & 15), ((instr >> 12) & 15), up->pid); target = *Rn;
if(instr & fP)
@@ -336,7 +336,7 @@
if(instr & (1<<22))
invalid(instr);
Rn = up->R +((instr >> 16) & 15);
- if(debug)
+ if(debug > 1)
print("block: Rn=%d pid=%d\n", ((instr >> 16) & 15), up->pid); targ = evenaddr(*Rn, 3);
if(instr & fU) {@@ -381,7 +381,7 @@
Rs = up->R + ((instr >> 8) & 15);
Rn = up->R + ((instr >> 12) & 15);
Rd = up->R + ((instr >> 16) & 15);
- if(debug)
+ if(debug > 1)
print("multiply: Rm=%d Rs=%d Rn=%d Rd=%d pid=%d\n", (instr & 15), ((instr >> 8) & 15), ((instr >> 12) & 15), ((instr >> 16) & 15), up->pid);if(Rd == Rm || Rm == up->R + 15 || Rs == up->R + 15 || Rn == up->R + 15 || Rd == up->R + 15)
invalid(instr);
@@ -403,7 +403,7 @@
{u32int *RdH, *RdL, *Rs, *Rm;
u64int res;
- if(debug)
+ if(debug > 1)
print("multiplylong\n");Rm = up->R + (instr & 15);
Rs = up->R + ((instr >> 8) & 15);
@@ -437,7 +437,7 @@
{u32int *Rn, *Rd, *Rm, *targ, addr;
Segment *seg;
- if(debug)
+ if(debug > 1)
print("singleex: Rd=%d Rn=%d pid=%d\n", ((instr >> 12) & 15), ((instr >> 16) & 15), up->pid);Rd = up->R + ((instr >> 12) & 15);
Rn = up->R + ((instr >> 16) & 15);
@@ -464,7 +464,7 @@
void
clrex(void)
{- if(debug)
+ if(debug > 1)
print("clrex\n");up->lladdr = 0;
up->llval = 0;
@@ -473,7 +473,7 @@
static void
barrier(void)
{- if(debug)
+ if(debug > 1)
print("barrier\n");static Lock l;
lock(&l);
@@ -484,7 +484,7 @@
step(void)
{u32int instr;
- char *state;
+ //char *state;
Segment *seg;
switch(up->procctl) {--- a/kern/dat.h
+++ b/kern/dat.h
@@ -21,6 +21,7 @@
typedef struct Mntwalk Mntwalk;
typedef struct Mnt Mnt;
typedef struct Mhead Mhead;
+typedef struct Note Note;
typedef struct Path Path;
typedef struct Pgrps Pgrps;
typedef struct Pgrp Pgrp;
@@ -287,6 +288,13 @@
NDebug, /* print debug message */
};
+struct Note
+{+ char msg[ERRMAX];
+ int flag; /* whether system posted it */
+ Ref ref;
+};
+
enum
{RENDLOG = 5,
@@ -368,6 +376,7 @@
int nfd; /* number allocated */
int maxfd; /* highest fd in use */
int exceed; /* debugging */
+ RWlock lk;
};
enum
@@ -435,6 +444,7 @@
uint mach;
ulong pid;
+ ulong noteid;
ulong procmode;
Pgrp *pgrp; /* Process group for namespace */
@@ -474,11 +484,19 @@
Fd *fd; /* fd for syscall emulation */
/* Notes */
+ Note *lastnote;
+ Note *note[NNOTE];
+ short nnote;
+ //short notified; /* sysnoted is due */
+ //int (*notify)(void*, char*);
+
u32int notehandler;
+
int innote;
jmp_buf notejmp;
char notes[ERRMAX][NNOTE];
long notein, noteout;
+
Chan *slash;
Chan *dot;
--- a/kern/devlfd-posix.c
+++ b/kern/devlfd-posix.c
@@ -77,7 +77,7 @@
}
} else {/* Generate by index, starting with 0, 1, 2, then others up to maxfd */
- for(fd = 0, s = s; fd <= fg->maxfd && s >= 0; fd++) {+ for(fd = 0; fd <= fg->maxfd && s >= 0; fd++) {if(fd >= fg->nfd || fg->fd[fd] == nil)
continue;
if(s-- == 0)
--- a/kern/devproc.c
+++ b/kern/devproc.c
@@ -132,8 +132,8 @@
static void
procstopwait(Proc *p, int ctl)
{- char *state;
- int pid;
+ //char *state;
+ //int pid;
/*
if(p->pdbg != nil)
error(Einuse);
@@ -178,23 +178,23 @@
if(f == nil)
error(Eprocdied);
- incref(f);
- lock(f);
+ incref(&f->ref);
+ lock(&f->lk);
while(fd <= f->maxfd){c = f->fd[fd];
if(c != nil){f->fd[fd] = nil;
- unlock(f);
+ unlock(&f->lk);
qunlock(&p->debug);
cclose(c);
qlock(&p->debug);
- lock(f);
+ lock(&f->lk);
}
if(!all)
break;
fd++;
}
- unlock(f);
+ unlock(&f->lk);
closefgrp(f);
}
@@ -354,9 +354,7 @@
int2flag(cm->mflag, flag);
if(strcmp(cm->to->path->s, "#M") == 0){- //srv = cm->to->mchan->srvname;
- if(srv == nil)
- srv = cm->to->mchan->path->s;
+ srv = cm->to->mchan->path->s;
i = snprint(buf, nbuf, *cm->spec?
"mount %s %q %q %q\n": "mount %s %q %q\n", flag,
srv, mh->from->path->s, cm->spec);
--- a/kern/fns.h
+++ b/kern/fns.h
@@ -159,6 +159,7 @@
int pprint(char*, ...);
int procfdprint(Chan*, int, int, char*, int);
void procinit0(void);
+void procrun(void*);
Proc* proctab(int);
void procwired(Proc*, int);
int pullblock(Block**, int);
--- a/kern/procinit.c
+++ b/kern/procinit.c
@@ -103,9 +103,11 @@
p->fgrp = nil;
}
+ if(freemem)
+ freesegs();
+
cclose(p->dot);
cclose(p->slash);
-
free(p);
osexit(msg);
}
--- a/kern/seg.c
+++ b/kern/seg.c
@@ -49,7 +49,7 @@
continue;
ss = *s;
// Assure we don't have any weird state
- if(!ss->dref || ss->dref->ref == 0 || !&ss->ref.ref == 0)
+ if(!ss->dref || ss->dref->ref == 0 || ss->ref.ref != 0)
continue;
if(decref(ss->dref) == 0)
free(ss->dref);
@@ -112,9 +112,9 @@
s = seg[segno];
if(debug > 1)
print("dupseg: segno=%d, type=%d, start=%.8ux, size=%.8ux, share=%d\n", segno, s->type, s->start, s->size, share);- qlock(&s->rw);
+ rlock(&s->rw);
if(waserror()) {- qunlock(&s->rw);
+ runlock(&s->rw);
nexterror();
}
switch(s->type&SG_TYPE) {@@ -136,7 +136,7 @@
case SG_DATA: /* Copy on write plus demand load info */
if(segno == TSEG){n = data2txt(s);
- qunlock(&s->rw);
+ runlock(&s->rw);
poperror();
return n;
}
@@ -148,12 +148,12 @@
if(n != nil && n != s)
memcpy(n->data, s->data, s->size);
- qunlock(&s->rw);
+ runlock(&s->rw);
poperror();
return n;
sameseg:
- incref(s);
- qunlock(&s->rw);
+ incref(&s->ref);
+ runlock(&s->rw);
poperror();
return s;
}
--- a/kern/syscall.c
+++ b/kern/syscall.c
@@ -476,13 +476,13 @@
static void
_sysrendezvous(void)
{- u32int tag, value;
+ uintptr_t tag, value;
tag = arg(0);
value = arg(1);
if(debug)
print("sysrendezvous: tag=%.8ux, value=%.8ux\n", tag, value);- up->R[0] = (u32int) (uintptr)rendezvous((void *)tag, (void *)value);
+ up->R[0] = (u32int)(uintptr_t)(rendezvous((void*)(uintptr_t)tag, (void*)(uintptr_t)value));
if(up->R[0] == ~0)
noteerr(0, 1);
}
--- a/kern/sysproc.c
+++ b/kern/sysproc.c
@@ -21,25 +21,10 @@
#define USTKTOP 0x3FFFFFFFULL
#define USTKSIZE 0x100000
-
-static void
-nop(int x)
-{- USED(x);
-}
-
-static u32int
-arg(int n)
-{- USED(n);
- /* no locking necessary, since we're on the stack */
- return *(u32int*) vaddrnol(up->R[13] + 4 + 4 * n, 4);
-}
-
void
devmask(Pgrp *pgrp, int invert, char *devs)
{- int i, t, w;
+ int t, w;
char *p;
Rune r;
u64int mask[nelem(pgrp->notallowed)];
@@ -290,15 +275,6 @@
up->R[15] = ureg[17];
}
-void
-inittos(Proc *p)
-{- ulong tos;
-
- tos = (USTKTOP & ~7) - sizeof(Tos) * 2;
- ((Tos *) vaddrnol(tos, sizeof(Tos)))->pid = p->pid;
-}
-
static void
initstack(int argc, char **argv)
{@@ -305,6 +281,8 @@
ulong tos, sp, ap, size, i, len;
tos = (USTKTOP & ~7) - sizeof(Tos) * 2;
+ ((Tos *) vaddrnol(tos, sizeof(Tos)))->pid = up->pid;
+
sp = tos;
if(debug > 1)
print("initstack: tos=%.8ux tossz=%.8ux USTKTOP=%.8ux\n", tos, sizeof(Tos), USTKTOP);@@ -331,7 +309,6 @@
ap += len;
}
*(ulong *) vaddrnol(sp, 4) = 0;
- inittos(up);
}
static int
@@ -415,6 +392,8 @@
bsssz = beswal(hdr.bss);
copyname(file);
+
+ // TODO: Notes.
up->notehandler = up->innote = up->notein = up->noteout = 0;
freesegs();
memset(up->R, 0, sizeof(up->R));
@@ -450,8 +429,9 @@
void
-procrun(void*)
+procrun(void *v)
{+ USED(v);
for(;;) {if(debug > 2)
dump();
@@ -471,7 +451,7 @@
Pgrp *opg;
Rgrp *org;
Egrp *oeg;
- char *devs;
+ char *devs = nil;
int i, n;
/* Check flags before we commit */
@@ -579,7 +559,7 @@
}
else {p->fgrp = up->fgrp;
- incref(p->fgrp);
+ incref(&p->fgrp->ref);
}
/* Process groups */
@@ -591,7 +571,7 @@
memmove(p->pgrp->notallowed, up->pgrp->notallowed, sizeof p->pgrp->notallowed);
} else {p->pgrp = up->pgrp;
- incref(p->pgrp);
+ incref(&p->pgrp->ref);
}
if(flag & RFNOMNT)
devmask(p->pgrp, 1, devs);
@@ -599,7 +579,7 @@
if(flag & RFREND)
p->rgrp = newrgrp();
else {- incref(up->rgrp);
+ incref(&up->rgrp->ref);
p->rgrp = up->rgrp;
}
@@ -611,7 +591,7 @@
envcpy(p->egrp, up->egrp);
} else {p->egrp = up->egrp;
- incref(p->egrp);
+ incref(&p->egrp->ref);
}
p->fn = procrun;
p->parent = up;
@@ -625,9 +605,7 @@
unlock(&up->exl);
}
- inittos(p);
osproc(p);
up->child = p;
-
return p->pid;
}
--- a/libauth/attr.c
+++ b/libauth/attr.c
@@ -15,11 +15,11 @@
default:
continue;
case AttrQuery:
- fmtprint(fmt, first+" %q?", a->name);
+ fmtprint(fmt, first ? "%q?" : " %q?", a->name);
break;
case AttrNameval:
case AttrDefault:
- fmtprint(fmt, first+" %q=%q", a->name, a->val);
+ fmtprint(fmt, first ? "%q=%q" : " %q=%q", a->name, a->val);
break;
}
first = 0;
--- a/libsec/tlshand.c
+++ b/libsec/tlshand.c
@@ -330,12 +330,12 @@
int len;
} hashfun[] = {/* [0x00] is reserved for MD5+SHA1 for < TLS1.2 */
- [0x01] {md5, MD5dlen},- [0x02] {sha1, SHA1dlen},- [0x03] {sha2_224, SHA2_224dlen},- [0x04] {sha2_256, SHA2_256dlen},- [0x05] {sha2_384, SHA2_384dlen},- [0x06] {sha2_512, SHA2_512dlen},+ [0x01] = {md5, MD5dlen},+ [0x02] = {sha1, SHA1dlen},+ [0x03] = {sha2_224, SHA2_224dlen},+ [0x04] = {sha2_256, SHA2_256dlen},+ [0x05] = {sha2_384, SHA2_384dlen},+ [0x06] = {sha2_512, SHA2_512dlen},};
// signature algorithms (only RSA and ECDSA at the moment)
@@ -404,7 +404,6 @@
static void* emalloc(int);
static void* erealloc(void*, int);
-static void put32(uchar *p, u32int);
static void put24(uchar *p, int);
static void put16(uchar *p, int);
static int get24(uchar *p);
@@ -2904,15 +2903,6 @@
sysfatal("out of memory");setrealloctag(ReallocP, getcallerpc(&ReallocP));
return(ReallocP);
-}
-
-static void
-put32(uchar *p, u32int x)
-{- p[0] = x>>24;
- p[1] = x>>16;
- p[2] = x>>8;
- p[3] = x;
}
static void
--- a/main.c
+++ b/main.c
@@ -156,15 +156,7 @@
panic("open2: %r");notify(notehandler);
- for(;;) {- if(debug > 2)
- dump();
- step();
- while((up->notein - up->noteout) % NNOTE) {- donote(up->notes[up->noteout % NNOTE], 0);
- up->noteout++;
- }
- }
+ procrun(0);
exits(0);
}
--
⑨