1/* $NetBSD: unistd.h,v 1.52.18.1 2012/08/09 06:49:23 jdc 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 /* CPU type */ 97#undef _POSIX_CPUTYPE 98 /* file synchronization is available */ 99#define _POSIX_FSYNC 1 100 /* support IPv6 */ 101#define _POSIX_IPV6 0 102 /* job control is available */ 103#define _POSIX_JOB_CONTROL 1 104 /* memory mapped files */ 105#define _POSIX_MAPPED_FILES 1 106 /* memory locking whole address space */ 107#define _POSIX_MEMLOCK 1 108 /* memory locking address ranges */ 109#define _POSIX_MEMLOCK_RANGE 1 110 /* memory access protections */ 111#define _POSIX_MEMORY_PROTECTION 1 112 /* message passing is available */ 113#define _POSIX_MESSAGE_PASSING 200112L 114 /* monotonic clock */ 115#define _POSIX_MONOTONIC_CLOCK 200112L 116 /* too-long path comp generate errors */ 117#define _POSIX_NO_TRUNC 1 118 /* prioritized I/O */ 119#define _POSIX_PRIORITIZED_IO -1 120 /* priority scheduling */ 121#define _POSIX_PRIORITY_SCHEDULING 200112L 122 /* raw sockets */ 123#define _POSIX_RAW_SOCKETS 200112L 124 /* read/write locks */ 125#define _POSIX_READER_WRITER_LOCKS 200112L 126 /* realtime signals */ 127#undef _POSIX_REALTIME_SIGNALS 128 /* regular expressions */ 129#define _POSIX_REGEXP 1 130 /* semaphores */ 131#define _POSIX_SEMAPHORES 0 132 /* shared memory */ 133#undef _POSIX_SHARED_MEMORY_OBJECTS 134 /* shell */ 135#define _POSIX_SHELL 1 136 /* spin locks */ 137#define _POSIX_SPIN_LOCKS 200112L 138 /* sporadic server */ 139#undef _POSIX_SPORADIC_SERVER 140 /* synchronized I/O is available */ 141#define _POSIX_SYNCHRONIZED_IO 1 142 /* threads */ 143#define _POSIX_THREADS 200112L 144 /* pthread_attr for stack size */ 145#define _POSIX_THREAD_ATTR_STACKSIZE 200112L 146 /* pthread_attr for stack address */ 147#define _POSIX_THREAD_ATTR_STACKADDR 200112L 148 /* _r functions */ 149#define _POSIX_THREAD_SAFE_FUNCTIONS 200112L 150 /* timeouts */ 151#undef _POSIX_TIMEOUTS 152 /* timers */ 153#define _POSIX_TIMERS 200112L 154 /* typed memory objects */ 155#undef _POSIX_TYPED_MEMORY_OBJECTS 156 /* may disable terminal spec chars */ 157#define _POSIX_VDISABLE __CAST(unsigned char, '\377') 158 159 /* C binding */ 160#define _POSIX2_C_BIND 200112L 161 162 /* XPG4.2 shared memory */ 163#define _XOPEN_SHM 0 164 165/* access function */ 166#define F_OK 0 /* test for existence of file */ 167#define X_OK 0x01 /* test for execute or search permission */ 168#define W_OK 0x02 /* test for write permission */ 169#define R_OK 0x04 /* test for read permission */ 170 171/* whence values for lseek(2) */ 172#define SEEK_SET 0 /* set file offset to offset */ 173#define SEEK_CUR 1 /* set file offset to current plus offset */ 174#define SEEK_END 2 /* set file offset to EOF plus offset */ 175 176#if defined(_NETBSD_SOURCE) 177/* whence values for lseek(2); renamed by POSIX 1003.1 */ 178#define L_SET SEEK_SET 179#define L_INCR SEEK_CUR 180#define L_XTND SEEK_END 181 182/* 183 * fsync_range values. 184 * 185 * Note the following flag values were chosen to not overlap 186 * values for SEEK_XXX flags. While not currently implemented, 187 * it is possible to extend this call to respect SEEK_CUR and 188 * SEEK_END offset addressing modes. 189 */ 190#define FDATASYNC 0x0010 /* sync data and minimal metadata */ 191#define FFILESYNC 0x0020 /* sync data and metadata */ 192#define FDISKSYNC 0x0040 /* flush disk caches after sync */ 193#endif 194 195/* configurable pathname variables; use as argument to pathconf(3) */ 196#define _PC_LINK_MAX 1 197#define _PC_MAX_CANON 2 198#define _PC_MAX_INPUT 3 199#define _PC_NAME_MAX 4 200#define _PC_PATH_MAX 5 201#define _PC_PIPE_BUF 6 202#define _PC_CHOWN_RESTRICTED 7 203#define _PC_NO_TRUNC 8 204#define _PC_VDISABLE 9 205#define _PC_SYNC_IO 10 206#define _PC_FILESIZEBITS 11 207#define _PC_SYMLINK_MAX 12 208#define _PC_2_SYMLINKS 13 209#define _PC_ACL_EXTENDED 14 210 211/* From OpenSolaris, used by SEEK_DATA/SEEK_HOLE. */ 212#define _PC_MIN_HOLE_SIZE 15 213 214/* configurable system variables; use as argument to sysconf(3) */ 215/* 216 * XXX The value of _SC_CLK_TCK is embedded in <time.h>. 217 * XXX The value of _SC_PAGESIZE is embedded in <sys/shm.h>. 218 */ 219#define _SC_ARG_MAX 1 220#define _SC_CHILD_MAX 2 221#define _O_SC_CLK_TCK 3 /* Old version, always 100 */ 222#define _SC_NGROUPS_MAX 4 223#define _SC_OPEN_MAX 5 224#define _SC_JOB_CONTROL 6 225#define _SC_SAVED_IDS 7 226#define _SC_VERSION 8 227#define _SC_BC_BASE_MAX 9 228#define _SC_BC_DIM_MAX 10 229#define _SC_BC_SCALE_MAX 11 230#define _SC_BC_STRING_MAX 12 231#define _SC_COLL_WEIGHTS_MAX 13 232#define _SC_EXPR_NEST_MAX 14 233#define _SC_LINE_MAX 15 234#define _SC_RE_DUP_MAX 16 235#define _SC_2_VERSION 17 236#define _SC_2_C_BIND 18 237#define _SC_2_C_DEV 19 238#define _SC_2_CHAR_TERM 20 239#define _SC_2_FORT_DEV 21 240#define _SC_2_FORT_RUN 22 241#define _SC_2_LOCALEDEF 23 242#define _SC_2_SW_DEV 24 243#define _SC_2_UPE 25 244#define _SC_STREAM_MAX 26 245#define _SC_TZNAME_MAX 27 246#define _SC_PAGESIZE 28 247#define _SC_PAGE_SIZE _SC_PAGESIZE /* 1170 compatibility */ 248#define _SC_FSYNC 29 249#define _SC_XOPEN_SHM 30 250#define _SC_SYNCHRONIZED_IO 31 251#define _SC_IOV_MAX 32 252#define _SC_MAPPED_FILES 33 253#define _SC_MEMLOCK 34 254#define _SC_MEMLOCK_RANGE 35 255#define _SC_MEMORY_PROTECTION 36 256#define _SC_LOGIN_NAME_MAX 37 257#define _SC_MONOTONIC_CLOCK 38 258#define _SC_CLK_TCK 39 /* New, variable version */ 259#define _SC_ATEXIT_MAX 40 260#define _SC_THREADS 41 261#define _SC_SEMAPHORES 42 262#define _SC_BARRIERS 43 263#define _SC_TIMERS 44 264#define _SC_SPIN_LOCKS 45 265#define _SC_READER_WRITER_LOCKS 46 266#define _SC_GETGR_R_SIZE_MAX 47 267#define _SC_GETPW_R_SIZE_MAX 48 268#define _SC_CLOCK_SELECTION 49 269#define _SC_ASYNCHRONOUS_IO 50 270#define _SC_AIO_LISTIO_MAX 51 271#define _SC_AIO_MAX 52 272#define _SC_MESSAGE_PASSING 53 273#define _SC_MQ_OPEN_MAX 54 274#define _SC_MQ_PRIO_MAX 55 275#define _SC_PRIORITY_SCHEDULING 56 276#define _SC_THREAD_DESTRUCTOR_ITERATIONS 57 277#define _SC_THREAD_KEYS_MAX 58 278#define _SC_THREAD_STACK_MIN 59 279#define _SC_THREAD_THREADS_MAX 60 280#define _SC_THREAD_ATTR_STACKADDR 61 281#define _SC_THREAD_ATTR_STACKSIZE 62 282#define _SC_THREAD_PRIORITY_SCHEDULING 63 283#define _SC_THREAD_PRIO_INHERIT 64 284#define _SC_THREAD_PRIO_PROTECT 65 285#define _SC_THREAD_PROCESS_SHARED 66 286#define _SC_THREAD_SAFE_FUNCTIONS 67 287#define _SC_TTY_NAME_MAX 68 288#define _SC_HOST_NAME_MAX 69 289#define _SC_PASS_MAX 70 290#define _SC_REGEXP 71 291#define _SC_SHELL 72 292#define _SC_SYMLOOP_MAX 73 293 294/* Actually, they are not supported or implemented yet */ 295#define _SC_V6_ILP32_OFF32 74 296#define _SC_V6_ILP32_OFFBIG 75 297#define _SC_V6_LP64_OFF64 76 298#define _SC_V6_LPBIG_OFFBIG 77 299#define _SC_2_PBS 80 300#define _SC_2_PBS_ACCOUNTING 81 301#define _SC_2_PBS_CHECKPOINT 82 302#define _SC_2_PBS_LOCATE 83 303#define _SC_2_PBS_MESSAGE 84 304#define _SC_2_PBS_TRACK 85 305 306/* This is implemented */ 307#define _SC_SPAWN 86 308 309/* Extensions found in Solaris and Linux. */ 310#define _SC_PHYS_PAGES 121 311 312#ifdef _NETBSD_SOURCE 313/* Commonly provided sysconf() extensions */ 314#define _SC_NPROCESSORS_CONF 1001 315#define _SC_NPROCESSORS_ONLN 1002 316/* Native variables */ 317#define _SC_SCHED_RT_TS 2001 318#define _SC_SCHED_PRI_MIN 2002 319#define _SC_SCHED_PRI_MAX 2003 320#endif /* _NETBSD_SOURCE */ 321 322/* configurable system strings */ 323#define _CS_PATH 1 324 325#endif /* !_SYS_UNISTD_H_ */ 326