1 #ifndef _LIMITS_H 2 #define _LIMITS_H 3 4 #include <features.h> 5 6 #include <bits/alltypes.h> /* __LONG_MAX */ 7 #ifdef __LITEOS__ 8 #include "los_sem.h" 9 #endif 10 /* Support signed or unsigned plain-char */ 11 12 #if '\xff' > 0 13 #define CHAR_MIN 0 14 #define CHAR_MAX 255 15 #else 16 #define CHAR_MIN (-128) 17 #define CHAR_MAX 127 18 #endif 19 20 #define CHAR_BIT 8 21 #define SCHAR_MIN (-128) 22 #define SCHAR_MAX 127 23 #define UCHAR_MAX 255 24 #define SHRT_MIN (-1 - 0x7fff) 25 #define SHRT_MAX 0x7fff 26 #define USHRT_MAX 0xffff 27 #define INT_MIN (-1 - 0x7fffffff) 28 #define INT_MAX 0x7fffffff 29 #define UINT_MAX 0xffffffffU 30 #define LONG_MIN (-LONG_MAX - 1) 31 #define LONG_MAX __LONG_MAX 32 #define ULONG_MAX (2UL * LONG_MAX + 1) 33 #define LLONG_MIN (-LLONG_MAX - 1) 34 #define LLONG_MAX 0x7fffffffffffffffLL 35 #define ULLONG_MAX (2ULL * LLONG_MAX + 1) 36 37 #define MB_LEN_MAX 4 38 39 #if defined(_POSIX_SOURCE) || defined(_POSIX_C_SOURCE) \ 40 || defined(_XOPEN_SOURCE) || defined(_GNU_SOURCE) || defined(_BSD_SOURCE) 41 42 #include <bits/limits.h> 43 44 #ifndef __LITEOS__ 45 #define PIPE_BUF 4096 46 #else 47 #define PIPE_BUF 512 48 #endif 49 #define FILESIZEBITS 64 50 #ifndef NAME_MAX 51 #define NAME_MAX 255 52 #endif 53 #ifndef __LITEOS__ 54 #define PATH_MAX 4096 55 #else 56 #define PATH_MAX 260 57 #define CONFIG_NAME_MAX NAME_MAX 58 #define CONFIG_PATH_MAX PATH_MAX 59 #endif 60 61 #ifdef __LITEOS__ 62 #define NGROUPS_MAX 0 63 #define ARG_MAX 4096 64 #else 65 #define NGROUPS_MAX 32 66 #define ARG_MAX 131072 67 #endif 68 #define IOV_MAX 1024 69 #define SYMLOOP_MAX 40 70 #define WORD_BIT 32 71 #define SSIZE_MAX LONG_MAX 72 #define TZNAME_MAX 6 73 #define TTY_NAME_MAX 32 74 #define HOST_NAME_MAX 255 75 76 #if LONG_MAX == 0x7fffffffL 77 #define LONG_BIT 32 78 #else 79 #define LONG_BIT 64 80 #endif 81 82 /* Implementation choices... */ 83 84 #define PTHREAD_KEYS_MAX 128 85 #ifndef __LITEOS__ 86 #define PTHREAD_STACK_MIN 2048 87 #else 88 #define PTHREAD_STACK_MIN LOS_TASK_MIN_STACK_SIZE 89 #endif 90 #define PTHREAD_DESTRUCTOR_ITERATIONS 4 91 #ifndef __LITEOS__ 92 #define SEM_VALUE_MAX 0x7fffffff 93 #define SEM_NSEMS_MAX 256 94 #else 95 /** 96 * @ingroup semaphore 97 * Maximum semaphore value. 98 */ 99 #define SEM_VALUE_MAX LOS_SEM_COUNT_MAX 100 /** 101 * @ingroup semaphore 102 * Maximum number of supported semaphores. 103 */ 104 #define SEM_NSEMS_MAX LOSCFG_BASE_IPC_SEM_LIMIT 105 #endif 106 #define DELAYTIMER_MAX 0x7fffffff 107 #ifdef __LITEOS__ 108 #define MQ_PRIO_MAX 1 109 #else 110 #define MQ_PRIO_MAX 32768 111 #endif 112 #define LOGIN_NAME_MAX 256 113 114 /* Arbitrary numbers... */ 115 116 #define BC_BASE_MAX 99 117 #define BC_DIM_MAX 2048 118 #define BC_SCALE_MAX 99 119 #define BC_STRING_MAX 1000 120 #define CHARCLASS_NAME_MAX 14 121 #define COLL_WEIGHTS_MAX 2 122 #define EXPR_NEST_MAX 32 123 #define LINE_MAX 4096 124 #define RE_DUP_MAX 255 125 126 #define NL_ARGMAX 9 127 #define NL_MSGMAX 32767 128 #define NL_SETMAX 255 129 #define NL_TEXTMAX 2048 130 131 #endif 132 133 #if defined(_GNU_SOURCE) || defined(_BSD_SOURCE) || defined(_XOPEN_SOURCE) 134 135 #ifdef PAGESIZE 136 #define PAGE_SIZE PAGESIZE 137 #endif 138 #define NZERO 20 139 #define NL_LANGMAX 32 140 141 #endif 142 143 #if defined(_GNU_SOURCE) || defined(_BSD_SOURCE) \ 144 || (defined(_XOPEN_SOURCE) && _XOPEN_SOURCE+0 < 700) 145 146 #define NL_NMAX 16 147 148 #endif 149 150 /* POSIX/SUS requirements follow. These numbers come directly 151 * from SUS and have nothing to do with the host system. */ 152 153 #define _POSIX_AIO_LISTIO_MAX 2 154 #define _POSIX_AIO_MAX 1 155 #define _POSIX_ARG_MAX 4096 156 #define _POSIX_CHILD_MAX 25 157 #define _POSIX_CLOCKRES_MIN 20000000 158 #define _POSIX_DELAYTIMER_MAX 32 159 #define _POSIX_HOST_NAME_MAX 255 160 #define _POSIX_LINK_MAX 8 161 #define _POSIX_LOGIN_NAME_MAX 9 162 #define _POSIX_MAX_CANON 255 163 #define _POSIX_MAX_INPUT 255 164 #define _POSIX_MQ_OPEN_MAX 8 165 #define _POSIX_MQ_PRIO_MAX 32 166 #define _POSIX_NAME_MAX 14 167 #define _POSIX_NGROUPS_MAX 8 168 #define _POSIX_OPEN_MAX 20 169 #define _POSIX_PATH_MAX 256 170 #define _POSIX_PIPE_BUF 512 171 #define _POSIX_RE_DUP_MAX 255 172 #define _POSIX_RTSIG_MAX 8 173 #define _POSIX_SEM_NSEMS_MAX 256 174 #define _POSIX_SEM_VALUE_MAX 32767 175 #define _POSIX_SIGQUEUE_MAX 32 176 #define _POSIX_SSIZE_MAX 32767 177 #define _POSIX_STREAM_MAX 8 178 #define _POSIX_SS_REPL_MAX 4 179 #define _POSIX_SYMLINK_MAX 255 180 #define _POSIX_SYMLOOP_MAX 8 181 #define _POSIX_THREAD_DESTRUCTOR_ITERATIONS 4 182 #define _POSIX_THREAD_KEYS_MAX 128 183 #define _POSIX_THREAD_THREADS_MAX 64 184 #define _POSIX_TIMER_MAX 32 185 #define _POSIX_TRACE_EVENT_NAME_MAX 30 186 #define _POSIX_TRACE_NAME_MAX 8 187 #define _POSIX_TRACE_SYS_MAX 8 188 #define _POSIX_TRACE_USER_EVENT_MAX 32 189 #define _POSIX_TTY_NAME_MAX 9 190 #define _POSIX_TZNAME_MAX 6 191 #define _POSIX2_BC_BASE_MAX 99 192 #define _POSIX2_BC_DIM_MAX 2048 193 #define _POSIX2_BC_SCALE_MAX 99 194 #define _POSIX2_BC_STRING_MAX 1000 195 #define _POSIX2_CHARCLASS_NAME_MAX 14 196 #define _POSIX2_COLL_WEIGHTS_MAX 2 197 #define _POSIX2_EXPR_NEST_MAX 32 198 #define _POSIX2_LINE_MAX 2048 199 #define _POSIX2_RE_DUP_MAX 255 200 201 #define _XOPEN_IOV_MAX 16 202 #define _XOPEN_NAME_MAX 255 203 #define _XOPEN_PATH_MAX 1024 204 205 #ifdef __LITEOS__ 206 #ifdef LOSCFG_FS_VFS 207 #include "vfs_config.h" 208 #endif 209 210 #define CHILD_MAX 6 211 #define _POSIX_CLK_TICK time((time_t *)NULL) 212 #define _POSIX_GETGR_R_SIZE_MAX 0 213 #define _POSIX_GETPW_R_SIZE_MAX 0 214 #define _LITEOS_MQ_OPEN_MAX LOSCFG_BASE_IPC_QUEUE_LIMIT 215 #define GETGR_R_SIZE_MAX _POSIX_GETGR_R_SIZE_MAX 216 #define GETPW_R_SIZE_MAX _POSIX_GETPW_R_SIZE_MAX 217 218 #ifdef LOSCFG_FS_VFS 219 #define OPEN_MAX CONFIG_NFILE_DESCRIPTORS 220 #else 221 #define OPEN_MAX 255 222 #endif 223 #define RTSIG_MAX 8 224 #define PTHREAD_ATTR_STACKSIZE LOSCFG_BASE_CORE_TSK_DEFAULT_STACK_SIZE 225 #define PTHREAD_PRIORITY_SCHEDULING SCHED_OTHER 226 #define PTHREAD_THREADS_MAX (LOSCFG_BASE_CORE_TSK_LIMIT + 1) 227 228 #ifdef LOSCFG_BASE_CORE_SWTMR 229 #define TIMERS 1 230 #else 231 #define TIMERS 0 232 #endif 233 234 #define TIMER_MAX _POSIX_TIMER_MAX 235 #define _POSIX_VERSION 200809L 236 #define POSIX_VERSION _POSIX_VERSION 237 #define SIGQUEUE_MAX 32 238 #define STREAM_MAX 8 239 #define MQ_OPEN_MAX _LITEOS_MQ_OPEN_MAX 240 #define SYS_CLK_TCK _POSIX_CLK_TICK 241 #define CONFIG_PATH_MAX PATH_MAX 242 #define LINK_MAX 8 243 #endif 244 245 #endif 246