src/SDL.c
author Sam Lantinga <slouken@libsdl.org>
Wed, 03 Jan 2018 10:03:25 -0800
changeset 11811 5d94cb6b24d3
parent 10955 82bec2d58a45
child 11882 0ee27779b86f
permissions -rw-r--r--
Updated copyright for 2018
slouken@0
     1
/*
slouken@5535
     2
  Simple DirectMedia Layer
slouken@11811
     3
  Copyright (C) 1997-2018 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
*/
icculus@8093
    21
#include "./SDL_internal.h"
slouken@0
    22
slouken@7828
    23
#if defined(__WIN32__)
slouken@7828
    24
#include "core/windows/SDL_windows.h"
slouken@7828
    25
#endif
slouken@7828
    26
slouken@0
    27
/* Initialization code for SDL */
slouken@0
    28
slouken@1361
    29
#include "SDL.h"
jorgen@6866
    30
#include "SDL_bits.h"
slouken@5310
    31
#include "SDL_revision.h"
slouken@4472
    32
#include "SDL_assert_c.h"
slouken@7360
    33
#include "events/SDL_events_c.h"
slouken@4472
    34
#include "haptic/SDL_haptic_c.h"
slouken@4472
    35
#include "joystick/SDL_joystick_c.h"
slouken@3647
    36
slouken@0
    37
/* Initialization/Cleanup routines */
slouken@1361
    38
#if !SDL_TIMERS_DISABLED
slouken@10609
    39
# include "timer/SDL_timer_c.h"
slouken@0
    40
#endif
slouken@7110
    41
#if SDL_VIDEO_DRIVER_WINDOWS
slouken@2713
    42
extern int SDL_HelperWindowCreate(void);
slouken@2713
    43
extern int SDL_HelperWindowDestroy(void);
slouken@2713
    44
#endif
slouken@0
    45
slouken@3647
    46
slouken@0
    47
/* The initialized subsystems */
slouken@7281
    48
#ifdef SDL_MAIN_NEEDED
slouken@7281
    49
static SDL_bool SDL_MainIsReady = SDL_FALSE;
slouken@7281
    50
#else
slouken@7281
    51
static SDL_bool SDL_MainIsReady = SDL_TRUE;
slouken@7281
    52
#endif
slouken@6690
    53
static SDL_bool SDL_bInMainQuit = SDL_FALSE;
jorgen@6866
    54
static Uint8 SDL_SubsystemRefCount[ 32 ];
slouken@0
    55
jorgen@6866
    56
/* Private helper to increment a subsystem's ref counter. */
jorgen@6867
    57
static void
jorgen@6867
    58
SDL_PrivateSubsystemRefCountIncr(Uint32 subsystem)
slouken@6690
    59
{
jorgen@6866
    60
    int subsystem_index = SDL_MostSignificantBitIndex32(subsystem);
jorgen@6866
    61
    SDL_assert(SDL_SubsystemRefCount[subsystem_index] < 255);
jorgen@6866
    62
    ++SDL_SubsystemRefCount[subsystem_index];
jorgen@6866
    63
}
slouken@6690
    64
jorgen@6866
    65
/* Private helper to decrement a subsystem's ref counter. */
jorgen@6867
    66
static void
jorgen@6867
    67
SDL_PrivateSubsystemRefCountDecr(Uint32 subsystem)
jorgen@6866
    68
{
jorgen@6866
    69
    int subsystem_index = SDL_MostSignificantBitIndex32(subsystem);
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);
icculus@10925
    81
    return (SDL_SubsystemRefCount[subsystem_index] == 0) ? SDL_TRUE : SDL_FALSE;
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
     */
icculus@10925
    95
    return (SDL_SubsystemRefCount[subsystem_index] == 1 || SDL_bInMainQuit) ? SDL_TRUE : SDL_FALSE;
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
slouken@10549
   115
    if ((flags & SDL_INIT_GAMECONTROLLER)) {
slouken@10549
   116
        /* game controller implies joystick */
slouken@10549
   117
        flags |= SDL_INIT_JOYSTICK;
slouken@10549
   118
    }
slouken@10549
   119
