Index: pjproject/branches/projects/winphone/pjlib/include/pj/compat/os_winphone.h
===================================================================
--- pjproject/branches/projects/winphone/pjlib/include/pj/compat/os_winphone.h	(revision 4776)
+++ pjproject/branches/projects/winphone/pjlib/include/pj/compat/os_winphone.h	(revision 4777)
@@ -22,6 +22,6 @@
 
 /**
- * @file os_win32.h
- * @brief Describes Win32 operating system family specifics.
+ * @file os_winphone.h
+ * @brief Describes Windows Phone operating system family specifics.
  */
 
@@ -146,302 +146,4 @@
 
 
-#endif	/* __PJ_COMPAT_OS_WIN32_WINCE_H__ */
+#endif	/* __PJ_COMPAT_OS_WIN32_WINPHONE_H__ */
 
-/* $Id$ */
-/* 
- * Copyright (C) 2008-2011 Teluu Inc. (http://www.teluu.com)
- * Copyright (C) 2003-2008 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 
- */
-#ifndef __PJ_COMPAT_OS_WINPHONE_H__
-#define __PJ_COMPAT_OS_WIN32_WINPHONE_H__
-
-/**
- * @file os_win32.h
- * @brief Describes Win32 operating system family specifics.
- */
-
-#define PJ_OS_NAME		    "winphone"
-
-#define WIN32_LEAN_AND_MEAN
-#define RPC_NO_WINDOWS_H
-#define PJ_WIN32_WINNT		    0x0602 /*_WIN32_WINNT_WIN8*/
-#ifdef _WIN32_WINNT
-#undef _WIN32_WINNT
-#define _WIN32_WINNT		    PJ_WIN32_WINNT
-#endif
-
-#define PJ_HAS_ARPA_INET_H	    0
-#define PJ_HAS_ASSERT_H		    1
-#define PJ_HAS_CTYPE_H		    1
-#define PJ_HAS_ERRNO_H		    0   /* Must be zero, otherwise errno_test() fails. */
-#define PJ_HAS_LINUX_SOCKET_H	    0
-#define PJ_HAS_MALLOC_H		    1
-#define PJ_HAS_NETDB_H		    0
-#define PJ_HAS_NETINET_IN_H	    0
-#define PJ_HAS_NETINET_TCP_H	    0
-#define PJ_HAS_SETJMP_H		    1
-#define PJ_HAS_STDARG_H		    1
-#define PJ_HAS_STDDEF_H		    1
-#define PJ_HAS_STDIO_H		    1
-#define PJ_HAS_STDLIB_H		    1
-#define PJ_HAS_STRING_H		    1
-#define PJ_HAS_SYS_IOCTL_H	    0
-#define PJ_HAS_SYS_SELECT_H	    0
-#define PJ_HAS_SYS_SOCKET_H	    0
-#define PJ_HAS_SYS_TIME_H	    0
-#define PJ_HAS_SYS_TIMEB_H	    0	/* Doesn't have sys/timeb.h */
-#define PJ_HAS_SYS_TYPES_H	    0	/* Doesn't have sys/types.h */
-#define PJ_HAS_TIME_H		    1
-#define PJ_HAS_UNISTD_H		    0
-
-#define PJ_HAS_MSWSOCK_H	    1
-#define PJ_HAS_WINSOCK_H	    0
-#define PJ_HAS_WINSOCK2_H	    1
-
-#define PJ_SOCK_HAS_INET_ATON	    0
-
-/* Set 1 if native sockaddr_in has sin_len member. 
- * Default: 0
- */
-#define PJ_SOCKADDR_HAS_LEN	    0
-
-/* Is errno a good way to retrieve OS errors? (no)
- */
-#define PJ_HAS_ERRNO_VAR	    0
-
-/* When this macro is set, getsockopt(SOL_SOCKET, SO_ERROR) will return
- * the status of non-blocking connect() operation.
- */
-#define PJ_HAS_SO_ERROR             0
-
-/* This value specifies the value set in errno by the OS when a non-blocking
- * socket recv() or send() can not return immediately.
- */
-#define PJ_BLOCKING_ERROR_VAL       WSAEWOULDBLOCK
-
-/* This value specifies the value set in errno by the OS when a non-blocking
- * socket connect() can not get connected immediately.
- */
-#define PJ_BLOCKING_CONNECT_ERROR_VAL   WSAEWOULDBLOCK
-
-/**
- * If this macro is set, it tells select I/O Queue that select() needs to
- * be given correct value of nfds (i.e. largest fd + 1). This requires
- * select ioqueue to re-scan the descriptors on each registration and
- * unregistration.
- * If this macro is not set, then ioqueue will always give FD_SETSIZE for
- * nfds argument when calling select().
- *
- * Default: 0
- */
-#define PJ_SELECT_NEEDS_NFDS	    0
-
-/* Endianness */
-#ifndef PJ_IS_LITTLE_ENDIAN
-#   define PJ_IS_LITTLE_ENDIAN	1
-#   define PJ_IS_BIG_ENDIAN	0
-#endif
-
-/* Default threading is enabled, unless it's overridden. */
-#ifndef PJ_HAS_THREADS
-#  define PJ_HAS_THREADS	    (1)
-#endif
-
-#define PJ_HAS_HIGH_RES_TIMER	    1
-#define PJ_HAS_MALLOC               1
-#define PJ_OS_HAS_CHECK_STACK	    1
-
-#define PJ_ATOMIC_VALUE_TYPE	    long
-
-/* No console. */
-#define PJ_TERM_HAS_COLOR	    0
-
-/* TlsAlloc() error value. */
-#define TLS_OUT_OF_INDEXES	    0xFFFFFFFF
-
-/* No rdtsc */
-#define PJ_TIMESTAMP_USE_RDTSC	    0
-
-/* Native string is Unicode. */
-#define PJ_NATIVE_STRING_IS_UNICODE 1
-
-/* If 1, use Read/Write mutex emulation for platforms that don't support it */
-#define PJ_EMULATE_RWMUTEX	    1
-
-/* If 1, pj_thread_create() should enforce the stack size when creating 
- * threads.
- * Default: 0 (let OS decide the thread's stack size).
- */
-#define PJ_THREAD_SET_STACK_SIZE    	0
-
-/* If 1, pj_thread_create() should allocate stack from the pool supplied.
- * Default: 0 (let OS allocate memory for thread's stack).
- */
-#define PJ_THREAD_ALLOCATE_STACK    	0
-
-
-#endif	/* __PJ_COMPAT_OS_WIN32_WINCE_H__ */
-
-/* $Id$ */
-/* 
- * Copyright (C) 2008-2011 Teluu Inc. (http://www.teluu.com)
- * Copyright (C) 2003-2008 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 
- */
-#ifndef __PJ_COMPAT_OS_WINPHONE_H__
-#define __PJ_COMPAT_OS_WIN32_WINPHONE_H__
-
-/**
- * @file os_win32.h
- * @brief Describes Win32 operating system family specifics.
- */
-
-#define PJ_OS_NAME		    "winphone"
-
-#define WIN32_LEAN_AND_MEAN
-#define RPC_NO_WINDOWS_H
-#define PJ_WIN32_WINNT		    0x0602 /*_WIN32_WINNT_WIN8*/
-#ifdef _WIN32_WINNT
-#undef _WIN32_WINNT
-#define _WIN32_WINNT		    PJ_WIN32_WINNT
-#endif
-
-#define PJ_HAS_ARPA_INET_H	    0
-#define PJ_HAS_ASSERT_H		    1
-#define PJ_HAS_CTYPE_H		    1
-#define PJ_HAS_ERRNO_H		    0   /* Must be zero, otherwise errno_test() fails. */
-#define PJ_HAS_LINUX_SOCKET_H	    0
-#define PJ_HAS_MALLOC_H		    1
-#define PJ_HAS_NETDB_H		    0
-#define PJ_HAS_NETINET_IN_H	    0
-#define PJ_HAS_NETINET_TCP_H	    0
-#define PJ_HAS_SETJMP_H		    1
-#define PJ_HAS_STDARG_H		    1
-#define PJ_HAS_STDDEF_H		    1
-#define PJ_HAS_STDIO_H		    1
-#define PJ_HAS_STDLIB_H		    1
-#define PJ_HAS_STRING_H		    1
-#define PJ_HAS_SYS_IOCTL_H	    0
-#define PJ_HAS_SYS_SELECT_H	    0
-#define PJ_HAS_SYS_SOCKET_H	    0
-#define PJ_HAS_SYS_TIME_H	    0
-#define PJ_HAS_SYS_TIMEB_H	    0	/* Doesn't have sys/timeb.h */
-#define PJ_HAS_SYS_TYPES_H	    0	/* Doesn't have sys/types.h */
-#define PJ_HAS_TIME_H		    1
-#define PJ_HAS_UNISTD_H		    0
-
-#define PJ_HAS_MSWSOCK_H	    1
-#define PJ_HAS_WINSOCK_H	    0
-#define PJ_HAS_WINSOCK2_H	    1
-
-#define PJ_SOCK_HAS_INET_ATON	    0
-
-/* Set 1 if native sockaddr_in has sin_len member. 
- * Default: 0
- */
-#define PJ_SOCKADDR_HAS_LEN	    0
-
-/* Is errno a good way to retrieve OS errors? (no)
- */
-#define PJ_HAS_ERRNO_VAR	    0
-
-/* When this macro is set, getsockopt(SOL_SOCKET, SO_ERROR) will return
- * the status of non-blocking connect() operation.
- */
-#define PJ_HAS_SO_ERROR             0
-
-/* This value specifies the value set in errno by the OS when a non-blocking
- * socket recv() or send() can not return immediately.
- */
-#define PJ_BLOCKING_ERROR_VAL       WSAEWOULDBLOCK
-
-/* This value specifies the value set in errno by the OS when a non-blocking
- * socket connect() can not get connected immediately.
- */
-#define PJ_BLOCKING_CONNECT_ERROR_VAL   WSAEWOULDBLOCK
-
-/**
- * If this macro is set, it tells select I/O Queue that select() needs to
- * be given correct value of nfds (i.e. largest fd + 1). This requires
- * select ioqueue to re-scan the descriptors on each registration and
- * unregistration.
- * If this macro is not set, then ioqueue will always give FD_SETSIZE for
- * nfds argument when calling select().
- *
- * Default: 0
- */
-#define PJ_SELECT_NEEDS_NFDS	    0
-
-/* Endianness */
-#ifndef PJ_IS_LITTLE_ENDIAN
-#   define PJ_IS_LITTLE_ENDIAN	1
-#   define PJ_IS_BIG_ENDIAN	0
-#endif
-
-/* Default threading is enabled, unless it's overridden. */
-#ifndef PJ_HAS_THREADS
-#  define PJ_HAS_THREADS	    (1)
-#endif
-
-#define PJ_HAS_HIGH_RES_TIMER	    1
-#define PJ_HAS_MALLOC               1
-#define PJ_OS_HAS_CHECK_STACK	    1
-
-#define PJ_ATOMIC_VALUE_TYPE	    long
-
-/* No console. */
-#define PJ_TERM_HAS_COLOR	    0
-
-/* TlsAlloc() error value. */
-#define TLS_OUT_OF_INDEXES	    0xFFFFFFFF
-
-/* No rdtsc */
-#define PJ_TIMESTAMP_USE_RDTSC	    0
-
-/* Native string is Unicode. */
-#define PJ_NATIVE_STRING_IS_UNICODE 1
-
-/* If 1, use Read/Write mutex emulation for platforms that don't support it */
-#define PJ_EMULATE_RWMUTEX	    1
-
-/* If 1, pj_thread_create() should enforce the stack size when creating 
- * threads.
- * Default: 0 (let OS decide the thread's stack size).
- */
-#define PJ_THREAD_SET_STACK_SIZE    	0
-
-/* If 1, pj_thread_create() should allocate stack from the pool supplied.
- * Default: 0 (let OS allocate memory for thread's stack).
- */
-#define PJ_THREAD_ALLOCATE_STACK    	0
-
-
-#endif	/* __PJ_COMPAT_OS_WIN32_WINCE_H__ */
-
Index: pjproject/branches/projects/winphone/pjlib/src/pj/file_access_win32.c
===================================================================
--- pjproject/branches/projects/winphone/pjlib/src/pj/file_access_win32.c	(revision 4776)
+++ pjproject/branches/projects/winphone/pjlib/src/pj/file_access_win32.c	(revision 4777)
@@ -36,11 +36,11 @@
 static pj_status_t get_file_size(HANDLE hFile, pj_off_t *size)
 {
-#ifdef PJ_WIN32_WINPHONE  
-    FILE_STANDARD_INFO fileInfo;
-
-    if (GetFileInformationByHandleEx(hFile, FileStandardInfo, &fileInfo,
-				     sizeof(FILE_STANDARD_INFO))) 
+#if defined(PJ_WIN32_WINPHONE) && PJ_WIN32_WINPHONE  
+    FILE_COMPRESSION_INFO fileInfo;
+
+    if (GetFileInformationByHandleEx(hFile, FileCompressionInfo, &fileInfo,
+				     sizeof(FILE_COMPRESSION_INFO))) 
     {
-	*size = fileInfo.AllocationSize.QuadPart;	
+	*size = fileInfo.CompressedFileSize.QuadPart;	
     } else {	
 	*size = -1;
@@ -71,5 +71,5 @@
 				 HANDLE template_file)
 {
-#ifdef PJ_WIN32_WINPHONE
+#if defined(PJ_WIN32_WINPHONE) && PJ_WIN32_WINPHONE
     PJ_UNUSED_ARG(security_attributes);
     PJ_UNUSED_ARG(flags_and_attributes);
@@ -216,5 +216,5 @@
     HANDLE hFile;
     FILETIME creationTime, accessTime, writeTime;
-#ifdef PJ_WIN32_WINPHONE
+#if defined(PJ_WIN32_WINPHONE) && PJ_WIN32_WINPHONE
     FILE_BASIC_INFO fileInfo;
 #endif
@@ -234,5 +234,5 @@
 	return PJ_RETURN_OS_ERROR(GetLastError());
     }
-#ifdef PJ_WIN32_WINPHONE
+#if defined(PJ_WIN32_WINPHONE) && PJ_WIN32_WINPHONE
     if (GetFileInformationByHandleEx(hFile, FileBasicInfo, &fileInfo,
 				     sizeof(FILE_BASIC_INFO))) 
Index: pjproject/branches/projects/winphone/pjlib/src/pj/file_io_win32.c
===================================================================
--- pjproject/branches/projects/winphone/pjlib/src/pj/file_io_win32.c	(revision 4776)
+++ pjproject/branches/projects/winphone/pjlib/src/pj/file_io_win32.c	(revision 4777)
@@ -89,5 +89,5 @@
     dwFlagsAndAttributes = FILE_ATTRIBUTE_NORMAL;
 
-#ifdef PJ_WIN32_WINPHONE  
+#if defined(PJ_WIN32_WINPHONE) && PJ_WIN32_WINPHONE  
     hFile = CreateFile2(PJ_STRING_TO_NATIVE(pathname,
 					    wpathname,sizeof(wpathname)), 
@@ -190,5 +190,5 @@
 				    DWORD dwMoveMethod)
 {
-#ifdef PJ_WIN32_WINPHONE
+#if defined(PJ_WIN32_WINPHONE) && PJ_WIN32_WINPHONE
     LARGE_INTEGER liDistance, liNewPos;    
 
Index: pjproject/branches/projects/winphone/pjlib/src/pj/ioqueue_select.c
===================================================================
--- pjproject/branches/projects/winphone/pjlib/src/pj/ioqueue_select.c	(revision 4776)
+++ pjproject/branches/projects/winphone/pjlib/src/pj/ioqueue_select.c	(revision 4777)
@@ -880,6 +880,18 @@
     pj_lock_release(ioqueue->lock);
 
+#if defined(PJ_WIN32_WINPHONE) && PJ_WIN32_WINPHONE
+    count = 0;
+    __try {    
+#endif
+
     count = pj_sock_select(ioqueue->nfds+1, &rfdset, &wfdset, &xfdset, 
 			   timeout);
+
+#if defined(PJ_WIN32_WINPHONE) && PJ_WIN32_WINPHONE
+    /* Ignore Invalid Handle Exception raised by select().*/
+    } __except(GetExceptionCode() == STATUS_INVALID_HANDLE?
+	       EXCEPTION_CONTINUE_EXECUTION:EXCEPTION_CONTINUE_SEARCH) {
+    }
+#endif
     
     if (count == 0)
Index: pjproject/branches/projects/winphone/pjlib/src/pj/os_core_win32.c
===================================================================
--- pjproject/branches/projects/winphone/pjlib/src/pj/os_core_win32.c	(revision 4776)
+++ pjproject/branches/projects/winphone/pjlib/src/pj/os_core_win32.c	(revision 4777)
@@ -39,6 +39,6 @@
 #endif
 
-#if PJ_WIN32_WINPHONE
-#   include "../../third_party/threademulation/include/ThreadEmulation.h"
+#if defined(PJ_WIN32_WINPHONE) && PJ_WIN32_WINPHONE
+#   include "../../../third_party/threademulation/include/ThreadEmulation.h"
 #endif
 
@@ -306,5 +306,5 @@
 PJ_DEF(int) pj_thread_get_prio(pj_thread_t *thread)
 {
-#if PJ_WIN32_WINPHONE
+#if defined(PJ_WIN32_WINPHONE) && PJ_WIN32_WINPHONE
     PJ_UNUSED_ARG(thread);
     return -1;
@@ -326,5 +326,9 @@
 		     PJ_EINVAL);
 
+#if defined(PJ_WIN32_WINPHONE) && PJ_WIN32_WINPHONE
+    if (SetThreadPriorityRT(thread->hthread, prio) == FALSE)
+#else
     if (SetThreadPriority(thread->hthread, prio) == FALSE)
+#endif
 	return PJ_RETURN_OS_ERROR(GetLastError());
 
@@ -487,4 +491,8 @@
     pj_thread_t *rec;
 
+#if defined(PJ_WIN32_WINPHONE) && PJ_WIN32_WINPHONE
+    PJ_UNUSED_ARG(stack_size);
+#endif
+
     PJ_CHECK_STACK();
     PJ_ASSERT_RETURN(pool && proc && thread_ptr, PJ_EINVAL);
@@ -521,8 +529,8 @@
     rec->arg = arg;
 
-#ifdef PJ_WIN32_WINPHONE
-    rec->hthread = CreateThread(NULL, stack_size, 
-				thread_main, rec,
-				dwflags, NULL);
+#if defined(PJ_WIN32_WINPHONE) && PJ_WIN32_WINPHONE
+    rec->hthread = CreateThreadRT(NULL, 0, 
+				  thread_main, rec,
+				  dwflags, NULL);
 #else
     rec->hthread = CreateThread(NULL, stack_size, 
@@ -562,5 +570,9 @@
     PJ_ASSERT_RETURN(p, PJ_EINVAL);
 
+#if defined(PJ_WIN32_WINPHONE) && PJ_WIN32_WINPHONE
+    if (ResumeThreadRT(rec->hthread) == (DWORD)-1)
+#else
     if (ResumeThread(rec->hthread) == (DWORD)-1)
+#endif
         return PJ_RETURN_OS_ERROR(GetLastError());
     else
@@ -606,5 +618,5 @@
     PJ_LOG(6, (pj_thread_this()->obj_name, "Joining thread %s", p->obj_name));
 
-#if PJ_WIN32_WINPHONE
+#if defined(PJ_WIN32_WINPHONE) && PJ_WIN32_WINPHONE
     rc = WaitForSingleObjectEx(rec->hthread, INFINITE, FALSE);
 #else
@@ -642,5 +654,9 @@
 {
     PJ_CHECK_STACK();
+#if defined(PJ_WIN32_WINPHONE) && PJ_WIN32_WINPHONE
+    SleepRT(msec);
+#else
     Sleep(msec);
+#endif
     return PJ_SUCCESS;
 }
@@ -836,5 +852,9 @@
     //PJ_CHECK_STACK();
 
+#if defined(PJ_WIN32_WINPHONE) && PJ_WIN32_WINPHONE
+    *index = TlsAllocRT();
+#else
     *index = TlsAlloc();
+#endif
 
     if (*index == TLS_OUT_OF_INDEXES)
@@ -850,5 +870,9 @@
 {
     PJ_CHECK_STACK();
+#if defined(PJ_WIN32_WINPHONE) && PJ_WIN32_WINPHONE
+    TlsFreeRT(index);
+#else
     TlsFree(index);
+#endif
 }
 
@@ -863,5 +887,9 @@
     //beginning before main thread is initialized.
     //PJ_CHECK_STACK();
+#if defined(PJ_WIN32_WINPHONE) && PJ_WIN32_WINPHONE
+    rc = TlsSetValueRT(index, value);
+#else
     rc = TlsSetValue(index, value);
+#endif
     return rc!=0 ? PJ_SUCCESS : PJ_RETURN_OS_ERROR(GetLastError());
 }
@@ -875,5 +903,9 @@
     //by PJ_CHECK_STACK() itself!!!
     //PJ_CHECK_STACK();
+#if defined(PJ_WIN32_WINPHONE) && PJ_WIN32_WINPHONE
+    return TlsGetValueRT(index);
+#else
     return TlsGetValue(index);
+#endif
 }
 
@@ -884,5 +916,5 @@
     PJ_CHECK_STACK();
 
-#if PJ_WIN32_WINPHONE
+#if defined(PJ_WIN32_WINPHONE) && PJ_WIN32_WINPHONE
     InitializeCriticalSectionEx(&mutex->crit, 0, 0);
 #elif PJ_WIN32_WINNT >= 0x0400
@@ -1140,5 +1172,5 @@
 
     sem = pj_pool_alloc(pool, sizeof(*sem)); 
-#if PJ_WIN32_WINPHONE
+#if defined(PJ_WIN32_WINPHONE) && PJ_WIN32_WINPHONE
     /** SEMAPHORE_ALL_ACCESS **/
     sem->hSemaphore = CreateSemaphoreEx(NULL, initial, max, NULL, 0, 
@@ -1177,5 +1209,5 @@
 			      pj_thread_this()->obj_name));
 
