SDL-mirror/include
Sam Lantinga f5c28b2406 Fixes bug 1296 - SDL_SetVideoMode crashes because of unaligned MOVAPS instruction
t.grundner@goto3d.de 2011-09-01 03:59:17 PDT
I figured out what is going on. GCC 4.5.2 assumes the stack is 16 byte aligned
by default. Therefore there are no AND alignment corrections necessary if we
wish to align a stack variable to a 16 byte boundary. That is bad if your OS
ABI is not 16 byte aligned. Windows 32 bit stacks are 4 byte aligned. This
results in the above mentioned SIGSEGV. This is also no problem if I compile
both SDL.dll and my app with MingW because MinGW/GCC inserts a

        andl    $-16, %esp

instruction right in the beginning of the main function. So at least the stack
of the thread calling the main function is 16 byte aligned. But as soon as I
start to use the SDL.dll from an application not compiled by MinGW there is no
ANDL safing my app.

However there is a GCC option that can change the default stack alignment:

        -mpreferred-stack-boundary=num

Setting num=2 assumes a the stack is aligned to a 4 byte boundary. This results
in GCC inserting the necessary

        andl    $-16, %esp

into SDL_FillRect. Rebuilding SDL with

       ./configure "CFLAGS=-mpreferred-stack-boundary=2 -g -O3"

solved the problem.

IMHO this should also be a problem on Solaris.

The following links contain further information:

http://gcc.gnu.org/onlinedocs/gcc-4.5.2/gcc/i386-and-x86_002d64-Options.html#i386-and-x86_002d64-Options

