Changeset 9a719ad0af1938ae8978e4e746dc6089eeaab8c6

Show
Ignore:
Timestamp:
05/08/08 21:33:21 (4 months ago)
Author:
Rémi Denis-Courmont <rem@videolan.org>
git-committer:
Rémi Denis-Courmont <rem@videolan.org> 1210275201 +0300
git-parent:

[707279b40c386c8a16e1f894db2141a93f647a96]

git-author:
Rémi Denis-Courmont <rem@videolan.org> 1210275201 +0300
Message:

Win32 compile fixes

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • include/vlc_common.h

    r707279b r9a719ad  
    444444#endif 
    445445 
     446#include "vlc_mtime.h" 
    446447#include "vlc_threads.h" 
    447448 
     
    930931#include "vlc_variables.h" 
    931932#include "vlc_objects.h" 
    932 #include "vlc_mtime.h" 
    933933#include "vlc_modules.h" 
    934934#include "vlc_main.h" 
  • include/vlc_threads.h

    r707279b r9a719ad  
    120120 
    121121#elif defined( WIN32 ) || defined( UNDER_CE ) 
    122 typedef struct 
    123 
    124     /* thread id */ 
    125     DWORD  id; 
    126     /* 
    127     ** handle to created thread, needs be closed to dispose of it 
    128     ** even after thread has exited 
    129     */ 
    130     HANDLE hThread; 
    131 } vlc_thread_t; 
     122typedef HANDLE  vlc_thread_t; 
    132123 
    133124typedef BOOL (WINAPI *SIGNALOBJECTANDWAIT) ( HANDLE, HANDLE, DWORD, BOOL ); 
     
    212203 
    213204#elif defined( UNDER_CE ) 
    214     VLC_UNUSED( psz_file); VLC_UNUSED( i_line )
     205    (void)psz_file; (void)i_line
    215206 
    216207    EnterCriticalSection( &p_mutex->csection ); 
    217208 
    218209#elif defined( WIN32 ) 
    219     VLC_UNUSED( psz_file); VLC_UNUSED( i_line )
     210    (void)psz_file; (void)i_line
    220211 
    221212    WaitForSingleObject( *p_mutex, INFINITE ); 
     
    245236 
    246237#elif defined( UNDER_CE ) 
    247     VLC_UNUSED( psz_file); VLC_UNUSED( i_line )
     238    (void)psz_file); (void)i_line
    248239 
    249240    LeaveCriticalSection( &p_mutex->csection ); 
    250241 
    251242#elif defined( WIN32 ) 
    252     VLC_UNUSED( psz_file); VLC_UNUSED( i_line )
     243    (void)psz_file; (void)i_line
    253244 
    254245    ReleaseMutex( *p_mutex ); 
     
    286277 
    287278#elif defined( UNDER_CE ) || defined( WIN32 ) 
    288     VLC_UNUSED( psz_file); VLC_UNUSED( i_line )
     279    (void)psz_file; (void)i_line
    289280 
    290281    /* Release one waiting thread if one is available. */ 
     
    344335 
    345336#elif defined( WIN32 ) 
    346     VLC_UNUSED( psz_file); VLC_UNUSED( i_line )
     337    (void)psz_file; (void)i_line
    347338 
    348339    /* Increase our wait count */ 
     
    393384#elif defined( UNDER_CE ) 
    394385    mtime_t delay_ms = (deadline - mdate())/1000; 
    395  
    396386    DWORD result; 
    397387    if( delay_ms < 0 ) 
     
    409399       return ETIMEDOUT; /* this error is perfectly normal */ 
    410400 
     401    (void)psz_file; (void)i_line; 
     402 
    411403#elif defined( WIN32 ) 
    412     VLC_UNUSED( psz_file); VLC_UNUSED( i_line ); 
    413  
     404    mtime_t delay_ms = (deadline - mdate())/1000; 
    414405    DWORD result; 
    415  
    416     mtime_t delay_ms = (deadline - mdate())/1000; 
    417406    if( delay_ms < 0 ) 
    418407        delay_ms = 0; 
     
    429418       return ETIMEDOUT; /* this error is perfectly normal */ 
    430419 
     420    (void)psz_file; (void)i_line; 
     421 
    431422#elif defined( HAVE_KERNEL_SCHEDULER_H ) 
    432423#   error Unimplemented 
  • src/misc/threads.c

    r4c35dd2 r9a719ad  
    384384#elif defined( WIN32 ) 
    385385    *p_tls = TlsAlloc(); 
    386     i_ret = (*p_tls == INVALID_HANDLE_VALUE) ? EAGAIN : 0; 
     386    i_ret = (*p_tls == TLS_OUT_OF_INDEXES) ? EAGAIN : 0; 
    387387#else 
    388388# error Unimplemented! 
     
    451451         * Knowledge Base, article 104641) */ 
    452452#if defined( UNDER_CE ) 
    453         DWORD  threadId; 
    454453        HANDLE hThread = CreateThread( NULL, 0, (LPTHREAD_START_ROUTINE)func, 
    455                                       (LPVOID)p_data, CREATE_SUSPENDED, 
    456                       &threadId ); 
     454                                      (LPVOID)p_data, CREATE_SUSPENDED, 
     455                                        NULL ); 
    457456#else 
    458         unsigned threadId; 
    459         uintptr_t hThread = _beginthreadex( NULL, 0, 
    460                         (LPTHREAD_START_ROUTINE)func, 
    461                                             (void*)p_data, CREATE_SUSPENDED, 
    462                         &threadId ); 
    463 #endif 
    464         p_priv->thread_id.id = (DWORD)threadId; 
    465         p_priv->thread_id.hThread = (HANDLE)hThread; 
    466         ResumeThread((HANDLE)hThread); 
    467     } 
    468  
    469     i_ret = ( p_priv->thread_id.hThread ? 0 : 1 ); 
     457        HANDLE hThread = (HANDLE)(uintptr_t) 
     458            _beginthreadex( NULL, 0, (LPTHREAD_START_ROUTINE)func, 
     459                            (void *)p_data, CREATE_SUSPENDED, NULL ); 
     460#endif 
     461        p_priv->thread_id = hThread; 
     462        ResumeThread(hThread); 
     463    } 
     464 
     465    i_ret = ( p_priv->thread_id ? 0 : errno ); 
    470466 
    471467    if( !i_ret && i_priority ) 
    472468    { 
    473         if( !SetThreadPriority(p_priv->thread_id.hThread, i_priority) ) 
     469        if( !SetThreadPriority(p_priv->thread_id, i_priority) ) 
    474470        { 
    475471            msg_Warn( p_this, "couldn't set a faster priority" ); 
     
    494490 
    495491        p_priv->b_thread = true; 
    496  
    497 #if defined( WIN32 ) || defined( UNDER_CE ) 
    498         msg_Dbg( p_this, "thread %u (%s) created at priority %d (%s:%d)", 
    499                  (unsigned int)p_priv->thread_id.id, psz_name, i_priority, 
     492        msg_Dbg( p_this, "thread %lu (%s) created at priority %d (%s:%d)", 
     493                 (unsigned long)p_priv->thread_id, psz_name, i_priority, 
    500494                 psz_file, i_line ); 
    501 #else 
    502         msg_Dbg( p_this, "thread %u (%s) created at priority %d (%s:%d)", 
    503                  (unsigned int)p_priv->thread_id, psz_name, i_priority, 
    504                  psz_file, i_line ); 
    505 #endif 
    506495    } 
    507496    else 
     
    561550    VLC_UNUSED( psz_file); VLC_UNUSED( i_line ); 
    562551 
    563     if( !p_priv->thread_id.hThread
    564         p_priv->thread_id.hThread = GetCurrentThread(); 
    565     if( !SetThreadPriority(p_priv->thread_id.hThread, i_priority) ) 
     552    if( !p_priv->thread_id
     553        p_priv->thread_id = GetCurrentThread(); 
     554    if( !SetThreadPriority(p_priv->thread_id, i_priority) ) 
    566555    { 
    567556        msg_Warn( p_this, "couldn't set a faster priority" ); 
     
    611600    */ 
    612601    if( ! DuplicateHandle(GetCurrentProcess(), 
    613             p_priv->thread_id.hThread
     602            p_priv->thread_id
    614603            GetCurrentProcess(), 
    615604            &hThread, 
     
    618607            DUPLICATE_SAME_ACCESS) ) 
    619608    { 
    620         msg_Err( p_this, "thread_join(%u) failed at %s:%d (%u)", 
    621                          (unsigned int)p_priv->thread_id.id, 
    622              psz_file, i_line, (unsigned int)GetLastError() ); 
    623609        p_priv->b_thread = false; 
    624         return; 
     610        i_ret = GetLastError(); 
     611        goto error; 
    625612    } 
    626613 
    627614    WaitForSingleObject( hThread, INFINITE ); 
    628615 
    629     msg_Dbg( p_this, "thread %u joined (%s:%d)", 
    630              (unsigned int)p_priv->thread_id.id, 
    631              psz_file, i_line ); 
    632616#if defined( UNDER_CE ) 
    633617    hmodule = GetModuleHandle( _T("COREDLL") ); 
     
    666650    } 
    667651    CloseHandle( hThread ); 
     652error: 
    668653 
    669654#elif defined( HAVE_KERNEL_SCHEDULER_H ) 
     
    676661    { 
    677662        errno = i_ret; 
    678         msg_Err( p_this, "thread_join(%u) failed at %s:%d (%m)", 
    679                          (unsigned int)p_priv->thread_id, psz_file, i_line ); 
     663        msg_Err( p_this, "thread_join(%lu) failed at %s:%d (%m)", 
     664                         (unsigned long)p_priv->thread_id, psz_file, i_line ); 
    680665    } 
    681666    else 
    682         msg_Dbg( p_this, "thread %u joined (%s:%d)", 
    683                          (unsigned int)p_priv->thread_id, psz_file, i_line ); 
     667        msg_Dbg( p_this, "thread %lu joined (%s:%d)", 
     668                         (unsigned long)p_priv->thread_id, psz_file, i_line ); 
    684669 
    685670    p_priv->b_thread = false;