- // TODO: Timeout
- // TODO: Allow extra events to be waited upon
- Threads_WaitEvents( THREAD_EVENT_VFS|ExtraEvents );
+ LOG("Semaphore_Wait()");
+ // TODO: Actual timeout
+ Threads_WaitEvents( THREAD_EVENT_VFS|THREAD_EVENT_SIGNAL|ExtraEvents );
+ }
+ else if( *Timeout > 0 )
+ {
+ tTimer *t = Time_AllocateTimer(NULL, NULL);
+ // Clear timer event
+ Threads_ClearEvent( THREAD_EVENT_TIMER );
+ // TODO: Convert *Timeout?
+ LOG("Timeout %lli ms", *Timeout);
+ Time_ScheduleTimer( t, *Timeout );
+ // Wait for the timer or a VFS event
+ Threads_WaitEvents( THREAD_EVENT_VFS|THREAD_EVENT_TIMER|ExtraEvents );
+ Time_FreeTimer(t);