Index: pjproject/trunk/pjlib/src/pj/os_core_unix.c
===================================================================
--- pjproject/trunk/pjlib/src/pj/os_core_unix.c	(revision 4359)
+++ pjproject/trunk/pjlib/src/pj/os_core_unix.c	(revision 4728)
@@ -1,4 +1,4 @@
 /* $Id$ */
-/* 
+/*
  * Copyright (C) 2008-2011 Teluu Inc. (http://www.teluu.com)
  * Copyright (C) 2003-2008 Benny Prijono <benny@prijono.org>
@@ -16,5 +16,5 @@
  * You should have received a copy of the GNU General Public License
  * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA 
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  */
 /*
@@ -165,5 +165,5 @@
     pj_log_init();
 
-    /* Initialize exception ID for the pool. 
+    /* Initialize exception ID for the pool.
      * Must do so after critical section is configured.
      */
@@ -171,5 +171,5 @@
     if (rc != PJ_SUCCESS)
         return rc;
-    
+
     /* Init random seed. */
     /* Or probably not. Let application in charge of this */
@@ -188,5 +188,5 @@
 	}
     }
-#endif   
+#endif
 
     /* Flag PJLIB as initialized */
@@ -383,5 +383,5 @@
  * Get native thread handle
  */
-PJ_DEF(void*) pj_thread_get_os_handle(pj_thread_t *thread) 
+PJ_DEF(void*) pj_thread_get_os_handle(pj_thread_t *thread)
 {
     PJ_ASSERT_RETURN(thread, NULL);
@@ -441,10 +441,10 @@
 
     if(cstr_thread_name && pj_strlen(&thread_name) < sizeof(thread->obj_name)-1)
-	pj_ansi_snprintf(thread->obj_name, sizeof(thread->obj_name), 
+	pj_ansi_snprintf(thread->obj_name, sizeof(thread->obj_name),
 			 cstr_thread_name, thread->thread);
     else
-	pj_ansi_snprintf(thread->obj_name, sizeof(thread->obj_name), 
+	pj_ansi_snprintf(thread->obj_name, sizeof(thread->obj_name),
 			 "thr%p", (void*)thread->thread);
-    
+
     rc = pj_thread_local_set(thread_tls_id, thread);
     if (rc != PJ_SUCCESS) {
@@ -458,5 +458,5 @@
     thread->stk_max_usage = 0;
 #else
-    stack_ptr = '\0';
+    PJ_UNUSED_ARG(stack_ptr);
 #endif
 
@@ -533,9 +533,9 @@
  * pj_thread_create(...)
  */
-PJ_DEF(pj_status_t) pj_thread_create( pj_pool_t *pool, 
+PJ_DEF(pj_status_t) pj_thread_create( pj_pool_t *pool,
 				      const char *thread_name,
-				      pj_thread_proc *proc, 
+				      pj_thread_proc *proc,
 				      void *arg,
-				      pj_size_t stack_size, 
+				      pj_size_t stack_size,
 				      unsigned flags,
 				      pj_thread_t **ptr_thread)
@@ -555,9 +555,9 @@
     rec = (struct pj_thread_t*) pj_pool_zalloc(pool, sizeof(pj_thread_t));
     PJ_ASSERT_RETURN(rec, PJ_ENOMEM);
-    
+
     /* Set name. */
-    if (!thread_name) 
+    if (!thread_name)
 	thread_name = "thr%p";
-    
+
     if (strchr(thread_name, '%')) {
 	pj_ansi_snprintf(rec->obj_name, PJ_MAX_OBJ_NAME, thread_name, rec);
@@ -587,5 +587,5 @@
 	pj_assert(rec->suspended_mutex == NULL);
     }
-    
+
 
     /* Init thread attributes */
@@ -668,5 +668,5 @@
 #if PJ_HAS_THREADS
     pj_thread_t *rec = (pj_thread_t*)pj_thread_local_get(thread_tls_id);
-    
+
     if (rec == NULL) {
 	pj_assert(!"Calling pjlib from unknown/external thread. You must "
@@ -706,6 +706,6 @@
 	return PJ_SUCCESS;
     else {
-	/* Calling pthread_join() on a thread that no longer exists and 
-	 * getting back ESRCH isn't an error (in this context). 
+	/* Calling pthread_join() on a thread that no longer exists and
+	 * getting back ESRCH isn't an error (in this context).
 	 * Thanks Phil Torre <ptorre@zetron.com>.
 	 */
@@ -762,7 +762,7 @@
     /* MacOS X (reported on 10.5) seems to always set errno to ETIMEDOUT.
      * It does so because usleep() is declared to return int, and we're
-     * supposed to check for errno only when usleep() returns non-zero. 
+     * supposed to check for errno only when usleep() returns non-zero.
      * Unfortunately, usleep() is declared to return void in other platforms
-     * so it's not possible to always check for the return value (unless 
+     * so it's not possible to always check for the return value (unless
      * we add a detection routine in autoconf).
      *
@@ -832,5 +832,5 @@
  * pj_atomic_create()
  */
-PJ_DEF(pj_status_t) pj_atomic_create( pj_pool_t *pool, 
+PJ_DEF(pj_status_t) pj_atomic_create( pj_pool_t *pool,
 				      pj_atomic_value_t initial,
 				      pj_atomic_t **ptr_atomic)
@@ -842,5 +842,5 @@
 
     PJ_ASSERT_RETURN(atomic_var, PJ_ENOMEM);
-    
+
 #if PJ_HAS_THREADS
     rc = pj_mutex_create(pool, "atm%p", PJ_MUTEX_SIMPLE, &atomic_var->mutex);
@@ -880,5 +880,5 @@
 #if PJ_HAS_THREADS
     pj_mutex_unlock( atomic_var->mutex);
-#endif 
+#endif
 }
 
@@ -889,5 +889,5 @@
 {
     pj_atomic_value_t oldval;
-    
+
     PJ_CHECK_STACK();
 
@@ -959,6 +959,6 @@
 /*
  * pj_atomic_add_and_get()
- */ 
-PJ_DEF(pj_atomic_value_t) pj_atomic_add_and_get( pj_atomic_t *atomic_var, 
+ */
+PJ_DEF(pj_atomic_value_t) pj_atomic_add_and_get( pj_atomic_t *atomic_var,
                                                  pj_atomic_value_t value )
 {
@@ -968,5 +968,5 @@
     pj_mutex_lock(atomic_var->mutex);
 #endif
-    
+
     atomic_var->value += value;
     new_value = atomic_var->value;
@@ -981,6 +981,6 @@
 /*
  * pj_atomic_add()
- */ 
-PJ_DEF(void) pj_atomic_add( pj_atomic_t *atomic_var, 
+ */
+PJ_DEF(void) pj_atomic_add( pj_atomic_t *atomic_var,
                             pj_atomic_value_t value )
 {
@@ -1012,7 +1012,7 @@
 	    break;
     }
-    if (i == MAX_THREADS) 
+    if (i == MAX_THREADS)
 	return PJ_ETOOMANY;
-    
+
     tls_flag[i] = 1;
     tls[i] = NULL;
@@ -1119,5 +1119,5 @@
        defined(PJ_PTHREAD_MUTEXATTR_T_HAS_RECURSIVE)
 	// Phil Torre <ptorre@zetron.com>:
-	// The RTEMS implementation of POSIX mutexes doesn't include 
+	// The RTEMS implementation of POSIX mutexes doesn't include
 	// pthread_mutexattr_settype(), so what follows is a hack
 	// until I get RTEMS patched to support the set/get functions.
@@ -1132,5 +1132,5 @@
 #endif
     }
-    
+
     if (rc != 0) {
 	return PJ_RETURN_OS_ERROR(rc);
@@ -1141,5 +1141,5 @@
 	return PJ_RETURN_OS_ERROR(rc);
     }
-    
+
     rc = pthread_mutexattr_destroy(&attr);
     if (rc != 0) {
@@ -1176,6 +1176,6 @@
  * pj_mutex_create()
  */
-PJ_DEF(pj_status_t) pj_mutex_create(pj_pool_t *pool, 
-				    const char *name, 
+PJ_DEF(pj_status_t) pj_mutex_create(pj_pool_t *pool,
+				    const char *name,
 				    int type,
 				    pj_mutex_t **ptr_mutex)
@@ -1192,5 +1192,5 @@
     if ((rc=init_mutex(mutex, name, type)) != PJ_SUCCESS)
 	return rc;
-    
+
     *ptr_mutex = mutex;
     return PJ_SUCCESS;
@@ -1204,5 +1204,5 @@
  * pj_mutex_create_simple()
  */
-PJ_DEF(pj_status_t) pj_mutex_create_simple( pj_pool_t *pool, 
+PJ_DEF(pj_status_t) pj_mutex_create_simple( pj_pool_t *pool,
                                             const char *name,
 					    pj_mutex_t **mutex )
@@ -1233,9 +1233,9 @@
 
 #if PJ_DEBUG
-    PJ_LOG(6,(mutex->obj_name, "Mutex: thread %s is waiting (mutex owner=%s)", 
+    PJ_LOG(6,(mutex->obj_name, "Mutex: thread %s is waiting (mutex owner=%s)",
 				pj_thread_this()->obj_name,
 				mutex->owner_name));
 #else
-    PJ_LOG(6,(mutex->obj_name, "Mutex: thread %s is waiting", 
+    PJ_LOG(6,(mutex->obj_name, "Mutex: thread %s is waiting",
 				pj_thread_this()->obj_name));
 #endif
@@ -1251,12 +1251,12 @@
     }
 
-    PJ_LOG(6,(mutex->obj_name, 
-	      (status==0 ? 
-		"Mutex acquired by thread %s (level=%d)" : 
+    PJ_LOG(6,(mutex->obj_name,
+	      (status==0 ?
+		"Mutex acquired by thread %s (level=%d)" :
 		"Mutex acquisition FAILED by %s (level=%d)"),
 	      pj_thread_this()->obj_name,
 	      mutex->nesting_level));
 #else
-    PJ_LOG(6,(mutex->obj_name, 
+    PJ_LOG(6,(mutex->obj_name,
 	      (status==0 ? "Mutex acquired by thread %s" : "FAILED by %s"),
 	      pj_thread_this()->obj_name));
@@ -1291,9 +1291,9 @@
     }
 
-    PJ_LOG(6,(mutex->obj_name, "Mutex released by thread %s (level=%d)", 
-				pj_thread_this()->obj_name, 
+    PJ_LOG(6,(mutex->obj_name, "Mutex released by thread %s (level=%d)",
+				pj_thread_this()->obj_name,
 				mutex->nesting_level));
 #else
-    PJ_LOG(6,(mutex->obj_name, "Mutex released by thread %s", 
+    PJ_LOG(6,(mutex->obj_name, "Mutex released by thread %s",
 				pj_thread_this()->obj_name));
 #endif
@@ -1322,5 +1322,5 @@
     PJ_ASSERT_RETURN(mutex, PJ_EINVAL);
 
-    PJ_LOG(6,(mutex->obj_name, "Mutex: thread %s is trying", 
+    PJ_LOG(6,(mutex->obj_name, "Mutex: thread %s is trying",
 				pj_thread_this()->obj_name));
 
@@ -1333,16 +1333,16 @@
 	++mutex->nesting_level;
 
-	PJ_LOG(6,(mutex->obj_name, "Mutex acquired by thread %s (level=%d)", 
+	PJ_LOG(6,(mutex->obj_name, "Mutex acquired by thread %s (level=%d)",
 				   pj_thread_this()->obj_name,
 				   mutex->nesting_level));
 #else
-	PJ_LOG(6,(mutex->obj_name, "Mutex acquired by thread %s", 
+	PJ_LOG(6,(mutex->obj_name, "Mutex acquired by thread %s",
 				  pj_thread_this()->obj_name));
 #endif
     } else {
-	PJ_LOG(6,(mutex->obj_name, "Mutex: thread %s's trylock() failed", 
+	PJ_LOG(6,(mutex->obj_name, "Mutex: thread %s's trylock() failed",
 				    pj_thread_this()->obj_name));
     }
-    
+
     if (status==0)
 	return PJ_SUCCESS;
@@ -1426,5 +1426,5 @@
 
     PJ_UNUSED_ARG(name);
-    
+
     rwm = PJ_POOL_ALLOC_T(pool, pj_rwmutex_t);
     PJ_ASSERT_RETURN(rwm, PJ_ENOMEM);
@@ -1516,7 +1516,7 @@
  * pj_sem_create()
  */
-PJ_DEF(pj_status_t) pj_sem_create( pj_pool_t *pool, 
+PJ_DEF(pj_status_t) pj_sem_create( pj_pool_t *pool,
 				   const char *name,
-				   unsigned initial, 
+				   unsigned initial,
 				   unsigned max,
 				   pj_sem_t **ptr_sem)
@@ -1537,5 +1537,5 @@
 	pj_str_t nam;
 
-	/* We should use SEM_NAME_LEN, but this doesn't seem to be 
+	/* We should use SEM_NAME_LEN, but this doesn't seem to be
 	 * declared anywhere? The value here is just from trial and error
 	 * to get the longest name supported.
@@ -1554,5 +1554,5 @@
 
 	/* Create semaphore */
-	sem->sem = sem_open(sem_name, O_CREAT|O_EXCL, S_IRUSR|S_IWUSR, 
+	sem->sem = sem_open(sem_name, O_CREAT|O_EXCL, S_IRUSR|S_IWUSR,
 			    initial);
 	if (sem->sem == SEM_FAILED)
@@ -1564,8 +1564,8 @@
 #else
     sem->sem = PJ_POOL_ALLOC_T(pool, sem_t);
-    if (sem_init( sem->sem, 0, initial) != 0) 
+    if (sem_init( sem->sem, 0, initial) != 0)
 	return PJ_RETURN_OS_ERROR(pj_get_native_os_error());
 #endif
-    
+
     /* Set name. */
     if (!name) {
@@ -1600,14 +1600,14 @@
     PJ_ASSERT_RETURN(sem, PJ_EINVAL);
 
-    PJ_LOG(6, (sem->obj_name, "Semaphore: thread %s is waiting", 
+    PJ_LOG(6, (sem->obj_name, "Semaphore: thread %s is waiting",
 			      pj_thread_this()->obj_name));
 
     result = sem_wait( sem->sem );
-    
+
     if (result == 0) {
-	PJ_LOG(6, (sem->obj_name, "Semaphore acquired by thread %s", 
+	PJ_LOG(6, (sem->obj_name, "Semaphore acquired by thread %s",
 				  pj_thread_this()->obj_name));
     } else {
-	PJ_LOG(6, (sem->obj_name, "Semaphore: thread %s FAILED to acquire", 
+	PJ_LOG(6, (sem->obj_name, "Semaphore: thread %s FAILED to acquire",
 				  pj_thread_this()->obj_name));
     }
@@ -1635,9 +1635,9 @@
 
     result = sem_trywait( sem->sem );
-    
+
     if (result == 0) {
-	PJ_LOG(6, (sem->obj_name, "Semaphore acquired by thread %s", 
+	PJ_LOG(6, (sem->obj_name, "Semaphore acquired by thread %s",
 				  pj_thread_this()->obj_name));
-    } 
+    }
     if (result == 0)
 	return PJ_SUCCESS;
