src/SDL.c
author Sam Lantinga <slouken@libsdl.org>
Wed, 05 Jun 2013 21:23:59 -0700
changeset 7281 cd5516b9263d
parent 7191 75360622e65f
child 7346 ff228f955a48
permissions -rw-r--r--
Added some extra protection to notify the developer if they haven't initialized the application properly.

This will help reduce issues like that reported in bug 1819:

Wouter van Oortmerssen 2013-04-23 20:12:07 EDT
#0 0x01d1e881 in __HALT ()
#1 0x01c58971 in _CFRuntimeCreateInstance ()
#2 0x02e4acc1 in GSFontCreateWithName ()
#3 0x00adc0e1 in UINewFont ()
#4 0x00adc24c in +[UIFont systemFontOfSize:traits:] ()
#5 0x00adc298 in +[UIFont systemFontOfSize:] ()
#6 0x009fb5d9 in +[UITextFieldLabel defaultFont] ()
#7 0x00a8ccd5 in -[UILabel _commonInit] ()
#8 0x00a8ce14 in -[UILabel initWithFrame:] ()
#9 0x00a052eb in -[UITextField createTextLabelWithTextColor:] ()
#10 0x009fbede in -[UITextField initWithFrame:] ()
#11 0x00152ead in -[SDL_uikitview initializeKeyboard] at /Users/aardappel/lobster/external/SDL-2.0.0-7046/Xcode-iOS/SDL/../../src/video/uikit/SDL_uikitview.m:208
#12 0x0015290c in -[SDL_uikitview initWithFrame:] at /Users/aardappel/lobster/external/SDL-2.0.0-7046/Xcode-iOS/SDL/../../src/video/uikit/SDL_uikitview.m:50
#13 0x00153b5b in -[SDL_uikitopenglview initWithFrame:scale:retainBacking:rBits:gBits:bBits:aBits:depthBits:stencilBits:majorVersion:] at /Users/aardappel/lobster/external/SDL-2.0.0-7046/Xcode-iOS/SDL/../../src/video/uikit/SDL_uikitopenglview.m:53
#14 0x001524ff in UIKit_GL_CreateContext at /Users/aardappel/lobster/external/SDL-2.0.0-7046/Xcode-iOS/SDL/../../src/video/uikit/SDL_uikitopengles.m:114
#15 0x0015078f in SDL_GL_CreateContext at /Users/aardappel/lobster/external/SDL-2.0.0-7046/Xcode-iOS/SDL/../../src/video/SDL_video.c:2666
#16 0x000d8c5c in SDLInit(char const*, vec<int, 2>&) at /Users/aardappel/lobster/dev/xcode/lobster/../../src/sdlsystem.cpp:193
slouken@0
     1
/*
slouken@5535
     2
  Simple DirectMedia Layer
slouken@6885
     3
  Copyright (C) 1997-2013 Sam Lantinga <slouken@libsdl.org>
slouken@0
     4
slouken@5535
     5
  This software is provided 'as-is', without any express or implied
slouken@5535
     6
  warranty.  In no event will the authors be held liable for any damages
slouken@5535
     7
  arising from the use of this software.
slouken@0
     8
slouken@5535
     9
  Permission is granted to anyone to use this software for any purpose,
slouken@5535
    10
  including commercial applications, and to alter it and redistribute it
slouken@5535
    11
  freely, subject to the following restrictions:
slouken@0
    12
slouken@5535
    13
  1. The origin of this software must not be misrepresented; you must not
slouken@5535
    14
     claim that you wrote the original software. If you use this software
slouken@5535
    15
     in a product, an acknowledgment in the product documentation would be
slouken@5535
    16
     appreciated but is not required.
slouken@5535
    17
  2. Altered source versions must be plainly marked as such, and must not be
slouken@5535
    18
     misrepresented as being the original software.
slouken@5535
    19
  3. This notice may not be removed or altered from any source distribution.
slouken@0
    20
*/
slouken@1402
    21
#include "SDL_config.h"
slouken@0
    22
slouken@0
    23
/* Initialization code for SDL */
slouken@0
    24
