Mercurial > sdl-ios-xcode
comparison src/timer/linux/SDL_systimer.c @ 415:104f32d04cd1
Fixed building with pthreads and the pth library
author | Sam Lantinga <slouken@libsdl.org> |
---|---|
date | Thu, 13 Jun 2002 21:36:25 +0000 |
parents | 71fe0b713085 |
children | b8d311d90021 |
comparison
equal
deleted
inserted
replaced
414:dd56447ef292 | 415:104f32d04cd1 |
---|---|
38 #include "SDL_timer.h" | 38 #include "SDL_timer.h" |
39 #include "SDL_timer_c.h" | 39 #include "SDL_timer_c.h" |
40 | 40 |
41 #if _POSIX_THREAD_SYSCALL_SOFT | 41 #if _POSIX_THREAD_SYSCALL_SOFT |
42 #include <pthread.h> | 42 #include <pthread.h> |
43 #endif | |
44 #ifdef ENABLE_PTH | |
45 #include <pth.h> | |
43 #endif | 46 #endif |
44 | 47 |
45 #if defined(DISABLE_THREADS) || defined(FORK_HACK) | 48 #if defined(DISABLE_THREADS) || defined(FORK_HACK) |
46 #define USE_ITIMER | 49 #define USE_ITIMER |
47 #endif | 50 #endif |
140 #endif /* USE_RDTSC */ | 143 #endif /* USE_RDTSC */ |
141 } | 144 } |
142 | 145 |
143 void SDL_Delay (Uint32 ms) | 146 void SDL_Delay (Uint32 ms) |
144 { | 147 { |
148 #ifdef ENABLE_PTH | |
149 pth_time_t tv; | |
150 tv.tv_sec = ms/1000; | |
151 tv.tv_usec = (ms%1000)*1000; | |
152 pth_nap(tv); | |
153 #else | |
145 int was_error; | 154 int was_error; |
146 | 155 |
147 #ifdef USE_NANOSLEEP | 156 #ifdef USE_NANOSLEEP |
148 struct timespec elapsed, tv; | 157 struct timespec elapsed, tv; |
149 #else | 158 #else |
187 tv.tv_usec = (ms%1000)*1000; | 196 tv.tv_usec = (ms%1000)*1000; |
188 #endif | 197 #endif |
189 was_error = select(0, NULL, NULL, NULL, &tv); | 198 was_error = select(0, NULL, NULL, NULL, &tv); |
190 #endif /* USE_NANOSLEEP */ | 199 #endif /* USE_NANOSLEEP */ |
191 } while ( was_error && (errno == EINTR) ); | 200 } while ( was_error && (errno == EINTR) ); |
201 #endif /* ENABLE_PTH */ | |
192 } | 202 } |
193 | 203 |
194 #ifdef USE_ITIMER | 204 #ifdef USE_ITIMER |
195 | 205 |
196 static void HandleAlarm(int sig) | 206 static void HandleAlarm(int sig) |