src/SDL.c
author Sam Lantinga <slouken@libsdl.org>
Sat, 01 Mar 2014 09:50:52 -0800
changeset 8268 3f8410f20405
parent 8149 681eb46b8ac4
child 8886 e0aa3fb16668
permissions -rw-r--r--
Fixed bug 2423 - timeBeginPeriod & timeEndPeriod mismatch

Coriiander

In src\timer\windows\SDL_systimer.c there is an error with regards to timeBeginPeriod and timeEndPeriod. These functions typically get called when no high resolution timer is available, and GetTickCount is not used.

According to MSDN (link: http://msdn.microsoft.com/en-us/library/windows/desktop/dd757624(v=vs.85).aspx), for every call to timeBeginPeriod a subsequent call to timeEndPeriod is required. While SDL is currently doing this, it fails to call timeEndPeriod when cleaning up/shutting down SDL. Please note that these functions affect things on a system level. Failing to call timeEndPeriod, disables applications for using WINMM-timers after usage&shutdown of SDL, as effectively they the mechanism is now broken.

Solution:
Ensure this code gets called when shutting down the timer subsystem:

#ifndef USE_GETTICKCOUNT
if (!hires_timer_available)
{
timeSetPeriod(0);
}
#endif
slouken@0
     1
/*
slouken@5535
     2
  Simple DirectMedia Layer
slouken@8149
     3
  Copyright (C) 1997-2014 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
{
slouken@7281
   110
    if (!SDL_MainIsReady) {
slouken@7281
   111
        SDL_SetError("Application didn't initialize properly, did you include SDL_main.h in the file containing your main() function?");
slouken@7281
   112
        return -1;
slouken@7281
   113
    }
slouken@7281
   114
icculus@7590
   115
    /* Clear the error message */
icculus@7590
   116
    SDL_ClearError();
icculus@7590
   117
icculus@7590
   118
#if SDL_VIDEO_DRIVER_WINDOWS
slouken@7918
   119
	if ((flags & (SDL_INIT_HAPTIC|SDL_INIT_JOYSTICK))) {
slouken@7918
   120
		if (SDL_HelperWindowCreate() < 0) {
slouken@7918
   121
			return -1;
slouken@7918
   122
		}
slouken@7918
   123
	}
icculus@7590
   124
#endif
icculus@7590
   125
slouken@6128
   126
#if !SDL_TIMERS_DISABLED
slouken@8268
   127
    SDL_TicksInit();
jorgen@6866
   128
#endif
slouken@6690
   129
slouken@7360
   130
    if ((flags & SDL_INIT_GAMECONTROLLER)) {
slouken@7360
   131
        /* game controller implies joystick */
slouken@7360
   132
        flags |= SDL_INIT_JOYSTICK;
slouken@7360
   133
    }
slouken@7360
   134
slouken@7360
   135
    if ((flags & (SDL_INIT_VIDEO|SDL_INIT_JOYSTICK))) {
slouken@7360
   136
        /* video or joystick implies events */
slouken@7360
   137
        flags |= SDL_INIT_EVENTS;
slouken@7360
   138
    }
slouken@7360
   139
slouken@7360
   140
    /* Initialize the event subsystem */
slouken@7360
   141
    if ((flags & SDL_INIT_EVENTS)) {
slouken@7360
   142
#if !SDL_EVENTS_DISABLED
slouken@7360
   143
        if (SDL_PrivateShouldInitSubsystem(SDL_INIT_EVENTS)) {
slouken@7360
   144
            if (SDL_StartEventLoop() < 0) {
slouken@7360
   145
                return (-1);
slouken@7360
   146
            }
slouken@7360
   147
            SDL_QuitInit();
slouken@7360
   148
        }
slouken@7360
   149
        SDL_PrivateSubsystemRefCountIncr(SDL_INIT_EVENTS);
slouken@7360
   150
#else
slouken@7360
   151
        return SDL_SetError("SDL not built with events support");
slouken@7360
   152
#endif
slouken@7360
   153
    }
slouken@7360
   154
jorgen@6866
   155
    /* Initialize the timer subsystem */
slouken@7360
   156
    if ((flags & SDL_INIT_TIMER)){
jorgen@6866
   157
#if !SDL_TIMERS_DISABLED
jorgen@6927
   158
        if (SDL_PrivateShouldInitSubsystem(SDL_INIT_TIMER)) {
jorgen@6924
   159
            if (SDL_TimerInit() < 0) {
jorgen@6924
   160
                return (-1);
jorgen@6924
   161
            }
jorgen@6866
   162
        }
jorgen@6866
   163
        SDL_PrivateSubsystemRefCountIncr(SDL_INIT_TIMER);
slouken@6128
   164
#else
icculus@7037
   165
        return SDL_SetError("SDL not built with timer support");
jorgen@6866
   166
#endif
slouken@6128
   167
    }
slouken@6128
   168
slouken@7360
   169
    /* Initialize the video subsystem */
slouken@7360
   170
    if ((flags & SDL_INIT_VIDEO)){
slouken@1361
   171
#if !SDL_VIDEO_DISABLED
jorgen@6927
   172
        if (SDL_PrivateShouldInitSubsystem(SDL_INIT_VIDEO)) {
jorgen@6924
   173
            if (SDL_VideoInit(NULL) < 0) {
jorgen@6924
   174
                return (-1);
jorgen@6924
   175
            }
jorgen@6866
   176
        }
jorgen@6866
   177
        SDL_PrivateSubsystemRefCountIncr(SDL_INIT_VIDEO);
slouken@0
   178
#else
icculus@7037
   179
        return SDL_SetError("SDL not built with video support");
jorgen@6866
   180
#endif
slouken@1895
   181
    }
slouken@0
   182
jorgen@6866
   183
    /* Initialize the audio subsystem */
slouken@7360
   184
    if ((flags & SDL_INIT_AUDIO)){
slouken@1361
   185
#if !SDL_AUDIO_DISABLED
jorgen@6927
   186
        if (SDL_PrivateShouldInitSubsystem(SDL_INIT_AUDIO)) {
jorgen@6924
   187
            if (SDL_AudioInit(NULL) < 0) {
jorgen@6924
   188
                return (-1);
jorgen@6924
   189
            }
jorgen@6866
   190
        }
jorgen@6866
   191
        SDL_PrivateSubsystemRefCountIncr(SDL_INIT_AUDIO);
slouken@0
   192
#else
icculus@7037
   193
        return SDL_SetError("SDL not built with audio support");
jorgen@6866
   194
#endif
slouken@1895
   195
    }
slouken@0
   196
jorgen@6866
   197
    /* Initialize the joystick subsystem */
slouken@7360
   198
    if ((flags & SDL_INIT_JOYSTICK)){
slouken@1361
   199
#if !SDL_JOYSTICK_DISABLED
jorgen@6927
   200
        if (SDL_PrivateShouldInitSubsystem(SDL_INIT_JOYSTICK)) {
jorgen@6924
   201
           if (SDL_JoystickInit() < 0) {
jorgen@6924
   202
               return (-1);
jorgen@6924
   203
           }
slouken@1895
   204
        }
jorgen@6866
   205
        SDL_PrivateSubsystemRefCountIncr(SDL_INIT_JOYSTICK);
slouken@0
   206
#else
icculus@7037
   207
        return SDL_SetError("SDL not built with joystick support");
jorgen@6866
   208
#endif
slouken@1895
   209
    }
jorgen@6866
   210
slouken@7360
   211
    if ((flags & SDL_INIT_GAMECONTROLLER)){
jorgen@6866
   212
#if !SDL_JOYSTICK_DISABLED
jorgen@6927
   213
        if (SDL_PrivateShouldInitSubsystem(SDL_INIT_GAMECONTROLLER)) {
jorgen@6924
   214
            if (SDL_GameControllerInit() < 0) {
jorgen@6924
   215
                return (-1);
jorgen@6924
   216
            }
jorgen@6866
   217
        }
jorgen@6866
   218
        SDL_PrivateSubsystemRefCountIncr(SDL_INIT_GAMECONTROLLER);
jorgen@6866
   219
#else
icculus@7037
   220
        return SDL_SetError("SDL not built with joystick support");
slouken@0
   221
#endif
jorgen@6866
   222
    }
slouken@0
   223
jorgen@6866
   224
    /* Initialize the haptic subsystem */
slouken@7360
   225
    if ((flags & SDL_INIT_HAPTIC)){
slouken@2713
   226
#if !SDL_HAPTIC_DISABLED
jorgen@6927
   227
        if (SDL_PrivateShouldInitSubsystem(SDL_INIT_HAPTIC)) {
jorgen@6924
   228
            if (SDL_HapticInit() < 0) {
jorgen@6927
   229
                return (-1);
jorgen@6927
   230
            }
jorgen@6866
   231
        }
jorgen@6866
   232
        SDL_PrivateSubsystemRefCountIncr(SDL_INIT_HAPTIC);
slouken@2713
   233
#else
icculus@7037
   234
        return SDL_SetError("SDL not built with haptic (force feedback) support");
jorgen@6866
   235
#endif
slouken@2713
   236
    }
jorgen@6866
   237
slouken@1895
   238
    return (0);
slouken@0
   239
}
slouken@0
   240
