- Timestamp:
- Oct 29, 2006 6:13:13 PM (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
pjproject/branches/symbian/pjlib/src/pj/os_core_symbian.cpp
r788 r789 47 47 void *tls_values[PJ_MAX_TLS]; 48 48 49 #if defined(PJ_OS_HAS_CHECK_STACK) && PJ_OS_HAS_CHECK_STACK!=0 50 pj_uint32_t stk_size; 51 pj_uint32_t stk_max_usage; 52 char *stk_start; 53 const char *caller_file; 54 int caller_line; 55 #endif 56 49 57 } main_thread; 50 58 … … 54 62 }; 55 63 64 struct pj_sem_t 65 { 66 int value; 67 int max; 68 }; 56 69 57 70 /* Flags to indicate which TLS variables have been used */ … … 67 80 68 81 CPjTimeoutTimer::CPjTimeoutTimer() 69 : CActive(EPriorityNormal), hasTimedOut_( false)82 : CActive(EPriorityNormal), hasTimedOut_(PJ_FALSE) 70 83 { 71 84 } … … 80 93 void CPjTimeoutTimer::ConstructL() 81 94 { 95 hasTimedOut_ = PJ_FALSE; 82 96 timer_.CreateLocal(); 83 97 CActiveScheduler::Add(this); … … 86 100 CPjTimeoutTimer *CPjTimeoutTimer::NewL() 87 101 { 88 CPjTimeoutTimer *self = new (ELeave)CPjTimeoutTimer;102 CPjTimeoutTimer *self = new CPjTimeoutTimer; 89 103 CleanupStack::PushL(self); 90 104 … … 101 115 Cancel(); 102 116 103 hasTimedOut_ = false;117 hasTimedOut_ = PJ_FALSE; 104 118 timer_.After(iStatus, miliSeconds * 1000); 105 119 SetActive(); 120 121 pj_assert(iStatus==KRequestPending); 106 122 } 107 123 108 124 bool CPjTimeoutTimer::HasTimedOut() const 109 125 { 110 return hasTimedOut_ ;126 return hasTimedOut_ != 0; 111 127 } 112 128 113 129 void CPjTimeoutTimer::RunL() 114 130 { 115 hasTimedOut_ = true;131 hasTimedOut_ = PJ_TRUE; 116 132 } 117 133 … … 252 268 { 253 269 pj_ansi_strcpy(main_thread.obj_name, "pjthread"); 270 271 // Init main thread 272 pj_memset(&main_thread, 0, sizeof(main_thread)); 254 273 255 274 // Initialize PjSymbianOS instance … … 365 384 PJ_DEF(pj_status_t) pj_thread_sleep(unsigned msec) 366 385 { 386 //Not a good idea, as we don't want network events to 387 //arrive while we're not polling them: 388 //PjSymbianOS::Instance()->WaitForActiveObjects(); 389 390 //.. so rather use this, which won't wake up Active Objects: 367 391 User::After(msec*1000); 392 368 393 return PJ_SUCCESS; 369 394 } … … 642 667 unsigned initial, 643 668 unsigned max, 644 pj_sem_t **sem) 645 { 646 PJ_UNUSED_ARG(pool); 669 pj_sem_t **p_sem) 670 { 671 pj_sem_t *sem; 672 647 673 PJ_UNUSED_ARG(name); 648 PJ_UNUSED_ARG(initial); 649 PJ_UNUSED_ARG(max); 674 675 sem = (pj_sem_t*) pj_pool_zalloc(pool, sizeof(pj_sem_t)); 676 sem->value = initial; 677 sem->max = max; 678 679 *p_sem = sem; 680 681 return PJ_SUCCESS; 682 } 683 684 685 /* 686 * Wait for semaphore. 687 */ 688 PJ_DEF(pj_status_t) pj_sem_wait(pj_sem_t *sem) 689 { 690 if (sem->value > 0) { 691 sem->value--; 692 return PJ_SUCCESS; 693 } else { 694 pj_assert(!"Unexpected!"); 695 return PJ_EINVALIDOP; 696 } 697 } 698 699 700 /* 701 * Try wait for semaphore. 702 */ 703 PJ_DEF(pj_status_t) pj_sem_trywait(pj_sem_t *sem) 704 { 705 if (sem->value > 0) { 706 sem->value--; 707 return PJ_SUCCESS; 708 } else { 709 pj_assert(!"Unexpected!"); 710 return PJ_EINVALIDOP; 711 } 712 } 713 714 715 /* 716 * Release semaphore. 717 */ 718 PJ_DEF(pj_status_t) pj_sem_post(pj_sem_t *sem) 719 { 720 sem->value++; 721 return PJ_SUCCESS; 722 } 723 724 725 /* 726 * Destroy semaphore. 727 */ 728 PJ_DEF(pj_status_t) pj_sem_destroy(pj_sem_t *sem) 729 { 650 730 PJ_UNUSED_ARG(sem); 651 652 /* Unsupported */ 653 return PJ_ENOTSUP; 654 } 655 656 657 /* 658 * Wait for semaphore. 659 */ 660 PJ_DEF(pj_status_t) pj_sem_wait(pj_sem_t *sem) 661 { 662 PJ_UNUSED_ARG(sem); 663 return PJ_EINVALIDOP; 664 } 665 666 667 /* 668 * Try wait for semaphore. 669 */ 670 PJ_DEF(pj_status_t) pj_sem_trywait(pj_sem_t *sem) 671 { 672 PJ_UNUSED_ARG(sem); 673 return PJ_EINVALIDOP; 674 } 675 676 677 /* 678 * Release semaphore. 679 */ 680 PJ_DEF(pj_status_t) pj_sem_post(pj_sem_t *sem) 681 { 682 PJ_UNUSED_ARG(sem); 683 return PJ_EINVALIDOP; 684 } 685 686 687 /* 688 * Destroy semaphore. 689 */ 690 PJ_DEF(pj_status_t) pj_sem_destroy(pj_sem_t *sem) 691 { 692 PJ_UNUSED_ARG(sem); 693 return PJ_EINVALIDOP; 694 } 695 696 731 return PJ_SUCCESS; 732 } 733 734 735 #if defined(PJ_OS_HAS_CHECK_STACK) && PJ_OS_HAS_CHECK_STACK != 0 736 /* 737 * The implementation of stack checking. 738 */ 739 PJ_DEF(void) pj_thread_check_stack(const char *file, int line) 740 { 741 char stk_ptr; 742 pj_uint32_t usage; 743 pj_thread_t *thread = pj_thread_this(); 744 745 pj_assert(thread); 746 747 /* Calculate current usage. */ 748 usage = (&stk_ptr > thread->stk_start) ? &stk_ptr - thread->stk_start : 749 thread->stk_start - &stk_ptr; 750 751 /* Assert if stack usage is dangerously high. */ 752 pj_assert("STACK OVERFLOW!! " && (usage <= thread->stk_size - 128)); 753 754 /* Keep statistic. */ 755 if (usage > thread->stk_max_usage) { 756 thread->stk_max_usage = usage; 757 thread->caller_file = file; 758 thread->caller_line = line; 759 } 760 } 761 762 /* 763 * Get maximum stack usage statistic. 764 */ 765 PJ_DEF(pj_uint32_t) pj_thread_get_stack_max_usage(pj_thread_t *thread) 766 { 767 return thread->stk_max_usage; 768 } 769 770 /* 771 * Dump thread stack status. 772 */ 773 PJ_DEF(pj_status_t) pj_thread_get_stack_info(pj_thread_t *thread, 774 const char **file, 775 int *line) 776 { 777 pj_assert(thread); 778 779 *file = thread->caller_file; 780 *line = thread->caller_line; 781 return 0; 782 } 783 784 #endif /* PJ_OS_HAS_CHECK_STACK */
Note: See TracChangeset
for help on using the changeset viewer.