Mercurial > sdl-ios-xcode
comparison src/SDL.c @ 1361:19418e4422cb
New configure-based build system. Still work in progress, but much improved
author | Sam Lantinga <slouken@libsdl.org> |
---|---|
date | Thu, 16 Feb 2006 10:11:48 +0000 |
parents | c71e05b4dc2e |
children | d910939febfa |
comparison
equal
deleted
inserted
replaced
1360:70a9cfb4cf1b | 1361:19418e4422cb |
---|---|
20 slouken@libsdl.org | 20 slouken@libsdl.org |
21 */ | 21 */ |
22 | 22 |
23 /* Initialization code for SDL */ | 23 /* Initialization code for SDL */ |
24 | 24 |
25 #ifdef ENABLE_PTH | |
26 #include <pth.h> | |
27 #endif | |
28 | |
29 #include "SDL.h" | 25 #include "SDL.h" |
30 #include "SDL_fatal.h" | 26 #include "SDL_fatal.h" |
31 #ifndef DISABLE_VIDEO | 27 #if !SDL_VIDEO_DISABLED |
32 #include "SDL_leaks.h" | 28 #include "video/SDL_leaks.h" |
29 #endif | |
30 | |
31 #if SDL_THREAD_PTH | |
32 #include <pth.h> | |
33 #endif | 33 #endif |
34 | 34 |
35 /* Initialization/Cleanup routines */ | 35 /* Initialization/Cleanup routines */ |
36 #ifndef DISABLE_JOYSTICK | 36 #if !SDL_JOYSTICK_DISABLED |
37 extern int SDL_JoystickInit(void); | 37 extern int SDL_JoystickInit(void); |
38 extern void SDL_JoystickQuit(void); | 38 extern void SDL_JoystickQuit(void); |
39 #endif | 39 #endif |
40 #ifndef DISABLE_CDROM | 40 #if !SDL_CDROM_DISABLED |
41 extern int SDL_CDROMInit(void); | 41 extern int SDL_CDROMInit(void); |
42 extern void SDL_CDROMQuit(void); | 42 extern void SDL_CDROMQuit(void); |
43 #endif | 43 #endif |
44 #ifndef DISABLE_TIMERS | 44 #if !SDL_TIMERS_DISABLED |
45 extern void SDL_StartTicks(void); | 45 extern void SDL_StartTicks(void); |
46 extern int SDL_TimerInit(void); | 46 extern int SDL_TimerInit(void); |
47 extern void SDL_TimerQuit(void); | 47 extern void SDL_TimerQuit(void); |
48 #endif | 48 #endif |
49 | 49 |
59 int surfaces_allocated = 0; | 59 int surfaces_allocated = 0; |
60 #endif | 60 #endif |
61 | 61 |
62 int SDL_InitSubSystem(Uint32 flags) | 62 int SDL_InitSubSystem(Uint32 flags) |
63 { | 63 { |
64 #ifndef DISABLE_VIDEO | 64 #if !SDL_VIDEO_DISABLED |
65 /* Initialize the video/event subsystem */ | 65 /* Initialize the video/event subsystem */ |
66 if ( (flags & SDL_INIT_VIDEO) && !(SDL_initialized & SDL_INIT_VIDEO) ) { | 66 if ( (flags & SDL_INIT_VIDEO) && !(SDL_initialized & SDL_INIT_VIDEO) ) { |
67 if ( SDL_VideoInit(SDL_getenv("SDL_VIDEODRIVER"), | 67 if ( SDL_VideoInit(SDL_getenv("SDL_VIDEODRIVER"), |
68 (flags&SDL_INIT_EVENTTHREAD)) < 0 ) { | 68 (flags&SDL_INIT_EVENTTHREAD)) < 0 ) { |
69 return(-1); | 69 return(-1); |
75 SDL_SetError("SDL not built with video support"); | 75 SDL_SetError("SDL not built with video support"); |
76 return(-1); | 76 return(-1); |
77 } | 77 } |
78 #endif | 78 #endif |
79 | 79 |
80 #ifndef DISABLE_AUDIO | 80 #if !SDL_AUDIO_DISABLED |
81 /* Initialize the audio subsystem */ | 81 /* Initialize the audio subsystem */ |
82 if ( (flags & SDL_INIT_AUDIO) && !(SDL_initialized & SDL_INIT_AUDIO) ) { | 82 if ( (flags & SDL_INIT_AUDIO) && !(SDL_initialized & SDL_INIT_AUDIO) ) { |
83 if ( SDL_AudioInit(SDL_getenv("SDL_AUDIODRIVER")) < 0 ) { | 83 if ( SDL_AudioInit(SDL_getenv("SDL_AUDIODRIVER")) < 0 ) { |
84 return(-1); | 84 return(-1); |
85 } | 85 } |
90 SDL_SetError("SDL not built with audio support"); | 90 SDL_SetError("SDL not built with audio support"); |
91 return(-1); | 91 return(-1); |
92 } | 92 } |
93 #endif | 93 #endif |
94 | 94 |
95 #ifndef DISABLE_TIMERS | 95 #if !SDL_TIMERS_DISABLED |
96 /* Initialize the timer subsystem */ | 96 /* Initialize the timer subsystem */ |
97 if ( ! ticks_started ) { | 97 if ( ! ticks_started ) { |
98 SDL_StartTicks(); | 98 SDL_StartTicks(); |
99 ticks_started = 1; | 99 ticks_started = 1; |
100 } | 100 } |
109 SDL_SetError("SDL not built with timer support"); | 109 SDL_SetError("SDL not built with timer support"); |
110 return(-1); | 110 return(-1); |
111 } | 111 } |
112 #endif | 112 #endif |
113 | 113 |
114 #ifndef DISABLE_JOYSTICK | 114 #if !SDL_JOYSTICK_DISABLED |
115 /* Initialize the joystick subsystem */ | 115 /* Initialize the joystick subsystem */ |
116 if ( (flags & SDL_INIT_JOYSTICK) && | 116 if ( (flags & SDL_INIT_JOYSTICK) && |
117 !(SDL_initialized & SDL_INIT_JOYSTICK) ) { | 117 !(SDL_initialized & SDL_INIT_JOYSTICK) ) { |
118 if ( SDL_JoystickInit() < 0 ) { | 118 if ( SDL_JoystickInit() < 0 ) { |
119 return(-1); | 119 return(-1); |
125 SDL_SetError("SDL not built with joystick support"); | 125 SDL_SetError("SDL not built with joystick support"); |
126 return(-1); | 126 return(-1); |
127 } | 127 } |
128 #endif | 128 #endif |
129 | 129 |
130 #ifndef DISABLE_CDROM | 130 #if !SDL_CDROM_DISABLED |
131 /* Initialize the CD-ROM subsystem */ | 131 /* Initialize the CD-ROM subsystem */ |
132 if ( (flags & SDL_INIT_CDROM) && !(SDL_initialized & SDL_INIT_CDROM) ) { | 132 if ( (flags & SDL_INIT_CDROM) && !(SDL_initialized & SDL_INIT_CDROM) ) { |
133 if ( SDL_CDROMInit() < 0 ) { | 133 if ( SDL_CDROMInit() < 0 ) { |
134 return(-1); | 134 return(-1); |
135 } | 135 } |
144 return(0); | 144 return(0); |
145 } | 145 } |
146 | 146 |
147 int SDL_Init(Uint32 flags) | 147 int SDL_Init(Uint32 flags) |
148 { | 148 { |
149 #if !defined(DISABLE_THREADS) && defined(ENABLE_PTH) | 149 #if !SDL_THREADS_DISABLED && SDL_THREAD_PTH |
150 if (!pth_init()) { | 150 if (!pth_init()) { |
151 return -1; | 151 return -1; |
152 } | 152 } |
153 #endif | 153 #endif |
154 | 154 |
168 } | 168 } |
169 | 169 |
170 void SDL_QuitSubSystem(Uint32 flags) | 170 void SDL_QuitSubSystem(Uint32 flags) |
171 { | 171 { |
172 /* Shut down requested initialized subsystems */ | 172 /* Shut down requested initialized subsystems */ |
173 #ifndef DISABLE_CDROM | 173 #if !SDL_CDROM_DISABLED |
174 if ( (flags & SDL_initialized & SDL_INIT_CDROM) ) { | 174 if ( (flags & SDL_initialized & SDL_INIT_CDROM) ) { |
175 SDL_CDROMQuit(); | 175 SDL_CDROMQuit(); |
176 SDL_initialized &= ~SDL_INIT_CDROM; | 176 SDL_initialized &= ~SDL_INIT_CDROM; |
177 } | 177 } |
178 #endif | 178 #endif |
179 #ifndef DISABLE_JOYSTICK | 179 #if !SDL_JOYSTICK_DISABLED |
180 if ( (flags & SDL_initialized & SDL_INIT_JOYSTICK) ) { | 180 if ( (flags & SDL_initialized & SDL_INIT_JOYSTICK) ) { |
181 SDL_JoystickQuit(); | 181 SDL_JoystickQuit(); |
182 SDL_initialized &= ~SDL_INIT_JOYSTICK; | 182 SDL_initialized &= ~SDL_INIT_JOYSTICK; |
183 } | 183 } |
184 #endif | 184 #endif |
185 #ifndef DISABLE_TIMERS | 185 #if !SDL_TIMERS_DISABLED |
186 if ( (flags & SDL_initialized & SDL_INIT_TIMER) ) { | 186 if ( (flags & SDL_initialized & SDL_INIT_TIMER) ) { |
187 SDL_TimerQuit(); | 187 SDL_TimerQuit(); |
188 SDL_initialized &= ~SDL_INIT_TIMER; | 188 SDL_initialized &= ~SDL_INIT_TIMER; |
189 } | 189 } |
190 #endif | 190 #endif |
191 #ifndef DISABLE_AUDIO | 191 #if !SDL_AUDIO_DISABLED |
192 if ( (flags & SDL_initialized & SDL_INIT_AUDIO) ) { | 192 if ( (flags & SDL_initialized & SDL_INIT_AUDIO) ) { |
193 SDL_AudioQuit(); | 193 SDL_AudioQuit(); |
194 SDL_initialized &= ~SDL_INIT_AUDIO; | 194 SDL_initialized &= ~SDL_INIT_AUDIO; |
195 } | 195 } |
196 #endif | 196 #endif |
197 #ifndef DISABLE_VIDEO | 197 #if !SDL_VIDEO_DISABLED |
198 if ( (flags & SDL_initialized & SDL_INIT_VIDEO) ) { | 198 if ( (flags & SDL_initialized & SDL_INIT_VIDEO) ) { |
199 SDL_VideoQuit(); | 199 SDL_VideoQuit(); |
200 SDL_initialized &= ~SDL_INIT_VIDEO; | 200 SDL_initialized &= ~SDL_INIT_VIDEO; |
201 } | 201 } |
202 #endif | 202 #endif |
234 #endif | 234 #endif |
235 | 235 |
236 /* Uninstall any parachute signal handlers */ | 236 /* Uninstall any parachute signal handlers */ |
237 SDL_UninstallParachute(); | 237 SDL_UninstallParachute(); |
238 | 238 |
239 #if !defined(DISABLE_THREADS) && defined(ENABLE_PTH) | 239 #if !SDL_THREADS_DISABLED && SDL_THREAD_PTH |
240 pth_kill(); | 240 pth_kill(); |
241 #endif | 241 #endif |
242 #ifdef DEBUG_BUILD | 242 #ifdef DEBUG_BUILD |
243 printf("[SDL_Quit] : Returning!\n"); fflush(stdout); | 243 printf("[SDL_Quit] : Returning!\n"); fflush(stdout); |
244 #endif | 244 #endif |