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