slouken@1361
    25
#include "SDL.h"
jorgen@6866
    26
#include "SDL_bits.h"
slouken@5310
    27
#include "SDL_revision.h"
slouken@1361
    28
#include "SDL_fatal.h"
slouken@4472
    29
#include "SDL_assert_c.h"
slouken@4472
    30
#include "haptic/SDL_haptic_c.h"
slouken@4472
    31
#include "joystick/SDL_joystick_c.h"
slouken@3647
    32
slouken@0
    33
/* Initialization/Cleanup routines */
slouken@1361
    34
#if !SDL_TIMERS_DISABLED
slouken@1895
    35
extern int SDL_TimerInit(void);
slouken@0
    36
extern void SDL_TimerQuit(void);
urkle@7139
    37
extern void SDL_InitTicks(void);
slouken@0
    38
#endif
slouken@7110
    39
#if SDL_VIDEO_DRIVER_WINDOWS
slouken@2713
    40
extern int SDL_HelperWindowCreate(void);
slouken@2713
    41
extern int SDL_HelperWindowDestroy(void);
slouken@2713
    42
#endif
slouken@0
    43
slouken@3647
    44
slouken@0
    45
/* The initialized subsystems */
slouken@7281
    46
#ifdef SDL_MAIN_NEEDED
slouken@7281
    47
static SDL_bool SDL_MainIsReady = SDL_FALSE;
slouken@7281
    48
#else
slouken@7281
    49
static SDL_bool SDL_MainIsReady = SDL_TRUE;
slouken@7281
    50
#endif
slouken@6690
    51
static SDL_bool SDL_bInMainQuit = SDL_FALSE;
jorgen@6866
    52
static Uint8 SDL_SubsystemRefCount[ 32 ];
slouken@0
    53
jorgen@6866
    54
/* Private helper to increment a subsystem's ref counter. */
jorgen@6867
    55
static void
jorgen@6867
    56
SDL_PrivateSubsystemRefCountIncr(Uint32 subsystem)
slouken@6690
    57
{
jorgen@6866
    58
    int subsystem_index = SDL_MostSignificantBitIndex32(subsystem);
jorgen@6866
    59
    SDL_assert(SDL_SubsystemRefCount[subsystem_index] < 255);
jorgen@6866
    60
    ++SDL_SubsystemRefCount[subsystem_index];
jorgen@6866
    61
}
slouken@6690
    62
jorgen@6866
    63
/* Private helper to decrement a subsystem's ref counter. */
jorgen@6867
    64
static void
jorgen@6867
    65
SDL_PrivateSubsystemRefCountDecr(Uint32 subsystem)
jorgen@6866
    66
{
jorgen@6866
    67
    int subsystem_index = SDL_MostSignificantBitIndex32(subsystem);
jorgen@6866
    68
    if (SDL_SubsystemRefCount[subsystem_index] > 0) {
jorgen@6866
    69
        --SDL_SubsystemRefCount[subsystem_index];
jorgen@6866
    70
    }
jorgen@6866
    71
}
jorgen@6866
    72
jorgen@6866
    73
/* Private helper to check if a system needs init. */
jorgen@6866
    74
static SDL_bool
jorgen@6927
    75
SDL_PrivateShouldInitSubsystem(Uint32 subsystem)
jorgen@6866
    76
{
jorgen@6927
    77
    int subsystem_index = SDL_MostSignificantBitIndex32(subsystem);
jorgen@6866
    78
    SDL_assert(SDL_SubsystemRefCount[subsystem_index] < 255);
jorgen@6866
    79
    return (SDL_SubsystemRefCount[subsystem_index] == 0);
jorgen@6866
    80
}
jorgen@6866
    81
jorgen@6866
    82
/* Private helper to check if a system needs to be quit. */
jorgen@6866
    83
static SDL_bool
jorgen@6866
    84
