From f564ce6a2c7d8a27291d1745ba18a6b2724e3cfb Mon Sep 17 00:00:00 2001 From: Ragnvald Maartmann-Moe IV Date: Mon, 4 Feb 2002 17:24:46 +0000 Subject: [PATCH] Fix compiling linux target for use on non-linux systems. Doesn't fix my puzzlement on why people do these things. ;) --- linux/q_shlinux.c | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/linux/q_shlinux.c b/linux/q_shlinux.c index 9c2b090..cd063b5 100644 --- a/linux/q_shlinux.c +++ b/linux/q_shlinux.c @@ -65,6 +65,7 @@ void *Hunk_Alloc (int size) return buf; } +#ifdef mremap int Hunk_End (void) { byte *n; @@ -76,6 +77,32 @@ int Hunk_End (void) return curhunksize; } +#else +int Hunk_End (void) +{ + long pgsz, newsz, modsz; + + pgsz = sysconf(_SC_PAGESIZE); + if (pgsz == -1) + Sys_Error("Hunk_End: Sysconf() failed: %s", strerror(errno)); + + newsz = curhunksize + sizeof(int); + + if (newsz > maxhunksize) + Sys_Error("Hunk_End Overflow"); + else if (newsz < maxhunksize) { + modsz = newsz % pgsz; + if (modsz) newsz += pgsz - modsz; + + if (munmap(membase + newsz, maxhunksize - newsz) == -1) + Sys_Error("Hunk_End: munmap() failed: %s", strerror(errno)); + } + + *((int *)membase) = curhunksize + sizeof(int); + + return curhunksize; +} +#endif void Hunk_Free (void *base) {