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