SDL_PrivateShouldQuitSubsystem(Uint32 subsystem) {
jorgen@6866
    85
    int subsystem_index = SDL_MostSignificantBitIndex32(subsystem);
jorgen@6866
    86
    if (SDL_SubsystemRefCount[subsystem_index] == 0) {
jorgen@6866
    87
      return SDL_FALSE;
jorgen@6866
    88
    }
jorgen@6866
    89
jorgen@6866
    90
    /* If we're in SDL_Quit, we shut down every subsystem, even if refcount
jorgen@6866
    91
     * isn't zero.
jorgen@6866
    92
     */
jorgen@6866
    93
    return SDL_SubsystemRefCount[subsystem_index] == 1 || SDL_bInMainQuit;
slouken@6690
    94
}
slouken@0
    95
slouken@7281
    96
void
slouken@7281
    97
SDL_SetMainReady(void)
slouken@7281
    98
{
slouken@7281
    99
    SDL_MainIsReady = SDL_TRUE;
slouken@7281
   100
}
slouken@7281
   101
slouken@1895
   102
int
slouken@1895
   103
SDL_InitSubSystem(Uint32 flags)
slouken@0
   104
{
slouken@7281
   105
    if (!SDL_MainIsReady) {
slouken@7281
   106
        SDL_SetError("Application didn't initialize properly, did you include SDL_main.h in the file containing your main() function?");
slouken@7281
   107
        return -1;
slouken@7281
   108
    }
slouken@7281
   109
slouken@6128
   110
#if !SDL_TIMERS_DISABLED
urkle@7139
   111
    SDL_InitTicks();
jorgen@6866
   112
#endif
slouken@6690
   113
jorgen@6866
   114
    /* Initialize the timer subsystem */
jorgen@6924
   115
    if ((flags & SDL_INIT_TIMER) ){
jorgen@6866
   116
#if !SDL_TIMERS_DISABLED
jorgen@6927
   117
        if (SDL_PrivateShouldInitSubsystem(SDL_INIT_TIMER)) {
jorgen@6924
   118
            if (SDL_TimerInit() < 0) {
jorgen@6924
   119
                return (-1);
jorgen@6924
   120
            }
jorgen@6866
   121
        }
jorgen@6866
   122
        SDL_PrivateSubsystemRefCountIncr(SDL_INIT_TIMER);
slouken@6128
   123
#else
icculus@7037
   124
        return SDL_SetError("SDL not built with timer support");
jorgen@6866
   125
#endif
slouken@6128
   126
    }
slouken@6128
   127
jorgen@6866
   128
    /* Initialize the video/event subsystem */
jorgen@6924
   129
    if ((flags & SDL_INIT_VIDEO) ){
slouken@1361
   130
#if !SDL_VIDEO_DISABLED
jorgen@6927
   131
        if (SDL_PrivateShouldInitSubsystem(SDL_INIT_VIDEO)) {
jorgen@6924
   132
            if (SDL_VideoInit(NULL) < 0) {
jorgen@6924
   133
                return (-1);
jorgen@6924
   134
            }
jorgen@6866
   135
        }
jorgen@6866
   136
        SDL_PrivateSubsystemRefCountIncr(SDL_INIT_VIDEO);
slouken@0
   137
#else
icculus@7037
   138
        return SDL_SetError("SDL not built with video support");
jorgen@6866
   139
#endif
slouken@1895
   140
    }
slouken@0
   141
jorgen@6866
   142
    /* Initialize the audio subsystem */
jorgen@6924
   143
    if ((flags & SDL_INIT_AUDIO) ){
slouken@1361
   144
#if !SDL_AUDIO_DISABLED
jorgen@6927
   145
        if (SDL_PrivateShouldInitSubsystem(SDL_INIT_AUDIO)) {
jorgen@6924
   146
            if (SDL_AudioInit(NULL) < 0) {
jorgen@6924
   147
                return (-1);
jorgen@6924
   148
            }
jorgen@6866
   149
        }
jorgen@6866
   150
        SDL_PrivateSubsystemRefCountIncr(SDL_INIT_AUDIO);
slouken@0
   151
#else
icculus@7037
   152
        return SDL_SetError("SDL not built with audio support");
jorgen@6866
   153
#endif
slouken@1895
   154
    }
slouken@0
   155
jorgen@6866
   156
    if ((flags & SDL_INIT_GAMECONTROLLER)) {
slouken@7191
   157
        /* Game controller implies Joystick. */
jorgen@6866
   158
        flags |= SDL_INIT_JOYSTICK;
jorgen@6866
   159
    }
jorgen@6866
   160
jorgen@6866
   161
    /* Initialize the joystick subsystem */
jorgen@6924
   162
    if ((flags & SDL_INIT_JOYSTICK) ){
slouken@1361
   163
#if !SDL_JOYSTICK_DISABLED
jorgen@6927
   164
        if (SDL_PrivateShouldInitSubsystem(SDL_INIT_JOYSTICK)) {
jorgen@6924
   165
           if (SDL_JoystickInit() < 0) {
jorgen@6924
   166
               return (-1);
jorgen@6924
   167
           }
slouken@1895
   168
        }
jorgen@6866
   169
        SDL_PrivateSubsystemRefCountIncr(SDL_INIT_JOYSTICK);
slouken@0
   170
#else
icculus@7037
   171
        return SDL_SetError("SDL not built with joystick support");
jorgen@6866
   172
#endif
slouken@1895
   173
    }
jorgen@6866
   174
jorgen@6924
   175
    if ((flags & SDL_INIT_GAMECONTROLLER) ){
jorgen@6866
   176
#if !SDL_JOYSTICK_DISABLED
jorgen@6927
   177
        if (SDL_PrivateShouldInitSubsystem(SDL_INIT_GAMECONTROLLER)) {
jorgen@6924
   178
            if (SDL_GameControllerInit() < 0) {
jorgen@6924
   179
                return (-1);
jorgen@6924
   180
            }
jorgen@6866
   181
        }
jorgen@6866
   182
        SDL_PrivateSubsystemRefCountIncr(SDL_INIT_GAMECONTROLLER);
jorgen@6866
   183
#else
icculus@7037
   184
        return SDL_SetError("SDL not built with joystick support");
slouken@0
   185
#endif
jorgen@6866
   186
    }
slouken@0
   187
jorgen@6866
   188
    /* Initialize the haptic subsystem */
jorgen@6924
   189
    if ((flags & SDL_INIT_HAPTIC) ){
slouken@2713
   190
#if !SDL_HAPTIC_DISABLED
jorgen@6927
   191
        if (SDL_PrivateShouldInitSubsystem(SDL_INIT_HAPTIC)) {
jorgen@6924
   192
            if (SDL_HapticInit() < 0) {
jorgen@6927
   193
                return (-1);
jorgen@6927
   194
            }
jorgen@6866
   195
        }
jorgen@6866
   196
        SDL_PrivateSubsystemRefCountIncr(SDL_INIT_HAPTIC);
slouken@2713
   197
#else
icculus@7037
   198
        return SDL_SetError("SDL not built with haptic (force feedback) support");
jorgen@6866
   199
#endif
slouken@2713
   200
    }
jorgen@6866
   201
slouken@1895
   202
    return (0);
slouken@0
   203
}
slouken@0
   204
