FreeNOS
Data Structures | Macros | Typedefs | Functions | Variables
libposix

Provides support for the POSIX.1-2008 portable operating system interface for user programs. More...

Data Structures

struct  FileSystemMount
 Represents a mounted filesystem. More...
 
struct  dirent
 Represents a directory entry. More...
 
struct  DIR
 A type representing a directory stream. More...
 
struct  FILE
 A structure containing information about a file. More...
 
struct  sockaddr
 Defines a socket address and port pair. More...
 
struct  iovec
 Input/Output vector for multi-packet operations. More...
 
struct  msghdr
 Describes one or more datagrams. More...
 
struct  stat
 The <sys/stat.h> header shall define the stat structure. More...
 
struct  timeval
 Time value information. More...
 
struct  timezone
 Time zone information. More...
 
struct  utsname
 System name structure. More...
 
struct  timespec
 The <time.h> header shall declare the timespec structure. More...
 

Macros

#define assert(exp)
 Insert program diagnostics. More...
 
#define isdigit(c)   Character::isDigit(c)
 Test for a decimal digit. More...
 
#define islower(c)   Character::isLower(c)
 Test for a lowercase letter. More...
 
#define isupper(c)   Character::isUpper(c)
 Test for an uppercase letter. More...
 
#define isalpha(c)   Character::isAlpha(c)
 Test for an alphabetic character. More...
 
#define isalnum(c)   Character::isAlnum(c)
 Test for an alphanumeric character. More...
 
#define isblank(c)   Character::isBlank(c)
 Test for a blank character. More...
 
#define isspace(c)   Character::isSpace(c)
 Test for a white-space character. More...
 
#define tolower(c)   Character::lower(c)
 Converts the letter c to lowercase. More...
 
#define toupper(c)   Character::upper(c)
 Converts the letter c to uppercase. More...
 
#define DT_UNKNOWN   0
 The file type is unknown. More...
 
#define DT_FIFO   1
 This is a named pipe (FIFO). More...
 
#define DT_CHR   2
 This is a character device. More...
 
#define DT_DIR   4
 This is a directory. More...
 
#define DT_BLK   6
 This is a block device. More...
 
#define DT_REG   8
 This is a regular file. More...
 
#define DT_LNK   10
 This is a symbolic link. More...
 
#define DT_SOCK   12
 This is a Unix domain socket. More...
 
#define DIRLEN   64
 Maximum length of a directory entry name. More...
 
#define CHAR_BIT   8
 Number of bits in a type char. More...
 
#define PATH_MAX   FileSystemPath::MaximumLength
 Maximum file path length. More...
 
#define dprintf(fmt, ...)   printf("{%s:%d}: " fmt, __FILE__, __LINE__, ##__VA_ARGS__);
 Output a debug message using printf(). More...
 
#define EXIT_SUCCESS   0
 Successful termination. More...
 
#define EXIT_FAILURE   1
 Unsuccessful termination. More...
 
#define FILETYPE_BITS   3
 Number of bits needed to store a FileType. More...
 
#define FILETYPE_MASK   7
 Masker value for all FileTypes. More...
 
#define FILEMODE_BITS   9
 Number of bits required for all FileModes. More...
 
#define FILEMODE_MASK   0777
 Masker value for all FileMode values. More...
 
#define UTSBUF   128
 Size of each buffer in the utsname structure fields. More...
 
#define WEXITSTATUS(st)   (st)
 Returns the exit status of the child process. More...
 
#define _POSIX_VERSION   200809L
 Integer value indicating version of this standard (C-language binding) to which the implementation conforms. More...
 
#define _POSIX2_VERSION   200809L
 Integer value indicating version of the Shell and Utilities volume of POSIX.1 to which the implementation conforms. More...
 

Typedefs

typedef struct FileSystemMount FileSystemMount
 Represents a mounted filesystem. More...
 
typedef struct DIR DIR
 A type representing a directory stream. More...
 
typedef Size socklen_t
 
typedef ProcessID pid_t
 Used for process IDs and process group IDs. More...
 
typedef Size size_t
 Used for sizes of objects. More...
 
typedef slong ssize_t
 Used for a count of bytes or an error indication. More...
 
typedef DeviceID dev_t
 Used for device IDs. More...
 
typedef uint ino_t
 Used for file serial numbers. More...
 
typedef uint mode_t
 Used for some file attributes. More...
 
typedef u16 uid_t
 Used for user IDs. More...
 
typedef u16 gid_t
 Used for group IDs. More...
 
typedef Size nlink_t
 Used for link counts. More...
 
typedef sint off_t
 Used for file sizes. More...
 
typedef sint blkcnt_t
 Used for file block counts. More...
 
typedef sint blksize_t
 Used for block sizes. More...
 
typedef u64 time_t
 Used for time in seconds. More...
 

Functions

C DIRopendir (const char *dirname)
 Open directory associated with file descriptor. More...
 
C struct direntreaddir (DIR *dirp)
 Read a directory. More...
 
C int closedir (DIR *dirp)
 Close a directory stream. More...
 
C int open (const char *path, int oflag,...)
 Open file relative to directory file descriptor. More...
 
C char * basename (char *path)
 Return the last component of a pathname. More...
 
C char * dirname (char *path)
 Return the directory portion of a pathname. More...
 
C int abs (int number)
 Compute the absolute value of a number. More...
 
C u32 sqrt (u32 number)
 Compute the square root of a number. More...
 
C int snprintf (char *buffer, unsigned int size, const char *fmt,...)
 Write a formatted string into a buffer. More...
 
C int vsnprintf (char *buffer, unsigned int size, const char *fmt, va_list args)
 Write a formatted string into a buffer. More...
 
C int printf (const char *format,...)
 Output a formatted string to standard output. More...
 
C int vprintf (const char *format, va_list args)
 Output a formatted string to standard output, using a variable argument list. More...
 
C void exit (int status)
 Terminate a process. More...
 
C void itoa (char *buffer, int divisor, int number)
 Convert a number to a string. More...
 
C int atoi (const char *nptr)
 Convert a string to an integer. More...
 
C long strtol (const char *nptr, char **endptr, int base)
 Convert a string to a long integer. More...
 
C void * malloc (size_t size)
 A memory allocator. More...
 
C void free (void *ptr)
 Free allocated memory. More...
 
C void srandom (unsigned int seed)
 Random number generator. More...
 
C long int random (void)
 Random number generator. More...
 
C int strcmp (const char *dest, const char *src)
 Compare two strings. More...
 
C int strncmp (const char *dest, const char *src, size_t count)
 Compare two strings, by only a maximum number of bytes. More...
 
C int strcasecmp (const char *dest, const char *src)
 Compare two strings, ignoring case considerations. More...
 
C int strncasecmp (const char *dest, const char *src, size_t count)
 Compare two strings, ignoring case considerations. More...
 
C char * strdup (const char *str)
 Duplicate a string. More...
 
C char * strndup (const char *s, size_t size)
 Duplicate a specific number of bytes from a string. More...
 
C void * memset (void *dest, int ch, size_t count)
 Fill memory with a constant byte. More...
 
C void * memcpy (void *dest, const void *src, size_t count)
 Copy memory from one place to another. More...
 
C size_t strlen (const char *str)
 Calculate the length of a string. More...
 
C int strcpy (char *dest, const char *src)
 Copy a string. More...
 
C int strncpy (char *dest, const char *src, size_t sz)
 Copy a string, given a maximum number of bytes. More...
 
C size_t strlcpy (char *dst, const char *src, size_t siz)
 Copy src to string dst of size siz. More...
 
C char * strcat (char *dest, const char *src)
 Concatenate two strings. More...
 
C char * strncat (char *dest, const char *src, size_t siz)
 Concatenate a string with part of another. More...
 
C char * strerror (int errnum)
 The strerror function maps the number in errnum to a message string. More...
 
C char * strchr (const char *s, int c)
 String scanning operation. More...
 
C char * strrchr (const char *s, int c)
 String scanning operation. More...
 
C int connect (int sockfd, struct sockaddr *addr, socklen_t addrlen)
 Connect a socket to an address/port. More...
 
C int recvfrom (int sockfd, void *buf, size_t len, int flags, struct sockaddr *addr, socklen_t addrlen)
 Receive a single datagram from a socket. More...
 
C int sendto (int sockfd, const void *buf, size_t len, int flags, const struct sockaddr *addr, socklen_t addrlen)
 Send a single datagram to a remote host. More...
 
C int sendmsg (int sockfd, const struct msghdr *msg, int flags)
 Send multiple datagrams to a remote host. More...
 
C int stat (const char *path, struct stat *buf)
 Get file status. More...
 
C int mknod (const char *path, mode_t mode, dev_t dev)
 Make directory, special file, or regular file. More...
 
C int mkdir (const char *path, mode_t mode)
 Create a new directory. More...
 
C int creat (const char *path, mode_t mode)
 Create a new file or rewrite an existing one. More...
 
C int gettimeofday (struct timeval *tv, struct timezone *tz)
 Get current time of day. More...
 
C int uname (struct utsname *name)
 Get the name of the current system. More...
 
C pid_t waitpid (pid_t pid, int *stat_loc, int options)
 Wait for a child process to stop or terminate. More...
 
C unsigned long mktime (const unsigned int year, const unsigned int month, const unsigned int day, const unsigned int hour, const unsigned int min, const unsigned int sec)
 Convert given time values to UNIX timestamp (seconds since epoch) More...
 
C pid_t getpid ()
 Get the process ID. More...
 
C pid_t getppid ()
 Get parent process ID. More...
 
C ssize_t read (int fildes, void *buf, size_t nbyte)
 Read from a file. More...
 
C ssize_t write (int fildes, const void *buf, size_t nbyte)
 Write on a file. More...
 
C int close (int fildes)
 Close a file descriptor. More...
 
C off_t lseek (int fildes, off_t offset, int whence)
 Move the read/write file offset. More...
 
C int forkexec (const char *path, const char *argv[])
 Create a new process and execute program. More...
 
C int spawn (Address program, Size programSize, const char *argv[])
 Create a new process using in-memory image. More...
 
C int gethostname (char *name, size_t namelen)
 Get name of current host. More...
 
C char * getcwd (char *buf, size_t size)
 Get the pathname of the current working directory. More...
 
C int chdir (const char *path)
 Change working directory. More...
 
C int unlink (const char *path)
 Remove a file from the filesystem. More...
 
C unsigned int sleep (unsigned int seconds)
 Sleep for the specified number of seconds. More...
 

Variables

C int errno
 The lvalue errno is used by many functions to return error values. More...
 
C char * error_map []
 Contains a array of character strings, representing errno values. More...
 

Error codes

Functions that use errno variable can set the errno value to any of these values.

See also
errno
#define ESUCCESS   0
 Reports a success operation. More...
 
#define E2BIG   -1
 Argument list too long. More...
 
#define EACCES   -2
 Permission denied. More...
 
#define EADDRINUSE   -3
 Address in use. More...
 
#define EADDRNOTAVAIL   -4
 Address not available. More...
 
#define EAFNOSUPPORT   -5
 Address family not supported. More...
 
#define EAGAIN   -6
 Resource unavailable, try again (may be the same value as [EWOULDBLOCK]). More...
 
#define EALREADY   -7
 Connection already in progress. More...
 
#define EBADF   -8
 Bad file descriptor. More...
 
#define EBADMSG   -9
 Bad message. More...
 
#define EBUSY   -10
 Device or resource busy. More...
 
#define ECANCELED   -11
 Operation canceled. More...
 
#define ECHILD   -12
 No child processes. More...
 
#define ECONNABORTED   -13
 Connection aborted. More...
 
#define ECONNREFUSED   -14
 Connection refused. More...
 
#define ECONNRESET   -15
 Connection reset. More...
 
#define EDEADLK   -16
 Resource deadlock would occur. More...
 
#define EDESTADDRREQ   -17
 Destination address required. More...
 
#define EDOM   -18
 Mathematics argument out of domain of function. More...
 
