comparison src/timer/unix/SDL_systimer.c @ 3696:47d923feedb0

Fixed bug #935 Patrice Mandin Hello, I originally added pth support for threads in SDL 1.2 because on the Atari platform we did not have any thread library. I think pth support could be removed from SDL 1.3 for two reasons: - Atari platform removed - pth does not provides real (preemptive) threads, because it is user space, and expect the application to call one of its function to give CPU to another thread. So it is not exactly useful for applications, that expect threads to run simultaneously.
author Sam Lantinga <slouken@libsdl.org>
date Sun, 24 Jan 2010 20:47:20 +0000
parents 99210400e8b9
children f7b03b6838cb
comparison
equal deleted inserted replaced
3695:f6a8be3fefa0 3696:47d923feedb0
38 for __USE_POSIX199309 38 for __USE_POSIX199309
39 Tommi Kyntola (tommi.kyntola@ray.fi) 27/09/2005 39 Tommi Kyntola (tommi.kyntola@ray.fi) 27/09/2005
40 */ 40 */
41 #if HAVE_NANOSLEEP || HAVE_CLOCK_GETTIME 41 #if HAVE_NANOSLEEP || HAVE_CLOCK_GETTIME
42 #include <time.h> 42 #include <time.h>
43 #endif
44
45 #if SDL_THREAD_PTH
46 #include <pth.h>
47 #endif 43 #endif
48 44
49 #if SDL_THREADS_DISABLED 45 #if SDL_THREADS_DISABLED
50 #define USE_ITIMER 46 #define USE_ITIMER
51 #endif 47 #endif
92 } 88 }
93 89
94 void 90 void
95 SDL_Delay(Uint32 ms) 91 SDL_Delay(Uint32 ms)
96 { 92 {
97 #if SDL_THREAD_PTH
98 pth_time_t tv;
99 tv.tv_sec = ms / 1000;
100 tv.tv_usec = (ms % 1000) * 1000;
101 pth_nap(tv);
102 #else
103 int was_error; 93 int was_error;
104 94
105 #if HAVE_NANOSLEEP 95 #if HAVE_NANOSLEEP
106 struct timespec elapsed, tv; 96 struct timespec elapsed, tv;
107 #else 97 #else
136 tv.tv_usec = (ms % 1000) * 1000; 126 tv.tv_usec = (ms % 1000) * 1000;
137 127
138 was_error = select(0, NULL, NULL, NULL, &tv); 128 was_error = select(0, NULL, NULL, NULL, &tv);
139 #endif /* HAVE_NANOSLEEP */ 129 #endif /* HAVE_NANOSLEEP */
140 } while (was_error && (errno == EINTR)); 130 } while (was_error && (errno == EINTR));
141 #endif /* SDL_THREAD_PTH */
142 } 131 }
143 132
144 #ifdef USE_ITIMER 133 #ifdef USE_ITIMER
145 134
146 static void 135 static void