Benny Prijono | a9b372a | 2006-07-24 02:07:11 +0000 | [diff] [blame] | 1 | /* $Id$ */ |
| 2 | /* |
Benny Prijono | 844653c | 2008-12-23 17:27:53 +0000 | [diff] [blame] | 3 | * Copyright (C) 2008-2009 Teluu Inc. (http://www.teluu.com) |
| 4 | * Copyright (C) 2003-2008 Benny Prijono <benny@prijono.org> |
Benny Prijono | a9b372a | 2006-07-24 02:07:11 +0000 | [diff] [blame] | 5 | * |
| 6 | * This program is free software; you can redistribute it and/or modify |
| 7 | * it under the terms of the GNU General Public License as published by |
| 8 | * the Free Software Foundation; either version 2 of the License, or |
| 9 | * (at your option) any later version. |
| 10 | * |
| 11 | * This program is distributed in the hope that it will be useful, |
| 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 14 | * GNU General Public License for more details. |
| 15 | * |
| 16 | * You should have received a copy of the GNU General Public License |
| 17 | * along with this program; if not, write to the Free Software |
| 18 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
| 19 | */ |
| 20 | #ifndef __PJ_COMPAT_OS_AUTO_H__ |
| 21 | #define __PJ_COMPAT_OS_AUTO_H__ |
| 22 | |
| 23 | /** |
| 24 | * @file os_auto.h |
| 25 | * @brief Describes operating system specifics (automatically detected by |
| 26 | * autoconf) |
| 27 | */ |
| 28 | |
| 29 | /* Canonical OS name */ |
| 30 | #undef PJ_OS_NAME |
| 31 | |
Benny Prijono | c5b6dbf | 2006-09-10 16:33:48 +0000 | [diff] [blame] | 32 | /* Legacy macros */ |
| 33 | #undef PJ_WIN32 |
| 34 | #undef PJ_WIN32_WINNT |
| 35 | #undef WIN32_LEAN_AND_MEAN |
| 36 | #undef PJ_DARWINOS |
| 37 | #undef PJ_LINUX |
| 38 | #undef PJ_RTEMS |
| 39 | #undef PJ_SUNOS |
| 40 | |
| 41 | #if defined(PJ_WIN32_WINNT) && !defined(_WIN32_WINNT) |
| 42 | # define _WIN32_WINNT PJ_WIN32_WINNT |
| 43 | #endif |
| 44 | |
Benny Prijono | a9b372a | 2006-07-24 02:07:11 +0000 | [diff] [blame] | 45 | /* Headers availability */ |
| 46 | #undef PJ_HAS_ARPA_INET_H |
| 47 | #undef PJ_HAS_ASSERT_H |
| 48 | #undef PJ_HAS_CTYPE_H |
| 49 | #undef PJ_HAS_ERRNO_H |
Benny Prijono | 1d481ab | 2008-01-24 15:27:30 +0000 | [diff] [blame] | 50 | #undef PJ_HAS_FCNTL_H |
Benny Prijono | a9b372a | 2006-07-24 02:07:11 +0000 | [diff] [blame] | 51 | #undef PJ_HAS_LINUX_SOCKET_H |
| 52 | #undef PJ_HAS_MALLOC_H |
| 53 | #undef PJ_HAS_NETDB_H |
Benny Prijono | 37fc9de | 2008-08-04 14:45:02 +0000 | [diff] [blame] | 54 | #undef PJ_HAS_NETINET_IN_SYSTM_H |
Benny Prijono | a9b372a | 2006-07-24 02:07:11 +0000 | [diff] [blame] | 55 | #undef PJ_HAS_NETINET_IN_H |
Benny Prijono | 87a0089 | 2007-02-01 00:33:12 +0000 | [diff] [blame] | 56 | #undef PJ_HAS_NETINET_IP_H |
Benny Prijono | 1d61ba5 | 2009-10-24 00:00:40 +0000 | [diff] [blame] | 57 | #undef PJ_HAS_NETINET_TCP_H |
Benny Prijono | 0ae59ae | 2007-11-17 10:27:34 +0000 | [diff] [blame] | 58 | #undef PJ_HAS_NET_IF_H |
Benny Prijono | 1d65f70 | 2007-12-03 04:03:17 +0000 | [diff] [blame] | 59 | #undef PJ_HAS_IFADDRS_H |
Benny Prijono | 1c5f4e4 | 2008-02-07 13:11:39 +0000 | [diff] [blame] | 60 | #undef PJ_HAS_SEMAPHORE_H |
Benny Prijono | a9b372a | 2006-07-24 02:07:11 +0000 | [diff] [blame] | 61 | #undef PJ_HAS_SETJMP_H |
| 62 | #undef PJ_HAS_STDARG_H |
| 63 | #undef PJ_HAS_STDDEF_H |
| 64 | #undef PJ_HAS_STDIO_H |
Benny Prijono | fdafd40 | 2008-01-23 14:34:46 +0000 | [diff] [blame] | 65 | #undef PJ_HAS_STDINT_H |
Benny Prijono | a9b372a | 2006-07-24 02:07:11 +0000 | [diff] [blame] | 66 | #undef PJ_HAS_STDLIB_H |
| 67 | #undef PJ_HAS_STRING_H |
| 68 | #undef PJ_HAS_SYS_IOCTL_H |
| 69 | #undef PJ_HAS_SYS_SELECT_H |
| 70 | #undef PJ_HAS_SYS_SOCKET_H |
| 71 | #undef PJ_HAS_SYS_TIME_H |
| 72 | #undef PJ_HAS_SYS_TIMEB_H |
| 73 | #undef PJ_HAS_SYS_TYPES_H |
Benny Prijono | a1aec0e | 2010-01-13 21:28:06 +0000 | [diff] [blame] | 74 | #undef PJ_HAS_SYS_FILIO_H |
| 75 | #undef PJ_HAS_SYS_SOCKIO_H |
Benny Prijono | a9b372a | 2006-07-24 02:07:11 +0000 | [diff] [blame] | 76 | #undef PJ_HAS_TIME_H |
| 77 | #undef PJ_HAS_UNISTD_H |
| 78 | |
| 79 | #undef PJ_HAS_MSWSOCK_H |
| 80 | #undef PJ_HAS_WINSOCK_H |
| 81 | #undef PJ_HAS_WINSOCK2_H |
Benny Prijono | e274613 | 2008-09-27 13:16:35 +0000 | [diff] [blame] | 82 | #undef PJ_HAS_WS2TCPIP_H |
Benny Prijono | a9b372a | 2006-07-24 02:07:11 +0000 | [diff] [blame] | 83 | |
| 84 | #undef PJ_SOCK_HAS_INET_ATON |
Benny Prijono | c16c6e3 | 2007-11-18 14:53:47 +0000 | [diff] [blame] | 85 | #undef PJ_SOCK_HAS_INET_PTON |
| 86 | #undef PJ_SOCK_HAS_INET_NTOP |
| 87 | #undef PJ_SOCK_HAS_GETADDRINFO |
Benny Prijono | a9b372a | 2006-07-24 02:07:11 +0000 | [diff] [blame] | 88 | |
Benny Prijono | 1c5f4e4 | 2008-02-07 13:11:39 +0000 | [diff] [blame] | 89 | /* On these OSes, semaphore feature depends on semaphore.h */ |
| 90 | #if defined(PJ_HAS_SEMAPHORE_H) && PJ_HAS_SEMAPHORE_H!=0 |
| 91 | # define PJ_HAS_SEMAPHORE 1 |
Benny Prijono | c2e3481 | 2008-02-08 15:18:20 +0000 | [diff] [blame] | 92 | #elif defined(PJ_WIN32) && PJ_WIN32!=0 |
| 93 | # define PJ_HAS_SEMAPHORE 1 |
Benny Prijono | 1c5f4e4 | 2008-02-07 13:11:39 +0000 | [diff] [blame] | 94 | #else |
| 95 | # define PJ_HAS_SEMAPHORE 0 |
| 96 | #endif |
| 97 | |
| 98 | /* Do we have pthread_mutexattr_settype()? */ |
| 99 | #undef PJ_HAS_PTHREAD_MUTEXATTR_SETTYPE |
| 100 | |
| 101 | /* Does pthread_mutexattr_t has "recursive" member? */ |
| 102 | #undef PJ_PTHREAD_MUTEXATTR_T_HAS_RECURSIVE |
| 103 | |
Benny Prijono | a9b372a | 2006-07-24 02:07:11 +0000 | [diff] [blame] | 104 | /* Set 1 if native sockaddr_in has sin_len member. |
| 105 | * Default: 0 |
| 106 | */ |
| 107 | #undef PJ_SOCKADDR_HAS_LEN |
| 108 | |
Benny Prijono | 30f85c6 | 2006-09-09 20:05:33 +0000 | [diff] [blame] | 109 | /* Does the OS have socklen_t? */ |
| 110 | #undef PJ_HAS_SOCKLEN_T |
| 111 | |
Benny Prijono | b726d26 | 2008-07-19 18:05:04 +0000 | [diff] [blame] | 112 | #if !defined(socklen_t) && (!defined(PJ_HAS_SOCKLEN_T) || PJ_HAS_SOCKLEN_T==0) |
Benny Prijono | c5b6dbf | 2006-09-10 16:33:48 +0000 | [diff] [blame] | 113 | # define PJ_HAS_SOCKLEN_T 1 |
Benny Prijono | 30f85c6 | 2006-09-09 20:05:33 +0000 | [diff] [blame] | 114 | typedef int socklen_t; |
| 115 | #endif |
| 116 | |
Benny Prijono | a9b372a | 2006-07-24 02:07:11 +0000 | [diff] [blame] | 117 | /** |
| 118 | * If this macro is set, it tells select I/O Queue that select() needs to |
| 119 | * be given correct value of nfds (i.e. largest fd + 1). This requires |
| 120 | * select ioqueue to re-scan the descriptors on each registration and |
| 121 | * unregistration. |
| 122 | * If this macro is not set, then ioqueue will always give FD_SETSIZE for |
| 123 | * nfds argument when calling select(). |
| 124 | * |
| 125 | * Default: 0 |
| 126 | */ |
| 127 | #undef PJ_SELECT_NEEDS_NFDS |
| 128 | |
| 129 | /* Is errno a good way to retrieve OS errors? |
| 130 | */ |
| 131 | #undef PJ_HAS_ERRNO_VAR |
| 132 | |
| 133 | /* When this macro is set, getsockopt(SOL_SOCKET, SO_ERROR) will return |
| 134 | * the status of non-blocking connect() operation. |
| 135 | */ |
| 136 | #undef PJ_HAS_SO_ERROR |
| 137 | |
| 138 | /* This value specifies the value set in errno by the OS when a non-blocking |
| 139 | * socket recv() can not return immediate daata. |
| 140 | */ |
| 141 | #undef PJ_BLOCKING_ERROR_VAL |
| 142 | |
| 143 | /* This value specifies the value set in errno by the OS when a non-blocking |
| 144 | * socket connect() can not get connected immediately. |
| 145 | */ |
| 146 | #undef PJ_BLOCKING_CONNECT_ERROR_VAL |
| 147 | |
| 148 | /* Default threading is enabled, unless it's overridden. */ |
| 149 | #ifndef PJ_HAS_THREADS |
| 150 | # define PJ_HAS_THREADS (1) |
| 151 | #endif |
| 152 | |
Benny Prijono | 30f85c6 | 2006-09-09 20:05:33 +0000 | [diff] [blame] | 153 | /* Do we need high resolution timer? */ |
Benny Prijono | a9b372a | 2006-07-24 02:07:11 +0000 | [diff] [blame] | 154 | #undef PJ_HAS_HIGH_RES_TIMER |
Benny Prijono | 30f85c6 | 2006-09-09 20:05:33 +0000 | [diff] [blame] | 155 | |
| 156 | /* Is malloc() available? */ |
Benny Prijono | a9b372a | 2006-07-24 02:07:11 +0000 | [diff] [blame] | 157 | #undef PJ_HAS_MALLOC |
Benny Prijono | 30f85c6 | 2006-09-09 20:05:33 +0000 | [diff] [blame] | 158 | |
Benny Prijono | a9b372a | 2006-07-24 02:07:11 +0000 | [diff] [blame] | 159 | #ifndef PJ_OS_HAS_CHECK_STACK |
| 160 | # define PJ_OS_HAS_CHECK_STACK 0 |
| 161 | #endif |
Benny Prijono | 30f85c6 | 2006-09-09 20:05:33 +0000 | [diff] [blame] | 162 | |
| 163 | /* Unicode? */ |
Benny Prijono | a9b372a | 2006-07-24 02:07:11 +0000 | [diff] [blame] | 164 | #undef PJ_NATIVE_STRING_IS_UNICODE |
| 165 | |
Benny Prijono | 1d97162 | 2006-09-10 22:27:40 +0000 | [diff] [blame] | 166 | /* Pool alignment in bytes */ |
| 167 | #undef PJ_POOL_ALIGNMENT |
| 168 | |
Benny Prijono | 30f85c6 | 2006-09-09 20:05:33 +0000 | [diff] [blame] | 169 | /* The type of atomic variable value: */ |
Benny Prijono | a9b372a | 2006-07-24 02:07:11 +0000 | [diff] [blame] | 170 | #undef PJ_ATOMIC_VALUE_TYPE |
| 171 | |
Sauw Ming | d39818b | 2010-07-15 13:32:11 +0000 | [diff] [blame] | 172 | #if defined(PJ_DARWINOS) && PJ_DARWINOS!=0 |
| 173 | # include "TargetConditionals.h" |
Sauw Ming | c28ecd0 | 2010-07-23 04:27:32 +0000 | [diff] [blame] | 174 | # if TARGET_OS_IPHONE |
| 175 | # include "Availability.h" |
| 176 | # ifdef __IPHONE_4_0 |
Sauw Ming | be3771a | 2010-08-27 06:46:29 +0000 | [diff] [blame] | 177 | /* Append ".local" suffix to the system's hostname? (see ticket #1104) */ |
| 178 | # define PJ_GETHOSTNAME_APPEND_LOCAL_SUFFIX 1 |
| 179 | /* Is multitasking support available? (see ticket #1107) */ |
| 180 | # define PJ_IPHONE_OS_HAS_MULTITASKING_SUPPORT 1 |
| 181 | /* Enable activesock TCP background mode support */ |
| 182 | # define PJ_ACTIVESOCK_TCP_IPHONE_OS_BG 1 |
Sauw Ming | c28ecd0 | 2010-07-23 04:27:32 +0000 | [diff] [blame] | 183 | # endif |
Sauw Ming | d39818b | 2010-07-15 13:32:11 +0000 | [diff] [blame] | 184 | # endif |
| 185 | #endif |
| 186 | |
Benny Prijono | a9b372a | 2006-07-24 02:07:11 +0000 | [diff] [blame] | 187 | /* If 1, use Read/Write mutex emulation for platforms that don't support it */ |
| 188 | #undef PJ_EMULATE_RWMUTEX |
| 189 | |
| 190 | /* If 1, pj_thread_create() should enforce the stack size when creating |
| 191 | * threads. |
| 192 | * Default: 0 (let OS decide the thread's stack size). |
| 193 | */ |
| 194 | #undef PJ_THREAD_SET_STACK_SIZE |
| 195 | |
| 196 | /* If 1, pj_thread_create() should allocate stack from the pool supplied. |
| 197 | * Default: 0 (let OS allocate memory for thread's stack). |
| 198 | */ |
| 199 | #undef PJ_THREAD_ALLOCATE_STACK |
| 200 | |
Nanang Izzuddin | ea6d3c4 | 2009-10-26 15:47:52 +0000 | [diff] [blame] | 201 | /* SSL socket availability. */ |
| 202 | #ifndef PJ_HAS_SSL_SOCK |
| 203 | #undef PJ_HAS_SSL_SOCK |
| 204 | #endif |
| 205 | |
| 206 | |
Benny Prijono | a9b372a | 2006-07-24 02:07:11 +0000 | [diff] [blame] | 207 | #endif /* __PJ_COMPAT_OS_AUTO_H__ */ |
| 208 | |