src/SDL.c
author Ryan C. Gordon <icculus@icculus.org>
Sat, 01 Apr 2017 00:46:15 -0400
changeset 10954 b2804f1267bb
parent 10925 4de9d54bbc87
child 10955 82bec2d58a45
permissions -rw-r--r--
Intentionally breaking buildbot to test email server change.
icculus@10954
     1
sdfsdf
slouken@0
     2
/*
slouken@5535
     3
  Simple DirectMedia Layer
slouken@10737
     4
  Copyright (C) 1997-2017 Sam Lantinga <slouken@libsdl.org>
slouken@0
     5
slouken@5535
     6
  This software is provided 'as-is', without any express or implied
slouken@5535
     7
  warranty.  In no event will the authors be held liable for any damages
slouken@5535
     8
  arising from the use of this software.
slouken@0
     9
slouken@5535
    10
  Permission is granted to anyone to use this software for any purpose,
slouken@5535
    11
  including commercial applications, and to alter it and redistribute it
slouken@5535
    12
  freely, subject to the following restrictions:
slouken@0
    13
slouken@5535
    14
  1. The origin of this software must not be misrepresented; you must not
slouken@5535
    15
     claim that you wrote the original software. If you use this software
slouken@5535
    16
     in a product, an acknowledgment in the product documentation would be
slouken@5535
    17
     appreciated but is not required.
slouken@5535
    18
  2. Altered source versions must be plainly marked as such, and must not be
slouken@5535
    19
     misrepresented as being the original software.
slouken@5535
    20
  3. This notice may not be removed or altered from any source distribution.
slouken@0
    21
*/
icculus@8093
    22
#include "./SDL_internal.h"
slouken@0
    23
slouken@7828
    24
#if defined(__WIN32__)
slouken@7828
    25
#include "core/windows/SDL_windows.h"
slouken@7828
    26
#endif
slouken@7828
    27
slouken@0
    28
/* Initialization code for SDL */
slouken@0
    29
slouken@1361
    30
#include "SDL.h"
jorgen@6866
    31
#include "SDL_bits.h"
slouken@5310
    32
#include "SDL_revision.h"
slouken@4472
    33
#include "SDL_assert_c.h"
slouken@7360
    34
#include "events/SDL_events_c.h"
slouken@4472
    35
#include "haptic/SDL_haptic_c.h"
slouken@4472
    36
#include "joystick/SDL_joystick_c.h"
slouken@3647
    37
slouken@0
    38
/* Initialization/Cleanup routines */
slouken@1361
    39
#if !SDL_TIMERS_DISABLED
slouken@10609
    40
# include "timer/SDL_timer_c.h"
slouken@0
    41
#endif
slouken@7110
    42
#if SDL_VIDEO_DRIVER_WINDOWS
slouken@2713
    43
extern int SDL_HelperWindowCreate(void);
slouken@2713
    44
extern int SDL_HelperWindowDestroy(void);
slouken@2713
    45
#endif
slouken@0
    46
slouken@3647
    47
slouken@0
    48
/* The initialized subsystems */
slouken@7281
    49
#ifdef SDL_MAIN_NEEDED
slouken@7281
    50
static SDL_bool SDL_MainIsReady = SDL_FALSE;
slouken@7281
    51
#else
slouken@7281
    52
static SDL_bool SDL_MainIsReady = SDL_TRUE;
slouken@7281
    53
#endif
slouken@6690
    54
static SDL_bool SDL_bInMainQuit = SDL_FALSE;
jorgen@6866
    55
static Uint8 SDL_SubsystemRefCount[ 32 ];
slouken@0
    56
jorgen@6866
    57
/* Private helper to increment a subsystem's ref counter. */
jorgen@6867
    58
static void
jorgen@6867
    59
