2021-05-09 23:00:11 +02:00
|
|
|
#ifndef __UNISTD_H__
|
|
|
|
# define __UNISTD_H__
|
2020-09-17 19:27:01 +02:00
|
|
|
|
2021-06-28 15:49:05 +02:00
|
|
|
#ifdef __cplusplus
|
|
|
|
extern "C" {
|
|
|
|
#endif
|
|
|
|
|
2021-12-13 18:09:43 +01:00
|
|
|
#include <stdio.h>
|
2020-09-17 19:27:01 +02:00
|
|
|
#include <stdint.h>
|
2021-05-09 16:35:40 +02:00
|
|
|
#include <sys/types.h>
|
2020-09-17 19:27:01 +02:00
|
|
|
|
2021-12-13 18:09:43 +01:00
|
|
|
/* Standard file descriptors. */
|
|
|
|
#define STDIN_FILENO 0
|
|
|
|
#define STDOUT_FILENO 1
|
|
|
|
#define STDERR_FILENO 2
|
|
|
|
|
|
|
|
/* Write data to a file descriptor; returns number of bytes written or -1. */
|
|
|
|
extern ssize_t write(int __fd, const void *__buf, size_t __nbytes);
|
|
|
|
|
|
|
|
/* Read data from a file descriptor; returns number of bytes read or -1. */
|
|
|
|
extern ssize_t read(int __fd, void *__buf, size_t __nbytes);
|
|
|
|
|
|
|
|
/* Read at a specific position from a file descriptor. */
|
|
|
|
extern ssize_t pread(int __fd, void *__buf, size_t __nbytes, off_t __offset);
|
|
|
|
|
|
|
|
/* Write at a specific position to a file descriptor. */
|
|
|
|
extern ssize_t pwrite(int __fd, const void *__buf, size_t __n, off_t __offset);
|
|
|
|
|
|
|
|
/* Seek at an offset from SEEK_SET/SEEK_CUR/SEEK_END; returns new position. */
|
|
|
|
extern off_t lseek(int __fd, off_t __offset, int __whence);
|
|
|
|
|
|
|
|
/* Close a file descriptor. */
|
|
|
|
extern int close(int __fd);
|
|
|
|
|
|
|
|
/* Remove a file. */
|
|
|
|
extern int unlink(const char *__path);
|
|
|
|
|
2021-12-21 18:47:01 +01:00
|
|
|
/* Create a directory. */
|
|
|
|
extern int mkdir(const char *__path, mode_t __mode);
|
|
|
|
|
|
|
|
/* Remove an empty directory. */
|
|
|
|
extern int rmdir(const char *__path);
|
|
|
|
|
2022-08-13 00:01:00 +02:00
|
|
|
extern char *getcwd(char *__buf, size_t __size);
|
|
|
|
|
|
|
|
extern int chdir(char const *__path);
|
|
|
|
|
2024-07-05 22:28:52 +02:00
|
|
|
extern int isatty(int __fd);
|
|
|
|
|
|
|
|
extern int dup(int __fd);
|
|
|
|
|
2024-05-12 12:47:31 +02:00
|
|
|
/* Exit immediately, bypassing exit handlers or signal handlers. */
|
|
|
|
__attribute__((noreturn))
|
|
|
|
extern void _exit(int __status);
|
|
|
|
|
2021-12-13 18:09:43 +01:00
|
|
|
|
|
|
|
/* Kernel-style functions supported only by Vhex. */
|
|
|
|
|
2020-10-14 11:45:08 +02:00
|
|
|
//---
|
2020-09-17 19:27:01 +02:00
|
|
|
// Process part
|
2020-10-14 11:45:08 +02:00
|
|
|
///---
|
|
|
|
/* Get the process ID of the calling process. */
|
2020-09-17 19:27:01 +02:00
|
|
|
extern pid_t getpid(void);
|
2020-10-14 11:45:08 +02:00
|
|
|
|
|
|
|
/* Get the process group ID of the calling process. */
|
2020-09-17 19:27:01 +02:00
|
|
|
extern pid_t getpgid(void);
|
2020-10-14 11:45:08 +02:00
|
|
|
|
|
|
|
/* Get the process ID of the calling process's parent. */
|
2020-09-17 19:27:01 +02:00
|
|
|
extern pid_t getppid(void);
|
|
|
|
|
2020-10-14 11:45:08 +02:00
|
|
|
/*
|
|
|
|
** Set the process group ID of the process matching PID to PGID.
|
|
|
|
** If PID is zero, the current process's process group ID is set.
|
|
|
|
** If PGID is zero, the process ID of the process is used.
|
|
|
|
*/
|
|
|
|
extern int setpgid(pid_t __pid, pid_t __pgid);
|
|
|
|
|
|
|
|
//---
|
2020-09-17 19:27:01 +02:00
|
|
|
// System part
|
2020-10-14 11:45:08 +02:00
|
|
|
//---
|
|
|
|
/*
|
|
|
|
** Get the `_PC_*' symbols for the NAME argument to `pathconf' and `fpathconf';
|
|
|
|
** the `_SC_*' symbols for the NAME argument to `sysconf'; and the `_CS_*'
|
|
|
|
** symbols for the NAME argument to `confstr'.
|
|
|
|
*/
|
2021-05-09 16:35:40 +02:00
|
|
|
#include <bits/confname.h>
|
2020-10-14 11:45:08 +02:00
|
|
|
|
|
|
|
/* Get the value of the system variable NAME. */
|
|
|
|
extern long int sysconf(int __name);
|
2020-09-17 19:27:01 +02:00
|
|
|
|
2021-06-28 15:49:05 +02:00
|
|
|
#ifdef __cplusplus
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2021-05-09 23:00:11 +02:00
|
|
|
#endif /*__UNISTD_H__*/
|