From 559d2919f4372e88ac32b19512b37dfc6d065ef7 Mon Sep 17 00:00:00 2001 From: kirby Date: Sun, 18 Mar 2012 16:48:15 +0000 Subject: [PATCH] Add missing VM patches by Toni Spets. Pointed by Antti Harri, thanks. Remove old patches (yes, I should tattoo cvs add and cvs rm on my wrist). --- .../patches/patch-code_qcommon_net_ip_c | 25 -------------- .../patches/patch-code_qcommon_q_shared_h | 15 --------- .../patches/patch-code_qcommon_vm_x86_64_c | 24 ++++++++++++++ .../patches/patch-code_qcommon_vm_x86_c | 33 +++++++++++++++++++ .../patches/patch-code_renderer_tr_local_h | 28 ---------------- .../patches/patch-code_renderer_tr_surface_c | 18 ---------- 6 files changed, 57 insertions(+), 86 deletions(-) delete mode 100644 games/openarena/patches/patch-code_qcommon_net_ip_c delete mode 100644 games/openarena/patches/patch-code_qcommon_q_shared_h create mode 100644 games/openarena/patches/patch-code_qcommon_vm_x86_64_c create mode 100644 games/openarena/patches/patch-code_qcommon_vm_x86_c delete mode 100644 games/openarena/patches/patch-code_renderer_tr_local_h delete mode 100644 games/openarena/patches/patch-code_renderer_tr_surface_c diff --git a/games/openarena/patches/patch-code_qcommon_net_ip_c b/games/openarena/patches/patch-code_qcommon_net_ip_c deleted file mode 100644 index d8d1ecb602d..00000000000 --- a/games/openarena/patches/patch-code_qcommon_net_ip_c +++ /dev/null @@ -1,25 +0,0 @@ -$OpenBSD: patch-code_qcommon_net_ip_c,v 1.1.1.1 2008/10/27 13:29:02 weerd Exp $ ---- code/qcommon/net_ip.c.orig Sun Aug 31 14:36:07 2008 -+++ code/qcommon/net_ip.c Sun Aug 31 14:44:25 2008 -@@ -335,7 +335,21 @@ Sys_SockaddrToString - */ - static void Sys_SockaddrToString(char *dest, int destlen, struct sockaddr *input, int inputlen) - { -+/* OA's inputlen is incompatible with getnameinfo() on OpenBSD */ -+#ifdef __OpenBSD__ -+ struct sockaddr_in *s4; -+ struct sockaddr_in6 *s6; -+ -+ if (input->sa_family == AF_INET) { -+ s4 = (struct sockaddr_in *)(input); -+ inet_ntop(AF_INET, (void *)&(s4->sin_addr), dest, destlen); -+ } else if (input->sa_family == AF_INET6) { -+ s6 = (struct sockaddr_in6 *)(input); -+ inet_ntop(AF_INET6, (void *)&(s6->sin6_addr), dest, destlen); -+ } -+#else - getnameinfo(input, inputlen, dest, destlen, NULL, 0, NI_NUMERICHOST); -+#endif - } - - /* diff --git a/games/openarena/patches/patch-code_qcommon_q_shared_h b/games/openarena/patches/patch-code_qcommon_q_shared_h deleted file mode 100644 index ceb70cd126c..00000000000 --- a/games/openarena/patches/patch-code_qcommon_q_shared_h +++ /dev/null @@ -1,15 +0,0 @@ -$OpenBSD: patch-code_qcommon_q_shared_h,v 1.1 2010/05/27 03:47:28 jakemsr Exp $ ---- code/qcommon/q_shared.h.orig Mon May 3 04:41:00 2010 -+++ code/qcommon/q_shared.h Mon May 3 04:41:20 2010 -@@ -157,9 +157,9 @@ typedef int clipHandle_t; - #define PAD(x,y) (((x)+(y)-1) & ~((y)-1)) - - #ifdef __GNUC__ --#define ALIGN(x) __attribute__((aligned(x))) -+#define QALIGN(x) __attribute__((aligned(x))) - #else --#define ALIGN(x) -+#define QALIGN(x) - #endif - - #ifndef NULL diff --git a/games/openarena/patches/patch-code_qcommon_vm_x86_64_c b/games/openarena/patches/patch-code_qcommon_vm_x86_64_c new file mode 100644 index 00000000000..b25db81b402 --- /dev/null +++ b/games/openarena/patches/patch-code_qcommon_vm_x86_64_c @@ -0,0 +1,24 @@ +$OpenBSD: patch-code_qcommon_vm_x86_64_c,v 1.1 2012/03/18 16:48:16 kirby Exp $ + + * Add PROT_READ to x86 and x86_64 VM mmap calls[1] + +[1] According to OpenBSD's mmap(2): + +BUGS + Due to a limitation of the current vm system (see uvm(9)), mapping + descriptors PROT_WRITE without also specifying PROT_READ is useless + (results in a segmentation fault when first accessing the mapping). This + means that such descriptors must be opened with O_RDWR, which requires + both read and write permissions on the underlying object. + +--- code/qcommon/vm_x86_64.c.orig Sat Dec 24 14:29:32 2011 ++++ code/qcommon/vm_x86_64.c Sun Mar 11 15:22:24 2012 +@@ -445,7 +445,7 @@ void VM_Compile( vm_t *vm, vmHeader_t *header ) { + vm->codeLength = compiledOfs; + + #ifdef VM_X86_64_MMAP +- vm->codeBase = mmap(NULL, compiledOfs, PROT_WRITE, MAP_SHARED|MAP_ANONYMOUS, -1, 0); ++ vm->codeBase = mmap(NULL, compiledOfs, PROT_READ|PROT_WRITE, MAP_SHARED|MAP_ANONYMOUS, -1, 0); + if(vm->codeBase == MAP_FAILED) + Com_Error(ERR_FATAL, "VM_CompileX86_64: can't mmap memory"); + #elif __WIN64__ diff --git a/games/openarena/patches/patch-code_qcommon_vm_x86_c b/games/openarena/patches/patch-code_qcommon_vm_x86_c new file mode 100644 index 00000000000..2b7cae984a3 --- /dev/null +++ b/games/openarena/patches/patch-code_qcommon_vm_x86_c @@ -0,0 +1,33 @@ +$OpenBSD: patch-code_qcommon_vm_x86_c,v 1.1 2012/03/18 16:48:16 kirby Exp $ + + * Add PROT_READ to x86 and x86_64 VM mmap calls[1] + +[1] According to OpenBSD's mmap(2): + +BUGS + Due to a limitation of the current vm system (see uvm(9)), mapping + descriptors PROT_WRITE without also specifying PROT_READ is useless + (results in a segmentation fault when first accessing the mapping). This + means that such descriptors must be opened with O_RDWR, which requires + both read and write permissions on the underlying object. + +--- code/qcommon/vm_x86.c.orig Sat Dec 24 14:29:32 2011 ++++ code/qcommon/vm_x86.c Sun Mar 11 15:22:08 2012 +@@ -36,7 +36,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, + + /* need this on NX enabled systems (i386 with PAE kernel or + * noexec32=on x86_64) */ +-#if defined(__linux__) || defined(__FreeBSD__) ++#if defined(__linux__) || defined(__FreeBSD__) || defined(__OpenBSD__) + #define VM_X86_MMAP + #endif + +@@ -1094,7 +1094,7 @@ void VM_Compile( vm_t *vm, vmHeader_t *header ) { + // copy to an exact size buffer on the hunk + vm->codeLength = compiledOfs; + #ifdef VM_X86_MMAP +- vm->codeBase = mmap(NULL, compiledOfs, PROT_WRITE, MAP_SHARED|MAP_ANONYMOUS, -1, 0); ++ vm->codeBase = mmap(NULL, compiledOfs, PROT_READ|PROT_WRITE, MAP_SHARED|MAP_ANONYMOUS, -1, 0); + if(vm->codeBase == MAP_FAILED) + Com_Error(ERR_FATAL, "VM_CompileX86: can't mmap memory"); + #elif _WIN32 diff --git a/games/openarena/patches/patch-code_renderer_tr_local_h b/games/openarena/patches/patch-code_renderer_tr_local_h deleted file mode 100644 index b97336ad66a..00000000000 --- a/games/openarena/patches/patch-code_renderer_tr_local_h +++ /dev/null @@ -1,28 +0,0 @@ -$OpenBSD: patch-code_renderer_tr_local_h,v 1.1 2010/05/27 03:47:28 jakemsr Exp $ ---- code/renderer/tr_local.h.orig Mon May 3 04:41:46 2010 -+++ code/renderer/tr_local.h Mon May 3 04:42:13 2010 -@@ -1302,16 +1302,16 @@ typedef struct stageVars - - typedef struct shaderCommands_s - { -- glIndex_t indexes[SHADER_MAX_INDEXES] ALIGN(16); -- vec4_t xyz[SHADER_MAX_VERTEXES] ALIGN(16); -- vec4_t normal[SHADER_MAX_VERTEXES] ALIGN(16); -- vec2_t texCoords[SHADER_MAX_VERTEXES][2] ALIGN(16); -- color4ub_t vertexColors[SHADER_MAX_VERTEXES] ALIGN(16); -- int vertexDlightBits[SHADER_MAX_VERTEXES] ALIGN(16); -+ glIndex_t indexes[SHADER_MAX_INDEXES] QALIGN(16); -+ vec4_t xyz[SHADER_MAX_VERTEXES] QALIGN(16); -+ vec4_t normal[SHADER_MAX_VERTEXES] QALIGN(16); -+ vec2_t texCoords[SHADER_MAX_VERTEXES][2] QALIGN(16); -+ color4ub_t vertexColors[SHADER_MAX_VERTEXES] QALIGN(16); -+ int vertexDlightBits[SHADER_MAX_VERTEXES] QALIGN(16); - -- stageVars_t svars ALIGN(16); -+ stageVars_t svars QALIGN(16); - -- color4ub_t constantColor255[SHADER_MAX_VERTEXES] ALIGN(16); -+ color4ub_t constantColor255[SHADER_MAX_VERTEXES] QALIGN(16); - - shader_t *shader; - float shaderTime; diff --git a/games/openarena/patches/patch-code_renderer_tr_surface_c b/games/openarena/patches/patch-code_renderer_tr_surface_c deleted file mode 100644 index 8c8df3d5f9a..00000000000 --- a/games/openarena/patches/patch-code_renderer_tr_surface_c +++ /dev/null @@ -1,18 +0,0 @@ -$OpenBSD: patch-code_renderer_tr_surface_c,v 1.1 2010/05/27 03:47:28 jakemsr Exp $ ---- code/renderer/tr_surface.c.orig Mon May 3 04:42:28 2010 -+++ code/renderer/tr_surface.c Mon May 3 04:42:47 2010 -@@ -615,10 +615,10 @@ static void LerpMeshVertexes_altivec(md3Surface_t *sur - { - short *oldXyz, *newXyz, *oldNormals, *newNormals; - float *outXyz, *outNormal; -- float oldXyzScale ALIGN(16); -- float newXyzScale ALIGN(16); -- float oldNormalScale ALIGN(16); -- float newNormalScale ALIGN(16); -+ float oldXyzScale QALIGN(16); -+ float newXyzScale QALIGN(16); -+ float oldNormalScale QALIGN(16); -+ float newNormalScale QALIGN(16); - int vertNum; - unsigned lat, lng; - int numVerts;