slouken@1895
   205
int
slouken@1895
   206
SDL_Init(Uint32 flags)
slouken@0
   207
{
slouken@3647
   208
    if (SDL_AssertionsInit() < 0) {
slouken@3647
   209
        return -1;
slouken@3647
   210
    }
slouken@3647
   211
slouken@1895
   212
    /* Clear the error message */
slouken@1895
   213
    SDL_ClearError();
slouken@0
   214
slouken@7110
   215
#if SDL_VIDEO_DRIVER_WINDOWS
slouken@2713
   216
    if (SDL_HelperWindowCreate() < 0) {
slouken@2713
   217
        return -1;
slouken@2713
   218
    }
slouken@2713
   219
#endif
slouken@2713
   220
slouken@1895
   221
    /* Initialize the desired subsystems */
slouken@1895
   222
    if (SDL_InitSubSystem(flags) < 0) {
slouken@1895
   223
        return (-1);
slouken@1895
   224
    }
slouken@0
   225
slouken@1895
   226
    /* Everything is initialized */
slouken@1895
   227
    if (!(flags & SDL_INIT_NOPARACHUTE)) {
slouken@1895
   228
        SDL_InstallParachute();
slouken@1895
   229
    }
slouken@3647
   230
slouken@1895
   231
    return (0);
slouken@0
   232
}
slouken@0
   233
