include/SDL_config.h
author Sam Lantinga <slouken@libsdl.org>
Thu, 29 Dec 2011 05:36:39 -0500
changeset 6116 66f48d6bf735
parent 6102 bf7254ec1bf9
child 6156 160a69849b9e
permissions -rw-r--r--
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
slouken@6116
     1
/* include/SDL_config.h.  Generated from SDL_config.h.in by configure.  */
slouken@1603
     2
/*
slouken@5535
     3
  Simple DirectMedia Layer
slouken@5535
     4
  Copyright (C) 1997-2011 Sam Lantinga <slouken@libsdl.org>
slouken@1603
     5
slouken@5535
     6
  This software is provided 'as-is', without any express or implied
slouken@5535
     7
  warranty.  In no event will the authors be held liable for any damages
slouken@5535
     8
  arising from the use of this software.
slouken@1603
     9
slouken@5535
    10
  Permission is granted to anyone to use this software for any purpose,
slouken@5535
    11
  including commercial applications, and to alter it and redistribute it
slouken@5535
    12
  freely, subject to the following restrictions:
slouken@1603
    13
slouken@5535
    14
  1. The origin of this software must not be misrepresented; you must not
slouken@5535
    15
     claim that you wrote the original software. If you use this software
slouken@5535
    16
     in a product, an acknowledgment in the product documentation would be
slouken@5535
    17
     appreciated but is not required.
slouken@5535
    18
  2. Altered source versions must be plainly marked as such, and must not be
slouken@5535
    19
     misrepresented as being the original software.
slouken@5535
    20
  3. This notice may not be removed or altered from any source distribution.
slouken@1603
    21
*/
slouken@1603
    22
slouken@1603
    23
#ifndef _SDL_config_h
slouken@1603
    24
#define _SDL_config_h
slouken@1603
    25
slouken@6116
    26
/**
slouken@6116
    27
 *  \file SDL_config.h.in
slouken@6116
    28
 *
slouken@6116
    29
 *  This is a set of defines to configure the SDL features
slouken@6116
    30
 */
slouken@6116
    31
slouken@6116
    32
/* General platform specific identifiers */
slouken@1603
    33
#include "SDL_platform.h"
slouken@1603
    34
slouken@6116
    35
/* Make sure that this isn't included by Visual C++ */
slouken@6116
    36
#ifdef _MSC_VER
slouken@6116
    37
#error You should run hg revert SDL_config.h 
slouken@6116
    38
#endif
slouken@6116
    39
slouken@6116
    40
/* C language features */
slouken@6116
    41
/* #undef const */
slouken@6116
    42
/* #undef inline */
slouken@6116
    43
/* #undef volatile */
slouken@6116
    44
slouken@6116
    45
/* C datatypes */
slouken@6116
    46
#define SIZEOF_VOIDP 8
slouken@6116
    47
#define HAVE_GCC_ATOMICS 1
slouken@6116
    48
/* #undef HAVE_GCC_SYNC_LOCK_TEST_AND_SET */
slouken@6116
    49
/* #undef HAVE_PTHREAD_SPINLOCK */
slouken@6116
    50
slouken@6116
    51
/* Comment this if you want to build without any C library requirements */
slouken@6116
    52
#define HAVE_LIBC 1
slouken@6116
    53
#if HAVE_LIBC
slouken@6116
    54
slouken@6116
    55
/* Useful headers */
slouken@6116
    56
#define HAVE_ALLOCA_H 1
slouken@6116
    57
#define HAVE_SYS_TYPES_H 1
slouken@6116
    58
#define HAVE_STDIO_H 1
slouken@6116
    59
#define STDC_HEADERS 1
slouken@6116
    60
#define HAVE_STDLIB_H 1
slouken@6116
    61
#define HAVE_STDARG_H 1
slouken@6116
    62
/* #undef HAVE_MALLOC_H */
slouken@6116
    63
#define HAVE_MEMORY_H 1
slouken@6116
    64
#define HAVE_STRING_H 1
slouken@6116
    65
#define HAVE_STRINGS_H 1
slouken@6116
    66
#define HAVE_INTTYPES_H 1
slouken@6116
    67
#define HAVE_STDINT_H 1
slouken@6116
    68
#define HAVE_CTYPE_H 1
slouken@6116
    69
#define HAVE_MATH_H 1
slouken@6116
    70
#define HAVE_ICONV_H 1
slouken@6116
    71
