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