duckinator / unistd.h
# ifndef _UNISTD_H |
# define _UNISTD_H |
/* ok, this may be a joke, but I’m working on it */ |
# define _POSIX_VERSION 198808L |
# define _POSIX_CHOWN_RESTRICTED /* only root can do a chown (I think..) */ |
/* #define _POSIX_NO_TRUNC */ /* pathname truncation (but see in kernel) */ |
# define _POSIX_VDISABLE ‘ \0 ‘ /* character to disable things like ^C */ |
/* #define _POSIX_SAVED_IDS */ /* we’ll get to this yet */ |
/* #define _POSIX_JOB_CONTROL */ /* we aren’t there quite yet. Soon hopefully */ |
# define STDIN_FILENO 0 |
# define STDOUT_FILENO 1 |
# define STDERR_FILENO 2 |
# ifndef NULL |
# define NULL (( void *) 0 ) |
# endif |
/* access */ |
# define F_OK 0 |
# define X_OK 1 |
# define W_OK 2 |
# define R_OK 4 |
/* lseek */ |
# define SEEK_SET 0 |
# define SEEK_CUR 1 |
# define SEEK_END 2 |
/* _SC stands for System Configuration. We don’t use them much */ |
# define _SC_ARG_MAX 1 |
# define _SC_CHILD_MAX 2 |
# define _SC_CLOCKS_PER_SEC 3 |
# define _SC_NGROUPS_MAX 4 |
# define _SC_OPEN_MAX 5 |
# define _SC_JOB_CONTROL 6 |
# define _SC_SAVED_IDS 7 |
# define _SC_VERSION 8 |
/* more (possibly) configurable things — now pathnames */ |
# define _PC_LINK_MAX 1 |
# define _PC_MAX_CANON 2 |
# define _PC_MAX_INPUT 3 |
# define _PC_NAME_MAX 4 |
# define _PC_PATH_MAX 5 |
# define _PC_PIPE_BUF 6 |
# define _PC_NO_TRUNC 7 |
# define _PC_VDISABLE 8 |
# define _PC_CHOWN_RESTRICTED 9 |
# include sys/stat.h > |
# include sys/times.h > |
# include sys/utsname.h > |
# include utime.h > |
# ifdef __LIBRARY__ |
# define __NR_setup 0 /* used only by init, to get system going */ |
# define __NR_exit 1 |
# define __NR_fork 2 |
# define __NR_read 3 |
# define __NR_write 4 |
# define __NR_open 5 |
# define __NR_close 6 |
# define __NR_waitpid 7 |
# define __NR_creat 8 |
# define __NR_link 9 |
# define __NR_unlink 10 |
# define __NR_execve 11 |
# define __NR_chdir 12 |
# define __NR_time 13 |
# define __NR_mknod 14 |
# define __NR_chmod 15 |
# define __NR_chown 16 |
# define __NR_break 17 |
# define __NR_stat 18 |
# define __NR_lseek 19 |
# define __NR_getpid 20 |
# define __NR_mount 21 |
# define __NR_umount 22 |
# define __NR_setuid 23 |
# define __NR_getuid 24 |
# define __NR_stime 25 |
# define __NR_ptrace 26 |
# define __NR_alarm 27 |
# define __NR_fstat 28 |
# define __NR_pause 29 |
# define __NR_utime 30 |
# define __NR_stty 31 |
# define __NR_gtty 32 |
# define __NR_access 33 |
# define __NR_nice 34 |
# define __NR_ftime 35 |
# define __NR_sync 36 |
# define __NR_kill 37 |
# define __NR_rename 38 |
# define __NR_mkdir 39 |
# define __NR_rmdir 40 |
# define __NR_dup 41 |
# define __NR_pipe 42 |
# define __NR_times 43 |
# define __NR_prof 44 |
# define __NR_brk 45 |
# define __NR_setgid 46 |
# define __NR_getgid 47 |
# define __NR_signal 48 |
# define __NR_geteuid 49 |
# define __NR_getegid 50 |
# define __NR_acct 51 |
# define __NR_phys 52 |
# define __NR_lock 53 |
# define __NR_ioctl 54 |
# define __NR_fcntl 55 |
# define __NR_mpx 56 |
# define __NR_setpgid 57 |
# define __NR_ulimit 58 |
# define __NR_uname 59 |
# define __NR_umask 60 |
# define __NR_chroot 61 |
# define __NR_ustat 62 |
# define __NR_dup2 63 |
# define __NR_getppid 64 |
# define __NR_getpgrp 65 |
# define __NR_setsid 66 |
# define _syscall0 ( type,name ) \ |
type name ( void ) \ |
< \ |
type __res; \ |
__asm__ volatile ( » int $0x80 » \ |
: » =a » (__res) \ |
: » 0 » (__NR_##name)); \ |
if (__res >= 0 ) \ |
return __res; \ |
errno = -__res; \ |
return — 1 ; \ |
> |
# define _syscall1 ( type,name,atype,a ) \ |
type name (atype a) \ |
< \ |
type __res; \ |
__asm__ volatile ( » int $0x80 » \ |
: » =a » (__res) \ |
: » 0 » (__NR_##name), » b » (a)); \ |
if (__res >= 0 ) \ |
return __res; \ |
errno = -__res; \ |
return — 1 ; \ |
> |
# define _syscall2 ( type,name,atype,a,btype,b ) \ |
type name (atype a,btype b) \ |
< \ |
type __res; \ |
__asm__ volatile ( » int $0x80 » \ |
: » =a » (__res) \ |
: » 0 » (__NR_##name), » b » (a), » c » (b)); \ |
if (__res >= 0 ) \ |
return __res; \ |
errno = -__res; \ |
return — 1 ; \ |
> |
# define _syscall3 ( type,name,atype,a,btype,b,ctype,c ) \ |
type name (atype a,btype b,ctype c) \ |
< \ |
type __res; \ |
__asm__ volatile ( » int $0x80 » \ |
: » =a » (__res) \ |
: » 0 » (__NR_##name), » b » (a), » c » (b), » d » (c)); \ |
if (__res 0 ) \ |
errno=-__res , __res = — 1 ; \ |
return __res;\ |
> |
# endif /* __LIBRARY__ */ |
extern int errno; |
int access ( const char * filename, mode_t mode); |
int acct ( const char * filename); |
int alarm ( int sec); |
int brk ( void * end_data_segment); |
void * sbrk ( ptrdiff_t increment); |
int chdir ( const char * filename); |
int chmod ( const char * filename, mode_t mode); |
int chown ( const char * filename, uid_t owner, gid_t group); |
int chroot ( const char * filename); |
int close ( int fildes); |
int creat ( const char * filename, mode_t mode); |
int dup ( int fildes); |
int execve ( const char * filename, char ** argv, char ** envp); |
int execv ( const char * pathname, char ** argv); |
int execvp ( const char * file, char ** argv); |
int execl ( const char * pathname, char * arg0, . ); |
int execlp ( const char * file, char * arg0, . ); |
int execle ( const char * pathname, char * arg0, . ); |
void exit ( int status); |
void _exit ( int status); |
int fcntl ( int fildes, int cmd, . ); |
int fork ( void ); |
int getpid ( void ); |
int getuid ( void ); |
int geteuid ( void ); |
int getgid ( void ); |
int getegid ( void ); |
int ioctl ( int fildes, int cmd, . ); |
int kill ( pid_t pid, int signal); |
int link ( const char * filename1, const char * filename2); |
int lseek ( int fildes, off_t offset, int origin); |
int mknod ( const char * filename, mode_t mode, dev_t dev); |
int mount ( const char * specialfile, const char * dir, int rwflag); |
int nice ( int val); |
int open ( const char * filename, int flag, . ); |
int pause ( void ); |
int pipe ( int * fildes); |
int read ( int fildes, char * buf, off_t count); |
int setpgrp ( void ); |
int setpgid ( pid_t pid, pid_t pgid); |
int setuid ( uid_t uid); |
int setgid ( gid_t gid); |
void (* signal ( int sig, void (*fn)( int )))( int ); |
int stat ( const char * filename, struct stat * stat_buf); |
int fstat ( int fildes, struct stat * stat_buf); |
int stime ( time_t * tptr); |
int sync ( void ); |
time_t time ( time_t * tloc); |
time_t times ( struct tms * tbuf); |
int ulimit ( int cmd, long limit); |
mode_t umask ( mode_t mask); |
int umount ( const char * specialfile); |
int uname ( struct utsname * name); |
int unlink ( const char * filename); |
int ustat ( dev_t dev, struct ustat * ubuf); |
int utime ( const char * filename, struct utimbuf * times); |
pid_t waitpid ( pid_t pid, int * wait_stat, int options); |
pid_t wait ( int * wait_stat); |
int write ( int fildes, const char * buf, off_t count); |
int dup2 ( int oldfd, int newfd); |
int getppid ( void ); |
pid_t getpgrp ( void ); |
pid_t setsid ( void ); |
# endif |
You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.
Unistd h for windows
The unistd.h > header defines the symbolic constants and structures which are not already defined or declared in some other header. The contents of this header are shown below.
Version Test Macros
The following symbolic constants are defined (with fixed values):
_POSIX_VERSION Integer value indicating version of the POSIX standard (C language binding). See standards (5).
_POSIX2_VERSION Integer value indicating version of the POSIX.2 standard (Commands).
_POSIX2_C_VERSION Integer value indicating version of the POSIX.2 standard (C language binding).
_XOPEN_VERSION Integer value indicating version of the XPG to which system conforms.
_XOPEN_XCU_VERSION Integer value indicating the version of the XCU specification to which the implementation conforms. If this constant is not defined, use the sysconf (3C) function to determine which features are supported. This constant is not defined for the SUSv3 environment.
Mandatory Symbolic Constants
The following symbolic constants, if defined in unistd.h >, have a value of -1, 0, or greater, unless otherwise specified below. If these are undefined, the fpathconf (2), pathconf (2), or sysconf (3C) functions can be used to determine whether the option is provided for a particular invocation of the application.
If a symbolic constant is defined with the value -1, the option is not supported. Headers, data types, and function interfaces required only for the option need not be supplied. An application that attempts to use anything associated only with the option is considered to be requiring an extension.
If a symbolic constant is defined with a value greater than zero, the option is always supported when the application is executed. All headers, data types, and functions are present and operate as specified.
If a symbolic constant is defined with the value zero, all headers, data types, and functions are present. The application can check at runtime to see whether the option is supported by calling fpathconf() , pathconf() , or sysconf() with the indicated name parameter.
Unless explicitly specified otherwise, the behavior of functions associated with an unsupported option is unspecified, and an application that uses such functions without first checking fpathconf() , pathconf() , or sysconf() is considered to be requiring an extension.
Implementation supports the Advisory Information option.
Implementation supports the Asynchronous Input and Output option.
Implementation supports the Barriers option.
Implementation supports the Clock Selection option.
Implementation supports the Process CPU-Time Clocks option.
Implementation supports the File Synchronisation option.
Implementation supports the IPv6 option.
Implementation supports job control.
Implementation supports the Memory Mapped Files option.
Implementation supports the Process Memory Locking option.
Implementation supports the Range Memory Locking option.
Implementation supports the Memory Protection option.
Implementation supports the Message Passing option.
Implementation supports the Monotonic Clock option.
Implementation supports the Process Scheduling option.
Implementation supports the Raw Sockets option.
Implementation supports the Read-Write Locks option.
Implementation supports the Realtime Signals Extension option.
Implementation supports the Regular Expression Handling option.
The exec functions (see exec (2)) save the effective user and group.
Implementation supports the Semaphores option.
Implementation supports the Shared Memory Objects option.
Implementation supports the POSIX shell.
Implementation supports the Spawn option.
Implementation supports the Spin Locks option.
Implementation supports the Process Sporadic Server option.
Implementation supports the Synchronized Input and Output option.
Implementation supports the thread stack address attribute option.
Implementation supports the thread stack size attribute option.
Implementation supports the Thread CPU-Time Clocks option.
Implementation supports the process-shared synchronization option.
Implementation supports the thread-safe functions option.
Implementation supports the Thread Sporadic Server option.
Implementation supports the threads option.
Implementation supports the Timers option.
Implementation supports the Timeouts option.
Implementation supports the Trace option.
Implementation supports the Trace Event Filter option.
Implementation supports the Trace Inherit option.
Implementation supports the Trace Log option.
Implementation supports the Typed Memory Objects option.
Implementation provides a C-language compilation environment with 32-bit int , long , and pointer types and an off_t type using at least 64 bits.
Implementation provides a C-language compilation environment with 32-bit int , long , and pointer types and an off_t type using at least 64 bits.
Implementation provides a C-language compilation environment with 32-bit int and 64-bit long , pointer , and off_t types.
Implementation provides a C-language compilation environment with an int type using at least 32 bits and long , pointer , and off_t types using at least 64 bits.
Implementation supports the XSI STREAMS Option Group.
Implementation supports the C Language Binding option.
Implementation supports the C Language Development Utilities option.
Implementation supports at least one terminal type.
Implementation supports the creation of locales by the localedef (1) utility.
Implementation supports the Batch Environment Services and Utilities option.
Implementation supports the Batch Accounting option.
Implementation supports the Batch Checkpoint/Restart option.
Implementation supports the Locate Batch Job Request option.
Implementation supports the Batch Job Message Request option.
Implementation supports the Track Batch Job Request option.
Implementation supports the Software Development Utilities option.
Implementation supports the User Portability Utilities option.
Implementation provides a C-language compilation environment with 32-bit int , long , pointer and off_t types.
Implementation provides a C-language compilation environment with 32-bit int , long and pointer types and an off_t type using at least 64 bits.
Implementation provides a C-language compilation environment with 32-bit int and 64-bit long , pointer and off_t types.
Implementation provides a C-language compilation environment with an int type using at least 32 bits and long , pointer and off_t types using at least 64 bits.
Implementation supports the Issue 4, Version 2 Enhanced Internationalization Feature Group.
Implementation supports the Legacy Feature Group.
Implementation supports the X/Open Realtime Feature Group.
Implementation supports the Issue 4, Version 2 Shared Memory Feature Group.
X/Open CAE Specification, January 1997, System Interfaces and Headers, Issue 5 (ISBN: 1-85912-181-0, C606).
X/Open Specification, February 1992, System Interfaces and Headers, Issue 3 (ISBN: 1-872630-37-5, C212); this specification was formerly X/Open Portability Guide, Issue 3, Volume 2, January 1989, XSI System Interface and Headers (ISBN: 0-13-685843-0, XO/XPG/89/003).
X/Open CAE Specification, July 1992, System Interfaces and Headers, Issue 4 (ISBN: 1-872630-47-2, C202).
Execution-time Symbolic Constants
If any of the following constants are not defined in the header , the value varies depending on the file to which it is applied.
If any of the following constants are defined to have value -1 in the header , the implementation will not provide the option on any file; if any are defined to have a value other than -1 in the header , the implementation will provide the option on all applicable files.
All of the following constants, whether defined in or not, can be queried with respect to a specific file using the pathconf() or fpathconf() functions.
_POSIX_ASYNC_IO Asynchronous input or output operations can be performed for the associated file.
_POSIX_PRIO_IO Prioritized input or output operations can be performed for the associated file.
_POSIX_SYNC_IO Synchronized input or output operations can be performed for the associated file.
Constants for Functions
The following constant is defined:
The following symbolic constants are defined for the access (2) function:
R_OK Test for read permission.
W_OK Test for write permission.
X_OK Test for execute (search) permission.
F_OK Test for existence of file.
The constants F_OK , R_OK , W_OK , and X_OK , and the expressions R_OK|W_OK , R_OK|X_OK , and R_OK|W_OK|X_OK all have distinct values.
The following symbolic constants are defined for the lockf (3C) function:
F_ULOCK Unlock a previously locked region.
F_LOCK Lock a region for exclusive use.
F_TLOCK Test and lock a region for exclusive use.
F_TEST Test a region for other processes locks.
The following symbolic constants are defined for the lseek (2) and fcntl (2) functions (they have distinct values):
SEEK_SET Set file offset to offset .
SEEK_CUR Set file offset to current plus offset .
SEEK_END Set file offset to EOF plus offset .
The following symbolic constants are defined for the confstr (3C) function for both SPARC and x86:
_CS_LFS64_CFLAGS | _CS_LFS64_LDFLAGS |
_CS_LFS64_LIBS | _CS_LFS64_LINTFLAGS |
_CS_LFS_CFLAGS | |
_CS_LFS_LIBS | |
_CS_PATH | |
_CS_POSIX_V6_ILP32_OFF32_LDFLAGS | |
_CS_POSIX_V6_ILP32_OFF32_LINTFLAGS | |
_CS_POSIX_V6_ILP32_OFFBIG_LDFLAGS | |
_CS_POSIX_V6_ILP32_OFFBIG_LINTFLAGS | |
_CS_XBS5_ILP32_OFF32_CFLAGS | |
_CS_XBS5_ILP32_OFF32_LIBS | |
_CS_XBS5_ILP32_OFFBIG_CFLAGS | |
_CS_XBS5_ILP32_OFFBIG_LIBS |
The followwing symbolic constants are defined for the confstr() function for SPARC only:
_CS_POSIX_V6_LP64_OFF64_CFLAGS | _CS_POSIX_V6_LP64_OFF64_LDFLAGS |
_CS_POSIX_V6_LP64_OFF64_LIBS | _CS_POSIX_V6_LP64_OFF64_LINTFLAGS |
_CS_POSIX_V6_LPBIG_OFFBIG_CFLAGS | |
_CS_POSIX_V6_LPBIG_OFFBIG_LIBS | |
_CS_XBS5_LP64_OFF64_CFLAGS | |
_CS_XBS5_LP64_OFF64_LIBS | |
_CS_XBS5_LPBIG_OFFBIG_CFLAGS | |
_CS_XBS5_LPBIG_OFFBIG_LIBS |
The following symbolic constants are defined for the sysconf (3C) function:
_SC_2_C_BIND | _SC_2_C_DEV |
_SC_2_C_VERSION | _SC_2_FORT_DEV |
_SC_2_FORT_RUN | |
_SC_2_PBS | |
_SC_2_PBS_CHECKPOINT | |
_SC_2_PBS_MESSAGE | |
_SC_2_SW_DEV | |
_SC_2_VERSION | |
_SC_AIO_LISTIO_MAX | |
_SC_AIO_PRIO_DELTA_MAX | |
_SC_ASYNCHRONOUS_IO | |
_SC_AVPHYS_PAGES | |
_SC_BC_BASE_MAX | |
_SC_BC_SCALE_MAX | |
_SC_CHILD_MAX | |
_SC_CLOCK_SELECTION | |
_SC_CPUTIME | |
_SC_EXPR_NEST_MAX | |
_SC_GETGR_R_SIZE_MAX | |
_SC_HOST_NAME_MAX | |
_SC_IPV6 | |
_SC_LINE_MAX | |
_SC_LOGNAME_MAX | |
_SC_MEMLOCK | |
_SC_MEMORY_PROTECTION | |
_SC_MONOTONIC_CLOCK | |
_SC_MQ_PRIO_MAX | |
_SC_NPROCESSORS_CONF | |
_SC_OPEN_MAX | |
_SC_PAGE_SIZE | |
_SC_PHYS_PAGES | |
_SC_PRIORITY_SCHEDULING | |
_SC_READER_WRITER_LOCKS | |
_SC_REGEXP | |
_SC_RTSIG_MAX | |
_SC_SEMAPHORES | |
_SC_SEM_VALUE_MAX | |
_SC_SHELL | |
_SC_SPAWN | |
_SC_SPORADIC_SERVER | |
_SC_STREAM_MAX | |
_SC_SYNCHRONIZED_IO | |
_SC_THREAD_ATTR_STACKSIZE | |
_SC_THREAD_DESTRUCTOR_ITERATIONS | |
_SC_THREAD_PRIO_INHERIT | |
_SC_THREAD_PRIORITY_SCHEDULING | |
_SC_THREAD_SPORADIC_SERVER | |
_SC_THREAD_SAFE_FUNCTIONS | |
_SC_THREAD_THREADS_MAX | |
_SC_TIMER_MAX | |
_SC_TRACE | |
_SC_TRACE_EVENT_NAME_MAX | |
_SC_TRACE_LOG | |
_SC_TRACE_SYS_MAX | |
_SC_TTY_NAME_MAX | |
_SC_TZNAME_MAX | |
_SC_V6_ILP32_OFFBIG | |
_SC_V6_LPBIG_OFFBIG | |
_SC_XBS5_ILP32_OFF32 | |
_SC_XBS5_LP64_OFF64 | |
_SC_XOPEN_CRYPT | |
_SC_XOPEN_SHM | |
_SC_XOPEN_UNIX | |
_SC_XOPEN_XCU_VERSION |
The constants _SC_PAGESIZE and _SC_PAGE_SIZE can be defined to have the same value.
The following symbolic constants are defined for the fpathconf (2) function:
_PC_2_SYMLINKS | _PC_ALLOC_SIZE_MIN |
_PC_ASYNC_IO | _PC_CHOWN_RESTRICTED |
_PC_FILESIZEBITS | |
_PC_MAX_CANON | |
_PC_NAME_MAX | |
_PC_PATH_MAX | |
_PC_PRIO_IO | |
_PC_REC_MAX_XFER_SIZE | |
_PC_REC_XFER_ALIGN | |
_PC_SYNC_IO | |
_PC_XATTR_ENABLED |
The following symbolic constants are defined for file streams:
STDIN_FILENO File number ( 0 ) of stdin .
STDOUT_FILENO File number ( 1 ) of stout .
STDERR_FILENO File number ( 2 ) of stderr .
The following pathnames are defined:
GF_PATH Pathname of the group file.
PF_PATH Pathname of the passwd file.
ATTRIBUTES
See attributes (5) for descriptions of the following attributes: