xref: /netbsd/sys/sys/unistd.h (revision b9c1fd7f)
1 /*	$NetBSD: unistd.h,v 1.63 2020/05/16 18:31:53 christos Exp $	*/
2 
3 /*
4  * Copyright (c) 1989, 1993
5  *	The Regents of the University of California.  All rights reserved.
6  *
7  * Redistribution and use in source and binary forms, with or without
8  * modification, are permitted provided that the following conditions
9  * are met:
10  * 1. Redistributions of source code must retain the above copyright
11  *    notice, this list of conditions and the following disclaimer.
12  * 2. Redistributions in binary form must reproduce the above copyright
13  *    notice, this list of conditions and the following disclaimer in the
14  *    documentation and/or other materials provided with the distribution.
15  * 3. Neither the name of the University nor the names of its contributors
16  *    may be used to endorse or promote products derived from this software
17  *    without specific prior written permission.
18  *
19  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
20  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
22  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
23  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
24  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
25  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
26  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
27  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
28  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
29  * SUCH DAMAGE.
30  *
31  *	@(#)unistd.h	8.2 (Berkeley) 1/7/94
32  */
33 
34 #ifndef _SYS_UNISTD_H_
35 #define	_SYS_UNISTD_H_
36 
37 #include <sys/featuretest.h>
38 
39 /* compile-time symbolic constants */
40 #define	_POSIX_JOB_CONTROL	1
41 				/* implementation supports job control */
42 
43 /*
44  * According to POSIX 1003.1:
45  * "The saved set-user-ID capability allows a program to regain the
46  * effective user ID established at the last exec call."
47  * However, the setuid/setgid function as specified by POSIX 1003.1 does
48  * not allow changing the effective ID from the super-user without also
49  * changed the saved ID, so it is impossible to get super-user privileges
50  * back later.  Instead we provide this feature independent of the current
51  * effective ID through the seteuid/setegid function.  In addition, we do
52  * not use the saved ID as specified by POSIX 1003.1 in setuid/setgid,
53  * because this would make it impossible for a set-user-ID executable
54  * owned by a user other than the super-user to permanently revoke its
55  * extra privileges.
56  */
57 #ifdef	_NOT_AVAILABLE
58 #define	_POSIX_SAVED_IDS	1
59 				/* saved set-user-ID and set-group-ID */
60 #endif
61 
62 #define	_POSIX_VERSION			200112L
63 #define	_POSIX2_VERSION			200112L
64 
65 /*
66  * We support the posix_spawn() family of functions (unconditionally).
67  */
68 #define	_POSIX_SPAWN			200809L
69 
70 /* execution-time symbolic constants */
71 
72 /*
73  * POSIX options and option groups we unconditionally do or don't
74  * implement.  Those options which are implemented (or not) entirely
75  * in user mode are defined in <unistd.h>.  Please keep this list in
76  * alphabetical order.
77  *
78  * Anything which is defined as zero below **must** have an
79  * implementation for the corresponding sysconf() which is able to
80  * determine conclusively whether or not the feature is supported.
81  * Anything which is defined as other than -1 below **must** have
82  * complete headers, types, and function declarations as specified by
83  * the POSIX standard; however, if the relevant sysconf() function
84  * returns -1, the functions may be stubbed out.
85  */
86 					/* Advisory information */
87 #undef	_POSIX_ADVISORY_INFO
88 					/* asynchronous I/O is available */
89 #define	_POSIX_ASYNCHRONOUS_IO		200112L
90 					/* barriers */
91 #define	_POSIX_BARRIERS			200112L
92 					/* chown requires correct privileges */
93 #define	_POSIX_CHOWN_RESTRICTED		1
94 					/* clock selection */
95 #define	_POSIX_CLOCK_SELECTION		-1
96 					/* cputime clock */
97 #define	_POSIX_CPUTIME			200112L
98 					/* CPU type */
99 #undef	_POSIX_CPUTYPE
100 					/* file synchronization is available */
101 #define	_POSIX_FSYNC			1
102 					/* support IPv6 */
103 #define	_POSIX_IPV6			0
104 					/* job control is available */
105 #define	_POSIX_JOB_CONTROL		1
106 					/* memory mapped files */
107 #define	_POSIX_MAPPED_FILES		1
108 					/* memory locking whole address space */
109 #define	_POSIX_MEMLOCK			1
110 					/* memory locking address ranges */
111 #define	_POSIX_MEMLOCK_RANGE		1
112 					/* memory access protections */
113 #define	_POSIX_MEMORY_PROTECTION	1
114 					/* message passing is available */
115 #define	_POSIX_MESSAGE_PASSING		200112L
116 					/* monotonic clock */
117 #define	_POSIX_MONOTONIC_CLOCK		200112L
118 					/* too-long path comp generate errors */
119 #define	_POSIX_NO_TRUNC			1
120 					/* prioritized I/O */
121 #define	_POSIX_PRIORITIZED_IO		-1
122 					/* priority scheduling */
123 #define	_POSIX_PRIORITY_SCHEDULING	200112L
124 					/* raw sockets */
125 #define	_POSIX_RAW_SOCKETS		200112L
126 					/* read/write locks */
127 #define	_POSIX_READER_WRITER_LOCKS	200112L
128 					/* realtime signals */
129 #undef	_POSIX_REALTIME_SIGNALS
130 					/* regular expressions */
131 #define	_POSIX_REGEXP			1
132 					/* semaphores */
133 #define	_POSIX_SEMAPHORES		0
134 					/* shared memory objects */
135 #define	_POSIX_SHARED_MEMORY_OBJECTS	0
136 					/* shell */
137 #define	_POSIX_SHELL			1
138 					/* spin locks */
139 #define	_POSIX_SPIN_LOCKS		200112L
140 					/* sporadic server */
141 #undef	_POSIX_SPORADIC_SERVER
142 					/* synchronized I/O is available */
143 #define	_POSIX_SYNCHRONIZED_IO		1
144 					/* threads */
145 #define	_POSIX_THREADS			200112L
146 					/* pthread_attr for stack size */
147 #define	_POSIX_THREAD_ATTR_STACKSIZE	200112L
148 					/* pthread_attr for stack address */
149 #define	_POSIX_THREAD_ATTR_STACKADDR	200112L
150 					/* thread cputime clock */
151 #define	_POSIX_THREAD_CPUTIME		200112L
152 					/* _r functions */
153 #define	_POSIX_THREAD_PRIO_PROTECT	200112L
154 					/* PTHREAD_PRIO_PROTECT */
155 #define	_POSIX_THREAD_SAFE_FUNCTIONS	200112L
156 					/* timeouts */
157 #undef	_POSIX_TIMEOUTS
158 					/* timers */
159 #define	_POSIX_TIMERS			200112L
160 					/* typed memory objects */
161 #undef	_POSIX_TYPED_MEMORY_OBJECTS
162 					/* may disable terminal spec chars */
163 #define	_POSIX_VDISABLE			__CAST(unsigned char, '\377')
164 
165 					/* C binding */
166 #define	_POSIX2_C_BIND			200112L
167 
168 					/* XPG4.2 shared memory */
169 #define	_XOPEN_SHM			0
170 
171 /* access function */
172 #define	F_OK		0	/* test for existence of file */
173 #define	X_OK		0x01	/* test for execute or search permission */
174 #define	W_OK		0x02	/* test for write permission */
175 #define	R_OK		0x04	/* test for read permission */
176 
177 /* whence values for lseek(2) */
178 #define	SEEK_SET	0	/* set file offset to offset */
179 #define	SEEK_CUR	1	/* set file offset to current plus offset */
180 #define	SEEK_END	2	/* set file offset to EOF plus offset */
181 
182 #if defined(_NETBSD_SOURCE)
183 /* whence values for lseek(2); renamed by POSIX 1003.1 */
184 #define	L_SET		SEEK_SET
185 #define	L_INCR		SEEK_CUR
186 #define	L_XTND		SEEK_END
187 
188 /*
189  * fsync_range values.
190  *
191  * Note the following flag values were chosen to not overlap
192  * values for SEEK_XXX flags.  While not currently implemented,
193  * it is possible to extend this call to respect SEEK_CUR and
194  * SEEK_END offset addressing modes.
195  */
196 #define	FDATASYNC	0x0010	/* sync data and minimal metadata */
197 #define	FFILESYNC	0x0020	/* sync data and metadata */
198 #define	FDISKSYNC	0x0040	/* flush disk caches after sync */
199 #endif
200 
201 /* configurable pathname variables; use as argument to pathconf(3) */
202 #define	_PC_LINK_MAX		 1
203 #define	_PC_MAX_CANON		 2
204 #define	_PC_MAX_INPUT		 3
205 #define	_PC_NAME_MAX		 4
206 #define	_PC_PATH_MAX		 5
207 #define	_PC_PIPE_BUF		 6
208 #define	_PC_CHOWN_RESTRICTED	 7
209 #define	_PC_NO_TRUNC		 8
210 #define	_PC_VDISABLE		 9
211 #define	_PC_SYNC_IO		10
212 #define	_PC_FILESIZEBITS	11
213 #define	_PC_SYMLINK_MAX		12
214 #define	_PC_2_SYMLINKS		13
215 #define	_PC_ACL_EXTENDED	14
216 
217 /* From OpenSolaris, used by SEEK_DATA/SEEK_HOLE. */
218 #define	_PC_MIN_HOLE_SIZE	15
219 
220 #ifdef _NETBSD_SOURCE
221 #define _PC_ACL_PATH_MAX        16
222 #define _PC_ACL_NFS4            17
223 #endif
224 
225 /* configurable system variables; use as argument to sysconf(3) */
226 /*
227  * XXX The value of _SC_CLK_TCK is embedded in <time.h>.
228  * XXX The value of _SC_PAGESIZE is embedded in <sys/shm.h>.
229  */
230 #define	_SC_ARG_MAX		 1
231 #define	_SC_CHILD_MAX		 2
232 #define	_O_SC_CLK_TCK		 3 /* Old version, always 100 */
233 #define	_SC_NGROUPS_MAX		 4
234 #define	_SC_OPEN_MAX		 5
235 #define	_SC_JOB_CONTROL		 6
236 #define	_SC_SAVED_IDS		 7
237 #define	_SC_VERSION		 8
238 #define	_SC_BC_BASE_MAX		 9
239 #define	_SC_BC_DIM_MAX		10
240 #define	_SC_BC_SCALE_MAX	11
241 #define	_SC_BC_STRING_MAX	12
242 #define	_SC_COLL_WEIGHTS_MAX	13
243 #define	_SC_EXPR_NEST_MAX	14
244 #define	_SC_LINE_MAX		15
245 #define	_SC_RE_DUP_MAX		16
246 #define	_SC_2_VERSION		17
247 #define	_SC_2_C_BIND		18
248 #define	_SC_2_C_DEV		19
249 #define	_SC_2_CHAR_TERM		20
250 #define	_SC_2_FORT_DEV		21
251 #define	_SC_2_FORT_RUN		22
252 #define	_SC_2_LOCALEDEF		23
253 #define	_SC_2_SW_DEV		24
254 #define	_SC_2_UPE		25
255 #define	_SC_STREAM_MAX		26
256 #define	_SC_TZNAME_MAX		27
257 #define	_SC_PAGESIZE		28
258 #define	_SC_PAGE_SIZE		_SC_PAGESIZE	/* 1170 compatibility */
259 #define	_SC_FSYNC		29
260 #define	_SC_XOPEN_SHM		30
261 #define	_SC_SYNCHRONIZED_IO	31
262 #define	_SC_IOV_MAX		32
263 #define	_SC_MAPPED_FILES	33
264 #define	_SC_MEMLOCK		34
265 #define	_SC_MEMLOCK_RANGE	35
266 #define	_SC_MEMORY_PROTECTION	36
267 #define	_SC_LOGIN_NAME_MAX	37
268 #define	_SC_MONOTONIC_CLOCK	38
269 #define	_SC_CLK_TCK		39 /* New, variable version */
270 #define	_SC_ATEXIT_MAX		40
271 #define	_SC_THREADS		41
272 #define	_SC_SEMAPHORES		42
273 #define	_SC_BARRIERS		43
274 #define	_SC_TIMERS		44
275 #define	_SC_SPIN_LOCKS		45
276 #define	_SC_READER_WRITER_LOCKS	46
277 #define	_SC_GETGR_R_SIZE_MAX	47
278 #define	_SC_GETPW_R_SIZE_MAX	48
279 #define	_SC_CLOCK_SELECTION	49
280 #define	_SC_ASYNCHRONOUS_IO	50
281 #define	_SC_AIO_LISTIO_MAX	51
282 #define	_SC_AIO_MAX		52
283 #define	_SC_MESSAGE_PASSING	53
284 #define	_SC_MQ_OPEN_MAX		54
285 #define	_SC_MQ_PRIO_MAX		55
286 #define	_SC_PRIORITY_SCHEDULING	56
287 #define	_SC_THREAD_DESTRUCTOR_ITERATIONS 57
288 #define	_SC_THREAD_KEYS_MAX		58
289 #define	_SC_THREAD_STACK_MIN		59
290 #define	_SC_THREAD_THREADS_MAX		60
291 #define	_SC_THREAD_ATTR_STACKADDR	61
292 #define	_SC_THREAD_ATTR_STACKSIZE 	62
293 #define	_SC_THREAD_PRIORITY_SCHEDULING	63
294 #define	_SC_THREAD_PRIO_INHERIT 	64
295 #define	_SC_THREAD_PRIO_PROTECT		65
296 #define	_SC_THREAD_PROCESS_SHARED	66
297 #define	_SC_THREAD_SAFE_FUNCTIONS	67
298 #define	_SC_TTY_NAME_MAX		68
299 #define	_SC_HOST_NAME_MAX		69
300 #define	_SC_PASS_MAX			70
301 #define	_SC_REGEXP			71
302 #define	_SC_SHELL			72
303 #define	_SC_SYMLOOP_MAX			73
304 
305 /* Actually, they are not supported or implemented yet */
306 #define	_SC_V6_ILP32_OFF32		74
307 #define	_SC_V6_ILP32_OFFBIG		75
308 #define	_SC_V6_LP64_OFF64		76
309 #define	_SC_V6_LPBIG_OFFBIG		77
310 #define	_SC_2_PBS			80
311 #define	_SC_2_PBS_ACCOUNTING		81
312 #define	_SC_2_PBS_CHECKPOINT		82
313 #define	_SC_2_PBS_LOCATE		83
314 #define	_SC_2_PBS_MESSAGE		84
315 #define	_SC_2_PBS_TRACK			85
316 
317 /* These are implemented */
318 #define	_SC_SPAWN			86
319 #define	_SC_SHARED_MEMORY_OBJECTS	87
320 
321 #define	_SC_TIMER_MAX			88
322 #define	_SC_SEM_NSEMS_MAX		89
323 #define	_SC_CPUTIME			90
324 #define	_SC_THREAD_CPUTIME		91
325 #define	_SC_DELAYTIMER_MAX		92
326 #define	_SC_SIGQUEUE_MAX		93
327 #define	_SC_REALTIME_SIGNALS		94
328 #define	_SC_RTSIG_MAX			95
329 
330 /* Extensions found in Solaris and Linux. */
331 #define	_SC_PHYS_PAGES		121
332 
333 #ifdef _NETBSD_SOURCE
334 /* Commonly provided sysconf() extensions */
335 #define	_SC_NPROCESSORS_CONF	1001
336 #define	_SC_NPROCESSORS_ONLN	1002
337 /* Native variables */
338 #define	_SC_SCHED_RT_TS		2001
339 #define	_SC_SCHED_PRI_MIN	2002
340 #define	_SC_SCHED_PRI_MAX	2003
341 #endif	/* _NETBSD_SOURCE */
342 
343 /* configurable system strings */
344 #define	_CS_PATH		 1
345 
346 #endif /* !_SYS_UNISTD_H_ */
347