Index: /pjproject/branches/symbian/pjlib/build/os-symbian.mak
===================================================================
--- /pjproject/branches/symbian/pjlib/build/os-symbian.mak	(revision 685)
+++ /pjproject/branches/symbian/pjlib/build/os-symbian.mak	(revision 686)
@@ -8,10 +8,12 @@
 # to all operating systems should go in Makefile instead.
 #
-export PJLIB_OBJS += addr_resolv_sock.o file_access_unistd.o \
+export PJLIB_OBJS += 	addr_resolv_sock.o file_access_unistd.o \
 			file_io_ansi.o guid_simple.o \
 			log_writer_stdout.o os_core_symbian.o \
 			os_error_unix.o os_time_unix.o \
 			os_timestamp_common.o os_timestamp_posix.o \
-			pool_policy_malloc.o compat/string.o sock_bsd.o sock_select.o 
+			pool_policy_malloc.o compat/string.o sock_bsd.o
+export PJLIB_OBJS += 	sock_select_symbian.o ioqueue_symbian.o
+
 
 #
@@ -31,5 +33,5 @@
 #
 #-L"C:\project\symbian\pjlib\lib" -
-export TEST_LDFLAGS +=  -leexe.lib -leuser.lib -L. -lpj-symbian.lib
+export TEST_LDFLAGS +=  -leexe.lib -leuser.lib -L..\ -lpj-symbian.lib
 
 #
Index: /pjproject/branches/symbian/pjlib/build/pjlib.dsp
===================================================================
--- /pjproject/branches/symbian/pjlib/build/pjlib.dsp	(revision 685)
+++ /pjproject/branches/symbian/pjlib/build/pjlib.dsp	(revision 686)
@@ -121,4 +121,9 @@
 # Begin Source File
 
+SOURCE=..\src\pj\os_core_symbian.cpp
+# PROP Exclude_From_Build 1
+# End Source File
+# Begin Source File
+
 SOURCE=..\src\pj\os_core_unix.c
 # PROP Exclude_From_Build 1
@@ -234,11 +239,4 @@
 
 SOURCE=..\src\pj\ioqueue_select.c
-
-!IF  "$(CFG)" == "pjlib - Win32 Release"
-
-!ELSEIF  "$(CFG)" == "pjlib - Win32 Debug"
-
-!ENDIF 
-
 # End Source File
 # Begin Source File
@@ -397,4 +395,8 @@
 
 SOURCE=..\include\pj\compat\os_sunos.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\include\pj\compat\os_symbian.h
 # End Source File
 # Begin Source File
Index: /pjproject/branches/symbian/pjlib/src/pj/ioqueue_symbian.cpp
===================================================================
--- /pjproject/branches/symbian/pjlib/src/pj/ioqueue_symbian.cpp	(revision 686)
+++ /pjproject/branches/symbian/pjlib/src/pj/ioqueue_symbian.cpp	(revision 686)
@@ -0,0 +1,29 @@
+/* $Id$ */
+/* 
+ * Copyright (C)2003-2006 Benny Prijono <benny@prijono.org>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * 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 
+ */
+#include <pj/ioqueue.h>
+
+
+/*
+ * Return the name of the ioqueue implementation.
+ */
+PJ_DEF(const char*) pj_ioqueue_name(void)
+{
+    return "symbian";
+}
+
Index: /pjproject/branches/symbian/pjlib/src/pj/os_core_symbian.cpp
===================================================================
--- /pjproject/branches/symbian/pjlib/src/pj/os_core_symbian.cpp	(revision 685)
+++ /pjproject/branches/symbian/pjlib/src/pj/os_core_symbian.cpp	(revision 686)
@@ -1,3 +1,3 @@
-/* $Id: os_core_unix.c 433 2006-05-10 19:24:40Z bennylp $ */
+/* $Id$ */
 /* 
  * Copyright (C)2003-2006 Benny Prijono <benny@prijono.org>
@@ -18,5 +18,4 @@
  */
 
-//Auto-generated file. Please do not modify.
 #include <e32cmn.h>
 #pragma data_seg(".SYMBIAN")
@@ -45,16 +44,28 @@
 
 
+#define PJ_MAX_TLS  32
+
+
 struct pj_thread_t
 {
-    char	obj_name[PJ_MAX_OBJ_NAME];
-    RThread    thread;
+    char	    obj_name[PJ_MAX_OBJ_NAME];
+    RThread	   *thread;
     pj_thread_proc *proc;
     void	   *arg;
-	
+    unsigned	    flags;
+    void	   *tls_values[PJ_MAX_TLS];
 };
 
-/*
-    TODO: implement these stub methods!
-*/
+
+/* Flags to indicate which TLS variables have been used */
+static int tls_vars[PJ_MAX_TLS];
+
+
+
+PJ_DEF(pj_uint32_t) pj_getpid(void)
+{
+    return 0;
+}
+
 
 /*
@@ -67,4 +78,5 @@
   return PJ_SUCCESS;
 }
+
 
 /*
@@ -73,9 +85,15 @@
  * This is the main entry for all threads.
  */