#define HAVE_SIGNAL_H 1
slouken@6116
    72
/* #undef HAVE_ALTIVEC_H */
slouken@6116
    73
/* #undef HAVE_PTHREAD_NP_H */
slouken@6116
    74
slouken@6116
    75
/* C library functions */
slouken@6116
    76
#define HAVE_MALLOC 1
slouken@6116
    77
#define HAVE_CALLOC 1
slouken@6116
    78
#define HAVE_REALLOC 1
slouken@6116
    79
#define HAVE_FREE 1
slouken@6116
    80
#define HAVE_ALLOCA 1
slouken@6116
    81
#ifndef __WIN32__ /* Don't use C runtime versions of these on Windows */
slouken@6116
    82
#define HAVE_GETENV 1
slouken@6116
    83
#define HAVE_SETENV 1
slouken@6116
    84
#define HAVE_PUTENV 1
slouken@6116
    85
#define HAVE_UNSETENV 1
slouken@6116
    86
#endif
slouken@6116
    87
#define HAVE_QSORT 1
slouken@6116
    88
#define HAVE_ABS 1
slouken@6116
    89
#define HAVE_BCOPY 1
slouken@6116
    90
#define HAVE_MEMSET 1
slouken@6116
    91
#define HAVE_MEMCPY 1
slouken@6116
    92
#define HAVE_MEMMOVE 1
slouken@6116
    93
#define HAVE_MEMCMP 1
slouken@6116
    94
#define HAVE_STRLEN 1
slouken@6116
    95
#define HAVE_STRLCPY 1
slouken@6116
    96
#define HAVE_STRLCAT 1
slouken@6116
    97
#define HAVE_STRDUP 1
slouken@6116
    98
/* #undef HAVE__STRREV */
slouken@6116
    99
/* #undef HAVE__STRUPR */
slouken@6116
   100
/* #undef HAVE__STRLWR */
slouken@6116
   101
/* #undef HAVE_INDEX */
slouken@6116
   102
/* #undef HAVE_RINDEX */
slouken@6116
   103
#define HAVE_STRCHR 1
slouken@6116
   104
#define HAVE_STRRCHR 1
slouken@6116
   105
#define HAVE_STRSTR 1
slouken@6116
   106
/* #undef HAVE_ITOA */
slouken@6116
   107
/* #undef HAVE__LTOA */
slouken@6116
   108
/* #undef HAVE__UITOA */
slouken@6116
   109
/* #undef HAVE__ULTOA */
slouken@6116
   110
#define HAVE_STRTOL 1
slouken@6116
   111
#define HAVE_STRTOUL 1
slouken@6116
   112
/* #undef HAVE__I64TOA */
slouken@6116
   113
/* #undef HAVE__UI64TOA */
slouken@6116
   114
#define HAVE_STRTOLL 1
slouken@6116
   115
#define HAVE_STRTOULL 1
slouken@6116
   116
#define HAVE_STRTOD 1
slouken@6116
   117
#define HAVE_ATOI 1
slouken@6116
   118
#define HAVE_ATOF 1
slouken@6116
   119
#define HAVE_STRCMP 1
slouken@6116
   120
#define HAVE_STRNCMP 1
slouken@6116
   121
/* #undef HAVE__STRICMP */
slouken@6116
   122
#define HAVE_STRCASECMP 1
slouken@6116
   123
/* #undef HAVE__STRNICMP */
slouken@6116
   124
#define HAVE_STRNCASECMP 1
slouken@6116
   125
#define HAVE_SSCANF 1
slouken@6116
   126
#define HAVE_SNPRINTF 1
slouken@6116
   127
#define HAVE_VSNPRINTF 1
slouken@6116
   128
#define HAVE_M_PI 
slouken@6116
   129
#define HAVE_ATAN 1
slouken@6116
   130
#define HAVE_ATAN2 1
slouken@6116
   131
#define HAVE_CEIL 1
slouken@6116
   132
#define HAVE_COPYSIGN 1
slouken@6116
   133
#define HAVE_COS 1
slouken@6116
   134
#define HAVE_COSF 1
slouken@6116
   135
#define HAVE_FABS 1
slouken@6116
   136
#define HAVE_FLOOR 1
slouken@6116
   137
#define HAVE_LOG 1
slouken@6116
   138
#define HAVE_POW 1
slouken@6116
   139
#define HAVE_SCALBN 1
slouken@6116
   140
#define HAVE_SIN 1
slouken@6116
   141