-#if PJ_WIN32_WINPHONE
+#if defined(PJ_WIN32_WINPHONE) && PJ_WIN32_WINPHONE
     result = WaitForSingleObjectEx(sem->hSemaphore, timeout, FALSE);
 #else
@@ -1279,5 +1311,5 @@
         return PJ_ENOMEM;
 
-#if PJ_WIN32_WINPHONE
+#if defined(PJ_WIN32_WINPHONE) && PJ_WIN32_WINPHONE
     event->hEvent = CreateEventEx(NULL, NULL, 
 				  (manual_reset?0x1:0x0)|(initial?0x2:0x0), 
@@ -1318,5 +1350,5 @@
 			        pj_thread_this()->obj_name));
 
-#if PJ_WIN32_WINPHONE
+#if defined(PJ_WIN32_WINPHONE) && PJ_WIN32_WINPHONE
     result = WaitForSingleObjectEx(event->hEvent, timeout, FALSE);
 #else
@@ -1380,5 +1412,5 @@
 PJ_DEF(pj_status_t) pj_event_pulse(pj_event_t *event)
 {
-#ifdef PJ_WIN32_WINPHONE
+#if defined(PJ_WIN32_WINPHONE) && PJ_WIN32_WINPHONE
     PJ_UNUSED_ARG(event);
     pj_assert(!"pj_event_pulse() not supported!");
Index: pjproject/branches/projects/winphone/pjlib/src/pj/os_info.c
===================================================================
--- pjproject/branches/projects/winphone/pjlib/src/pj/os_info.c	(revision 4776)
+++ pjproject/branches/projects/winphone/pjlib/src/pj/os_info.c	(revision 4777)
@@ -187,5 +187,5 @@
 #elif defined(_MSC_VER)
     {
-	#ifdef PJ_WIN32_WINPHONE
+	#if defined(PJ_WIN32_WINPHONE) && PJ_WIN32_WINPHONE
 	    si.os_name = pj_str("winphone");
 	#else
@@ -210,5 +210,5 @@
 	SYSTEM_INFO wsi;
 
-    #ifdef PJ_WIN32_WINPHONE
+    #if defined(PJ_WIN32_WINPHONE) && PJ_WIN32_WINPHONE
 	GetNativeSystemInfo(&wsi);
     #else
@@ -238,5 +238,5 @@
     #endif	/* PJ_WIN32_WINCE || PJ_WIN32_WINPHONE */
 	}
-    #ifdef PJ_WIN32_WINPHONE
+    #if defined(PJ_WIN32_WINPHONE) && PJ_WIN32_WINPHONE
 	/* Avoid compile warning. */
 	goto get_sdk_info;
Index: pjproject/branches/projects/winphone/third_party/threademulation/include/ThreadEmulation.h
===================================================================
--- pjproject/branches/projects/winphone/third_party/threademulation/include/ThreadEmulation.h	(revision 4776)
+++ pjproject/branches/projects/winphone/third_party/threademulation/include/ThreadEmulation.h	(revision 4777)
@@ -34,7 +34,8 @@
 
 #ifdef __cplusplus
-namespace ThreadEmulation
-{
-    extern "C" {
+//namespace ThreadEmulation
+//{
+extern "C" 
+    {
 #endif
     #ifndef CREATE_SUSPENDED
@@ -42,20 +43,17 @@
     #endif
 
-    HANDLE WINAPI CreateThread(_In_opt_ LPSECURITY_ATTRIBUTES unusedThreadAttributes, _In_ SIZE_T unusedStackSize, _In_ LPTHREAD_START_ROUTINE lpStartAddress, _In_opt_ LPVOID lpParameter, _In_ DWORD dwCreationFlags, _Out_opt_ LPDWORD unusedThreadId);
+    HANDLE WINAPI CreateThreadRT(_In_opt_ LPSECURITY_ATTRIBUTES unusedThreadAttributes, _In_ SIZE_T unusedStackSize, _In_ LPTHREAD_START_ROUTINE lpStartAddress, _In_opt_ LPVOID lpParameter, _In_ DWORD dwCreationFlags, _Out_opt_ LPDWORD unusedThreadId);
+    DWORD WINAPI ResumeThreadRT(_In_ HANDLE hThread);
+    BOOL WINAPI SetThreadPriorityRT(_In_ HANDLE hThread, _In_ int nPriority);
+    
+    VOID WINAPI SleepRT(_In_ DWORD dwMilliseconds);
 
-    DWORD WINAPI ResumeThread(_In_ HANDLE hThread);
-    BOOL WINAPI SetThreadPriority(_In_ HANDLE hThread, _In_ int nPriority);
-    
-    VOID WINAPI Sleep(_In_ DWORD dwMilliseconds);
-
-    DWORD WINAPI TlsAlloc();
-    BOOL WINAPI TlsFree(_In_ DWORD dwTlsIndex);
-    LPVOID WINAPI TlsGetValue(_In_ DWORD dwTlsIndex);
-    BOOL WINAPI TlsSetValue(_In_ DWORD dwTlsIndex, _In_opt_ LPVOID lpTlsValue);
+    DWORD WINAPI TlsAllocRT();
+    BOOL WINAPI TlsFreeRT(_In_ DWORD dwTlsIndex);
+    LPVOID WINAPI TlsGetValueRT(_In_ DWORD dwTlsIndex);
+    BOOL WINAPI TlsSetValueRT(_In_ DWORD dwTlsIndex, _In_opt_ LPVOID lpTlsValue);
     
     void WINAPI TlsShutdown();
-
 #ifdef __cplusplus
     }
-}
 #endif
Index: pjproject/branches/projects/winphone/third_party/threademulation/src/ThreadEmulation.cpp
===================================================================
--- pjproject/branches/projects/winphone/third_party/threademulation/src/ThreadEmulation.cpp	(revision 4776)
+++ pjproject/branches/projects/winphone/third_party/threademulation/src/ThreadEmulation.cpp	(revision 4777)
@@ -6,5 +6,4 @@
 // Copyright (c) Microsoft Corporation. All rights reserved.
 
-//#include "ThreadEmulation.h"
 #include "../include/ThreadEmulation.h"
 
@@ -20,9 +19,6 @@
 using namespace Windows::System::Threading;
 
-
-#ifdef __cplusplus
-namespace ThreadEmulation
-{
-#endif
+//namespace ThreadEmulation
+//{
     // Stored data for CREATE_SUSPENDED and ResumeThread.
     struct PendingThreadInfo
@@ -84,5 +80,6 @@
     }
 
-    _Use_decl_annotations_ HANDLE WINAPI CreateThread(LPSECURITY_ATTRIBUTES unusedThreadAttributes, SIZE_T unusedStackSize, LPTHREAD_START_ROUTINE lpStartAddress, LPVOID lpParameter, DWORD dwCreationFlags, LPDWORD unusedThreadId)
+
+    _Use_decl_annotations_ HANDLE WINAPI CreateThreadRT(LPSECURITY_ATTRIBUTES unusedThreadAttributes, SIZE_T unusedStackSize, LPTHREAD_START_ROUTINE lpStartAddress, LPVOID lpParameter, DWORD dwCreationFlags, LPDWORD unusedThreadId)
     {
         // Validate parameters.
@@ -143,5 +140,6 @@
     }
 
-    _Use_decl_annotations_ DWORD WINAPI ResumeThread(HANDLE hThread)
+
+    _Use_decl_annotations_ DWORD WINAPI ResumeThreadRT(HANDLE hThread)
     {
         lock_guard<mutex> lock(pendingThreadsLock);
@@ -176,5 +174,5 @@
 
 
-    _Use_decl_annotations_ BOOL WINAPI SetThreadPriority(HANDLE hThread, int nPriority)
+    _Use_decl_annotations_ BOOL WINAPI SetThreadPriorityRT(HANDLE hThread, int nPriority)
     {
         lock_guard<mutex> lock(pendingThreadsLock);
@@ -197,5 +195,5 @@
 
 
-    _Use_decl_annotations_ VOID WINAPI Sleep(DWORD dwMilliseconds)
+    _Use_decl_annotations_ VOID WINAPI SleepRT(DWORD dwMilliseconds)
     {
         static HANDLE singletonEvent = nullptr;
@@ -226,5 +224,5 @@
 
 
-    DWORD WINAPI TlsAlloc()
+    DWORD WINAPI TlsAllocRT()
     {
         lock_guard<mutex> lock(tlsAllocationLock);
@@ -243,5 +241,5 @@
 
 
-    _Use_decl_annotations_ BOOL WINAPI TlsFree(DWORD dwTlsIndex)
+    _Use_decl_annotations_ BOOL WINAPI TlsFreeRT(DWORD dwTlsIndex)
     {
         lock_guard<mutex> lock(tlsAllocationLock);
@@ -273,5 +271,5 @@
 
 
-    _Use_decl_annotations_ LPVOID WINAPI TlsGetValue(DWORD dwTlsIndex)
+    _Use_decl_annotations_ LPVOID WINAPI TlsGetValueRT(DWORD dwTlsIndex)
     {
         ThreadLocalData* threadData = currentThreadData;
@@ -290,5 +288,5 @@
 
 
-    _Use_decl_annotations_ BOOL WINAPI TlsSetValue(DWORD dwTlsIndex, LPVOID lpTlsValue)
+    _Use_decl_annotations_ BOOL WINAPI TlsSetValueRT(DWORD dwTlsIndex, LPVOID lpTlsValue)
     {
         ThreadLocalData* threadData = currentThreadData;
@@ -355,5 +353,3 @@
         }
     }
-#ifdef __cplusplus
-}
-#endif
+//}
