src/SDL.c
author Ryan C. Gordon <icculus@icculus.org>
Wed, 07 Aug 2013 11:12:11 -0700
changeset 7589 e9a7333d86f0
parent 7588 f1ca6adffc4b
child 7590 5706d7fc10d0
permissions -rw-r--r--
SDL_*Parachute() are no-ops, remove them.
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@4472
    28
#include "SDL_assert_c.h"
slouken@7360
    29
#include "events/SDL_events_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
slouken@7360
   114
    if ((flags & SDL_INIT_GAMECONTROLLER)) {
slouken@7360
   115
        /* game controller implies joystick */
slouken@7360
   116
        flags |= SDL_INIT_JOYSTICK;
slouken@7360
   117
    }
slouken@7360
   118
slouken@7360
   119
    if ((flags & (SDL_INIT_VIDEO|SDL_INIT_JOYSTICK))) {
slouken@7360
   120
        /* video or joystick implies events */
slouken@7360
   121
        flags |= SDL_INIT_EVENTS;
slouken@7360
   122
    }
slouken@7360
   123
slouken@7360
   124
    /* Initialize the event subsystem */
slouken@7360
   125
    if ((flags & SDL_INIT_EVENTS)) {
slouken@7360
   126
#if !SDL_EVENTS_DISABLED
slouken@7360
   127
        if (SDL_PrivateShouldInitSubsystem(SDL_INIT_EVENTS)) {
slouken@7360
   128
            if (SDL_StartEventLoop() < 0) {
slouken@7360
   129
                return (-1);
slouken@7360
   130
            }
slouken@7360
   131
            SDL_QuitInit();
slouken@7360
   132
        }
slouken@7360
   133
        SDL_PrivateSubsystemRefCountIncr(SDL_INIT_EVENTS);
slouken@7360
   134
#else
slouken@7360
   135
        return SDL_SetError("SDL not built with events support");
slouken@7360
   136
#endif
slouken@7360
   137
    }
slouken@7360
   138
jorgen@6866
   139
    /* Initialize the timer subsystem */
slouken@7360
   140
    if ((flags & SDL_INIT_TIMER)){
jorgen@6866
   141
#if !SDL_TIMERS_DISABLED
jorgen@6927
   142
        if (SDL_PrivateShouldInitSubsystem(SDL_INIT_TIMER)) {
jorgen@6924
   143
            if (SDL_TimerInit() < 0) {
jorgen@6924
   144
                return (-1);
jorgen@6924
   145
            }
jorgen@6866
   146
        }
jorgen@6866
   147
        SDL_PrivateSubsystemRefCountIncr(SDL_INIT_TIMER);
slouken@6128
   148
#else
icculus@7037
   149
        return SDL_SetError("SDL not built with timer support");
jorgen@6866
   150
#endif
slouken@6128
   151
    }
slouken@6128
   152
slouken@7360
   153
    /* Initialize the video subsystem */
slouken@7360
   154
    if ((flags & SDL_INIT_VIDEO)){
slouken@1361
   155
#if !SDL_VIDEO_DISABLED
jorgen@6927
   156
        if (SDL_PrivateShouldInitSubsystem(SDL_INIT_VIDEO)) {
jorgen@6924
   157
            if (SDL_VideoInit(NULL) < 0) {
jorgen@6924
   158
                return (-1);
jorgen@6924
   159
            }
jorgen@6866
   160
        }
jorgen@6866
   161
        SDL_PrivateSubsystemRefCountIncr(SDL_INIT_VIDEO);
slouken@0
   162
#else
icculus@7037
   163
        return SDL_SetError("SDL not built with video support");
jorgen@6866
   164
#endif
slouken@1895
   165
    }
slouken@0
   166
jorgen@6866
   167
    /* Initialize the audio subsystem */
slouken@7360
   168
    if ((flags & SDL_INIT_AUDIO)){
slouken@1361
   169
#if !SDL_AUDIO_DISABLED
jorgen@6927
   170
        if (SDL_PrivateShouldInitSubsystem(SDL_INIT_AUDIO)) {
jorgen@6924
   171
            if (SDL_AudioInit(NULL) < 0) {
jorgen@6924
   172
                return (-1);
jorgen@6924
   173
            }
jorgen@6866
   174
        }
jorgen@6866
   175
        SDL_PrivateSubsystemRefCountIncr(SDL_INIT_AUDIO);
slouken@0
   176
#else
icculus@7037
   177
        return SDL_SetError("SDL not built with audio support");
jorgen@6866
   178
#endif
slouken@1895
   179
    }