SDL_PrivateSubsystemRefCountIncr(Uint32 subsystem)
slouken@6690
    60
{
jorgen@6866
    61
    int subsystem_index = SDL_MostSignificantBitIndex32(subsystem);
jorgen@6866
    62
    SDL_assert(SDL_SubsystemRefCount[subsystem_index] < 255);
jorgen@6866
    63
    ++SDL_SubsystemRefCount[subsystem_index];
jorgen@6866
    64
}
slouken@6690
    65
jorgen@6866
    66
/* Private helper to decrement a subsystem's ref counter. */
jorgen@6867
    67
static void
jorgen@6867
    68
SDL_PrivateSubsystemRefCountDecr(Uint32 subsystem)
jorgen@6866
    69
{
jorgen@6866
    70
    int subsystem_index = SDL_MostSignificantBitIndex32(subsystem);
jorgen@6866
    71
    if (SDL_SubsystemRefCount[subsystem_index] > 0) {
jorgen@6866
    72
        --SDL_SubsystemRefCount[subsystem_index];
jorgen@6866
    73
    }
jorgen@6866
    74
}
jorgen@6866
    75
jorgen@6866
    76
/* Private helper to check if a system needs init. */
jorgen@6866
    77
static SDL_bool
jorgen@6927
    78
SDL_PrivateShouldInitSubsystem(Uint32 subsystem)
jorgen@6866
    79
{
jorgen@6927
    80
    int subsystem_index = SDL_MostSignificantBitIndex32(subsystem);
jorgen@6866
    81
    SDL_assert(SDL_SubsystemRefCount[subsystem_index] < 255);
icculus@10925
    82
    return (SDL_SubsystemRefCount[subsystem_index] == 0) ? SDL_TRUE : SDL_FALSE;
jorgen@6866
    83
}
jorgen@6866
    84
jorgen@6866
    85
/* Private helper to check if a system needs to be quit. */
jorgen@6866
    86
static SDL_bool
jorgen@6866
    87
SDL_PrivateShouldQuitSubsystem(Uint32 subsystem) {
jorgen@6866
    88
    int subsystem_index = SDL_MostSignificantBitIndex32(subsystem);
jorgen@6866
    89
    if (SDL_SubsystemRefCount[subsystem_index] == 0) {
jorgen@6866
    90
      return SDL_FALSE;
jorgen@6866
    91
    }
jorgen@6866
    92
jorgen@6866
    93
    /* If we're in SDL_Quit, we shut down every subsystem, even if refcount
jorgen@6866
    94
     * isn't zero.
jorgen@6866
    95
     */
icculus@10925
    96
    return (SDL_SubsystemRefCount[subsystem_index] == 1 || SDL_bInMainQuit) ? SDL_TRUE : SDL_FALSE;
slouken@6690
    97
}
slouken@0
    98
slouken@7281
    99
void
slouken@7281
   100
SDL_SetMainReady(void)
slouken@7281
   101
{
slouken@7281
   102
    SDL_MainIsReady = SDL_TRUE;
slouken@7281
   103
}
slouken@7281
   104
slouken@1895
   105
int
slouken@1895
   106
