Mercurial > sdl-ios-xcode
comparison src/video/SDL_stretch.c @ 4108:3feb94233f90 SDL-1.2
Fixed bug #528
OpenBSD (and possibly others) do not have executable memory by default,
so use mprotect() to allow execution of dynamic assembly block.
author | Sam Lantinga <slouken@libsdl.org> |
---|---|
date | Sat, 29 Dec 2007 03:50:29 +0000 |
parents | b5a4ac87b98c |
children | cd2ab40f1219 |
comparison
equal
deleted
inserted
replaced
4107:4e3b250c950e | 4108:3feb94233f90 |
---|---|
39 (defined(__GNUC__) && defined(__i386__))) && SDL_ASSEMBLY_ROUTINES | 39 (defined(__GNUC__) && defined(__i386__))) && SDL_ASSEMBLY_ROUTINES |
40 #define USE_ASM_STRETCH | 40 #define USE_ASM_STRETCH |
41 #endif | 41 #endif |
42 | 42 |
43 #ifdef USE_ASM_STRETCH | 43 #ifdef USE_ASM_STRETCH |
44 | |
45 /* OpenBSD has non-executable memory by default, so use mprotect() */ | |
46 #ifdef __OpenBSD__ | |
47 #define USE_MPROTECT | |
48 #endif | |
49 #ifdef USE_MPROTECT | |
50 #include <sys/types.h> | |
51 #include <sys/mman.h> | |
52 #endif | |
44 | 53 |
45 #if defined(_M_IX86) || defined(i386) | 54 #if defined(_M_IX86) || defined(i386) |
46 #define PREFIX16 0x66 | 55 #define PREFIX16 0x66 |
47 #define STORE_BYTE 0xAA | 56 #define STORE_BYTE 0xAA |
48 #define STORE_WORD 0xAB | 57 #define STORE_WORD 0xAB |
89 break; | 98 break; |
90 default: | 99 default: |
91 SDL_SetError("ASM stretch of %d bytes isn't supported\n", bpp); | 100 SDL_SetError("ASM stretch of %d bytes isn't supported\n", bpp); |
92 return(-1); | 101 return(-1); |
93 } | 102 } |
103 #ifdef USE_MPROTECT | |
104 mprotect(copy_row, sizeof(copy_row), PROT_READ|PROT_WRITE|PROT_EXEC); | |
105 #endif | |
94 pos = 0x10000; | 106 pos = 0x10000; |
95 inc = (src_w << 16) / dst_w; | 107 inc = (src_w << 16) / dst_w; |
96 eip = copy_row; | 108 eip = copy_row; |
97 for ( i=0; i<dst_w; ++i ) { | 109 for ( i=0; i<dst_w; ++i ) { |
98 while ( pos >= 0x10000L ) { | 110 while ( pos >= 0x10000L ) { |