#define EDQUOT   -19
 Reserved. More...
 
#define EEXIST   -20
 File exists. More...
 
#define EFAULT   -21
 Bad address. More...
 
#define EFBIG   -22
 File too large. More...
 
#define EHOSTUNREACH   -23
 Host is unreachable. More...
 
#define EIDRM   -24
 Identifier removed. More...
 
#define EILSEQ   -25
 Illegal byte sequence. More...
 
#define EINPROGRESS   -26
 Operation in progress. More...
 
#define EINTR   -27
 Interrupted function. More...
 
#define EINVAL   -28
 Invalid argument. More...
 
#define EIO   -29
 I/O error. More...
 
#define EISCONN   -30
 Socket is connected. More...
 
#define EISDIR   -31
 Is a directory. More...
 
#define ELOOP   -32
 Too many levels of symbolic links. More...
 
#define EMFILE   -33
 File descriptor value too large. More...
 
#define EMLINK   -34
 Too many links. More...
 
#define EMSGSIZE   -35
 Message too large. More...
 
#define EMULTIHOP   -36
 Reserved. More...
 
#define ENAMETOOLONG   -37
 Filename too long. More...
 
#define ENETDOWN   -38
 Network is down. More...
 
#define ENETRESET   -39
 Connection aborted by network. More...
 
#define ENETUNREACH   -40
 Network unreachable. More...
 
#define ENFILE   -41
 Too many files open in system. More...
 
#define ENOBUFS   -42
 No buffer space available. More...
 
#define ENODATA   -43
 No message is available on the STREAM head read queue. More...
 
#define ENODEV   -44
 No such device. More...
 
#define ENOENT   -45
 No such file or directory. More...
 
#define ENOEXEC   -46
 Executable file format error. More...
 
#define ENOLCK   -47
 No locks available. More...
 
#define ENOLINK   -48
 Reserved. More...
 
#define ENOMEM   -49
 Not enough space. More...
 
#define ENOMSG   -50
 No message of the desired type. More...
 
#define ENOPROTOOPT   -51
 Protocol not available. More...
 
#define ENOSPC   -52
 No space left on device. More...
 
#define ENOSR   -53
 No STREAM resources. More...
 
#define ENOSTR   -54
 Not a STREAM. More...
 
#define ENOSYS   -55
 Function not supported. More...
 
#define ENOTCONN   -56
 The socket is not connected. More...
 
#define ENOTDIR   -57
 Not a directory. More...
 
#define ENOTEMPTY   -58
 Directory not empty. More...
 
#define ENOTRECOVERABLE   -59
 State not recoverable. More...
 
#define ENOTSOCK   -60
 Not a socket. More...
 
#define ENOTSUP   -61
 Not supported (may be the same value as [EOPNOTSUPP]). More...
 
#define ENOTTY   -62
 Inappropriate I/O control operation. More...
 
#define ENXIO   -63
 No such device or address. More...
 
#define EOPNOTSUPP   -64
 Operation not supported on socket (may be the same value as [ENOTSUP]). More...
 
#define EOVERFLOW   -65
 Value too large to be stored in data type. More...
 
#define EOWNERDEAD   -66
 Previous owner died. More...
 
#define EPERM   -67
 Operation not permitted. More...
 
#define EPIPE   -68
 Broken pipe. More...
 
#define EPROTO   -69
 Protocol error. More...
 
#define EPROTONOSUPPORT   -70
 Protocol not supported. More...
 
#define EPROTOTYPE   -71
 Protocol wrong type for socket. More...
 
#define ERANGE   -72
 Result too large. More...
 
#define EROFS   -73
 Read-only file system. More...
 
#define ESPIPE   -74
 Invalid seek. More...
 
#define ESRCH   -75
 No such process. More...
 
#define ESTALE   -76
 Reserved. More...
 
#define ETIME   -77
 Stream ioctl() timeout. More...
 
#define ETIMEDOUT   -78
 Connection timed out. More...
 
#define ETXTBSY   -79
 Text file busy. More...
 
#define EWOULDBLOCK   -80
 Operation would block (may be the same value as [EAGAIN]). More...
 
#define EXDEV   -81
 Cross-device link. More...
 
#define ERESTART   (1 << 17)
 Triggers a restart of all filesystem requests. More...
 
#define ELAST   ERESTART
 Last defined error value (do not use). More...
 

File Constants

#define O_CREAT   (1 << 0)
 Create file if it does not exist. More...
 
#define O_EXCL   (1 << 1)
 Exclusive use flag. More...
 
#define O_NOCTTY   (1 << 2)
 Do not assign controlling terminal. More...
 
#define O_TRUNC   (1 << 3)
 Truncate flag. More...
 
#define O_TTY_INIT   (1 << 4)
 Set the termios structure terminal parameters to a state that provides conforming behavior; see Parameters that Can be Set. More...
 
#define O_APPEND   (1 << 5)
 Set append mode. More...
 
#define O_DSYNC   (1 << 6)
 Write according to synchronized I/O data integrity completion. More...
 
#define O_NONBLOCK   (1 << 7)
 Non-blocking mode. More...
 
#define O_RSYNC   (1 << 8)
 Synchronized read I/O operations. More...
 
#define O_SYNC   (1 << 9)
 Write according to synchronized I/O file integrity completion. More...
 
#define O_ACCMODE   (O_EXEC | O_RDONLY | O_RDWR | O_SEARCH | O_WRONLY)
 Mask for file access modes. More...
 
#define O_EXEC   (1 << 10)
 Open for execute only (non-directory files). More...
 
#define O_RDONLY   (1 << 11)
 Open for reading only. More...
 
#define O_RDWR   (1 << 12)
 Open for reading and writing. More...
 
#define O_SEARCH   (1 << 13)
 Open directory for search only. More...
 
#define O_WRONLY   (1 << 14)
 Open for writing only. More...
 

ISO C99 Signals

Note
This list based on the bits/signum-generic.h file in glibc.
#define SIGINT   2
 Interactive attention signal. More...
 
#define SIGILL   4
 Illegal instruction. More...
 
#define SIGABRT   6
 Abnormal termination. More...
 
#define SIGFPE   8
 Erroneous arithmetic operation. More...
 
#define SIGSEGV   11
 Invalid access to storage. More...
 
#define SIGTERM   15
 Termination request. More...
 

POSIX.1-2008 Signals

Note
This list based on the bits/signum-generic.h file in glibc.
#define SIGHUP   1
 Hangup. More...
 
#define SIGQUIT   3
 Quit. More...
 
#define SIGTRAP   5
 Trace/breakpoint trap. More...
 
#define SIGKILL   9
 Killed. More...
 
#define SIGBUS   10
 Bus error. More...
 
#define SIGSYS   12
 Bad system call. More...
 
#define SIGPIPE   13
 Broken pipe. More...
 
#define SIGALRM   14
 Alarm clock. More...
 
#define SIGURG   16
 Urgent data is available at a socket. More...
 
#define SIGSTOP   17
 Stop, unblockable. More...
 
#define SIGTSTP   18
 Keyboard stop. More...
 
#define SIGCONT   19
 Continue. More...
 
#define SIGCHLD   20
 Child terminated or stopped. More...
 
#define SIGTTIN   21
 Background read from control terminal. More...
 
#define SIGTTOU   22
 Background write to control terminal. More...
 
#define SIGPOLL   23
 Pollable event occurred (System V). More...
 
#define SIGXCPU   24
 CPU time limit exceeded. More...
 
#define SIGXFSZ   25
 File size limit exceeded. More...
 
#define SIGVTALRM   26
 Virtual timer expired. More...
 
#define SIGPROF   27
 Profiling timer expired. More...
 
#define SIGUSR1   30
 User-defined signal 1. More...
 
#define SIGUSR2   31
 User-defined signal 2. More...
 

Signal Functions

C int kill (pid_t pid, int sig)
 Send a signal to a process or a group of processes. More...
 

File seek operations

#define SEEK_CUR   0
 Seek relative to current position. More...
 
#define SEEK_END   1
 Seek relative to end-of-file. More...
 
#define SEEK_SET   2
 Seek relative to start-of-file. More...
 

File streams

typedef struct FILE FILE
 A structure containing information about a file. More...
 
C FILEfopen (const char *filename, const char *mode)
 Open a stream. More...
 
C size_t fread (void *ptr, size_t size, size_t nitems, FILE *stream)
 Binary input. More...
 
C size_t fwrite (const void *ptr, size_t size, size_t nitems, FILE *stream)
 The fwrite() function shall write, from the array pointed to by ptr, up to nitems elements whose size is specified by size, to the stream pointed to by stream. More...
 
C int fclose (FILE *stream)
 Close a stream. More...
 

File stat type bits.

The <sys/stat.h> header shall define the following symbolic constants for the file types encoded in type mode_t.

The values shall be suitable for use in #if preprocessing directives.

#define S_IFMT   (FILETYPE_MASK << FILEMODE_BITS)
 Type of file. More...
 
#define S_IFBLK   (FileSystem::BlockDeviceFile << FILEMODE_BITS)
 Block special. More...
 
#define S_IFCHR   (FileSystem::CharacterDeviceFile << FILEMODE_BITS)
 Character special. More...
 
#define S_IFIFO   (FileSystem::FIFOFile << FILEMODE_BITS)
 FIFO special. More...
 
#define S_IFREG   (FileSystem::RegularFile << FILEMODE_BITS)
 Regular. More...
 
#define S_IFDIR   (FileSystem::DirectoryFile << FILEMODE_BITS)
 Directory. More...
 
#define S_IFLNK   (FileSystem::SymlinkFile << FILEMODE_BITS)
 Symbolic link. More...
 
#define S_IFSOCK   (FileSystem::SocketFile << FILEMODE_BITS)
 Socket. More...
 
#define S_IRWXU   FileSystem::OwnerRWX
 File mode bits. More...
 
#define S_IRUSR   FileSystem::OwnerR
 Read permission, owner. More...
 
#define S_IWUSR   FileSystem::OwnerW
 Write permission, owner. More...
 
#define S_IXUSR   FileSystem::OwnerX
 Execute/search permission, owner. More...
 
#define S_IRWXG   FileSystem::GroupRWX
 Read, write, execute/search by group. More...
 
#define S_IRGRP   FileSystem::GroupR
 Read permission, group. More...
 
#define S_IWGRP   FileSystem::GroupW
 Write permission, group. More...
 
#define S_IXGRP   FileSystem::GroupX
 Execute/search permission, group. More...
 
#define S_IRWXO   FileSystem::OtherRWX
 Read, write, execute/search by others. More...
 
#define S_IROTH   FileSystem::OtherR
 Read permission, others. More...
 
#define S_IWOTH   FileSystem::OtherW
 Write permission, others. More...
 
#define S_IXOTH   FileSystem::OtherX
 Execute/search permission, others. More...
 

File type macros.

The following macros shall be provided to test whether a file is of the specified type.

The value m supplied to the macros is the value of st_mode from a stat structure. The macro shall evaluate to a non-zero value if the test is true; 0 if the test is false.

#define S_ISTYPE(mode, mask)   (((mode) & S_IFMT) == (mask))
 Test for mode bits. More...
 
#define S_ISBLK(m)   S_ISTYPE(m, S_IFBLK)
 Test for a block special file. More...
 
#define S_ISCHR(m)   S_ISTYPE(m, S_IFCHR)
 Test for a character special file. More...
 
#define S_ISDIR(m)   S_ISTYPE(m, S_IFDIR)
 Test for a directory. More...
 
#define S_ISFIFO(m)   S_ISTYPE(m, S_IFIFO)
 Test for a pipe or FIFO special file. More...
 
#define S_ISREG(m)   S_ISTYPE(m, S_IFREG)
 Test for a regular file. More...
 
#define S_ISLNK(m)   S_ISTYPE(m, S_IFLNK)
 Test for a symbolic link. More...
 
#define S_ISSOCK(m)   S_ISTYPE(m, S_IFSOCK)
 Test for a socket. More...
 

Detailed Description

Provides support for the POSIX.1-2008 portable operating system interface for user programs.

Macro Definition Documentation

◆ _POSIX2_VERSION

#define _POSIX2_VERSION   200809L

Integer value indicating version of the Shell and Utilities volume of POSIX.1 to which the implementation conforms.

For implementations conforming to POSIX.1-2008, the value shall be 200809L.

Definition at line 45 of file unistd.h.

◆ _POSIX_VERSION

#define _POSIX_VERSION   200809L

Integer value indicating version of this standard (C-language binding) to which the implementation conforms.

For implementations conforming to POSIX.1-2008, the value shall be 200809L.

Definition at line 38 of file unistd.h.

◆ assert

#define assert (   exp)
Value:
if (!(exp)) \
{ \
printf("[%s:%d]: *** Assertion `%s' failed ***\n", \
__FILE__, __LINE__, #exp); \
exit(1); \
}

Insert program diagnostics.

The assert() macro shall insert diagnostics into programs; it shall expand to a void expression. When it is executed, if expression (which shall have a scalar type) is false (that is, compares equal to 0), assert() shall write information about the particular call that failed on stderr and shall call abort().

The information written about the call that failed shall include the text of the argument, the name of the source file, the source file line number, and the name of the enclosing function; the latter are, respectively, the values of the preprocessing macros FILE and LINE and of the identifier func.

Forcing a definition of the name NDEBUG, either from the compiler command line or with the preprocessor control statement #define NDEBUG ahead of the #include <assert.h> statement, shall stop assertions from being compiled into the program.

Parameters
expBoolean expression.
Returns
The assert() macro shall not return a value.

Definition at line 60 of file assert.h.

◆ CHAR_BIT

#define CHAR_BIT   8

Number of bits in a type char.

Definition at line 34 of file limits.h.

◆ DIRLEN

#define DIRLEN   64

Maximum length of a directory entry name.

Definition at line 59 of file dirent.h.

◆ dprintf

#define dprintf (   fmt,
  ... 
)    printf("{%s:%d}: " fmt, __FILE__, __LINE__, ##__VA_ARGS__);

Output a debug message using printf().

Parameters
fmtFormatted string.
...Argument list.
See also
printf

Definition at line 179 of file stdio.h.

◆ DT_BLK

#define DT_BLK   6

This is a block device.

Definition at line 47 of file dirent.h.

◆ DT_CHR

#define DT_CHR   2

This is a character device.

Definition at line 41 of file dirent.h.

◆ DT_DIR

#define DT_DIR   4

This is a directory.

Definition at line 44 of file dirent.h.

◆ DT_FIFO

#define DT_FIFO   1

This is a named pipe (FIFO).

Definition at line 38 of file dirent.h.

◆ DT_LNK

#define DT_LNK   10

This is a symbolic link.

Definition at line 53 of file dirent.h.

◆ DT_REG

#define DT_REG   8

This is a regular file.

Definition at line 50 of file dirent.h.

◆ DT_SOCK

#define DT_SOCK   12

This is a Unix domain socket.

Definition at line 56 of file dirent.h.

◆ DT_UNKNOWN

#define DT_UNKNOWN   0

The file type is unknown.

Definition at line 35 of file dirent.h.

◆ E2BIG

#define E2BIG   -1

Argument list too long.

Definition at line 46 of file errno.h.

◆ EACCES

#define EACCES   -2

Permission denied.

Definition at line 49 of file errno.h.

◆ EADDRINUSE

#define EADDRINUSE   -3

Address in use.

Definition at line 52 of file errno.h.

◆ EADDRNOTAVAIL

#define EADDRNOTAVAIL   -4

Address not available.

Definition at line 55 of file errno.h.

◆ EAFNOSUPPORT

#define EAFNOSUPPORT   -5

Address family not supported.

Definition at line 58 of file errno.h.

◆ EAGAIN

#define EAGAIN   -6

Resource unavailable, try again (may be the same value as [EWOULDBLOCK]).

Definition at line 61 of file errno.h.

◆ EALREADY

#define EALREADY   -7

Connection already in progress.

Definition at line 64 of file errno.h.

◆ EBADF

#define EBADF   -8

Bad file descriptor.

Definition at line 67 of file errno.h.

◆ EBADMSG

#define EBADMSG   -9

Bad message.

Definition at line 70 of file errno.h.

◆ EBUSY

#define EBUSY   -10

Device or resource busy.

Definition at line 73 of file errno.h.

◆ ECANCELED

#define ECANCELED   -11

Operation canceled.

Definition at line 76 of file errno.h.

◆ ECHILD

#define ECHILD   -12

No child processes.

Definition at line 79 of file errno.h.

◆ ECONNABORTED

#define ECONNABORTED   -13

Connection aborted.

Definition at line 82 of file errno.h.

◆ ECONNREFUSED

#define ECONNREFUSED   -14

Connection refused.

Definition at line 85 of file errno.h.

◆ ECONNRESET

#define ECONNRESET   -15

Connection reset.

Definition at line 88 of file errno.h.

◆ EDEADLK

#define EDEADLK   -16

Resource deadlock would occur.

Definition at line 91 of file errno.h.

◆ EDESTADDRREQ

#define EDESTADDRREQ   -17

Destination address required.

Definition at line 94 of file errno.h.

◆ EDOM

#define EDOM   -18

Mathematics argument out of domain of function.

Definition at line 97 of file errno.h.

◆ EDQUOT

#define EDQUOT   -19

Reserved.

Definition at line 100 of file errno.h.

◆ EEXIST

#define EEXIST   -20

File exists.

Definition at line 103 of file errno.h.

◆ EFAULT

#define EFAULT   -21

Bad address.

Definition at line 106 of file errno.h.

◆ EFBIG

#define EFBIG   -22

File too large.

Definition at line 109 of file errno.h.

◆ EHOSTUNREACH

#define EHOSTUNREACH   -23

Host is unreachable.

Definition at line 112 of file errno.h.

◆ EIDRM

#define EIDRM   -24

Identifier removed.

Definition at line 115 of file errno.h.

◆ EILSEQ

#define EILSEQ   -25

Illegal byte sequence.

Definition at line 118 of file errno.h.

◆ EINPROGRESS

#define EINPROGRESS   -26

Operation in progress.

Definition at line 121 of file errno.h.

◆ EINTR

#define EINTR   -27

Interrupted function.

Definition at line 124 of file errno.h.

◆ EINVAL

#define EINVAL   -28

Invalid argument.

Definition at line 127 of file errno.h.

◆ EIO

#define EIO   -29

I/O error.

Definition at line 130 of file errno.h.

◆ EISCONN

#define EISCONN   -30

Socket is connected.

Definition at line 133 of file errno.h.

◆ EISDIR

#define EISDIR   -31

Is a directory.

Definition at line 136 of file errno.h.

◆ ELAST

#define ELAST   ERESTART

Last defined error value (do not use).

Definition at line 292 of file errno.h.

◆ ELOOP

#define ELOOP   -32

Too many levels of symbolic links.

Definition at line 139 of file errno.h.

◆ EMFILE

#define EMFILE   -33

File descriptor value too large.

Definition at line 142 of file errno.h.

◆ EMLINK

#define EMLINK   -34

Too many links.

Definition at line 145 of file errno.h.

◆ EMSGSIZE

#define EMSGSIZE   -35

Message too large.

Definition at line 148 of file errno.h.

◆ EMULTIHOP

#define EMULTIHOP   -36

Reserved.

Definition at line 151 of file errno.h.

◆ ENAMETOOLONG

#define ENAMETOOLONG   -37

Filename too long.

Definition at line 154 of file errno.h.

◆ ENETDOWN

#define ENETDOWN   -38

Network is down.

Definition at line 157 of file errno.h.

◆ ENETRESET

#define ENETRESET   -39

Connection aborted by network.

Definition at line 160 of file errno.h.

◆ ENETUNREACH

#define ENETUNREACH   -40

Network unreachable.

Definition at line 163 of file errno.h.

◆ ENFILE

#define ENFILE   -41

Too many files open in system.

Definition at line 166 of file errno.h.

◆ ENOBUFS

#define ENOBUFS   -42

No buffer space available.

Definition at line 169 of file errno.h.

◆ ENODATA

#define ENODATA   -43

No message is available on the STREAM head read queue.

Definition at line 172 of file errno.h.

◆ ENODEV

#define ENODEV   -44

No such device.

Definition at line 175 of file errno.h.

◆ ENOENT

#define ENOENT   -45

No such file or directory.

Definition at line 178 of file errno.h.

◆ ENOEXEC

#define ENOEXEC   -46

Executable file format error.

Definition at line 181 of file errno.h.

◆ ENOLCK

#define ENOLCK   -47

No locks available.

Definition at line 184 of file errno.h.

◆ ENOLINK

#define ENOLINK   -48

Reserved.

Definition at line 187 of file errno.h.

◆ ENOMEM

#define ENOMEM   -49

Not enough space.

Definition at line 190 of file errno.h.

◆ ENOMSG

#define ENOMSG   -50

No message of the desired type.

Definition at line 193 of file errno.h.

◆ ENOPROTOOPT

#define ENOPROTOOPT   -51

Protocol not available.

Definition at line 196 of file errno.h.

◆ ENOSPC

#define ENOSPC   -52

No space left on device.

Definition at line 199 of file errno.h.

◆ ENOSR

#define ENOSR   -53

No STREAM resources.

Definition at line 202 of file errno.h.

◆ ENOSTR

#define ENOSTR   -54

Not a STREAM.

Definition at line 205 of file errno.h.

◆ ENOSYS

#define ENOSYS   -55

Function not supported.

Definition at line 208 of file errno.h.

◆ ENOTCONN

#define ENOTCONN   -56

The socket is not connected.

Definition at line 211 of file errno.h.

◆ ENOTDIR

#define ENOTDIR   -57

Not a directory.

Definition at line 214 of file errno.h.

◆ ENOTEMPTY

#define ENOTEMPTY   -58

Directory not empty.

Definition at line 217 of file errno.h.

◆ ENOTRECOVERABLE

#define ENOTRECOVERABLE   -59

State not recoverable.

Definition at line 220 of file errno.h.

◆ ENOTSOCK

#define ENOTSOCK   -60

Not a socket.

Definition at line 223 of file errno.h.

◆ ENOTSUP

#define ENOTSUP   -61

Not supported (may be the same value as [EOPNOTSUPP]).

Definition at line 226 of file errno.h.

◆ ENOTTY

#define ENOTTY   -62

Inappropriate I/O control operation.

Definition at line 229 of file errno.h.

◆ ENXIO

#define ENXIO   -63

No such device or address.

Definition at line 232 of file errno.h.

◆ EOPNOTSUPP

#define EOPNOTSUPP   -64

Operation not supported on socket (may be the same value as [ENOTSUP]).

Definition at line 235 of file errno.h.

◆ EOVERFLOW

#define EOVERFLOW   -65

Value too large to be stored in data type.

Definition at line 238 of file errno.h.

◆ EOWNERDEAD

#define EOWNERDEAD   -66

Previous owner died.

Definition at line 241 of file errno.h.

◆ EPERM

#define EPERM   -67

Operation not permitted.

Definition at line 244 of file errno.h.

◆ EPIPE

#define EPIPE   -68

Broken pipe.

Definition at line 247 of file errno.h.

◆ EPROTO

#define EPROTO   -69

Protocol error.

Definition at line 250 of file errno.h.

◆ EPROTONOSUPPORT

#define EPROTONOSUPPORT   -70

Protocol not supported.

Definition at line 253 of file errno.h.

◆ EPROTOTYPE

#define EPROTOTYPE   -71

Protocol wrong type for socket.

Definition at line 256 of file errno.h.

◆ ERANGE

#define ERANGE   -72

Result too large.

Definition at line 259 of file errno.h.

◆ ERESTART

#define ERESTART   (1 << 17)

Triggers a restart of all filesystem requests.

Definition at line 289 of file errno.h.

◆ EROFS

#define EROFS   -73

Read-only file system.

Definition at line 262 of file errno.h.

◆ ESPIPE

#define ESPIPE   -74

Invalid seek.

Definition at line 265 of file errno.h.

◆ ESRCH

#define ESRCH   -75

No such process.

Definition at line 268 of file errno.h.

◆ ESTALE

#define ESTALE   -76

Reserved.

Definition at line 271 of file errno.h.

◆ ESUCCESS

#define ESUCCESS   0

Reports a success operation.

Definition at line 43 of file errno.h.

◆ ETIME

#define ETIME   -77

Stream ioctl() timeout.

Definition at line 274 of file errno.h.

◆ ETIMEDOUT

#define ETIMEDOUT   -78

Connection timed out.

Definition at line 277 of file errno.h.

◆ ETXTBSY

#define ETXTBSY   -79

Text file busy.

Definition at line 280 of file errno.h.

◆ EWOULDBLOCK

#define EWOULDBLOCK   -80

Operation would block (may be the same value as [EAGAIN]).

Definition at line 283 of file errno.h.

◆ EXDEV

#define EXDEV   -81

Cross-device link.

Definition at line 286 of file errno.h.

◆ EXIT_FAILURE

#define EXIT_FAILURE   1

Unsuccessful termination.

Definition at line 36 of file stdlib.h.

◆ EXIT_SUCCESS

#define EXIT_SUCCESS   0

Successful termination.

Definition at line 33 of file stdlib.h.

◆ FILEMODE_BITS

#define FILEMODE_BITS   9

Number of bits required for all FileModes.

Definition at line 42 of file stat.h.

◆ FILEMODE_MASK

#define FILEMODE_MASK   0777

Masker value for all FileMode values.

Definition at line 45 of file stat.h.

◆ FILETYPE_BITS

#define FILETYPE_BITS   3

Number of bits needed to store a FileType.

Definition at line 36 of file stat.h.

◆ FILETYPE_MASK

#define FILETYPE_MASK   7

Masker value for all FileTypes.

Definition at line 39 of file stat.h.

◆ isalnum

#define isalnum (   c)    Character::isAlnum(c)

Test for an alphanumeric character.

Parameters
cInput character.
Returns
Boolean

Definition at line 72 of file ctype.h.

◆ isalpha

#define isalpha (   c)    Character::isAlpha(c)

Test for an alphabetic character.

Parameters
cInput character.
Returns
Boolean

Definition at line 63 of file ctype.h.

◆ isblank

#define isblank (   c)    Character::isBlank(c)

Test for a blank character.

Parameters
cInput character.
Returns
Boolean

Definition at line 81 of file ctype.h.

◆ isdigit

#define isdigit (   c)    Character::isDigit(c)

Test for a decimal digit.

Parameters
cInput character.

Definition at line 36 of file ctype.h.

◆ islower

#define islower (   c)    Character::isLower(c)

Test for a lowercase letter.

Parameters
cInput character.
Returns
Boolean

Definition at line 45 of file ctype.h.

◆ isspace

#define isspace (   c)    Character::isSpace(c)

Test for a white-space character.

Parameters
cInput character.
Returns
Boolean

Definition at line 90 of file ctype.h.

◆ isupper

#define isupper (   c)    Character::isUpper(c)

Test for an uppercase letter.

Parameters
cInput character.
Returns
Boolean

Definition at line 54 of file ctype.h.

◆ O_ACCMODE

#define O_ACCMODE   (O_EXEC | O_RDONLY | O_RDWR | O_SEARCH | O_WRONLY)

Mask for file access modes.

Definition at line 72 of file fcntl.h.

◆ O_APPEND

#define O_APPEND   (1 << 5)

Set append mode.

Definition at line 57 of file fcntl.h.

◆ O_CREAT

#define O_CREAT   (1 << 0)

Create file if it does not exist.

Definition at line 39 of file fcntl.h.

◆ O_DSYNC

#define O_DSYNC   (1 << 6)

Write according to synchronized I/O data integrity completion.

Definition at line 60 of file fcntl.h.

◆ O_EXCL

#define O_EXCL   (1 << 1)

Exclusive use flag.

Definition at line 42 of file fcntl.h.

◆ O_EXEC

#define O_EXEC   (1 << 10)

Open for execute only (non-directory files).

The result is unspecified if this flag is applied to a directory.

Definition at line 78 of file fcntl.h.

◆ O_NOCTTY

#define O_NOCTTY   (1 << 2)

Do not assign controlling terminal.

Definition at line 45 of file fcntl.h.

◆ O_NONBLOCK

#define O_NONBLOCK   (1 << 7)

Non-blocking mode.

Definition at line 63 of file fcntl.h.

◆ O_RDONLY

#define O_RDONLY   (1 << 11)

Open for reading only.

Definition at line 81 of file fcntl.h.

◆ O_RDWR

#define O_RDWR   (1 << 12)

Open for reading and writing.

Definition at line 84 of file fcntl.h.

◆ O_RSYNC

#define O_RSYNC   (1 << 8)

Synchronized read I/O operations.

Definition at line 66 of file fcntl.h.

◆ O_SEARCH

#define O_SEARCH   (1 << 13)

Open directory for search only.

The result is unspecified if this flag is applied to a non-directory file.

Definition at line 90 of file fcntl.h.

◆ O_SYNC

#define O_SYNC   (1 << 9)

Write according to synchronized I/O file integrity completion.

Definition at line 69 of file fcntl.h.

◆ O_TRUNC

#define O_TRUNC   (1 << 3)

Truncate flag.

Definition at line 48 of file fcntl.h.

◆ O_TTY_INIT

#define O_TTY_INIT   (1 << 4)

Set the termios structure terminal parameters to a state that provides conforming behavior; see Parameters that Can be Set.

Definition at line 54 of file fcntl.h.

◆ O_WRONLY

#define O_WRONLY   (1 << 14)

Open for writing only.

Definition at line 93 of file fcntl.h.

◆ PATH_MAX

#define PATH_MAX   FileSystemPath::MaximumLength

Maximum file path length.

Definition at line 37 of file limits.h.

◆ S_IFBLK

#define S_IFBLK   (FileSystem::BlockDeviceFile << FILEMODE_BITS)

Block special.

Definition at line 61 of file stat.h.

◆ S_IFCHR

Character special.

Definition at line 64 of file stat.h.

◆ S_IFDIR

#define S_IFDIR   (FileSystem::DirectoryFile << FILEMODE_BITS)

Directory.

Definition at line 73 of file stat.h.

◆ S_IFIFO

#define S_IFIFO   (FileSystem::FIFOFile << FILEMODE_BITS)

FIFO special.

Definition at line 67 of file stat.h.

◆ S_IFLNK

#define S_IFLNK   (FileSystem::SymlinkFile << FILEMODE_BITS)

Symbolic link.

Definition at line 76 of file stat.h.

◆ S_IFMT

#define S_IFMT   (FILETYPE_MASK << FILEMODE_BITS)

Type of file.

Definition at line 58 of file stat.h.

◆ S_IFREG

#define S_IFREG   (FileSystem::RegularFile << FILEMODE_BITS)

Regular.

Definition at line 70 of file stat.h.

◆ S_IFSOCK

#define S_IFSOCK   (FileSystem::SocketFile << FILEMODE_BITS)

Socket.

Definition at line 79 of file stat.h.

◆ S_IRGRP

#define S_IRGRP   FileSystem::GroupR

Read permission, group.

Definition at line 112 of file stat.h.

◆ S_IROTH

#define S_IROTH   FileSystem::OtherR

Read permission, others.

Definition at line 124 of file stat.h.

◆ S_IRUSR

#define S_IRUSR   FileSystem::OwnerR

Read permission, owner.

Definition at line 100 of file stat.h.

◆ S_IRWXG

#define S_IRWXG   FileSystem::GroupRWX

Read, write, execute/search by group.

Definition at line 109 of file stat.h.

◆ S_IRWXO

#define S_IRWXO   FileSystem::OtherRWX

Read, write, execute/search by others.

Definition at line 121 of file stat.h.

◆ S_IRWXU

#define S_IRWXU   FileSystem::OwnerRWX

File mode bits.

The <sys/stat.h> header shall define the following symbolic constants for the file mode bits encoded in type mode_t, with the indicated numeric values. These macros shall expand to an expression which has a type that allows them to be used, either singly or OR'ed together, as the third argument to open() without the need for a mode_t cast. The values shall be suitable for use in #if preprocessing directives. Read, write, execute/search by owner.

Definition at line 97 of file stat.h.

◆ S_ISBLK

#define S_ISBLK (   m)    S_ISTYPE(m, S_IFBLK)

Test for a block special file.

Definition at line 149 of file stat.h.

◆ S_ISCHR

#define S_ISCHR (   m)    S_ISTYPE(m, S_IFCHR)

Test for a character special file.

Definition at line 152 of file stat.h.

◆ S_ISDIR

#define S_ISDIR (   m)    S_ISTYPE(m, S_IFDIR)

Test for a directory.

Definition at line 155 of file stat.h.

◆ S_ISFIFO

#define S_ISFIFO (   m)    S_ISTYPE(m, S_IFIFO)

Test for a pipe or FIFO special file.

Definition at line 158 of file stat.h.

◆ S_ISLNK

#define S_ISLNK (   m)    S_ISTYPE(m, S_IFLNK)

Test for a symbolic link.

Definition at line 164 of file stat.h.

◆ S_ISREG

#define S_ISREG (   m)    S_ISTYPE(m, S_IFREG)

Test for a regular file.

Definition at line 161 of file stat.h.

◆ S_ISSOCK

#define S_ISSOCK (   m)    S_ISTYPE(m, S_IFSOCK)

Test for a socket.

Definition at line 167 of file stat.h.

◆ S_ISTYPE

#define S_ISTYPE (   mode,
  mask 
)    (((mode) & S_IFMT) == (mask))