slouken@0
   180
jorgen@6866
   181
    /* Initialize the joystick subsystem */
slouken@7360
   182
    if ((flags & SDL_INIT_JOYSTICK)){
slouken@1361
   183
#if !SDL_JOYSTICK_DISABLED
jorgen@6927
   184
        if (SDL_PrivateShouldInitSubsystem(SDL_INIT_JOYSTICK)) {
jorgen@6924
   185
           if (SDL_JoystickInit() < 0) {
jorgen@6924
   186
               return (-1);
jorgen@6924
   187
           }
slouken@1895
   188
        }
jorgen@6866
   189
        SDL_PrivateSubsystemRefCountIncr(SDL_INIT_JOYSTICK);
slouken@0
   190
#else
icculus@7037
   191
        return SDL_SetError("SDL not built with joystick support");
jorgen@6866
   192
#endif
slouken@1895
   193
    }
jorgen@6866
   194
slouken@7360
   195
    if ((flags & SDL_INIT_GAMECONTROLLER)){
jorgen@6866
   196
#if !SDL_JOYSTICK_DISABLED
jorgen@6927
   197
        if (SDL_PrivateShouldInitSubsystem(SDL_INIT_GAMECONTROLLER)) {
jorgen@6924
   198
            if (SDL_GameControllerInit() < 0) {
jorgen@6924
   199
                return (-1);
jorgen@6924
   200
            }
jorgen@6866
   201
        }
jorgen@6866
   202
        SDL_PrivateSubsystemRefCountIncr(SDL_INIT_GAMECONTROLLER);
jorgen@6866
   203
#else
icculus@7037
   204
        return SDL_SetError("SDL not built with joystick support");
slouken@0
   205
#endif
jorgen@6866
   206
    }
slouken@0
   207
jorgen@6866
   208
    /* Initialize the haptic subsystem */
slouken@7360
   209
    if ((flags & SDL_INIT_HAPTIC)){
slouken@2713
   210
#if !SDL_HAPTIC_DISABLED
jorgen@6927
   211
        if (SDL_PrivateShouldInitSubsystem(SDL_INIT_HAPTIC)) {
jorgen@6924
   212
            if (SDL_HapticInit() < 0) {
jorgen@6927
   213
                return (-1);
jorgen@6927
   214
            }
jorgen@6866
   215
        }
jorgen@6866
   216
        SDL_PrivateSubsystemRefCountIncr(SDL_INIT_HAPTIC);
slouken@2713
   217
#else
icculus@7037
   218
        return SDL_SetError("SDL not built with haptic (force feedback) support");
jorgen@6866
   219
#endif
slouken@2713
   220
    }
jorgen@6866
   221
slouken@1895
   222
    return (0);
slouken@0
   223
}
slouken@0
   224
slouken@1895
   225
int
slouken@1895
   226
SDL_Init(Uint32 flags)
slouken@0
   227
{
slouken@1895
   228
    /* Clear the error message */
slouken@1895
   229
    SDL_ClearError();
slouken@0
   230
slouken@7110
   231
#if SDL_VIDEO_DRIVER_WINDOWS
slouken@2713
   232
    if (SDL_HelperWindowCreate() < 0) {
slouken@2713
   233
        return -1;
slouken@2713
   234
    }
slouken@2713
   235
#endif
slouken@2713
   236
slouken@1895
   237
    /* Initialize the desired subsystems */
slouken@1895
   238
    if (SDL_InitSubSystem(flags) < 0) {
slouken@1895
   239
        return (-1);
slouken@1895
   240
    }
slouken@0
   241
slouken@1895
   242
    return (0);
slouken@0
   243
}
slouken@0
   244
slouken@1895
   245
void
slouken@1895
   246
