Changeset 5539 for pjproject/trunk/pjlib/src/pj/os_core_win32.c
- Timestamp:
- Jan 23, 2017 4:32:34 AM (8 years ago)
- Location:
- pjproject/trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
pjproject/trunk
- Property svn:mergeinfo changed
/pjproject/branches/projects/uwp (added) merged: 5208,5210-5211,5254,5256,5298,5439,5470,5497,5511-5515,5526,5528-5529,5532,5538 -
Property
svn:global-ignores
set to
bin
obj
lib
Bin
output
Debug
Generated[^A-Ba-b0-9]Files
Service[^A-Ba-b0-9]References
*.opendb
*.db
*.user
- Property svn:mergeinfo changed
-
pjproject/trunk/pjlib/src/pj/os_core_win32.c
r4537 r5539 39 39 #endif 40 40 41 #if defined(PJ_WIN32_WINPHONE8) && PJ_WIN32_WINPHONE8 42 # include "../../../third_party/threademulation/include/ThreadEmulation.h" 43 #endif 44 41 45 /* Activate mutex related logging if PJ_DEBUG_MUTEX is set, otherwise 42 46 * use default level 6 logging. … … 298 302 PJ_DEF(int) pj_thread_get_prio(pj_thread_t *thread) 299 303 { 304 #if defined(PJ_WIN32_WINPHONE8) && PJ_WIN32_WINPHONE8 305 PJ_UNUSED_ARG(thread); 306 return -1; 307 #else 300 308 return GetThreadPriority(thread->hthread); 309 #endif 301 310 } 302 311 … … 313 322 PJ_EINVAL); 314 323 324 #if defined(PJ_WIN32_WINPHONE8) && PJ_WIN32_WINPHONE8 325 if (SetThreadPriorityRT(thread->hthread, prio) == FALSE) 326 #else 315 327 if (SetThreadPriority(thread->hthread, prio) == FALSE) 328 #endif 316 329 return PJ_RETURN_OS_ERROR(GetLastError()); 317 330 … … 474 487 pj_thread_t *rec; 475 488 489 #if defined(PJ_WIN32_WINPHONE8) && PJ_WIN32_WINPHONE8 490 PJ_UNUSED_ARG(stack_size); 491 #endif 492 476 493 PJ_CHECK_STACK(); 477 494 PJ_ASSERT_RETURN(pool && proc && thread_ptr, PJ_EINVAL); … … 507 524 rec->proc = proc; 508 525 rec->arg = arg; 509 rec->hthread = CreateThread(NULL, stack_size, 510 thread_main, rec, 511 dwflags, &rec->idthread); 526 527 #if defined(PJ_WIN32_WINPHONE8) && PJ_WIN32_WINPHONE8 528 rec->hthread = CreateThreadRT(NULL, 0, 529 thread_main, rec, 530 dwflags, NULL); 531 #else 532 rec->hthread = CreateThread(NULL, stack_size, 533 thread_main, rec, 534 dwflags, &rec->idthread); 535 #endif 536 512 537 if (rec->hthread == NULL) 513 538 return PJ_RETURN_OS_ERROR(GetLastError()); … … 541 566 PJ_ASSERT_RETURN(p, PJ_EINVAL); 542 567 568 #if defined(PJ_WIN32_WINPHONE8) && PJ_WIN32_WINPHONE8 569 if (ResumeThreadRT(rec->hthread) == (DWORD)-1) 570 #else 543 571 if (ResumeThread(rec->hthread) == (DWORD)-1) 572 #endif 544 573 return PJ_RETURN_OS_ERROR(GetLastError()); 545 574 else … … 585 614 PJ_LOG(6, (pj_thread_this()->obj_name, "Joining thread %s", p->obj_name)); 586 615 616 #if defined(PJ_WIN32_WINPHONE8) && PJ_WIN32_WINPHONE8 617 rc = WaitForSingleObjectEx(rec->hthread, INFINITE, FALSE); 618 #else 587 619 rc = WaitForSingleObject(rec->hthread, INFINITE); 620 #endif 588 621 589 622 if (rc==WAIT_OBJECT_0) … … 617 650 { 618 651 PJ_CHECK_STACK(); 652 653 #if defined(PJ_WIN32_WINPHONE8) && PJ_WIN32_WINPHONE8 654 SleepRT(msec); 655 #else 619 656 Sleep(msec); 657 #endif 658 620 659 return PJ_SUCCESS; 621 660 } … … 811 850 //PJ_CHECK_STACK(); 812 851 852 #if defined(PJ_WIN32_WINPHONE8) && PJ_WIN32_WINPHONE8 853 *index = TlsAllocRT(); 854 #else 813 855 *index = TlsAlloc(); 856 #endif 814 857 815 858 if (*index == TLS_OUT_OF_INDEXES) … … 825 868 { 826 869 PJ_CHECK_STACK(); 870 #if defined(PJ_WIN32_WINPHONE8) && PJ_WIN32_WINPHONE8 871 TlsFreeRT(index); 872 #else 827 873 TlsFree(index); 874 #endif 828 875 } 829 876 … … 838 885 //beginning before main thread is initialized. 839 886 //PJ_CHECK_STACK(); 887 888 #if defined(PJ_WIN32_WINPHONE8) && PJ_WIN32_WINPHONE8 889 rc = TlsSetValueRT(index, value); 890 #else 840 891 rc = TlsSetValue(index, value); 892 #endif 893 841 894 return rc!=0 ? PJ_SUCCESS : PJ_RETURN_OS_ERROR(GetLastError()); 842 895 } … … 850 903 //by PJ_CHECK_STACK() itself!!! 851 904 //PJ_CHECK_STACK(); 905 #if defined(PJ_WIN32_WINPHONE8) && PJ_WIN32_WINPHONE8 906 return TlsGetValueRT(index); 907 #else 852 908 return TlsGetValue(index); 909 #endif 853 910 } 854 911 … … 859 916 PJ_CHECK_STACK(); 860 917 861 #if PJ_WIN32_WINNT >= 0x0400 918 #if defined(PJ_WIN32_WINPHONE8) && PJ_WIN32_WINPHONE8 919 InitializeCriticalSectionEx(&mutex->crit, 0, 0); 920 #elif PJ_WIN32_WINNT >= 0x0400 862 921 InitializeCriticalSection(&mutex->crit); 863 922 #else … … 1113 1172 1114 1173 sem = pj_pool_alloc(pool, sizeof(*sem)); 1174 1175 #if defined(PJ_WIN32_WINPHONE8) && PJ_WIN32_WINPHONE8 1176 /** SEMAPHORE_ALL_ACCESS **/ 1177 sem->hSemaphore = CreateSemaphoreEx(NULL, initial, max, NULL, 0, 1178 SEMAPHORE_ALL_ACCESS); 1179 #else 1115 1180 sem->hSemaphore = CreateSemaphore(NULL, initial, max, NULL); 1181 #endif 1182 1116 1183 if (!sem->hSemaphore) 1117 1184 return PJ_RETURN_OS_ERROR(GetLastError()); … … 1143 1210 LOG_MUTEX((sem->obj_name, "Semaphore: thread %s is waiting", 1144 1211 pj_thread_this()->obj_name)); 1145 1212 1213 #if defined(PJ_WIN32_WINPHONE8) && PJ_WIN32_WINPHONE8 1214 result = WaitForSingleObjectEx(sem->hSemaphore, timeout, FALSE); 1215 #else 1146 1216 result = WaitForSingleObject(sem->hSemaphore, timeout); 1217 #endif 1218 1147 1219 if (result == WAIT_OBJECT_0) { 1148 1220 LOG_MUTEX((sem->obj_name, "Semaphore acquired by thread %s", … … 1241 1313 return PJ_ENOMEM; 1242 1314 1243 event->hEvent = CreateEvent(NULL, manual_reset?TRUE:FALSE, 1244 initial?TRUE:FALSE, NULL); 1315 #if defined(PJ_WIN32_WINPHONE8) && PJ_WIN32_WINPHONE8 1316 event->hEvent = CreateEventEx(NULL, NULL, 1317 (manual_reset? 0x1:0x0) | (initial? 0x2:0x0), 1318 EVENT_ALL_ACCESS); 1319 #else 1320 event->hEvent = CreateEvent(NULL, manual_reset ? TRUE : FALSE, 1321 initial ? TRUE : FALSE, NULL); 1322 #endif 1245 1323 1246 1324 if (!event->hEvent) … … 1274 1352 pj_thread_this()->obj_name)); 1275 1353 1354 #if defined(PJ_WIN32_WINPHONE8) && PJ_WIN32_WINPHONE8 1355 result = WaitForSingleObjectEx(event->hEvent, timeout, FALSE); 1356 #else 1276 1357 result = WaitForSingleObject(event->hEvent, timeout); 1358 #endif 1359 1277 1360 if (result == WAIT_OBJECT_0) { 1278 1361 PJ_LOG(6, (event->obj_name, "Event: thread %s is released", … … 1332 1415 PJ_DEF(pj_status_t) pj_event_pulse(pj_event_t *event) 1333 1416 { 1417 #if defined(PJ_WIN32_WINPHONE8) && PJ_WIN32_WINPHONE8 1418 PJ_UNUSED_ARG(event); 1419 pj_assert(!"pj_event_pulse() not supported!"); 1420 return PJ_ENOTSUP; 1421 #else 1334 1422 PJ_CHECK_STACK(); 1335 1423 PJ_ASSERT_RETURN(event, PJ_EINVAL); … … 1338 1426 1339 1427 if (PulseEvent(event->hEvent)) 1340 1428 return PJ_SUCCESS; 1341 1429 else 1342 return PJ_RETURN_OS_ERROR(GetLastError()); 1430 return PJ_RETURN_OS_ERROR(GetLastError()); 1431 #endif 1343 1432 } 1344 1433
Note: See TracChangeset
for help on using the changeset viewer.