Merge branch 'vendor/OPENSSH'
[dragonfly.git] / sys / sys / unistd.h
1 /*-
2  * Copyright (c) 1989, 1993
3  *      The Regents of the University of California.  All rights reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions
7  * are met:
8  * 1. Redistributions of source code must retain the above copyright
9  *    notice, this list of conditions and the following disclaimer.
10  * 2. Redistributions in binary form must reproduce the above copyright
11  *    notice, this list of conditions and the following disclaimer in the
12  *    documentation and/or other materials provided with the distribution.
13  * 3. Neither the name of the University nor the names of its contributors
14  *    may be used to endorse or promote products derived from this software
15  *    without specific prior written permission.
16  *
17  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
18  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
21  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
22  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
23  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
24  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
25  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
26  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
27  * SUCH DAMAGE.
28  *
29  *      @(#)unistd.h    8.2 (Berkeley) 1/7/94
30  * $FreeBSD: src/sys/sys/unistd.h,v 1.50 2009/01/31 10:04:36 trhodes Exp $
31  */
32
33 #ifndef _SYS_UNISTD_H_
34 #define _SYS_UNISTD_H_
35
36 #include <sys/cdefs.h>
37 #include <sys/types.h>
38
39 /*
40  * POSIX options and option groups we unconditionally do or don't
41  * implement.  Those options which are implemented (or not) entirely
42  * in user mode are defined in <unistd.h>.  Please keep this list in
43  * alphabetical order.
44  *
45  * Anything which is defined as zero below **must** have an
46  * implementation for the corresponding sysconf() which is able to
47  * determine conclusively whether or not the feature is supported.
48  * Anything which is defined as other than -1 below **must** have
49  * complete headers, types, and function declarations as specified by
50  * the POSIX standard; however, if the relevant sysconf() function
51  * returns -1, the functions may be stubbed out.
52  */
53 #define _POSIX_ADVISORY_INFO            -1      /* [ADV] */
54 #define _POSIX_ASYNCHRONOUS_IO          0       /* mandatory */
55 #define _POSIX_BARRIERS                 200112L /* mandatory */
56 #define _POSIX_CHOWN_RESTRICTED         1
57 #define _POSIX_CLOCK_SELECTION          -1      /* XXX mandatory */
58 #define _POSIX_CPUTIME                  -1      /* [CPT] */
59 #define _POSIX_FSYNC                    200112L /* [FSC] */
60 #define _POSIX_IPV6                     0
61 #define _POSIX_JOB_CONTROL              1       /* mandatory */
62 #define _POSIX_MAPPED_FILES             200112L /* mandatory */
63 #define _POSIX_MEMLOCK                  -1      /* [ML] */
64 #define _POSIX_MEMLOCK_RANGE            200112L /* [MLR] */
65 #define _POSIX_MEMORY_PROTECTION        200112L /* mandatory */
66 #define _POSIX_MESSAGE_PASSING          200112L /* [MSG] */
67 #define _POSIX_MONOTONIC_CLOCK          200112L /* [MON] */
68 #define _POSIX_NO_TRUNC                 1
69 #define _POSIX_PRIORITIZED_IO           -1      /* [PIO] */
70 #define _POSIX_PRIORITY_SCHEDULING      200112L /* [PS] */
71 #define _POSIX_RAW_SOCKETS              200112L /* [RS] */
72 #define _POSIX_REALTIME_SIGNALS         200112L /* mandatory */
73 #define _POSIX_SEMAPHORES               200112L /* mandatory */
74 #define _POSIX_SHARED_MEMORY_OBJECTS    200112L /* [SHM] */
75 #define _POSIX_SPIN_LOCKS               200112L /* mandatory */
76 #define _POSIX_SPORADIC_SERVER          -1      /* [SS] */
77 #define _POSIX_SYNCHRONIZED_IO          -1      /* [SIO] */
78 #define _POSIX_TIMEOUTS                 200112L /* mandatory */
79 #define _POSIX_TIMERS                   200112L /* mandatory */
80 #define _POSIX_TYPED_MEMORY_OBJECTS     -1      /* [TYM] */
81 #define _POSIX_VDISABLE                 0xff
82
83 #if __XSI_VISIBLE
84 #define _XOPEN_SHM                      1
85 #define _XOPEN_STREAMS                  -1
86 #endif
87
88 /*
89  * Although we have saved user/group IDs, we do not use them in setuid
90  * as described in POSIX 1003.1, because the feature does not work for
91  * root.  We use the saved IDs in seteuid/setegid, which are not currently
92  * part of the POSIX 1003.1 specification.  See comments in kern_prot.c.
93  *
94  * XXX revisit for 1003.1-2008 as this is now mandatory since 1003.1-2001.
95  */
96 #if 0
97 #define _POSIX_SAVED_IDS        1 /* saved set-user-ID and set-group-ID */
98 #endif
99
100 /* Define the POSIX.1 version we target for compliance. */
101 #ifndef _POSIX_VERSION
102 #define _POSIX_VERSION          200112L
103 #endif
104
105 /* access function */
106 #define F_OK            0       /* test for existence of file */
107 #define X_OK            0x01    /* test for execute or search permission */
108 #define W_OK            0x02    /* test for write permission */
109 #define R_OK            0x04    /* test for read permission */
110
111 /* whence values for lseek(2) */
112 #ifndef SEEK_SET
113 #define SEEK_SET        0       /* set file offset to offset */
114 #define SEEK_CUR        1       /* set file offset to current plus offset */
115 #define SEEK_END        2       /* set file offset to EOF plus offset */
116 #endif
117 #if __BSD_VISIBLE
118 #define SEEK_DATA       3       /* set file offset to next data past offset */
119 #define SEEK_HOLE       4       /* set file offset to next hole past offset */
120
121 /* whence values for lseek(2); renamed by POSIX 1003.1 */
122 #define L_SET           SEEK_SET
123 #define L_INCR          SEEK_CUR
124 #define L_XTND          SEEK_END
125 #endif
126
127 /* configurable pathname variables */
128 #define _PC_LINK_MAX             1
129 #define _PC_MAX_CANON            2
130 #define _PC_MAX_INPUT            3
131 #define _PC_NAME_MAX             4
132 #define _PC_PATH_MAX             5
133 #define _PC_PIPE_BUF             6
134 #define _PC_CHOWN_RESTRICTED     7
135 #define _PC_NO_TRUNC             8
136 #define _PC_VDISABLE             9
137
138 #if __POSIX_VISIBLE >= 199309
139 #define _PC_ASYNC_IO            53
140 #define _PC_PRIO_IO             54
141 #define _PC_SYNC_IO             55
142 #endif
143
144 #if __POSIX_VISIBLE >= 200112
145 #define _PC_ALLOC_SIZE_MIN      10
146 #define _PC_FILESIZEBITS        12
147 #define _PC_REC_INCR_XFER_SIZE  14
148 #define _PC_REC_MAX_XFER_SIZE   15
149 #define _PC_REC_MIN_XFER_SIZE   16
150 #define _PC_REC_XFER_ALIGN      17
151 #define _PC_SYMLINK_MAX         18
152 #endif
153
154 #if __POSIX_VISIBLE >= 200809
155 #define _PC_2_SYMLINKS          22
156 #endif
157
158 #if __BSD_VISIBLE
159 #define _PC_ACL_EXTENDED        59
160 #define _PC_ACL_PATH_MAX        60
161 #define _PC_CAP_PRESENT         61
162 #define _PC_INF_PRESENT         62
163 #define _PC_MAC_PRESENT         63
164 #endif
165
166 /* From OpenSolaris, used by SEEK_DATA/SEEK_HOLE. */
167 #define _PC_MIN_HOLE_SIZE       21
168
169 #if __BSD_VISIBLE
170 /*
171  * rfork() options.
172  *
173  * XXX currently, operations without RFPROC set are not supported.
174  */
175 #define RFNAMEG         (1<<0)  /* UNIMPL new plan9 `name space' */
176 #define RFENVG          (1<<1)  /* UNIMPL copy plan9 `env space' */
177 #define RFFDG           (1<<2)  /* copy fd table */
178 #define RFNOTEG         (1<<3)  /* UNIMPL create new plan9 `note group' */
179 #define RFPROC          (1<<4)  /* change child (else changes curproc) */
180 #define RFMEM           (1<<5)  /* share `address space' */
181 #define RFNOWAIT        (1<<6)  /* parent need not wait() on child */
182 #define RFCNAMEG        (1<<10) /* UNIMPL zero plan9 `name space' */
183 #define RFCENVG         (1<<11) /* UNIMPL zero plan9 `env space' */
184 #define RFCFDG          (1<<12) /* zero fd table */
185 #define RFTHREAD        (1<<13) /* enable kernel thread support */
186 #define RFSIGSHARE      (1<<14) /* share signal handlers */
187 #define RFLINUXTHPN     (1<<16) /* do linux clone exit parent notification */
188 #define RFPGLOCK        (1<<30) /* process group interlock for signal race */
189 #define RFPPWAIT        (1<<31) /* parent sleeps until child exits (vfork) */
190 #define RFKERNELONLY    (RFPGLOCK | RFPPWAIT)
191
192 /*
193  * Extended exit extexit() operation modes.
194  */
195 /* Types of action to communicate exit */
196 #define EXTEXIT_SIMPLE  0
197 #define EXTEXIT_SETINT  1
198 #define EXTEXIT_ACTION(f) ((f) & 0xffff)
199 /* Types describing what to exit */
200 #define EXTEXIT_PROC    (0<<16)
201 #define EXTEXIT_LWP     (1<<16)
202 #define EXTEXIT_WHO(f)  ((f) & (0xffff<<16))
203
204
205 /*
206  * Parameters for the creation of a new lwp.
207  */
208 struct lwp_params {
209         void (*lwp_func)(void *); /* Function to start execution */
210         void *lwp_arg;          /* Parameter to this function */
211         void *lwp_stack;        /* Stack address to use */
212         lwpid_t *lwp_tid1;      /* Address to copy out new tid */
213         lwpid_t *lwp_tid2;      /* Same */
214 };
215
216 #endif /* __BSD_VISIBLE */
217
218 #endif /* !_SYS_UNISTD_H_ */