Skip to content
This repository has been archived by the owner on Feb 11, 2021. It is now read-only.

Commit

Permalink
Cleanup of SDL_PrivateShouldInitSubsystem.
Browse files Browse the repository at this point in the history
Also fixes a build error if a module was disabled.
  • Loading branch information
jorgenpt committed Feb 26, 2013
1 parent 3de4c3d commit b057254
Showing 1 changed file with 11 additions and 16 deletions.
27 changes: 11 additions & 16 deletions src/SDL.c
Expand Up @@ -68,14 +68,9 @@ SDL_PrivateSubsystemRefCountDecr(Uint32 subsystem)

/* Private helper to check if a system needs init. */
static SDL_bool
SDL_PrivateShouldInitSubsystem(Uint32 flags, Uint32 subsystem)
SDL_PrivateShouldInitSubsystem(Uint32 subsystem)
{
int subsystem_index;
if ((flags & subsystem) == 0) {
return SDL_FALSE;
}

subsystem_index = SDL_MostSignificantBitIndex32(subsystem);
int subsystem_index = SDL_MostSignificantBitIndex32(subsystem);
SDL_assert(SDL_SubsystemRefCount[subsystem_index] < 255);
return (SDL_SubsystemRefCount[subsystem_index] == 0);
}
Expand Down Expand Up @@ -106,8 +101,8 @@ SDL_InitSubSystem(Uint32 flags)

/* Initialize the timer subsystem */
if ((flags & SDL_INIT_TIMER) ){
if (SDL_PrivateShouldInitSubsystem(flags, SDL_INIT_TIMER)) {
#if !SDL_TIMERS_DISABLED
if (SDL_PrivateShouldInitSubsystem(SDL_INIT_TIMER)) {
if (SDL_TimerInit() < 0) {
return (-1);
}
Expand All @@ -121,8 +116,8 @@ SDL_InitSubSystem(Uint32 flags)

/* Initialize the video/event subsystem */
if ((flags & SDL_INIT_VIDEO) ){
if (SDL_PrivateShouldInitSubsystem(flags, SDL_INIT_VIDEO)) {
#if !SDL_VIDEO_DISABLED
if (SDL_PrivateShouldInitSubsystem(SDL_INIT_VIDEO)) {
if (SDL_VideoInit(NULL) < 0) {
return (-1);
}
Expand All @@ -136,8 +131,8 @@ SDL_InitSubSystem(Uint32 flags)

/* Initialize the audio subsystem */
if ((flags & SDL_INIT_AUDIO) ){
if (SDL_PrivateShouldInitSubsystem(flags, SDL_INIT_AUDIO)) {
#if !SDL_AUDIO_DISABLED
if (SDL_PrivateShouldInitSubsystem(SDL_INIT_AUDIO)) {
if (SDL_AudioInit(NULL) < 0) {
return (-1);
}
Expand All @@ -156,8 +151,8 @@ SDL_InitSubSystem(Uint32 flags)

/* Initialize the joystick subsystem */
if ((flags & SDL_INIT_JOYSTICK) ){
if (SDL_PrivateShouldInitSubsystem(flags, SDL_INIT_JOYSTICK)) {
#if !SDL_JOYSTICK_DISABLED
if (SDL_PrivateShouldInitSubsystem(SDL_INIT_JOYSTICK)) {
if (SDL_JoystickInit() < 0) {
return (-1);
}
Expand All @@ -170,8 +165,8 @@ SDL_InitSubSystem(Uint32 flags)
}

if ((flags & SDL_INIT_GAMECONTROLLER) ){
if (SDL_PrivateShouldInitSubsystem(flags, SDL_INIT_GAMECONTROLLER)) {
#if !SDL_JOYSTICK_DISABLED
if (SDL_PrivateShouldInitSubsystem(SDL_INIT_GAMECONTROLLER)) {
if (SDL_GameControllerInit() < 0) {
return (-1);
}
Expand All @@ -185,11 +180,11 @@ SDL_InitSubSystem(Uint32 flags)

/* Initialize the haptic subsystem */
if ((flags & SDL_INIT_HAPTIC) ){
if (SDL_PrivateShouldInitSubsystem(flags, SDL_INIT_HAPTIC)) {
#if !SDL_HAPTIC_DISABLED
if (SDL_PrivateShouldInitSubsystem(SDL_INIT_HAPTIC)) {
if (SDL_HapticInit() < 0) {
return (-1);
}
return (-1);
}
}
SDL_PrivateSubsystemRefCountIncr(SDL_INIT_HAPTIC);
#else
Expand Down Expand Up @@ -441,4 +436,4 @@ _DllMainCRTStartup(HANDLE hModule,

#endif /* __WIN32__ */

/* vi: set ts=4 sw=4 expandtab: */
/* vi: set sts=4 ts=4 sw=4 expandtab: */

0 comments on commit b057254

Please sign in to comment.