Test for mode bits.

Definition at line 146 of file stat.h.

◆ S_IWGRP

#define S_IWGRP   FileSystem::GroupW

Write permission, group.

Definition at line 115 of file stat.h.

◆ S_IWOTH

#define S_IWOTH   FileSystem::OtherW

Write permission, others.

Definition at line 127 of file stat.h.

◆ S_IWUSR

#define S_IWUSR   FileSystem::OwnerW

Write permission, owner.

Definition at line 103 of file stat.h.

◆ S_IXGRP

#define S_IXGRP   FileSystem::GroupX

Execute/search permission, group.

Definition at line 118 of file stat.h.

◆ S_IXOTH

#define S_IXOTH   FileSystem::OtherX

Execute/search permission, others.

Definition at line 130 of file stat.h.

◆ S_IXUSR

#define S_IXUSR   FileSystem::OwnerX

Execute/search permission, owner.

Definition at line 106 of file stat.h.

◆ SEEK_CUR

#define SEEK_CUR   0

Seek relative to current position.

Definition at line 40 of file stdio.h.

◆ SEEK_END

#define SEEK_END   1

Seek relative to end-of-file.

Definition at line 43 of file stdio.h.

◆ SEEK_SET

#define SEEK_SET   2

Seek relative to start-of-file.

Definition at line 46 of file stdio.h.

◆ SIGABRT

#define SIGABRT   6

Abnormal termination.

Definition at line 45 of file signal.h.

◆ SIGALRM

#define SIGALRM   14

Alarm clock.

Definition at line 89 of file signal.h.

◆ SIGBUS

#define SIGBUS   10

Bus error.

Definition at line 80 of file signal.h.

◆ SIGCHLD

#define SIGCHLD   20

Child terminated or stopped.

Definition at line 104 of file signal.h.

◆ SIGCONT

#define SIGCONT   19

Continue.

Definition at line 101 of file signal.h.

◆ SIGFPE

#define SIGFPE   8

Erroneous arithmetic operation.

Definition at line 48 of file signal.h.

◆ SIGHUP

#define SIGHUP   1

Hangup.

Definition at line 68 of file signal.h.

◆ SIGILL

