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. All advertising materials mentioning features or use of this software 14 * must display the following acknowledgement: 15 * This product includes software developed by the University of 16 * California, Berkeley and its contributors. 17 * 4. Neither the name of the University nor the names of its contributors 18 * may be used to endorse or promote products derived from this software 19 * without specific prior written permission. 20 * 21 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 22 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 23 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 24 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 25 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 26 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 27 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 28 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 29 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 30 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 31 * SUCH DAMAGE. 32 * 33 * @(#)unistd.h 8.2 (Berkeley) 1/7/94 34 * $FreeBSD: src/sys/sys/unistd.h,v 1.22.2.2 2000/08/22 01:46:30 jhb Exp $ 35 * $DragonFly: src/sys/sys/unistd.h,v 1.9 2008/02/21 12:47:54 hasso Exp $ 36 */ 37 38 #ifndef _SYS_UNISTD_H_ 39 #define _SYS_UNISTD_H_ 40 41 #include <sys/types.h> 42 #include <sys/_posix.h> 43 44 /* compile-time symbolic constants */ 45 #define _POSIX_JOB_CONTROL /* implementation supports job control */ 46 47 /* 48 * Although we have saved user/group IDs, we do not use them in setuid 49 * as described in POSIX 1003.1, because the feature does not work for 50 * root. We use the saved IDs in seteuid/setegid, which are not currently 51 * part of the POSIX 1003.1 specification. 52 */ 53 #ifdef _NOT_AVAILABLE 54 #define _POSIX_SAVED_IDS /* saved set-user-ID and set-group-ID */ 55 #endif 56 57 #define _POSIX2_VERSION 199212L 58 59 /* execution-time symbolic constants */ 60 /* chown requires appropriate privileges */ 61 #define _POSIX_CHOWN_RESTRICTED 1 62 /* too-long path components generate errors */ 63 #define _POSIX_NO_TRUNC 1 64 /* may disable terminal special characters */ 65 #define _POSIX_VDISABLE 0xff 66 67 /* 68 * Threads features: 69 * 70 * Note that those commented out are not currently supported by the 71 * implementation. 72 */ 73 #define _POSIX_THREADS 200112L 74 #define _POSIX_THREAD_ATTR_STACKADDR 200112L 75 #define _POSIX_THREAD_ATTR_STACKSIZE 200112L 76 #define _POSIX_THREAD_PRIORITY_SCHEDULING 200112L 77 #define _POSIX_THREAD_PRIO_INHERIT 200112L 78 #define _POSIX_THREAD_PRIO_PROTECT 200112L 79 /* #define _POSIX_THREAD_PROCESS_SHARED */ 80 /* 81 * 1003.1c-1995 says on page 38 (2.9.3, paragraph 3) that if _POSIX_THREADS is 82 * defined, then _POSIX_THREAD_SAFE_FUNCTIONS must also be defined. (This is 83 * likely a typo (reversed dependency), in which case we would be compliant if 84 * the typo were officially acknowledged.) However, we do not support all of 85 * the required _r() interfaces, which means we cannot legitimately define 86 * _POSIX_THREAD_SAFE_FUNCTIONS. Therefore, we are non-compliant here in two 87 * ways. 88 */ 89 /* #define _POSIX_THREAD_SAFE_FUNCTIONS */ 90 #define _POSIX_SEMAPHORES 200112L 91 92 /* access function */ 93 #define F_OK 0 /* test for existence of file */ 94 #define X_OK 0x01 /* test for execute or search permission */ 95 #define W_OK 0x02 /* test for write permission */ 96 #define R_OK 0x04 /* test for read permission */ 97 98 /* whence values for lseek(2) */ 99 #define SEEK_SET 0 /* set file offset to offset */ 100 #define SEEK_CUR 1 /* set file offset to current plus offset */ 101 #define SEEK_END 2 /* set file offset to EOF plus offset */ 102 103 #ifndef _POSIX_SOURCE 104 /* whence values for lseek(2); renamed by POSIX 1003.1 */ 105 #define L_SET SEEK_SET 106 #define L_INCR SEEK_CUR 107 #define L_XTND SEEK_END 108 #endif 109 110 /* configurable pathname variables */ 111 #define _PC_LINK_MAX 1 112 #define _PC_MAX_CANON 2 113 #define _PC_MAX_INPUT 3 114 #define _PC_NAME_MAX 4 115 #define _PC_PATH_MAX 5 116 #define _PC_PIPE_BUF 6 117 #define _PC_CHOWN_RESTRICTED 7 118 #define _PC_NO_TRUNC 8 119 #define _PC_VDISABLE 9 120 121 /* configurable system variables */ 122 #define _SC_ARG_MAX 1 123 #define _SC_CHILD_MAX 2 124 #define _SC_CLK_TCK 3 125 #define _SC_NGROUPS_MAX 4 126 #define _SC_OPEN_MAX 5 127 #define _SC_JOB_CONTROL 6 128 #define _SC_SAVED_IDS 7 129 #define _SC_VERSION 8 130 #define _SC_BC_BASE_MAX 9 131 #define _SC_BC_DIM_MAX 10 132 #define _SC_BC_SCALE_MAX 11 133 #define _SC_BC_STRING_MAX 12 134 #define _SC_COLL_WEIGHTS_MAX 13 135 #define _SC_EXPR_NEST_MAX 14 136 #define _SC_LINE_MAX 15 137 #define _SC_RE_DUP_MAX 16 138 #define _SC_2_VERSION 17 139 #define _SC_2_C_BIND 18 140 #define _SC_2_C_DEV 19 141 #define _SC_2_CHAR_TERM 20 142 #define _SC_2_FORT_DEV 21 143 #define _SC_2_FORT_RUN 22 144 #define _SC_2_LOCALEDEF 23 145 #define _SC_2_SW_DEV 24 146 #define _SC_2_UPE 25 147 #define _SC_STREAM_MAX 26 148 #define _SC_TZNAME_MAX 27 149 #define _SC_IOV_MAX 56 150 151 /* configurable system strings */ 152 #define _CS_PATH 1 153 154 #ifdef _P1003_1B_VISIBLE 155 156 #define _POSIX_PRIORITY_SCHEDULING 200112L 157 158 #if 0 159 /* Not until the dust settles after the header commit 160 */ 161 #define _POSIX_ASYNCHRONOUS_IO 162 #define _POSIX_MEMLOCK 163 #define _POSIX_MEMLOCK_RANGE 164 #endif 165 166 /* ??? #define _POSIX_FSYNC 1 */ 167 #define _POSIX_MAPPED_FILES 200112L 168 #define _POSIX_SHARED_MEMORY_OBJECTS 200112L 169 170 /* POSIX.1B sysconf options */ 171 #define _SC_ASYNCHRONOUS_IO 28 172 #define _SC_MAPPED_FILES 29 173 #define _SC_MEMLOCK 30 174 #define _SC_MEMLOCK_RANGE 31 175 #define _SC_MEMORY_PROTECTION 32 176 #define _SC_MESSAGE_PASSING 33 177 #define _SC_PRIORITIZED_IO 34 178 #define _SC_PRIORITY_SCHEDULING 35 179 #define _SC_REALTIME_SIGNALS 36 180 #define _SC_SEMAPHORES 37 181 #define _SC_FSYNC 38 182 #define _SC_SHARED_MEMORY_OBJECTS 39 183 #define _SC_SYNCHRONIZED_IO 40 184 #define _SC_TIMERS 41 185 #define _SC_AIO_LISTIO_MAX 42 186 #define _SC_AIO_MAX 43 187 #define _SC_AIO_PRIO_DELTA_MAX 44 188 #define _SC_DELAYTIMER_MAX 45 189 #define _SC_MQ_OPEN_MAX 46 190 #define _SC_PAGESIZE 47 191 #define _SC_RTSIG_MAX 48 192 #define _SC_SEM_NSEMS_MAX 49 193 #define _SC_SEM_VALUE_MAX 50 194 #define _SC_SIGQUEUE_MAX 51 195 #define _SC_TIMER_MAX 52 196 197 /* POSIX.1B pathconf and fpathconf options */ 198 #define _PC_ASYNC_IO 53 199 #define _PC_PRIO_IO 54 200 #define _PC_SYNC_IO 55 201 202 #endif /* _P1003_1B_VISIBLE */ 203 204 #define _SC_NPROCESSORS_CONF 57 205 #define _SC_NPROCESSORS_ONLN 58 206 207 #ifndef _POSIX_SOURCE 208 /* 209 * rfork() options. 210 * 211 * XXX currently, operations without RFPROC set are not supported. 212 */ 213 #define RFNAMEG (1<<0) /* UNIMPL new plan9 `name space' */ 214 #define RFENVG (1<<1) /* UNIMPL copy plan9 `env space' */ 215 #define RFFDG (1<<2) /* copy fd table */ 216 #define RFNOTEG (1<<3) /* UNIMPL create new plan9 `note group' */ 217 #define RFPROC (1<<4) /* change child (else changes curproc) */ 218 #define RFMEM (1<<5) /* share `address space' */ 219 #define RFNOWAIT (1<<6) /* parent need not wait() on child */ 220 #define RFCNAMEG (1<<10) /* UNIMPL zero plan9 `name space' */ 221 #define RFCENVG (1<<11) /* UNIMPL zero plan9 `env space' */ 222 #define RFCFDG (1<<12) /* zero fd table */ 223 #define RFTHREAD (1<<13) /* enable kernel thread support */ 224 #define RFSIGSHARE (1<<14) /* share signal handlers */ 225 #define RFLINUXTHPN (1<<16) /* do linux clone exit parent notification */ 226 #define RFPGLOCK (1<<30) /* process group interlock for signal race */ 227 #define RFPPWAIT (1<<31) /* parent sleeps until child exits (vfork) */ 228 #define RFKERNELONLY (RFPPWAIT|RFPGLOCK) 229 230 /* 231 * Extended exit extexit() operation modes. 232 */ 233 /* Types of action to communicate exit */ 234 #define EXTEXIT_SIMPLE 0 235 #define EXTEXIT_SETINT 1 236 #define EXTEXIT_ACTION(f) ((f) & 0xffff) 237 /* Types describing what to exit */ 238 #define EXTEXIT_PROC (0<<16) 239 #define EXTEXIT_LWP (1<<16) 240 #define EXTEXIT_WHO(f) ((f) & (0xffff<<16)) 241 242 243 /* 244 * Parameters for the creation of a new lwp. 245 */ 246 struct lwp_params { 247 void (*func)(void *); /* Function to start execution */ 248 void *arg; /* Parameter to this function */ 249 void *stack; /* Stack address to use */ 250 lwpid_t *tid1; /* Address to copy out new tid */ 251 lwpid_t *tid2; /* Same */ 252 }; 253 254 #endif /* !_POSIX_SOURCE */ 255 256 #endif /* !_SYS_UNISTD_H_ */ 257