Changeset 4777


Ignore:
Timestamp:
Mar 5, 2014 6:48:59 AM (8 years ago)
Author:
riza
Message:

Re #1704:

  • Fix duplicate code on os_winphone.h
  • Change the use of PJ_WIN32_WINPHONE to follow the code convention
  • Fix incorrect link of the Thread library
  • Handle exception raised from select() API. However the break window will still be shown when debugging on Visual Studio. To disable it, from Debug>Exceptions>Win32 Exceptions> unmark the "An invalid handle was specified” exception.
Location:
pjproject/branches/projects/winphone
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • pjproject/branches/projects/winphone/pjlib/include/pj/compat/os_winphone.h

    r4618 r4777  
    2222 
    2323/** 
    24  * @file os_win32.h 
    25  * @brief Describes Win32 operating system family specifics. 
     24 * @file os_winphone.h 
     25 * @brief Describes Windows Phone operating system family specifics. 
    2626 */ 
    2727 
     
    146146 
    147147 
    148 #endif  /* __PJ_COMPAT_OS_WIN32_WINCE_H__ */ 
     148#endif  /* __PJ_COMPAT_OS_WIN32_WINPHONE_H__ */ 
    149149 
    150 /* $Id$ */ 
    151 /*  
    152  * Copyright (C) 2008-2011 Teluu Inc. (http://www.teluu.com) 
    153  * Copyright (C) 2003-2008 Benny Prijono <benny@prijono.org> 
    154  * 
    155  * This program is free software; you can redistribute it and/or modify 
    156  * it under the terms of the GNU General Public License as published by 
    157  * the Free Software Foundation; either version 2 of the License, or 
    158  * (at your option) any later version. 
    159  * 
    160  * This program is distributed in the hope that it will be useful, 
    161  * but WITHOUT ANY WARRANTY; without even the implied warranty of 
    162  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the 
    163  * GNU General Public License for more details. 
    164  * 
    165  * You should have received a copy of the GNU General Public License 
    166  * along with this program; if not, write to the Free Software 
    167  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA  
    168  */ 
    169 #ifndef __PJ_COMPAT_OS_WINPHONE_H__ 
    170 #define __PJ_COMPAT_OS_WIN32_WINPHONE_H__ 
    171  
    172 /** 
    173  * @file os_win32.h 
    174  * @brief Describes Win32 operating system family specifics. 
    175  */ 
    176  
    177 #define PJ_OS_NAME                  "winphone" 
    178  
    179 #define WIN32_LEAN_AND_MEAN 
    180 #define RPC_NO_WINDOWS_H 
    181 #define PJ_WIN32_WINNT              0x0602 /*_WIN32_WINNT_WIN8*/ 
    182 #ifdef _WIN32_WINNT 
    183 #undef _WIN32_WINNT 
    184 #define _WIN32_WINNT                PJ_WIN32_WINNT 
    185 #endif 
    186  
    187 #define PJ_HAS_ARPA_INET_H          0 
    188 #define PJ_HAS_ASSERT_H             1 
    189 #define PJ_HAS_CTYPE_H              1 
    190 #define PJ_HAS_ERRNO_H              0   /* Must be zero, otherwise errno_test() fails. */ 
    191 #define PJ_HAS_LINUX_SOCKET_H       0 
    192 #define PJ_HAS_MALLOC_H             1 
    193 #define PJ_HAS_NETDB_H              0 
    194 #define PJ_HAS_NETINET_IN_H         0 
    195 #define PJ_HAS_NETINET_TCP_H        0 
    196 #define PJ_HAS_SETJMP_H             1 
    197 #define PJ_HAS_STDARG_H             1 
    198 #define PJ_HAS_STDDEF_H             1 
    199 #define PJ_HAS_STDIO_H              1 
    200 #define PJ_HAS_STDLIB_H             1 
    201 #define PJ_HAS_STRING_H             1 
    202 #define PJ_HAS_SYS_IOCTL_H          0 
    203 #define PJ_HAS_SYS_SELECT_H         0 
    204 #define PJ_HAS_SYS_SOCKET_H         0 
    205 #define PJ_HAS_SYS_TIME_H           0 
    206 #define PJ_HAS_SYS_TIMEB_H          0   /* Doesn't have sys/timeb.h */ 
    207 #define PJ_HAS_SYS_TYPES_H          0   /* Doesn't have sys/types.h */ 
    208 #define PJ_HAS_TIME_H               1 
    209 #define PJ_HAS_UNISTD_H             0 
    210  
    211 #define PJ_HAS_MSWSOCK_H            1 
    212 #define PJ_HAS_WINSOCK_H            0 
    213 #define PJ_HAS_WINSOCK2_H           1 
    214  
    215 #define PJ_SOCK_HAS_INET_ATON       0 
    216  
    217 /* Set 1 if native sockaddr_in has sin_len member.  
    218  * Default: 0 
    219  */ 
    220 #define PJ_SOCKADDR_HAS_LEN         0 
    221  
    222 /* Is errno a good way to retrieve OS errors? (no) 
    223  */ 
    224 #define PJ_HAS_ERRNO_VAR            0 
    225  
    226 /* When this macro is set, getsockopt(SOL_SOCKET, SO_ERROR) will return 
    227  * the status of non-blocking connect() operation. 
    228  */ 
    229 #define PJ_HAS_SO_ERROR             0 
    230  
    231 /* This value specifies the value set in errno by the OS when a non-blocking 
    232  * socket recv() or send() can not return immediately. 
    233  */ 
    234 #define PJ_BLOCKING_ERROR_VAL       WSAEWOULDBLOCK 
    235  
    236 /* This value specifies the value set in errno by the OS when a non-blocking 
    237  * socket connect() can not get connected immediately. 
    238  */ 
    239 #define PJ_BLOCKING_CONNECT_ERROR_VAL   WSAEWOULDBLOCK 
    240  
    241 /** 
    242  * If this macro is set, it tells select I/O Queue that select() needs to 
    243  * be given correct value of nfds (i.e. largest fd + 1). This requires 
    244  * select ioqueue to re-scan the descriptors on each registration and 
    245  * unregistration. 
    246  * If this macro is not set, then ioqueue will always give FD_SETSIZE for 
    247  * nfds argument when calling select(). 
    248  * 
    249  * Default: 0 
    250  */ 
    251 #define PJ_SELECT_NEEDS_NFDS        0 
    252  
    253 /* Endianness */ 
    254 #ifndef PJ_IS_LITTLE_ENDIAN 
    255 #   define PJ_IS_LITTLE_ENDIAN  1 
    256 #   define PJ_IS_BIG_ENDIAN     0 
    257 #endif 
    258  
    259 /* Default threading is enabled, unless it's overridden. */ 
    260 #ifndef PJ_HAS_THREADS 
    261 #  define PJ_HAS_THREADS            (1) 
    262 #endif 
    263  
    264 #define PJ_HAS_HIGH_RES_TIMER       1 
    265 #define PJ_HAS_MALLOC               1 
    266 #define PJ_OS_HAS_CHECK_STACK       1 
    267  
    268 #define PJ_ATOMIC_VALUE_TYPE        long 
    269  
    270 /* No console. */ 
    271 #define PJ_TERM_HAS_COLOR           0 
    272  
    273 /* TlsAlloc() error value. */ 
    274 #define TLS_OUT_OF_INDEXES          0xFFFFFFFF 
    275  
    276 /* No rdtsc */ 
    277 #define PJ_TIMESTAMP_USE_RDTSC      0 
    278  
    279 /* Native string is Unicode. */ 
    280 #define PJ_NATIVE_STRING_IS_UNICODE 1 
    281  
    282 /* If 1, use Read/Write mutex emulation for platforms that don't support it */ 
    283 #define PJ_EMULATE_RWMUTEX          1 
    284  
    285 /* If 1, pj_thread_create() should enforce the stack size when creating  
    286  * threads. 
    287  * Default: 0 (let OS decide the thread's stack size). 
    288  */ 
    289 #define PJ_THREAD_SET_STACK_SIZE        0 
    290  
    291 /* If 1, pj_thread_create() should allocate stack from the pool supplied. 
    292  * Default: 0 (let OS allocate memory for thread's stack). 
    293  */ 
    294 #define PJ_THREAD_ALLOCATE_STACK        0 
    295  
    296  
    297 #endif  /* __PJ_COMPAT_OS_WIN32_WINCE_H__ */ 
    298  
    299 /* $Id$ */ 
    300 /*  
    301  * Copyright (C) 2008-2011 Teluu Inc. (http://www.teluu.com) 
    302  * Copyright (C) 2003-2008 Benny Prijono <benny@prijono.org> 
    303  * 
    304  * This program is free software; you can redistribute it and/or modify 
    305  * it under the terms of the GNU General Public License as published by 
    306  * the Free Software Foundation; either version 2 of the License, or 
    307  * (at your option) any later version. 
    308  * 
    309  * This program is distributed in the hope that it will be useful, 
    310  * but WITHOUT ANY WARRANTY; without even the implied warranty of 
    311  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the 
    312  * GNU General Public License for more details. 
    313  * 
    314  * You should have received a copy of the GNU General Public License 
    315  * along with this program; if not, write to the Free Software 
    316  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA  
    317  */ 
    318 #ifndef __PJ_COMPAT_OS_WINPHONE_H__ 
    319 #define __PJ_COMPAT_OS_WIN32_WINPHONE_H__ 
    320  
    321 /** 
    322  * @file os_win32.h 
    323  * @brief Describes Win32 operating system family specifics. 
    324  */ 
    325  
    326 #define PJ_OS_NAME                  "winphone" 
    327  
    328 #define WIN32_LEAN_AND_MEAN 
    329 #define RPC_NO_WINDOWS_H 
    330 #define PJ_WIN32_WINNT              0x0602 /*_WIN32_WINNT_WIN8*/ 
    331 #ifdef _WIN32_WINNT 
    332 #undef _WIN32_WINNT 
    333 #define _WIN32_WINNT                PJ_WIN32_WINNT 
    334 #endif 
    335  
    336 #define PJ_HAS_ARPA_INET_H          0 
    337 #define PJ_HAS_ASSERT_H             1 
    338 #define PJ_HAS_CTYPE_H              1 
    339 #define PJ_HAS_ERRNO_H              0   /* Must be zero, otherwise errno_test() fails. */ 
    340 #define PJ_HAS_LINUX_SOCKET_H       0 
    341 #define PJ_HAS_MALLOC_H             1 
    342 #define PJ_HAS_NETDB_H              0 
    343 #define PJ_HAS_NETINET_IN_H         0 
    344 #define PJ_HAS_NETINET_TCP_H        0 
    345 #define PJ_HAS_SETJMP_H             1 
    346 #define PJ_HAS_STDARG_H             1 
    347 #define PJ_HAS_STDDEF_H             1 
    348 #define PJ_HAS_STDIO_H              1 
    349 #define PJ_HAS_STDLIB_H             1 
    350 #define PJ_HAS_STRING_H             1 
    351 #define PJ_HAS_SYS_IOCTL_H          0 
    352 #define PJ_HAS_SYS_SELECT_H         0 
    353 #define PJ_HAS_SYS_SOCKET_H         0 
    354 #define PJ_HAS_SYS_TIME_H           0 
    355 #define PJ_HAS_SYS_TIMEB_H          0   /* Doesn't have sys/timeb.h */ 
    356 #define PJ_HAS_SYS_TYPES_H          0   /* Doesn't have sys/types.h */ 
    357 #define PJ_HAS_TIME_H               1 
    358 #define PJ_HAS_UNISTD_H             0 
    359  
    360 #define PJ_HAS_MSWSOCK_H            1 
    361 #define PJ_HAS_WINSOCK_H            0 
    362 #define PJ_HAS_WINSOCK2_H           1 
    363  
    364 #define PJ_SOCK_HAS_INET_ATON       0 
    365  
    366 /* Set 1 if native sockaddr_in has sin_len member.  
    367  * Default: 0 
    368  */ 
    369 #define PJ_SOCKADDR_HAS_LEN         0 
    370  
    371 /* Is errno a good way to retrieve OS errors? (no) 
    372  */ 
    373 #define PJ_HAS_ERRNO_VAR            0 
    374  
    375 /* When this macro is set, getsockopt(SOL_SOCKET, SO_ERROR) will return 
    376  * the status of non-blocking connect() operation. 
    377  */ 
    378 #define PJ_HAS_SO_ERROR             0 
    379  
    380 /* This value specifies the value set in errno by the OS when a non-blocking 
    381  * socket recv() or send() can not return immediately. 
    382  */ 
    383 #define PJ_BLOCKING_ERROR_VAL       WSAEWOULDBLOCK 
    384  
    385 /* This value specifies the value set in errno by the OS when a non-blocking 
    386  * socket connect() can not get connected immediately. 
    387  */ 
    388 #define PJ_BLOCKING_CONNECT_ERROR_VAL   WSAEWOULDBLOCK 
    389  
    390 /** 
    391  * If this macro is set, it tells select I/O Queue that select() needs to 
    392  * be given correct value of nfds (i.e. largest fd + 1). This requires 
    393  * select ioqueue to re-scan the descriptors on each registration and 
    394  * unregistration. 
    395  * If this macro is not set, then ioqueue will always give FD_SETSIZE for 
    396  * nfds argument when calling select(). 
    397  * 
    398  * Default: 0 
    399  */ 
    400 #define PJ_SELECT_NEEDS_NFDS        0 
    401  
    402 /* Endianness */ 
    403 #ifndef PJ_IS_LITTLE_ENDIAN 
    404 #   define PJ_IS_LITTLE_ENDIAN  1 
    405 #   define PJ_IS_BIG_ENDIAN     0 
    406 #endif 
    407  
    408 /* Default threading is enabled, unless it's overridden. */ 
    409 #ifndef PJ_HAS_THREADS 
    410 #  define PJ_HAS_THREADS            (1) 
    411 #endif 
    412  
    413 #define PJ_HAS_HIGH_RES_TIMER       1 
    414 #define PJ_HAS_MALLOC               1 
    415 #define PJ_OS_HAS_CHECK_STACK       1 
    416  
    417 #define PJ_ATOMIC_VALUE_TYPE        long 
    418  
    419 /* No console. */ 
    420 #define PJ_TERM_HAS_COLOR           0 
    421  
    422 /* TlsAlloc() error value. */ 
    423 #define TLS_OUT_OF_INDEXES          0xFFFFFFFF 
    424  
    425 /* No rdtsc */ 
    426 #define PJ_TIMESTAMP_USE_RDTSC      0 
    427  
    428 /* Native string is Unicode. */ 
    429 #define PJ_NATIVE_STRING_IS_UNICODE 1 
    430  
    431 /* If 1, use Read/Write mutex emulation for platforms that don't support it */ 
    432 #define PJ_EMULATE_RWMUTEX          1 
    433  
    434 /* If 1, pj_thread_create() should enforce the stack size when creating  
    435  * threads. 
    436  * Default: 0 (let OS decide the thread's stack size). 
    437  */ 
    438 #define PJ_THREAD_SET_STACK_SIZE        0 
    439  
    440 /* If 1, pj_thread_create() should allocate stack from the pool supplied. 
    441  * Default: 0 (let OS allocate memory for thread's stack). 
    442  */ 
    443 #define PJ_THREAD_ALLOCATE_STACK        0 
    444  
    445  
    446 #endif  /* __PJ_COMPAT_OS_WIN32_WINCE_H__ */ 
    447  
  • pjproject/branches/projects/winphone/pjlib/src/pj/file_access_win32.c

    r4629 r4777  
    3636static pj_status_t get_file_size(HANDLE hFile, pj_off_t *size) 
    3737{ 
    38 #ifdef PJ_WIN32_WINPHONE   
    39     FILE_STANDARD_INFO fileInfo; 
    40  
    41     if (GetFileInformationByHandleEx(hFile, FileStandardInfo, &fileInfo, 
    42                                      sizeof(FILE_STANDARD_INFO)))  
     38#if defined(PJ_WIN32_WINPHONE) && PJ_WIN32_WINPHONE   
     39    FILE_COMPRESSION_INFO fileInfo; 
     40 
     41    if (GetFileInformationByHandleEx(hFile, FileCompressionInfo, &fileInfo, 
     42                                     sizeof(FILE_COMPRESSION_INFO)))  
    4343    { 
    44         *size = fileInfo.AllocationSize.QuadPart;        
     44        *size = fileInfo.CompressedFileSize.QuadPart;    
    4545    } else {     
    4646        *size = -1; 
     
    7171                                 HANDLE template_file) 
    7272{ 
    73 #ifdef PJ_WIN32_WINPHONE 
     73#if defined(PJ_WIN32_WINPHONE) && PJ_WIN32_WINPHONE 
    7474    PJ_UNUSED_ARG(security_attributes); 
    7575    PJ_UNUSED_ARG(flags_and_attributes); 
     
    216216    HANDLE hFile; 
    217217    FILETIME creationTime, accessTime, writeTime; 
    218 #ifdef PJ_WIN32_WINPHONE 
     218#if defined(PJ_WIN32_WINPHONE) && PJ_WIN32_WINPHONE 
    219219    FILE_BASIC_INFO fileInfo; 
    220220#endif 
     
    234234        return PJ_RETURN_OS_ERROR(GetLastError()); 
    235235    } 
    236 #ifdef PJ_WIN32_WINPHONE 
     236#if defined(PJ_WIN32_WINPHONE) && PJ_WIN32_WINPHONE 
    237237    if (GetFileInformationByHandleEx(hFile, FileBasicInfo, &fileInfo, 
    238238                                     sizeof(FILE_BASIC_INFO)))  
  • pjproject/branches/projects/winphone/pjlib/src/pj/file_io_win32.c

    r4629 r4777  
    8989    dwFlagsAndAttributes = FILE_ATTRIBUTE_NORMAL; 
    9090 
    91 #ifdef PJ_WIN32_WINPHONE   
     91#if defined(PJ_WIN32_WINPHONE) && PJ_WIN32_WINPHONE   
    9292    hFile = CreateFile2(PJ_STRING_TO_NATIVE(pathname, 
    9393                                            wpathname,sizeof(wpathname)),  
     
    190190                                    DWORD dwMoveMethod) 
    191191{ 
    192 #ifdef PJ_WIN32_WINPHONE 
     192#if defined(PJ_WIN32_WINPHONE) && PJ_WIN32_WINPHONE 
    193193    LARGE_INTEGER liDistance, liNewPos;     
    194194 
  • pjproject/branches/projects/winphone/pjlib/src/pj/ioqueue_select.c

    r4537 r4777  
    880880    pj_lock_release(ioqueue->lock); 
    881881 
     882#if defined(PJ_WIN32_WINPHONE) && PJ_WIN32_WINPHONE 
     883    count = 0; 
     884    __try {     
     885#endif 
     886 
    882887    count = pj_sock_select(ioqueue->nfds+1, &rfdset, &wfdset, &xfdset,  
    883888                           timeout); 
     889 
     890#if defined(PJ_WIN32_WINPHONE) && PJ_WIN32_WINPHONE 
     891    /* Ignore Invalid Handle Exception raised by select().*/ 
     892    } __except(GetExceptionCode() == STATUS_INVALID_HANDLE? 
     893               EXCEPTION_CONTINUE_EXECUTION:EXCEPTION_CONTINUE_SEARCH) { 
     894    } 
     895#endif 
    884896     
    885897    if (count == 0) 
  • pjproject/branches/projects/winphone/pjlib/src/pj/os_core_win32.c

    r4618 r4777  
    3939#endif 
    4040 
    41 #if PJ_WIN32_WINPHONE 
    42 #   include "../../third_party/threademulation/include/ThreadEmulation.h" 
     41#if defined(PJ_WIN32_WINPHONE) && PJ_WIN32_WINPHONE 
     42#   include "../../../third_party/threademulation/include/ThreadEmulation.h" 
    4343#endif 
    4444 
     
    306306PJ_DEF(int) pj_thread_get_prio(pj_thread_t *thread) 
    307307{ 
    308 #if PJ_WIN32_WINPHONE 
     308#if defined(PJ_WIN32_WINPHONE) && PJ_WIN32_WINPHONE 
    309309    PJ_UNUSED_ARG(thread); 
    310310    return -1; 
     
    326326                     PJ_EINVAL); 
    327327 
     328#if defined(PJ_WIN32_WINPHONE) && PJ_WIN32_WINPHONE 
     329    if (SetThreadPriorityRT(thread->hthread, prio) == FALSE) 
     330#else 
    328331    if (SetThreadPriority(thread->hthread, prio) == FALSE) 
     332#endif 
    329333        return PJ_RETURN_OS_ERROR(GetLastError()); 
    330334 
     
    487491    pj_thread_t *rec; 
    488492 
     493#if defined(PJ_WIN32_WINPHONE) && PJ_WIN32_WINPHONE 
     494    PJ_UNUSED_ARG(stack_size); 
     495#endif 
     496 
    489497    PJ_CHECK_STACK(); 
    490498    PJ_ASSERT_RETURN(pool && proc && thread_ptr, PJ_EINVAL); 
     
    521529    rec->arg = arg; 
    522530 
    523 #ifdef PJ_WIN32_WINPHONE 
    524     rec->hthread = CreateThread(NULL, stack_size,  
    525                                 thread_main, rec, 
    526                                 dwflags, NULL); 
     531#if defined(PJ_WIN32_WINPHONE) && PJ_WIN32_WINPHONE 
     532    rec->hthread = CreateThreadRT(NULL, 0,  
     533                                  thread_main, rec, 
     534                                  dwflags, NULL); 
    527535#else 
    528536    rec->hthread = CreateThread(NULL, stack_size,  
     
    562570    PJ_ASSERT_RETURN(p, PJ_EINVAL); 
    563571 
     572#if defined(PJ_WIN32_WINPHONE) && PJ_WIN32_WINPHONE 
     573    if (ResumeThreadRT(rec->hthread) == (DWORD)-1) 
     574#else 
    564575    if (ResumeThread(rec->hthread) == (DWORD)-1) 
     576#endif 
    565577        return PJ_RETURN_OS_ERROR(GetLastError()); 
    566578    else 
     
    606618    PJ_LOG(6, (pj_thread_this()->obj_name, "Joining thread %s", p->obj_name)); 
    607619 
    608 #if PJ_WIN32_WINPHONE 
     620#if defined(PJ_WIN32_WINPHONE) && PJ_WIN32_WINPHONE 
    609621    rc = WaitForSingleObjectEx(rec->hthread, INFINITE, FALSE); 
    610622#else 
     
    642654{ 
    643655    PJ_CHECK_STACK(); 
     656#if defined(PJ_WIN32_WINPHONE) && PJ_WIN32_WINPHONE 
     657    SleepRT(msec); 
     658#else 
    644659    Sleep(msec); 
     660#endif 
    645661    return PJ_SUCCESS; 
    646662} 
     
    836852    //PJ_CHECK_STACK(); 
    837853 
     854#if defined(PJ_WIN32_WINPHONE) && PJ_WIN32_WINPHONE 
     855    *index = TlsAllocRT(); 
     856#else 
    838857    *index = TlsAlloc(); 
     858#endif 
    839859 
    840860    if (*index == TLS_OUT_OF_INDEXES) 
     
    850870{ 
    851871    PJ_CHECK_STACK(); 
     872#if defined(PJ_WIN32_WINPHONE) && PJ_WIN32_WINPHONE 
     873    TlsFreeRT(index); 
     874#else 
    852875    TlsFree(index); 
     876#endif 
    853877} 
    854878 
     
    863887    //beginning before main thread is initialized. 
    864888    //PJ_CHECK_STACK(); 
     889#if defined(PJ_WIN32_WINPHONE) && PJ_WIN32_WINPHONE 
     890    rc = TlsSetValueRT(index, value); 
     891#else 
    865892    rc = TlsSetValue(index, value); 
     893#endif 
    866894    return rc!=0 ? PJ_SUCCESS : PJ_RETURN_OS_ERROR(GetLastError()); 
    867895} 
     
    875903    //by PJ_CHECK_STACK() itself!!! 
    876904    //PJ_CHECK_STACK(); 
     905#if defined(PJ_WIN32_WINPHONE) && PJ_WIN32_WINPHONE 
     906    return TlsGetValueRT(index); 
     907#else 
    877908    return TlsGetValue(index); 
     909#endif 
    878910} 
    879911 
     
    884916    PJ_CHECK_STACK(); 
    885917 
    886 #if PJ_WIN32_WINPHONE 
     918#if defined(PJ_WIN32_WINPHONE) && PJ_WIN32_WINPHONE 
    887919    InitializeCriticalSectionEx(&mutex->crit, 0, 0); 
    888920#elif PJ_WIN32_WINNT >= 0x0400 
     
    11401172 
    11411173    sem = pj_pool_alloc(pool, sizeof(*sem));  
    1142 #if PJ_WIN32_WINPHONE 
     1174#if defined(PJ_WIN32_WINPHONE) && PJ_WIN32_WINPHONE 
    11431175    /** SEMAPHORE_ALL_ACCESS **/ 
    11441176    sem->hSemaphore = CreateSemaphoreEx(NULL, initial, max, NULL, 0,  
     
    11771209                              pj_thread_this()->obj_name)); 
    11781210 
    1179 #if PJ_WIN32_WINPHONE 
     1211#if defined(PJ_WIN32_WINPHONE) && PJ_WIN32_WINPHONE 
    11801212    result = WaitForSingleObjectEx(sem->hSemaphore, timeout, FALSE); 
    11811213#else 
     
    12791311        return PJ_ENOMEM; 
    12801312 
    1281 #if PJ_WIN32_WINPHONE 
     1313#if defined(PJ_WIN32_WINPHONE) && PJ_WIN32_WINPHONE 
    12821314    event->hEvent = CreateEventEx(NULL, NULL,  
    12831315                                  (manual_reset?0x1:0x0)|(initial?0x2:0x0),  
     
    13181350                                pj_thread_this()->obj_name)); 
    13191351 
    1320 #if PJ_WIN32_WINPHONE 
     1352#if defined(PJ_WIN32_WINPHONE) && PJ_WIN32_WINPHONE 
    13211353    result = WaitForSingleObjectEx(event->hEvent, timeout, FALSE); 
    13221354#else 
     
    13801412PJ_DEF(pj_status_t) pj_event_pulse(pj_event_t *event) 
    13811413{ 
    1382 #ifdef PJ_WIN32_WINPHONE 
     1414#if defined(PJ_WIN32_WINPHONE) && PJ_WIN32_WINPHONE 
    13831415    PJ_UNUSED_ARG(event); 
    13841416    pj_assert(!"pj_event_pulse() not supported!"); 
  • pjproject/branches/projects/winphone/pjlib/src/pj/os_info.c

    r4629 r4777  
    187187#elif defined(_MSC_VER) 
    188188    { 
    189         #ifdef PJ_WIN32_WINPHONE 
     189        #if defined(PJ_WIN32_WINPHONE) && PJ_WIN32_WINPHONE 
    190190            si.os_name = pj_str("winphone"); 
    191191        #else 
     
    210210        SYSTEM_INFO wsi; 
    211211 
    212     #ifdef PJ_WIN32_WINPHONE 
     212    #if defined(PJ_WIN32_WINPHONE) && PJ_WIN32_WINPHONE 
    213213        GetNativeSystemInfo(&wsi); 
    214214    #else 
     
    238238    #endif      /* PJ_WIN32_WINCE || PJ_WIN32_WINPHONE */ 
    239239        } 
    240     #ifdef PJ_WIN32_WINPHONE 
     240    #if defined(PJ_WIN32_WINPHONE) && PJ_WIN32_WINPHONE 
    241241        /* Avoid compile warning. */ 
    242242        goto get_sdk_info; 
  • pjproject/branches/projects/winphone/third_party/threademulation/include/ThreadEmulation.h

    r4618 r4777  
    3434 
    3535#ifdef __cplusplus 
    36 namespace ThreadEmulation 
    37 { 
    38     extern "C" { 
     36//namespace ThreadEmulation 
     37//{ 
     38extern "C"  
     39    { 
    3940#endif 
    4041    #ifndef CREATE_SUSPENDED 
     
    4243    #endif 
    4344 
    44     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); 
     45    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); 
     46    DWORD WINAPI ResumeThreadRT(_In_ HANDLE hThread); 
     47    BOOL WINAPI SetThreadPriorityRT(_In_ HANDLE hThread, _In_ int nPriority); 
     48     
     49    VOID WINAPI SleepRT(_In_ DWORD dwMilliseconds); 
    4550 
    46     DWORD WINAPI ResumeThread(_In_ HANDLE hThread); 
    47     BOOL WINAPI SetThreadPriority(_In_ HANDLE hThread, _In_ int nPriority); 
    48      
    49     VOID WINAPI Sleep(_In_ DWORD dwMilliseconds); 
    50  
    51     DWORD WINAPI TlsAlloc(); 
    52     BOOL WINAPI TlsFree(_In_ DWORD dwTlsIndex); 
    53     LPVOID WINAPI TlsGetValue(_In_ DWORD dwTlsIndex); 
    54     BOOL WINAPI TlsSetValue(_In_ DWORD dwTlsIndex, _In_opt_ LPVOID lpTlsValue); 
     51    DWORD WINAPI TlsAllocRT(); 
     52    BOOL WINAPI TlsFreeRT(_In_ DWORD dwTlsIndex); 
     53    LPVOID WINAPI TlsGetValueRT(_In_ DWORD dwTlsIndex); 
     54    BOOL WINAPI TlsSetValueRT(_In_ DWORD dwTlsIndex, _In_opt_ LPVOID lpTlsValue); 
    5555     
    5656    void WINAPI TlsShutdown(); 
    57  
    5857#ifdef __cplusplus 
    5958    } 
    60 } 
    6159#endif 
  • pjproject/branches/projects/winphone/third_party/threademulation/src/ThreadEmulation.cpp

    r4618 r4777  
    66// Copyright (c) Microsoft Corporation. All rights reserved. 
    77 
    8 //#include "ThreadEmulation.h" 
    98#include "../include/ThreadEmulation.h" 
    109 
     
    2019using namespace Windows::System::Threading; 
    2120 
    22  
    23 #ifdef __cplusplus 
    24 namespace ThreadEmulation 
    25 { 
    26 #endif 
     21//namespace ThreadEmulation 
     22//{ 
    2723    // Stored data for CREATE_SUSPENDED and ResumeThread. 
    2824    struct PendingThreadInfo 
     
    8480    } 
    8581 
    86     _Use_decl_annotations_ HANDLE WINAPI CreateThread(LPSECURITY_ATTRIBUTES unusedThreadAttributes, SIZE_T unusedStackSize, LPTHREAD_START_ROUTINE lpStartAddress, LPVOID lpParameter, DWORD dwCreationFlags, LPDWORD unusedThreadId) 
     82 
     83    _Use_decl_annotations_ HANDLE WINAPI CreateThreadRT(LPSECURITY_ATTRIBUTES unusedThreadAttributes, SIZE_T unusedStackSize, LPTHREAD_START_ROUTINE lpStartAddress, LPVOID lpParameter, DWORD dwCreationFlags, LPDWORD unusedThreadId) 
    8784    { 
    8885        // Validate parameters. 
     
    143140    } 
    144141 
    145     _Use_decl_annotations_ DWORD WINAPI ResumeThread(HANDLE hThread) 
     142 
     143    _Use_decl_annotations_ DWORD WINAPI ResumeThreadRT(HANDLE hThread) 
    146144    { 
    147145        lock_guard<mutex> lock(pendingThreadsLock); 
     
    176174 
    177175 
    178     _Use_decl_annotations_ BOOL WINAPI SetThreadPriority(HANDLE hThread, int nPriority) 
     176    _Use_decl_annotations_ BOOL WINAPI SetThreadPriorityRT(HANDLE hThread, int nPriority) 
    179177    { 
    180178        lock_guard<mutex> lock(pendingThreadsLock); 
     
    197195 
    198196 
    199     _Use_decl_annotations_ VOID WINAPI Sleep(DWORD dwMilliseconds) 
     197    _Use_decl_annotations_ VOID WINAPI SleepRT(DWORD dwMilliseconds) 
    200198    { 
    201199        static HANDLE singletonEvent = nullptr; 
     
    226224 
    227225 
    228     DWORD WINAPI TlsAlloc() 
     226    DWORD WINAPI TlsAllocRT() 
    229227    { 
    230228        lock_guard<mutex> lock(tlsAllocationLock); 
     
    243241 
    244242 
    245     _Use_decl_annotations_ BOOL WINAPI TlsFree(DWORD dwTlsIndex) 
     243    _Use_decl_annotations_ BOOL WINAPI TlsFreeRT(DWORD dwTlsIndex) 
    246244    { 
    247245        lock_guard<mutex> lock(tlsAllocationLock); 
     
    273271 
    274272 
    275     _Use_decl_annotations_ LPVOID WINAPI TlsGetValue(DWORD dwTlsIndex) 
     273    _Use_decl_annotations_ LPVOID WINAPI TlsGetValueRT(DWORD dwTlsIndex) 
    276274    { 
    277275        ThreadLocalData* threadData = currentThreadData; 
     
    290288 
    291289 
    292     _Use_decl_annotations_ BOOL WINAPI TlsSetValue(DWORD dwTlsIndex, LPVOID lpTlsValue) 
     290    _Use_decl_annotations_ BOOL WINAPI TlsSetValueRT(DWORD dwTlsIndex, LPVOID lpTlsValue) 
    293291    { 
    294292        ThreadLocalData* threadData = currentThreadData; 
     
    355353        } 
    356354    } 
    357 #ifdef __cplusplus 
    358 } 
    359 #endif 
     355//} 
Note: See TracChangeset for help on using the changeset viewer.