slouken@1895
   241
int
slouken@1895
   242
SDL_Init(Uint32 flags)
slouken@0
   243
{
icculus@7590
   244
    return SDL_InitSubSystem(flags);
slouken@0
   245
}
slouken@0
   246
slouken@1895
   247
void
slouken@1895
   248
SDL_QuitSubSystem(Uint32 flags)
slouken@0
   249
{
slouken@1895
   250
    /* Shut down requested initialized subsystems */
slouken@1361
   251
#if !SDL_JOYSTICK_DISABLED
jorgen@6866
   252
    if ((flags & SDL_INIT_GAMECONTROLLER)) {
slouken@7360
   253
        /* game controller implies joystick */
jorgen@6866
   254
        flags |= SDL_INIT_JOYSTICK;
jorgen@6866
   255
jorgen@6866
   256
        if (SDL_PrivateShouldQuitSubsystem(SDL_INIT_GAMECONTROLLER)) {
jorgen@6866
   257
            SDL_GameControllerQuit();
slouken@7191
   258
        }
jorgen@6866
   259
        SDL_PrivateSubsystemRefCountDecr(SDL_INIT_GAMECONTROLLER);
jorgen@6866
   260
    }
slouken@6690
   261
jorgen@6866
   262
    if ((flags & SDL_INIT_JOYSTICK)) {
slouken@7360
   263
        /* joystick implies events */
slouken@7360
   264
        flags |= SDL_INIT_EVENTS;
slouken@7360
   265
jorgen@6866
   266
        if (SDL_PrivateShouldQuitSubsystem(SDL_INIT_JOYSTICK)) {
slouken@7191
   267
            SDL_JoystickQuit();
slouken@7191
   268
        }
jorgen@6866
   269
        SDL_PrivateSubsystemRefCountDecr(SDL_INIT_JOYSTICK);
slouken@1895
   270
    }
slouken@0
   271
#endif
jorgen@6866
   272
slouken@2713
   273
#if !SDL_HAPTIC_DISABLED
jorgen@6866
   274
    if ((flags & SDL_INIT_HAPTIC)) {
jorgen@6866
   275
        if (SDL_PrivateShouldQuitSubsystem(SDL_INIT_HAPTIC)) {
slouken@7191
   276
            SDL_HapticQuit();
slouken@7191
   277
        }
jorgen@6866
   278
        SDL_PrivateSubsystemRefCountDecr(SDL_INIT_HAPTIC);
slouken@2713
   279
    }
slouken@2713
   280
#endif
jorgen@6866
   281
slouken@1361
   282
#if !SDL_AUDIO_DISABLED
jorgen@6866
   283
    if ((flags & SDL_INIT_AUDIO)) {
jorgen@6866
   284
        if (SDL_PrivateShouldQuitSubsystem(SDL_INIT_AUDIO)) {
slouken@7191
   285
            SDL_AudioQuit();
slouken@7191
   286
        }
jorgen@6866
   287
        SDL_PrivateSubsystemRefCountDecr(SDL_INIT_AUDIO);
slouken@1895
   288
    }
slouken@0
   289
#endif
jorgen@6866
   290
slouken@1361
   291
#if !SDL_VIDEO_DISABLED
jorgen@6866
   292
    if ((flags & SDL_INIT_VIDEO)) {
slouken@7360
   293
        /* video implies events */
slouken@7360
   294
        flags |= SDL_INIT_EVENTS;
slouken@7360
   295
jorgen@6866
   296
        if (SDL_PrivateShouldQuitSubsystem(SDL_INIT_VIDEO)) {
slouken@7191
   297
            SDL_VideoQuit();
slouken@7191
   298
        }
jorgen@6866
   299
        SDL_PrivateSubsystemRefCountDecr(SDL_INIT_VIDEO);
slouken@1895
   300
    }
slouken@0
   301
#endif
jorgen@6866
   302
slouken@6128
   303
#if !SDL_TIMERS_DISABLED
jorgen@6866
   304
    if ((flags & SDL_INIT_TIMER)) {
jorgen@6866
   305
        if (SDL_PrivateShouldQuitSubsystem(SDL_INIT_TIMER)) {
slouken@7191
   306
            SDL_TimerQuit();
slouken@7191
   307
        }
jorgen@6866
   308
        SDL_PrivateSubsystemRefCountDecr(SDL_INIT_TIMER);
slouken@6128
   309
    }
slouken@6128
   310
#endif
slouken@7360
   311
slouken@7360
   312
#if !SDL_EVENTS_DISABLED
slouken@7360
   313
    if ((flags & SDL_INIT_EVENTS)) {
slouken@7360
   314
        if (SDL_PrivateShouldQuitSubsystem(SDL_INIT_EVENTS)) {
slouken@7360
   315
            SDL_QuitQuit();
slouken@7360
   316
            SDL_StopEventLoop();
slouken@7360
   317
        }
slouken@7360
   318
        SDL_PrivateSubsystemRefCountDecr(SDL_INIT_EVENTS);
slouken@7360
   319
    }
slouken@7360
   320
#endif
slouken@0
   321
}
slouken@0
   322