#define HAVE_SINF 1
slouken@6116
   142
#define HAVE_SQRT 1
slouken@6116
   143
#define HAVE_SIGACTION 1
slouken@6116
   144
#define HAVE_SA_SIGACTION 1
slouken@6116
   145
#define HAVE_SETJMP 1
slouken@6116
   146
#define HAVE_NANOSLEEP 1
slouken@6116
   147
#define HAVE_SYSCONF 1
slouken@6116
   148
#define HAVE_SYSCTLBYNAME 1
slouken@6116
   149
/* #undef HAVE_CLOCK_GETTIME */
slouken@6116
   150
/* #undef HAVE_GETPAGESIZE */
slouken@6116
   151
#define HAVE_MPROTECT 1
slouken@6116
   152
#define HAVE_ICONV 1
slouken@6116
   153
#define HAVE_PTHREAD_SETNAME_NP 1
slouken@6116
   154
/* #undef HAVE_PTHREAD_SET_NAME_NP */
slouken@6116
   155
slouken@1603
   156
#else
slouken@6116
   157
/* We may need some replacement for stdarg.h here */
slouken@6116
   158
#include <stdarg.h>
slouken@6116
   159
#endif /* HAVE_LIBC */
slouken@6116
   160
slouken@6116
   161
/* SDL internal assertion support */
slouken@6116
   162
/* #undef SDL_DEFAULT_ASSERT_LEVEL */
slouken@6116
   163
slouken@6116
   164
/* Allow disabling of core subsystems */
slouken@6116
   165
/* #undef SDL_ATOMIC_DISABLED */
slouken@6116
   166
/* #undef SDL_AUDIO_DISABLED */
slouken@6116
   167
/* #undef SDL_CPUINFO_DISABLED */
slouken@6116
   168
/* #undef SDL_EVENTS_DISABLED */
slouken@6116
   169
/* #undef SDL_FILE_DISABLED */
slouken@6116
   170
/* #undef SDL_JOYSTICK_DISABLED */
slouken@6116
   171
/* #undef SDL_HAPTIC_DISABLED */
slouken@6116
   172
/* #undef SDL_LOADSO_DISABLED */
slouken@6116
   173
/* #undef SDL_RENDER_DISABLED */
slouken@6116
   174
/* #undef SDL_THREADS_DISABLED */
slouken@6116
   175
/* #undef SDL_TIMERS_DISABLED */
slouken@6116
   176
/* #undef SDL_VIDEO_DISABLED */
slouken@6116
   177
/* #undef SDL_POWER_DISABLED */
slouken@6116
   178
slouken@6116
   179
/* Enable various audio drivers */
slouken@6116
   180
/* #undef SDL_AUDIO_DRIVER_ALSA */
slouken@6116
   181
/* #undef SDL_AUDIO_DRIVER_ALSA_DYNAMIC */
slouken@6116
   182
/* #undef SDL_AUDIO_DRIVER_ARTS */
slouken@6116
   183
/* #undef SDL_AUDIO_DRIVER_ARTS_DYNAMIC */
slouken@6116
   184
/* #undef SDL_AUDIO_DRIVER_PULSEAUDIO */
slouken@6116
   185
/* #undef SDL_AUDIO_DRIVER_PULSEAUDIO_DYNAMIC */
slouken@6116
   186
/* #undef SDL_AUDIO_DRIVER_BEOSAUDIO */
slouken@6116
   187
/* #undef SDL_AUDIO_DRIVER_BSD */
slouken@6116
   188
#define SDL_AUDIO_DRIVER_COREAUDIO 1
slouken@6116
   189
#define SDL_AUDIO_DRIVER_DISK 1
slouken@6116
   190
#define SDL_AUDIO_DRIVER_DUMMY 1
slouken@6116
   191
/* #undef SDL_AUDIO_DRIVER_XAUDIO2 */
slouken@6116
   192
/* #undef SDL_AUDIO_DRIVER_DSOUND */
slouken@6116
   193
/* #undef SDL_AUDIO_DRIVER_ESD */
slouken@6116
   194
/* #undef SDL_AUDIO_DRIVER_ESD_DYNAMIC */
slouken@6116
   195
/* #undef SDL_AUDIO_DRIVER_NAS */
slouken@6116
   196
/* #undef SDL_AUDIO_DRIVER_NAS_DYNAMIC */
slouken@6116
   197