#define SIGILL   4

Illegal instruction.

Definition at line 42 of file signal.h.

◆ SIGINT

#define SIGINT   2

Interactive attention signal.

Definition at line 39 of file signal.h.

◆ SIGKILL

#define SIGKILL   9

Killed.

Definition at line 77 of file signal.h.

◆ SIGPIPE

#define SIGPIPE   13

Broken pipe.

Definition at line 86 of file signal.h.

◆ SIGPOLL

#define SIGPOLL   23

Pollable event occurred (System V).

Definition at line 113 of file signal.h.

◆ SIGPROF

#define SIGPROF   27

Profiling timer expired.

Definition at line 125 of file signal.h.

◆ SIGQUIT

#define SIGQUIT   3

Quit.

Definition at line 71 of file signal.h.

◆ SIGSEGV

#define SIGSEGV   11

Invalid access to storage.

Definition at line 51 of file signal.h.

◆ SIGSTOP

#define SIGSTOP   17

Stop, unblockable.

Definition at line 95 of file signal.h.

◆ SIGSYS

#define SIGSYS   12

Bad system call.

Definition at line 83 of file signal.h.

◆ SIGTERM

#define SIGTERM   15

Termination request.

Definition at line 54 of file signal.h.

◆ SIGTRAP

#define SIGTRAP   5

Trace/breakpoint trap.

Definition at line 74 of file signal.h.

◆ SIGTSTP

#define SIGTSTP   18

Keyboard stop.

Definition at line 98 of file signal.h.

◆ SIGTTIN

#define SIGTTIN   21

Background read from control terminal.

Definition at line 107 of file signal.h.

◆ SIGTTOU

#define SIGTTOU   22

Background write to control terminal.

Definition at line 110 of file signal.h.

◆ SIGURG

#define SIGURG   16

Urgent data is available at a socket.

Definition at line 92 of file signal.h.

◆ SIGUSR1

#define SIGUSR1   30

User-defined signal 1.

Definition at line 128 of file signal.h.

◆ SIGUSR2

#define SIGUSR2   31

User-defined signal 2.

Definition at line 131 of file signal.h.

◆ SIGVTALRM

#define SIGVTALRM   26

Virtual timer expired.

Definition at line 122 of file signal.h.

◆ SIGXCPU

#define SIGXCPU   24

CPU time limit exceeded.

Definition at line 116 of file signal.h.

◆ SIGXFSZ

#define SIGXFSZ   25

File size limit exceeded.

Definition at line 119 of file signal.h.

◆ tolower

#define tolower (   c)    Character::lower(c)

Converts the letter c to lowercase.

Parameters
cThe letter to convert.
Returns
The converted letter, or c if conversion was not possible.

Definition at line 99 of file ctype.h.

◆ toupper

#define toupper (   c)    Character::upper(c)

Converts the letter c to uppercase.

Parameters
cThe letter to convert.
Returns
The converted letter, or c if conversion was not possible.

Definition at line 108 of file ctype.h.

◆ UTSBUF

#define UTSBUF   128

Size of each buffer in the utsname structure fields.

Definition at line 33 of file utsname.h.

◆ WEXITSTATUS

#define WEXITSTATUS (   st)    (st)

Returns the exit status of the child process.

Parameters
stContains the stat_loc value from waitpid()
Returns
Exit status of the child process

Definition at line 39 of file wait.h.

Typedef Documentation

◆ blkcnt_t

typedef sint blkcnt_t

Used for file block counts.

Definition at line 62 of file types.h.

◆ blksize_t

typedef sint blksize_t

Used for block sizes.

Definition at line 65 of file types.h.

◆ dev_t

typedef DeviceID dev_t

Used for device IDs.

Definition at line 41 of file types.h.

◆ DIR

typedef struct DIR DIR

A type representing a directory stream.

Note
The DIR type may be an incomplete type.

◆ FILE

typedef struct FILE FILE

A structure containing information about a file.

◆ FileSystemMount

Represents a mounted filesystem.

◆ gid_t

typedef u16 gid_t

Used for group IDs.

Definition at line 53 of file types.h.

◆ ino_t

typedef uint ino_t

Used for file serial numbers.

Definition at line 44 of file types.h.

◆ mode_t

typedef uint mode_t

Used for some file attributes.

Definition at line 47 of file types.h.

◆ nlink_t

typedef Size nlink_t

Used for link counts.

Definition at line 56 of file types.h.

◆ off_t

typedef sint off_t

Used for file sizes.

Definition at line 59 of file types.h.

◆ pid_t

typedef ProcessID pid_t

Used for process IDs and process group IDs.

Definition at line 32 of file types.h.

◆ size_t

typedef Size size_t

Used for sizes of objects.

Definition at line 35 of file types.h.

◆ socklen_t

typedef Size socklen_t

Definition at line 50 of file socket.h.

◆ ssize_t

typedef slong ssize_t

Used for a count of bytes or an error indication.

Definition at line 38 of file types.h.

◆ time_t

typedef u64 time_t

Used for time in seconds.

Definition at line 68 of file types.h.

◆ uid_t

typedef u16 uid_t

Used for user IDs.

Definition at line 50 of file types.h.

Function Documentation

◆ abs()

C int abs ( int  number)

Compute the absolute value of a number.

The absolute value of a number turns it to positive in case it is negative. Basically it just removes the sign (-) from a number. For example, -3 returns 3, and 8 returns 8.

Parameters
numberThe number to make absolute.
Returns
Absolute value of the given number.

Definition at line 21 of file abs.cpp.

References CHAR_BIT.

◆ atoi()

C int atoi ( const char *  nptr)

Convert a string to an integer.

The atoi, atol, and atoll functions convert the initial portion of the string pointed to by nptr to int, long int, and long long int representation, respectively.

Parameters
nptrString pointer to convert.
Returns
The atoi, atol, and atoll functions return the converted value.

Definition at line 21 of file atoi.cpp.

References String::toLong().

Referenced by MakeNode::exec(), SievePrime::exec(), Sleep::exec(), MpiPrime::exec(), NetCat::initialize(), main(), MpiHost::parseHostsFile(), and vsnprintf().

◆ basename()

C char* basename ( char *  path)

Return the last component of a pathname.

The basename() function shall take the pathname pointed to by path and return a pointer to the final component of the pathname, deleting any trailing '/' characters.

Parameters
pathFilesystem path.
Returns
String pointer to the last component.

Definition at line 21 of file basename.cpp.

References strrchr().

Referenced by ListFiles::printSingleFile(), StdoutReporter::reportAfter(), StdoutReporter::reportBefore(), StdoutReporter::reportBegin(), StdoutReporter::reportFinish(), and MpiHost::startProcesses().

◆ chdir()

C int chdir ( const char *  path)

Change working directory.

The chdir() function shall cause the directory named by the pathname pointed to by the path argument to become the current working directory; that is, the starting point for path searches for pathnames not beginning with '/' .

Parameters
pathPath to the directory to use as working directory.
Returns
Upon successful completion, 0 shall be returned. Otherwise, -1 shall be returned, the current working directory shall remain unchanged, and errno shall be set to indicate the error.

Definition at line 27 of file chdir.cpp.

References List< T >::append(), ENOTDIR, errno, getcwd(), ListIterator< T >::hasCurrent(), String::length(), memset(), PATH_MAX, List< T >::remove(), S_ISDIR, FileSystemClient::setCurrentDirectory(), snprintf(), FileSystemPath::split(), stat::st_mode, stat(), strcat(), strcpy(), and ZERO.

Referenced by ChangeDirCommand::execute().

◆ close()

C int close ( int  fildes)

Close a file descriptor.

Parameters
fildesThe close() function shall deallocate the file descriptor indicated by fildes.
Returns
Upon successful completion, 0 shall be returned; otherwise, -1 shall be returned and errno set to indicate the error.

Definition at line 22 of file close.cpp.

References FileSystemClient::closeFile(), ENOENT, errno, and FileSystem::Success.

Referenced by Cat::cat(), closedir(), Login::exec(), StdioCommand::execute(), WriteCommand::execute(), fclose(), forkexec(), NetPing::icmpPing(), Terminal::initialize(), LinnCreate::insertFile(), CoreServer::loadKernel(), BufferedFile::read(), NetCtl::showDevice(), BufferedFile::write(), and Terminal::~Terminal().

◆ closedir()

C int closedir ( DIR dirp)

Close a directory stream.

Parameters
dirpThe closedir() function shall close the directory stream referred to by the argument dirp.
Returns
Upon successful completion, closedir() shall return 0; otherwise, -1 shall be returned and errno set to indicate the error.

Definition at line 22 of file closedir.cpp.

References DIR::buffer, close(), and DIR::fd.

Referenced by LinnCreate::insertDirectory(), opendir(), ListFiles::printFiles(), and DirectoryScanner::scan().

◆ connect()

C int connect ( int  sockfd,
struct sockaddr addr,
socklen_t  addrlen 
)

Connect a socket to an address/port.

Parameters
sockfdSocket file descriptor
addrPointer to the address and port to connect to.
addrlenLength of the address
Returns
Zero on success and -1 on error

Definition at line 23 of file connect.cpp.

References sockaddr::addr, NetworkClient::connectSocket(), EIO, ESUCCESS, NetworkClient::initialize(), and NetworkClient::Success.

◆ creat()

C int creat ( const char *  path,
mode_t  mode 
)

Create a new file or rewrite an existing one.

The creat() function is redundant. Its services are also provided by the open() function. It has been included primarily for historical purposes since many existing applications depend on it. It is best considered a part of the C binding rather than a function that should be provided in other languages.

Parameters
pathFull path to the file to create
modeInitial access permissions for the file.
Returns
Upon successful completion, these functions shall return 0. Otherwise, these functions shall return -1 and set errno to indicate the error. If -1 is returned, no file shall be created.

Definition at line 25 of file creat.cpp.

References FileSystemClient::createFile(), EIO, errno, ESUCCESS, FILEMODE_MASK, FileSystem::RegularFile, and FileSystem::Success.

Referenced by CreateFile::createFile().

◆ dirname()

C char* dirname ( char *  path)

Return the directory portion of a pathname.

Parameters
pathFilesystem path
Returns
String pointer to the directory of pathname.

Definition at line 22 of file dirname.cpp.

References PATH_MAX, strlcpy(), and strrchr().

Referenced by opendir().

◆ exit()

C void exit ( int  status)

Terminate a process.

The exit function causes normal program termination to occur. If more than one call to the exit function is executed by a program, the behaviour is undefined.

Parameters
statusIf the value of status is zero or EXIT_SUCCESS, an implementation defined form of the status successful termination is returned. If the value of status is EXIT_FAILURE, an implementation-defined form of the status unsuccesful termination is returned. Otherwise the status is implementation-defined.
Returns
The exit function cannot return to its caller.

Definition at line 21 of file exit.cpp.

References KillPID, ProcessCtl(), and SELF.

Referenced by LinnCreate::createInode(), ApplicationLauncher::exec(), ExitCommand::execute(), LinnCreate::insertDirectory(), LinnCreate::insertEntry(), LinnCreate::insertFile(), BootImageCreate::readBootSymbols(), NetCat::readLine(), StdioLog::terminate(), and Mount::waitForMount().

◆ fclose()

C int fclose ( FILE stream)

Close a stream.

The fclose() function shall cause the stream pointed to by stream to be flushed and the associated file to be closed. Any unwritten buffered data for the stream shall be written to the file; any unread buffered data shall be discarded. Whether or not the call succeeds, the stream shall be disassociated from the file and any buffer set by the setbuf() or setvbuf() function shall be disassociated from the stream. If the associated buffer was automatically allocated, it shall be deallocated.

Parameters
streamFile stream to close.
Returns
Upon successful completion, fclose() shall return 0; otherwise, it shall return EOF and set errno to indicate the error.

Definition at line 23 of file fclose.cpp.

References close(), errno, FILE::fd, and free().

Referenced by Shell::exec(), BootImageCreate::exec(), main(), MpiHost::parseHostsFile(), BootImageCreate::readBootSymbols(), and LinnCreate::writeImage().

◆ fopen()

C FILE* fopen ( const char *  filename,
const char *  mode 
)

Open a stream.

The fopen() function shall open the file whose pathname is the string pointed to by filename, and associates a stream with it. The mode argument points to a string. If the string is one of the following, the file shall be opened in the indicated mode. Otherwise, the behavior is undefined.

r or rb Open file for reading. w or wb Truncate to zero length or create file for writing. a or ab Append; open or create file for writing at end-of-file. r+ or rb+ or r+b Open file for update (reading and writing). w+ or wb+ or w+b Truncate to zero length or create file for update. a+ or ab+ or a+b Append; open or create file for update, writing at end-of-file.

Parameters
filenamePath to the file to open.
modeMode describes how to open the file.
Returns
Upon successful completion, fopen() shall return a pointer to the object controlling the stream. Otherwise, a null pointer shall be returned, and errno shall be set to indicate the error.

Definition at line 24 of file fopen.cpp.

References ENOTSUP, errno, FILE::fd, malloc(), NULL, open(), and ZERO.

Referenced by Shell::exec(), BootImageCreate::exec(), main(), MpiHost::parseHostsFile(), BootImageCreate::readBootSymbols(), and LinnCreate::writeImage().

◆ forkexec()

C int forkexec ( const char *  path,
const char *  argv[] 
)

Create a new process and execute program.

Parameters
pathFile to execute.
argvArgument list pointer.
Returns
New process ID on success and -1 on failure.
Note
Errno is set with the appropriate error code on failure.

Definition at line 27 of file forkexec.cpp.

References Memory::Range::access, close(), EFAULT, EIO, errno, Lz4Decompressor::getUncompressedSize(), Lz4Decompressor::initialize(), MapContiguous, O_RDONLY, open(), Memory::Range::phys, read(), Lz4Decompressor::read(), Memory::Readable, Release, SELF, Memory::Range::size, spawn(), stat::st_size, stat(), API::Success, Lz4Decompressor::Success, Memory::User, Memory::Range::virt, VMCtl(), Memory::Writable, and ZERO.

Referenced by Login::exec(), ApplicationLauncher::exec(), and ExternalTest::run().

◆ fread()

C size_t fread ( void *  ptr,
size_t  size,
size_t  nitems,
FILE stream 
)

Binary input.

The fread() function shall read into the array pointed to by ptr up to nitems elements whose size is specified by size in bytes, from the stream pointed to by stream. For each object, size calls shall be made to the fgetc() function and the results stored, in the order read, in an array of unsigned char exactly overlaying the object. The file position indicator for the stream (if defined) shall be advanced by the number of bytes successfully read. If an error occurs, the resulting value of the file position indicator for the stream is unspecified. If a partial element is read, its value is unspecified.

Parameters
ptrOutput buffer.
sizeSize of each item to read.
nitemsNumber of items to read.
streamFILE pointer to read from.
Returns
Upon successful completion, fread() shall return the number of elements successfully read which is less than nitems only if a read error or end-of-file is encountered. If size or nitems is 0, fread() shall return 0 and the contents of the array and the state of the stream remain unchanged. Otherwise, if a read error occurs, the error indicator for the stream shall be set, and errno shall be set to indicate the error.

Definition at line 24 of file fread.cpp.

References FILE::fd, and read().

Referenced by Shell::exec(), main(), MpiHost::parseHostsFile(), and BootImageCreate::readBootSymbols().

◆ free()

C void free ( void *  ptr)

Free allocated memory.

The free() function shall cause the space pointed to by ptr to be deallocated; that is, made available for further allocation. If ptr is a null pointer, no action shall occur. Otherwise, if the argument does not match a pointer earlier returned by a function in POSIX.1-2008 that allocates memory as if by malloc(), or if the space has been deallocated by a call to free() or realloc(), the behavior is undefined. Any use of a pointer that refers to freed space results in undefined behavior.

Parameters
ptrPreviously allocated memory to free.
Returns
The free() function shall not return a value.

Definition at line 22 of file free.cpp.

Referenced by MpiPrime::exec(), and fclose().

◆ fwrite()

C size_t fwrite ( const void *  ptr,
size_t  size,
size_t  nitems,
FILE stream 
)

The fwrite() function shall write, from the array pointed to by ptr, up to nitems elements whose size is specified by size, to the stream pointed to by stream.

For each object, size calls shall be made to the fputc() function, taking the values (in order) from an array of unsigned char exactly overlaying the object. The file-position indicator for the stream (if defined) shall be advanced by the number of bytes successfully written. If an error occurs, the resulting value of the file-position indicator for the stream is unspecified.

Parameters
ptrInput buffer.
sizeSize of each item to write.
nitemsNumber of items to write.
streamFILE pointer to write to.
Returns
The fwrite() function shall return the number of elements successfully written, which may be less than nitems if a write error is encountered. If size or nitems is 0, fwrite() shall return 0 and the state of the stream remains unchanged. Otherwise, if a write error occurs, the error indicator for the stream shall be set, and errno shall be set to indicate the error.

Definition at line 24 of file fwrite.cpp.

References FILE::fd, and write().

Referenced by BootImageCreate::exec(), and LinnCreate::writeImage().

◆ getcwd()

C char* getcwd ( char *  buf,
size_t  size 
)

Get the pathname of the current working directory.

The getcwd() function shall place an absolute pathname of the current working directory in the array pointed to by buf, and return buf. The pathname shall contain no components that are dot or dot-dot, or are symbolic links.

Parameters
bufOutput buffer, to store the current directory.
sizeSize of the output buffer.
Returns
Upon successful completion, getcwd() shall return the buf argument. Otherwise, getcwd() shall return a null pointer and set errno to indicate the error. The contents of the array pointed to by buf are then undefined.

Definition at line 24 of file getcwd.cpp.

References assert, errno, ESUCCESS, FileSystemClient::getCurrentDirectory(), memcpy(), and NULL.

Referenced by chdir(), ListFiles::exec(), and Shell::prompt().

◆ gethostname()

C int gethostname ( char *  name,
size_t  namelen 
)

Get name of current host.

The gethostname() function shall return the standard host name for the current machine. The namelen argument shall specify the size of the array pointed to by the name argument. The returned name shall be null-terminated, except that if namelen is an insufficient length to hold the host name, then the returned name shall be truncated and it is unspecified whether the returned name is null-terminated. Host names are limited to {HOST_NAME_MAX} bytes.

Parameters
nameOutput buffer.
namelenSize of the output buffer.
Returns
Upon successful completion, 0 shall be returned; otherwise, -1 shall be returned.

Definition at line 21 of file gethostname.cpp.

References strlcpy().

Referenced by Hostname::exec(), Shell::prompt(), and uname().

◆ getpid()

C pid_t getpid ( )

Get the process ID.

The getpid() function shall return the process ID of the calling process.

Returns
The getpid() function shall always be successful and no return value is reserved to indicate an error.

Definition at line 21 of file getpid.cpp.

References ProcessClient::getProcessID().

Referenced by TestData< T >::seed().

◆ getppid()

C pid_t getppid ( )

Get parent process ID.

Returns
The parent process ID.

Definition at line 21 of file getppid.cpp.

References ProcessClient::getParentID().

◆ gettimeofday()

C int gettimeofday ( struct timeval tv,
struct timezone tz 
)

Get current time of day.

Parameters
tvTimeval struct object pointer.
tzTimezone struct object pointer.
Returns
Zero on success and -1 on error.

Definition at line 22 of file gettimeofday.cpp.

References ERANGE, errno, InfoTimer, ProcessCtl(), SELF, timeval::tv_sec, and timeval::tv_usec.

Referenced by SysInfo::exec(), SystemClock::now(), and TestData< T >::seed().

◆ itoa()

C void itoa ( char *  buffer,
int  divisor,
int  number 
)

Convert a number to a string.

Parameters
bufferString buffer to write to.
divisorBase of the number, e.g. 16 for hexadecimal.
numberThe number to convert.

Definition at line 21 of file itoa.cpp.

References Number::Dec, Number::Hex, and String::set().

Referenced by vsnprintf().

◆ kill()

C int kill ( pid_t  pid,
int  sig 
)

Send a signal to a process or a group of processes.

For a process to have permission to send a signal to a process designated by pid, unless the sending process has appropriate privileges, the real or effective user ID of the sending process shall match the real or saved set-user-ID of the receiving process.

If pid is greater than 0, sig shall be sent to the process whose process ID is equal to pid. If pid is 0, sig shall be sent to all processes (excluding an unspecified set of system processes) whose process group ID is equal to the process group ID of the sender, and for which the process has permission to send a signal. If pid is -1, sig shall be sent to all processes (excluding an unspecified set of system processes) for which the process has permission to send that signal. If pid is negative, but not -1, sig shall be sent to all processes (excluding an unspecified set of system processes) whose process group ID is equal to the absolute value of pid, and for which the process has permission to send a signal. If the value of pid causes sig to be generated for the sending process, and if sig is not blocked for the calling thread and if no other thread has sig unblocked or is waiting in a sigwait() function for sig, either sig or at least one pending unblocked signal shall be delivered to the sending thread before kill() returns.

The user ID tests described above shall not be applied when sending SIGCONT to a process that is a member of the same session as the sending process.

Parameters
pidThe kill() function shall send a signal to a process or a group of processes specified by pid.
sigThe signal to be sent is specified by sig and is either one from the list given in <signal.h> or 0. If sig is 0 (the null signal), error checking is performed but no signal is actually sent. The null signal can be used to check the validity of pid.
Returns
Upon successful completion, 0 shall be returned. Otherwise, -1 shall be returned and errno set to indicate the error.

Definition at line 23 of file kill.cpp.

References EIO, ENOTSUP, errno, EXIT_FAILURE, KillPID, ProcessCtl(), SIGKILL, SIGTERM, and API::Success.

Referenced by ApplicationLauncher::terminate().

◆ lseek()

C off_t lseek ( int  fildes,
off_t  offset,
int  whence 
)

Move the read/write file offset.

The lseek() function shall set the file offset for the open file description associated with the file descriptor fildes, as follows:

If whence is SEEK_SET, the file offset shall be set to offset bytes. If whence is SEEK_CUR, the file offset shall be set to its current location plus offset. If whence is SEEK_END, the file offset shall be set to the size of the file plus offset.

Parameters
fildesFile descriptor.
offsetNew file offset.
whenceDetermines how to modify the file offset pointer.
Returns
Upon successful completion, the resulting offset, as measured in bytes from the beginning of the file, shall be returned. Otherwise, (off_t)-1 shall be returned, errno shall be set to indicate the error, and the file offset shall remain unchanged.

Definition at line 22 of file lseek.cpp.

References ENOENT, errno, FileDescriptor::getEntry(), StrictSingleton< FileDescriptor >::instance(), FileDescriptor::Entry::open, and FileDescriptor::Entry::position.

Referenced by Terminal::writeTerminal().

◆ malloc()

C void* malloc ( size_t  size)

A memory allocator.

The malloc() function shall allocate unused space for an object whose size in bytes is specified by size and whose value is unspecified.

Parameters
sizeNumber of bytes to allocate.
Returns
Upon successful completion with size not equal to 0, malloc() shall return a pointer to the allocated space. If size is 0, either a null pointer or a unique pointer that can be successfully passed to free() shall be returned. Otherwise, it shall return a null pointer [CX] [Option Start] and set errno to indicate the error.

Definition at line 22 of file malloc.cpp.

References ENOMEM, and errno.

Referenced by SievePrime::exec(), MpiPrime::exec(), fopen(), strdup(), strndup(), and timeString().

◆ memcpy()

C void* memcpy ( void *  dest,
const void *  src,
size_t  count 
)

Copy memory from one place to another.

Parameters
destDestination address.
srcSource address.
countNumber of bytes to copy.
Returns
The destination address.

Definition at line 20 of file memcpy.cpp.