slouken@1895
   323
Uint32
slouken@1895
   324
SDL_WasInit(Uint32 flags)
slouken@0
   325
{
jorgen@6866
   326
    int i;
jorgen@6866
   327
    int num_subsystems = SDL_arraysize(SDL_SubsystemRefCount);
jorgen@6866
   328
    Uint32 initialized = 0;
jorgen@6866
   329
slouken@1895
   330
    if (!flags) {
slouken@1895
   331
        flags = SDL_INIT_EVERYTHING;
slouken@1895
   332
    }
jorgen@6866
   333
jorgen@6866
   334
    num_subsystems = SDL_min(num_subsystems, SDL_MostSignificantBitIndex32(flags) + 1);
jorgen@6866
   335
jorgen@6866
   336
    /* Iterate over each bit in flags, and check the matching subsystem. */
jorgen@6866
   337
    for (i = 0; i < num_subsystems; ++i) {
jorgen@6866
   338
        if ((flags & 1) && SDL_SubsystemRefCount[i] > 0) {
jorgen@6866
   339
            initialized |= (1 << i);
jorgen@6866
   340
        }
jorgen@6866
   341
jorgen@6866
   342
        flags >>= 1;
jorgen@6866
   343
    }
jorgen@6866
   344
jorgen@6866
   345
    return initialized;
slouken@0
   346
}
slouken@0
   347
