src/SDL.c
author Ryan C. Gordon <icculus@icculus.org>
Tue, 26 May 2015 21:13:27 -0400
changeset 9648 e6bf740c92f8
parent 9619 b94b6d0bff0f
child 9649 d7762e30ba24
permissions -rw-r--r--
Added a hint to specify new thread stack size (thanks, Gabriel!).

Fixes Bugzilla #2019.

(we'll do a better fix when we break the API in SDL 2.1.)
slouken@0
     1
/*
slouken@5535
     2
  Simple DirectMedia Layer
slouken@9619
     3
  Copyright (C) 1997-2015 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@1895
    39
extern int SDL_TimerInit(void);
slouken@0
    40
extern void SDL_TimerQuit(void);
slouken@8268
    41
extern void SDL_TicksInit(void);
slouken@8268
    42
extern void SDL_TicksQuit(void);
slouken@0
    43
#endif
slouken@7110
    44
#if SDL_VIDEO_DRIVER_WINDOWS
slouken@2713
    45
extern int SDL_HelperWindowCreate(void);
slouken@2713
    46
extern int SDL_HelperWindowDestroy(void);
slouken@2713
    47
#endif
slouken@0
    48
slouken@3647
    49
slouken@0
    50
/* The initialized subsystems */
slouken@7281
    51
#ifdef SDL_MAIN_NEEDED
slouken@7281
    52
static SDL_bool SDL_MainIsReady = SDL_FALSE;
slouken@7281
    53
#else
slouken@7281
    54
static SDL_bool SDL_MainIsReady = SDL_TRUE;
slouken@7281
    55
#endif
slouken@6690
    56
static SDL_bool SDL_bInMainQuit = SDL_FALSE;
jorgen@6866
    57
static Uint8 SDL_SubsystemRefCount[ 32 ];
slouken@0
    58
jorgen@6866
    59
/* Private helper to increment a subsystem's ref counter. */
jorgen@6867
    60
static void
jorgen@6867
    61
SDL_PrivateSubsystemRefCountIncr(Uint32 subsystem)
slouken@6690
    62
{
jorgen@6866
    63
    int subsystem_index = SDL_MostSignificantBitIndex32(subsystem);
jorgen@6866
    64
    SDL_assert(SDL_SubsystemRefCount[subsystem_index] < 255);
jorgen@6866
    65
    ++SDL_SubsystemRefCount[subsystem_index];
jorgen@6866
    66
}
slouken@6690
    67
jorgen@6866
    68
/* Private helper to decrement a subsystem's ref counter. */
jorgen@6867
    69
static void
jorgen@6867
    70
SDL_PrivateSubsystemRefCountDecr(Uint32 subsystem)
jorgen@6866
    71
{
jorgen@6866
    72
    int subsystem_index = SDL_MostSignificantBitIndex32(subsystem);
jorgen@6866
    73
    if (SDL_SubsystemRefCount[subsystem_index] > 0) {
jorgen@6866
    74
        --SDL_SubsystemRefCount[subsystem_index];
jorgen@6866
    75
    }
jorgen@6866
    76
}
jorgen@6866
    77
jorgen@6866
    78
/* Private helper to check if a system needs init. */
jorgen@6866
    79
static SDL_bool
jorgen@6927
    80
SDL_PrivateShouldInitSubsystem(Uint32 subsystem)
jorgen@6866
    81
{
jorgen@6927
    82
    int subsystem_index = SDL_MostSignificantBitIndex32(subsystem);
jorgen@6866
    83
    SDL_assert(SDL_SubsystemRefCount[subsystem_index] < 255);
jorgen@6866
    84
    return (SDL_SubsystemRefCount[subsystem_index] == 0);
jorgen@6866
    85
}
jorgen@6866
    86
jorgen@6866
    87
/* Private helper to check if a system needs to be quit. */
jorgen@6866
    88
static SDL_bool
jorgen@6866
    89
SDL_PrivateShouldQuitSubsystem(Uint32 subsystem) {
jorgen@6866
    90
    int subsystem_index = SDL_MostSignificantBitIndex32(subsystem);
jorgen@6866
    91
    if (SDL_SubsystemRefCount[subsystem_index] == 0) {
jorgen@6866
    92
      return SDL_FALSE;
jorgen@6866
    93
    }
jorgen@6866
    94
jorgen@6866
    95
    /* If we're in SDL_Quit, we shut down every subsystem, even if refcount
jorgen@6866
    96
     * isn't zero.
jorgen@6866
    97
     */
jorgen@6866
    98
    return SDL_SubsystemRefCount[subsystem_index] == 1 || SDL_bInMainQuit;
slouken@6690
    99
}
slouken@0
   100
slouken@7281
   101
void
slouken@7281
   102
SDL_SetMainReady(void)
slouken@7281
   103
{
slouken@7281
   104
    SDL_MainIsReady = SDL_TRUE;
slouken@7281
   105
}
slouken@7281
   106
slouken@1895
   107
int
slouken@1895
   108
SDL_InitSubSystem(Uint32 flags)
slouken@0
   109
{
icculus@9648
   110
    static Uint32 hints_initialized = SDL_FALSE;
slouken@7281
   111
    if (!SDL_MainIsReady) {
slouken@7281
   112
        SDL_SetError("Application didn't initialize properly, did you include SDL_main.h in the file containing your main() function?");
slouken@7281
   113
        return -1;
slouken@7281
   114
    }
slouken@7281
   115
icculus@7590
   116
    /* Clear the error message */
icculus@7590
   117
    SDL_ClearError();
icculus@9648
   118
    
icculus@9648
   119
    if (hints_initialized == SDL_FALSE) {
icculus@9648
   120
        /* Set a default of -1 for SDL_HINT_THREAD_STACK_SIZE to prevent the
icculus@9648
   121
           end user from interfering it's value with environment variables */
icculus@9648
   122
        SDL_SetHintWithPriority(SDL_HINT_THREAD_STACK_SIZE, "-1", SDL_HINT_OVERRIDE);
icculus@9648
   123
        hints_initialized = SDL_TRUE;
icculus@9648
   124
    }
icculus@7590
   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
    if ((flags & SDL_INIT_GAMECONTROLLER)) {
slouken@7360
   139
        /* game controller implies joystick */
slouken@7360
   140
        flags |= SDL_INIT_JOYSTICK;
slouken@7360
   141
    }
slouken@7360
   142
slouken@7360
   143
    if ((flags & (SDL_INIT_VIDEO|SDL_INIT_JOYSTICK))) {
slouken@7360
   144
        /* video or joystick implies events */
slouken@7360
   145
        flags |= SDL_INIT_EVENTS;
slouken@7360
   146
    }
slouken@7360
   147
slouken@7360
   148
    /* Initialize the event subsystem */
slouken@7360
   149
    if ((flags & SDL_INIT_EVENTS)) {
slouken@7360
   150
#if !SDL_EVENTS_DISABLED
slouken@7360
   151
        if (SDL_PrivateShouldInitSubsystem(SDL_INIT_EVENTS)) {
slouken@7360
   152
            if (SDL_StartEventLoop() < 0) {
slouken@7360
   153
                return (-1);
slouken@7360
   154
            }
slouken@7360
   155
            SDL_QuitInit();
slouken@7360
   156
        }
slouken@7360
   157
        SDL_PrivateSubsystemRefCountIncr(SDL_INIT_EVENTS);
slouken@7360
   158
#else
slouken@7360
   159
        return SDL_SetError("SDL not built with events support");
slouken@7360
   160
#endif
slouken@7360
   161
    }
slouken@7360
   162
jorgen@6866
   163
    /* Initialize the timer subsystem */
slouken@7360
   164
    if ((flags & SDL_INIT_TIMER)){
jorgen@6866
   165
#if !SDL_TIMERS_DISABLED
jorgen@6927
   166
        if (SDL_PrivateShouldInitSubsystem(SDL_INIT_TIMER)) {
jorgen@6924
   167
            if (SDL_TimerInit() < 0) {
jorgen@6924
   168
                return (-1);
jorgen@6924
   169
            }
jorgen@6866
   170
        }
jorgen@6866
   171
        SDL_PrivateSubsystemRefCountIncr(SDL_INIT_TIMER);
slouken@6128
   172
#else
icculus@7037
   173
        return SDL_SetError("SDL not built with timer support");
jorgen@6866
   174
#endif
slouken@6128
   175
    }
slouken@6128
   176
slouken@7360
   177
    /* Initialize the video subsystem */
slouken@7360
   178
    if ((flags & SDL_INIT_VIDEO)){
slouken@1361
   179
#if !SDL_VIDEO_DISABLED
jorgen@6927
   180
        if (SDL_PrivateShouldInitSubsystem(SDL_INIT_VIDEO)) {
jorgen@6924
   181
            if (SDL_VideoInit(NULL) < 0) {
jorgen@6924
   182
                return (-1);
jorgen@6924
   183
            }
jorgen@6866
   184
        }
jorgen@6866
   185
        SDL_PrivateSubsystemRefCountIncr(SDL_INIT_VIDEO);
slouken@0
   186
#else
icculus@7037
   187
        return SDL_SetError("SDL not built with video support");
jorgen@6866
   188
#endif
slouken@1895
   189
    }
slouken@0
   190
jorgen@6866
   191
    /* Initialize the audio subsystem */
slouken@7360
   192
    if ((flags & SDL_INIT_AUDIO)){
slouken@1361
   193
#if !SDL_AUDIO_DISABLED
jorgen@6927
   194
        if (SDL_PrivateShouldInitSubsystem(SDL_INIT_AUDIO)) {
jorgen@6924
   195
            if (SDL_AudioInit(NULL) < 0) {
jorgen@6924
   196
                return (-1);
jorgen@6924
   197
            }
jorgen@6866
   198
        }
jorgen@6866
   199
        SDL_PrivateSubsystemRefCountIncr(SDL_INIT_AUDIO);
slouken@0
   200
#else
icculus@7037
   201
        return SDL_SetError("SDL not built with audio support");
jorgen@6866
   202
#endif
slouken@1895
   203
    }
slouken@0
   204
jorgen@6866
   205
    /* Initialize the joystick subsystem */
slouken@7360
   206
    if ((flags & SDL_INIT_JOYSTICK)){
slouken@1361
   207
#if !SDL_JOYSTICK_DISABLED
jorgen@6927
   208
        if (SDL_PrivateShouldInitSubsystem(SDL_INIT_JOYSTICK)) {
jorgen@6924
   209
           if (SDL_JoystickInit() < 0) {
jorgen@6924
   210
               return (-1);
jorgen@6924
   211
           }
slouken@1895
   212
        }
jorgen@6866
   213
        SDL_PrivateSubsystemRefCountIncr(SDL_INIT_JOYSTICK);
slouken@0
   214
#else
icculus@7037
   215
        return SDL_SetError("SDL not built with joystick support");
jorgen@6866
   216
#endif
slouken@1895
   217
    }
jorgen@6866
   218
slouken@7360
   219
    if ((flags & SDL_INIT_GAMECONTROLLER)){
jorgen@6866
   220
#if !SDL_JOYSTICK_DISABLED
jorgen@6927
   221
        if (SDL_PrivateShouldInitSubsystem(SDL_INIT_GAMECONTROLLER)) {
jorgen@6924
   222
            if (SDL_GameControllerInit() < 0) {
jorgen@6924
   223
                return (-1);
jorgen@6924
   224
            }
jorgen@6866
   225
        }
jorgen@6866
   226
        SDL_PrivateSubsystemRefCountIncr(SDL_INIT_GAMECONTROLLER);
jorgen@6866
   227
#else
icculus@7037
   228
        return SDL_SetError("SDL not built with joystick support");
slouken@0
   229
#endif
jorgen@6866
   230
    }
slouken@0
   231
jorgen@6866
   232
    /* Initialize the haptic subsystem */
slouken@7360
   233
    if ((flags & SDL_INIT_HAPTIC)){
slouken@2713
   234
#if !SDL_HAPTIC_DISABLED
jorgen@6927
   235
        if (SDL_PrivateShouldInitSubsystem(SDL_INIT_HAPTIC)) {
jorgen@6924
   236
            if (SDL_HapticInit() < 0) {
jorgen@6927
   237
                return (-1);
jorgen@6927
   238
            }
jorgen@6866
   239
        }
jorgen@6866
   240
        SDL_PrivateSubsystemRefCountIncr(SDL_INIT_HAPTIC);
slouken@2713
   241
#else
icculus@7037
   242
        return SDL_SetError("SDL not built with haptic (force feedback) support");
jorgen@6866
   243
#endif
slouken@2713
   244
    }
jorgen@6866
   245
slouken@1895
   246
    return (0);
slouken@0
   247
}
slouken@0
   248
slouken@1895
   249
int
slouken@1895
   250
SDL_Init(Uint32 flags)
slouken@0
   251
{
icculus@7590
   252
    return SDL_InitSubSystem(flags);
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@8268
   367
#if !SDL_TIMERS_DISABLED
slouken@8268
   368
    SDL_TicksQuit();
slouken@8268
   369
#endif
slouken@8268
   370
slouken@5189
   371
    SDL_ClearHints();
slouken@3647
   372
    SDL_AssertionsQuit();
slouken@5221
   373
    SDL_LogResetPriorities();
slouken@6690
   374
jorgen@6866
   375
    /* Now that every subsystem has been quit, we reset the subsystem refcount
jorgen@6866
   376
     * and the list of initialized subsystems.
jorgen@6866
   377
     */
jorgen@6866
   378
    SDL_memset( SDL_SubsystemRefCount, 0x0, sizeof(SDL_SubsystemRefCount) );
jorgen@6866
   379
jorgen@6866
   380
    SDL_bInMainQuit = SDL_FALSE;
slouken@0
   381
}
slouken@0
   382
slouken@1895
   383
/* Get the library version number */
slouken@1895
   384
void
slouken@1895
   385
SDL_GetVersion(SDL_version * ver)
slouken@0
   386
{
slouken@1895
   387
    SDL_VERSION(ver);
slouken@0
   388
}
slouken@0
   389
slouken@2982
   390
/* Get the library source revision */
icculus@4419
   391
const char *
slouken@2996
   392
SDL_GetRevision(void)
slouken@2982
   393
{
slouken@2983
   394
    return SDL_REVISION;
slouken@2982
   395
}
slouken@2982
   396
slouken@5359
   397
/* Get the library source revision number */
slouken@5359
   398
int
slouken@5359
   399
SDL_GetRevisionNumber(void)
slouken@5359
   400
{
slouken@5359
   401
    return SDL_REVISION_NUMBER;
slouken@5359
   402
}
slouken@5359
   403
slouken@3319
   404
/* Get the name of the platform */
slouken@3319
   405
const char *
slouken@3319
   406
SDL_GetPlatform()
slouken@3319
   407
{
slouken@3319
   408
#if __AIX__
slouken@3319
   409
    return "AIX";
slouken@6441
   410
#elif __ANDROID__
slouken@6441
   411
    return "Android";
slouken@3319
   412
#elif __BSDI__
slouken@3319
   413
    return "BSDI";
slouken@3319
   414
#elif __DREAMCAST__
slouken@3319
   415
    return "Dreamcast";
philipp@9341
   416
#elif __EMSCRIPTEN__
philipp@9341
   417
    return "Emscripten";
slouken@3319
   418
#elif __FREEBSD__
slouken@3319
   419
    return "FreeBSD";
icculus@7346
   420
#elif __HAIKU__
icculus@7346
   421
    return "Haiku";
slouken@3319
   422
#elif __HPUX__
slouken@3319
   423
    return "HP-UX";
slouken@3319
   424
#elif __IRIX__
slouken@3319
   425
    return "Irix";
slouken@3319
   426
#elif __LINUX__
slouken@3319
   427
    return "Linux";
slouken@3319
   428
#elif __MINT__
slouken@3319
   429
    return "Atari MiNT";
slouken@3319
   430
#elif __MACOS__
slouken@3319
   431
    return "MacOS Classic";
slouken@3319
   432
#elif __MACOSX__
slouken@3319
   433
    return "Mac OS X";
slouken@8886
   434
#elif __NACL__
slouken@8886
   435
    return "NaCl";
slouken@3319
   436
#elif __NETBSD__
slouken@3319
   437
    return "NetBSD";
slouken@3319
   438
#elif __OPENBSD__
slouken@3319
   439
    return "OpenBSD";
slouken@3319
   440
#elif __OS2__
slouken@3319
   441
    return "OS/2";
slouken@3319
   442
#elif __OSF__
slouken@3319
   443
    return "OSF/1";
slouken@3319
   444
#elif __QNXNTO__
slouken@3319
   445
    return "QNX Neutrino";
slouken@3319
   446
#elif __RISCOS__
slouken@3319
   447
    return "RISC OS";
slouken@3319
   448
#elif __SOLARIS__
slouken@3319
   449
    return "Solaris";
slouken@5086
   450
#elif __WIN32__
slouken@3319
   451
    return "Windows";
dludwig@9223
   452
#elif __WINRT__
dludwig@9223
   453
    return "WinRT";
slouken@3319
   454
#elif __IPHONEOS__
slouken@7592
   455
    return "iOS";
kimonline@7009
   456
#elif __PSP__
kimonline@7009
   457
    return "PlayStation Portable";
slouken@3319
   458
#else
slouken@3319
   459
    return "Unknown (see SDL_platform.h)";
slouken@3319
   460
#endif
slouken@3319
   461
}
slouken@3319
   462
slouken@5086
   463
#if defined(__WIN32__)
slouken@1330
   464
slouken@1465
   465
#if !defined(HAVE_LIBC) || (defined(__WATCOMC__) && defined(BUILD_DLL))
slouken@1465
   466
/* Need to include DllMain() on Watcom C for some reason.. */
slouken@1330
   467
slouken@1895
   468
BOOL APIENTRY
slouken@1895
   469
_DllMainCRTStartup(HANDLE hModule,
slouken@1895
   470
                   DWORD ul_reason_for_call, LPVOID lpReserved)
slouken@1330
   471
{
slouken@1895
   472
    switch (ul_reason_for_call) {
slouken@1895
   473
    case DLL_PROCESS_ATTACH:
slouken@1895
   474
    case DLL_THREAD_ATTACH:
slouken@1895
   475
    case DLL_THREAD_DETACH:
slouken@1895
   476
    case DLL_PROCESS_DETACH:
slouken@1895
   477
        break;
slouken@1895
   478
    }
slouken@1895
   479
    return TRUE;
slouken@1330
   480
}
slouken@1465
   481
#endif /* building DLL with Watcom C */
slouken@1330
   482
slouken@5086
   483
#endif /* __WIN32__ */
slouken@1895
   484
jorgen@6927
   485
/* vi: set sts=4 ts=4 sw=4 expandtab: */