References sp.

Referenced by copy(), getcwd(), recvfrom(), sendto(), strdup(), and strndup().

◆ memset()

C void* memset ( void *  dest,
int  ch,
size_t  count 
)

Fill memory with a constant byte.

Parameters
destMemory to write to.
chConstant byte.
countNumber of bytes to fill.
Returns
Pointer to dest.

Definition at line 20 of file memset.cpp.

Referenced by Cat::cat(), chdir(), LinnCreate::create(), BootImageCreate::exec(), MpiHost::initialize(), Terminal::initialize(), opendir(), spawn(), teken_subr_tab_clear(), and teken_tab_default().

◆ mkdir()

C int mkdir ( const char *  path,
mode_t  mode 
)

Create a new directory.

The mkdir() function shall create a new directory with name path. The file permission bits of the new directory shall be initialized from mode. These file permission bits of the mode argument shall be modified by the process' file creation mask.

Parameters
pathFull path to the directory to create.
modeInitial access permissions on the directory.
Returns
Upon successful completion, these functions shall return 0. Otherwise, these functions shall return -1 and set errno to indicate the error. If -1 is returned, no directory shall be created.

Definition at line 25 of file mkdir.cpp.

References FileSystemClient::createFile(), FileSystem::DirectoryFile, EIO, errno, ESUCCESS, FILEMODE_MASK, and FileSystem::Success.

◆ mknod()

C int mknod ( const char *  path,
mode_t  mode,
dev_t  dev 
)

Make directory, special file, or regular file.

Parameters
pathThe mknod() function shall create a new file named by the pathname to which the argument path points.
modeThe file type for path is OR'ed into the mode argument.
devDevice specific identifiers
Returns
Upon successful completion, these functions shall return 0. Otherwise, these functions shall return -1 and set errno to indicate the error. If -1 is returned, the new file shall not be created.

Definition at line 25 of file mknod.cpp.

References FileSystemClient::createFile(), EIO, errno, ESUCCESS, FILEMODE_BITS, FILEMODE_MASK, FILETYPE_MASK, and FileSystem::Success.

Referenced by MakeNode::exec().

◆ mktime()

C unsigned long mktime ( const unsigned int  year,
const unsigned int  month,
const unsigned int  day,
const unsigned int  hour,
const unsigned int  min,
const unsigned int  sec 
)

Convert given time values to UNIX timestamp (seconds since epoch)

Parameters
yearYear value
monthMonth value
dayDay value
hourHour value (0-23)
minMinute value (0-59)
secSecond value (0-59)
Returns
Converted timestamp in seconds since epoch (UNIX time)
Note
This code is based on the linux source in kernel/time.c

Convert given time values to UNIX timestamp (seconds since epoch)

This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

This program 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 General Public License for more details.

You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/.

Definition at line 20 of file time.cpp.

Referenced by Time::read().

◆ open()

C int open ( const char *  path,
int  oflag,
  ... 
)

Open file relative to directory file descriptor.

Parameters
pathThe path argument points to a pathname naming the file.
oflagValues for oflag are constructed by a bitwise-inclusive OR of flags from the following list, defined in <fcntl.h>.
Returns
Upon successful completion, these functions shall open the file and return a non-negative integer representing the lowest numbered unused file descriptor. Otherwise, these functions shall return -1 and set errno to indicate the error. If - is returned, no files shall be created or modified.

Definition at line 26 of file open.cpp.

References ENOENT, errno, ESUCCESS, FileSystemClient::openFile(), and FileSystem::Success.

Referenced by Cat::cat(), Login::exec(), StdioCommand::execute(), WriteCommand::execute(), fopen(), forkexec(), Terminal::initialize(), LinnCreate::insertFile(), CoreServer::loadKernel(), opendir(), FileDescriptor::openEntry(), BufferedFile::read(), NetCtl::showDevice(), and BufferedFile::write().

◆ opendir()

C DIR* opendir ( const char *  dirname)

Open directory associated with file descriptor.

Parameters
dirnameThe opendir() function shall open a directory stream corresponding to the directory named by the dirname argument.
Returns
Upon successful completion, these functions shall return a pointer to an object of type DIR. Otherwise, these functions shall return a null pointer and set errno to indicate the error.

Definition at line 27 of file opendir.cpp.

References DIR::buffer, closedir(), DIR::count, DIR::current, dirent::d_type, DIRLEN, dirname(), DT_BLK, DT_CHR, DT_DIR, DT_FIFO, DT_LNK, DT_REG, DT_SOCK, DIR::eof, errno, ESUCCESS, DIR::fd, memset(), open(), read(), stat(), strlcpy(), type, and ZERO.

Referenced by LinnCreate::insertDirectory(), ListFiles::printFiles(), and DirectoryScanner::scan().

◆ printf()

C int printf ( const char *  format,
  ... 
)

◆ random()

C long int random ( void  )

Random number generator.

Returns
Successive pseudo-random numbers in the range from 0 to RAND_MAX.

Definition at line 26 of file random.cpp.

References Randomizer::next().

Referenced by TestInt< T >::random(), and TestInt< T >::unique().

◆ read()

C ssize_t read ( int  fildes,
void *  buf,
size_t  nbyte 
)

Read from a file.

Parameters
fildesThe read() function shall attempt to read nbyte bytes from the file associated with the open file descriptor, fildes, into the buffer pointed to by buf.
bufThe read() function shall attempt to read nbyte bytes from the file associated with the open file descriptor, fildes, into the buffer pointed to by buf.
nbyteIf the value of nbyte is greater than {SSIZE_MAX}, the result is implementation-defined.
Returns
Upon successful completion, these functions shall return a non-negative integer indicating the number of bytes actually read. Otherwise, the functions shall return -1 and set errno to indicate the error.

Definition at line 22 of file read.cpp.

References ENOENT, errno, FileSystemClient::readFile(), and FileSystem::Success.

Referenced by NetPing::arpPing(), Cat::cat(), forkexec(), fread(), Shell::getInput(), Login::getUsername(), NetPing::icmpPing(), LinnCreate::insertFile(), CoreServer::loadKernel(), opendir(), NetCat::readLine(), recvfrom(), and NetCtl::showDevice().

◆ readdir()

C struct dirent* readdir ( DIR dirp)

Read a directory.

Parameters
dirpThe readdir() function shall return a pointer to a structure representing the directory entry at the current position in the directory stream specified by the argument dirp, and position the directory stream at the next entry.
Returns
Upon successful completion, readdir() shall return a pointer to an object of type struct dirent. When an error is encountered, a null pointer shall be returned and errno shall be set to indicate the error. When the end of the directory is encountered, a null pointer shall be returned and errno is not changed.

Definition at line 21 of file readdir.cpp.

References DIR::buffer, DIR::count, DIR::current, and ZERO.

Referenced by LinnCreate::insertDirectory(), ListFiles::printFiles(), and DirectoryScanner::scan().

◆ recvfrom()

C int recvfrom ( int  sockfd,
void *  buf,
size_t  len,
int  flags,
struct sockaddr addr,
socklen_t  addrlen 
)

Receive a single datagram from a socket.

Parameters
sockfdSocket file descriptor
bufDestination buffer for receiving the payload
lenMaximum number of bytes to receive
flagsOptional flags for the receive operation
addrPointer to the address and port of the sender of the datagram
addrlenLength of the address
Returns
Number of bytes received on success and -1 on error

Definition at line 25 of file recvfrom.cpp.

References sockaddr::addr, NetworkClient::SocketInfo::address, ERANGE, memcpy(), sockaddr::port, NetworkClient::SocketInfo::port, and read().

Referenced by MpiHost::receivePacket(), NetCat::udpReceive(), MpiProxy::udpReceive(), and DhcpClient::udpReceive().

◆ sendmsg()

C int sendmsg ( int  sockfd,
const struct msghdr msg,
int  flags 
)

Send multiple datagrams to a remote host.

Parameters
sockfdSocket file descriptor
msgPointer to the messages to send
flagsOptional flags for the send operation
Returns
Number of bytes send on success and -1 on error

Definition at line 24 of file sendmsg.cpp.

References NetworkClient::SocketInfo::action, sockaddr::addr, NetworkClient::SocketInfo::address, NetworkClient::PacketInfo::address, ERANGE, iovec::iov_base, iovec::iov_len, msghdr::msg_iov, msghdr::msg_iovlen, msghdr::msg_name, msghdr::msg_namelen, NetworkClient::SocketInfo::port, NetworkClient::SendMultiple, NetworkClient::PacketInfo::size, and write().

Referenced by NetSend::udpSendMultiple(), and MpiProxy::udpSendMultiple().

◆ sendto()

C int sendto ( int  sockfd,
const void *  buf,
size_t  len,
int  flags,
const struct sockaddr addr,
socklen_t  addrlen 
)

Send a single datagram to a remote host.

Parameters
sockfdSocket file descriptor
bufSource buffer containing the payload to send
lenMaximum number of bytes to send.
flagsOptional flags for the send operation
addrPointer to the destination address and port to send to
addrlenLength of the address
Returns
Number of bytes send on success and -1 on error

Definition at line 25 of file sendto.cpp.

References NetworkClient::SocketInfo::action, sockaddr::addr, NetworkClient::SocketInfo::address, ERANGE, memcpy(), NetworkClient::SocketInfo::port, NetworkClient::SendSingle, and write().

Referenced by MpiHost::sendPacket(), NetCat::udpSend(), MpiProxy::udpSend(), and DhcpClient::udpSend().

◆ sleep()

C unsigned int sleep ( unsigned int  seconds)

Sleep for the specified number of seconds.

Parameters
secondsNumber of seconds to sleep
Returns
Zero on success or number of seconds left when interrupted.

Definition at line 23 of file sleep.cpp.

References EAGAIN, EIO, errno, InfoTimer, ProcessCtl(), SELF, API::Success, and WaitTimer.

Referenced by Sleep::exec().

◆ snprintf()

C int snprintf ( char *  buffer,
unsigned int  size,
const char *  fmt,
  ... 
)

Write a formatted string into a buffer.

Parameters
bufferString buffer to write to.
sizeMaximum number of bytes to write.
fmtFormatted string.
...Argument list.
Returns
Number of bytes written to the buffer.

Definition at line 22 of file snprintf.cpp.

References va_end, va_start, and vsnprintf().

Referenced by chdir(), ProcessList::exec(), Shell::executeInput(), LinnCreate::insertDirectory(), ListFiles::printFiles(), Time::read(), BootImageCreate::readBootSymbols(), DirectoryScanner::scan(), and teken_subr_do_cpr().

◆ spawn()

C int spawn ( Address  program,
Size  programSize,
const char *  argv[] 
)

◆ sqrt()

C u32 sqrt ( u32  number)

Compute the square root of a number.

Parameters
numberThe number to use for square root.
Returns
Square root of the given number.

Definition at line 20 of file sqrt.cpp.

Referenced by MpiPrime::collect(), SievePrime::exec(), MpiPrime::exec(), and MpiPrime::searchParallel().

◆ srandom()

C void srandom ( unsigned int  seed)

Random number generator.

The srandom() function sets its argument as the seed for a new sequence of pseudo-random integers to be returned by random(). These sequences are repeatable by calling srandom() with the same seed value. If no seed value is provided, the random() function is automatically seeded with a value of 1.

Parameters
seedInitial seed value for the randomizer

Definition at line 20 of file random.cpp.

References Randomizer::seed().

Referenced by TestData< T >::seed().

◆ stat()

C int stat ( const char *  path,
struct stat buf 
)

Get file status.

Parameters
pathThe path argument points to a pathname naming a file. Read, write, or execute permission of the named file is not required. An implementation that provides additional or alternate file access control mechanisms may, under implementation-defined conditions, cause stat() to fail. In particular, the system may deny the existence of the file specified by path.
bufThe buf argument is a pointer to a stat structure, as defined in the <sys/stat.h> header, into which information is placed concerning the file.
Returns
Upon successful completion, these functions shall return 0. Otherwise, these functions shall return -1 and set errno to indicate the error.