slouken@1895
   348
void
slouken@1895
   349
SDL_Quit(void)
slouken@0
   350
{
jorgen@6866
   351
    SDL_bInMainQuit = SDL_TRUE;
jorgen@6866
   352
slouken@1895
   353
    /* Quit all subsystems */
slouken@7110
   354
#if SDL_VIDEO_DRIVER_WINDOWS
slouken@2713
   355
    SDL_HelperWindowDestroy();
slouken@2713
   356
#endif
slouken@1895
   357
    SDL_QuitSubSystem(SDL_INIT_EVERYTHING);
slouken@0
   358
slouken@8268
   359
#if !SDL_TIMERS_DISABLED
slouken@8268
   360
    SDL_TicksQuit();
slouken@8268
   361
#endif
slouken@8268
   362
slouken@5189
   363
    SDL_ClearHints();
slouken@3647
   364
    SDL_AssertionsQuit();
slouken@5221
   365
    SDL_LogResetPriorities();
slouken@6690
   366
jorgen@6866
   367
    /* Now that every subsystem has been quit, we reset the subsystem refcount
jorgen@6866
   368
     * and the list of initialized subsystems.
jorgen@6866
   369
     */
jorgen@6866
   370
    SDL_memset( SDL_SubsystemRefCount, 0x0, sizeof(SDL_SubsystemRefCount) );
jorgen@6866
   371
jorgen@6866
   372
    SDL_bInMainQuit = SDL_FALSE;
slouken@0
   373
}
slouken@0
   374
