Ignore:
Timestamp:
Oct 29, 2006 6:13:13 PM (18 years ago)
Author:
bennylp
Message:

Another Symbian commit, ported all PJSIP libraries and sipstateless runs without crashes (still no SIP message though)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • pjproject/branches/symbian/pjlib/src/pj/os_core_symbian.cpp

    r788 r789  
    4747    void           *tls_values[PJ_MAX_TLS]; 
    4848 
     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 
    4957} main_thread; 
    5058 
     
    5462}; 
    5563 
     64struct pj_sem_t 
     65{ 
     66    int value; 
     67    int max; 
     68}; 
    5669 
    5770/* Flags to indicate which TLS variables have been used */ 
     
    6780 
    6881CPjTimeoutTimer::CPjTimeoutTimer() 
    69 : CActive(EPriorityNormal), hasTimedOut_(false) 
     82: CActive(EPriorityNormal), hasTimedOut_(PJ_FALSE) 
    7083{ 
    7184} 
     
    8093void CPjTimeoutTimer::ConstructL() 
    8194{ 
     95    hasTimedOut_ = PJ_FALSE; 
    8296    timer_.CreateLocal(); 
    8397    CActiveScheduler::Add(this); 
     
    86100CPjTimeoutTimer *CPjTimeoutTimer::NewL() 
    87101{ 
    88     CPjTimeoutTimer *self = new (ELeave) CPjTimeoutTimer; 
     102    CPjTimeoutTimer *self = new CPjTimeoutTimer; 
    89103    CleanupStack::PushL(self); 
    90104 
     
    101115        Cancel(); 
    102116 
    103     hasTimedOut_ = false; 
     117    hasTimedOut_ = PJ_FALSE; 
    104118    timer_.After(iStatus, miliSeconds * 1000); 
    105119    SetActive(); 
     120 
     121    pj_assert(iStatus==KRequestPending); 
    106122} 
    107123 
    108124bool CPjTimeoutTimer::HasTimedOut() const 
    109125{ 
    110     return hasTimedOut_; 
     126    return hasTimedOut_ != 0; 
    111127} 
    112128 
    113129void CPjTimeoutTimer::RunL() 
    114130{ 
    115     hasTimedOut_ = true; 
     131    hasTimedOut_ = PJ_TRUE; 
    116132} 
    117133 
     
    252268{ 
    253269    pj_ansi_strcpy(main_thread.obj_name, "pjthread"); 
     270 
     271    // Init main thread 
     272    pj_memset(&main_thread, 0, sizeof(main_thread)); 
    254273 
    255274    // Initialize PjSymbianOS instance 
     
    365384PJ_DEF(pj_status_t) pj_thread_sleep(unsigned msec) 
    366385{ 
     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: 
    367391    User::After(msec*1000); 
     392 
    368393    return PJ_SUCCESS; 
    369394} 
     
    642667                                   unsigned initial,  
    643668                                   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  
    647673    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 */ 
     688PJ_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 */ 
     703PJ_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 */ 
     718PJ_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 */ 
     728PJ_DEF(pj_status_t) pj_sem_destroy(pj_sem_t *sem) 
     729{ 
    650730    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 */ 
     739PJ_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 */ 
     765PJ_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 */ 
     773PJ_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.