Changeset 433
- Timestamp:
- May 10, 2006 7:24:40 PM (18 years ago)
- Location:
- pjproject/trunk
- Files:
-
- 8 added
- 31 edited
- 2 moved
Legend:
- Unmodified
- Added
- Removed
-
pjproject/trunk/README-configure
r432 r433 1 #2 # This file contains all possible values for the build.mak. Select3 # the appropriate settings, and put it in build.mak.4 #5 # (Just in case "./configure" fails to detect the appropriate values).6 #7 # Build configurations:8 #9 # MACHINE_NAME values:10 # - i386 (generic x86)11 # - sparc12 # - alpha13 #14 # OS_NAME values:15 # - win32 (generic windows)16 # - linux17 # - sunos18 #19 # CC_NAME values:20 # - gcc21 # - msvc22 #23 # HOST_NAME values:24 # - win32 (Windows command line)25 # - mingw (Windows, mingw)26 # - unix27 #28 1 29 # 30 # PalmOS 6 cross-compile, cygwin 31 # 32 #export MACHINE_NAME := m68k 33 #export OS_NAME := palmos 34 #export CC_NAME := gcc 35 #export HOST_NAME := mingw 2 Configuring the Build System 3 Update: 04 May 2006 36 4 37 #38 # Win32, mingw39 #40 #export MACHINE_NAME := i38641 #export OS_NAME := win3242 #export CC_NAME := gcc43 #export HOST_NAME := mingw44 5 45 # 46 # Linux i386, gcc 47 # 48 export MACHINE_NAME := i386 49 export OS_NAME := linux 50 export CC_NAME := gcc 51 export HOST_NAME := unix 6 1. Overview 7 8 The "configure" script in pjproject root directory is not an autoconf script, 9 but it's just a custom script to generate "build.mak" for the build system. 10 The "build.mak" file declares the following global Makefile variables: 52 11 53 # 54 # Linux KERNEL i386, gcc 55 # 56 #export MACHINE_NAME := i386 57 #export OS_NAME := linux-kernel 58 #export CC_NAME := gcc 59 #export HOST_NAME := unix 60 #export PJPROJECT_DIR := /usr/src/pjproject-0.3 61 ##export KERNEL_DIR = /usr/src/linux 62 #export KERNEL_DIR = /usr/src/uml/linux 63 #export KERNEL_ARCH = ARCH=um 12 MACHINE_NAME 13 The processor and hardware platform of the target. For each MACHINE_NAME, 14 there must be matching "m-*.mak" entry in "build/" subdirectory. For 15 example, when MACHINE_NAME is declared as "i386", then there must be 16 "m-i386.mak" file in "build/" subdirectory. 17 18 OS_NAME 19 Operating system name, determines which "os-*.mak" in "build/" dir to use. 64 20 65 # 66 # SunOS, sparc, gcc 67 # 68 #export MACHINE_NAME := sparc 69 #export OS_NAME := sunos 70 #export CC_NAME := gcc 71 #export HOST_NAME := unix 21 HOST_NAME 22 Build host name, determines which "host-*.mak" to use. 72 23 24 CC_NAME 25 Compiler name, determines which "cc-*.mak" to use. 26 27 TARGET_NAME 28 Determines suffix to be added to output files (for example, 29 "libpjsip-i386-linux-gcc.a"). The value normally is equal to 30 $(MACHINE_NAME)-$(OS_NAME)-$(CC_NAME), but it can contain any value. 31 32 CROSS_COMPILE 33 Determine the prefix to be applied when invoking build tools (for 34 example, "powerpc-rtems-"). The default is empty. 35 36 37 At present, the configure script CAN NOT be used for configuring cross 38 compilation. For cross compiling, you must create the "build.mak" file 39 manually. 40 41 42 2. Supported Hosts and Targets 43 44 The number of supported hosts and targets will (hopefully) increase over time. 45 See "build/" subdirectory for list of supported machines, OSes, hosts, and 46 compilers. 47 -
pjproject/trunk/build/cc-gcc.mak
r65 r433 1 1 export CC = $(CROSS_COMPILE)gcc -c 2 export AR = $(CROSS_COMPILE)ar r 2 export AR = $(CROSS_COMPILE)ar rv 3 3 export LD = $(CROSS_COMPILE)gcc 4 4 export LDOUT = -o -
pjproject/trunk/build/host-unix.mak
r65 r433 3 3 export HOST_RMR := rm -rf @@ 4 4 export HOST_RMDIR := rm -rf @@ 5 export HOST_MKDIR := mkdir @@5 export HOST_MKDIR := mkdir -p @@ 6 6 export HOST_EXE := 7 7 export HOST_PSEP := / -
pjproject/trunk/build/rules.mak
r431 r433 155 155 if test -f $$F; then \ 156 156 echo "$(OBJDIR)/" | tr -d '\n' >> $(DEP_FILE); \ 157 if gcc-M $(DEPFLAGS) $$F | sed '/^#/d' >> $(DEP_FILE); then \157 if $(CC_NAME) -M $(DEPFLAGS) $$F | sed '/^#/d' >> $(DEP_FILE); then \ 158 158 true; \ 159 159 else \ -
pjproject/trunk/configure
r431 r433 2 2 3 3 # 4 # Detect machine 4 # Detect machine, unless the choice has been made already. 5 5 # 6 MACHINE=`uname -p` 7 if echo $MACHINE | grep unknown > /dev/null; then 8 MACHINE=`uname -m` 9 fi; 6 if [ "$MACHINE" = "" ]; then 7 MACHINE=`uname -m` 8 fi 10 9 11 if echo $MACHINE | grep s parc> /dev/null; then10 if echo $MACHINE | grep sun4u > /dev/null; then 12 11 MACHINE_NAME=sparc 13 12 elif echo $MACHINE | grep i.86 > /dev/null; then … … 18 17 MACHINE_NAME=powerpc 19 18 else 20 echo "Unable to detect processor type ('uname - p' == '$MACHINE')"19 echo "Unable to detect processor type ('uname -m' == '$MACHINE')" 21 20 exit 1 22 21 fi 23 22 24 23 # 25 # Detect OS and host 24 # Detect OS and host, unless the choice has been made already 26 25 # 27 SYSTEM=`uname -s` 26 if [ "$SYSTEM" = "" ]; then 27 SYSTEM=`uname -s` 28 fi 29 28 30 29 31 if echo $SYSTEM | grep -i sunos > /dev/null; then … … 54 56 OS_NAME=darwinos 55 57 HOST_NAME=unix 58 elif echo $SYSTEM | grep -i rtems > /dev/null; then 59 OS_NAME=rtems 60 HOST_NAME=unix 56 61 else 57 62 echo "Unable to detect system type ('uname -s' == '$SYSTEM')" … … 60 65 61 66 # 62 # Detect gcc 67 # Detect gcc, unless it has been chosen already 63 68 # 64 if gcc --version 2>&1 > /dev/null; then 65 CC_NAME=gcc 66 else 67 echo "Unable to find gcc" 68 exit 1 69 fi 69 if [ "$CC_NAME" = "" ]; then 70 if gcc --version 2>&1 > /dev/null; then 71 CC_NAME=gcc 72 else 73 echo "Unable to find gcc" 74 exit 1 75 fi 76 fi 77 70 78 71 79 # 72 # TARGET80 # Specify TARGET_NAME, if not already choosen. 73 81 # 74 TARGET_NAME=$MACHINE_NAME-$OS_NAME-$CC_NAME 82 if [ "$TARGET_NAME" = "" ]; then 83 TARGET_NAME=$MACHINE_NAME-$OS_NAME-$CC_NAME 84 fi 75 85 76 86 … … 86 96 echo " CC_NAME = $CC_NAME" 87 97 echo " TARGET_NAME = $TARGET_NAME" 98 echo " CROSS_COMPILE= $CROSS_COMPILE" 88 99 echo " LINUX_POLL = $LINUX_POLL" 89 100 … … 94 105 echo "export CC_NAME := $CC_NAME" >> build.mak 95 106 echo "export TARGET_NAME := $TARGET_NAME" >> build.mak 107 echo "export CROSS_COMPILE := $CROSS_COMPILE" >> build.mak 96 108 echo "export LINUX_POLL := $LINUX_POLL" >> build.mak 97 109 -
pjproject/trunk/pjlib/include/pj/compat/os_darwinos.h
r338 r433 95 95 */ 96 96 typedef int socklen_t; 97 98 /* Set 1 if native sockaddr_in has sin_len member. 99 * Default: 0 100 */ 97 101 #define PJ_SOCKADDR_HAS_LEN 1 98 102 … … 106 110 #define PJ_IOQUEUE_MAX_HANDLES 1024 107 111 112 /** 113 * If this macro is set, it tells select I/O Queue that select() needs to 114 * be given correct value of nfds (i.e. largest fd + 1). This requires 115 * select ioqueue to re-scan the descriptors on each registration and 116 * unregistration. 117 * If this macro is not set, then ioqueue will always give FD_SETSIZE for 118 * nfds argument when calling select(). 119 * 120 * Default: 0 121 */ 122 #define PJ_SELECT_NEEDS_NFDS 0 123 124 /* If 1, use Read/Write mutex emulation for platforms that don't support it */ 125 #define PJ_EMULATE_RWMUTEX 0 126 127 /* If 1, pj_thread_create() should enforce the stack size when creating 128 * threads. 129 * Default: 0 (let OS decide the thread's stack size). 130 */ 131 #define PJ_THREAD_SET_STACK_SIZE 0 132 133 /* If 1, pj_thread_create() should allocate stack from the pool supplied. 134 * Default: 0 (let OS allocate memory for thread's stack). 135 */ 136 #define PJ_THREAD_ALLOCATE_STACK 0 137 108 138 109 139 #endif /* __PJ_COMPAT_OS_DARWINOS_H__ */ -
pjproject/trunk/pjlib/include/pj/compat/os_linux.h
r356 r433 55 55 56 56 #define PJ_SOCK_HAS_INET_ATON 1 57 58 /* Set 1 if native sockaddr_in has sin_len member. 59 * Default: 0 60 */ 57 61 #define PJ_SOCKADDR_HAS_LEN 0 62 63 /** 64 * If this macro is set, it tells select I/O Queue that select() needs to 65 * be given correct value of nfds (i.e. largest fd + 1). This requires 66 * select ioqueue to re-scan the descriptors on each registration and 67 * unregistration. 68 * If this macro is not set, then ioqueue will always give FD_SETSIZE for 69 * nfds argument when calling select(). 70 * 71 * Default: 0 72 */ 73 #define PJ_SELECT_NEEDS_NFDS 0 58 74 59 75 /* Is errno a good way to retrieve OS errors? … … 90 106 #define PJ_ATOMIC_VALUE_TYPE long 91 107 108 /* If 1, use Read/Write mutex emulation for platforms that don't support it */ 109 #define PJ_EMULATE_RWMUTEX 0 110 111 /* If 1, pj_thread_create() should enforce the stack size when creating 112 * threads. 113 * Default: 0 (let OS decide the thread's stack size). 114 */ 115 #define PJ_THREAD_SET_STACK_SIZE 0 116 117 /* If 1, pj_thread_create() should allocate stack from the pool supplied. 118 * Default: 0 (let OS allocate memory for thread's stack). 119 */ 120 #define PJ_THREAD_ALLOCATE_STACK 0 121 122 123 92 124 #endif /* __PJ_COMPAT_OS_LINUX_H__ */ 93 125 -
pjproject/trunk/pjlib/include/pj/compat/os_linux_kernel.h
r338 r433 55 55 56 56 #define PJ_SOCK_HAS_INET_ATON 0 57 58 /* Set 1 if native sockaddr_in has sin_len member. 59 * Default: 0 60 */ 57 61 #define PJ_SOCKADDR_HAS_LEN 0 58 62 … … 61 65 */ 62 66 #define PJ_HAS_SO_ERROR 1 67 68 /** 69 * If this macro is set, it tells select I/O Queue that select() needs to 70 * be given correct value of nfds (i.e. largest fd + 1). This requires 71 * select ioqueue to re-scan the descriptors on each registration and 72 * unregistration. 73 * If this macro is not set, then ioqueue will always give FD_SETSIZE for 74 * nfds argument when calling select(). 75 * 76 * Default: 0 77 */ 78 #define PJ_SELECT_NEEDS_NFDS 0 63 79 64 80 /* This value specifies the value set in errno by the OS when a non-blocking … … 105 121 #define PJ_THREAD_DESC_SIZE 128 106 122 123 /* If 1, use Read/Write mutex emulation for platforms that don't support it */ 124 #define PJ_EMULATE_RWMUTEX 0 125 126 /* If 1, pj_thread_create() should enforce the stack size when creating 127 * threads. 128 * Default: 0 (let OS decide the thread's stack size). 129 */ 130 #define PJ_THREAD_SET_STACK_SIZE 0 131 132 /* If 1, pj_thread_create() should allocate stack from the pool supplied. 133 * Default: 0 (let OS allocate memory for thread's stack). 134 */ 135 #define PJ_THREAD_ALLOCATE_STACK 0 136 137 138 107 139 #endif /* __PJ_COMPAT_OS_LINUX_KERNEL_H__ */ 108 140 -
pjproject/trunk/pjlib/include/pj/compat/os_palmos.h
r338 r433 53 53 54 54 #define PJ_SOCK_HAS_INET_ATON 0 55 56 /* Set 1 if native sockaddr_in has sin_len member. 57 * Default: 0 58 */ 55 59 #define PJ_SOCKADDR_HAS_LEN 0 60 61 /** 62 * If this macro is set, it tells select I/O Queue that select() needs to 63 * be given correct value of nfds (i.e. largest fd + 1). This requires 64 * select ioqueue to re-scan the descriptors on each registration and 65 * unregistration. 66 * If this macro is not set, then ioqueue will always give FD_SETSIZE for 67 * nfds argument when calling select(). 68 * 69 * Default: 0 70 */ 71 #define PJ_SELECT_NEEDS_NFDS 0 56 72 57 73 /* Is errno a good way to retrieve OS errors? … … 84 100 #define PJ_NATIVE_STRING_IS_UNICODE 0 85 101 102 /* If 1, use Read/Write mutex emulation for platforms that don't support it */ 103 #define PJ_EMULATE_RWMUTEX 1 104 105 /* If 1, pj_thread_create() should enforce the stack size when creating 106 * threads. 107 * Default: 0 (let OS decide the thread's stack size). 108 */ 109 #define PJ_THREAD_SET_STACK_SIZE 0 110 111 /* If 1, pj_thread_create() should allocate stack from the pool supplied. 112 * Default: 0 (let OS allocate memory for thread's stack). 113 */ 114 #define PJ_THREAD_ALLOCATE_STACK 0 115 116 86 117 #endif /* __PJ_COMPAT_OS_PALMOS_H__ */ 118 -
pjproject/trunk/pjlib/include/pj/compat/os_sunos.h
r338 r433 55 55 56 56 #define PJ_SOCK_HAS_INET_ATON 0 57 58 /* Set 1 if native sockaddr_in has sin_len member. 59 * Default: 0 60 */ 57 61 #define PJ_SOCKADDR_HAS_LEN 0 58 62 … … 76 80 #define PJ_BLOCKING_CONNECT_ERROR_VAL EINPROGRESS 77 81 82 /** 83 * If this macro is set, it tells select I/O Queue that select() needs to 84 * be given correct value of nfds (i.e. largest fd + 1). This requires 85 * select ioqueue to re-scan the descriptors on each registration and 86 * unregistration. 87 * If this macro is not set, then ioqueue will always give FD_SETSIZE for 88 * nfds argument when calling select(). 89 * 90 * Default: 0 91 */ 92 #define PJ_SELECT_NEEDS_NFDS 0 93 78 94 /* Default threading is enabled, unless it's overridden. */ 79 95 #ifndef PJ_HAS_THREADS … … 93 109 #define BSD_COMP 94 110 111 /* If 1, use Read/Write mutex emulation for platforms that don't support it */ 112 #define PJ_EMULATE_RWMUTEX 0 113 114 /* If 1, pj_thread_create() should enforce the stack size when creating 115 * threads. 116 * Default: 0 (let OS decide the thread's stack size). 117 */ 118 #define PJ_THREAD_SET_STACK_SIZE 0 119 120 /* If 1, pj_thread_create() should allocate stack from the pool supplied. 121 * Default: 0 (let OS allocate memory for thread's stack). 122 */ 123 #define PJ_THREAD_ALLOCATE_STACK 0 124 125 126 95 127 #endif /* __PJ_COMPAT_OS_SUNOS_H__ */ 96 128 -
pjproject/trunk/pjlib/include/pj/compat/os_win32.h
r338 r433 61 61 62 62 #define PJ_SOCK_HAS_INET_ATON 0 63 64 /* Set 1 if native sockaddr_in has sin_len member. 65 * Default: 0 66 */ 63 67 #define PJ_SOCKADDR_HAS_LEN 0 64 68 … … 82 86 #define PJ_BLOCKING_CONNECT_ERROR_VAL WSAEWOULDBLOCK 83 87 88 /** 89 * If this macro is set, it tells select I/O Queue that select() needs to 90 * be given correct value of nfds (i.e. largest fd + 1). This requires 91 * select ioqueue to re-scan the descriptors on each registration and 92 * unregistration. 93 * If this macro is not set, then ioqueue will always give FD_SETSIZE for 94 * nfds argument when calling select(). 95 * 96 * Default: 0 97 */ 98 #define PJ_SELECT_NEEDS_NFDS 0 99 84 100 /* Default threading is enabled, unless it's overridden. */ 85 101 #ifndef PJ_HAS_THREADS … … 96 112 #define PJ_ATOMIC_VALUE_TYPE long 97 113 114 /* If 1, use Read/Write mutex emulation for platforms that don't support it */ 115 #define PJ_EMULATE_RWMUTEX 1 116 117 /* If 1, pj_thread_create() should enforce the stack size when creating 118 * threads. 119 * Default: 0 (let OS decide the thread's stack size). 120 */ 121 #define PJ_THREAD_SET_STACK_SIZE 0 122 123 /* If 1, pj_thread_create() should allocate stack from the pool supplied. 124 * Default: 0 (let OS allocate memory for thread's stack). 125 */ 126 #define PJ_THREAD_ALLOCATE_STACK 0 127 128 98 129 #endif /* __PJ_COMPAT_OS_WIN32_H__ */ 130 -
pjproject/trunk/pjlib/include/pj/compat/os_win32_wince.h
r338 r433 59 59 60 60 #define PJ_SOCK_HAS_INET_ATON 0 61 62 /* Set 1 if native sockaddr_in has sin_len member. 63 * Default: 0 64 */ 61 65 #define PJ_SOCKADDR_HAS_LEN 0 62 66 … … 79 83 */ 80 84 #define PJ_BLOCKING_CONNECT_ERROR_VAL WSAEWOULDBLOCK 85 86 /** 87 * If this macro is set, it tells select I/O Queue that select() needs to 88 * be given correct value of nfds (i.e. largest fd + 1). This requires 89 * select ioqueue to re-scan the descriptors on each registration and 90 * unregistration. 91 * If this macro is not set, then ioqueue will always give FD_SETSIZE for 92 * nfds argument when calling select(). 93 * 94 * Default: 0 95 */ 96 #define PJ_SELECT_NEEDS_NFDS 0 81 97 82 98 /* Default threading is enabled, unless it's overridden. */ … … 103 119 #define PJ_NATIVE_STRING_IS_UNICODE 1 104 120 121 /* If 1, use Read/Write mutex emulation for platforms that don't support it */ 122 #define PJ_EMULATE_RWMUTEX 1 123 124 /* If 1, pj_thread_create() should enforce the stack size when creating 125 * threads. 126 * Default: 0 (let OS decide the thread's stack size). 127 */ 128 #define PJ_THREAD_SET_STACK_SIZE 0 129 130 /* If 1, pj_thread_create() should allocate stack from the pool supplied. 131 * Default: 0 (let OS allocate memory for thread's stack). 132 */ 133 #define PJ_THREAD_ALLOCATE_STACK 0 134 135 105 136 #endif /* __PJ_COMPAT_OS_WIN32_WINCE_H__ */ 106 137 -
pjproject/trunk/pjlib/include/pj/config.h
r364 r433 54 54 #elif defined(PJ_DARWINOS) && PJ_DARWINOS!=0 55 55 # include <pj/compat/os_darwinos.h> 56 #elif defined(PJ_RTEMS) && PJ_RTEMS!=0 57 # include <pj/compat/os_rtems.h> 56 58 #else 57 59 # error "Please specify target os." … … 224 226 225 227 /** 228 * Specify this as \a stack_size argument in #pj_thread_create() to specify 229 * that thread should use default stack size for the current platform. 230 * 231 * Default: 8192 232 */ 233 #ifndef PJ_THREAD_DEFAULT_STACK_SIZE 234 # define PJ_THREAD_DEFAULT_STACK_SIZE 8192 235 #endif 236 237 238 /** 226 239 * Do we have alternate pool implementation? 227 240 * … … 557 570 #endif 558 571 559 572 #if !defined(PJ_EMULATE_RWMUTEX) 573 # error "PJ_EMULATE_RWMUTEX should be defined in compat/os_xx.h" 574 #endif 575 576 #if !defined(PJ_THREAD_SET_STACK_SIZE) 577 # error "PJ_THREAD_SET_STACK_SIZE should be defined in compat/os_xx.h" 578 #endif 579 580 #if !defined(PJ_THREAD_ALLOCATE_STACK) 581 # error "PJ_THREAD_ALLOCATE_STACK should be defined in compat/os_xx.h" 582 #endif 560 583 561 584 PJ_BEGIN_DECL -
pjproject/trunk/pjlib/include/pj/os.h
r228 r433 58 58 } pj_thread_create_flags; 59 59 60 61 /**62 * Specify this as \a stack_size argument in #pj_thread_create() to specify63 * that thread should use default stack size for the current platform.64 */65 #define PJ_THREAD_DEFAULT_STACK_SIZE 066 60 67 61 /** … … 162 156 163 157 /** 164 * Join thread. 165 * This function will block the caller thread until the specified thread exits. 158 * Join thread, and block the caller thread until the specified thread exits. 159 * If the specified thread has already been dead, or it does not exist, 160 * the function will return immediately with successfull status. 166 161 * 167 162 * @param thread The thread handle. 168 163 * 169 * @return zeroon success.164 * @return PJ_SUCCESS on success. 170 165 */ 171 166 PJ_DECL(pj_status_t) pj_thread_join(pj_thread_t *thread); -
pjproject/trunk/pjlib/src/pj/hash.c
r127 r433 50 50 51 51 52 PJ_DEF(pj_uint32_t) pj_hash_calc(pj_uint32_t hash, const void *key, unsigned keylen) 52 PJ_DEF(pj_uint32_t) pj_hash_calc(pj_uint32_t hash, const void *key, 53 unsigned keylen) 53 54 { 54 55 PJ_CHECK_STACK(); … … 57 58 const unsigned char *p = key; 58 59 for ( ; *p; ++p ) { 59 hash = hash * PJ_HASH_MULTIPLIER+ *p;60 hash = (hash * PJ_HASH_MULTIPLIER) + *p; 60 61 } 61 62 } else { … … 63 64 *end = p + keylen; 64 65 for ( ; p!=end; ++p) { 65 hash = hash * PJ_HASH_MULTIPLIER+ *p;66 hash = (hash * PJ_HASH_MULTIPLIER) + *p; 66 67 } 67 68 } -
pjproject/trunk/pjlib/src/pj/ioqueue_common_abs.c
r365 r433 238 238 239 239 gp_rc = getpeername(h->fd, (struct sockaddr*)&addr, &addrlen); 240 bytes_transfered = gp_rc;240 bytes_transfered = (gp_rc < 0) ? gp_rc : -gp_rc; 241 241 } 242 242 #endif -
pjproject/trunk/pjlib/src/pj/ioqueue_select.c
r365 r433 94 94 #define VALIDATE_FD_SET 0 95 95 96 #if 0 97 # define TRACE__(args) PJ_LOG(3,args) 98 #else 99 # define TRACE__(args) 100 #endif 101 96 102 /* 97 103 * This describes each key. … … 109 115 DECLARE_COMMON_IOQUEUE 110 116 111 unsigned max, count; 112 pj_ioqueue_key_t active_list; 117 unsigned max, count; /* Max and current key count */ 118 int nfds; /* The largest fd value (for select)*/ 119 pj_ioqueue_key_t active_list; /* List of active keys. */ 113 120 pj_fd_set_t rfdset; 114 121 pj_fd_set_t wfdset; … … 136 143 return "select"; 137 144 } 145 146 /* 147 * Scan the socket descriptor sets for the largest descriptor. 148 * This value is needed by select(). 149 */ 150 #if defined(PJ_SELECT_NEEDS_NFDS) && PJ_SELECT_NEEDS_NFDS!=0 151 static void rescan_fdset(pj_ioqueue_t *ioqueue) 152 { 153 pj_ioqueue_key_t *key = ioqueue->active_list.next; 154 int max = 0; 155 156 while (key != &ioqueue->active_list) { 157 if (key->fd > max) 158 max = key->fd; 159 key = key->next; 160 } 161 162 ioqueue->nfds = max; 163 } 164 #else 165 static void rescan_fdset(pj_ioqueue_t *ioqueue) 166 { 167 ioqueue->nfds = FD_SETSIZE-1; 168 } 169 #endif 170 138 171 139 172 /* … … 172 205 #endif 173 206 pj_list_init(&ioqueue->active_list); 207 208 rescan_fdset(ioqueue); 174 209 175 210 #if PJ_IOQUEUE_HAS_SAFE_UNREG … … 333 368 ++ioqueue->count; 334 369 370 /* Rescan fdset to get max descriptor */ 371 rescan_fdset(ioqueue); 372 335 373 on_return: 336 374 /* On error, socket may be left in non-blocking mode. */ … … 369 407 pj_list_erase(key); 370 408 pj_list_push_back(&key->ioqueue->closing_list, key); 409 /* Rescan fdset to get max descriptor */ 410 rescan_fdset(key->ioqueue); 371 411 pj_lock_release(key->ioqueue->lock); 372 412 } … … 612 652 #endif 613 653 pj_lock_release(ioqueue->lock); 654 TRACE__((THIS_FILE, " poll: no fd is set")); 614 655 if (timeout) 615 656 pj_thread_sleep(PJ_TIME_VAL_MSEC(*timeout)); … … 633 674 pj_lock_release(ioqueue->lock); 634 675 635 count = pj_sock_select(FD_SETSIZE, &rfdset, &wfdset, &xfdset, timeout); 676 count = pj_sock_select(ioqueue->nfds+1, &rfdset, &wfdset, &xfdset, 677 timeout); 636 678 637 679 if (count <= 0) -
pjproject/trunk/pjlib/src/pj/os_core_unix.c
r338 r433 17 17 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 18 18 */ 19 /* 20 * Contributors: 21 * - Thanks for Zetron, Inc. (Phil Torre, ptorre@zetron.com) for donating 22 * the RTEMS port. 23 */ 19 24 #define _GNU_SOURCE 20 25 #include <pj/os.h> … … 154 159 #endif 155 160 156 PJ_LOG(4,(THIS_FILE, "pjlib %s for Unixinitialized",161 PJ_LOG(4,(THIS_FILE, "pjlib %s for POSIX initialized", 157 162 PJ_VERSION)); 158 163 … … 197 202 //*thread_ptr = (pj_thread_t*)pj_thread_local_get (thread_tls_id); 198 203 //return PJ_SUCCESS; 204 PJ_LOG(4,(THIS_FILE, "Info: possibly re-registering existing " 205 "thread")); 199 206 } 200 207 … … 282 289 /* Done. */ 283 290 PJ_LOG(6,(rec->obj_name, "Thread quitting")); 291 284 292 return result; 285 293 } … … 299 307 #if PJ_HAS_THREADS 300 308 pj_thread_t *rec; 309 pthread_attr_t thread_attr; 310 void *stack_addr; 301 311 int rc; 312 313 PJ_UNUSED_ARG(stack_addr); 302 314 303 315 PJ_CHECK_STACK(); … … 306 318 /* Create thread record and assign name for the thread */ 307 319 rec = (struct pj_thread_t*) pj_pool_zalloc(pool, sizeof(pj_thread_t)); 308 if (!rec) 309 return PJ_ENOMEM; 320 PJ_ASSERT_RETURN(rec, PJ_ENOMEM); 310 321 311 322 /* Set name. */ … … 320 331 } 321 332 333 /* Set default stack size */ 334 if (stack_size == 0) 335 stack_size = PJ_THREAD_DEFAULT_STACK_SIZE; 336 322 337 #if defined(PJ_OS_HAS_CHECK_STACK) && PJ_OS_HAS_CHECK_STACK!=0 323 rec->stk_size = stack_size ? stack_size : 0xFFFFFFFFUL;338 rec->stk_size = stack_size; 324 339 rec->stk_max_usage = 0; 325 340 #endif … … 328 343 if (flags & PJ_THREAD_SUSPENDED) { 329 344 rc = pj_mutex_create_simple(pool, NULL, &rec->suspended_mutex); 330 if (rc != PJ_SUCCESS) 345 if (rc != PJ_SUCCESS) { 331 346 return rc; 347 } 332 348 333 349 pj_mutex_lock(rec->suspended_mutex); … … 336 352 } 337 353 338 PJ_LOG(6, (rec->obj_name, "Thread created")); 354 355 /* Init thread attributes */ 356 pthread_attr_init(&thread_attr); 357 358 #if defined(PJ_THREAD_SET_STACK_SIZE) && PJ_THREAD_SET_STACK_SIZE!=0 359 /* Set thread's stack size */ 360 rc = pthread_attr_setstacksize(&thread_attr, stack_size); 361 if (rc != 0) 362 return PJ_RETURN_OS_ERROR(rc); 363 #endif /* PJ_THREAD_SET_STACK_SIZE */ 364 365 366 #if defined(PJ_THREAD_ALLOCATE_STACK) && PJ_THREAD_ALLOCATE_STACK!=0 367 /* Allocate memory for the stack */ 368 stack_addr = pj_pool_alloc(pool, stack_size); 369 PJ_ASSERT_RETURN(stack_addr, PJ_ENOMEM); 370 371 rc = pthread_attr_setstackaddr(&thread_attr, stack_addr); 372 if (rc != 0) 373 return PJ_RETURN_OS_ERROR(rc); 374 #endif /* PJ_THREAD_ALLOCATE_STACK */ 375 339 376 340 377 /* Create the thread. */ 341 378 rec->proc = proc; 342 379 rec->arg = arg; 343 rc = pthread_create( &rec->thread, NULL,thread_main, rec);344 if (rc != 0) 380 rc = pthread_create( &rec->thread, &thread_attr, &thread_main, rec); 381 if (rc != 0) { 345 382 return PJ_RETURN_OS_ERROR(rc); 383 } 346 384 347 385 *ptr_thread = rec; 386 387 PJ_LOG(6, (rec->obj_name, "Thread created")); 348 388 return PJ_SUCCESS; 349 389 #else … … 424 464 if (result == 0) 425 465 return PJ_SUCCESS; 426 else 427 return PJ_RETURN_OS_ERROR(result); 466 else { 467 /* Calling pthread_join() on a thread that no longer exists and 468 * getting back ESRCH isn't an error (in this context). 469 * Thanks Phil Torre <ptorre@zetron.com>. 470 */ 471 return result==ESRCH ? PJ_SUCCESS : PJ_RETURN_OS_ERROR(result); 472 } 428 473 #else 429 474 PJ_CHECK_STACK(); … … 438 483 PJ_DEF(pj_status_t) pj_thread_destroy(pj_thread_t *p) 439 484 { 440 /* This function is used to destroy thread handle in other platforms. 441 * I suppose there's nothing to do here.. 442 */ 443 PJ_CHECK_STACK(); 485 PJ_CHECK_STACK(); 486 487 /* Destroy mutex used to suspend thread */ 488 if (p->suspended_mutex) { 489 pj_mutex_destroy(p->suspended_mutex); 490 p->suspended_mutex = NULL; 491 } 492 444 493 return PJ_SUCCESS; 445 494 } … … 450 499 PJ_DEF(pj_status_t) pj_thread_sleep(unsigned msec) 451 500 { 452 PJ_CHECK_STACK(); 453 return usleep(msec * 1000); 501 /* TODO: should change this to something like PJ_OS_HAS_NANOSLEEP */ 502 #if defined(PJ_RTEMS) && PJ_RTEMS!=0 503 enum { NANOSEC_PER_MSEC = 1000000 }; 504 struct timespec req; 505 506 PJ_CHECK_STACK(); 507 req.tv_sec = msec / 1000; 508 req.tv_nsec = (msec % 1000) * NANOSEC_PER_MSEC; 509 510 if (nanosleep(&req, NULL) == 0) 511 return PJ_SUCCESS; 512 513 return PJ_RETURN_OS_ERROR(pj_get_native_os_error()); 514 #else 515 PJ_CHECK_STACK(); 516 if (usleep(msec * 1000) == 0) 517 return PJ_SUCCESS; 518 519 return PJ_RETURN_OS_ERROR(pj_get_native_os_error()); 520 #endif /* PJ_RTEMS */ 454 521 } 455 522 … … 514 581 pj_status_t rc; 515 582 pj_atomic_t *atomic_var = pj_pool_calloc(pool, 1, sizeof(pj_atomic_t)); 516 if (!atomic_var) 517 return PJ_ENOMEM; 583 PJ_ASSERT_RETURN(atomic_var, PJ_ENOMEM); 518 584 519 585 #if PJ_HAS_THREADS … … 766 832 PJ_CHECK_STACK(); 767 833 768 pthread_mutexattr_init(&attr); 834 rc = pthread_mutexattr_init(&attr); 835 if (rc != 0) 836 return PJ_RETURN_OS_ERROR(rc); 769 837 770 838 if (type == PJ_MUTEX_SIMPLE) { … … 772 840 extern int pthread_mutexattr_settype(pthread_mutexattr_t*,int); 773 841 rc = pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_FAST_NP); 842 #elif defined(PJ_RTEMS) && PJ_RTEMS!=0 843 /* Nothing to do, default is simple */ 774 844 #else 775 845 rc = pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_NORMAL); … … 779 849 extern int pthread_mutexattr_settype(pthread_mutexattr_t*,int); 780 850 rc = pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_RECURSIVE_NP); 851 #elif defined(PJ_RTEMS) && PJ_RTEMS!=0 852 // Phil Torre <ptorre@zetron.com>: 853 // The RTEMS implementation of POSIX mutexes doesn't include 854 // pthread_mutexattr_settype(), so what follows is a hack 855 // until I get RTEMS patched to support the set/get functions. 856 PJ_TODO(FIX_RTEMS_RECURSIVE_MUTEX_TYPE) 857 attr.recursive = 1; 781 858 #else 782 859 rc = pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_RECURSIVE); … … 832 909 833 910 mutex = pj_pool_alloc(pool, sizeof(*mutex)); 834 if (!mutex) return PJ_ENOMEM;911 PJ_ASSERT_RETURN(mutex, PJ_ENOMEM); 835 912 836 913 if ((rc=init_mutex(mutex, name, type)) != PJ_SUCCESS) … … 1003 1080 1004 1081 /////////////////////////////////////////////////////////////////////////////// 1082 /* 1083 * Include Read/Write mutex emulation for POSIX platforms that lack it (e.g. 1084 * RTEMS). Otherwise use POSIX rwlock. 1085 */ 1086 #if defined(PJ_EMULATE_RWMUTEX) && PJ_EMULATE_RWMUTEX!=0 1087 # include "os_rwmutex.c" 1088 #else 1005 1089 struct pj_rwmutex_t 1006 1090 { … … 1095 1179 return PJ_SUCCESS; 1096 1180 } 1181 1182 #endif /* PJ_EMULATE_RWMUTEX */ 1183 1097 1184 1098 1185 /////////////////////////////////////////////////////////////////////////////// … … 1114 1201 PJ_ASSERT_RETURN(pool != NULL && ptr_sem != NULL, PJ_EINVAL); 1115 1202 1116 sem = pj_pool_alloc(pool, sizeof(*sem)); 1117 if (!sem) return PJ_ENOMEM;1203 sem = pj_pool_alloc(pool, sizeof(*sem)); 1204 PJ_ASSERT_RETURN(sem, PJ_ENOMEM); 1118 1205 1119 1206 if (sem_init( &sem->sem, 0, initial) != 0) -
pjproject/trunk/pjlib/src/pj/os_time_unix.c
r338 r433 18 18 */ 19 19 #include <pj/os.h> 20 #include <pj/errno.h> 20 21 #include <pj/compat/time.h> 21 22 … … 24 25 #endif 25 26 27 #include <errno.h> 28 26 29 /////////////////////////////////////////////////////////////////////////////// 27 30 28 31 PJ_DEF(pj_status_t) pj_gettimeofday(pj_time_val *p_tv) 29 32 { 30 struct timeval tv; 33 struct timeval the_time; 34 int rc; 31 35 32 36 PJ_CHECK_STACK(); 33 37 34 gettimeofday(&tv, NULL); 35 p_tv->sec = tv.tv_sec; 36 p_tv->msec = tv.tv_usec / 1000; 38 rc = gettimeofday(&the_time, NULL); 39 if (rc != 0) 40 return PJ_RETURN_OS_ERROR(pj_get_native_os_error()); 41 42 p_tv->sec = the_time.tv_sec; 43 p_tv->msec = the_time.tv_usec / 1000; 37 44 return PJ_SUCCESS; 38 45 } -
pjproject/trunk/pjlib/src/pj/pool.c
r364 r433 174 174 PJ_CHECK_STACK(); 175 175 176 /* If callback is NULL, set calback from the policy */ 177 if (callback == NULL) 178 callback = f->policy.callback; 179 180 /* Allocate initial block */ 176 181 buffer = (*f->policy.block_alloc)(f, initial_size); 177 182 if (!buffer) -
pjproject/trunk/pjlib/src/pj/sock_bsd.c
r348 r433 27 27 /* 28 28 * Address families conversion. 29 * The values here are indexed based on pj_addr_family -0xFF00.29 * The values here are indexed based on pj_addr_family. 30 30 */ 31 31 const pj_uint16_t PJ_AF_UNIX = AF_UNIX; … … 45 45 /* 46 46 * Socket types conversion. 47 * The values here are indexed based on pj_sock_type -0xFF0047 * The values here are indexed based on pj_sock_type 48 48 */ 49 49 const pj_uint16_t PJ_SOCK_STREAM = SOCK_STREAM; … … 347 347 PJ_CHECK_STACK(); 348 348 349 PJ_ASSERT_RETURN(addr && len > 0, PJ_EINVAL);349 PJ_ASSERT_RETURN(addr && len >= sizeof(struct sockaddr_in), PJ_EINVAL); 350 350 351 351 if (bind(sock, (struct sockaddr*)addr, len) != 0) -
pjproject/trunk/pjlib/src/pjlib-test/ioq_tcp.c
r65 r433 344 344 } 345 345 346 if (status > pending_op) { 347 PJ_LOG(3,(THIS_FILE, 348 "...error: pj_ioqueue_poll() returned %d " 349 "(only expecting %d)", 350 status, pending_op)); 351 return -52; 352 } 346 353 pending_op -= status; 347 354 … … 479 486 } 480 487 488 if (status > pending_op) { 489 PJ_LOG(3,(THIS_FILE, 490 "...error: pj_ioqueue_poll() returned %d " 491 "(only expecting %d)", 492 status, pending_op)); 493 return -552; 494 } 495 481 496 pending_op -= status; 482 497 if (pending_op == 0) { -
pjproject/trunk/pjlib/src/pjlib-test/ioq_udp.c
r365 r433 42 42 #define PORT 51233 43 43 #define LOOP 100 44 ///#define LOOP 2 44 45 #define BUF_MIN_SIZE 32 45 46 #define BUF_MAX_SIZE 2048 … … 50 51 #undef TRACE_ 51 52 #define TRACE_(msg) PJ_LOG(3,(THIS_FILE,"....." msg)) 53 54 #if 0 55 # define TRACE__(args) PJ_LOG(3,args) 56 #else 57 # define TRACE__(args) 58 #endif 59 52 60 53 61 static pj_ssize_t callback_read_size, … … 70 78 callback_read_op = op_key; 71 79 callback_read_size = bytes_read; 80 TRACE__((THIS_FILE, " callback_read_key = %p, bytes=%d", 81 key, bytes_read)); 72 82 } 73 83 … … 255 265 status=-45; goto on_error; 256 266 } else if (rc < 0) { 257 app_perror("...ERROR in ioqueue_poll()", rc);267 app_perror("...ERROR in ioqueue_poll()", -rc); 258 268 status=-50; goto on_error; 259 269 } … … 493 503 pj_ioqueue_key_t **key; 494 504 pj_status_t rc; 495 int count, i; 505 int count, i; /* must be signed */ 496 506 497 507 PJ_LOG(3,(THIS_FILE,"...testing with so many handles")); … … 534 544 /* Now deregister and close all handles. */ 535 545 536 for (i=0; i<count; ++i) { 546 /* NOTE for RTEMS: 547 * It seems that the order of close(sock) is pretty important here. 548 * If we close the sockets with the same order as when they were created, 549 * RTEMS doesn't seem to reuse the sockets, thus next socket created 550 * will have descriptor higher than the last socket created. 551 * If we close the sockets in the reverse order, then the descriptor will 552 * get reused. 553 * This used to cause problem with select ioqueue, since the ioqueue 554 * always gives FD_SETSIZE for the first select() argument. This ioqueue 555 * behavior can be changed with setting PJ_SELECT_NEEDS_NFDS macro. 556 */ 557 for (i=count-1; i>=0; --i) { 558 ///for (i=0; i<count; ++i) { 537 559 rc = pj_ioqueue_unregister(key[i]); 538 560 if (rc != PJ_SUCCESS) { … … 571 593 pj_ioqueue_key_t *skey, *ckey, *key; 572 594 pj_timestamp t1, t2, t_elapsed; 573 int rc=0, i; 595 int rc=0, i; /* i must be signed */ 574 596 pj_str_t temp; 575 char errbuf[128]; 597 char errbuf[PJ_ERR_MSG_SIZE]; 598 599 TRACE__((THIS_FILE, " bench test %d", inactive_sock_count)); 576 600 577 601 // Create pool. … … 692 716 &addr, sizeof(addr)); 693 717 if (rc != PJ_SUCCESS && rc != PJ_EPENDING) { 694 app_perror("...error: pj_ioqueue_write()", bytes);718 app_perror("...error: pj_ioqueue_write()", rc); 695 719 break; 720 } 721 if (rc == PJ_SUCCESS) { 722 if (bytes < 0) { 723 app_perror("...error: pj_ioqueue_sendto()", -bytes); 724 break; 725 } 696 726 } 697 727 … … 702 732 callback_read_key = NULL; 703 733 callback_read_size = 0; 734 TRACE__((THIS_FILE, " waiting for key = %p", skey)); 704 735 do { 705 rc = pj_ioqueue_poll(ioque, NULL); 736 pj_time_val timeout = { 1, 0 }; 737 rc = pj_ioqueue_poll(ioque, &timeout); 738 TRACE__((THIS_FILE, " poll rc=%d", rc)); 706 739 } while (rc >= 0 && callback_read_key != skey); 707 740 … … 750 783 751 784 // Cleaning up. 752 for (i= 0; i<inactive_sock_count; ++i)785 for (i=inactive_sock_count-1; i>=0; --i) { 753 786 pj_sock_close(inactive_sock[i]); 787 } 788 754 789 pj_sock_close(ssock); 755 790 pj_sock_close(csock); 791 756 792 757 793 pj_ioqueue_destroy(ioque); -
pjproject/trunk/pjlib/src/pjlib-test/pool_perf.c
r65 r433 33 33 #define COUNT 1024 34 34 static unsigned sizes[COUNT]; 35 static char *p[COUNT]; 35 36 #define MIN_SIZE 4 36 37 #define MAX_SIZE 512 37 38 static unsigned total_size; 39 38 40 39 41 static int pool_test_pool() … … 46 48 for (i=0; i<COUNT; ++i) { 47 49 char *p; 48 if ( (p=(char*)pj_pool_alloc(pool, sizes[i])) == NULL) 50 if ( (p=(char*)pj_pool_alloc(pool, sizes[i])) == NULL) { 51 PJ_LOG(3,(THIS_FILE," error: pool failed to allocate %d bytes", 52 sizes[i])); 53 pj_pool_release(pool); 49 54 return -1; 55 } 50 56 *p = '\0'; 51 57 } … … 57 63 static int pool_test_malloc_free() 58 64 { 59 char *p[COUNT]; 60 int i; 65 int i; /* must be signed */ 61 66 62 67 for (i=0; i<COUNT; ++i) { 63 68 p[i] = (char*)malloc(sizes[i]); 64 69 if (!p[i]) { 65 // Don't care for memory leak in this test 70 PJ_LOG(3,(THIS_FILE," error: malloc failed to allocate %d bytes", 71 sizes[i])); 72 --i; 73 while (i >= 0) 74 free(p[i]), --i; 66 75 return -1; 67 76 } … … 83 92 pj_uint32_t best, worst; 84 93 85 / / Initialize sizes.94 /* Initialize size of chunks to allocate in for the test. */ 86 95 for (i=0; i<COUNT; ++i) { 87 sizes[i] = MIN_SIZE + pj_rand() % MAX_SIZE;96 sizes[i] = MIN_SIZE + (pj_rand() % MAX_SIZE); 88 97 total_size += sizes[i]; 89 98 } 90 99 100 /* Add some more for pool admin area */ 101 total_size += 512; 102 91 103 PJ_LOG(3, (THIS_FILE, "Benchmarking pool..")); 92 104 93 / / Warmup105 /* Warmup */ 94 106 pool_test_pool(); 95 107 pool_test_malloc_free(); … … 118 130 } 119 131 120 PJ_LOG(4, (THIS_FILE, "..LOOP count: %u",LOOP));121 PJ_LOG(4, (THIS_FILE, "..number of alloc/dealloc per loop: %u",COUNT));122 PJ_LOG(4, (THIS_FILE, "..pool allocation/deallocation time: %u",pool_time));123 PJ_LOG(4, (THIS_FILE, "..malloc/free time: %u",malloc_time));124 PJ_LOG(4, (THIS_FILE, "..pool again, second invocation: %u",pool_time2));132 PJ_LOG(4,(THIS_FILE,"..LOOP count: %u",LOOP)); 133 PJ_LOG(4,(THIS_FILE,"..number of alloc/dealloc per loop: %u",COUNT)); 134 PJ_LOG(4,(THIS_FILE,"..pool allocation/deallocation time: %u",pool_time)); 135 PJ_LOG(4,(THIS_FILE,"..malloc/free time: %u",malloc_time)); 136 PJ_LOG(4,(THIS_FILE,"..pool again, second invocation: %u",pool_time2)); 125 137 126 138 if (pool_time2==0) pool_time2=1; … … 130 142 best = pool_time2, worst = pool_time; 131 143 132 PJ_LOG(3, (THIS_FILE, ".. malloc Speedupbest=%dx, worst=%dx",144 PJ_LOG(3, (THIS_FILE, "..pool speedup over malloc best=%dx, worst=%dx", 133 145 (int)(malloc_time/best), 134 146 (int)(malloc_time/worst))); -
pjproject/trunk/pjlib/src/pjlib-test/sock.c
r65 r433 64 64 #define TCP_PORT (UDP_PORT+10) 65 65 #define BIG_DATA_LEN 9000 66 #define ADDRESS "127.0.0.1" 67 #define A0 127 68 #define A1 0 69 #define A2 0 70 #define A3 1 71 66 72 67 73 static char bigdata[BIG_DATA_LEN]; … … 70 76 static int format_test(void) 71 77 { 72 pj_str_t s = pj_str( "127.0.0.1");73 char *p;78 pj_str_t s = pj_str(ADDRESS); 79 unsigned char *p; 74 80 pj_in_addr addr; 75 81 const pj_str_t *hostname; … … 82 88 83 89 /* Check the result. */ 84 p = (char*)&addr; 85 if (p[0]!=127 || p[1]!=0 || p[2]!=0 || p[3]!=1) 90 p = (unsigned char*)&addr; 91 if (p[0]!=A0 || p[1]!=A1 || p[2]!=A2 || p[3]!=A3) { 92 PJ_LOG(3,("test", " error: mismatched address. p0=%d, p1=%d, " 93 "p2=%d, p3=%d", p[0] & 0xFF, p[1] & 0xFF, 94 p[2] & 0xFF, p[3] & 0xFF)); 86 95 return -15; 96 } 87 97 88 98 /* pj_inet_ntoa() */ … … 98 108 if (!hostname || !hostname->ptr || !hostname->slen) 99 109 return -40; 110 111 PJ_LOG(3,("test", "....hostname is %.*s", 112 (int)hostname->slen, hostname->ptr)); 100 113 101 114 /* pj_gethostaddr() */ … … 314 327 dstaddr.sin_family = PJ_AF_INET; 315 328 dstaddr.sin_port = pj_htons(UDP_PORT); 316 dstaddr.sin_addr = pj_inet_addr(pj_cstr(&s, "127.0.0.1"));329 dstaddr.sin_addr = pj_inet_addr(pj_cstr(&s, ADDRESS)); 317 330 318 331 if ((rc=pj_sock_bind(ss, &dstaddr, sizeof(dstaddr))) != 0) { 319 app_perror("...bind error ", rc);332 app_perror("...bind error udp:"ADDRESS, rc); 320 333 rc = -120; goto on_error; 321 334 } … … 325 338 srcaddr.sin_family = PJ_AF_INET; 326 339 srcaddr.sin_port = pj_htons(UDP_PORT-1); 327 srcaddr.sin_addr = pj_inet_addr(pj_cstr(&s, "127.0.0.1"));340 srcaddr.sin_addr = pj_inet_addr(pj_cstr(&s, ADDRESS)); 328 341 329 342 if ((rc=pj_sock_bind(cs, &srcaddr, sizeof(srcaddr))) != 0) { -
pjproject/trunk/pjlib/src/pjlib-test/test.c
r365 r433 41 41 PJ_LOG_HAS_MICRO_SEC; 42 42 43 int null_func() 44 { 45 return 0; 46 } 47 43 48 int test_inner(void) 44 49 { … … 59 64 } 60 65 61 pj_dump_config();66 //pj_dump_config(); 62 67 pj_caching_pool_init( &caching_pool, &pj_pool_factory_default_policy, 0 ); 63 68 64 69 #if INCLUDE_ERRNO_TEST 65 70 DO_TEST( errno_test() ); 66 #endif67 68 #if INCLUDE_TIMESTAMP_TEST69 DO_TEST( timestamp_test() );70 71 #endif 71 72 … … 100 101 #if INCLUDE_RBTREE_TEST 101 102 DO_TEST( rbtree_test() ); 103 #endif 104 105 #if INCLUDE_TIMESTAMP_TEST 106 DO_TEST( timestamp_test() ); 102 107 #endif 103 108 -
pjproject/trunk/pjlib/src/pjlib-test/test.h
r365 r433 22 22 #include <pj/types.h> 23 23 24 #define GROUP_LIBC 125 #define GROUP_OS 126 #define GROUP_DATA_STRUCTURE 127 #define GROUP_NETWORK 128 #define GROUP_FILE 124 #define GROUP_LIBC 0 25 #define GROUP_OS 0 26 #define GROUP_DATA_STRUCTURE 0 27 #define GROUP_NETWORK 0 28 #define GROUP_FILE 0 29 29 30 30 #define INCLUDE_ERRNO_TEST GROUP_LIBC … … 49 49 #define INCLUDE_TCP_IOQUEUE_TEST GROUP_NETWORK 50 50 #define INCLUDE_IOQUEUE_PERF_TEST GROUP_NETWORK 51 #define INCLUDE_IOQUEUE_UNREG_TEST GROUP_NETWORK51 #define INCLUDE_IOQUEUE_UNREG_TEST 1 // GROUP_NETWORK 52 52 #define INCLUDE_FILE_TEST GROUP_FILE 53 53 … … 104 104 extern pj_status_t app_socketpair(int family, int type, int protocol, 105 105 pj_sock_t *server, pj_sock_t *client); 106 extern int null_func(void); 106 107 107 108 //#define TRACE_(expr) PJ_LOG(3,expr) 108 109 #define TRACE_(expr) 110 #define HALT(msg) { PJ_LOG(3,(THIS_FILE,"%s halted",msg)); for(;;) sleep(1); } 109 111 110 112 PJ_END_DECL -
pjproject/trunk/pjlib/src/pjlib-test/thread.c
r351 r433 53 53 #define THIS_FILE "thread_test" 54 54 55 static int quit_flag=0; 55 static volatile int quit_flag=0; 56 57 #if 0 58 # define TRACE__(args) PJ_LOG(3,args) 59 #else 60 # define TRACE__(args) 61 #endif 62 56 63 57 64 /* … … 66 73 pj_thread_desc desc; 67 74 pj_thread_t *this_thread; 75 unsigned id = *pcounter; 68 76 pj_status_t rc; 77 78 TRACE__((THIS_FILE, " thread %d running..", id)); 69 79 70 80 rc = pj_thread_register("thread", desc, &this_thread); … … 91 101 (*pcounter)++; 92 102 //Must sleep if platform doesn't do time-slicing. 93 pj_thread_sleep(0); 94 } 95 103 //pj_thread_sleep(0); 104 } 105 106 TRACE__((THIS_FILE, " thread %d quitting..", id)); 96 107 return NULL; 97 108 } … … 115 126 quit_flag = 0; 116 127 128 TRACE__((THIS_FILE, " Creating thread 0..")); 117 129 rc = pj_thread_create(pool, "thread", (pj_thread_proc*)&thread_proc, 118 130 &counter, … … 126 138 } 127 139 128 pj_thread_sleep(500); 140 TRACE__((THIS_FILE, " Main thread waiting..")); 141 pj_thread_sleep(1500); 142 TRACE__((THIS_FILE, " Main thread resuming..")); 129 143 130 144 if (flags & PJ_THREAD_SUSPENDED) { … … 145 159 PJ_LOG(3,(THIS_FILE, "..waiting for thread to quit..")); 146 160 147 pj_thread_sleep( 500);161 pj_thread_sleep(1500); 148 162 149 163 quit_flag = 1; … … 176 190 quit_flag = 0; 177 191 178 pool = pj_pool_create(mem, NULL, 40 96,0, NULL);192 pool = pj_pool_create(mem, NULL, 4000, 4000, NULL); 179 193 if (!pool) 180 194 return -10; … … 184 198 /* Create all threads in suspended mode. */ 185 199 for (i=0; i<NUM_THREADS; ++i) { 186 counter[i] = 0;200 counter[i] = i; 187 201 rc = pj_thread_create(pool, "thread", (pj_thread_proc*)&thread_proc, 188 202 &counter[i], … … 199 213 * The purpose of this is to test whether all threads are suspended. 200 214 */ 215 TRACE__((THIS_FILE, " Main thread waiting..")); 201 216 pj_thread_sleep(1000); 217 TRACE__((THIS_FILE, " Main thread resuming..")); 202 218 203 219 /* Check that all counters are still zero. */ 204 220 for (i=0; i<NUM_THREADS; ++i) { 205 if (counter[i] != 0) {221 if (counter[i] > i) { 206 222 PJ_LOG(3,(THIS_FILE, "....ERROR! Thread %d-th is not suspended!", 207 223 i)); … … 212 228 /* Now resume all threads. */ 213 229 for (i=0; i<NUM_THREADS; ++i) { 230 TRACE__((THIS_FILE, " Resuming thread %d [%p]..", i, thread[i])); 214 231 rc = pj_thread_resume(thread[i]); 215 232 if (rc != PJ_SUCCESS) { … … 223 240 * but it'll make user waits for longer for the test to finish. 224 241 */ 242 TRACE__((THIS_FILE, " Main thread waiting (5s)..")); 225 243 pj_thread_sleep(5000); 244 TRACE__((THIS_FILE, " Main thread resuming..")); 226 245 227 246 /* Signal all threads to quit. */ … … 230 249 /* Wait until all threads quit, then destroy. */ 231 250 for (i=0; i<NUM_THREADS; ++i) { 251 TRACE__((THIS_FILE, " Main thread joining thread %d [%p]..", 252 i, thread[i])); 232 253 rc = pj_thread_join(thread[i]); 233 254 if (rc != PJ_SUCCESS) { … … 235 256 return -50; 236 257 } 258 TRACE__((THIS_FILE, " Destroying thread %d [%p]..", i, thread[i])); 237 259 rc = pj_thread_destroy(thread[i]); 238 260 if (rc != PJ_SUCCESS) { … … 241 263 } 242 264 } 265 266 TRACE__((THIS_FILE, " Main thread calculating time slices..")); 243 267 244 268 /* Now examine the value of the counters. … … 264 288 diff = (highest-lowest)*100 / ((highest+lowest)/2); 265 289 if ( diff >= 50) { 266 PJ_LOG(3,(THIS_FILE, "...ERROR: thread didn't have equal timeslice!")); 267 PJ_LOG(3,(THIS_FILE, ".....lowest counter=%u, highest counter=%u, diff=%u%%", 268 lowest, highest, diff)); 290 PJ_LOG(3,(THIS_FILE, 291 "...ERROR: thread didn't have equal timeslice!")); 292 PJ_LOG(3,(THIS_FILE, 293 ".....lowest counter=%u, highest counter=%u, diff=%u%%", 294 lowest, highest, diff)); 269 295 return -80; 270 296 } else { … … 274 300 } 275 301 302 pj_pool_release(pool); 276 303 return 0; 277 304 } -
pjproject/trunk/pjlib/src/pjlib-test/timestamp.c
r387 r433 189 189 190 190 /* Loop.. */ 191 for (i=0; i<1000000; ++i) 192 ; 191 for (i=0; i<1000000; ++i) { 192 /* Try to do something so that smart compilers wont 193 * remove this silly loop. 194 */ 195 null_func(); 196 } 197 198 sleep(0); 193 199 194 200 /* Mark end time. */ … … 199 205 PJ_LOG(3,(THIS_FILE, "....elapsed: %u usec", (unsigned)elapsed)); 200 206 201 /* See if elapsed time is reasonable. */ 202 if (elapsed < 1 || elapsed > 100000) { 207 /* See if elapsed time is "reasonable". 208 * This should be good even on 50Mhz embedded powerpc. 209 */ 210 if (elapsed < 1 || elapsed > 1000000) { 203 211 PJ_LOG(3,(THIS_FILE, "....error: elapsed time outside window (%u, " 204 212 "t1.u32.hi=%u, t1.u32.lo=%u, " -
pjproject/trunk/pjlib/src/pjlib-test/util.c
r153 r433 20 20 #include <pjlib.h> 21 21 22 #define THIS_FILE "util.c" 23 22 24 void app_perror(const char *msg, pj_status_t rc) 23 25 { 24 char errbuf[ 256];26 char errbuf[PJ_ERR_MSG_SIZE]; 25 27 26 28 PJ_CHECK_STACK(); 27 29 28 30 pj_strerror(rc, errbuf, sizeof(errbuf)); 29 PJ_LOG( 1,("test", "%s: [pj_status_t=%d] %s", msg, rc, errbuf));31 PJ_LOG(3,("test", "%s: [pj_status_t=%d] %s", msg, rc, errbuf)); 30 32 } 31 33 -
pjproject/trunk/pjmedia/src/pjmedia-codec/gsm/config.h
r241 r433 10 10 #define CONFIG_H 11 11 12 / *efine SIGHANDLER_T int// * signal handlers are void */13 / *efine HAS_SYSV_SIGNAL 1// * sigs not blocked/reset? */12 //#define SIGHANDLER_T int // * signal handlers are void */ 13 //#define HAS_SYSV_SIGNAL 1 // * sigs not blocked/reset? */ 14 14 15 #define HAS_STDLIB_H 1/* /usr/include/stdlib.h */16 / *efine HAS_LIMITS_H 1// * /usr/include/limits.h */17 #define HAS_FCNTL_H 1/* /usr/include/fcntl.h */18 / *efine HAS_ERRNO_DECL 1// * errno.h declares errno */15 #define HAS_STDLIB_H 1 /* /usr/include/stdlib.h */ 16 //#define HAS_LIMITS_H 1 // * /usr/include/limits.h */ 17 #define HAS_FCNTL_H 1 /* /usr/include/fcntl.h */ 18 //#define HAS_ERRNO_DECL 1 // * errno.h declares errno */ 19 19 20 #define HAS_FSTAT 1/* fstat syscall */21 #define HAS_FCHMOD 1/* fchmod syscall */22 #define HAS_CHMOD 1/* chmod syscall */23 #define HAS_FCHOWN 1/* fchown syscall */24 #define HAS_CHOWN 1/* chown syscall */25 / *efine HAS__FSETMODE 1// * _fsetmode -- set file mode */20 #define HAS_FSTAT 1 /* fstat syscall */ 21 #define HAS_FCHMOD 1 /* fchmod syscall */ 22 #define HAS_CHMOD 1 /* chmod syscall */ 23 #define HAS_FCHOWN 1 /* fchown syscall */ 24 #define HAS_CHOWN 1 /* chown syscall */ 25 //#define HAS__FSETMODE 1 // * _fsetmode -- set file mode */ 26 26 27 #define HAS_STRING_H 1/* /usr/include/string.h */28 / *efine HAS_STRINGS_H 1// * /usr/include/strings.h */27 #define HAS_STRING_H 1 /* /usr/include/string.h */ 28 //#define HAS_STRINGS_H 1 // * /usr/include/strings.h */ 29 29 30 #define HAS_UNISTD_H 1/* /usr/include/unistd.h */31 #define HAS_UTIME 1/* POSIX utime(path, times) */32 / *efine HAS_UTIMES 1 // * use utimes() syscall instead*/33 #define HAS_UTIME_H 1/* UTIME header file */34 / *efine HAS_UTIMBUF 1// * struct utimbuf */35 / *efine HAS_UTIMEUSEC 1// * microseconds in utimbuf? */30 #define HAS_UNISTD_H 1 /* /usr/include/unistd.h */ 31 #define HAS_UTIME 1 /* POSIX utime(path, times) */ 32 //#define HAS_UTIMES 1 // * use utimes() syscall instead*/ 33 #define HAS_UTIME_H 1 /* UTIME header file */ 34 //#define HAS_UTIMBUF 1 // * struct utimbuf */ 35 //#define HAS_UTIMEUSEC 1 // * microseconds in utimbuf? */ 36 36 37 37 38 38 #endif /* CONFIG_H */ 39 -
pjproject/trunk/pjmedia/src/test/main.c
r129 r433 19 19 #include "test.h" 20 20 21 22 /* Any tests that want to build a linked executable for RTEMS must include 23 this header to get a default config for the network stack. */ 24 #if defined(PJ_RTEMS) 25 # include <bsp.h> 26 # include <rtems.h> 27 # include <rtems/rtems_bsdnet.h> 28 # include "../../../pjlib/include/rtems-network-config.h" 29 #endif 30 31 21 32 int main() 22 33 {
Note: See TracChangeset
for help on using the changeset viewer.