slouken@10549
   120
    if ((flags & (SDL_INIT_VIDEO|SDL_INIT_JOYSTICK))) {
slouken@10549
   121
        /* video or joystick implies events */
slouken@10549
   122
        flags |= SDL_INIT_EVENTS;
slouken@10549
   123
    }
slouken@10549
   124
icculus@7590
   125
#if SDL_VIDEO_DRIVER_WINDOWS
slouken@7918
   126
	if ((flags & (SDL_INIT_HAPTIC|SDL_INIT_JOYSTICK))) {
slouken@7918
   127
		if (SDL_HelperWindowCreate() < 0) {
slouken@7918
   128
			return -1;
slouken@7918
   129
		}
slouken@7918
   130
	}
icculus@7590
   131
#endif
icculus@7590
   132
slouken@6128
   133
#if !SDL_TIMERS_DISABLED
slouken@8268
   134
    SDL_TicksInit();
jorgen@6866
   135
#endif
slouken@6690
   136
slouken@7360
   137
    /* Initialize the event subsystem */
slouken@7360
   138
    if ((flags & SDL_INIT_EVENTS)) {
slouken@7360
   139
#if !SDL_EVENTS_DISABLED
slouken@7360
   140
        if (SDL_PrivateShouldInitSubsystem(SDL_INIT_EVENTS)) {
slouken@7360
   141
            if (SDL_StartEventLoop() < 0) {
slouken@7360
   142
                return (-1);
slouken@7360
   143
            }
slouken@7360
   144
            SDL_QuitInit();
slouken@7360
   145
        }
slouken@7360
   146
        SDL_PrivateSubsystemRefCountIncr(SDL_INIT_EVENTS);
slouken@7360
   147
#else
slouken@7360
   148
        return SDL_SetError("SDL not built with events support");
slouken@7360
   149
#endif
slouken@7360
   150
    }
slouken@7360
   151
jorgen@6866
   152
    /* Initialize the timer subsystem */
slouken@7360
   153
    if ((flags & SDL_INIT_TIMER)){
jorgen@6866
   154
#if !SDL_TIMERS_DISABLED
jorgen@6927
   155
        if (SDL_PrivateShouldInitSubsystem(SDL_INIT_TIMER)) {
jorgen@6924
   156
            if (SDL_TimerInit() < 0) {
jorgen@6924
   157
                return (-1);
jorgen@6924
   158
            }
jorgen@6866
   159
        }
jorgen@6866
   160
        SDL_PrivateSubsystemRefCountIncr(SDL_INIT_TIMER);
slouken@6128
   161
#else
icculus@7037
   162
        return SDL_SetError("SDL not built with timer support");
jorgen@6866
   163
#endif
slouken@6128
   164
    }
slouken@6128
   165
slouken@7360
   166
    /* Initialize the video subsystem */
slouken@7360
   167
    if ((flags & SDL_INIT_VIDEO)){
slouken@1361
   168
#if !SDL_VIDEO_DISABLED
jorgen@6927
   169
        if (SDL_PrivateShouldInitSubsystem(SDL_INIT_VIDEO)) {
jorgen@6924
   170
            if (SDL_VideoInit(NULL) < 0) {
jorgen@6924
   171
                return (-1);
jorgen@6924
   172
            }
jorgen@6866
   173
        }
jorgen@6866
   174
        SDL_PrivateSubsystemRefCountIncr(SDL_INIT_VIDEO);
slouken@0
   175
#else
icculus@7037
   176
        return SDL_SetError("SDL not built with video support");
jorgen@6866
   177
#endif
slouken@1895
   178
    }
slouken@0
   179
jorgen@6866
   180
    /* Initialize the audio subsystem */
slouken@7360
   181
    if ((flags & SDL_INIT_AUDIO)){
slouken@1361
   182
#if !SDL_AUDIO_DISABLED
jorgen@6927
   183
        if (SDL_PrivateShouldInitSubsystem(SDL_INIT_AUDIO)) {
jorgen@6924
   184
            if (SDL_AudioInit(NULL) < 0) {
jorgen@6924
   185
                return (-1);
jorgen@6924
   186
            }
jorgen@6866
   187
        }
jorgen@6866
   188
        SDL_PrivateSubsystemRefCountIncr(SDL_INIT_AUDIO);
slouken@0
   189
#else
icculus@7037
   190
        return SDL_SetError("SDL not built with audio support");
jorgen@6866
   191
#endif
slouken@1895
   192
    }