SDL_InitSubSystem(Uint32 flags)
slouken@0
   107
{
slouken@7281
   108
    if (!SDL_MainIsReady) {
slouken@7281
   109
        SDL_SetError("Application didn't initialize properly, did you include SDL_main.h in the file containing your main() function?");
slouken@7281
   110
        return -1;
slouken@7281
   111
    }
slouken@7281
   112
icculus@7590
   113
    /* Clear the error message */
icculus@7590
   114
    SDL_ClearError();
icculus@7590
   115
slouken@10549
   116
    if ((flags & SDL_INIT_GAMECONTROLLER)) {
slouken@10549
   117
        /* game controller implies joystick */
slouken@10549
   118
        flags |= SDL_INIT_JOYSTICK;
slouken@10549
   119
    }
slouken@10549
   120
slouken@10549
   121
    if ((flags & (SDL_INIT_VIDEO|SDL_INIT_JOYSTICK))) {
slouken@10549
   122
        /* video or joystick implies events */
slouken@10549
   123
        flags |= SDL_INIT_EVENTS;
slouken@10549
   124
    }
slouken@10549
   125
icculus@7590
   126
#if SDL_VIDEO_DRIVER_WINDOWS
slouken@7918
   127
	if ((flags & (SDL_INIT_HAPTIC|SDL_INIT_JOYSTICK))) {
slouken@7918
   128
		if (SDL_HelperWindowCreate() < 0) {
slouken@7918
   129
			return -1;
slouken@7918
   130
		}
slouken@7918
   131
	}
icculus@7590
   132
#endif
icculus@7590
   133
slouken@6128
   134
#if !SDL_TIMERS_DISABLED
slouken@8268
   135
    SDL_TicksInit();
jorgen@6866
   136
#endif
slouken@6690
   137
slouken@7360
   138
    /* Initialize the event subsystem */
slouken@7360
   139
    if ((flags & SDL_INIT_EVENTS)) {
slouken@7360
   140
#if !SDL_EVENTS_DISABLED
slouken@7360
   141
        if (SDL_PrivateShouldInitSubsystem(SDL_INIT_EVENTS)) {
slouken@7360
   142
            if (SDL_StartEventLoop() < 0) {
slouken@7360
   143
                return (-1);
slouken@7360
   144
            }
slouken@7360
   145
            SDL_QuitInit();
slouken@7360
   146
        }
slouken@7360
   147
        SDL_PrivateSubsystemRefCountIncr(SDL_INIT_EVENTS);
slouken@7360
   148
#else
slouken@7360
   149
        return SDL_SetError("SDL not built with events support");
slouken@7360
   150
#endif
slouken@7360
   151
    }
slouken@7360
   152
jorgen@6866
   153
    /* Initialize the timer subsystem */
slouken@7360
   154
    if ((flags & SDL_INIT_TIMER)){
jorgen@6866
   155
#if !SDL_TIMERS_DISABLED
jorgen@6927
   156
        if (SDL_PrivateShouldInitSubsystem(SDL_INIT_TIMER)) {
jorgen@6924
   157
            if (SDL_TimerInit() < 0) {
jorgen@6924
   158
                return (-1);
jorgen@6924
   159
            }
jorgen@6866
   160
        }
jorgen@6866
   161
        SDL_PrivateSubsystemRefCountIncr(SDL_INIT_TIMER);
slouken@6128
   162
#else
icculus@7037
   163
        return SDL_SetError("SDL not built with timer support");
jorgen@6866
   164
#endif
slouken@6128
   165
    }
slouken@6128
   166
slouken@7360
   167
    /* Initialize the video subsystem */
slouken@7360
   168
    if ((flags & SDL_INIT_VIDEO)){
slouken@1361
   169
#if !SDL_VIDEO_DISABLED
jorgen@6927
   170
        if (SDL_PrivateShouldInitSubsystem(SDL_INIT_VIDEO)) {
jorgen@6924
   171
            if (SDL_VideoInit(NULL) < 0) {
jorgen@6924
   172
                return (-1);
jorgen@6924
   173
            }
jorgen@6866
   174
        }
jorgen@6866
   175
        SDL_PrivateSubsystemRefCountIncr(SDL_INIT_VIDEO);
slouken@0
   176
#else
icculus@7037
   177
        return SDL_SetError("SDL not built with video support");
jorgen@6866
   178
#endif
slouken@1895
   179
    }
slouken@0
   180
jorgen@6866
   181
    /* Initialize the audio subsystem */
slouken@7360
   182
    if ((flags & SDL_INIT_AUDIO)){
slouken@1361
   183
#if !SDL_AUDIO_DISABLED
jorgen@6927
   184
        if (SDL_PrivateShouldInitSubsystem(SDL_INIT_AUDIO)) {
jorgen@6924
   185
            if (SDL_AudioInit(NULL) < 0) {
jorgen@6924
   186
                return (-1);
jorgen@6924
   187
            }
jorgen@6866
   188
        }
jorgen@6866
   189
        SDL_PrivateSubsystemRefCountIncr(SDL_INIT_AUDIO);
slouken@0
   190
#else
icculus@7037
   191
        return SDL_SetError("SDL not built with audio support");
jorgen@6866
   192
#endif
slouken@1895
   193
    }
slouken@0
   194
jorgen@6866
   195
    /* Initialize the joystick subsystem */
slouken@7360
   196
    if ((flags & SDL_INIT_JOYSTICK)){
slouken@1361
   197
#if !SDL_JOYSTICK_DISABLED
jorgen@6927
   198
        if (SDL_PrivateShouldInitSubsystem(SDL_INIT_JOYSTICK)) {
jorgen@6924
   199
           if (SDL_JoystickInit() < 0) {
jorgen@6924
   200
               return (-1);
jorgen@6924
   201
           }
slouken@1895
   202
        }
jorgen@6866
   203
        SDL_PrivateSubsystemRefCountIncr(SDL_INIT_JOYSTICK);
slouken@0
   204
#else
icculus@7037
   205
        return SDL_SetError("SDL not built with joystick support");
jorgen@6866
   206
#endif
slouken@1895
   207
    }
jorgen@6866
   208
slouken@7360
   209
    if ((flags & SDL_INIT_GAMECONTROLLER)){
jorgen@6866
   210
#if !SDL_JOYSTICK_DISABLED
jorgen@6927
   211
        if (SDL_PrivateShouldInitSubsystem(SDL_INIT_GAMECONTROLLER)) {
jorgen@6924
   212
            if (SDL_GameControllerInit() < 0) {
jorgen@6924
   213
                return (-1);
jorgen@6924
   214
            }
jorgen@6866
   215
        }
jorgen@6866
   216
        SDL_PrivateSubsystemRefCountIncr(SDL_INIT_GAMECONTROLLER);
jorgen@6866
   217
#else
icculus@7037
   218
        return SDL_SetError("SDL not built with joystick support");
slouken@0
   219
#endif
jorgen@6866
   220
    }
slouken@0
   221
jorgen@6866
   222
    /* Initialize the haptic subsystem */
slouken@7360
   223
    if ((flags & SDL_INIT_HAPTIC)){
slouken@2713
   224
#if !SDL_HAPTIC_DISABLED
jorgen@6927
   225
        if (SDL_PrivateShouldInitSubsystem(SDL_INIT_HAPTIC)) {
jorgen@6924
   226
            if (SDL_HapticInit() < 0) {
jorgen@6927
   227
                return (-1);
jorgen@6927
   228
            }
jorgen@6866
   229
        }
jorgen@6866
   230
        SDL_PrivateSubsystemRefCountIncr(SDL_INIT_HAPTIC);
slouken@2713
   231
#else
icculus@7037
   232
        return SDL_SetError("SDL not built with haptic (force feedback) support");
jorgen@6866
   233
#endif
slouken@2713
   234
    }
jorgen@6866
   235
slouken@1895
   236
    return (0);
slouken@0
   237
}
slouken@0
   238
