Changeset 338


Ignore:
Timestamp:
Mar 20, 2006 12:39:24 PM (18 years ago)
Author:
bennylp
Message:

Ported pjlib to PowerPC/MacOS

Location:
pjproject/trunk
Files:
7 added
20 edited
1 moved

Legend:

Unmodified
Added
Removed
  • pjproject/trunk/configure

    r316 r338  
    44# Detect machine 
    55# 
    6 MACHINE=`uname -m` 
     6MACHINE=`uname -p` 
    77 
    88if echo $MACHINE | grep sun4u > /dev/null; then 
     
    1212elif echo $MACHINE | grep alpha > /dev/null; then 
    1313    MACHINE_NAME=alpha 
     14elif echo $MACHINE | grep powerpc > /dev/null; then 
     15    MACHINE_NAME=powerpc 
    1416else 
    15     echo "Unable to detect processor type ('uname -m' == '$MACHINE')" 
     17    echo "Unable to detect processor type ('uname -p' == '$MACHINE')" 
    1618    exit 1 
    1719fi 
     
    4547    OS_NAME=win32 
    4648    HOST_NAME=mingw 
     49elif echo $SYSTEM | grep -i darwin > /dev/null; then 
     50    OS_NAME=darwinos 
     51    HOST_NAME=unix 
    4752else 
    4853    echo "Unable to detect system type ('uname -s' == '$SYSTEM')" 
  • pjproject/trunk/pjlib/build

    • Property svn:ignore
      •  

        old new  
        88test*.txt 
        99*.vcproj* 
         10.gdb* 
  • pjproject/trunk/pjlib/build/Makefile

    r153 r338  
    2323export PJLIB_OBJS += $(OS_OBJS) $(M_OBJS) $(CC_OBJS) $(HOST_OBJS) \ 
    2424        array.o config.o ctype.o errno.o except.o fifobuf.o guid.o \ 
    25         hash.o list.o lock.o log.o \ 
     25        hash.o list.o lock.o log.o os_time_common.o \ 
    2626        pool.o pool_caching.o rand.o \ 
    2727        rbtree.o string.o timer.o \ 
  • pjproject/trunk/pjlib/build/os-linux.mak

    r65 r338  
    1010export PJLIB_OBJS +=    addr_resolv_sock.o guid_simple.o \ 
    1111                        log_writer_stdout.o os_core_unix.o \ 
    12                         os_error_unix.o os_time_ansi.o \ 
     12                        os_error_unix.o os_time_unix.o \ 
    1313                        os_timestamp_common.o os_timestamp_linux.o \ 
    1414                        os_time_ansi.o \ 
  • pjproject/trunk/pjlib/build/os-sunos.mak

    r65 r338  
    1010export PJLIB_OBJS +=    addr_resolv_sock.o guid_simple.o \ 
    1111                        log_writer_stdout.o os_core_unix.o \ 
    12                         os_error_unix.o os_time_ansi.o \ 
     12                        os_error_unix.o os_time_unix.o \ 
    1313                        os_timestamp_common.o os_timestamp_linux.o \ 
    1414                        os_time_ansi.o \ 
  • pjproject/trunk/pjlib/include/pj/compat/errno.h

    r125 r338  
    2727#   define pj_get_native_netos_error()      WSAGetLastError() 
    2828 
    29 #elif (defined(PJ_LINUX) && PJ_LINUX != 0) || \ 
    30       (defined(PJ_LINUX_KERNEL) && PJ_LINUX_KERNEL != 0) || \ 
    31       (defined(PJ_SUNOS) && PJ_SUNOS != 0) 
     29#elif defined(PJ_HAS_ERRNO_VAR) && PJ_HAS_ERRNO_VAR!= 0 
    3230 
    3331    typedef int pj_os_err_type; 
     
    3735#else 
    3836 
    39 #   error "Please define pj_os_err_type for this platform here!" 
     37#   error "Please define how to get errno for this platform here!" 
    4038 
    4139#endif 
  • pjproject/trunk/pjlib/include/pj/compat/os_linux.h

    r153 r338  
    4444#define PJ_HAS_SYS_SELECT_H         1 
    4545#define PJ_HAS_SYS_SOCKET_H         1 
     46#define PJ_HAS_SYS_TIME_H           0 
    4647#define PJ_HAS_SYS_TIMEB_H          1 
    4748#define PJ_HAS_SYS_TYPES_H          1 
     
    5455 
    5556#define PJ_SOCK_HAS_INET_ATON       1 
     57#define PJ_SOCKADDR_HAS_LEN         0 
     58 
     59/* Is errno a good way to retrieve OS errors? 
     60 */ 
     61#define PJ_HAS_ERRNO_VAR            1 
    5662 
    5763/* When this macro is set, getsockopt(SOL_SOCKET, SO_ERROR) will return 
  • pjproject/trunk/pjlib/include/pj/compat/os_linux_kernel.h

    r153 r338  
    4444#define PJ_HAS_SYS_SELECT_H         0 
    4545#define PJ_HAS_SYS_SOCKET_H         0 
     46#define PJ_HAS_SYS_TIME_H           0 
    4647#define PJ_HAS_SYS_TIMEB_H          0 
    4748#define PJ_HAS_SYS_TYPES_H          0 
     
    5455 
    5556#define PJ_SOCK_HAS_INET_ATON       0 
     57#define PJ_SOCKADDR_HAS_LEN         0 
    5658 
    5759/* When this macro is set, getsockopt(SOL_SOCKET, SO_ERROR) will return 
  • pjproject/trunk/pjlib/include/pj/compat/os_palmos.h

    r153 r338  
    5353 
    5454#define PJ_SOCK_HAS_INET_ATON       0 
     55#define PJ_SOCKADDR_HAS_LEN         0 
     56 
     57/* Is errno a good way to retrieve OS errors? 
     58 */ 
     59#define PJ_HAS_ERRNO_VAR            0 
    5560 
    5661/* When this macro is set, getsockopt(SOL_SOCKET, SO_ERROR) will return 
  • pjproject/trunk/pjlib/include/pj/compat/os_sunos.h

    r153 r338  
    4444#define PJ_HAS_SYS_SELECT_H         1 
    4545#define PJ_HAS_SYS_SOCKET_H         1 
     46#define PJ_HAS_SYS_TIME_H           0 
    4647#define PJ_HAS_SYS_TIMEB_H          1 
    4748#define PJ_HAS_SYS_TYPES_H          1 
     
    5455 
    5556#define PJ_SOCK_HAS_INET_ATON       0 
     57#define PJ_SOCKADDR_HAS_LEN         0 
     58 
     59/* Is errno a good way to retrieve OS errors? 
     60 */ 
     61#define PJ_HAS_ERRNO_VAR            1 
    5662 
    5763/* When this macro is set, getsockopt(SOL_SOCKET, SO_ERROR) will return 
  • pjproject/trunk/pjlib/include/pj/compat/os_win32.h

    r239 r338  
    5050#define PJ_HAS_SYS_SELECT_H         0 
    5151#define PJ_HAS_SYS_SOCKET_H         0 
     52#define PJ_HAS_SYS_TIME_H           0 
    5253#define PJ_HAS_SYS_TIMEB_H          1 
    5354#define PJ_HAS_SYS_TYPES_H          1 
     
    6061 
    6162#define PJ_SOCK_HAS_INET_ATON       0 
     63#define PJ_SOCKADDR_HAS_LEN         0 
     64 
     65/* Is errno a good way to retrieve OS errors? (No) 
     66 */ 
     67#define PJ_HAS_ERRNO_VAR            0 
    6268 
    6369/* When this macro is set, getsockopt(SOL_SOCKET, SO_ERROR) will return 
  • pjproject/trunk/pjlib/include/pj/compat/os_win32_wince.h

    r125 r338  
    4848#define PJ_HAS_SYS_SELECT_H         0 
    4949#define PJ_HAS_SYS_SOCKET_H         0 
     50#define PJ_HAS_SYS_TIME_H           0 
    5051#define PJ_HAS_SYS_TIMEB_H          0   /* Doesn't have sys/timeb.h */ 
    5152#define PJ_HAS_SYS_TYPES_H          0   /* Doesn't have sys/types.h */ 
     
    5859 
    5960#define PJ_SOCK_HAS_INET_ATON       0 
     61#define PJ_SOCKADDR_HAS_LEN         0 
     62 
     63/* Is errno a good way to retrieve OS errors? (no) 
     64 */ 
     65#define PJ_HAS_ERRNO_VAR            0 
    6066 
    6167/* When this macro is set, getsockopt(SOL_SOCKET, SO_ERROR) will return 
     
    98104 
    99105#endif  /* __PJ_COMPAT_OS_WIN32_WINCE_H__ */ 
     106 
  • pjproject/trunk/pjlib/include/pj/compat/time.h

    r65 r338  
    2929#endif 
    3030 
     31#if defined(PJ_HAS_SYS_TIME_H) && PJ_HAS_SYS_TIME_H != 0 
     32#  include <sys/time.h> 
     33#endif 
     34 
    3135#if defined(PJ_HAS_SYS_TIMEB_H) && PJ_HAS_SYS_TIMEB_H != 0 
    3236#  include <sys/timeb.h> 
     
    3539 
    3640#endif  /* __PJ_COMPAT_TIME_H__ */ 
     41 
  • pjproject/trunk/pjlib/include/pj/config.h

    r331 r338  
    5252#elif defined(PJ_SUNOS) && PJ_SUNOS!=0 
    5353#  include <pj/compat/os_sunos.h> 
     54#elif defined(PJ_DARWINOS) && PJ_DARWINOS!=0 
     55#  include <pj/compat/os_darwinos.h> 
    5456#else 
    5557#  error "Please specify target os." 
     
    7072#elif defined (PJ_M_ARMV4) && PJ_M_ARMV4 != 0 
    7173#   include <pj/compat/m_armv4.h> 
     74#elif defined (PJ_M_POWERPC) && PJ_M_POWERPC != 0 
     75#   include <pj/compat/m_powerpc.h> 
    7276#else 
    7377#  error "Please specify target machine." 
     
    247251 * be set to this value). 
    248252 * 
    249  * Default: 256 (64 for WinCE) 
     253 * Default: if FD_SETSIZE is defined and the value is greather than 256, 
     254 *          then it will be used.  Otherwise 256 (64 for WinCE). 
    250255 */ 
    251256#ifndef PJ_IOQUEUE_MAX_HANDLES 
  • pjproject/trunk/pjlib/include/pj/sock.h

    r122 r338  
    157157/** 
    158158 * Structure describing a generic socket address. 
     159 * If PJ_SOCKADDR_HAS_LEN is not zero, then sa_zero_len member is added 
     160 * to this struct. As far the application is concerned, the value of 
     161 * this member will always be zero. Internally, PJLIB may modify the value 
     162 * before calling OS socket API, and reset the value back to zero before 
     163 * returning the struct to application. 
    159164 */ 
    160165typedef struct pj_sockaddr 
    161166{ 
     167#if defined(PJ_SOCKADDR_HAS_LEN) && PJ_SOCKADDR_HAS_LEN!=0 
     168    pj_uint8_t  sa_zero_len; 
     169    pj_uint8_t  sa_family; 
     170#else 
    162171    pj_uint16_t sa_family;      /**< Common data: address family.   */ 
     172#endif 
    163173    char        sa_data[14];    /**< Address data.                  */ 
    164174} pj_sockaddr; 
     
    176186/** 
    177187 * This structure describes Internet socket address. 
     188 * If PJ_SOCKADDR_HAS_LEN is not zero, then sin_zero_len member is added 
     189 * to this struct. As far the application is concerned, the value of 
     190 * this member will always be zero. Internally, PJLIB may modify the value 
     191 * before calling OS socket API, and reset the value back to zero before 
     192 * returning the struct to application. 
    178193 */ 
    179194struct pj_sockaddr_in 
    180195{ 
     196#if defined(PJ_SOCKADDR_HAS_LEN) && PJ_SOCKADDR_HAS_LEN!=0 
     197    pj_uint8_t  sin_zero_len;   /**< Just ignore this.              */ 
     198    pj_uint8_t  sin_family;     /**< Address family.                */ 
     199#else 
    181200    pj_uint16_t sin_family;     /**< Address family.                */ 
     201#endif 
    182202    pj_uint16_t sin_port;       /**< Transport layer port number.   */ 
    183203    pj_in_addr  sin_addr;       /**< IP address.                    */ 
     
    213233/** 
    214234 * This structure describes IPv6 socket address. 
     235 * If PJ_SOCKADDR_HAS_LEN is not zero, then sin_zero_len member is added 
     236 * to this struct. As far the application is concerned, the value of 
     237 * this member will always be zero. Internally, PJLIB may modify the value 
     238 * before calling OS socket API, and reset the value back to zero before 
     239 * returning the struct to application. 
    215240 */ 
    216241typedef struct pj_sockaddr_in6 
    217242{ 
     243#if defined(PJ_SOCKADDR_HAS_LEN) && PJ_SOCKADDR_HAS_LEN!=0 
     244    pj_uint8_t  sin_zero_len;       /**< Just ignore this.         */ 
     245    pj_uint8_t  sin_family;         /**< Address family.           */ 
     246#else 
    218247    pj_uint16_t sin6_family;        /**< Address family             */ 
     248#endif 
    219249    pj_uint16_t sin6_port;          /**< Transport layer port number. */ 
    220250    pj_uint32_t sin6_flowinfo;      /**< IPv6 flow information      */ 
  • pjproject/trunk/pjlib/src/pj/guid_simple.c

    r66 r338  
    2121#include <pj/rand.h> 
    2222#include <pj/string.h> 
    23 #include <pj/compat/sprintf.h> 
    2423 
    2524const unsigned PJ_GUID_STRING_LENGTH=20; 
  • pjproject/trunk/pjlib/src/pj/os_core_unix.c

    r304 r338  
    2525#include <pj/string.h> 
    2626#include <pj/guid.h> 
    27 #include <pj/compat/sprintf.h> 
    2827#include <pj/except.h> 
    2928#include <pj/errno.h> 
     
    205204 
    206205    if(cstr_thread_name && pj_strlen(&thread_name) < sizeof(thread->obj_name)-1) 
    207         pj_sprintf(thread->obj_name, cstr_thread_name, thread->thread); 
     206        pj_ansi_sprintf(thread->obj_name, cstr_thread_name, thread->thread); 
    208207    else 
    209         pj_sprintf(thread->obj_name, "thr%p", (void*)thread->thread); 
     208        pj_ansi_sprintf(thread->obj_name, "thr%p", (void*)thread->thread); 
    210209     
    211210    rc = pj_thread_local_set(thread_tls_id, thread); 
     
    315314     
    316315    if (strchr(thread_name, '%')) { 
    317         pj_snprintf(rec->obj_name, PJ_MAX_OBJ_NAME, thread_name, rec); 
     316        pj_ansi_snprintf(rec->obj_name, PJ_MAX_OBJ_NAME, thread_name, rec); 
    318317    } else { 
    319318        strncpy(rec->obj_name, thread_name, PJ_MAX_OBJ_NAME); 
     
    805804    } 
    806805    if (strchr(name, '%')) { 
    807         pj_snprintf(mutex->obj_name, PJ_MAX_OBJ_NAME, name, mutex); 
     806        pj_ansi_snprintf(mutex->obj_name, PJ_MAX_OBJ_NAME, name, mutex); 
    808807    } else { 
    809808        strncpy(mutex->obj_name, name, PJ_MAX_OBJ_NAME); 
     
    11261125    } 
    11271126    if (strchr(name, '%')) { 
    1128         pj_snprintf(sem->obj_name, PJ_MAX_OBJ_NAME, name, sem); 
     1127        pj_ansi_snprintf(sem->obj_name, PJ_MAX_OBJ_NAME, name, sem); 
    11291128    } else { 
    11301129        strncpy(sem->obj_name, name, PJ_MAX_OBJ_NAME); 
  • pjproject/trunk/pjlib/src/pj/os_time_bsd.c

    r337 r338  
    3434} 
    3535 
    36 PJ_DEF(pj_status_t) pj_time_decode(const pj_time_val *tv, pj_parsed_time *pt) 
    37 { 
    38     struct tm *local_time; 
    39  
    40     PJ_CHECK_STACK(); 
    41  
    42     local_time = localtime((time_t*)&tv->sec); 
    43  
    44     pt->year = local_time->tm_year+1900; 
    45     pt->mon = local_time->tm_mon; 
    46     pt->day = local_time->tm_mday; 
    47     pt->hour = local_time->tm_hour; 
    48     pt->min = local_time->tm_min; 
    49     pt->sec = local_time->tm_sec; 
    50     pt->wday = local_time->tm_wday; 
    51     pt->msec = tv->msec; 
    52  
    53     return PJ_SUCCESS; 
    54 } 
    55  
    56 /** 
    57  * Encode parsed time to time value. 
    58  */ 
    59 PJ_DEF(pj_status_t) pj_time_encode(const pj_parsed_time *pt, pj_time_val *tv) 
    60 { 
    61     struct tm local_time; 
    62  
    63     local_time.tm_year = pt->year-1900; 
    64     local_time.tm_mon = pt->mon; 
    65     local_time.tm_mday = pt->day; 
    66     local_time.tm_hour = pt->hour; 
    67     local_time.tm_min = pt->min; 
    68     local_time.tm_sec = pt->sec; 
    69     local_time.tm_isdst = 0; 
    70      
    71     tv->sec = mktime(&local_time); 
    72     tv->msec = pt->msec; 
    73  
    74     return PJ_SUCCESS; 
    75 } 
    76  
    77 /** 
    78  * Convert local time to GMT. 
    79  */ 
    80 PJ_DEF(pj_status_t) pj_time_local_to_gmt(pj_time_val *tv); 
    81  
    82 /** 
    83  * Convert GMT to local time. 
    84  */ 
    85 PJ_DEF(pj_status_t) pj_time_gmt_to_local(pj_time_val *tv); 
    86  
    87  
  • pjproject/trunk/pjlib/src/pj/pool_caching.c

    r232 r338  
    5858    cp->factory.dump_status = &cpool_dump_status; 
    5959 
    60     cp->pool = pj_pool_create_int(&cp->factory, "cachingpool", 128,  
     60    cp->pool = pj_pool_create_int(&cp->factory, "cachingpool", 256,  
    6161                                  0, NULL); 
    6262    i = pj_mutex_create_simple(cp->pool, "cachingpool", &cp->mutex); 
  • pjproject/trunk/pjlib/src/pj/sock_bsd.c

    r153 r338  
    8383 
    8484 
     85#if defined(PJ_SOCKADDR_HAS_LEN) && PJ_SOCKADDR_HAS_LEN!=0 
     86#   define SET_LEN(addr,len) (((pj_sockaddr*)(addr))->sa_zero_len=(len)) 
     87#   define RESET_LEN(addr)   (((pj_sockaddr*)(addr))->sa_zero_len=0) 
     88#else 
     89#   define SET_LEN(addr,len)  
     90#   define RESET_LEN(addr) 
     91#endif 
     92 
     93 
    8594/* 
    8695 * Convert 16-bit value from network byte order to host byte order. 
     
    191200                     (addr->sin_addr.s_addr=PJ_INADDR_NONE, PJ_EINVAL)); 
    192201 
     202    RESET_LEN(addr); 
    193203    addr->sin_family = AF_INET; 
    194204 
     
    227237    PJ_ASSERT_RETURN(addr, (addr->sin_addr.s_addr=PJ_INADDR_NONE, PJ_EINVAL)); 
    228238 
     239    RESET_LEN(addr); 
    229240    addr->sin_family = PJ_AF_INET; 
    230241    pj_sockaddr_in_set_port(addr, port); 
     
    347358    PJ_CHECK_STACK(); 
    348359 
     360    SET_LEN(&addr, sizeof(pj_sockaddr_in)); 
    349361    addr.sin_family = PJ_AF_INET; 
    350362    addr.sin_addr.s_addr = pj_htonl(addr32); 
     
    386398    if (getpeername(sock, (struct sockaddr*)addr, (socklen_t*)namelen) != 0) 
    387399        return PJ_RETURN_OS_ERROR(pj_get_native_netos_error()); 
    388     else 
    389         return PJ_SUCCESS; 
     400    else { 
     401        RESET_LEN(addr); 
     402        return PJ_SUCCESS; 
     403    } 
    390404} 
    391405 
     
    400414    if (getsockname(sock, (struct sockaddr*)addr, (socklen_t*)namelen) != 0) 
    401415        return PJ_RETURN_OS_ERROR(pj_get_native_netos_error()); 
    402     else 
    403         return PJ_SUCCESS; 
     416    else { 
     417        RESET_LEN(addr); 
     418        return PJ_SUCCESS; 
     419    } 
    404420} 
    405421 
     
    484500    if (*len < 0)  
    485501        return PJ_RETURN_OS_ERROR(pj_get_native_netos_error()); 
    486     else 
    487         return PJ_SUCCESS; 
     502    else { 
     503        RESET_LEN(from); 
     504        return PJ_SUCCESS; 
     505    } 
    488506} 
    489507 
     
    575593    PJ_ASSERT_RETURN(newsock != NULL, PJ_EINVAL); 
    576594 
     595#if defined(PJ_SOCKADDR_HAS_LEN) && PJ_SOCKADDR_HAS_LEN!=0 
     596    if (addr) { 
     597        SET_LEN(addr, *addrlen); 
     598    } 
     599#endif 
     600     
    577601    *newsock = accept(serverfd, (struct sockaddr*)addr, (socklen_t*)addrlen); 
    578602    if (*newsock==PJ_INVALID_SOCKET) 
    579603        return PJ_RETURN_OS_ERROR(pj_get_native_netos_error()); 
    580     else 
    581         return PJ_SUCCESS; 
     604    else { 
     605         
     606#if defined(PJ_SOCKADDR_HAS_LEN) && PJ_SOCKADDR_HAS_LEN!=0 
     607        if (addr) { 
     608            RESET_LEN(addr); 
     609        } 
     610#endif 
     611             
     612        return PJ_SUCCESS; 
     613    } 
    582614} 
    583615#endif  /* PJ_HAS_TCP */ 
  • pjproject/trunk/pjlib/src/pj/sock_select.c

    r66 r338  
    2525#if defined(PJ_HAS_STRING_H) && PJ_HAS_STRING_H!=0 
    2626#   include <string.h> 
     27#endif 
     28 
     29#if defined(PJ_HAS_SYS_TIME_H) && PJ_HAS_SYS_TIME_H!=0 
     30#   include <sys/time.h> 
    2731#endif 
    2832 
Note: See TracChangeset for help on using the changeset viewer.