slouken@0
   193
jorgen@6866
   194
    /* Initialize the joystick subsystem */
slouken@7360
   195
    if ((flags & SDL_INIT_JOYSTICK)){
slouken@1361
   196
#if !SDL_JOYSTICK_DISABLED
jorgen@6927
   197
        if (SDL_PrivateShouldInitSubsystem(SDL_INIT_JOYSTICK)) {
jorgen@6924
   198
           if (SDL_JoystickInit() < 0) {
jorgen@6924
   199
               return (-1);
jorgen@6924
   200
           }
slouken@1895
   201
        }
jorgen@6866
   202
        SDL_PrivateSubsystemRefCountIncr(SDL_INIT_JOYSTICK);
slouken@0
   203
#else
icculus@7037
   204
        return SDL_SetError("SDL not built with joystick support");
jorgen@6866
   205
#endif
slouken@1895
   206
    }
jorgen@6866
   207
slouken@7360
   208
    if ((flags & SDL_INIT_GAMECONTROLLER)){
jorgen@6866
   209
#if !SDL_JOYSTICK_DISABLED
jorgen@6927
   210
        if (SDL_PrivateShouldInitSubsystem(SDL_INIT_GAMECONTROLLER)) {
jorgen@6924
   211
            if (SDL_GameControllerInit() < 0) {
jorgen@6924
   212
                return (-1);
jorgen@6924
   213
            }
jorgen@6866
   214
        }
jorgen@6866
   215
        SDL_PrivateSubsystemRefCountIncr(SDL_INIT_GAMECONTROLLER);
jorgen@6866
   216
#else
icculus@7037
   217
        return SDL_SetError("SDL not built with joystick support");
slouken@0
   218
#endif
jorgen@6866
   219
    }
slouken@0
   220
jorgen@6866
   221
    /* Initialize the haptic subsystem */
slouken@7360
   222
    if ((flags & SDL_INIT_HAPTIC)){
slouken@2713
   223
#if !SDL_HAPTIC_DISABLED
jorgen@6927
   224
        if (SDL_PrivateShouldInitSubsystem(SDL_INIT_HAPTIC)) {
jorgen@6924
   225
            if (SDL_HapticInit() < 0) {
jorgen@6927
   226
                return (-1);
jorgen@6927
   227
            }
jorgen@6866
   228
        }
jorgen@6866
   229
        SDL_PrivateSubsystemRefCountIncr(SDL_INIT_HAPTIC);
slouken@2713
   230
#else
icculus@7037
   231
        return SDL_SetError("SDL not built with haptic (force feedback) support");
jorgen@6866
   232
#endif
slouken@2713
   233
    }
jorgen@6866
   234
slouken@1895
   235
    return (0);
slouken@0
   236
}
slouken@0
   237
slouken@1895
   238
int
slouken@1895
   239
SDL_Init(Uint32 flags)
slouken@0
   240
{
icculus@7590
   241
    return SDL_InitSubSystem(flags);
slouken@0
   242
}
slouken@0
   243
slouken@1895
   244
void
slouken@1895
   245