slouken@1895
   239
int
slouken@1895
   240
SDL_Init(Uint32 flags)
slouken@0
   241
{
icculus@7590
   242
    return SDL_InitSubSystem(flags);
slouken@0
   243
}
slouken@0
   244
slouken@1895
   245
void
slouken@1895
   246
SDL_QuitSubSystem(Uint32 flags)
slouken@0
   247
{
slouken@1895
   248
    /* Shut down requested initialized subsystems */
slouken@1361
   249
#if !SDL_JOYSTICK_DISABLED
jorgen@6866
   250
    if ((flags & SDL_INIT_GAMECONTROLLER)) {
slouken@7360
   251
        /* game controller implies joystick */
jorgen@6866
   252
        flags |= SDL_INIT_JOYSTICK;
jorgen@6866
   253
jorgen@6866
   254
        if (SDL_PrivateShouldQuitSubsystem(SDL_INIT_GAMECONTROLLER)) {
jorgen@6866
   255
            SDL_GameControllerQuit();
slouken@7191
   256
        }
jorgen@6866
   257
        SDL_PrivateSubsystemRefCountDecr(SDL_INIT_GAMECONTROLLER);
jorgen@6866
   258
    }
slouken@6690
   259
jorgen@6866
   260
    if ((flags & SDL_INIT_JOYSTICK)) {
slouken@7360
   261
        /* joystick implies events */
slouken@7360
   262
        flags |= SDL_INIT_EVENTS;
slouken@7360
   263
jorgen@6866
   264
        if (SDL_PrivateShouldQuitSubsystem(SDL_INIT_JOYSTICK)) {
slouken@7191
   265
            SDL_JoystickQuit();
slouken@7191
   266
        }
jorgen@6866
   267
        SDL_PrivateSubsystemRefCountDecr(SDL_INIT_JOYSTICK);
slouken@1895
   268
    }
slouken@0
   269
#endif
jorgen@6866
   270
slouken@2713
   271
#if !SDL_HAPTIC_DISABLED
jorgen@6866
   272
    if ((flags & SDL_INIT_HAPTIC)) {
jorgen@6866
   273
        if (SDL_PrivateShouldQuitSubsystem(SDL_INIT_HAPTIC)) {
slouken@7191
   274
            SDL_HapticQuit();
slouken@7191
   275
        }
jorgen@6866
   276
        SDL_PrivateSubsystemRefCountDecr(SDL_INIT_HAPTIC);
slouken@2713
   277
    }
slouken@2713
   278
#endif
jorgen@6866
   279
slouken@1361
   280
#if !SDL_AUDIO_DISABLED
jorgen@6866
   281
    if ((flags & SDL_INIT_AUDIO)) {
jorgen@6866
   282
        if (SDL_PrivateShouldQuitSubsystem(SDL_INIT_AUDIO)) {
slouken@7191
   283
            SDL_AudioQuit();
slouken@7191
   284
        }
jorgen@6866
   285
        SDL_PrivateSubsystemRefCountDecr(SDL_INIT_AUDIO);
slouken@1895
   286
    }
slouken@0
   287
#endif
jorgen@6866
   288
slouken@1361
   289
#if !SDL_VIDEO_DISABLED
jorgen@6866
   290
    if ((flags & SDL_INIT_VIDEO)) {
slouken@7360
   291
        /* video implies events */
slouken@7360
   292
        flags |= SDL_INIT_EVENTS;
slouken@7360
   293
jorgen@6866
   294
        if (SDL_PrivateShouldQuitSubsystem(SDL_INIT_VIDEO)) {
slouken@7191
   295
            SDL_VideoQuit();
slouken@7191
   296
        }
jorgen@6866
   297
        SDL_PrivateSubsystemRefCountDecr(SDL_INIT_VIDEO);
slouken@1895
   298
    }
slouken@0
   299
#endif
jorgen@6866
   300
slouken@6128
   301
#if !SDL_TIMERS_DISABLED
jorgen@6866
   302
    if ((flags & SDL_INIT_TIMER)) {
jorgen@6866
   303
        if (SDL_PrivateShouldQuitSubsystem(SDL_INIT_TIMER)) {
slouken@7191
   304
            SDL_TimerQuit();
slouken@7191
   305
        }
jorgen@6866
   306
        SDL_PrivateSubsystemRefCountDecr(SDL_INIT_TIMER);
slouken@6128
   307
    }
slouken@6128
   308
#endif
slouken@7360
   309
slouken@7360
   310
#if !SDL_EVENTS_DISABLED
slouken@7360
   311
    if ((flags & SDL_INIT_EVENTS)) {
slouken@7360
   312
        if (SDL_PrivateShouldQuitSubsystem(SDL_INIT_EVENTS)) {
slouken@7360
   313
            SDL_QuitQuit();
slouken@7360
   314
            SDL_StopEventLoop();
slouken@7360
   315
        }
slouken@7360
   316
        SDL_PrivateSubsystemRefCountDecr(SDL_INIT_EVENTS);
slouken@7360
   317
    }
slouken@7360
   318
#endif
slouken@0
   319
}
slouken@0
   320