SDL_QuitSubSystem(Uint32 flags)
slouken@0
   247
{
slouken@1895
   248
    /* Shut down requested initialized subsystems */
slouken@1361
   249
#if !SDL_JOYSTICK_DISABLED
jorgen@6866
   250
    if ((flags & SDL_INIT_GAMECONTROLLER)) {
slouken@7360
   251
        /* game controller implies joystick */
jorgen@6866
   252
        flags |= SDL_INIT_JOYSTICK;
jorgen@6866
   253
jorgen@6866
   254
        if (SDL_PrivateShouldQuitSubsystem(SDL_INIT_GAMECONTROLLER)) {
jorgen@6866
   255
            SDL_GameControllerQuit();
slouken@7191
   256
        }
jorgen@6866
   257
        SDL_PrivateSubsystemRefCountDecr(SDL_INIT_GAMECONTROLLER);
jorgen@6866
   258
    }
slouken@6690
   259
jorgen@6866
   260
    if ((flags & SDL_INIT_JOYSTICK)) {
slouken@7360
   261
        /* joystick implies events */
slouken@7360
   262
        flags |= SDL_INIT_EVENTS;
slouken@7360
   263
jorgen@6866
   264
        if (SDL_PrivateShouldQuitSubsystem(SDL_INIT_JOYSTICK)) {
slouken@7191
   265
            SDL_JoystickQuit();
slouken@7191
   266
        }
jorgen@6866
   267
        SDL_PrivateSubsystemRefCountDecr(SDL_INIT_JOYSTICK);
slouken@1895
   268
    }
slouken@0
   269
#endif
jorgen@6866
   270
slouken@2713
   271
#if !SDL_HAPTIC_DISABLED
jorgen@6866
   272
    if ((flags & SDL_INIT_HAPTIC)) {
jorgen@6866
   273
        if (SDL_PrivateShouldQuitSubsystem(SDL_INIT_HAPTIC)) {
slouken@7191
   274
            SDL_HapticQuit();
slouken@7191
   275
        }
jorgen@6866
   276
        SDL_PrivateSubsystemRefCountDecr(SDL_INIT_HAPTIC);
slouken@2713
   277
    }
slouken@2713
   278
#endif
jorgen@6866
   279
slouken@1361
   280
#if !SDL_AUDIO_DISABLED
jorgen@6866
   281
    if ((flags & SDL_INIT_AUDIO)) {
jorgen@6866
   282
        if (SDL_PrivateShouldQuitSubsystem(SDL_INIT_AUDIO)) {
slouken@7191
   283
            SDL_AudioQuit();
slouken@7191
   284
        }
jorgen@6866
   285
        SDL_PrivateSubsystemRefCountDecr(SDL_INIT_AUDIO);
slouken@1895
   286
    }
slouken@0
   287
#endif
jorgen@6866
   288
slouken@1361
   289
#if !SDL_VIDEO_DISABLED
jorgen@6866
   290
    if ((flags & SDL_INIT_VIDEO)) {
slouken@7360
   291
        /* video implies events */
slouken@7360
   292
        flags |= SDL_INIT_EVENTS;
slouken@7360
   293
jorgen@6866
   294
        if (SDL_PrivateShouldQuitSubsystem(SDL_INIT_VIDEO)) {
slouken@7191
   295
            SDL_VideoQuit();
slouken@7191
   296
        }
jorgen@6866
   297
        SDL_PrivateSubsystemRefCountDecr(SDL_INIT_VIDEO);
slouken@1895
   298
    }
slouken@0
   299
#endif
jorgen@6866
   300
slouken@6128
   301
#if !SDL_TIMERS_DISABLED
jorgen@6866
   302
    if ((flags & SDL_INIT_TIMER)) {
jorgen@6866
   303
        if (SDL_PrivateShouldQuitSubsystem(SDL_INIT_TIMER)) {
slouken@7191
   304
            SDL_TimerQuit();
slouken@7191
   305
        }
jorgen@6866
   306
        SDL_PrivateSubsystemRefCountDecr(SDL_INIT_TIMER);
slouken@6128
   307
    }
slouken@6128
   308
#endif
slouken@7360
   309
slouken@7360
   310
#if !SDL_EVENTS_DISABLED
slouken@7360
   311
    if ((flags & SDL_INIT_EVENTS)) {
slouken@7360
   312
        if (SDL_PrivateShouldQuitSubsystem(SDL_INIT_EVENTS)) {
slouken@7360
   313
            SDL_QuitQuit();
slouken@7360
   314
            SDL_StopEventLoop();
slouken@7360
   315
        }
slouken@7360
   316
        SDL_PrivateSubsystemRefCountDecr(SDL_INIT_EVENTS);
slouken@7360
   317
    }
slouken@7360
   318
#endif
slouken@0
   319
}
slouken@0
   320