SDL_QuitSubSystem(Uint32 flags)
slouken@0
   246
{
slouken@1895
   247
    /* Shut down requested initialized subsystems */
slouken@1361
   248
#if !SDL_JOYSTICK_DISABLED
jorgen@6866
   249
    if ((flags & SDL_INIT_GAMECONTROLLER)) {
slouken@7360
   250
        /* game controller implies joystick */
jorgen@6866
   251
        flags |= SDL_INIT_JOYSTICK;
jorgen@6866
   252
jorgen@6866
   253
        if (SDL_PrivateShouldQuitSubsystem(SDL_INIT_GAMECONTROLLER)) {
jorgen@6866
   254
            SDL_GameControllerQuit();
slouken@7191
   255
        }
jorgen@6866
   256
        SDL_PrivateSubsystemRefCountDecr(SDL_INIT_GAMECONTROLLER);
jorgen@6866
   257
    }
slouken@6690
   258
jorgen@6866
   259
    if ((flags & SDL_INIT_JOYSTICK)) {
slouken@7360
   260
        /* joystick implies events */
slouken@7360
   261
        flags |= SDL_INIT_EVENTS;
slouken@7360
   262
jorgen@6866
   263
        if (SDL_PrivateShouldQuitSubsystem(SDL_INIT_JOYSTICK)) {
slouken@7191
   264
            SDL_JoystickQuit();
slouken@7191
   265
        }
jorgen@6866
   266
        SDL_PrivateSubsystemRefCountDecr(SDL_INIT_JOYSTICK);
slouken@1895
   267
    }
slouken@0
   268
#endif
jorgen@6866
   269
slouken@2713
   270
#if !SDL_HAPTIC_DISABLED
jorgen@6866
   271
    if ((flags & SDL_INIT_HAPTIC)) {
jorgen@6866
   272
        if (SDL_PrivateShouldQuitSubsystem(SDL_INIT_HAPTIC)) {
slouken@7191
   273
            SDL_HapticQuit();
slouken@7191
   274
        }
jorgen@6866
   275
        SDL_PrivateSubsystemRefCountDecr(SDL_INIT_HAPTIC);
slouken@2713
   276
    }
slouken@2713
   277
#endif
jorgen@6866
   278
slouken@1361
   279
#if !SDL_AUDIO_DISABLED
jorgen@6866
   280
    if ((flags & SDL_INIT_AUDIO)) {
jorgen@6866
   281
        if (SDL_PrivateShouldQuitSubsystem(SDL_INIT_AUDIO)) {
slouken@7191
   282
            SDL_AudioQuit();
slouken@7191
   283
        }
jorgen@6866
   284
        SDL_PrivateSubsystemRefCountDecr(SDL_INIT_AUDIO);
slouken@1895
   285
    }
slouken@0
   286
#endif
jorgen@6866
   287
slouken@1361
   288
#if !SDL_VIDEO_DISABLED
jorgen@6866
   289
    if ((flags & SDL_INIT_VIDEO)) {
slouken@7360
   290
        /* video implies events */
slouken@7360
   291
        flags |= SDL_INIT_EVENTS;
slouken@7360
   292
jorgen@6866
   293
        if (SDL_PrivateShouldQuitSubsystem(SDL_INIT_VIDEO)) {
slouken@7191
   294
            SDL_VideoQuit();
slouken@7191
   295
        }
jorgen@6866
   296
        SDL_PrivateSubsystemRefCountDecr(SDL_INIT_VIDEO);
slouken@1895
   297
    }
slouken@0
   298
#endif
jorgen@6866
   299
slouken@6128
   300
#if !SDL_TIMERS_DISABLED
jorgen@6866
   301
    if ((flags & SDL_INIT_TIMER)) {
jorgen@6866
   302
        if (SDL_PrivateShouldQuitSubsystem(SDL_INIT_TIMER)) {
slouken@7191
   303
            SDL_TimerQuit();
slouken@7191
   304
        }
jorgen@6866
   305
        SDL_PrivateSubsystemRefCountDecr(SDL_INIT_TIMER);
slouken@6128
   306
    }
slouken@6128
   307
#endif
slouken@7360
   308
slouken@7360
   309
#if !SDL_EVENTS_DISABLED
slouken@7360
   310
    if ((flags & SDL_INIT_EVENTS)) {
slouken@7360
   311
        if (SDL_PrivateShouldQuitSubsystem(SDL_INIT_EVENTS)) {
slouken@7360
   312
            SDL_QuitQuit();
slouken@7360
   313
            SDL_StopEventLoop();
slouken@7360
   314
        }
slouken@7360
   315
        SDL_PrivateSubsystemRefCountDecr(SDL_INIT_EVENTS);
slouken@7360
   316
    }
slouken@7360
   317
#endif
slouken@0
   318
}
slouken@0
   319
slouken@1895
   320
Uint32
slouken@1895
   321