slouken@1895
   321
Uint32
slouken@1895
   322
SDL_WasInit(Uint32 flags)
slouken@0
   323
{
jorgen@6866
   324
    int i;
jorgen@6866
   325
    int num_subsystems = SDL_arraysize(SDL_SubsystemRefCount);
jorgen@6866
   326
    Uint32 initialized = 0;
jorgen@6866
   327
slouken@1895
   328
    if (!flags) {
slouken@1895
   329
        flags = SDL_INIT_EVERYTHING;
slouken@1895
   330
    }
jorgen@6866
   331
jorgen@6866
   332
    num_subsystems = SDL_min(num_subsystems, SDL_MostSignificantBitIndex32(flags) + 1);
jorgen@6866
   333
jorgen@6866
   334
    /* Iterate over each bit in flags, and check the matching subsystem. */
jorgen@6866
   335
    for (i = 0; i < num_subsystems; ++i) {
jorgen@6866
   336
        if ((flags & 1) && SDL_SubsystemRefCount[i] > 0) {
jorgen@6866
   337
            initialized |= (1 << i);
jorgen@6866
   338
        }
jorgen@6866
   339
jorgen@6866
   340
        flags >>= 1;
jorgen@6866
   341
    }
jorgen@6866
   342
jorgen@6866
   343
    return initialized;
slouken@0
   344
}
slouken@0
   345
