diff options
Diffstat (limited to 'os')
| -rw-r--r-- | os/port/lib.h | 3 | ||||
| -rw-r--r-- | os/port/portdat.h | 2 | ||||
| -rw-r--r-- | os/port/portfns.h | 1 | ||||
| -rw-r--r-- | os/port/xalloc.c | 11 |
4 files changed, 11 insertions, 6 deletions
diff --git a/os/port/lib.h b/os/port/lib.h index d6af4fa5..c9414b5a 100644 --- a/os/port/lib.h +++ b/os/port/lib.h @@ -2,6 +2,9 @@ /* * functions (possibly) linked in, complete, from libc. */ +#define nelem(n) (sizeof(n)/sizeof(n[0])) +#define offsetof(s, m) (ulong)(&(((s*)0)->m)) +#define assert(x) if(x){}else _assert("x") /* * mem routines diff --git a/os/port/portdat.h b/os/port/portdat.h index 103961e0..81e92012 100644 --- a/os/port/portdat.h +++ b/os/port/portdat.h @@ -53,8 +53,6 @@ typedef int Devgen(Chan*, char*, Dirtab*, int, int, Dir*); #include "fcall.h" #include <pool.h> -#define nelem(n) (sizeof(n)/sizeof(n[0])) - struct Ref { Lock l; diff --git a/os/port/portfns.h b/os/port/portfns.h index d6bcdcf0..619be83f 100644 --- a/os/port/portfns.h +++ b/os/port/portfns.h @@ -9,7 +9,6 @@ Block* adjustblock(Block*, int); Block* allocb(int); int anyhigher(void); int anyready(void); -#define assert(x) if(x){}else _assert("assert(x) failed") void _assert(char*); Block* bl2mem(uchar*, Block*, int); int blocklen(Block*); diff --git a/os/port/xalloc.c b/os/port/xalloc.c index 73310089..286881c2 100644 --- a/os/port/xalloc.c +++ b/os/port/xalloc.c @@ -163,9 +163,14 @@ xmerge(void *vp, void *vq) { Xhdr *p, *q; - p = vp; - if((uchar*)vp+p->size == (uchar*)vq) { - q = vq; + p = (Xhdr*)(((ulong)vp - offsetof(Xhdr, data[0]))); + q = (Xhdr*)(((ulong)vq - offsetof(Xhdr, data[0]))); + if(p->magix != Magichole || q->magix != Magichole) { + xsummary(); + panic("xmerge(%#p, %#p) bad magic %#lux, %#lux\n", + vp, vq, p->magix, q->magix); + } + if((uchar*)p+p->size == (uchar*)q) { p->size += q->size; return 1; } |