Definition at line 25 of file stat.cpp.

References DEBUG, EIO, ENOENT, errno, ESUCCESS, FileSystem::NotFound, FileSystemClient::statFile(), and FileSystem::Success.

Referenced by Cat::cat(), chdir(), BenchMark::exec(), Shell::exec(), ApplicationLauncher::exec(), forkexec(), LinnCreate::insertDirectory(), CoreServer::loadKernel(), opendir(), MpiHost::parseHostsFile(), ListFiles::printFiles(), ListFiles::printSingleFile(), FileStatus::printStatus(), BufferedFile::read(), and BootImageCreate::readBootSymbols().

◆ strcasecmp()

C int strcasecmp ( const char *  dest,
const char *  src 
)

Compare two strings, ignoring case considerations.

Parameters
destDestination string to compare.
srcSource string to compare.
Returns
Zero if equal, non-zero if not.

Definition at line 21 of file strcasecmp.cpp.

References tolower.

◆ strcat()

C char* strcat ( char *  dest,
const char *  src 
)

Concatenate two strings.

The strcat() function shall append a copy of the string pointed to by s2 (including the terminating NUL character) to the end of the string pointed to by s1.

Parameters
destDestination string.
srcSource string.
Returns
The strcat() function shall return s1; no return value is reserved to indicate an error.

Definition at line 20 of file strcat.cpp.

References strcpy().

Referenced by chdir().

◆ strchr()

C char* strchr ( const char *  s,
int  c 
)

String scanning operation.

The strchr() function shall locate the first occurrence of c (converted to a char) in the string pointed to by s. The terminating NULL character is considered to be part of the string.

Parameters
sString to search in.
cCharacter to look for.
Returns
Upon completion, strchr() shall return a pointer to the byte, or a null pointer if the byte was not found.

Definition at line 20 of file strchr.cpp.

References NULL.

◆ strcmp()

C int strcmp ( const char *  dest,
const char *  src 
)

Compare two strings.

Parameters
destDestination string to compare.
srcSource string to compare.
Returns
Zero if equal, non-zero if not.

Definition at line 20 of file strcmp.cpp.

Referenced by main(), NetCat::readLine(), and TestRunner::TestRunner().

◆ strcpy()

C int strcpy ( char *  dest,
const char *  src 
)

Copy a string.

Parameters
destDestination buffer.
srcSource string.
Returns
Number of bytes copied.

Definition at line 20 of file strcpy.cpp.

Referenced by chdir(), strcat(), and teken_subr_do_cpr().

◆ strdup()

C char* strdup ( const char *  str)

Duplicate a string.

Parameters
strString to duplicate
Returns
Duplicated string or NULL if not enough memory is available.

Definition at line 37 of file strdup.cpp.

References copy(), malloc(), memcpy(), NULL, and strlen().

Referenced by timeString().

◆ strerror()

C char* strerror ( int  errnum)

◆ strlcpy()

C size_t strlcpy ( char *  dst,
const char *  src,
size_t  siz 
)

Copy src to string dst of size siz.

At most siz-1 characters will be copied. Always NUL terminates (unless siz == 0).

Parameters
dstDestination string
srcSource string
sizsize_t of dst buffer
Returns
strlen(src); if retval >= siz, truncation occurred.
Note
This function is copied from OpenBSD-4.3

Definition at line 19 of file strlcpy.cpp.

Referenced by dirname(), gethostname(), opendir(), CoreServer::prepareCoreInfo(), spawn(), and uname().

◆ strlen()

C size_t strlen ( const char *  str)

Calculate the length of a string.

Parameters
strString to calculate length for.
Returns
Length of the string.

Definition at line 21 of file strlen.cpp.

Referenced by Login::exec(), Shell::executeInput(), Terminal::initialize(), BootImageCreate::readBootSymbols(), Shell::runInteractive(), strdup(), strndup(), and StdioLog::write().

◆ strncasecmp()

C int strncasecmp ( const char *  dest,
const char *  src,
size_t  count 
)

Compare two strings, ignoring case considerations.

Parameters
destDestination string to compare.
srcSource string to compare.
countMaximum number of bytes to compare.
Returns
Zero if equal, non-zero if not.

Definition at line 21 of file strncasecmp.cpp.

References tolower.

◆ strncat()

C char* strncat ( char *  dest,
const char *  src,
size_t  siz 
)

Concatenate a string with part of another.

The strncat() function shall append not more than n bytes (a NUL character and bytes that follow it are not appended) from the array pointed to by s2 to the end of the string pointed to by s1. The initial byte of s2 overwrites the NUL character at the end of s1. A terminating NUL character is always appended to the result. If copying takes place between objects that overlap, the behavior is undefined.

Parameters
destDestination string.
srcSource string.
sizNumber of character to concatenate.
Returns
The strncat() function shall return s1; no return value shall be reserved to indicate an error.

Definition at line 20 of file strncat.cpp.

References strncpy().

◆ strncmp()

C int strncmp ( const char *  dest,
const char *  src,
size_t  count 
)

Compare two strings, by only a maximum number of bytes.

Parameters
destDestination string to compare.
srcSource string to compare.
countMaximum number of bytes to compare.
Returns
Zero if equal, non-zero if not.

Definition at line 20 of file strncmp.cpp.

Referenced by NetCtl::exec(), and BootImageCreate::readBootSymbols().

◆ strncpy()

C int strncpy ( char *  dest,
const char *  src,
size_t  sz 
)

Copy a string, given a maximum number of bytes.

Parameters
destDestination buffer.
srcSource string.
szMaximum number of bytes to copy.
Returns
Number of bytes copied.

Definition at line 20 of file strncpy.cpp.

Referenced by BootImageCreate::exec(), LinnCreate::insertEntry(), BootImageCreate::readBootSymbols(), and strncat().

◆ strndup()

C char* strndup ( const char *  s,
size_t  size 
)

Duplicate a specific number of bytes from a string.

The strndup() function shall be equivalent to the strdup() function, duplicating the provided s in a new block of memory allocated as if by using malloc(), with the exception being that strndup() copies at most size plus one bytes into the newly allocated memory, terminating the new string with a NUL character. If the length of s is larger than size, only size bytes shall be duplicated. If size is larger than the length of s, all bytes in s shall be copied into the new memory buffer, including the terminating NUL character. The newly created string shall always be properly terminated.

Parameters
sString to duplicate.
sizeMaximum number of bytes to copy, excluding the NULL byte.
Returns
Upon successful completion, the strndup() function shall return a pointer to the newly allocated memory containing the duplicated string. Otherwise, it shall return a null pointer and set errno to indicate the error.

Definition at line 22 of file strndup.cpp.

References malloc(), memcpy(), NULL, and strlen().

◆ strrchr()

C char* strrchr ( const char *  s,
int  c 
)

String scanning operation.

The strrchr() function shall locate the last occurrence of c (converted to a char) in the string pointed to by s. The terminating NUL character is considered to be part of the string.

Parameters
sString to search in.
cCharacter to look for.
Returns
Upon successful completion, strrchr() shall return a pointer to the byte or a null pointer if c does not occur in the string.

Definition at line 20 of file strrchr.cpp.

References NULL.

Referenced by basename(), and dirname().

◆ strtol()

C long strtol ( const char *  nptr,
char **  endptr,
int  base 
)

Convert a string to a long integer.

These functions shall convert the initial portion of the string pointed to by str to a type long and long long representation, respectively. First, they decompose the input string into three parts:

Parameters
nptrInput string pointer to convert.
endptrIf the subject sequence is empty or does not have the expected form, no conversion is performed; the value of str is stored in the object pointed to by endptr, provided that endptr is not a null pointer.
baseBase of the number, e.g. 16 for hexadecimal.
Returns
Upon successful completion, these functions shall return the converted value, if any. If no conversion could be performed, 0 shall be returned and errno may be set to [EINVAL]. If the correct value is outside the range of representable values, {LONG_MIN}, {LONG_MAX}, {LLONG_MIN}, or {LLONG_MAX} shall be returned (according to the sign of the value), and errno set to [ERANGE].

Definition at line 23 of file strtol.cpp.

References Number::Dec, Number::Hex, Character::isDigit(), and String::toLong().

◆ uname()

C int uname ( struct utsname name)

Get the name of the current system.

Parameters
nameUsed to store information identifying the current system
Returns
Upon successful completion, a non-negative value shall be returned. Otherwise, -1 shall be returned and errno set to indicate the error.

Definition at line 23 of file utsname.cpp.

References gethostname(), utsname::machine, utsname::nodename, utsname::release, strlcpy(), utsname::sysname, UTSBUF, and utsname::version.

Referenced by UnixName::exec(), and Login::printPrompt().

◆ unlink()

C int unlink ( const char *  path)

Remove a file from the filesystem.

Parameters
pathParh to the file to remove.
Returns
Zero on success or -1 on failure with errno set.

Definition at line 24 of file unlink.cpp.

References FileSystemClient::deleteFile(), EIO, errno, ESUCCESS, and FileSystem::Success.

Referenced by Remove::exec().

◆ vprintf()

C int vprintf ( const char *  format,
va_list  args 
)

Output a formatted string to standard output, using a variable argument list.

Parameters
formatFormatted string.
argsArgument list.
Returns
Number of bytes written or error code on failure.

Definition at line 23 of file vprintf.cpp.

References vsnprintf(), and write().

Referenced by printf().

◆ vsnprintf()

C int vsnprintf ( char *  buffer,
unsigned int  size,
const char *  fmt,
va_list  args 
)

Write a formatted string into a buffer.

Parameters
bufferString buffer to write to.
sizeMaximum number of bytes to write.
fmtFormatted string.
argsArgument list.
Returns
Number of bytes written to the buffer.

Definition at line 23 of file vsnprintf.cpp.

References atoi(), Number::Dec, Number::Hex, itoa(), length, String::setUnsigned(), va_arg, and ZERO.

Referenced by snprintf(), and vprintf().

◆ waitpid()

C pid_t waitpid ( pid_t  pid,
int *  stat_loc,
int  options 
)

Wait for a child process to stop or terminate.

The wait() and waitpid() functions shall obtain status information pertaining to one of the caller's child processes. Various options permit status information to be obtained for child processes that have terminated or stopped. If status information is available for two or more child processes, the order in which their status is reported is unspecified.

Parameters
pidProcess ID of child to wait for.
stat_locPoints to an integer for storing the exit status.
optionsOptional flags.
Returns
Process ID of the child on success or -1 on error

Definition at line 23 of file waitpid.cpp.

References EIO, errno, ESRCH, API::NotFound, ProcessCtl(), API::Success, and WaitPID.

Referenced by CoreServer::createProcess(), Login::exec(), Init::exec(), Shell::executeInput(), MpiProxy::processTerminate(), ExternalTest::run(), and ApplicationLauncher::wait().

◆ write()

C ssize_t write ( int  fildes,
const void *  buf,
size_t  nbyte 
)

Write on a file.

The write() function shall attempt to write nbyte bytes from the buffer pointed to by buf to the file associated with the open file descriptor, fildes.

Parameters
fildesFile descriptor.
bufInput buffer.
nbyteMaximum number of bytes to write.
Returns
Upon successful completion, these functions shall return the number of bytes actually written to the file associated with fildes. This number shall never be greater than nbyte. Otherwise, -1 shall be returned and errno set to indicate the error.

Definition at line 22 of file write.cpp.

References ENOENT, errno, FileSystem::Success, and FileSystemClient::writeFile().

Referenced by NetPing::arpPing(), MpiPrime::collect(), ProcessList::exec(), SievePrime::exec(), WriteCommand::execute(), fwrite(), NetPing::icmpPing(), ListFiles::printFiles(), SievePrime::reportResult(), sendmsg(), sendto(), and vprintf().

Variable Documentation

◆ errno

C int errno

◆ error_map

char * error_map

Contains a array of character strings, representing errno values.

Definition at line 23 of file errno.c.

Referenced by strerror().