Changeset 692
- Timestamp:
- Aug 29, 2006 8:44:04 AM (18 years ago)
- Location:
- pjproject/branches/symbian
- Files:
-
- 8 added
- 6 edited
- 2 moved
Legend:
- Unmodified
- Added
- Removed
-
pjproject/branches/symbian/pjlib/build/pjlib.dsp
r686 r692 111 111 # Begin Source File 112 112 113 SOURCE=..\src\pj\ioqueue_symbian.cpp 114 # PROP Exclude_From_Build 1 115 # End Source File 116 # Begin Source File 117 113 118 SOURCE=..\src\pj\log_writer_printk.c 114 119 # PROP Exclude_From_Build 1 … … 162 167 163 168 SOURCE=..\src\pj\sock_linux_kernel.c 169 # PROP Exclude_From_Build 1 170 # End Source File 171 # Begin Source File 172 173 SOURCE=..\src\pj\sock_select_symbian.cpp 164 174 # PROP Exclude_From_Build 1 165 175 # End Source File -
pjproject/branches/symbian/pjlib/include/pj/compat/os_symbian.h
r687 r692 92 92 #define PJ_BLOCKING_CONNECT_ERROR_VAL EINPROGRESS 93 93 94 #ifndef PJ_HAS_THREADS 95 # define PJ_HAS_THREADS (1) 96 #endif 94 /* 95 * We don't want to use threads in Symbian 96 */ 97 #define PJ_HAS_THREADS 0 97 98 98 99 … … 107 108 * Override features. 108 109 */ 109 #define PJ_HAS_FLOATING_POINT 0110 #define PJ_HAS_MALLOC 0111 #define PJ_HAS_SEMAPHORE 0110 #define PJ_HAS_FLOATING_POINT 1 111 #define PJ_HAS_MALLOC 1 112 #define PJ_HAS_SEMAPHORE 1 112 113 #define PJ_HAS_EVENT_OBJ 0 113 114 #define PJ_HAS_HIGH_RES_TIMER 1 114 #ifndef PJ_OS_HAS_CHECK_STACK 115 # define PJ_OS_HAS_CHECK_STACK 0 116 #endif 115 #define PJ_OS_HAS_CHECK_STACK 0 117 116 #define PJ_TERM_HAS_COLOR 0 118 117 #define PJ_NATIVE_STRING_IS_UNICODE 0 … … 122 121 123 122 /* If 1, use Read/Write mutex emulation for platforms that don't support it */ 124 #define PJ_EMULATE_RWMUTEX 0123 #define PJ_EMULATE_RWMUTEX 1 125 124 126 125 /* If 1, pj_thread_create() should enforce the stack size when creating -
pjproject/branches/symbian/pjlib/include/pj/config.h
r687 r692 34 34 #elif defined(__CW32__) 35 35 # include <pj/compat/cc_mwcc.h> 36 #elif defined(__MWERKS__) 37 # include <pj/compat/cc_codew.h> 36 38 #else 37 39 # error "Unknown compiler." -
pjproject/branches/symbian/pjlib/src/pj/os_core_symbian.cpp
r686 r692 19 19 20 20 #include <e32cmn.h> 21 #pragma data_seg(".SYMBIAN")22 __EMULATOR_IMAGE_HEADER2 (0x10000079,0x1000008d,0x1000425b,EPriorityForeground,0x00000000u,0x00000000u,0x00000000,0x70000001,0x00000000,0)23 #pragma data_seg()24 25 26 21 #include <e32std.h> 27 22 … … 36 31 #include <pj/errno.h> 37 32 38 #if defined(PJ_HAS_SEMAPHORE) && PJ_HAS_SEMAPHORE != 0 39 # include <semaphore.h> 40 #endif 41 42 #include <unistd.h> // getpid() 43 #include <errno.h> // errno 44 45 46 #define PJ_MAX_TLS 32 47 33 34 #define PJ_MAX_TLS 32 35 #define DUMMY_MUTEX ((pj_mutex_t*)101) 36 #define DUMMY_SEMAPHORE ((pj_sem_t*)102) 37 38 39 /* 40 * Note: 41 * 42 * The Symbian implementation does not support threading! 43 */ 48 44 49 45 struct pj_thread_t 50 46 { 51 47 char obj_name[PJ_MAX_OBJ_NAME]; 52 RThread *thread;53 pj_thread_proc *proc;54 void *arg;55 unsigned flags;56 48 void *tls_values[PJ_MAX_TLS]; 49 50 } main_thread; 51 52 struct pj_atomic_t 53 { 54 pj_atomic_value_t value; 57 55 }; 58 56 … … 75 73 PJ_DEF(pj_status_t) pj_init(void) 76 74 { 77 78 return PJ_SUCCESS; 79 } 80 81 82 /* 83 * thread_main() 84 * 85 * This is the main entry for all threads. 86 */ 87 static TInt thread_main(TAny *param) 88 { 89 pj_thread_t *rec = (pj_thread_t *) param; 90 TInt result; 91 92 /* Save thread record to Symbian TLS */ 93 Dll::SetTls(rec); 94 95 /* Suspend thread if PJ_THREAD_SUSPENDED is specified */ 96 if (rec->flags & PJ_THREAD_SUSPENDED) 97 rec->thread->Suspend(); 98 99 PJ_LOG(6,(rec->obj_name, "Thread started")); 100 101 /* Call user's entry! */ 102 result = (TInt)(*rec->proc)(rec->arg); 103 104 /* Done. */ 105 PJ_LOG(6,(rec->obj_name, "Thread quitting")); 106 107 return result; 108 } 75 pj_ansi_strcpy(main_thread.obj_name, "pjthread"); 76 return PJ_SUCCESS; 77 } 78 109 79 110 80 /* … … 119 89 pj_thread_t **ptr_thread) 120 90 { 121 pj_thread_t *rec; 122 void *p; 123 int rc; 124 125 126 PJ_ASSERT_RETURN(pool && proc && ptr_thread, PJ_EINVAL); 127 128 /* Create thread record and assign name for the thread */ 129 rec = (struct pj_thread_t*) pj_pool_zalloc(pool, sizeof(pj_thread_t)); 130 PJ_ASSERT_RETURN(rec, PJ_ENOMEM); 131 132 /* Set name. */ 133 if (!thread_name) 134 thread_name = "thr%p"; 135 136 if (strchr(thread_name, '%')) { 137 pj_ansi_snprintf(rec->obj_name, PJ_MAX_OBJ_NAME, thread_name, rec); 138 } else { 139 strncpy(rec->obj_name, thread_name, PJ_MAX_OBJ_NAME); 140 rec->obj_name[PJ_MAX_OBJ_NAME-1] = '\0'; 141 } 142 143 /* Create Symbian RThread object */ 144 p = pj_pool_alloc(pool, sizeof(RThread)); 145 rec->thread = new (p) RThread; 146 147 /* Create the thread. */ 148 rec->proc = proc; 149 rec->arg = arg; 150 rec->flags = flags; 151 _LIT( KThreadName, "Athread"); 152 rc = rec->thread->Create(KThreadName, &thread_main, stack_size, 153 KMinHeapSize, KMinHeapSize, rec); 154 if (rc != 0) { 155 return PJ_RETURN_OS_ERROR(rc); 156 } 157 158 *ptr_thread = rec; 159 160 PJ_LOG(6, (rec->obj_name, "Thread created")); 161 return PJ_SUCCESS; 91 PJ_UNUSED_ARG(pool); 92 PJ_UNUSED_ARG(thread_name); 93 PJ_UNUSED_ARG(proc); 94 PJ_UNUSED_ARG(arg); 95 PJ_UNUSED_ARG(stack_size); 96 PJ_UNUSED_ARG(flags); 97 PJ_UNUSED_ARG(ptr_thread); 98 99 /* Sorry mate, we don't support threading */ 100 return PJ_ENOTSUP; 162 101 } 163 102 … … 167 106 PJ_DEF(const char*) pj_thread_get_name(pj_thread_t *p) 168 107 { 108 pj_assert(p == &main_thread); 169 109 return p->obj_name; 170 110 } … … 175 115 PJ_DEF(pj_status_t) pj_thread_resume(pj_thread_t *p) 176 116 { 177 p->thread->Resume();178 return PJ_ SUCCESS;117 PJ_UNUSED_ARG(p); 118 return PJ_EINVALIDOP; 179 119 } 180 120 … … 184 124 PJ_DEF(pj_thread_t*) pj_thread_this(void) 185 125 { 186 return (pj_thread_t*)Dll::Tls();126 return &main_thread; 187 127 } 188 128 … … 192 132 PJ_DEF(pj_status_t) pj_thread_join(pj_thread_t *rec) 193 133 { 194 TRequestStatus result; 195 196 PJ_LOG(6, (rec->obj_name, "Joining thread %s", rec->obj_name)); 197 198 rec->thread->Rendezvous(result); 199 200 return PJ_SUCCESS; 134 PJ_UNUSED_ARG(rec); 135 return PJ_EINVALIDOP; 201 136 } 202 137 … … 206 141 PJ_DEF(pj_status_t) pj_thread_destroy(pj_thread_t *rec) 207 142 { 208 rec->thread->Kill(1);209 return PJ_ SUCCESS;143 PJ_UNUSED_ARG(rec); 144 return PJ_EINVALIDOP; 210 145 } 211 146 … … 215 150 PJ_DEF(pj_status_t) pj_thread_sleep(unsigned msec) 216 151 { 217 PJ_TODO(MSEC_RESOLUTION_SLEEP); 218 219 if (sleep(msec * 1000) == 0) 220 return PJ_SUCCESS; 221 222 return PJ_SUCCESS; 152 PJ_UNUSED_ARG(msec); 153 154 /* Not supported either */ 155 return PJ_EINVALIDOP; 223 156 } 224 157 … … 288 221 289 222 223 /////////////////////////////////////////////////////////////////////////////// 224 /* 225 * Create atomic variable. 226 */ 227 PJ_DEF(pj_status_t) pj_atomic_create( pj_pool_t *pool, 228 pj_atomic_value_t initial, 229 pj_atomic_t **atomic ) 230 { 231 *atomic = (pj_atomic_t*)pj_pool_alloc(pool, sizeof(struct pj_atomic_t)); 232 (*atomic)->value = initial; 233 return PJ_SUCCESS; 234 } 235 236 237 /* 238 * Destroy atomic variable. 239 */ 240 PJ_DEF(pj_status_t) pj_atomic_destroy( pj_atomic_t *atomic_var ) 241 { 242 PJ_UNUSED_ARG(atomic_var); 243 return PJ_SUCCESS; 244 } 245 246 247 /* 248 * Set the value of an atomic type, and return the previous value. 249 */ 250 PJ_DEF(void) pj_atomic_set( pj_atomic_t *atomic_var, 251 pj_atomic_value_t value) 252 { 253 atomic_var->value = value; 254 } 255 256 257 /* 258 * Get the value of an atomic type. 259 */ 260 PJ_DEF(pj_atomic_value_t) pj_atomic_get(pj_atomic_t *atomic_var) 261 { 262 return atomic_var->value; 263 } 264 265 266 /* 267 * Increment the value of an atomic type. 268 */ 269 PJ_DEF(void) pj_atomic_inc(pj_atomic_t *atomic_var) 270 { 271 ++atomic_var->value; 272 } 273 274 275 /* 276 * Increment the value of an atomic type and get the result. 277 */ 278 PJ_DEF(pj_atomic_value_t) pj_atomic_inc_and_get(pj_atomic_t *atomic_var) 279 { 280 return ++atomic_var->value; 281 } 282 283 284 /* 285 * Decrement the value of an atomic type. 286 */ 287 PJ_DEF(void) pj_atomic_dec(pj_atomic_t *atomic_var) 288 { 289 --atomic_var->value; 290 } 291 292 293 /* 294 * Decrement the value of an atomic type and get the result. 295 */ 296 PJ_DEF(pj_atomic_value_t) pj_atomic_dec_and_get(pj_atomic_t *atomic_var) 297 { 298 return --atomic_var->value; 299 } 300 301 302 /* 303 * Add a value to an atomic type. 304 */ 305 PJ_DEF(void) pj_atomic_add( pj_atomic_t *atomic_var, 306 pj_atomic_value_t value) 307 { 308 atomic_var->value += value; 309 } 310 311 312 /* 313 * Add a value to an atomic type and get the result. 314 */ 315 PJ_DEF(pj_atomic_value_t) pj_atomic_add_and_get( pj_atomic_t *atomic_var, 316 pj_atomic_value_t value) 317 { 318 atomic_var->value += value; 319 return atomic_var->value; 320 } 321 322 323 324 ///////////////////////////////////////////////////////////////////////////// 325 290 326 PJ_DEF(pj_status_t) pj_mutex_create( pj_pool_t *pool, 291 327 const char *name, … … 293 329 pj_mutex_t **mutex) 294 330 { 295 PJ_TODO(pj_mutex_create); 296 *mutex = (pj_mutex_t*)1; 331 PJ_UNUSED_ARG(pool); 332 PJ_UNUSED_ARG(name); 333 PJ_UNUSED_ARG(type); 334 335 *mutex = DUMMY_MUTEX; 297 336 return PJ_SUCCESS; 298 337 } … … 322 361 PJ_DEF(pj_status_t) pj_mutex_lock(pj_mutex_t *mutex) 323 362 { 324 PJ_TODO(pj_mutex_lock);363 pj_assert(mutex == DUMMY_MUTEX); 325 364 return PJ_SUCCESS; 326 365 } … … 331 370 PJ_DEF(pj_status_t) pj_mutex_trylock(pj_mutex_t *mutex) 332 371 { 333 PJ_TODO(pj_mutex_trylock);372 pj_assert(mutex == DUMMY_MUTEX); 334 373 return PJ_SUCCESS; 335 374 } … … 340 379 PJ_DEF(pj_status_t) pj_mutex_unlock(pj_mutex_t *mutex) 341 380 { 342 PJ_TODO(pj_mutex_unlock);381 pj_assert(mutex == DUMMY_MUTEX); 343 382 return PJ_SUCCESS; 344 383 } … … 349 388 PJ_DEF(pj_status_t) pj_mutex_destroy(pj_mutex_t *mutex) 350 389 { 351 PJ_TODO(pj_mutex_destroy); 352 return PJ_SUCCESS; 353 } 390 pj_assert(mutex == DUMMY_MUTEX); 391 return PJ_SUCCESS; 392 } 393 354 394 355 395 ///////////////////////////////////////////////////////////////////////////// 396 /* 397 * RW Mutex 398 */ 399 #include "os_rwmutex.c" 400 401 402 ///////////////////////////////////////////////////////////////////////////// 356 403 357 404 /* … … 360 407 PJ_DEF(void) pj_enter_critical_section(void) 361 408 { 362 PJ_TODO(pj_enter_critical_section);409 /* Nothing to do */ 363 410 } 364 411 … … 369 416 PJ_DEF(void) pj_leave_critical_section(void) 370 417 { 371 PJ_TODO(pj_leave_critical_section); 372 } 373 374 375 376 418 /* Nothing to do */ 419 } 420 421 422 ///////////////////////////////////////////////////////////////////////////// 423 424 /* 425 * Create semaphore. 426 */ 427 PJ_DEF(pj_status_t) pj_sem_create( pj_pool_t *pool, 428 const char *name, 429 unsigned initial, 430 unsigned max, 431 pj_sem_t **sem) 432 { 433 PJ_UNUSED_ARG(pool); 434 PJ_UNUSED_ARG(name); 435 PJ_UNUSED_ARG(initial); 436 PJ_UNUSED_ARG(max); 437 PJ_UNUSED_ARG(sem); 438 439 /* Unsupported */ 440 return PJ_ENOTSUP; 441 } 442 443 444 /* 445 * Wait for semaphore. 446 */ 447 PJ_DEF(pj_status_t) pj_sem_wait(pj_sem_t *sem) 448 { 449 PJ_UNUSED_ARG(sem); 450 return PJ_EINVALIDOP; 451 } 452 453 454 /* 455 * Try wait for semaphore. 456 */ 457 PJ_DEF(pj_status_t) pj_sem_trywait(pj_sem_t *sem) 458 { 459 PJ_UNUSED_ARG(sem); 460 return PJ_EINVALIDOP; 461 } 462 463 464 /* 465 * Release semaphore. 466 */ 467 PJ_DEF(pj_status_t) pj_sem_post(pj_sem_t *sem) 468 { 469 PJ_UNUSED_ARG(sem); 470 return PJ_EINVALIDOP; 471 } 472 473 474 /* 475 * Destroy semaphore. 476 */ 477 PJ_DEF(pj_status_t) pj_sem_destroy(pj_sem_t *sem) 478 { 479 PJ_UNUSED_ARG(sem); 480 return PJ_EINVALIDOP; 481 } 482 483 -
pjproject/branches/symbian/pjlib/src/pj/os_rwmutex.c
r433 r692 57 57 58 58 *p_mutex = NULL; 59 rwmutex = pj_pool_alloc(pool, sizeof(struct pj_rwmutex_t));59 rwmutex = (pj_rwmutex_t*)pj_pool_alloc(pool, sizeof(struct pj_rwmutex_t)); 60 60 61 61 status = pj_mutex_create_simple(pool, name, &rwmutex ->read_lock); -
pjproject/branches/symbian/pjlib/src/pjlib-test/main_symbian.cpp
r681 r692 1 1 //Auto-generated file. Please do not modify. 2 #include <e32cmn.h> 3 #pragma data_seg(".SYMBIAN") 4 __EMULATOR_IMAGE_HEADER2 (0x1000007a,0x00000000,0x00000000,EPriorityForeground,0x00000000u,0x00000000u,0x00000000,0x00000000,0x00000000,0) 5 #pragma data_seg() 2 //#include <e32cmn.h> 3 4 //#pragma data_seg(".SYMBIAN") 5 //__EMULATOR_IMAGE_HEADER2 (0x1000007a,0x00000000,0x00000000,EPriorityForeground,0x00000000u,0x00000000u,0x00000000,0x00000000,0x00000000,0) 6 //#pragma data_seg() 6 7 7 8 #include "test.h" … … 69 70 console->Printf(KTextPressAnyKey); 70 71 console->Getch(); 71 console->Printf(KTextPressAnyKey);72 console->Getch();73 72 74 73 delete console;
Note: See TracChangeset
for help on using the changeset viewer.