vx32

Local 9vx git repository for patches.
git clone git://r-36.net/vx32
Log | Files | Refs

commit 18eaeecfea75a51c05f8d00e1a9c9421e23afb2f
parent 87bedba4a2005a117ba26a28f7dee4120cb2274f
Author: Jesus Galan Lopez (yiyus) <yiyu.jgl@gmail.com>
Date:   Mon,  7 Jun 2010 21:20:10 +0200

fixes to compile in FreeBSD

Diffstat:
src/9vx/main.c | 5+++++
src/9vx/mmu.c | 26+++++++++++++++++++-------
2 files changed, 24 insertions(+), 7 deletions(-)

diff --git a/src/9vx/main.c b/src/9vx/main.c @@ -758,8 +758,13 @@ sigsegv(int signo, siginfo_t *info, void *v) #elif defined(__FreeBSD__) mcontext_t *mc; mc = &uc->uc_mcontext; +#ifdef __i386__ eip = mc->mc_eip; esp = mc->mc_esp; +#elif defined(__amd64__) + eip = mc->mc_rip; + esp = mc->mc_rsp; +#endif addr = (ulong)info->si_addr; if(__FreeBSD__ < 7){ /* diff --git a/src/9vx/mmu.c b/src/9vx/mmu.c @@ -35,6 +35,19 @@ static Uspace uspace[16]; static Uspace *ulist[nelem(uspace)]; int nuspace = 1; +#ifdef __i386__ +#define BIT32 0 +#define HINT nil +#elif defined(__amd64__) +#ifdef linux +#define BIT32 MAP_32BIT +#define HINT nil +#elif defined(__FreeBSD__) +#define BIT32 MAP_FIXED +#define HINT (caddr_t)0x40000000 +#endif +#endif + int isuaddr(void *v) { @@ -56,15 +69,14 @@ mapzero(void) { int fd, bit32; void *v; + void *hint; -#ifdef i386 - bit32 = 0; -#else - bit32 = MAP_32BIT; -#endif + bit32 = BIT32; + hint = HINT; + /* First try mmaping /dev/zero. Some OS'es don't allow this. */ if((fd = open("/dev/zero", O_RDONLY)) >= 0){ - v = mmap(nil, USTKTOP, PROT_NONE, bit32|MAP_PRIVATE, fd, 0); + v = mmap(hint, USTKTOP, PROT_NONE, bit32|MAP_PRIVATE, fd, 0); if(v != MAP_FAILED) { if((uint32_t)(uintptr)v != (uintptr)v) { iprint("mmap returned 64-bit pointer %p\n", v); @@ -75,7 +87,7 @@ mapzero(void) } /* Next try an anonymous map. */ - v = mmap(nil, USTKTOP, PROT_NONE, bit32|MAP_PRIVATE|MAP_ANONYMOUS, -1, 0); + v = mmap(hint, USTKTOP, PROT_NONE, bit32|MAP_PRIVATE|MAP_ANONYMOUS, -1, 0); if(v != MAP_FAILED) { if((uint32_t)(uintptr)v != (uintptr)v) { iprint("mmap returned 64-bit pointer %p\n", v);