/* Copyright (C) 1991-2018 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
The GNU C Library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with the GNU C Library; if not, see
<http://www.gnu.org/licenses/>. */
* POSIX Standard: 2.10 Symbolic Constants <unistd.h>
/* These may be used to determine what facilities are present at compile time.
Their values can be obtained at run time from `sysconf'. */
/* POSIX Standard approved as ISO/IEC 9945-1 as of September 2008. */
# define _POSIX_VERSION 200809L
#elif defined __USE_XOPEN2K
/* POSIX Standard approved as ISO/IEC 9945-1 as of December 2001. */
# define _POSIX_VERSION 200112L
#elif defined __USE_POSIX199506
/* POSIX Standard approved as ISO/IEC 9945-1 as of June 1995. */
# define _POSIX_VERSION 199506L
#elif defined __USE_POSIX199309
/* POSIX Standard approved as ISO/IEC 9945-1 as of September 1993. */
# define _POSIX_VERSION 199309L
/* POSIX Standard approved as ISO/IEC 9945-1 as of September 1990. */
# define _POSIX_VERSION 199009L
/* These are not #ifdef __USE_POSIX2 because they are
in the theoretically application-owned namespace. */
# define __POSIX2_THIS_VERSION 200809L
/* The utilities on GNU systems also correspond to this version. */
#elif defined __USE_XOPEN2K
/* The utilities on GNU systems also correspond to this version. */
# define __POSIX2_THIS_VERSION 200112L
#elif defined __USE_POSIX199506
/* The utilities on GNU systems also correspond to this version. */
# define __POSIX2_THIS_VERSION 199506L
/* The utilities on GNU systems also correspond to this version. */
# define __POSIX2_THIS_VERSION 199209L
/* The utilities on GNU systems also correspond to this version. */
#define _POSIX2_VERSION __POSIX2_THIS_VERSION
/* This symbol was required until the 2001 edition of POSIX. */
#define _POSIX2_C_VERSION __POSIX2_THIS_VERSION
/* If defined, the implementation supports the
C Language Bindings Option. */
#define _POSIX2_C_BIND __POSIX2_THIS_VERSION
/* If defined, the implementation supports the
C Language Development Utilities Option. */
#define _POSIX2_C_DEV __POSIX2_THIS_VERSION
/* If defined, the implementation supports the
Software Development Utilities Option. */
#define _POSIX2_SW_DEV __POSIX2_THIS_VERSION
/* If defined, the implementation supports the
creation of locales with the localedef utility. */
#define _POSIX2_LOCALEDEF __POSIX2_THIS_VERSION
/* X/Open version number to which the library conforms. It is selectable. */
# define _XOPEN_VERSION 700
#elif defined __USE_XOPEN2K
# define _XOPEN_VERSION 600
#elif defined __USE_UNIX98
# define _XOPEN_VERSION 500
# define _XOPEN_VERSION 4
/* Commands and utilities from XPG4 are available. */
#define _XOPEN_XCU_VERSION 4
/* We are compatible with the old published standards as well. */
/* The X/Open Unix extensions are available. */
/* The enhanced internationalization capabilities according to XPG4.2
#define _XOPEN_ENH_I18N 1
/* The legacy interfaces are also available. */
/* Get values of POSIX options:
If these symbols are defined, the corresponding features are
always available. If not, they may be available sometimes.
The current values can be obtained with `sysconf'.
_POSIX_JOB_CONTROL Job control is supported.
_POSIX_SAVED_IDS Processes have a saved set-user-ID
and a saved set-group-ID.
_POSIX_REALTIME_SIGNALS Real-time, queued signals are supported.
_POSIX_PRIORITY_SCHEDULING Priority scheduling is supported.
_POSIX_TIMERS POSIX.4 clocks and timers are supported.
_POSIX_ASYNCHRONOUS_IO Asynchronous I/O is supported.
_POSIX_PRIORITIZED_IO Prioritized asynchronous I/O is supported.
_POSIX_SYNCHRONIZED_IO Synchronizing file data is supported.
_POSIX_FSYNC The fsync function is present.
_POSIX_MAPPED_FILES Mapping of files to memory is supported.
_POSIX_MEMLOCK Locking of all memory is supported.
_POSIX_MEMLOCK_RANGE Locking of ranges of memory is supported.
_POSIX_MEMORY_PROTECTION Setting of memory protections is supported.
_POSIX_MESSAGE_PASSING POSIX.4 message queues are supported.
_POSIX_SEMAPHORES POSIX.4 counting semaphores are supported.
_POSIX_SHARED_MEMORY_OBJECTS POSIX.4 shared memory objects are supported.
_POSIX_THREADS POSIX.1c pthreads are supported.
_POSIX_THREAD_ATTR_STACKADDR Thread stack address attribute option supported.
_POSIX_THREAD_ATTR_STACKSIZE Thread stack size attribute option supported.
_POSIX_THREAD_SAFE_FUNCTIONS Thread-safe functions are supported.
_POSIX_THREAD_PRIORITY_SCHEDULING
POSIX.1c thread execution scheduling supported.
_POSIX_THREAD_PRIO_INHERIT Thread priority inheritance option supported.
_POSIX_THREAD_PRIO_PROTECT Thread priority protection option supported.
_POSIX_THREAD_PROCESS_SHARED Process-shared synchronization supported.
_POSIX_PII Protocol-independent interfaces are supported.
_POSIX_PII_XTI XTI protocol-indep. interfaces are supported.
_POSIX_PII_SOCKET Socket protocol-indep. interfaces are supported.
_POSIX_PII_INTERNET Internet family of protocols supported.
_POSIX_PII_INTERNET_STREAM Connection-mode Internet protocol supported.
_POSIX_PII_INTERNET_DGRAM Connectionless Internet protocol supported.
_POSIX_PII_OSI ISO/OSI family of protocols supported.
_POSIX_PII_OSI_COTS Connection-mode ISO/OSI service supported.
_POSIX_PII_OSI_CLTS Connectionless ISO/OSI service supported.
_POSIX_POLL Implementation supports `poll' function.
_POSIX_SELECT Implementation supports `select' and `pselect'.
_XOPEN_REALTIME X/Open realtime support is available.
_XOPEN_REALTIME_THREADS X/Open realtime thread support is available.
_XOPEN_SHM Shared memory interface according to XPG4.2.
_XBS5_ILP32_OFF32 Implementation provides environment with 32-bit
int, long, pointer, and off_t types.
_XBS5_ILP32_OFFBIG Implementation provides environment with 32-bit
int, long, and pointer and off_t with at least
_XBS5_LP64_OFF64 Implementation provides environment with 32-bit
int, and 64-bit long, pointer, and off_t types.
_XBS5_LPBIG_OFFBIG Implementation provides environment with at
least 32 bits int and long, pointer, and off_t
If any of these symbols is defined as -1, the corresponding option is not
true for any file. If any is defined as other than -1, the corresponding
option is true for all files. If a symbol is not defined at all, the value
for a specific file can be obtained from `pathconf' and `fpathconf'.
_POSIX_CHOWN_RESTRICTED Only the super user can use `chown' to change
the owner of a file. `chown' can only be used
to change the group ID of a file to a group of
which the calling process is a member.
_POSIX_NO_TRUNC Pathname components longer than
NAME_MAX generate an error.
_POSIX_VDISABLE If defined, if the value of an element of the
`c_cc' member of `struct termios' is
_POSIX_VDISABLE, no character will have the
effect associated with that element.
_POSIX_SYNC_IO Synchronous I/O may be performed.
_POSIX_ASYNC_IO Asynchronous I/O may be performed.
_POSIX_PRIO_IO Prioritized Asynchronous I/O may be performed.
Support for the Large File Support interface is not generally available.
If it is available the following constants are defined to one.
_LFS64_LARGEFILE Low-level I/O supports large files.
_LFS64_STDIO Standard I/O supports large files.
#include <bits/posix_opt.h>
/* Get the environment definitions from Unix98. */
#if defined __USE_UNIX98 || defined __USE_XOPEN2K
# include <bits/environments.h>
/* Standard file descriptors. */
#define STDIN_FILENO 0 /* Standard input. */
#define STDOUT_FILENO 1 /* Standard output. */
#define STDERR_FILENO 2 /* Standard error output. */
/* All functions that are not declared anywhere else. */
#ifndef __ssize_t_defined
typedef __ssize_t ssize_t;
# define __ssize_t_defined
#if defined __USE_XOPEN || defined __USE_XOPEN2K
/* The Single Unix specification says that some more types are
# ifndef __USE_FILE_OFFSET64
# if defined __USE_LARGEFILE64 && !defined __off64_t_defined
typedef __off64_t off64_t;
# define __off64_t_defined
# ifndef __useconds_t_defined
typedef __useconds_t useconds_t;
# define __useconds_t_defined
#if defined __USE_XOPEN_EXTENDED || defined __USE_XOPEN2K
# ifndef __intptr_t_defined
typedef __intptr_t intptr_t;
# define __intptr_t_defined
#if defined __USE_MISC || defined __USE_XOPEN
# ifndef __socklen_t_defined
typedef __socklen_t socklen_t;
# define __socklen_t_defined
/* Values for the second argument to access.
These may be OR'd together. */
#define R_OK 4 /* Test for read permission. */
#define W_OK 2 /* Test for write permission. */
#define X_OK 1 /* Test for execute permission. */
#define F_OK 0 /* Test for existence. */
/* Test for access to NAME using the real UID and real GID. */
extern int access (const char *__name, int __type) __THROW __nonnull ((1));
/* Test for access to NAME using the effective UID and GID
(as normal file operations use). */
extern int euidaccess (const char *__name, int __type)
/* An alias for `euidaccess', used by some other systems. */
extern int eaccess (const char *__name, int __type)
/* Test for access to FILE relative to the directory FD is open on.
If AT_EACCESS is set in FLAG, then use effective IDs like `eaccess',
otherwise use real IDs like `access'. */
extern int faccessat (int __fd, const char *__file, int __type, int __flag)
__THROW __nonnull ((2)) __wur;
/* Values for the WHENCE argument to lseek. */
#ifndef _STDIO_H /* <stdio.h> has the same definitions. */
# define SEEK_SET 0 /* Seek from beginning of file. */
# define SEEK_CUR 1 /* Seek from current position. */
# define SEEK_END 2 /* Seek from end of file. */
# define SEEK_DATA 3 /* Seek to next data. */
# define SEEK_HOLE 4 /* Seek to next hole. */
#if defined __USE_MISC && !defined L_SET
/* Old BSD names for the same constants; just for compatibility. */
/* Move FD's file position to OFFSET bytes from the
beginning of the file (if WHENCE is SEEK_SET),
the current position (if WHENCE is SEEK_CUR),
or the end of the file (if WHENCE is SEEK_END).
Return the new file position. */
#ifndef __USE_FILE_OFFSET64
extern __off_t lseek (int __fd, __off_t __offset, int __whence) __THROW;
extern __off64_t __REDIRECT_NTH (lseek,
(int __fd, __off64_t __offset, int __whence),
extern __off64_t lseek64 (int __fd, __off64_t __offset, int __whence)
/* Close the file descriptor FD.
This function is a cancellation point and therefore not marked with
extern int close (int __fd);
/* Read NBYTES into BUF from FD. Return the
number read, -1 for errors or 0 for EOF.
This function is a cancellation point and therefore not marked with
extern ssize_t read (int __fd, void *__buf, size_t __nbytes) __wur;
/* Write N bytes of BUF to FD. Return the number written, or -1.
This function is a cancellation point and therefore not marked with
extern ssize_t write (int __fd, const void *__buf, size_t __n) __wur;
#if defined __USE_UNIX98 || defined __USE_XOPEN2K8
# ifndef __USE_FILE_OFFSET64
/* Read NBYTES into BUF from FD at the given position OFFSET without
changing the file pointer. Return the number read, -1 for errors
This function is a cancellation point and therefore not marked with
extern ssize_t pread (int __fd, void *__buf, size_t __nbytes,
/* Write N bytes of BUF to FD at the given position OFFSET without
changing the file pointer. Return the number written, or -1.
This function is a cancellation point and therefore not marked with
extern ssize_t pwrite (int __fd, const void *__buf, size_t __n,
extern ssize_t __REDIRECT (pread, (int __fd, void *__buf, size_t __nbytes,
extern ssize_t __REDIRECT (pwrite, (int __fd, const void *__buf,
size_t __nbytes, __off64_t __offset),
# ifdef __USE_LARGEFILE64
/* Read NBYTES into BUF from FD at the given position OFFSET without
changing the file pointer. Return the number read, -1 for errors
extern ssize_t pread64 (int __fd, void *__buf, size_t __nbytes,
__off64_t __offset) __wur;
/* Write N bytes of BUF to FD at the given position OFFSET without
changing the file pointer. Return the number written, or -1. */
extern ssize_t pwrite64 (int __fd, const void *__buf, size_t __n,
__off64_t __offset) __wur;
/* Create a one-way communication channel (pipe).
If successful, two file descriptors are stored in PIPEDES;
bytes written on PIPEDES[1] can be read from PIPEDES[0].
Returns 0 if successful, -1 if not. */
extern int pipe (int __pipedes[2]) __THROW __wur;
/* Same as pipe but apply flags passed in FLAGS to the new file
extern int pipe2 (int __pipedes[2], int __flags) __THROW __wur;
/* Schedule an alarm. In SECONDS seconds, the process will get a SIGALRM.
If SECONDS is zero, any currently scheduled alarm will be cancelled.
The function returns the number of seconds remaining until the last
alarm scheduled would have signaled, or zero if there wasn't one.
There is no return value to indicate an error, but you can set `errno'
to 0 and check its value after calling `alarm', and this might tell you.
The signal may come late due to processor scheduling. */
extern unsigned int alarm (unsigned int __seconds) __THROW;
/* Make the process sleep for SECONDS seconds, or until a signal arrives
and is not ignored. The function returns the number of seconds less
than SECONDS which it actually slept (thus zero if it slept the full time).
If a signal handler does a `longjmp' or modifies the handling of the
SIGALRM signal while inside `sleep' call, the handling of the SIGALRM
signal afterwards is undefined. There is no return value to indicate
error, but if `sleep' returns SECONDS, it probably didn't work.
This function is a cancellation point and therefore not marked with
extern unsigned int sleep (unsigned int __seconds);
#if (defined __USE_XOPEN_EXTENDED && !defined __USE_XOPEN2K8) \
/* Set an alarm to go off (generating a SIGALRM signal) in VALUE
microseconds. If INTERVAL is nonzero, when the alarm goes off, the
timer is reset to go off every INTERVAL microseconds thereafter.
Returns the number of microseconds remaining before the alarm. */
extern __useconds_t ualarm (__useconds_t __value, __useconds_t __interval)
/* Sleep USECONDS microseconds, or until a signal arrives that is not blocked
This function is a cancellation point and therefore not marked with
extern int usleep (__useconds_t __useconds);
/* Suspend the process until a signal arrives.
This always returns -1 and sets `errno' to EINTR.
This function is a cancellation point and therefore not marked with
/* Change the owner and group of FILE. */
extern int chown (const char *__file, __uid_t __owner, __gid_t __group)
__THROW __nonnull ((1)) __wur;
#if defined __USE_XOPEN_EXTENDED || defined __USE_XOPEN2K8
/* Change the owner and group of the file that FD is open on. */
extern int fchown (int __fd, __uid_t __owner, __gid_t __group) __THROW __wur;
/* Change owner and group of FILE, if it is a symbolic
link the ownership of the symbolic link is changed. */
extern int lchown (const char *__file, __uid_t __owner, __gid_t __group)
__THROW __nonnull ((1)) __wur;
#endif /* Use X/Open Unix. */
/* Change the owner and group of FILE relative to the directory FD is open
extern int fchownat (int __fd, const char *__file, __uid_t __owner,
__gid_t __group, int __flag)
__THROW __nonnull ((2)) __wur;
/* Change the process's working directory to PATH. */
extern int chdir (const char *__path) __THROW __nonnull ((1)) __wur;
#if defined __USE_XOPEN_EXTENDED || defined __USE_XOPEN2K8
/* Change the process's working directory to the one FD is open on. */