/* #undef SDL_AUDIO_DRIVER_NDS */
slouken@6116
   198
/* #undef SDL_AUDIO_DRIVER_OSS */
slouken@6116
   199
/* #undef SDL_AUDIO_DRIVER_OSS_SOUNDCARD_H */
slouken@6116
   200
/* #undef SDL_AUDIO_DRIVER_PAUDIO */
slouken@6116
   201
/* #undef SDL_AUDIO_DRIVER_QSA */
slouken@6116
   202
/* #undef SDL_AUDIO_DRIVER_SUNAUDIO */
slouken@6116
   203
/* #undef SDL_AUDIO_DRIVER_WINMM */
slouken@6116
   204
/* #undef SDL_AUDIO_DRIVER_FUSIONSOUND */
slouken@6116
   205
/* #undef SDL_AUDIO_DRIVER_FUSIONSOUND_DYNAMIC */
slouken@6116
   206
slouken@6116
   207
/* Enable various input drivers */
slouken@6116
   208
/* #undef SDL_INPUT_LINUXEV */
slouken@6116
   209
/* #undef SDL_INPUT_TSLIB */
slouken@6116
   210
/* #undef SDL_JOYSTICK_BEOS */
slouken@6116
   211
/* #undef SDL_JOYSTICK_DINPUT */
slouken@6116
   212
/* #undef SDL_JOYSTICK_DUMMY */
slouken@6116
   213
#define SDL_JOYSTICK_IOKIT 1
slouken@6116
   214
/* #undef SDL_JOYSTICK_LINUX */
slouken@6116
   215
/* #undef SDL_JOYSTICK_NDS */
slouken@6116
   216
/* #undef SDL_JOYSTICK_WINMM */
slouken@6116
   217
/* #undef SDL_JOYSTICK_USBHID */
slouken@6116
   218
/* #undef SDL_JOYSTICK_USBHID_MACHINE_JOYSTICK_H */
slouken@6116
   219
/* #undef SDL_HAPTIC_DUMMY */
slouken@6116
   220
/* #undef SDL_HAPTIC_LINUX */
slouken@6116
   221
#define SDL_HAPTIC_IOKIT 1
slouken@6116
   222
/* #undef SDL_HAPTIC_DINPUT */
slouken@6116
   223
slouken@6116
   224
/* Enable various shared object loading systems */
slouken@6116
   225
/* #undef SDL_LOADSO_BEOS */
slouken@6116
   226
#define SDL_LOADSO_DLOPEN 1
slouken@6116
   227
/* #undef SDL_LOADSO_DUMMY */
slouken@6116
   228
/* #undef SDL_LOADSO_LDG */
slouken@6116
   229
/* #undef SDL_LOADSO_WINDOWS */
slouken@6116
   230
slouken@6116
   231
/* Enable various threading systems */
slouken@6116
   232
/* #undef SDL_THREAD_BEOS */
slouken@6116
   233
/* #undef SDL_THREAD_NDS */
slouken@6116
   234
#define SDL_THREAD_PTHREAD 1
slouken@6116
   235
#define SDL_THREAD_PTHREAD_RECURSIVE_MUTEX 1
slouken@6116
   236
/* #undef SDL_THREAD_PTHREAD_RECURSIVE_MUTEX_NP */
slouken@6116
   237
/* #undef SDL_THREAD_WINDOWS */
slouken@6116
   238
slouken@6116
   239
/* Enable various timer systems */
slouken@6116
   240
/* #undef SDL_TIMER_BEOS */
slouken@6116
   241
/* #undef SDL_TIMER_DUMMY */
slouken@6116
   242
/* #undef SDL_TIMER_NDS */
slouken@6116
   243
#define SDL_TIMER_UNIX 1
slouken@6116
   244
/* #undef SDL_TIMER_WINDOWS */
slouken@6116
   245
/* #undef SDL_TIMER_WINCE */
slouken@6116
   246
slouken@6116
   247
/* Enable various video drivers */
slouken@6116
   248
/* #undef SDL_VIDEO_DRIVER_BWINDOW */
slouken@6116
   249
#define SDL_VIDEO_DRIVER_COCOA 1
slouken@6116
   250
/* #undef SDL_VIDEO_DRIVER_DIRECTFB */
slouken@6116
   251
/* #undef SDL_VIDEO_DRIVER_DIRECTFB_DYNAMIC */
slouken@6116
   252
#define SDL_VIDEO_DRIVER_DUMMY 1
slouken@6116
   253