slouken@1895
   346
void
slouken@1895
   347
SDL_Quit(void)
slouken@0
   348
{
jorgen@6866
   349
    SDL_bInMainQuit = SDL_TRUE;
jorgen@6866
   350
slouken@1895
   351
    /* Quit all subsystems */
slouken@7110
   352
#if SDL_VIDEO_DRIVER_WINDOWS
slouken@2713
   353
    SDL_HelperWindowDestroy();
slouken@2713
   354
#endif
slouken@1895
   355
    SDL_QuitSubSystem(SDL_INIT_EVERYTHING);
slouken@0
   356
slouken@8268
   357
#if !SDL_TIMERS_DISABLED
slouken@8268
   358
    SDL_TicksQuit();
slouken@8268
   359
#endif
slouken@8268
   360
slouken@5189
   361
    SDL_ClearHints();
slouken@3647
   362
    SDL_AssertionsQuit();
slouken@5221
   363
    SDL_LogResetPriorities();
slouken@6690
   364
jorgen@6866
   365
    /* Now that every subsystem has been quit, we reset the subsystem refcount
jorgen@6866
   366
     * and the list of initialized subsystems.
jorgen@6866
   367
     */
jorgen@6866
   368
    SDL_memset( SDL_SubsystemRefCount, 0x0, sizeof(SDL_SubsystemRefCount) );
jorgen@6866
   369
jorgen@6866
   370
    SDL_bInMainQuit = SDL_FALSE;
slouken@0
   371
}
slouken@0
   372
slouken@1895
   373
/* Get the library version number */
slouken@1895
   374
void
slouken@1895
   375
SDL_GetVersion(SDL_version * ver)
slouken@0
   376
{
slouken@1895
   377
    SDL_VERSION(ver);
slouken@0
   378
}
slouken@0
   379
slouken@2982
   380
/* Get the library source revision */
icculus@4419
   381