slouken@1895
   375
/* Get the library version number */
slouken@1895
   376
void
slouken@1895
   377
SDL_GetVersion(SDL_version * ver)
slouken@0
   378
{
slouken@1895
   379
    SDL_VERSION(ver);
slouken@0
   380
}
slouken@0
   381
slouken@2982
   382
/* Get the library source revision */
icculus@4419
   383
const char *
slouken@2996
   384
SDL_GetRevision(void)
slouken@2982
   385
{
slouken@2983
   386
    return SDL_REVISION;
slouken@2982
   387
}
slouken@2982
   388
slouken@5359
   389
/* Get the library source revision number */
slouken@5359
   390
int
slouken@5359
   391
SDL_GetRevisionNumber(void)
slouken@5359
   392
{
slouken@5359
   393
    return SDL_REVISION_NUMBER;
slouken@5359
   394
}
slouken@5359
   395
slouken@3319
   396
/* Get the name of the platform */
slouken@3319
   397
const char *
slouken@3319
   398
SDL_GetPlatform()
slouken@3319
   399
{
slouken@3319
   400
#if __AIX__
slouken@3319
   401
    return "AIX";
slouken@6441
   402
#elif __ANDROID__
slouken@6441
   403
    return "Android";
slouken@3319
   404
#elif __BSDI__
slouken@3319
   405
    return "BSDI";
slouken@3319
   406
#elif __DREAMCAST__
slouken@3319
   407
    return "Dreamcast";
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@3319
   424
#elif __NETBSD__
slouken@3319
   425
    return "NetBSD";
slouken@3319
   426
#elif __OPENBSD__
slouken@3319
   427
    return "OpenBSD";
slouken@3319
   428
#elif __OS2__
slouken@3319
   429
    return "OS/2";
slouken@3319
   430
#elif __OSF__
slouken@3319
   431
    return "OSF/1";
slouken@3319
   432
#elif __QNXNTO__
slouken@3319
   433
    return "QNX Neutrino";
slouken@3319
   434
#elif __RISCOS__
slouken@3319
   435
    return "RISC OS";
slouken@3319
   436
#elif __SOLARIS__
slouken@3319
   437
    return "Solaris";
slouken@5086
   438
#elif __WIN32__
slouken@3319
   439
    return "Windows";
slouken@3319
   440
#elif __IPHONEOS__
slouken@7592
   441
    return "iOS";
kimonline@7009
   442
#elif __PSP__
kimonline@7009
   443
    return "PlayStation Portable";
slouken@3319
   444
#else
slouken@3319
   445
    return "Unknown (see SDL_platform.h)";
slouken@3319
   446
#endif
slouken@3319
   447
}
slouken@3319
   448
slouken@5086
   449
#if defined(__WIN32__)
slouken@1330
   450
slouken@1465
   451
#if !defined(HAVE_LIBC) || (defined(__WATCOMC__) && defined(BUILD_DLL))
slouken@1465
   452
/* Need to include DllMain() on Watcom C for some reason.. */
slouken@1330
   453
slouken@1895
   454
BOOL APIENTRY
slouken@1895
   455
_DllMainCRTStartup(HANDLE hModule,
slouken@1895
   456
                   DWORD ul_reason_for_call, LPVOID lpReserved)
slouken@1330
   457
{
slouken@1895
   458
    switch (ul_reason_for_call) {
slouken@1895
   459
    case DLL_PROCESS_ATTACH:
slouken@1895
   460
    case DLL_THREAD_ATTACH:
slouken@1895
   461
    case DLL_THREAD_DETACH:
slouken@1895
   462
    case DLL_PROCESS_DETACH:
slouken@1895
   463
        break;
slouken@1895
   464
    }
slouken@1895
   465
    return TRUE;
slouken@1330
   466
}
slouken@1465
   467
#endif /* building DLL with Watcom C */
slouken@1330
   468
slouken@5086
   469
#endif /* __WIN32__ */
slouken@1895
   470
jorgen@6927
   471
/* vi: set sts=4 ts=4 sw=4 expandtab: */