src/SDL.c
author Ryan C. Gordon <icculus@icculus.org>
Wed, 07 Aug 2013 11:00:44 -0700
changeset 7588 f1ca6adffc4b
parent 7360 b86947ea2749
child 7589 e9a7333d86f0
permissions -rw-r--r--
Removed SDL_AssertionsInit(). It's a no-op, let's keep it that way. :)
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@1895
   229
    /* Clear the error message */
slouken@1895
   230
    SDL_ClearError();
slouken@0
   231
slouken@7110
   232
#if SDL_VIDEO_DRIVER_WINDOWS
slouken@2713
   233
    if (SDL_HelperWindowCreate() < 0) {
slouken@2713
   234
        return -1;
slouken@2713
   235
    }
slouken@2713
   236
#endif
slouken@2713
   237
slouken@1895
   238
    /* Initialize the desired subsystems */
slouken@1895
   239
    if (SDL_InitSubSystem(flags) < 0) {
slouken@1895
   240
        return (-1);
slouken@1895
   241
    }
slouken@0
   242
slouken@1895
   243
    /* Everything is initialized */
slouken@1895
   244
    if (!(flags & SDL_INIT_NOPARACHUTE)) {
slouken@1895
   245
        SDL_InstallParachute();
slouken@1895
   246
    }
slouken@3647
   247
slouken@1895
   248
    return (0);
slouken@0
   249
}
slouken@0
   250
slouken@1895
   251
void
slouken@1895
   252
SDL_QuitSubSystem(Uint32 flags)
slouken@0
   253
{
slouken@1895
   254
    /* Shut down requested initialized subsystems */
slouken@1361
   255
#if !SDL_JOYSTICK_DISABLED
jorgen@6866
   256
    if ((flags & SDL_INIT_GAMECONTROLLER)) {
slouken@7360
   257
        /* game controller implies joystick */
jorgen@6866
   258
        flags |= SDL_INIT_JOYSTICK;
jorgen@6866
   259
jorgen@6866
   260
        if (SDL_PrivateShouldQuitSubsystem(SDL_INIT_GAMECONTROLLER)) {
jorgen@6866
   261
            SDL_GameControllerQuit();
slouken@7191
   262
        }
jorgen@6866
   263
        SDL_PrivateSubsystemRefCountDecr(SDL_INIT_GAMECONTROLLER);
jorgen@6866
   264
    }
slouken@6690
   265
jorgen@6866
   266
    if ((flags & SDL_INIT_JOYSTICK)) {
slouken@7360
   267
        /* joystick implies events */
slouken@7360
   268
        flags |= SDL_INIT_EVENTS;
slouken@7360
   269
jorgen@6866
   270
        if (SDL_PrivateShouldQuitSubsystem(SDL_INIT_JOYSTICK)) {
slouken@7191
   271
            SDL_JoystickQuit();
slouken@7191
   272
        }
jorgen@6866
   273
        SDL_PrivateSubsystemRefCountDecr(SDL_INIT_JOYSTICK);
slouken@1895
   274
    }
slouken@0
   275
#endif
jorgen@6866
   276
slouken@2713
   277
#if !SDL_HAPTIC_DISABLED
jorgen@6866
   278
    if ((flags & SDL_INIT_HAPTIC)) {
jorgen@6866
   279
        if (SDL_PrivateShouldQuitSubsystem(SDL_INIT_HAPTIC)) {
slouken@7191
   280
            SDL_HapticQuit();
slouken@7191
   281
        }
jorgen@6866
   282
        SDL_PrivateSubsystemRefCountDecr(SDL_INIT_HAPTIC);
slouken@2713
   283
    }
slouken@2713
   284
#endif
jorgen@6866
   285
slouken@1361
   286
#if !SDL_AUDIO_DISABLED
jorgen@6866
   287
    if ((flags & SDL_INIT_AUDIO)) {
jorgen@6866
   288
        if (SDL_PrivateShouldQuitSubsystem(SDL_INIT_AUDIO)) {
slouken@7191
   289
            SDL_AudioQuit();
slouken@7191
   290
        }
jorgen@6866
   291
        SDL_PrivateSubsystemRefCountDecr(SDL_INIT_AUDIO);
slouken@1895
   292
    }
slouken@0
   293
#endif
jorgen@6866
   294
slouken@1361
   295
#if !SDL_VIDEO_DISABLED
jorgen@6866
   296
    if ((flags & SDL_INIT_VIDEO)) {
slouken@7360
   297
        /* video implies events */
slouken@7360
   298
        flags |= SDL_INIT_EVENTS;
slouken@7360
   299
jorgen@6866
   300
        if (SDL_PrivateShouldQuitSubsystem(SDL_INIT_VIDEO)) {
slouken@7191
   301
            SDL_VideoQuit();
slouken@7191
   302
        }
jorgen@6866
   303
        SDL_PrivateSubsystemRefCountDecr(SDL_INIT_VIDEO);
slouken@1895
   304
    }
slouken@0
   305
#endif
jorgen@6866
   306
slouken@6128
   307
#if !SDL_TIMERS_DISABLED
jorgen@6866
   308
    if ((flags & SDL_INIT_TIMER)) {
jorgen@6866
   309
        if (SDL_PrivateShouldQuitSubsystem(SDL_INIT_TIMER)) {
slouken@7191
   310
            SDL_TimerQuit();
slouken@7191
   311
        }
jorgen@6866
   312
        SDL_PrivateSubsystemRefCountDecr(SDL_INIT_TIMER);
slouken@6128
   313
    }
slouken@6128
   314
#endif
slouken@7360
   315
slouken@7360
   316
#if !SDL_EVENTS_DISABLED
slouken@7360
   317
    if ((flags & SDL_INIT_EVENTS)) {
slouken@7360
   318
        if (SDL_PrivateShouldQuitSubsystem(SDL_INIT_EVENTS)) {
slouken@7360
   319
            SDL_QuitQuit();
slouken@7360
   320
            SDL_StopEventLoop();
slouken@7360
   321
        }
slouken@7360
   322
        SDL_PrivateSubsystemRefCountDecr(SDL_INIT_EVENTS);
slouken@7360
   323
    }
slouken@7360
   324
#endif
slouken@0
   325
}
slouken@0
   326
