]> rtime.felk.cvut.cz Git - l4.git/blobdiff - l4/pkg/libsdl/contrib/test/testsem.c
update
[l4.git] / l4 / pkg / libsdl / contrib / test / testsem.c
index 9c0940eb965e2762467577d9f3da8e15d561985d..c906432b13a015177fd8ea87692c7e1f214b148f 100644 (file)
@@ -33,6 +33,28 @@ static void killed(int sig)
        alive = 0;
 }
 
+static void TestWaitTimeout(void)
+{
+       Uint32 start_ticks;
+       Uint32 end_ticks;
+       Uint32 duration;
+
+       sem = SDL_CreateSemaphore(0);
+       printf("Waiting 2 seconds on semaphore\n");
+
+       start_ticks = SDL_GetTicks();
+       SDL_SemWaitTimeout(sem, 2000);
+       end_ticks = SDL_GetTicks();
+
+       duration = end_ticks - start_ticks;
+       
+       /* Accept a little offset in the effective wait */
+       if (duration > 1900 && duration < 2050)
+               printf("Wait done.\n");
+       else
+               fprintf(stderr, "Wait took %d milliseconds\n", duration);
+}
+
 int main(int argc, char **argv)
 {
        SDL_Thread *threads[NUM_THREADS];
@@ -73,6 +95,9 @@ int main(int argc, char **argv)
        printf("Finished waiting for threads\n");
 
        SDL_DestroySemaphore(sem);
+
+       TestWaitTimeout();
+
        SDL_Quit();
        return(0);
 }