slouken@1895
   234
void
slouken@1895
   235
SDL_QuitSubSystem(Uint32 flags)
slouken@0
   236
{
slouken@1895
   237
    /* Shut down requested initialized subsystems */
slouken@1361
   238
#if !SDL_JOYSTICK_DISABLED
jorgen@6866
   239
    if ((flags & SDL_INIT_GAMECONTROLLER)) {
slouken@7191
   240
        /* Game controller implies Joystick. */
jorgen@6866
   241
        flags |= SDL_INIT_JOYSTICK;
jorgen@6866
   242
jorgen@6866
   243
        if (SDL_PrivateShouldQuitSubsystem(SDL_INIT_GAMECONTROLLER)) {
jorgen@6866
   244
            SDL_GameControllerQuit();
slouken@7191
   245
        }
jorgen@6866
   246
        SDL_PrivateSubsystemRefCountDecr(SDL_INIT_GAMECONTROLLER);
jorgen@6866
   247
    }
slouken@6690
   248
jorgen@6866
   249
    if ((flags & SDL_INIT_JOYSTICK)) {
jorgen@6866
   250
        if (SDL_PrivateShouldQuitSubsystem(SDL_INIT_JOYSTICK)) {
slouken@7191
   251
            SDL_JoystickQuit();
slouken@7191
   252
        }
jorgen@6866
   253
        SDL_PrivateSubsystemRefCountDecr(SDL_INIT_JOYSTICK);
slouken@1895
   254
    }
slouken@0
   255
#endif
jorgen@6866
   256
slouken@2713
   257
#if !SDL_HAPTIC_DISABLED
jorgen@6866
   258
    if ((flags & SDL_INIT_HAPTIC)) {
jorgen@6866
   259
        if (SDL_PrivateShouldQuitSubsystem(SDL_INIT_HAPTIC)) {
slouken@7191
   260
            SDL_HapticQuit();
slouken@7191
   261
        }
jorgen@6866
   262
        SDL_PrivateSubsystemRefCountDecr(SDL_INIT_HAPTIC);
slouken@2713
   263
    }
slouken@2713
   264
#endif
jorgen@6866
   265
slouken@1361
   266
#if !SDL_AUDIO_DISABLED
jorgen@6866
   267
    if ((flags & SDL_INIT_AUDIO)) {
jorgen@6866
   268
        if (SDL_PrivateShouldQuitSubsystem(SDL_INIT_AUDIO)) {
slouken@7191
   269
            SDL_AudioQuit();
slouken@7191
   270
        }
jorgen@6866
   271
        SDL_PrivateSubsystemRefCountDecr(SDL_INIT_AUDIO);
slouken@1895
   272
    }
slouken@0
   273
#endif
jorgen@6866
   274
slouken@1361
   275
#if !SDL_VIDEO_DISABLED
jorgen@6866
   276
    if ((flags & SDL_INIT_VIDEO)) {
jorgen@6866
   277
        if (SDL_PrivateShouldQuitSubsystem(SDL_INIT_VIDEO)) {
slouken@7191
   278
            SDL_VideoQuit();
slouken@7191
   279
        }
jorgen@6866
   280
        SDL_PrivateSubsystemRefCountDecr(SDL_INIT_VIDEO);
slouken@1895
   281
    }
slouken@0
   282
#endif
jorgen@6866
   283
slouken@6128
   284
#if !SDL_TIMERS_DISABLED
jorgen@6866
   285
    if ((flags & SDL_INIT_TIMER)) {
jorgen@6866
   286
        if (SDL_PrivateShouldQuitSubsystem(SDL_INIT_TIMER)) {
slouken@7191
   287
            SDL_TimerQuit();
slouken@7191
   288
        }
jorgen@6866
   289
        SDL_PrivateSubsystemRefCountDecr(SDL_INIT_TIMER);
slouken@6128
   290
    }
slouken@6128
   291
#endif
slouken@0
   292
}
slouken@0
   293