/* #undef SDL_VIDEO_DRIVER_NDS */
slouken@6116
   254
/* #undef SDL_VIDEO_DRIVER_WINDOWS */
slouken@6116
   255
#define SDL_VIDEO_DRIVER_X11 1
slouken@6116
   256
#define SDL_VIDEO_DRIVER_X11_DYNAMIC "/usr/X11R6/lib/libX11.6.dylib"
slouken@6116
   257
#define SDL_VIDEO_DRIVER_X11_DYNAMIC_XEXT "/usr/X11R6/lib/libXext.6.dylib"
slouken@6116
   258
#define SDL_VIDEO_DRIVER_X11_DYNAMIC_XCURSOR "/usr/X11R6/lib/libXcursor.1.dylib"
slouken@6116
   259
#define SDL_VIDEO_DRIVER_X11_DYNAMIC_XINERAMA "/usr/X11R6/lib/libXinerama.1.dylib"
slouken@6116
   260
#define SDL_VIDEO_DRIVER_X11_DYNAMIC_XINPUT "/usr/X11R6/lib/libXi.6.dylib"
slouken@6116
   261
#define SDL_VIDEO_DRIVER_X11_DYNAMIC_XRANDR "/usr/X11R6/lib/libXrandr.2.dylib"
slouken@6116
   262
#define SDL_VIDEO_DRIVER_X11_DYNAMIC_XSS "/usr/X11R6/lib/libXss.1.dylib"
slouken@6116
   263
#define SDL_VIDEO_DRIVER_X11_DYNAMIC_XVIDMODE "/usr/X11R6/lib/libXxf86vm.1.dylib"
slouken@6116
   264
#define SDL_VIDEO_DRIVER_X11_XCURSOR 1
slouken@6116
   265
#define SDL_VIDEO_DRIVER_X11_XINERAMA 1
slouken@6116
   266
#define SDL_VIDEO_DRIVER_X11_XINPUT 1
slouken@6116
   267
#define SDL_VIDEO_DRIVER_X11_XRANDR 1
slouken@6116
   268
#define SDL_VIDEO_DRIVER_X11_XSCRNSAVER 1
slouken@6116
   269
#define SDL_VIDEO_DRIVER_X11_XSHAPE 1
slouken@6116
   270
#define SDL_VIDEO_DRIVER_X11_XVIDMODE 1
slouken@6116
   271
slouken@6116
   272
/* #undef SDL_VIDEO_RENDER_D3D */
slouken@6116
   273
#define SDL_VIDEO_RENDER_OGL 1
slouken@6116
   274
/* #undef SDL_VIDEO_RENDER_OGL_ES */
slouken@6116
   275
/* #undef SDL_VIDEO_RENDER_DIRECTFB */
slouken@6116
   276
slouken@6116
   277
/* Enable OpenGL support */
slouken@6116
   278
#define SDL_VIDEO_OPENGL 1
slouken@6116
   279
/* #undef SDL_VIDEO_OPENGL_ES */
slouken@6116
   280
/* #undef SDL_VIDEO_OPENGL_BGL */
slouken@6116
   281
#define SDL_VIDEO_OPENGL_CGL 1
slouken@6116
   282
#define SDL_VIDEO_OPENGL_GLX 1
slouken@6116
   283
/* #undef SDL_VIDEO_OPENGL_WGL */
slouken@6116
   284
/* #undef SDL_VIDEO_OPENGL_OSMESA */
slouken@6116
   285
/* #undef SDL_VIDEO_OPENGL_OSMESA_DYNAMIC */
slouken@6116
   286
slouken@6116
   287
/* Enable system power support */
slouken@6116
   288
/* #undef SDL_POWER_LINUX */
slouken@6116
   289
/* #undef SDL_POWER_WINDOWS */
slouken@6116
   290
#define SDL_POWER_MACOSX 1
slouken@6116
   291
/* #undef SDL_POWER_BEOS */
slouken@6116
   292
/* #undef SDL_POWER_NINTENDODS */
slouken@6116
   293
/* #undef SDL_POWER_HARDWIRED */
slouken@6116
   294
slouken@6116
   295
/* Enable assembly routines */
slouken@6116
   296
#define SDL_ASSEMBLY_ROUTINES 1
slouken@6116
   297
/* #undef SDL_ALTIVEC_BLITTERS */
slouken@1603
   298
slouken@1603
   299
#endif /* _SDL_config_h */