-TInt thread_main(TAny *param)
+static TInt thread_main(TAny *param)
 {
     pj_thread_t *rec = (pj_thread_t *) param;
     TInt result;
-    /* pj_status_t rc; */
+
+    /* Save thread record to Symbian TLS */
+    Dll::SetTls(rec);
+
+    /* Suspend thread if PJ_THREAD_SUSPENDED is specified */
+    if (rec->flags & PJ_THREAD_SUSPENDED)
+	rec->thread->Suspend();
 
     PJ_LOG(6,(rec->obj_name, "Thread started"));
@@ -102,4 +120,5 @@
 {
     pj_thread_t *rec;
+    void *p;
     int rc;
 
@@ -122,10 +141,15 @@
     }
 
+    /* Create Symbian RThread object */
+    p = pj_pool_alloc(pool, sizeof(RThread));
+    rec->thread = new (p) RThread;
 
     /* Create the thread. */
     rec->proc = proc;
     rec->arg = arg;
+    rec->flags = flags;
     _LIT( KThreadName, "Athread");
-    rc = rec->thread.Create(KThreadName, thread_main, 4096, KMinHeapSize, 256*16, rec->arg, EOwnerThread);
+    rc = rec->thread->Create(KThreadName, &thread_main, stack_size, 
+			     KMinHeapSize, KMinHeapSize, rec);
     if (rc != 0) {
 	return PJ_RETURN_OS_ERROR(rc);
@@ -143,7 +167,5 @@
 PJ_DEF(const char*) pj_thread_get_name(pj_thread_t *p)
 {
-    pj_thread_t *rec = (pj_thread_t*)p;
-
-    return rec->obj_name;
+    return p->obj_name;
 }
 
@@ -153,13 +175,6 @@
 PJ_DEF(pj_status_t) pj_thread_resume(pj_thread_t *p)
 {
-    pj_status_t rc;
-
-    pj_thread_t *rec = (pj_thread_t*)p;
-
-    rec->thread.Resume();
-
-    rc = PJ_SUCCESS;
-
-    return rc;
+    p->thread->Resume();
+    return PJ_SUCCESS;
 }
 
@@ -169,6 +184,5 @@
 PJ_DEF(pj_thread_t*) pj_thread_this(void)
 {
-    // TODO
-    return NULL;
+    return (pj_thread_t*)Dll::Tls();
 }
 
@@ -176,12 +190,11 @@
  * pj_thread_join()
  */
-PJ_DEF(pj_status_t) pj_thread_join(pj_thread_t *p)
-{
-    pj_thread_t *rec = (pj_thread_t *)p;
+PJ_DEF(pj_status_t) pj_thread_join(pj_thread_t *rec)
+{
     TRequestStatus result;
 
-    //PJ_LOG(6, (pj_thread_this()->obj_name, "Joining thread %s", p->obj_name));
-
-    rec->thread.Rendezvous(result);
+    PJ_LOG(6, (rec->obj_name, "Joining thread %s", rec->obj_name));
+
+    rec->thread->Rendezvous(result);
 
     return PJ_SUCCESS;
@@ -191,10 +204,7 @@
  * pj_thread_destroy()
  */
-PJ_DEF(pj_status_t) pj_thread_destroy(pj_thread_t *p)
-{
-    pj_thread_t *rec = (pj_thread_t *)p;
-    rec->thread.Kill(1);
-	
-
+PJ_DEF(pj_status_t) pj_thread_destroy(pj_thread_t *rec)
+{
+    rec->thread->Kill(1);
     return PJ_SUCCESS;
 }
@@ -205,4 +215,6 @@
 PJ_DEF(pj_status_t) pj_thread_sleep(unsigned msec)
 {
+    PJ_TODO(MSEC_RESOLUTION_SLEEP);
+
     if (sleep(msec * 1000) == 0)
 	return PJ_SUCCESS;
@@ -219,4 +231,18 @@
 PJ_DEF(pj_status_t) pj_thread_local_alloc(long *index)
 {
+    unsigned i;
+
+    /* Find unused TLS variable */
+    for (i=0; i<PJ_ARRAY_SIZE(tls_vars); ++i) {
+	if (tls_vars[i] == 0)
+	    break;
+    }
+
+    if (i == PJ_ARRAY_SIZE(tls_vars))
+	return PJ_ETOOMANY;
+
+    tls_vars[i] = 1;
+    *index = i;
+
     return PJ_SUCCESS;
 }
@@ -227,9 +253,10 @@
 PJ_DEF(void) pj_thread_local_free(long index)
 {
-}
-
-class foodata
-{
-};
+    PJ_ASSERT_ON_FAIL(index >= 0 && index < PJ_ARRAY_SIZE(tls_vars) &&
+		     tls_vars[index] != 0, return);
+
+    tls_vars[index] = 0;
+}
+
 
 /*
@@ -238,4 +265,10 @@
 PJ_DEF(pj_status_t) pj_thread_local_set(long index, void *value)
 {
+    pj_thread_t *rec = pj_thread_this();
+
+    PJ_ASSERT_RETURN(index >= 0 && index < PJ_ARRAY_SIZE(tls_vars) &&
+		     tls_vars[index] != 0, PJ_EINVAL);
+
+    rec->tls_values[index] = value;
     return PJ_SUCCESS;
 }
@@ -246,7 +279,22 @@
 PJ_DEF(void*) pj_thread_local_get(long index)
 {
-    return NULL; //Dll::Tls();
-}
-
+    pj_thread_t *rec = pj_thread_this();
+
+    PJ_ASSERT_RETURN(index >= 0 && index < PJ_ARRAY_SIZE(tls_vars) &&
+		     tls_vars[index] != 0, NULL);
+
+    return rec->tls_values[index];
+}
+
+
+PJ_DEF(pj_status_t) pj_mutex_create( pj_pool_t *pool, 
+                                     const char *name,
+				     int type, 
+                                     pj_mutex_t **mutex)
+{
+    PJ_TODO(pj_mutex_create);
+    *mutex = (pj_mutex_t*)1;
+    return PJ_SUCCESS;
+}
 
 /*
@@ -257,7 +305,15 @@
 					    pj_mutex_t **mutex )
 {
-    (*mutex) = (pj_mutex_t *)1;
-    return PJ_SUCCESS;
-}
+    return pj_mutex_create(pool, name, PJ_MUTEX_SIMPLE, mutex);
+}
+
+
+PJ_DEF(pj_status_t) pj_mutex_create_recursive( pj_pool_t *pool,
+					       const char *name,
+					       pj_mutex_t **mutex )
+{
+    return pj_mutex_create(pool, name, PJ_MUTEX_RECURSE, mutex);
+}
+
 
 /*
@@ -266,4 +322,5 @@
 PJ_DEF(pj_status_t) pj_mutex_lock(pj_mutex_t *mutex)
 {
+    PJ_TODO(pj_mutex_lock);
     return PJ_SUCCESS;
 }
@@ -274,4 +331,5 @@
 PJ_DEF(pj_status_t) pj_mutex_trylock(pj_mutex_t *mutex)
 {
+    PJ_TODO(pj_mutex_trylock);
     return PJ_SUCCESS;
 }
@@ -282,4 +340,5 @@
 PJ_DEF(pj_status_t) pj_mutex_unlock(pj_mutex_t *mutex)
 {
+    PJ_TODO(pj_mutex_unlock);
     return PJ_SUCCESS;
 }
@@ -290,4 +349,28 @@
 PJ_DEF(pj_status_t) pj_mutex_destroy(pj_mutex_t *mutex)
 {
-    return PJ_SUCCESS;
-}
+    PJ_TODO(pj_mutex_destroy);
+    return PJ_SUCCESS;
+}
+
+/////////////////////////////////////////////////////////////////////////////
+
+/*
+ * Enter critical section.
+ */
+PJ_DEF(void) pj_enter_critical_section(void)
+{
+    PJ_TODO(pj_enter_critical_section);
+}
+
+
+/*
+ * Leave critical section.
+ */
+PJ_DEF(void) pj_leave_critical_section(void)
+{
+    PJ_TODO(pj_leave_critical_section);
+}
+
+
+
+
Index: /pjproject/branches/symbian/pjlib/src/pj/sock_select_symbian.cpp
===================================================================
--- /pjproject/branches/symbian/pjlib/src/pj/sock_select_symbian.cpp	(revision 686)
+++ /pjproject/branches/symbian/pjlib/src/pj/sock_select_symbian.cpp	(revision 686)
@@ -0,0 +1,61 @@
+/* $Id$ */
+/* 
+ * Copyright (C)2003-2006 Benny Prijono <benny@prijono.org>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * 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 
+ */
+#include <pj/sock_select.h>
+
+
+PJ_DEF(void) PJ_FD_ZERO(pj_fd_set_t *fdsetp)
+{
+    PJ_TODO(PJ_FD_ZERO);
+}
+
+
+PJ_DEF(void) PJ_FD_SET(pj_sock_t fd, pj_fd_set_t *fdsetp)
+{
+    PJ_TODO(PJ_FD_SET);
+}
+
+
+PJ_DEF(void) PJ_FD_CLR(pj_sock_t fd, pj_fd_set_t *fdsetp)
+{
+    PJ_TODO(PJ_FD_CLR);
+}
+
+
+PJ_DEF(pj_bool_t) PJ_FD_ISSET(pj_sock_t fd, const pj_fd_set_t *fdsetp)
+{
+    PJ_TODO(PJ_FD_ISSET);
+    return 0;
+}
+
+PJ_DEF(pj_size_t) PJ_FD_COUNT(const pj_fd_set_t *fdsetp)
+{
+    PJ_TODO(PJ_FD_COUNT);
+    return 0;
+}
+
+PJ_DEF(int) pj_sock_select( int n, 
+			    pj_fd_set_t *readfds, 
+			    pj_fd_set_t *writefds,
+			    pj_fd_set_t *exceptfds, 
+			    const pj_time_val *timeout)
+{
+    PJ_TODO(pj_sock_select);
+    return 0;
+}
+