slouken@1895
   294
Uint32
slouken@1895
   295
SDL_WasInit(Uint32 flags)
slouken@0
   296
{
jorgen@6866
   297
    int i;
jorgen@6866
   298
    int num_subsystems = SDL_arraysize(SDL_SubsystemRefCount);
jorgen@6866
   299
    Uint32 initialized = 0;
jorgen@6866
   300
slouken@1895
   301
    if (!flags) {
slouken@1895
   302
        flags = SDL_INIT_EVERYTHING;
slouken@1895
   303
    }
jorgen@6866
   304
jorgen@6866
   305
    num_subsystems = SDL_min(num_subsystems, SDL_MostSignificantBitIndex32(flags) + 1);
jorgen@6866
   306
jorgen@6866
   307
    /* Iterate over each bit in flags, and check the matching subsystem. */
jorgen@6866
   308
    for (i = 0; i < num_subsystems; ++i) {
jorgen@6866
   309
        if ((flags & 1) && SDL_SubsystemRefCount[i] > 0) {
jorgen@6866
   310
            initialized |= (1 << i);
jorgen@6866
   311
        }
jorgen@6866
   312
jorgen@6866
   313
        flags >>= 1;
jorgen@6866
   314
    }
jorgen@6866
   315
jorgen@6866
   316
    return initialized;
slouken@0
   317
}
slouken@0
   318
slouken@1895
   319
void
slouken@1895
   320
SDL_Quit(void)
slouken@0
   321
{
jorgen@6866
   322
    SDL_bInMainQuit = SDL_TRUE;
jorgen@6866
   323
slouken@1895
   324
    /* Quit all subsystems */
slouken@7110
   325
#if SDL_VIDEO_DRIVER_WINDOWS
slouken@2713
   326
    SDL_HelperWindowDestroy();
slouken@2713
   327
#endif
slouken@1895
   328
    SDL_QuitSubSystem(SDL_INIT_EVERYTHING);
slouken@0
   329
slouken@1895
   330
    /* Uninstall any parachute signal handlers */
slouken@1895
   331
    SDL_UninstallParachute();
slouken@397
   332
slouken@5189
   333
    SDL_ClearHints();
slouken@3647
   334
    SDL_AssertionsQuit();
slouken@5221
   335
    SDL_LogResetPriorities();
slouken@6690
   336
jorgen@6866
   337
    /* Now that every subsystem has been quit, we reset the subsystem refcount
jorgen@6866
   338
     * and the list of initialized subsystems.
jorgen@6866
   339
     */
jorgen@6866
   340
    SDL_memset( SDL_SubsystemRefCount, 0x0, sizeof(SDL_SubsystemRefCount) );
jorgen@6866
   341
jorgen@6866
   342
    SDL_bInMainQuit = SDL_FALSE;
slouken@0
   343
}
slouken@0
   344
slouken@1895
   345
/* Get the library version number */
slouken@1895
   346
void
slouken@1895
   347
SDL_GetVersion(SDL_version * ver)
slouken@0
   348
{
slouken@1895
   349
    SDL_VERSION(ver);
slouken@0
   350
}
slouken@0
   351
slouken@2982
   352
/* Get the library source revision */
icculus@4419
   353
const char *
slouken@2996
   354
SDL_GetRevision(void)
slouken@2982
   355
{
slouken@2983
   356
    return SDL_REVISION;
slouken@2982
   357
}
slouken@2982
   358
slouken@5359
   359
/* Get the library source revision number */
slouken@5359
   360
int
slouken@5359
   361
SDL_GetRevisionNumber(void)
slouken@5359
   362
{
slouken@5359
   363
    return SDL_REVISION_NUMBER;
slouken@5359
   364
}
slouken@5359
   365
slouken@3319
   366
/* Get the name of the platform */
slouken@3319
   367
const char *
slouken@3319
   368
