Changeset 9a719ad0af1938ae8978e4e746dc6089eeaab8c6
- 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
| r707279b |
r9a719ad |
|
| 444 | 444 | #endif |
|---|
| 445 | 445 | |
|---|
| | 446 | #include "vlc_mtime.h" |
|---|
| 446 | 447 | #include "vlc_threads.h" |
|---|
| 447 | 448 | |
|---|
| … | … | |
| 930 | 931 | #include "vlc_variables.h" |
|---|
| 931 | 932 | #include "vlc_objects.h" |
|---|
| 932 | | #include "vlc_mtime.h" |
|---|
| 933 | 933 | #include "vlc_modules.h" |
|---|
| 934 | 934 | #include "vlc_main.h" |
|---|
| r707279b |
r9a719ad |
|
| 120 | 120 | |
|---|
| 121 | 121 | #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; |
|---|
| | 122 | typedef HANDLE vlc_thread_t; |
|---|
| 132 | 123 | |
|---|
| 133 | 124 | typedef BOOL (WINAPI *SIGNALOBJECTANDWAIT) ( HANDLE, HANDLE, DWORD, BOOL ); |
|---|
| … | … | |
| 212 | 203 | |
|---|
| 213 | 204 | #elif defined( UNDER_CE ) |
|---|
| 214 | | VLC_UNUSED( psz_file); VLC_UNUSED( i_line ); |
|---|
| | 205 | (void)psz_file; (void)i_line; |
|---|
| 215 | 206 | |
|---|
| 216 | 207 | EnterCriticalSection( &p_mutex->csection ); |
|---|
| 217 | 208 | |
|---|
| 218 | 209 | #elif defined( WIN32 ) |
|---|
| 219 | | VLC_UNUSED( psz_file); VLC_UNUSED( i_line ); |
|---|
| | 210 | (void)psz_file; (void)i_line; |
|---|
| 220 | 211 | |
|---|
| 221 | 212 | WaitForSingleObject( *p_mutex, INFINITE ); |
|---|
| … | … | |
| 245 | 236 | |
|---|
| 246 | 237 | #elif defined( UNDER_CE ) |
|---|
| 247 | | VLC_UNUSED( psz_file); VLC_UNUSED( i_line ); |
|---|
| | 238 | (void)psz_file); (void)i_line; |
|---|
| 248 | 239 | |
|---|
| 249 | 240 | LeaveCriticalSection( &p_mutex->csection ); |
|---|
| 250 | 241 | |
|---|
| 251 | 242 | #elif defined( WIN32 ) |
|---|
| 252 | | VLC_UNUSED( psz_file); VLC_UNUSED( i_line ); |
|---|
| | 243 | (void)psz_file; (void)i_line; |
|---|
| 253 | 244 | |
|---|
| 254 | 245 | ReleaseMutex( *p_mutex ); |
|---|
| … | … | |
| 286 | 277 | |
|---|
| 287 | 278 | #elif defined( UNDER_CE ) || defined( WIN32 ) |
|---|
| 288 | | VLC_UNUSED( psz_file); VLC_UNUSED( i_line ); |
|---|
| | 279 | (void)psz_file; (void)i_line; |
|---|
| 289 | 280 | |
|---|
| 290 | 281 | /* Release one waiting thread if one is available. */ |
|---|
| … | … | |
| 344 | 335 | |
|---|
| 345 | 336 | #elif defined( WIN32 ) |
|---|
| 346 | | VLC_UNUSED( psz_file); VLC_UNUSED( i_line ); |
|---|
| | 337 | (void)psz_file; (void)i_line; |
|---|
| 347 | 338 | |
|---|
| 348 | 339 | /* Increase our wait count */ |
|---|
| … | … | |
| 393 | 384 | #elif defined( UNDER_CE ) |
|---|
| 394 | 385 | mtime_t delay_ms = (deadline - mdate())/1000; |
|---|
| 395 | | |
|---|
| 396 | 386 | DWORD result; |
|---|
| 397 | 387 | if( delay_ms < 0 ) |
|---|
| … | … | |
| 409 | 399 | return ETIMEDOUT; /* this error is perfectly normal */ |
|---|
| 410 | 400 | |
|---|
| | 401 | (void)psz_file; (void)i_line; |
|---|
| | 402 | |
|---|
| 411 | 403 | #elif defined( WIN32 ) |
|---|
| 412 | | VLC_UNUSED( psz_file); VLC_UNUSED( i_line ); |
|---|
| 413 | | |
|---|
| | 404 | mtime_t delay_ms = (deadline - mdate())/1000; |
|---|
| 414 | 405 | DWORD result; |
|---|
| 415 | | |
|---|
| 416 | | mtime_t delay_ms = (deadline - mdate())/1000; |
|---|
| 417 | 406 | if( delay_ms < 0 ) |
|---|
| 418 | 407 | delay_ms = 0; |
|---|
| … | … | |
| 429 | 418 | return ETIMEDOUT; /* this error is perfectly normal */ |
|---|
| 430 | 419 | |
|---|
| | 420 | (void)psz_file; (void)i_line; |
|---|
| | 421 | |
|---|
| 431 | 422 | #elif defined( HAVE_KERNEL_SCHEDULER_H ) |
|---|
| 432 | 423 | # error Unimplemented |
|---|
| r4c35dd2 |
r9a719ad |
|
| 384 | 384 | #elif defined( WIN32 ) |
|---|
| 385 | 385 | *p_tls = TlsAlloc(); |
|---|
| 386 | | i_ret = (*p_tls == INVALID_HANDLE_VALUE) ? EAGAIN : 0; |
|---|
| | 386 | i_ret = (*p_tls == TLS_OUT_OF_INDEXES) ? EAGAIN : 0; |
|---|
| 387 | 387 | #else |
|---|
| 388 | 388 | # error Unimplemented! |
|---|
| … | … | |
| 451 | 451 | * Knowledge Base, article 104641) */ |
|---|
| 452 | 452 | #if defined( UNDER_CE ) |
|---|
| 453 | | DWORD threadId; |
|---|
| 454 | 453 | 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 ); |
|---|
| 457 | 456 | #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 ); |
|---|
| 470 | 466 | |
|---|
| 471 | 467 | if( !i_ret && i_priority ) |
|---|
| 472 | 468 | { |
|---|
| 473 | | if( !SetThreadPriority(p_priv->thread_id.hThread, i_priority) ) |
|---|
| | 469 | if( !SetThreadPriority(p_priv->thread_id, i_priority) ) |
|---|
| 474 | 470 | { |
|---|
| 475 | 471 | msg_Warn( p_this, "couldn't set a faster priority" ); |
|---|
| … | … | |
| 494 | 490 | |
|---|
| 495 | 491 | 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, |
|---|
| 500 | 494 | 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 |
|---|
| 506 | 495 | } |
|---|
| 507 | 496 | else |
|---|
| … | … | |
| 561 | 550 | VLC_UNUSED( psz_file); VLC_UNUSED( i_line ); |
|---|
| 562 | 551 | |
|---|
| 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) ) |
|---|
| 566 | 555 | { |
|---|
| 567 | 556 | msg_Warn( p_this, "couldn't set a faster priority" ); |
|---|
| … | … | |
| 611 | 600 | */ |
|---|
| 612 | 601 | if( ! DuplicateHandle(GetCurrentProcess(), |
|---|
| 613 | | p_priv->thread_id.hThread, |
|---|
| | 602 | p_priv->thread_id, |
|---|
| 614 | 603 | GetCurrentProcess(), |
|---|
| 615 | 604 | &hThread, |
|---|
| … | … | |
| 618 | 607 | DUPLICATE_SAME_ACCESS) ) |
|---|
| 619 | 608 | { |
|---|
| 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() ); |
|---|
| 623 | 609 | p_priv->b_thread = false; |
|---|
| 624 | | return; |
|---|
| | 610 | i_ret = GetLastError(); |
|---|
| | 611 | goto error; |
|---|
| 625 | 612 | } |
|---|
| 626 | 613 | |
|---|
| 627 | 614 | WaitForSingleObject( hThread, INFINITE ); |
|---|
| 628 | 615 | |
|---|
| 629 | | msg_Dbg( p_this, "thread %u joined (%s:%d)", |
|---|
| 630 | | (unsigned int)p_priv->thread_id.id, |
|---|
| 631 | | psz_file, i_line ); |
|---|
| 632 | 616 | #if defined( UNDER_CE ) |
|---|
| 633 | 617 | hmodule = GetModuleHandle( _T("COREDLL") ); |
|---|
| … | … | |
| 666 | 650 | } |
|---|
| 667 | 651 | CloseHandle( hThread ); |
|---|
| | 652 | error: |
|---|
| 668 | 653 | |
|---|
| 669 | 654 | #elif defined( HAVE_KERNEL_SCHEDULER_H ) |
|---|
| … | … | |
| 676 | 661 | { |
|---|
| 677 | 662 | 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 ); |
|---|
| 680 | 665 | } |
|---|
| 681 | 666 | 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 ); |
|---|
| 684 | 669 | |
|---|
| 685 | 670 | p_priv->b_thread = false; |
|---|