http://www.agner.org/optimize/calling_conventions.pdf
2011-12-29 05:36:39 -05:00
..
begin_code.h SDL 1.3 is now under the zlib license. 2011-04-08 13:03:26 -07:00
close_code.h SDL 1.3 is now under the zlib license. 2011-04-08 13:03:26 -07:00
doxyfile
SDL.h SDL 1.3 is now under the zlib license. 2011-04-08 13:03:26 -07:00
SDL_assert.h Fixed -pedantic warning in SDL_assert.h. 2011-08-21 12:36:55 -04:00
SDL_atomic.h Fixed gcc warnings for apps using SDL headers with -Wundef flag. 2011-06-06 12:20:04 -04:00
SDL_audio.h SDL 1.3 is now under the zlib license. 2011-04-08 13:03:26 -07:00
SDL_blendmode.h SDL 1.3 is now under the zlib license. 2011-04-08 13:03:26 -07:00
SDL_clipboard.h Update SDL_HasClipboardText functions to return value based on clipboard content; Fix memory leak in fallback SetClipboard implementation 2011-10-29 23:43:59 -07:00
SDL_compat.h SDL 1.3 is now under the zlib license. 2011-04-08 13:03:26 -07:00
SDL_config.h Fixes bug 1296 - SDL_SetVideoMode crashes because of unaligned MOVAPS instruction 2011-12-29 05:36:39 -05:00
SDL_config.h.in Lots of fixes importing SDL source wholesale into a new iOS project 2011-10-31 05:56:58 -04:00
SDL_config_android.h SDL 1.3 is now under the zlib license. 2011-04-08 13:03:26 -07:00
SDL_config_iphoneos.h Specify joystick (accelerometer) support for iOS in the config header. 2011-10-14 00:20:44 -04:00
SDL_config_macosx.h SDL 1.3 is now under the zlib license. 2011-04-08 13:03:26 -07:00
SDL_config_minimal.h SDL 1.3 is now under the zlib license. 2011-04-08 13:03:26 -07:00
SDL_config_nintendods.h SDL 1.3 is now under the zlib license. 2011-04-08 13:03:26 -07:00
SDL_config_pandora.h SDL 1.3 is now under the zlib license. 2011-04-08 13:03:26 -07:00
SDL_config_windows.h Implemented XAudio2 target for Windows (and Xbox360, theoretically!). 2011-08-04 01:07:09 -04:00
SDL_config_wiz.h SDL 1.3 is now under the zlib license. 2011-04-08 13:03:26 -07:00
SDL_copying.h SDL 1.3 is now under the zlib license. 2011-04-08 13:03:26 -07:00
SDL_cpuinfo.h SDL 1.3 is now under the zlib license. 2011-04-08 13:03:26 -07:00
SDL_endian.h SDL 1.3 is now under the zlib license. 2011-04-08 13:03:26 -07:00
SDL_error.h SDL 1.3 is now under the zlib license. 2011-04-08 13:03:26 -07:00
SDL_events.h Fixed bug 1336 - Added a timestamp on all SDL events 2011-12-29 05:13:55 -05:00
SDL_gesture.h SDL 1.3 is now under the zlib license. 2011-04-08 13:03:26 -07:00
SDL_haptic.h SDL 1.3 is now under the zlib license. 2011-04-08 13:03:26 -07:00
SDL_hints.h * SDL_IOS_IDLE_TIMER_DISABLED hint 2011-06-10 14:23:36 +01:00
SDL_input.h SDL 1.3 is now under the zlib license. 2011-04-08 13:03:26 -07:00
SDL_joystick.h SDL 1.3 is now under the zlib license. 2011-04-08 13:03:26 -07:00
SDL_keyboard.h Added SDL_GetScancodeFromName() and SDL_GetKeyFromName() 2011-10-24 21:34:54 -04:00
SDL_keycode.h SDL 1.3 is now under the zlib license. 2011-04-08 13:03:26 -07:00
SDL_loadso.h SDL 1.3 is now under the zlib license. 2011-04-08 13:03:26 -07:00
SDL_log.h Fixed typo - thanks Sheena! 2011-10-30 17:31:59 -04:00
SDL_main.h SDL 1.3 is now under the zlib license. 2011-04-08 13:03:26 -07:00
SDL_mouse.h SDL 1.3 is now under the zlib license. 2011-04-08 13:03:26 -07:00
SDL_mutex.h SDL 1.3 is now under the zlib license. 2011-04-08 13:03:26 -07:00
SDL_name.h
SDL_opengl.h Lots of fixes importing SDL source wholesale into a new iOS project 2011-10-31 05:56:58 -04:00
SDL_opengles.h SDL 1.3 is now under the zlib license. 2011-04-08 13:03:26 -07:00
SDL_opengles2.h SDL 1.3 is now under the zlib license. 2011-04-08 13:03:26 -07:00
SDL_pixels.h GIMP wrote bmp files in RGBX format. Huh. 2011-11-09 22:53:44 -05:00
SDL_platform.h Removed the MAC_OS_X_VERSION_10_x macros from the 1.3 branch. 2011-08-25 03:11:28 -04:00
SDL_power.h SDL 1.3 is now under the zlib license. 2011-04-08 13:03:26 -07:00
SDL_quit.h Make SDL_QuitRequested() return an SDL_bool 2011-06-12 12:23:39 -04:00
SDL_rect.h Fix SDL_RectEquals define 2011-09-17 22:35:10 -07:00
SDL_render.h The draw color affects RenderClear() as well. (thanks to the feedback form to whoever pointed this out) 2011-10-30 17:53:54 -04:00
SDL_revision.h Backed out most of changeset 4b88086910d3, at Andreas's request. 2011-12-05 12:43:50 -05:00
SDL_rwops.h * Android's InputStream::skip is apparently buggy, so instead read into a dummy buffer 2011-10-14 17:29:49 +01:00
SDL_scancode.h SDL 1.3 is now under the zlib license. 2011-04-08 13:03:26 -07:00
SDL_shape.h SDL 1.3 is now under the zlib license. 2011-04-08 13:03:26 -07:00
SDL_stdinc.h SDL 1.3 is now under the zlib license. 2011-04-08 13:03:26 -07:00
SDL_surface.h SDL_ConvertPixels() returns 0 on success 2011-10-31 02:44:21 -04:00
SDL_syswm.h SDL 1.3 is now under the zlib license. 2011-04-08 13:03:26 -07:00
SDL_thread.h 1.3 API CHANGE: Add support for naming threads. 2011-10-02 00:29:16 -04:00
SDL_timer.h SDL 1.3 is now under the zlib license. 2011-04-08 13:03:26 -07:00
SDL_touch.h SDL 1.3 is now under the zlib license. 2011-04-08 13:03:26 -07:00
SDL_types.h SDL 1.3 is now under the zlib license. 2011-04-08 13:03:26 -07:00
SDL_version.h SDL 1.3 is now under the zlib license. 2011-04-08 13:03:26 -07:00
SDL_video.h Clarified SDL_GetWindowSurface() documentation 2011-04-22 09:06:29 -07:00