SDL_GetPlatform()
slouken@3319
   369
{
slouken@3319
   370
#if __AIX__
slouken@3319
   371
    return "AIX";
slouken@6441
   372
#elif __ANDROID__
slouken@6441
   373
    return "Android";
slouken@3319
   374
#elif __HAIKU__
slouken@3319
   375
/* Haiku must appear here before BeOS, since it also defines __BEOS__ */
slouken@3319
   376
    return "Haiku";
slouken@3319
   377
#elif __BEOS__
slouken@3319
   378
    return "BeOS";
slouken@3319
   379
#elif __BSDI__
slouken@3319
   380
    return "BSDI";
slouken@3319
   381
#elif __DREAMCAST__
slouken@3319
   382
    return "Dreamcast";
slouken@3319
   383
#elif __FREEBSD__
slouken@3319
   384
    return "FreeBSD";
slouken@3319
   385
#elif __HPUX__
slouken@3319
   386
    return "HP-UX";
slouken@3319
   387
#elif __IRIX__
slouken@3319
   388
    return "Irix";
slouken@3319
   389
#elif __LINUX__
slouken@3319
   390
    return "Linux";
slouken@3319
   391
#elif __MINT__
slouken@3319
   392
    return "Atari MiNT";
slouken@3319
   393
#elif __MACOS__
slouken@3319
   394
    return "MacOS Classic";
slouken@3319
   395
#elif __MACOSX__
slouken@3319
   396
    return "Mac OS X";
slouken@3319
   397
#elif __NETBSD__
slouken@3319
   398
    return "NetBSD";
slouken@3319
   399
#elif __OPENBSD__
slouken@3319
   400
    return "OpenBSD";
slouken@3319
   401
#elif __OS2__
slouken@3319
   402
    return "OS/2";
slouken@3319
   403
#elif __OSF__
slouken@3319
   404
    return "OSF/1";
slouken@3319
   405
#elif __QNXNTO__
slouken@3319
   406
    return "QNX Neutrino";
slouken@3319
   407
#elif __RISCOS__
slouken@3319
   408
    return "RISC OS";
slouken@3319
   409
#elif __SOLARIS__
slouken@3319
   410
    return "Solaris";
slouken@5086
   411
#elif __WIN32__
slouken@3319
   412
    return "Windows";
slouken@3319
   413
#elif __IPHONEOS__
slouken@3319
   414
    return "iPhone OS";
kimonline@7009
   415
#elif __PSP__
kimonline@7009
   416
    return "PlayStation Portable";
slouken@3319
   417
#else
slouken@3319
   418
    return "Unknown (see SDL_platform.h)";
slouken@3319
   419
#endif
slouken@3319
   420
}
slouken@3319
   421
slouken@5086
   422
#if defined(__WIN32__)
slouken@1330
   423
slouken@1465
   424
#if !defined(HAVE_LIBC) || (defined(__WATCOMC__) && defined(BUILD_DLL))
slouken@1465
   425
/* Need to include DllMain() on Watcom C for some reason.. */
slouken@5090
   426
#include "core/windows/SDL_windows.h"
slouken@1330
   427
slouken@1895
   428
BOOL APIENTRY
slouken@1895
   429
_DllMainCRTStartup(HANDLE hModule,
slouken@1895
   430
                   DWORD ul_reason_for_call, LPVOID lpReserved)
slouken@1330
   431
{
slouken@1895
   432
    switch (ul_reason_for_call) {
slouken@1895
   433
    case DLL_PROCESS_ATTACH:
slouken@1895
   434
    case DLL_THREAD_ATTACH:
slouken@1895
   435
    case DLL_THREAD_DETACH:
slouken@1895
   436
    case DLL_PROCESS_DETACH:
slouken@1895
   437
        break;
slouken@1895
   438
    }
slouken@1895
   439
    return TRUE;
slouken@1330
   440
}
slouken@1465
   441
#endif /* building DLL with Watcom C */
slouken@1330
   442
slouken@5086
   443
#endif /* __WIN32__ */
slouken@1895
   444
jorgen@6927
   445
/* vi: set sts=4 ts=4 sw=4 expandtab: */