diff options
author | Benny Prijono <bennylp@teluu.com> | 2006-05-10 19:24:40 +0000 |
---|---|---|
committer | Benny Prijono <bennylp@teluu.com> | 2006-05-10 19:24:40 +0000 |
commit | 50a501dbe89ec8f9a76540015890dd361f1ec8a1 (patch) | |
tree | a45dac4292320647ed297b35239fccf38eb5885b /pjlib/include/pj | |
parent | 5f10c756ac9d5f48efe2adbcccf5d54634540d61 (diff) |
Merge-in RTEMS port patch by Phil Torre <ptorre@zetron.com>, alpha release.
git-svn-id: http://svn.pjsip.org/repos/pjproject/trunk@433 74dad513-b988-da41-8d7b-12977e46ad98
Diffstat (limited to 'pjlib/include/pj')
-rw-r--r-- | pjlib/include/pj/compat/os_darwinos.h | 30 | ||||
-rw-r--r-- | pjlib/include/pj/compat/os_linux.h | 32 | ||||
-rw-r--r-- | pjlib/include/pj/compat/os_linux_kernel.h | 32 | ||||
-rw-r--r-- | pjlib/include/pj/compat/os_palmos.h | 32 | ||||
-rw-r--r-- | pjlib/include/pj/compat/os_rtems.h | 135 | ||||
-rw-r--r-- | pjlib/include/pj/compat/os_sunos.h | 32 | ||||
-rw-r--r-- | pjlib/include/pj/compat/os_win32.h | 32 | ||||
-rw-r--r-- | pjlib/include/pj/compat/os_win32_wince.h | 31 | ||||
-rw-r--r-- | pjlib/include/pj/config.h | 23 | ||||
-rw-r--r-- | pjlib/include/pj/os.h | 13 |
10 files changed, 383 insertions, 9 deletions
diff --git a/pjlib/include/pj/compat/os_darwinos.h b/pjlib/include/pj/compat/os_darwinos.h index 9a0f90b0..e797c438 100644 --- a/pjlib/include/pj/compat/os_darwinos.h +++ b/pjlib/include/pj/compat/os_darwinos.h @@ -94,6 +94,10 @@ * Socket related */ typedef int socklen_t; + +/* Set 1 if native sockaddr_in has sin_len member. + * Default: 0 + */ #define PJ_SOCKADDR_HAS_LEN 1 /* @@ -105,6 +109,32 @@ typedef int socklen_t; */ #define PJ_IOQUEUE_MAX_HANDLES 1024 +/** + * If this macro is set, it tells select I/O Queue that select() needs to + * be given correct value of nfds (i.e. largest fd + 1). This requires + * select ioqueue to re-scan the descriptors on each registration and + * unregistration. + * If this macro is not set, then ioqueue will always give FD_SETSIZE for + * nfds argument when calling select(). + * + * Default: 0 + */ +#define PJ_SELECT_NEEDS_NFDS 0 + +/* If 1, use Read/Write mutex emulation for platforms that don't support it */ +#define PJ_EMULATE_RWMUTEX 0 + +/* If 1, pj_thread_create() should enforce the stack size when creating + * threads. + * Default: 0 (let OS decide the thread's stack size). + */ +#define PJ_THREAD_SET_STACK_SIZE 0 + +/* If 1, pj_thread_create() should allocate stack from the pool supplied. + * Default: 0 (let OS allocate memory for thread's stack). + */ +#define PJ_THREAD_ALLOCATE_STACK 0 + #endif /* __PJ_COMPAT_OS_DARWINOS_H__ */ diff --git a/pjlib/include/pj/compat/os_linux.h b/pjlib/include/pj/compat/os_linux.h index eb6264ea..f0bef355 100644 --- a/pjlib/include/pj/compat/os_linux.h +++ b/pjlib/include/pj/compat/os_linux.h @@ -54,8 +54,24 @@ #define PJ_HAS_WINSOCK2_H 0 #define PJ_SOCK_HAS_INET_ATON 1 + +/* Set 1 if native sockaddr_in has sin_len member. + * Default: 0 + */ #define PJ_SOCKADDR_HAS_LEN 0 +/** + * If this macro is set, it tells select I/O Queue that select() needs to + * be given correct value of nfds (i.e. largest fd + 1). This requires + * select ioqueue to re-scan the descriptors on each registration and + * unregistration. + * If this macro is not set, then ioqueue will always give FD_SETSIZE for + * nfds argument when calling select(). + * + * Default: 0 + */ +#define PJ_SELECT_NEEDS_NFDS 0 + /* Is errno a good way to retrieve OS errors? */ #define PJ_HAS_ERRNO_VAR 1 @@ -89,5 +105,21 @@ #define PJ_ATOMIC_VALUE_TYPE long +/* If 1, use Read/Write mutex emulation for platforms that don't support it */ +#define PJ_EMULATE_RWMUTEX 0 + +/* If 1, pj_thread_create() should enforce the stack size when creating + * threads. + * Default: 0 (let OS decide the thread's stack size). + */ +#define PJ_THREAD_SET_STACK_SIZE 0 + +/* If 1, pj_thread_create() should allocate stack from the pool supplied. + * Default: 0 (let OS allocate memory for thread's stack). + */ +#define PJ_THREAD_ALLOCATE_STACK 0 + + + #endif /* __PJ_COMPAT_OS_LINUX_H__ */ diff --git a/pjlib/include/pj/compat/os_linux_kernel.h b/pjlib/include/pj/compat/os_linux_kernel.h index e481248d..fe3f737c 100644 --- a/pjlib/include/pj/compat/os_linux_kernel.h +++ b/pjlib/include/pj/compat/os_linux_kernel.h @@ -54,6 +54,10 @@ #define PJ_HAS_WINSOCK2_H 0 #define PJ_SOCK_HAS_INET_ATON 0 + +/* Set 1 if native sockaddr_in has sin_len member. + * Default: 0 + */ #define PJ_SOCKADDR_HAS_LEN 0 /* When this macro is set, getsockopt(SOL_SOCKET, SO_ERROR) will return @@ -61,6 +65,18 @@ */ #define PJ_HAS_SO_ERROR 1 +/** + * If this macro is set, it tells select I/O Queue that select() needs to + * be given correct value of nfds (i.e. largest fd + 1). This requires + * select ioqueue to re-scan the descriptors on each registration and + * unregistration. + * If this macro is not set, then ioqueue will always give FD_SETSIZE for + * nfds argument when calling select(). + * + * Default: 0 + */ +#define PJ_SELECT_NEEDS_NFDS 0 + /* This value specifies the value set in errno by the OS when a non-blocking * socket recv() can not return immediate daata. */ @@ -104,5 +120,21 @@ #define PJ_ATOMIC_VALUE_TYPE int #define PJ_THREAD_DESC_SIZE 128 +/* If 1, use Read/Write mutex emulation for platforms that don't support it */ +#define PJ_EMULATE_RWMUTEX 0 + +/* If 1, pj_thread_create() should enforce the stack size when creating + * threads. + * Default: 0 (let OS decide the thread's stack size). + */ +#define PJ_THREAD_SET_STACK_SIZE 0 + +/* If 1, pj_thread_create() should allocate stack from the pool supplied. + * Default: 0 (let OS allocate memory for thread's stack). + */ +#define PJ_THREAD_ALLOCATE_STACK 0 + + + #endif /* __PJ_COMPAT_OS_LINUX_KERNEL_H__ */ diff --git a/pjlib/include/pj/compat/os_palmos.h b/pjlib/include/pj/compat/os_palmos.h index 478e8715..cdabf00f 100644 --- a/pjlib/include/pj/compat/os_palmos.h +++ b/pjlib/include/pj/compat/os_palmos.h @@ -52,8 +52,24 @@ #define PJ_HAS_WINSOCK2_H 0 #define PJ_SOCK_HAS_INET_ATON 0 + +/* Set 1 if native sockaddr_in has sin_len member. + * Default: 0 + */ #define PJ_SOCKADDR_HAS_LEN 0 +/** + * If this macro is set, it tells select I/O Queue that select() needs to + * be given correct value of nfds (i.e. largest fd + 1). This requires + * select ioqueue to re-scan the descriptors on each registration and + * unregistration. + * If this macro is not set, then ioqueue will always give FD_SETSIZE for + * nfds argument when calling select(). + * + * Default: 0 + */ +#define PJ_SELECT_NEEDS_NFDS 0 + /* Is errno a good way to retrieve OS errors? */ #define PJ_HAS_ERRNO_VAR 0 @@ -83,4 +99,20 @@ # define PJ_OS_HAS_CHECK_STACK 0 #define PJ_NATIVE_STRING_IS_UNICODE 0 +/* If 1, use Read/Write mutex emulation for platforms that don't support it */ +#define PJ_EMULATE_RWMUTEX 1 + +/* If 1, pj_thread_create() should enforce the stack size when creating + * threads. + * Default: 0 (let OS decide the thread's stack size). + */ +#define PJ_THREAD_SET_STACK_SIZE 0 + +/* If 1, pj_thread_create() should allocate stack from the pool supplied. + * Default: 0 (let OS allocate memory for thread's stack). + */ +#define PJ_THREAD_ALLOCATE_STACK 0 + + #endif /* __PJ_COMPAT_OS_PALMOS_H__ */ + diff --git a/pjlib/include/pj/compat/os_rtems.h b/pjlib/include/pj/compat/os_rtems.h new file mode 100644 index 00000000..f764f9be --- /dev/null +++ b/pjlib/include/pj/compat/os_rtems.h @@ -0,0 +1,135 @@ +/* $Id$ */ +/* + * Copyright (C)2003-2006 Benny Prijono <benny@prijono.org> + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +/* + * Thanks Zetron, Inc and Phil Torre <ptorre@zetron.com> for donating PJLIB + * port to RTEMS. + */ + +#ifndef __PJ_COMPAT_OS_RTEMS_H__ +#define __PJ_COMPAT_OS_RTEMS_H__ + +/** + * @file os_linux.h + * @brief Describes Linux operating system specifics. + */ + +#define PJ_OS_NAME "rtems" + +#define PJ_HAS_ARPA_INET_H 1 +#define PJ_HAS_ASSERT_H 1 +#define PJ_HAS_CTYPE_H 1 +#define PJ_HAS_ERRNO_H 1 +#define PJ_HAS_LINUX_SOCKET_H 0 +#define PJ_HAS_MALLOC_H 1 +#define PJ_HAS_NETDB_H 1 +#define PJ_HAS_NETINET_IN_H 1 +#define PJ_HAS_SETJMP_H 1 +#define PJ_HAS_STDARG_H 0 +#define PJ_HAS_STDDEF_H 1 +#define PJ_HAS_STDIO_H 1 +#define PJ_HAS_STDLIB_H 1 +#define PJ_HAS_STRING_H 1 +#define PJ_HAS_SYS_IOCTL_H 1 +#define PJ_HAS_SYS_SELECT_H 1 +#define PJ_HAS_SYS_SOCKET_H 1 +#define PJ_HAS_SYS_TIME_H 1 +#define PJ_HAS_SYS_TIMEB_H 1 +#define PJ_HAS_SYS_TYPES_H 1 +#define PJ_HAS_TIME_H 1 +#define PJ_HAS_UNISTD_H 1 + +#define PJ_HAS_MSWSOCK_H 0 +#define PJ_HAS_WINSOCK_H 0 +#define PJ_HAS_WINSOCK2_H 0 + +#define PJ_SOCK_HAS_INET_ATON 1 + +/* Set 1 if native sockaddr_in has sin_len member. + * Default: 0 + */ +#define PJ_SOCKADDR_HAS_LEN 1 + +/* Is errno a good way to retrieve OS errors? + */ +#define PJ_HAS_ERRNO_VAR 1 + +/* When this macro is set, getsockopt(SOL_SOCKET, SO_ERROR) will return + * the status of non-blocking connect() operation. + */ +#define PJ_HAS_SO_ERROR 1 + +/** + * If this macro is set, it tells select I/O Queue that select() needs to + * be given correct value of nfds (i.e. largest fd + 1). This requires + * select ioqueue to re-scan the descriptors on each registration and + * unregistration. + * If this macro is not set, then ioqueue will always give FD_SETSIZE for + * nfds argument when calling select(). + * + * Default: 0 + */ +#define PJ_SELECT_NEEDS_NFDS 1 + +/* This value specifies the value set in errno by the OS when a non-blocking + * socket recv() can not return immediate daata. + */ +#define PJ_BLOCKING_ERROR_VAL EWOULDBLOCK + +/* This value specifies the value set in errno by the OS when a non-blocking + * socket connect() can not get connected immediately. + */ +#define PJ_BLOCKING_CONNECT_ERROR_VAL EINPROGRESS + +/* Default threading is enabled, unless it's overridden. */ +#ifndef PJ_HAS_THREADS +# define PJ_HAS_THREADS (1) +#endif + +#define PJ_HAS_HIGH_RES_TIMER 1 +#define PJ_HAS_MALLOC 1 +#ifndef PJ_OS_HAS_CHECK_STACK +# define PJ_OS_HAS_CHECK_STACK 0 +#endif +#define PJ_NATIVE_STRING_IS_UNICODE 0 + +#define PJ_ATOMIC_VALUE_TYPE int + +/* If 1, use Read/Write mutex emulation for platforms that don't support it */ +#define PJ_EMULATE_RWMUTEX 1 + +/* Missing socklen_t */ +typedef int socklen_t; + +/* If 1, pj_thread_create() should enforce the stack size when creating + * threads. + * Default: 0 (let OS decide the thread's stack size). + */ +#define PJ_THREAD_SET_STACK_SIZE 1 + +/* If 1, pj_thread_create() should allocate stack from the pool supplied. + * Default: 0 (let OS allocate memory for thread's stack). + */ +#define PJ_THREAD_ALLOCATE_STACK 1 + + + + +#endif /* __PJ_COMPAT_OS_RTEMS_H__ */ + diff --git a/pjlib/include/pj/compat/os_sunos.h b/pjlib/include/pj/compat/os_sunos.h index 389d66c2..56c48306 100644 --- a/pjlib/include/pj/compat/os_sunos.h +++ b/pjlib/include/pj/compat/os_sunos.h @@ -54,6 +54,10 @@ #define PJ_HAS_WINSOCK2_H 0 #define PJ_SOCK_HAS_INET_ATON 0 + +/* Set 1 if native sockaddr_in has sin_len member. + * Default: 0 + */ #define PJ_SOCKADDR_HAS_LEN 0 /* Is errno a good way to retrieve OS errors? @@ -75,6 +79,18 @@ */ #define PJ_BLOCKING_CONNECT_ERROR_VAL EINPROGRESS +/** + * If this macro is set, it tells select I/O Queue that select() needs to + * be given correct value of nfds (i.e. largest fd + 1). This requires + * select ioqueue to re-scan the descriptors on each registration and + * unregistration. + * If this macro is not set, then ioqueue will always give FD_SETSIZE for + * nfds argument when calling select(). + * + * Default: 0 + */ +#define PJ_SELECT_NEEDS_NFDS 0 + /* Default threading is enabled, unless it's overridden. */ #ifndef PJ_HAS_THREADS # define PJ_HAS_THREADS (1) @@ -92,5 +108,21 @@ /* Get BSD related identifers in Sun's include files */ #define BSD_COMP +/* If 1, use Read/Write mutex emulation for platforms that don't support it */ +#define PJ_EMULATE_RWMUTEX 0 + +/* If 1, pj_thread_create() should enforce the stack size when creating + * threads. + * Default: 0 (let OS decide the thread's stack size). + */ +#define PJ_THREAD_SET_STACK_SIZE 0 + +/* If 1, pj_thread_create() should allocate stack from the pool supplied. + * Default: 0 (let OS allocate memory for thread's stack). + */ +#define PJ_THREAD_ALLOCATE_STACK 0 + + + #endif /* __PJ_COMPAT_OS_SUNOS_H__ */ diff --git a/pjlib/include/pj/compat/os_win32.h b/pjlib/include/pj/compat/os_win32.h index 5abfc89d..cf7431d6 100644 --- a/pjlib/include/pj/compat/os_win32.h +++ b/pjlib/include/pj/compat/os_win32.h @@ -60,6 +60,10 @@ #define PJ_HAS_WINSOCK2_H 1 #define PJ_SOCK_HAS_INET_ATON 0 + +/* Set 1 if native sockaddr_in has sin_len member. + * Default: 0 + */ #define PJ_SOCKADDR_HAS_LEN 0 /* Is errno a good way to retrieve OS errors? (No) @@ -81,6 +85,18 @@ */ #define PJ_BLOCKING_CONNECT_ERROR_VAL WSAEWOULDBLOCK +/** + * If this macro is set, it tells select I/O Queue that select() needs to + * be given correct value of nfds (i.e. largest fd + 1). This requires + * select ioqueue to re-scan the descriptors on each registration and + * unregistration. + * If this macro is not set, then ioqueue will always give FD_SETSIZE for + * nfds argument when calling select(). + * + * Default: 0 + */ +#define PJ_SELECT_NEEDS_NFDS 0 + /* Default threading is enabled, unless it's overridden. */ #ifndef PJ_HAS_THREADS # define PJ_HAS_THREADS (1) @@ -95,4 +111,20 @@ #define PJ_ATOMIC_VALUE_TYPE long +/* If 1, use Read/Write mutex emulation for platforms that don't support it */ +#define PJ_EMULATE_RWMUTEX 1 + +/* If 1, pj_thread_create() should enforce the stack size when creating + * threads. + * Default: 0 (let OS decide the thread's stack size). + */ +#define PJ_THREAD_SET_STACK_SIZE 0 + +/* If 1, pj_thread_create() should allocate stack from the pool supplied. + * Default: 0 (let OS allocate memory for thread's stack). + */ +#define PJ_THREAD_ALLOCATE_STACK 0 + + #endif /* __PJ_COMPAT_OS_WIN32_H__ */ + diff --git a/pjlib/include/pj/compat/os_win32_wince.h b/pjlib/include/pj/compat/os_win32_wince.h index f6d46e89..36954bae 100644 --- a/pjlib/include/pj/compat/os_win32_wince.h +++ b/pjlib/include/pj/compat/os_win32_wince.h @@ -58,6 +58,10 @@ #define PJ_HAS_WINSOCK2_H 1 #define PJ_SOCK_HAS_INET_ATON 0 + +/* Set 1 if native sockaddr_in has sin_len member. + * Default: 0 + */ #define PJ_SOCKADDR_HAS_LEN 0 /* Is errno a good way to retrieve OS errors? (no) @@ -79,6 +83,18 @@ */ #define PJ_BLOCKING_CONNECT_ERROR_VAL WSAEWOULDBLOCK +/** + * If this macro is set, it tells select I/O Queue that select() needs to + * be given correct value of nfds (i.e. largest fd + 1). This requires + * select ioqueue to re-scan the descriptors on each registration and + * unregistration. + * If this macro is not set, then ioqueue will always give FD_SETSIZE for + * nfds argument when calling select(). + * + * Default: 0 + */ +#define PJ_SELECT_NEEDS_NFDS 0 + /* Default threading is enabled, unless it's overridden. */ #ifndef PJ_HAS_THREADS # define PJ_HAS_THREADS (1) @@ -102,5 +118,20 @@ /* Native string is Unicode. */ #define PJ_NATIVE_STRING_IS_UNICODE 1 +/* If 1, use Read/Write mutex emulation for platforms that don't support it */ +#define PJ_EMULATE_RWMUTEX 1 + +/* If 1, pj_thread_create() should enforce the stack size when creating + * threads. + * Default: 0 (let OS decide the thread's stack size). + */ +#define PJ_THREAD_SET_STACK_SIZE 0 + +/* If 1, pj_thread_create() should allocate stack from the pool supplied. + * Default: 0 (let OS allocate memory for thread's stack). + */ +#define PJ_THREAD_ALLOCATE_STACK 0 + + #endif /* __PJ_COMPAT_OS_WIN32_WINCE_H__ */ diff --git a/pjlib/include/pj/config.h b/pjlib/include/pj/config.h index cd95dbcd..1d74d8c7 100644 --- a/pjlib/include/pj/config.h +++ b/pjlib/include/pj/config.h @@ -53,6 +53,8 @@ # include <pj/compat/os_sunos.h> #elif defined(PJ_DARWINOS) && PJ_DARWINOS!=0 # include <pj/compat/os_darwinos.h> +#elif defined(PJ_RTEMS) && PJ_RTEMS!=0 +# include <pj/compat/os_rtems.h> #else # error "Please specify target os." #endif @@ -223,6 +225,17 @@ /** + * Specify this as \a stack_size argument in #pj_thread_create() to specify + * that thread should use default stack size for the current platform. + * + * Default: 8192 + */ +#ifndef PJ_THREAD_DEFAULT_STACK_SIZE +# define PJ_THREAD_DEFAULT_STACK_SIZE 8192 +#endif + + +/** * Do we have alternate pool implementation? * * Default: 0 @@ -556,7 +569,17 @@ # error "PJ_IS_BIG_ENDIAN is not defined!" #endif +#if !defined(PJ_EMULATE_RWMUTEX) +# error "PJ_EMULATE_RWMUTEX should be defined in compat/os_xx.h" +#endif +#if !defined(PJ_THREAD_SET_STACK_SIZE) +# error "PJ_THREAD_SET_STACK_SIZE should be defined in compat/os_xx.h" +#endif + +#if !defined(PJ_THREAD_ALLOCATE_STACK) +# error "PJ_THREAD_ALLOCATE_STACK should be defined in compat/os_xx.h" +#endif PJ_BEGIN_DECL diff --git a/pjlib/include/pj/os.h b/pjlib/include/pj/os.h index 991dacd0..439b0864 100644 --- a/pjlib/include/pj/os.h +++ b/pjlib/include/pj/os.h @@ -59,12 +59,6 @@ typedef enum pj_thread_create_flags /** - * Specify this as \a stack_size argument in #pj_thread_create() to specify - * that thread should use default stack size for the current platform. - */ -#define PJ_THREAD_DEFAULT_STACK_SIZE 0 - -/** * Type of thread entry function. */ typedef int (PJ_THREAD_FUNC pj_thread_proc)(void*); @@ -161,12 +155,13 @@ PJ_DECL(pj_status_t) pj_thread_resume(pj_thread_t *thread); PJ_DECL(pj_thread_t*) pj_thread_this(void); /** - * Join thread. - * This function will block the caller thread until the specified thread exits. + * Join thread, and block the caller thread until the specified thread exits. + * If the specified thread has already been dead, or it does not exist, + * the function will return immediately with successfull status. * * @param thread The thread handle. * - * @return zero on success. + * @return PJ_SUCCESS on success. */ PJ_DECL(pj_status_t) pj_thread_join(pj_thread_t *thread); |