slouken@1895
   321
Uint32
slouken@1895
   322
SDL_WasInit(Uint32 flags)
slouken@0
   323
{
jorgen@6866
   324
    int i;
jorgen@6866
   325
    int num_subsystems = SDL_arraysize(SDL_SubsystemRefCount);
jorgen@6866
   326
    Uint32 initialized = 0;
jorgen@6866
   327
slouken@1895
   328
    if (!flags) {
slouken@1895
   329
        flags = SDL_INIT_EVERYTHING;
slouken@1895
   330
    }
jorgen@6866
   331
jorgen@6866
   332
    num_subsystems = SDL_min(num_subsystems, SDL_MostSignificantBitIndex32(flags) + 1);
jorgen@6866
   333
jorgen@6866
   334
    /* Iterate over each bit in flags, and check the matching subsystem. */
jorgen@6866
   335
    for (i = 0; i < num_subsystems; ++i) {
jorgen@6866
   336
        if ((flags & 1) && SDL_SubsystemRefCount[i] > 0) {
jorgen@6866
   337
            initialized |= (1 << i);
jorgen@6866
   338
        }
jorgen@6866
   339
jorgen@6866
   340
        flags >>= 1;
jorgen@6866
   341
    }
jorgen@6866
   342
jorgen@6866
   343
    return initialized;
slouken@0
   344
}
slouken@0
   345
slouken@1895
   346
void
slouken@1895
   347
SDL_Quit(void)
slouken@0
   348
{
jorgen@6866
   349
    SDL_bInMainQuit = SDL_TRUE;
jorgen@6866
   350
slouken@1895
   351
    /* Quit all subsystems */
slouken@7110
   352
#if SDL_VIDEO_DRIVER_WINDOWS
slouken@2713
   353
    SDL_HelperWindowDestroy();
slouken@2713
   354
#endif
slouken@1895
   355
    SDL_QuitSubSystem(SDL_INIT_EVERYTHING);
slouken@0
   356
slouken@1895
   357
    /* Uninstall any parachute signal handlers */
slouken@1895
   358
    SDL_UninstallParachute();
slouken@397
   359
slouken@5189
   360
    SDL_ClearHints();
slouken@3647
   361
    SDL_AssertionsQuit();
slouken@5221
   362
    SDL_LogResetPriorities();
slouken@6690
   363
jorgen@6866
   364
    /* Now that every subsystem has been quit, we reset the subsystem refcount
jorgen@6866
   365
     * and the list of initialized subsystems.
jorgen@6866
   366
     */
jorgen@6866
   367
    SDL_memset( SDL_SubsystemRefCount, 0x0, sizeof(SDL_SubsystemRefCount) );
jorgen@6866
   368
jorgen@6866
   369
    SDL_bInMainQuit = SDL_FALSE;
slouken@0
   370
}
slouken@0
   371
slouken@1895
   372
/* Get the library version number */
slouken@1895
   373
void
slouken@1895
   374
SDL_GetVersion(SDL_version * ver)
slouken@0
   375
{
slouken@1895
   376
    SDL_VERSION(ver);
slouken@0
   377
}
slouken@0
   378
slouken@2982
   379
/* Get the library source revision */
icculus@4419
   380
const char *
slouken@2996
   381
SDL_GetRevision(void)
slouken@2982
   382
{
slouken@2983
   383
    return SDL_REVISION;
slouken@2982
   384
}
slouken@2982
   385
slouken@5359
   386
/* Get the library source revision number */
slouken@5359
   387
int
slouken@5359
   388
SDL_GetRevisionNumber(void)
slouken@5359
   389
{
slouken@5359
   390
    return SDL_REVISION_NUMBER;
slouken@5359
   391
}
slouken@5359
   392