slouken@1895
   327
Uint32
slouken@1895
   328
SDL_WasInit(Uint32 flags)
slouken@0
   329
{
jorgen@6866
   330
    int i;
jorgen@6866
   331
    int num_subsystems = SDL_arraysize(SDL_SubsystemRefCount);
jorgen@6866
   332
    Uint32 initialized = 0;
jorgen@6866
   333
slouken@1895
   334
    if (!flags) {
slouken@1895
   335
        flags = SDL_INIT_EVERYTHING;
slouken@1895
   336
    }
jorgen@6866
   337
jorgen@6866
   338
    num_subsystems = SDL_min(num_subsystems, SDL_MostSignificantBitIndex32(flags) + 1);
jorgen@6866
   339
jorgen@6866
   340
    /* Iterate over each bit in flags, and check the matching subsystem. */
jorgen@6866
   341
    for (i = 0; i < num_subsystems; ++i) {
jorgen@6866
   342
        if ((flags & 1) && SDL_SubsystemRefCount[i] > 0) {
jorgen@6866
   343
            initialized |= (1 << i);
jorgen@6866
   344
        }
jorgen@6866
   345
jorgen@6866
   346
        flags >>= 1;
jorgen@6866
   347
    }
jorgen@6866
   348
jorgen@6866
   349
    return initialized;
slouken@0
   350
}
slouken@0
   351
slouken@1895
   352
void
slouken@1895
   353
SDL_Quit(void)
slouken@0
   354
{
jorgen@6866
   355
    SDL_bInMainQuit = SDL_TRUE;
jorgen@6866
   356
slouken@1895
   357
    /* Quit all subsystems */
slouken@7110
   358
#if SDL_VIDEO_DRIVER_WINDOWS
slouken@2713
   359
    SDL_HelperWindowDestroy();
slouken@2713
   360
#endif
slouken@1895
   361
    SDL_QuitSubSystem(SDL_INIT_EVERYTHING);
slouken@0
   362
slouken@1895
   363
    /* Uninstall any parachute signal handlers */
slouken@1895
   364
    SDL_UninstallParachute();
slouken@397
   365
slouken@5189
   366
    SDL_ClearHints();
slouken@3647
   367
    SDL_AssertionsQuit();
slouken@5221
   368
    SDL_LogResetPriorities();
slouken@6690
   369
jorgen@6866
   370
    /* Now that every subsystem has been quit, we reset the subsystem refcount
jorgen@6866
   371
     * and the list of initialized subsystems.
jorgen@6866
   372
     */
jorgen@6866
   373
    SDL_memset( SDL_SubsystemRefCount, 0x0, sizeof(SDL_SubsystemRefCount) );
jorgen@6866
   374
jorgen@6866
   375
    SDL_bInMainQuit = SDL_FALSE;
slouken@0
   376
}
slouken@0
   377
slouken@1895
   378
/* Get the library version number */
slouken@1895
   379
void
slouken@1895
   380
SDL_GetVersion(SDL_version * ver)
slouken@0
   381
{
slouken@1895
   382
    SDL_VERSION(ver);
slouken@0
   383
}
slouken@0
   384
slouken@2982
   385
