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