aboutsummaryrefslogtreecommitdiff
path: root/games/r1q2/files/patch-linux__q_shlinux.c
blob: b69af4cde40cd54cfb12cfc5ca5449f8a9381111 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
--- linux/q_shlinux.c.orig	Fri Sep 28 21:38:18 2007
+++ linux/q_shlinux.c	Fri Sep 28 21:39:42 2007
@@ -16,6 +16,10 @@
 
 #include "../qcommon/qcommon.h"
 
+#ifndef __linux__
+#include <machine/param.h>
+#endif
+
 //===============================================================================
 
 byte *membase;
@@ -58,14 +62,29 @@
 
 int Hunk_End (void)
 {
-#ifndef __FreeBSD__
 	byte *n;
 
+#ifndef __linux__
+	size_t old_size = maxhunksize;
+	size_t new_size = curhunksize + sizeof(int);
+	void * unmap_base;
+	size_t unmap_len;
+
+	new_size = round_page(new_size);
+	old_size = round_page(old_size);
+	if (new_size > old_size)
+		n = 0; /* error */
+	else if (new_size < old_size) {
+		unmap_base = (caddr_t)(membase + new_size);
+		unmap_len = old_size - new_size;
+		n = munmap(unmap_base, unmap_len) + membase;
+	}
+#else
 	n = mremap(membase, maxhunksize, curhunksize + sizeof(int), 0);
+#endif
 	if (n != membase)
 		Sys_Error("Hunk_End:  Could not remap virtual block (%d)", errno);
 	*((int *)membase) = curhunksize + sizeof(int);
-#endif
 	
 	return curhunksize;
 }
@@ -111,7 +130,9 @@
 
 void Sys_DebugBreak (void)
 {
+#ifdef __i386__
         __asm ("int $3");
+#endif
 }
 
 void Sys_Mkdir (char *path)