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