| 1 | /* $NetBSD: unistd.h,v 1.61 2016/08/04 06:43:43 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 | /* configurable system variables; use as argument to sysconf(3) */ |
| 221 | /* |
| 222 | * XXX The value of _SC_CLK_TCK is embedded in <time.h>. |
| 223 | * XXX The value of _SC_PAGESIZE is embedded in <sys/shm.h>. |
| 224 | */ |
| 225 | #define _SC_ARG_MAX 1 |
| 226 | #define _SC_CHILD_MAX 2 |
| 227 | #define _O_SC_CLK_TCK 3 /* Old version, always 100 */ |
| 228 | #define _SC_NGROUPS_MAX 4 |
| 229 | #define _SC_OPEN_MAX 5 |
| 230 | #define _SC_JOB_CONTROL 6 |
| 231 | #define _SC_SAVED_IDS 7 |
| 232 | #define _SC_VERSION 8 |
| 233 | #define _SC_BC_BASE_MAX 9 |
| 234 | #define _SC_BC_DIM_MAX 10 |
| 235 | #define _SC_BC_SCALE_MAX 11 |
| 236 | #define _SC_BC_STRING_MAX 12 |
| 237 | #define _SC_COLL_WEIGHTS_MAX 13 |
| 238 | #define _SC_EXPR_NEST_MAX 14 |
| 239 | #define _SC_LINE_MAX 15 |
| 240 | #define _SC_RE_DUP_MAX 16 |
| 241 | #define _SC_2_VERSION 17 |
| 242 | #define _SC_2_C_BIND 18 |
| 243 | #define _SC_2_C_DEV 19 |
| 244 | #define _SC_2_CHAR_TERM 20 |
| 245 | #define _SC_2_FORT_DEV 21 |
| 246 | #define _SC_2_FORT_RUN 22 |
| 247 | #define _SC_2_LOCALEDEF 23 |
| 248 | #define _SC_2_SW_DEV 24 |
| 249 | #define _SC_2_UPE 25 |
| 250 | #define _SC_STREAM_MAX 26 |
| 251 | #define _SC_TZNAME_MAX 27 |
| 252 | #define _SC_PAGESIZE 28 |
| 253 | #define _SC_PAGE_SIZE _SC_PAGESIZE /* 1170 compatibility */ |
| 254 | #define _SC_FSYNC 29 |
| 255 | #define _SC_XOPEN_SHM 30 |
| 256 | #define _SC_SYNCHRONIZED_IO 31 |
| 257 | #define _SC_IOV_MAX 32 |
| 258 | #define _SC_MAPPED_FILES 33 |
| 259 | #define _SC_MEMLOCK 34 |
| 260 | #define _SC_MEMLOCK_RANGE 35 |
| 261 | #define _SC_MEMORY_PROTECTION 36 |
| 262 | #define _SC_LOGIN_NAME_MAX 37 |
| 263 | #define _SC_MONOTONIC_CLOCK 38 |
| 264 | #define _SC_CLK_TCK 39 /* New, variable version */ |
| 265 | #define _SC_ATEXIT_MAX 40 |
| 266 | #define _SC_THREADS 41 |
| 267 | #define _SC_SEMAPHORES 42 |
| 268 | #define _SC_BARRIERS 43 |
| 269 | #define _SC_TIMERS 44 |
| 270 | #define _SC_SPIN_LOCKS 45 |
| 271 | #define _SC_READER_WRITER_LOCKS 46 |
| 272 | #define _SC_GETGR_R_SIZE_MAX 47 |
| 273 | #define _SC_GETPW_R_SIZE_MAX 48 |
| 274 | #define _SC_CLOCK_SELECTION 49 |
| 275 | #define _SC_ASYNCHRONOUS_IO 50 |
| 276 | #define _SC_AIO_LISTIO_MAX 51 |
| 277 | #define _SC_AIO_MAX 52 |
| 278 | #define _SC_MESSAGE_PASSING 53 |
| 279 | #define _SC_MQ_OPEN_MAX 54 |
| 280 | #define _SC_MQ_PRIO_MAX 55 |
| 281 | #define _SC_PRIORITY_SCHEDULING 56 |
| 282 | #define _SC_THREAD_DESTRUCTOR_ITERATIONS 57 |
| 283 | #define _SC_THREAD_KEYS_MAX 58 |
| 284 | #define _SC_THREAD_STACK_MIN 59 |
| 285 | #define _SC_THREAD_THREADS_MAX 60 |
| 286 | #define _SC_THREAD_ATTR_STACKADDR 61 |
| 287 | #define _SC_THREAD_ATTR_STACKSIZE 62 |
| 288 | #define _SC_THREAD_PRIORITY_SCHEDULING 63 |
| 289 | #define _SC_THREAD_PRIO_INHERIT 64 |
| 290 | #define _SC_THREAD_PRIO_PROTECT 65 |
| 291 | #define _SC_THREAD_PROCESS_SHARED 66 |
| 292 | #define _SC_THREAD_SAFE_FUNCTIONS 67 |
| 293 | #define _SC_TTY_NAME_MAX 68 |
| 294 | #define _SC_HOST_NAME_MAX 69 |
| 295 | #define _SC_PASS_MAX 70 |
| 296 | #define _SC_REGEXP 71 |
| 297 | #define _SC_SHELL 72 |
| 298 | #define _SC_SYMLOOP_MAX 73 |
| 299 | |
| 300 | /* Actually, they are not supported or implemented yet */ |
| 301 | #define _SC_V6_ILP32_OFF32 74 |
| 302 | #define _SC_V6_ILP32_OFFBIG 75 |
| 303 | #define _SC_V6_LP64_OFF64 76 |
| 304 | #define _SC_V6_LPBIG_OFFBIG 77 |
| 305 | #define _SC_2_PBS 80 |
| 306 | #define _SC_2_PBS_ACCOUNTING 81 |
| 307 | #define _SC_2_PBS_CHECKPOINT 82 |
| 308 | #define _SC_2_PBS_LOCATE 83 |
| 309 | #define _SC_2_PBS_MESSAGE 84 |
| 310 | #define _SC_2_PBS_TRACK 85 |
| 311 | |
| 312 | /* These are implemented */ |
| 313 | #define _SC_SPAWN 86 |
| 314 | #define _SC_SHARED_MEMORY_OBJECTS 87 |
| 315 | |
| 316 | #define _SC_TIMER_MAX 88 |
| 317 | #define _SC_SEM_NSEMS_MAX 89 |
| 318 | #define _SC_CPUTIME 90 |
| 319 | #define _SC_THREAD_CPUTIME 91 |
| 320 | #define _SC_DELAYTIMER_MAX 92 |
| 321 | #define _SC_SIGQUEUE_MAX 93 |
| 322 | #define _SC_REALTIME_SIGNALS 94 |
| 323 | |
| 324 | /* Extensions found in Solaris and Linux. */ |
| 325 | #define _SC_PHYS_PAGES 121 |
| 326 | |
| 327 | #ifdef _NETBSD_SOURCE |
| 328 | /* Commonly provided sysconf() extensions */ |
| 329 | #define _SC_NPROCESSORS_CONF 1001 |
| 330 | #define _SC_NPROCESSORS_ONLN 1002 |
| 331 | /* Native variables */ |
| 332 | #define _SC_SCHED_RT_TS 2001 |
| 333 | #define _SC_SCHED_PRI_MIN 2002 |
| 334 | #define _SC_SCHED_PRI_MAX 2003 |
| 335 | #endif /* _NETBSD_SOURCE */ |
| 336 | |
| 337 | /* configurable system strings */ |
| 338 | #define _CS_PATH 1 |
| 339 | |
| 340 | #endif /* !_SYS_UNISTD_H_ */ |
| 341 | |