/* Get the library source revision */
icculus@4419
   386
const char *
slouken@2996
   387
SDL_GetRevision(void)
slouken@2982
   388
{
slouken@2983
   389
    return SDL_REVISION;
slouken@2982
   390
}
slouken@2982
   391
slouken@5359
   392
/* Get the library source revision number */
slouken@5359
   393
int
slouken@5359
   394
SDL_GetRevisionNumber(void)
slouken@5359
   395
{
slouken@5359
   396
    return SDL_REVISION_NUMBER;
slouken@5359
   397
}
slouken@5359
   398
slouken@3319
   399
/* Get the name of the platform */
slouken@3319
   400
const char *
slouken@3319
   401
SDL_GetPlatform()
slouken@3319
   402
{
slouken@3319
   403
#if __AIX__
slouken@3319
   404
    return "AIX";
slouken@6441
   405
#elif __ANDROID__
slouken@6441
   406
    return "Android";
slouken@3319
   407
#elif __BEOS__
slouken@3319
   408
    return "BeOS";
slouken@3319
   409
#elif __BSDI__
slouken@3319
   410
    return "BSDI";
slouken@3319
   411
#elif __DREAMCAST__
slouken@3319
   412
    return "Dreamcast";
slouken@3319
   413
#elif __FREEBSD__
slouken@3319
   414
    return "FreeBSD";
icculus@7346
   415
#elif __HAIKU__
icculus@7346
   416
    return "Haiku";
slouken@3319
   417
#elif __HPUX__
slouken@3319
   418
    return "HP-UX";
slouken@3319
   419
#elif __IRIX__
slouken@3319
   420
    return "Irix";
slouken@3319
   421
#elif __LINUX__
slouken@3319
   422
    return "Linux";
slouken@3319
   423
#elif __MINT__
slouken@3319
   424
    return "Atari MiNT";
slouken@3319
   425
#elif __MACOS__
slouken@3319
   426
    return "MacOS Classic";
slouken@3319
   427
#elif __MACOSX__
slouken@3319
   428
    return "Mac OS X";
slouken@3319
   429
#elif __NETBSD__
slouken@3319
   430
    return "NetBSD";
slouken@3319
   431
#elif __OPENBSD__
slouken@3319
   432
    return "OpenBSD";
slouken@3319
   433
#elif __OS2__
slouken@3319
   434
    return "OS/2";
slouken@3319
   435
#elif __OSF__
slouken@3319
   436
    return "OSF/1";
slouken@3319
   437
#elif __QNXNTO__
slouken@3319
   438
    return "QNX Neutrino";
slouken@3319
   439
#elif __RISCOS__
slouken@3319
   440
    return "RISC OS";
slouken@3319
   441
#elif __SOLARIS__
slouken@3319
   442
    return "Solaris";
slouken@5086
   443
#elif __WIN32__
slouken@3319
   444
    return "Windows";
slouken@3319
   445
#elif __IPHONEOS__
slouken@3319
   446
    return "iPhone OS";
kimonline@7009
   447
#elif __PSP__
kimonline@7009
   448
    return "PlayStation Portable";
slouken@3319
   449
#else
slouken@3319
   450
    return "Unknown (see SDL_platform.h)";
slouken@3319
   451
#endif
slouken@3319
   452
}
slouken@3319
   453
slouken@5086
   454
#if defined(__WIN32__)
slouken@1330
   455
slouken@1465
   456
#if !defined(HAVE_LIBC) || (defined(__WATCOMC__) && defined(BUILD_DLL))
slouken@1465
   457
/* Need to include DllMain() on Watcom C for some reason.. */
slouken@5090
   458
#include "core/windows/SDL_windows.h"
slouken@1330
   459
slouken@1895
   460
BOOL APIENTRY
slouken@1895
   461
_DllMainCRTStartup(HANDLE hModule,
slouken@1895
   462
                   DWORD ul_reason_for_call, LPVOID lpReserved)
slouken@1330
   463
{
slouken@1895
   464
    switch (ul_reason_for_call) {
slouken@1895
   465
    case DLL_PROCESS_ATTACH:
slouken@1895
   466
    case DLL_THREAD_ATTACH:
slouken@1895
   467
    case DLL_THREAD_DETACH:
slouken@1895
   468
    case DLL_PROCESS_DETACH:
slouken@1895
   469
        break;
slouken@1895
   470
    }
slouken@1895
   471
    return TRUE;
slouken@1330
   472
}
slouken@1465
   473
#endif /* building DLL with Watcom C */
slouken@1330
   474
slouken@5086
   475
#endif /* __WIN32__ */
slouken@1895
   476
jorgen@6927
   477
/* vi: set sts=4 ts=4 sw=4 expandtab: */