const char *
slouken@2996
   382
SDL_GetRevision(void)
slouken@2982
   383
{
slouken@2983
   384
    return SDL_REVISION;
slouken@2982
   385
}
slouken@2982
   386
slouken@5359
   387
/* Get the library source revision number */
slouken@5359
   388
int
slouken@5359
   389
SDL_GetRevisionNumber(void)
slouken@5359
   390
{
slouken@5359
   391
    return SDL_REVISION_NUMBER;
slouken@5359
   392
}
slouken@5359
   393
slouken@3319
   394
/* Get the name of the platform */
slouken@3319
   395
const char *
slouken@3319
   396
SDL_GetPlatform()
slouken@3319
   397
{
slouken@3319
   398
#if __AIX__
slouken@3319
   399
    return "AIX";
slouken@6441
   400
#elif __ANDROID__
slouken@6441
   401
    return "Android";
slouken@3319
   402
#elif __BSDI__
slouken@3319
   403
    return "BSDI";
slouken@3319
   404
#elif __DREAMCAST__
slouken@3319
   405
    return "Dreamcast";
philipp@9341
   406
#elif __EMSCRIPTEN__
philipp@9341
   407
    return "Emscripten";
slouken@3319
   408
#elif __FREEBSD__
slouken@3319
   409
    return "FreeBSD";
icculus@7346
   410
#elif __HAIKU__
icculus@7346
   411
    return "Haiku";
slouken@3319
   412
#elif __HPUX__
slouken@3319
   413
    return "HP-UX";
slouken@3319
   414
#elif __IRIX__
slouken@3319
   415
    return "Irix";
slouken@3319
   416
#elif __LINUX__
slouken@3319
   417
    return "Linux";
slouken@3319
   418
#elif __MINT__
slouken@3319
   419
    return "Atari MiNT";
slouken@3319
   420
#elif __MACOS__
slouken@3319
   421
    return "MacOS Classic";
slouken@3319
   422
#elif __MACOSX__
slouken@3319
   423
    return "Mac OS X";
slouken@8886
   424
#elif __NACL__
slouken@8886
   425
    return "NaCl";
slouken@3319
   426
#elif __NETBSD__
slouken@3319
   427
    return "NetBSD";
slouken@3319
   428
#elif __OPENBSD__
slouken@3319
   429
    return "OpenBSD";
slouken@3319
   430
#elif __OS2__
slouken@3319
   431
    return "OS/2";
slouken@3319
   432
#elif __OSF__
slouken@3319
   433
    return "OSF/1";
slouken@3319
   434
#elif __QNXNTO__
slouken@3319
   435
    return "QNX Neutrino";
slouken@3319
   436
#elif __RISCOS__
slouken@3319
   437
    return "RISC OS";
slouken@3319
   438
#elif __SOLARIS__
slouken@3319
   439
    return "Solaris";
slouken@5086
   440
#elif __WIN32__
slouken@3319
   441
    return "Windows";
dludwig@9223
   442
#elif __WINRT__
dludwig@9223
   443
    return "WinRT";
slime73@10340
   444
#elif __TVOS__
slime73@10340
   445
    return "tvOS";
slouken@3319
   446
#elif __IPHONEOS__
slouken@7592
   447
    return "iOS";
kimonline@7009
   448
#elif __PSP__
kimonline@7009
   449
    return "PlayStation Portable";
slouken@3319
   450
#else
slouken@3319
   451
    return "Unknown (see SDL_platform.h)";
slouken@3319
   452
#endif
slouken@3319
   453
}
slouken@3319
   454
slouken@5086
   455
#if defined(__WIN32__)
slouken@1330
   456
slouken@1465
   457
#if !defined(HAVE_LIBC) || (defined(__WATCOMC__) && defined(BUILD_DLL))
slouken@1465
   458
/* Need to include DllMain() on Watcom C for some reason.. */
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: */