typedef pthread_key_t vlc_threadvar_t;
#elif defined( WIN32 ) || defined( UNDER_CE )
-typedef struct
-{
- /* thread id */
- DWORD id;
- /*
- ** handle to created thread, needs be closed to dispose of it
- ** even after thread has exited
- */
- HANDLE hThread;
-} vlc_thread_t;
+typedef HANDLE vlc_thread_t;
typedef BOOL (WINAPI *SIGNALOBJECTANDWAIT) ( HANDLE, HANDLE, DWORD, BOOL );
VLC_THREAD_ASSERT ("locking mutex");
#elif defined( UNDER_CE )
- VLC_UNUSED( psz_file); VLC_UNUSED( i_line );
+ (void)psz_file; (void)i_line;
EnterCriticalSection( &p_mutex->csection );
#elif defined( WIN32 )
- VLC_UNUSED( psz_file); VLC_UNUSED( i_line );
+ (void)psz_file; (void)i_line;
WaitForSingleObject( *p_mutex, INFINITE );
VLC_THREAD_ASSERT ("unlocking mutex");
#elif defined( UNDER_CE )
- VLC_UNUSED( psz_file); VLC_UNUSED( i_line );
+ (void)psz_file); (void)i_line;
LeaveCriticalSection( &p_mutex->csection );
#elif defined( WIN32 )
- VLC_UNUSED( psz_file); VLC_UNUSED( i_line );
+ (void)psz_file; (void)i_line;
ReleaseMutex( *p_mutex );
VLC_THREAD_ASSERT ("signaling condition variable");
#elif defined( UNDER_CE ) || defined( WIN32 )
- VLC_UNUSED( psz_file); VLC_UNUSED( i_line );
+ (void)psz_file; (void)i_line;
/* Release one waiting thread if one is available. */
/* For this trick to work properly, the vlc_cond_signal must be surrounded
vlc_mutex_lock( p_mutex );
#elif defined( WIN32 )
- VLC_UNUSED( psz_file); VLC_UNUSED( i_line );
+ (void)psz_file; (void)i_line;
/* Increase our wait count */
p_condvar->i_waiting_threads++;
#elif defined( UNDER_CE )
mtime_t delay_ms = (deadline - mdate())/1000;
-
DWORD result;
if( delay_ms < 0 )
delay_ms = 0;
if(result == WAIT_TIMEOUT)
return ETIMEDOUT; /* this error is perfectly normal */
-#elif defined( WIN32 )
- VLC_UNUSED( psz_file); VLC_UNUSED( i_line );
-
- DWORD result;
+ (void)psz_file; (void)i_line;
+#elif defined( WIN32 )
mtime_t delay_ms = (deadline - mdate())/1000;
+ DWORD result;
if( delay_ms < 0 )
delay_ms = 0;
if(result == WAIT_TIMEOUT)
return ETIMEDOUT; /* this error is perfectly normal */
+ (void)psz_file; (void)i_line;
+
#elif defined( HAVE_KERNEL_SCHEDULER_H )
# error Unimplemented
#elif defined( UNDER_CE )
#elif defined( WIN32 )
*p_tls = TlsAlloc();
- i_ret = (*p_tls == INVALID_HANDLE_VALUE) ? EAGAIN : 0;
+ i_ret = (*p_tls == TLS_OUT_OF_INDEXES) ? EAGAIN : 0;
#else
# error Unimplemented!
#endif
* memory leaks and the signal functions not working (see Microsoft
* Knowledge Base, article 104641) */
#if defined( UNDER_CE )
- DWORD threadId;
HANDLE hThread = CreateThread( NULL, 0, (LPTHREAD_START_ROUTINE)func,
- (LPVOID)p_data, CREATE_SUSPENDED,
- &threadId );
+ (LPVOID)p_data, CREATE_SUSPENDED,
+ NULL );
#else
- unsigned threadId;
- uintptr_t hThread = _beginthreadex( NULL, 0,
- (LPTHREAD_START_ROUTINE)func,
- (void*)p_data, CREATE_SUSPENDED,
- &threadId );
+ HANDLE hThread = (HANDLE)(uintptr_t)
+ _beginthreadex( NULL, 0, (LPTHREAD_START_ROUTINE)func,
+ (void *)p_data, CREATE_SUSPENDED, NULL );
#endif
- p_priv->thread_id.id = (DWORD)threadId;
- p_priv->thread_id.hThread = (HANDLE)hThread;
- ResumeThread((HANDLE)hThread);
+ p_priv->thread_id = hThread;
+ ResumeThread(hThread);
}
- i_ret = ( p_priv->thread_id.hThread ? 0 : 1 );
+ i_ret = ( p_priv->thread_id ? 0 : errno );
if( !i_ret && i_priority )
{
- if( !SetThreadPriority(p_priv->thread_id.hThread, i_priority) )
+ if( !SetThreadPriority(p_priv->thread_id, i_priority) )
{
msg_Warn( p_this, "couldn't set a faster priority" );
i_priority = 0;
}
p_priv->b_thread = true;
-
-#if defined( WIN32 ) || defined( UNDER_CE )
- msg_Dbg( p_this, "thread %u (%s) created at priority %d (%s:%d)",
- (unsigned int)p_priv->thread_id.id, psz_name, i_priority,
- psz_file, i_line );
-#else
- msg_Dbg( p_this, "thread %u (%s) created at priority %d (%s:%d)",
- (unsigned int)p_priv->thread_id, psz_name, i_priority,
+ msg_Dbg( p_this, "thread %lu (%s) created at priority %d (%s:%d)",
+ (unsigned long)p_priv->thread_id, psz_name, i_priority,
psz_file, i_line );
-#endif
}
else
{
#elif defined( WIN32 ) || defined( UNDER_CE )
VLC_UNUSED( psz_file); VLC_UNUSED( i_line );
- if( !p_priv->thread_id.hThread )
- p_priv->thread_id.hThread = GetCurrentThread();
- if( !SetThreadPriority(p_priv->thread_id.hThread, i_priority) )
+ if( !p_priv->thread_id )
+ p_priv->thread_id = GetCurrentThread();
+ if( !SetThreadPriority(p_priv->thread_id, i_priority) )
{
msg_Warn( p_this, "couldn't set a faster priority" );
return 1;
** to be on the safe side
*/
if( ! DuplicateHandle(GetCurrentProcess(),
- p_priv->thread_id.hThread,
+ p_priv->thread_id,
GetCurrentProcess(),
&hThread,
0,
FALSE,
DUPLICATE_SAME_ACCESS) )
{
- msg_Err( p_this, "thread_join(%u) failed at %s:%d (%u)",
- (unsigned int)p_priv->thread_id.id,
- psz_file, i_line, (unsigned int)GetLastError() );
p_priv->b_thread = false;
- return;
+ i_ret = GetLastError();
+ goto error;
}
WaitForSingleObject( hThread, INFINITE );
- msg_Dbg( p_this, "thread %u joined (%s:%d)",
- (unsigned int)p_priv->thread_id.id,
- psz_file, i_line );
#if defined( UNDER_CE )
hmodule = GetModuleHandle( _T("COREDLL") );
#else
(double)((user_time%(60*1000000))/1000000.0) );
}
CloseHandle( hThread );
+error:
#elif defined( HAVE_KERNEL_SCHEDULER_H )
int32_t exit_value;
if( i_ret )
{
errno = i_ret;
- msg_Err( p_this, "thread_join(%u) failed at %s:%d (%m)",
- (unsigned int)p_priv->thread_id, psz_file, i_line );
+ msg_Err( p_this, "thread_join(%lu) failed at %s:%d (%m)",
+ (unsigned long)p_priv->thread_id, psz_file, i_line );
}
else
- msg_Dbg( p_this, "thread %u joined (%s:%d)",
- (unsigned int)p_priv->thread_id, psz_file, i_line );
+ msg_Dbg( p_this, "thread %lu joined (%s:%d)",
+ (unsigned long)p_priv->thread_id, psz_file, i_line );
p_priv->b_thread = false;
}