Fixed bug #528 SDL-1.2
authorSam Lantinga <slouken@libsdl.org>
Sat, 29 Dec 2007 03:50:29 +0000
branchSDL-1.2
changeset 41083feb94233f90
parent 4107 4e3b250c950e
child 4109 cd2ab40f1219
Fixed bug #528
OpenBSD (and possibly others) do not have executable memory by default,
so use mprotect() to allow execution of dynamic assembly block.
src/video/SDL_stretch.c
     1.1 --- a/src/video/SDL_stretch.c	Sat Dec 29 02:34:53 2007 +0000
     1.2 +++ b/src/video/SDL_stretch.c	Sat Dec 29 03:50:29 2007 +0000
     1.3 @@ -42,6 +42,15 @@
     1.4  
     1.5  #ifdef USE_ASM_STRETCH
     1.6  
     1.7 +/* OpenBSD has non-executable memory by default, so use mprotect() */
     1.8 +#ifdef __OpenBSD__
     1.9 +#define USE_MPROTECT
    1.10 +#endif
    1.11 +#ifdef USE_MPROTECT
    1.12 +#include <sys/types.h>
    1.13 +#include <sys/mman.h>
    1.14 +#endif
    1.15 +
    1.16  #if defined(_M_IX86) || defined(i386)
    1.17  #define PREFIX16	0x66
    1.18  #define STORE_BYTE	0xAA
    1.19 @@ -91,6 +100,9 @@
    1.20  		SDL_SetError("ASM stretch of %d bytes isn't supported\n", bpp);
    1.21  		return(-1);
    1.22  	}
    1.23 +#ifdef USE_MPROTECT
    1.24 +	mprotect(copy_row, sizeof(copy_row), PROT_READ|PROT_WRITE|PROT_EXEC);
    1.25 +#endif
    1.26  	pos = 0x10000;
    1.27  	inc = (src_w << 16) / dst_w;
    1.28  	eip = copy_row;