slouken@3319
   393
/* Get the name of the platform */
slouken@3319
   394
const char *
slouken@3319
   395
SDL_GetPlatform()
slouken@3319
   396
{
slouken@3319
   397
#if __AIX__
slouken@3319
   398
    return "AIX";
slouken@6441
   399
#elif __ANDROID__
slouken@6441
   400
    return "Android";
slouken@3319
   401
#elif __BEOS__
slouken@3319
   402
    return "BeOS";
slouken@3319
   403
#elif __BSDI__
slouken@3319
   404
    return "BSDI";
slouken@3319
   405
#elif __DREAMCAST__
slouken@3319
   406
    return "Dreamcast";
slouken@3319
   407
#elif __FREEBSD__
slouken@3319
   408
    return "FreeBSD";
icculus@7346
   409
#elif __HAIKU__
icculus@7346
   410
    return "Haiku";
slouken@3319
   411
#elif __HPUX__
slouken@3319
   412
    return "HP-UX";
slouken@3319
   413
#elif __IRIX__
slouken@3319
   414
    return "Irix";
slouken@3319
   415
#elif __LINUX__
slouken@3319
   416
    return "Linux";
slouken@3319
   417
#elif __MINT__
slouken@3319
   418
    return "Atari MiNT";
slouken@3319
   419
#elif __MACOS__
slouken@3319
   420
    return "MacOS Classic";
slouken@3319
   421
#elif __MACOSX__
slouken@3319
   422
    return "Mac OS X";
slouken@3319
   423
#elif __NETBSD__
slouken@3319
   424
    return "NetBSD";
slouken@3319
   425
#elif __OPENBSD__
slouken@3319
   426
    return "OpenBSD";
slouken@3319
   427
#elif __OS2__
slouken@3319
   428
    return "OS/2";
slouken@3319
   429
#elif __OSF__
slouken@3319
   430
    return "OSF/1";
slouken@3319
   431
#elif __QNXNTO__
slouken@3319
   432
    return "QNX Neutrino";
slouken@3319
   433
#elif __RISCOS__
slouken@3319
   434
    return "RISC OS";
slouken@3319
   435
#elif __SOLARIS__
slouken@3319
   436
    return "Solaris";
slouken@5086
   437
#elif __WIN32__
slouken@3319
   438
    return "Windows";
slouken@3319
   439
#elif __IPHONEOS__
slouken@3319
   440
    return "iPhone OS";
kimonline@7009
   441
#elif __PSP__
kimonline@7009
   442
    return "PlayStation Portable";
slouken@3319
   443
#else
slouken@3319
   444
    return "Unknown (see SDL_platform.h)";
slouken@3319
   445
#endif
slouken@3319
   446
}
slouken@3319
   447
slouken@5086
   448
#if defined(__WIN32__)
slouken@1330
   449
slouken@1465
   450
#if !defined(HAVE_LIBC) || (defined(__WATCOMC__) && defined(BUILD_DLL))
slouken@1465
   451
/* Need to include DllMain() on Watcom C for some reason.. */
slouken@5090
   452
#include "core/windows/SDL_windows.h"
slouken@1330
   453
slouken@1895
   454
BOOL APIENTRY
slouken@1895
   455
_DllMainCRTStartup(HANDLE hModule,
slouken@1895
   456
                   DWORD ul_reason_for_call, LPVOID lpReserved)
slouken@1330
   457
{
slouken@1895
   458
    switch (ul_reason_for_call) {
slouken@1895
   459
    case DLL_PROCESS_ATTACH:
slouken@1895
   460
    case DLL_THREAD_ATTACH:
slouken@1895
   461
    case DLL_THREAD_DETACH:
slouken@1895
   462
    case DLL_PROCESS_DETACH:
slouken@1895
   463
        break;
slouken@1895
   464
    }
slouken@1895
   465
    return TRUE;
slouken@1330
   466
}
slouken@1465
   467
#endif /* building DLL with Watcom C */
slouken@1330
   468
slouken@5086
   469
#endif /* __WIN32__ */
slouken@1895
   470
jorgen@6927
   471
/* vi: set sts=4 ts=4 sw=4 expandtab: */