SDL_WasInit(Uint32 flags)
slouken@0
   322
{
jorgen@6866
   323
    int i;
jorgen@6866
   324
    int num_subsystems = SDL_arraysize(SDL_SubsystemRefCount);
jorgen@6866
   325
    Uint32 initialized = 0;
jorgen@6866
   326
slouken@1895
   327
    if (!flags) {
slouken@1895
   328
        flags = SDL_INIT_EVERYTHING;
slouken@1895
   329
    }
jorgen@6866
   330
jorgen@6866
   331
    num_subsystems = SDL_min(num_subsystems, SDL_MostSignificantBitIndex32(flags) + 1);
jorgen@6866
   332
jorgen@6866
   333
    /* Iterate over each bit in flags, and check the matching subsystem. */
jorgen@6866
   334
    for (i = 0; i < num_subsystems; ++i) {
jorgen@6866
   335
        if ((flags & 1) && SDL_SubsystemRefCount[i] > 0) {
jorgen@6866
   336
            initialized |= (1 << i);
jorgen@6866
   337
        }
jorgen@6866
   338
jorgen@6866
   339
        flags >>= 1;
jorgen@6866
   340
    }
jorgen@6866
   341
jorgen@6866
   342
    return initialized;
slouken@0
   343
}
slouken@0
   344
slouken@1895
   345
void
slouken@1895
   346
SDL_Quit(void)
slouken@0
   347
{
jorgen@6866
   348
    SDL_bInMainQuit = SDL_TRUE;
jorgen@6866
   349
slouken@1895
   350
    /* Quit all subsystems */
slouken@7110
   351
#if SDL_VIDEO_DRIVER_WINDOWS
slouken@2713
   352
    SDL_HelperWindowDestroy();
slouken@2713
   353
#endif
slouken@1895
   354
    SDL_QuitSubSystem(SDL_INIT_EVERYTHING);
slouken@0
   355
slouken@8268
   356
#if !SDL_TIMERS_DISABLED
slouken@8268
   357
    SDL_TicksQuit();
slouken@8268
   358
#endif
slouken@8268
   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 __BSDI__
slouken@3319
   402
    return "BSDI";
slouken@3319
   403
#elif __DREAMCAST__
slouken@3319
   404
    return "Dreamcast";
philipp@9341
   405
#elif __EMSCRIPTEN__
philipp@9341
   406
    return "Emscripten";
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@8886
   423
#elif __NACL__
slouken@8886
   424
    return "NaCl";
slouken@3319
   425
#elif __NETBSD__
slouken@3319
   426
    return "NetBSD";
slouken@3319
   427
#elif __OPENBSD__
slouken@3319
   428
    return "OpenBSD";
slouken@3319
   429
#elif __OS2__
slouken@3319
   430
    return "OS/2";
slouken@3319
   431
#elif __OSF__
slouken@3319
   432
    return "OSF/1";
slouken@3319
   433
#elif __QNXNTO__
slouken@3319
   434
    return "QNX Neutrino";
slouken@3319
   435
#elif __RISCOS__
slouken@3319
   436
    return "RISC OS";
slouken@3319
   437
#elif __SOLARIS__
slouken@3319
   438
    return "Solaris";
slouken@5086
   439
#elif __WIN32__
slouken@3319
   440
    return "Windows";
dludwig@9223
   441
#elif __WINRT__
dludwig@9223
   442
    return "WinRT";
slime73@10340
   443
#elif __TVOS__
slime73@10340
   444
    return "tvOS";
slouken@3319
   445
#elif __IPHONEOS__
slouken@7592
   446
    return "iOS";
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@1330
   458
slouken@1895
   459
BOOL APIENTRY
slouken@1895
   460
_DllMainCRTStartup(HANDLE hModule,
slouken@1895
   461
                   DWORD ul_reason_for_call, LPVOID lpReserved)
slouken@1330
   462
{
slouken@1895
   463
    switch (ul_reason_for_call) {
slouken@1895
   464
    case DLL_PROCESS_ATTACH:
slouken@1895
   465
    case DLL_THREAD_ATTACH:
slouken@1895
   466
    case DLL_THREAD_DETACH:
slouken@1895
   467
    case DLL_PROCESS_DETACH:
slouken@1895
   468
        break;
slouken@1895
   469
    }
slouken@1895
   470
    return TRUE;
slouken@1330
   471
}
slouken@1465
   472
#endif /* building DLL with Watcom C */
slouken@1330
   473
slouken@5086
   474
#endif /* __WIN32__ */
slouken@1895
   475
jorgen@6927
   476
/* vi: set sts=4 ts=4 sw=4 expandtab: */