LibC: Rewrite all the headers.
We now have more or less posix issue 2018 conforming libc headers. This was a really time consuming and boring operation but it had to be done. Now we get to actually start implementing libc :)
This commit is contained in:
@@ -1,11 +1,14 @@
|
||||
#pragma once
|
||||
#ifndef _SYS_CDEFS_H
|
||||
#define _SYS_CDEFS_H 1
|
||||
|
||||
#define __banan_libc 1
|
||||
|
||||
#ifdef __cplusplus
|
||||
#define __BEGIN_DECLS extern "C" {
|
||||
#define __END_DECLS }
|
||||
#define __BEGIN_DECLS extern "C" {
|
||||
#define __END_DECLS }
|
||||
#else
|
||||
#define __BEGIN_DECLS
|
||||
#define __END_DECLS
|
||||
#define __BEGIN_DECLS
|
||||
#define __END_DECLS
|
||||
#endif
|
||||
|
||||
#endif
|
||||
37
libc/include/sys/ipc.h
Normal file
37
libc/include/sys/ipc.h
Normal file
@@ -0,0 +1,37 @@
|
||||
#ifndef _SYS_IPC_H
|
||||
#define _SYS_IPC_H 1
|
||||
|
||||
// https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/sys_ipc.h.html
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
|
||||
__BEGIN_DECLS
|
||||
|
||||
#define __need_uid_t
|
||||
#define __need_gid_t
|
||||
#define __need_mode_t
|
||||
#define __need_key_t
|
||||
#include <sys/types.h>
|
||||
|
||||
struct ipc_perm
|
||||
{
|
||||
uid_t uid; /* Owner's user ID. */
|
||||
gid_t gid; /* Owner's group ID. */
|
||||
uid_t cuid; /* Creator's user ID. */
|
||||
gid_t cgid; /* Creator's group ID. */
|
||||
mode_t mode; /* Read/write permission. */
|
||||
};
|
||||
|
||||
#define IPC_CREAT 0x01
|
||||
#define IPC_EXCL 0x02
|
||||
#define IPC_NOWAIT 0x04
|
||||
#define IPC_PRIVATE 0x08
|
||||
#define IPC_RMID 0x10
|
||||
#define IPC_SET 0x20
|
||||
#define IPC_STAT 0x40
|
||||
|
||||
key_t ftok(const char* path, int id);
|
||||
|
||||
__END_DECLS
|
||||
|
||||
#endif
|
||||
65
libc/include/sys/mman.h
Normal file
65
libc/include/sys/mman.h
Normal file
@@ -0,0 +1,65 @@
|
||||
#ifndef _SYS_MMAN_H
|
||||
#define _SYS_MMAN_H 1
|
||||
|
||||
// https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/sys_mman.h.html
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
|
||||
__BEGIN_DECLS
|
||||
|
||||
#define PROT_EXEC 0x01
|
||||
#define PROT_NONE 0x02
|
||||
#define PROT_READ 0x04
|
||||
#define PROT_WRITE 0x08
|
||||
|
||||
#define MAP_FIXED 0x01
|
||||
#define MAP_PRIVATE 0x02
|
||||
#define MAP_SHARED 0x04
|
||||
|
||||
#define MS_ASYNC 0x01
|
||||
#define MS_INVALIDATE 0x02
|
||||
#define MS_SYNC 0x04
|
||||
|
||||
#define MCL_CURRENT 0x01
|
||||
#define MCL_FUTURE 0x01
|
||||
|
||||
#define MAP_FAILED ((void*)0)
|
||||
|
||||
#define POSIX_MADV_DONTNEED 1
|
||||
#define POSIX_MADV_NORMAL 2
|
||||
#define POSIX_MADV_RANDOM 3
|
||||
#define POSIX_MADV_SEQUENTIAL 4
|
||||
#define POSIX_MADV_WILLNEED 5
|
||||
|
||||
#define POSIX_TYPED_MEM_ALLOCATE 0x01
|
||||
#define POSIX_TYPED_MEM_ALLOCATE_CONTIG 0x02
|
||||
#define POSIX_TYPED_MEM_MAP_ALLOCATABLE 0x04
|
||||
|
||||
#define __need_mode_t
|
||||
#define __need_off_t
|
||||
#define __need_size_t
|
||||
#include <sys/types.h>
|
||||
|
||||
struct posix_typed_mem_info
|
||||
{
|
||||
size_t posix_tmi_length; /* Maximum length which may be allocated from a typed memory object. */
|
||||
};
|
||||
|
||||
int mlock(const void* addr, size_t len);
|
||||
int mlockall(int flags);
|
||||
void* mmap(void* addr, size_t len, int prot, int flags, int fildes, off_t off);
|
||||
int mprotect(void* addr, size_t len, int prot);
|
||||
int msync(void* addr, size_t len, int flags);
|
||||
int munlock(const void* addr, size_t len);
|
||||
int munlockall(void);
|
||||
int munmap(void* addr, size_t len);
|
||||
int posix_madvise(void* addr, size_t len, int advice);
|
||||
int posix_mem_offset(const void* __restrict addr, size_t len, off_t* __restrict off, size_t* __restrict contig_len, int* __restrict fildes);
|
||||
int posix_typed_mem_get_info(int fildes, struct posix_typed_mem_info* info);
|
||||
int posix_typed_mem_open(const char* name, int oflag, int tflag);
|
||||
int shm_open(const char* name, int oflag, mode_t mode);
|
||||
int shm_unlink(const char* name);
|
||||
|
||||
__END_DECLS
|
||||
|
||||
#endif
|
||||
42
libc/include/sys/msg.h
Normal file
42
libc/include/sys/msg.h
Normal file
@@ -0,0 +1,42 @@
|
||||
#ifndef _SYS_MSG_H
|
||||
#define _SYS_MSG_H 1
|
||||
|
||||
// https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/sys_msg.h.html
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
|
||||
__BEGIN_DECLS
|
||||
|
||||
#define __need_pid_t
|
||||
#define __need_size_t
|
||||
#define __need_ssize_t
|
||||
#define __need_time_t
|
||||
#include <sys/types.h>
|
||||
|
||||
#include <sys/ipc.h>
|
||||
|
||||
typedef unsigned int msgqnum_t;
|
||||
typedef unsigned int msglen_t;
|
||||
|
||||
#define MSG_NOERROR 0
|
||||
|
||||
struct msqid_ds
|
||||
{
|
||||
struct ipc_perm msg_perm; /* Operation permission structure. */
|
||||
msgqnum_t msg_qnum; /* Number of messages currently on queue. */
|
||||
msglen_t msg_qbytes; /* Maximum number of bytes allowed on queue. */
|
||||
pid_t msg_lspid; /* Process ID of last msgsnd(). */
|
||||
pid_t msg_lrpid; /* Process ID of last msgrcv(). */
|
||||
time_t msg_stime; /* Time of last msgsnd(). */
|
||||
time_t msg_rtime; /* Time of last msgrcv(). */
|
||||
time_t msg_ctime; /* Time of last change. */
|
||||
};
|
||||
|
||||
int msgctl(int msqid, int cmd, struct msqid_ds* buf);
|
||||
int msgget(key_t key, int msgflg);
|
||||
ssize_t msgrcv(int msqid, void* msgp, size_t msgsz, long msgtyp, int msgflg);
|
||||
int msgsnd(int msqid, const void* msgp, size_t msgsz, int msgflg);
|
||||
|
||||
__END_DECLS
|
||||
|
||||
#endif
|
||||
@@ -1,4 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
#define MIN(a, b) ((a) < (b) ? (a) : (b))
|
||||
#define MAX(a, b) ((a) > (b) ? (a) : (b))
|
||||
56
libc/include/sys/resource.h
Normal file
56
libc/include/sys/resource.h
Normal file
@@ -0,0 +1,56 @@
|
||||
#ifndef _SYS_RESOURCE_H
|
||||
#define _SYS_RESOURCE_H 1
|
||||
|
||||
// https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/sys_resource.h.html
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
|
||||
__BEGIN_DECLS
|
||||
|
||||
#define __need_id_t
|
||||
#include <sys/types.h>
|
||||
|
||||
#include <sys/time.h>
|
||||
|
||||
#define PRIO_PROCESS 0
|
||||
#define PRIO_PGRP 1
|
||||
#define PRIO_USER 2
|
||||
|
||||
typedef unsigned int rlim_t;
|
||||
|
||||
#define RLIM_INFINITY ((rlim_t)-1)
|
||||
#define RLIM_SAVED_MAX RLIM_INFINITY
|
||||
#define RLIM_SAVED_CUR RLIM_INFINITY
|
||||
|
||||
#define RUSAGE_SELF 0
|
||||
#define RUSAGE_CHILDREN 1
|
||||
|
||||
struct rlimit
|
||||
{
|
||||
rlim_t rlim_cur; /* The current (soft) limit. */
|
||||
rlim_t rlim_max; /* The hard limit. */
|
||||
};
|
||||
|
||||
struct rusage
|
||||
{
|
||||
struct timeval ru_utime; /* User time used. */
|
||||
struct timeval ru_stime; /* System time used. */
|
||||
};
|
||||
|
||||
#define RLIMIT_CORE 0
|
||||
#define RLIMIT_CPU 1
|
||||
#define RLIMIT_DATA 2
|
||||
#define RLIMIT_FSIZE 3
|
||||
#define RLIMIT_NOFILE 4
|
||||
#define RLIMIT_STACK 5
|
||||
#define RLIMIT_AS 6
|
||||
|
||||
int getpriority(int which, id_t who);
|
||||
int getrlimit(int resource, struct rlimit* rlp);
|
||||
int getrusage(int who, struct rusage* r_usage);
|
||||
int setpriority(int which, id_t who, int value);
|
||||
int setrlimit(int resource, const struct rlimit* rlp);
|
||||
|
||||
__END_DECLS
|
||||
|
||||
#endif
|
||||
58
libc/include/sys/select.h
Normal file
58
libc/include/sys/select.h
Normal file
@@ -0,0 +1,58 @@
|
||||
#ifndef _SYS_SELECT_H
|
||||
#define _SYS_SELECT_H 1
|
||||
|
||||
// https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/sys_select.h.html
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
|
||||
__BEGIN_DECLS
|
||||
|
||||
#define __need_time_t
|
||||
#define __need_suseconds_t
|
||||
#include <sys/types.h>
|
||||
|
||||
#include <signal.h>
|
||||
#include <time.h>
|
||||
|
||||
#define FD_SETSIZE 1024
|
||||
|
||||
typedef unsigned long __fd_mask;
|
||||
#define __FD_MASK_SIZE (8 * sizeof(__fd_mask))
|
||||
|
||||
typedef struct {
|
||||
__fd_mask __bits[FD_SETSIZE / __FD_MASK_SIZE];
|
||||
} fd_set;
|
||||
|
||||
#define FD_CLR(fd, setp) \
|
||||
do { \
|
||||
__fd_mask off = (fd) / __FD_MASK_SIZE; \
|
||||
__fd_mask bit = (fd) % __FD_MASK_SIZE; \
|
||||
(setp)->__bits[off] &= ~((__fd_mask)1 << bit); \
|
||||
} while (0)
|
||||
|
||||
#define FD_ISSET(fd, setp) \
|
||||
({ \
|
||||
__fd_mask off = (fd) / __FD_MASK_SIZE; \
|
||||
__fd_mask bit = (fd) % __FD_MASK_SIZE; \
|
||||
(setp)->__bits[off] & ((__fd_mask)1 << bit); \
|
||||
})
|
||||
|
||||
#define FD_SET(fd, setp) \
|
||||
do { \
|
||||
__fd_mask off = (fd) / __FD_MASK_SIZE; \
|
||||
__fd_mask bit = (fd) % __FD_MASK_SIZE; \
|
||||
(setp)->__bits[off] |= ((__fd_mask)1 << bit); \
|
||||
} while (0)
|
||||
|
||||
#define FD_ZERO(setp) \
|
||||
do { \
|
||||
for (int i = 0; i < FD_SETSIZE / __FD_MASK_SIZE; i++) \
|
||||
(setp)->__bits[i] = (__fd_mask)0; \
|
||||
} while (0)
|
||||
|
||||
int pselect(int nfds, fd_set* __restrict readfds, fd_set* __restrict writefds, fd_set* __restrict errorfds, const struct timespec* __restrict timeout, const sigset_t* __restrict sigmask);
|
||||
int select(int nfds, fd_set* __restrict readfds, fd_set* __restrict writefds, fd_set* __restrict errorfds, struct timeval* __restrict timeout);
|
||||
|
||||
__END_DECLS
|
||||
|
||||
#endif
|
||||
54
libc/include/sys/sem.h
Normal file
54
libc/include/sys/sem.h
Normal file
@@ -0,0 +1,54 @@
|
||||
#ifndef _SYS_SEM_H
|
||||
#define _SYS_SEM_H 1
|
||||
|
||||
// https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/sys_sem.h.html
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
|
||||
__BEGIN_DECLS
|
||||
|
||||
#define __need_pid_t
|
||||
#define __need_size_t
|
||||
#define __need_time_t
|
||||
#include <sys/types.h>
|
||||
|
||||
#include <sys/ipc.h>
|
||||
|
||||
#define SEM_UNDO 1
|
||||
|
||||
#define GETNCNT 0
|
||||
#define GETPID 1
|
||||
#define GETVAL 2
|
||||
#define GETALL 3
|
||||
#define GETZCNT 4
|
||||
#define SETVAL 5
|
||||
#define SETALL 6
|
||||
|
||||
struct semid_ds
|
||||
{
|
||||
struct ipc_perm sem_perm; /* Operation permission structure. */
|
||||
unsigned short sem_nsems; /* Number of semaphores in set. */
|
||||
time_t sem_otime; /* Last semop() time. */
|
||||
time_t sem_ctime; /* Last time changed by semctl(). */
|
||||
};
|
||||
|
||||
// FIXME: A semaphore shall be represented by an anonymous structure, which shall include the following members:
|
||||
// unsigned short semval; /* Semaphore value. */
|
||||
// pid_t sempid; /* Process ID of last operation. */
|
||||
// unsigned short semncnt; /* Number of processes waiting for semval to become greater than current value. */
|
||||
// unsigned short semzcnt; /* Number of processes waiting for semval to become 0. */
|
||||
|
||||
struct sembuf
|
||||
{
|
||||
unsigned short sem_num; /* Semaphore number. */
|
||||
short sem_op; /* Semaphore operation. */
|
||||
short sem_flg; /* Operation flags. */
|
||||
};
|
||||
|
||||
int semctl(int, int, int, ...);
|
||||
int semget(key_t, int, int);
|
||||
int semop(int, struct sembuf *, size_t);
|
||||
|
||||
__END_DECLS
|
||||
|
||||
#endif
|
||||
42
libc/include/sys/shm.h
Normal file
42
libc/include/sys/shm.h
Normal file
@@ -0,0 +1,42 @@
|
||||
#ifndef _SYS_SHM_H
|
||||
#define _SYS_SHM_H 1
|
||||
|
||||
// https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/sys_shm.h.html
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
|
||||
__BEGIN_DECLS
|
||||
|
||||
#define __need_pid_t
|
||||
#define __need_size_t
|
||||
#define __need_time_t
|
||||
#include <sys/types.h>
|
||||
|
||||
#include <sys/ipc.h>
|
||||
|
||||
#define SHM_RDONLY 0x01
|
||||
#define SHM_RDONLY 0x02
|
||||
#define SHM_RDONLY 0x04
|
||||
|
||||
typedef unsigned int shmatt_t;
|
||||
|
||||
struct shmid_ds
|
||||
{
|
||||
struct ipc_perm shm_perm; /* Operation permission structure. */
|
||||
size_t shm_segsz; /* Size of segment in bytes. */
|
||||
pid_t shm_lpid; /* Process ID of last shared memory operation. */
|
||||
pid_t shm_cpid; /* Process ID of creator. */
|
||||
shmatt_t shm_nattch; /* Number of current attaches. */
|
||||
time_t shm_atime; /* Time of last shmat(). */
|
||||
time_t shm_dtime; /* Time of last shmdt(). */
|
||||
time_t shm_ctime; /* Time of last change by shmctl().*/
|
||||
};
|
||||
|
||||
void* shmat(int shmid, const void* shmaddr, int shmflg);
|
||||
int shmctl(int shmid, int cmd, struct shmid_ds* buf);
|
||||
int shmdt(const void* shmaddr);
|
||||
int shmget(key_t key, size_t size, int shmflg);
|
||||
|
||||
__END_DECLS
|
||||
|
||||
#endif
|
||||
129
libc/include/sys/socket.h
Normal file
129
libc/include/sys/socket.h
Normal file
@@ -0,0 +1,129 @@
|
||||
#ifndef _SYS_SOCKET_H
|
||||
#define _SYS_SOCKET_H 1
|
||||
|
||||
// https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/sys_socket.h.html
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
|
||||
__BEGIN_DECLS
|
||||
|
||||
#define __need_size_t
|
||||
#define __need_ssize_t
|
||||
#include <sys/types.h>
|
||||
|
||||
#include <sys/uio.h>
|
||||
|
||||
#include <bits/types/sa_family_t.h>
|
||||
typedef long socklen_t;
|
||||
|
||||
struct sockaddr
|
||||
{
|
||||
sa_family_t sa_family; /* Address family. */
|
||||
char sa_data[]; /* Socket address (variable-length data). */
|
||||
};
|
||||
|
||||
struct sockaddr_storage
|
||||
{
|
||||
// FIXME
|
||||
sa_family_t ss_family;
|
||||
};
|
||||
|
||||
struct msghdr
|
||||
{
|
||||
void* msg_name; /* Optional address. */
|
||||
socklen_t msg_namelen; /* Size of address. */
|
||||
struct iovec* msg_iov; /* Scatter/gather array. */
|
||||
int msg_iovlen; /* Members in msg_iov. */
|
||||
void* msg_control; /* Ancillary data; see below. */
|
||||
socklen_t msg_controllen; /* Ancillary data buffer len. */
|
||||
int msg_flags; /* Flags on received message. */
|
||||
};
|
||||
|
||||
struct cmsghdr
|
||||
{
|
||||
socklen_t cmsg_len; /* Data byte count, including the cmsghdr. */
|
||||
int cmsg_level; /* Originating protocol. */
|
||||
int cmsg_type; /* Protocol-specific type. */
|
||||
};
|
||||
|
||||
// FIXME
|
||||
#if 0
|
||||
#define SCM_RIGHTS
|
||||
|
||||
#define CMSG_DATA(cmsg)
|
||||
#define CMSG_NXTHDR(mhdr, cmsg)
|
||||
#define CMSG_FIRSTHDR(mhdr)
|
||||
#endif
|
||||
|
||||
struct linger
|
||||
{
|
||||
int l_onoff; /* Indicates wheter linger option is enabled. */
|
||||
int l_linger; /* Linger time, in seconds. */
|
||||
};
|
||||
|
||||
#define SOCK_DGRAM 0
|
||||
#define SOCK_RAW 1
|
||||
#define SOCK_SEQPACKET 2
|
||||
#define SOCK_STREAM 3
|
||||
|
||||
#define SOL_SOCKET 1
|
||||
|
||||
#define SO_ACCEPTCONN 0
|
||||
#define SO_BROADCAST 1
|
||||
#define SO_DEBUG 2
|
||||
#define SO_DONTROUTE 3
|
||||
#define SO_ERROR 4
|
||||
#define SO_KEEPALIVE 5
|
||||
#define SO_LINGER 6
|
||||
#define SO_OOBINLINE 7
|
||||
#define SO_RCVBUF 8
|
||||
#define SO_RCVLOWAT 9
|
||||
#define SO_RCVTIMEO 10
|
||||
#define SO_REUSEADDR 11
|
||||
#define SO_SNDBUF 12
|
||||
#define SO_SNDLOWAT 13
|
||||
#define SO_SNDTIMEO 14
|
||||
#define SO_TYPE 15
|
||||
|
||||
#define SOMAXCONN 4096
|
||||
|
||||
#define MSG_CTRUNC 0x01
|
||||
#define MSG_DONTROUTE 0x02
|
||||
#define MSG_EOR 0x04
|
||||
#define MSG_OOB 0x08
|
||||
#define MSG_NOSIGNAL 0x10
|
||||
#define MSG_PEEK 0x20
|
||||
#define MSG_TRUNC 0x40
|
||||
#define MSG_WAITALL 0x80
|
||||
|
||||
#define AF_UNSPEC 0
|
||||
#define AF_INET 1
|
||||
#define AF_INET6 2
|
||||
#define AF_UNIX 3
|
||||
|
||||
#define SHUT_RD 0x01
|
||||
#define SHUT_WR 0x02
|
||||
#define SHUT_RDWR (SHUT_RD | SHUT_WR)
|
||||
|
||||
int accept(int socket, struct sockaddr* __restrict address, socklen_t* __restrict address_len);
|
||||
int bind(int socket, const struct sockaddr* address, socklen_t address_len);
|
||||
int connect(int socket, const struct sockaddr* address, socklen_t address_len);
|
||||
int getpeername(int socket, struct sockaddr* __restrict address, socklen_t* __restrict address_len);
|
||||
int getsockname(int socket, struct sockaddr* __restrict address, socklen_t* __restrict address_len);
|
||||
int getsockopt(int socket, int level, int option_name, void* __restrict option_value, socklen_t* __restrict option_len);
|
||||
int listen(int socket, int backlog);
|
||||
ssize_t recv(int socket, void* buffer, size_t length, int flags);
|
||||
ssize_t recvfrom(int socket, void* __restrict buffer, size_t length, int flags, struct sockaddr* __restrict address, socklen_t* __restrict address_len);
|
||||
ssize_t recvmsg(int socket, struct msghdr* message, int flags);
|
||||
ssize_t send(int socket, const void* buffer, size_t length, int flags);
|
||||
ssize_t sendmsg(int socket, const struct msghdr* message, int flags);
|
||||
ssize_t sendto(int socket, const void* message, size_t length, int flags, const struct sockaddr* dest_addr, socklen_t dest_len);
|
||||
int setsockopt(int socket, int level, int option_name, const void* option_value, socklen_t option_len);
|
||||
int shutdown(int socket, int how);
|
||||
int sockatmark(int s);
|
||||
int socket(int domain, int type, int protocol);
|
||||
int socketpair(int domain, int type, int protocol, int socket_vector[2]);
|
||||
|
||||
__END_DECLS
|
||||
|
||||
#endif
|
||||
@@ -1,46 +1,108 @@
|
||||
#pragma once
|
||||
#ifndef _SYS_STAT_H
|
||||
#define _SYS_STAT_H 1
|
||||
|
||||
// https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/sys_stat.h.html
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
|
||||
__BEGIN_DECLS
|
||||
|
||||
#define __need_blkcnt_t
|
||||
#define __need_blksize_t
|
||||
#define __need_dev_t
|
||||
#define __need_ino_t
|
||||
#define __need_mode_t
|
||||
#define __need_nlink_t
|
||||
#define __need_uid_t
|
||||
#define __need_gid_t
|
||||
#define __need_off_t
|
||||
#define __need_time_t
|
||||
#include <sys/types.h>
|
||||
|
||||
#include <time.h>
|
||||
|
||||
struct stat
|
||||
{
|
||||
dev_t st_dev; /* Device ID of device containing file. */
|
||||
ino_t st_ino; /* File serial number. */
|
||||
mode_t st_mode; /* Mode of file (see below). */
|
||||
nlink_t st_nlink; /* Number of hard links to the file. */
|
||||
uid_t st_uid; /* User ID of file. */
|
||||
gid_t st_gid; /* Group ID of file. */
|
||||
dev_t st_rdev; /* Device ID (if file is character or block special). */
|
||||
off_t st_size; /* For regular files, the file size in bytes. For symbolic links, the length in bytes of the pathname contained in the symbolic link. For a shared memory object, the length in bytes. For a typed memory object, the length in bytes. For other file types, the use of this field is unspecified. */
|
||||
struct timespec st_atim; /* Last data access timestamp. */
|
||||
struct timespec st_mtim; /* Last data modification timestamp. */
|
||||
struct timespec st_ctim; /* Last file status change timestamp. */
|
||||
blksize_t st_blksize; /* A file system-specific preferred I/O block size for this object. In some file system types, this may vary from file to file. */
|
||||
blkcnt_t st_blocks; /* Number of blocks allocated for this object. */
|
||||
};
|
||||
|
||||
#define st_atime st_atim.tv_sec
|
||||
#define st_ctime st_ctim.tv_sec
|
||||
#define st_mtime st_mtim.tv_sec
|
||||
|
||||
__BEGIN_DECLS
|
||||
#define S_IRWXU ((mode_t)00700)
|
||||
#define S_IRUSR ((mode_t)00400)
|
||||
#define S_IWUSR ((mode_t)00200)
|
||||
#define S_IXUSR ((mode_t)00100)
|
||||
#define S_IRWXG ((mode_t)00070)
|
||||
#define S_IRGRP ((mode_t)00040)
|
||||
#define S_IWGRP ((mode_t)00020)
|
||||
#define S_IXGRP ((mode_t)00010)
|
||||
#define S_IRWXO ((mode_t)00007)
|
||||
#define S_IROTH ((mode_t)00004)
|
||||
#define S_IWOTH ((mode_t)00002)
|
||||
#define S_IXOTH ((mode_t)00001)
|
||||
#define S_ISUID ((mode_t)04000)
|
||||
#define S_ISGID ((mode_t)02000)
|
||||
#define S_ISVTX ((mode_t)01000)
|
||||
|
||||
struct stat
|
||||
{
|
||||
dev_t st_dev;
|
||||
ino_t st_ino;
|
||||
mode_t st_mode;
|
||||
nlink_t st_nlink;
|
||||
uid_t st_uid;
|
||||
gid_t st_gid;
|
||||
dev_t st_rdev;
|
||||
off_t st_size;
|
||||
timespec st_atim;
|
||||
timespec st_mtim;
|
||||
timespec st_ctim;
|
||||
blksize_t st_blksize;
|
||||
blkcnt_t st_blocks;
|
||||
};
|
||||
#define S_IFIFO ((mode_t)0010000)
|
||||
#define S_IFCHR ((mode_t)0020000)
|
||||
#define S_IFDIR ((mode_t)0040000)
|
||||
#define S_IFBLK ((mode_t)0060000)
|
||||
#define S_IFREG ((mode_t)0100000)
|
||||
#define S_IFLNK ((mode_t)0120000)
|
||||
#define S_IFSOCK ((mode_t)0140000)
|
||||
|
||||
int chmod(const char*, mode_t);
|
||||
int fchmod(int, mode_t);
|
||||
int fchmodat(int, const char*, mode_t, int);
|
||||
int fstat(int, struct stat*);
|
||||
int fstatat(int, const char*, struct stat*, int);
|
||||
int futimens(int, const struct timespec[2]);
|
||||
int lstat(const char*, struct stat*);
|
||||
int mkdir(const char*, mode_t);
|
||||
int mkdirat(int, const char*, mode_t);
|
||||
int mkfifo(const char*, mode_t);
|
||||
int mkfifoat(int, const char*, mode_t);
|
||||
int mknod(const char*, mode_t, dev_t);
|
||||
int mknodat(int, const char*, mode_t, dev_t);
|
||||
int stat(const char*, struct stat*);
|
||||
mode_t umask(mode_t);
|
||||
int utimensat(int, const char*, const struct timespec[2], int);
|
||||
#define S_ISBLK(mode) (mode & S_IFBLK)
|
||||
#define S_ISCHR(mode) (mode & S_IFCHR)
|
||||
#define S_ISDIR(mode) (mode & S_IFDIR)
|
||||
#define S_ISFIFO(mode) (mode & S_IFIFO)
|
||||
#define S_ISREG(mode) (mode & S_IFREG)
|
||||
#define S_ISLNK(mode) (mode & S_IFLNK)
|
||||
#define S_ISSOCK(mode) (mode & S_IFSOCK)
|
||||
|
||||
// FIXME
|
||||
#if 0
|
||||
#define S_TYPEISMQ(buf)
|
||||
#define S_TYPEISSEM(buf)
|
||||
#define S_TYPEISSHM(buf)
|
||||
#define S_TYPEISTMO(buf)
|
||||
#endif
|
||||
|
||||
#define UTIME_NOW 1000000001
|
||||
#define UTIME_OMIT 1000000002
|
||||
|
||||
|
||||
int chmod(const char* path, mode_t mode);
|
||||
int fchmod(int fildes, mode_t mode);
|
||||
int fchmodat(int fd, const char* path, mode_t mode, int flag);
|
||||
int fstat(int fildes, struct stat* buf);
|
||||
int fstatat(int fd, const char* __restrict path, struct stat* __restrict buf, int flag);
|
||||
int futimens(int fd, const struct timespec times[2]);
|
||||
int lstat(const char* __restrict path, struct stat* __restrict buf);
|
||||
int mkdir(const char* path, mode_t mode);
|
||||
int mkdirat(int fd, const char* path, mode_t mode);
|
||||
int mkfifo(const char* path, mode_t mode);
|
||||
int mkfifoat(int fd, const char* path, mode_t mode);
|
||||
int mknod(const char* path, mode_t mode, dev_t dev);
|
||||
int mknodat(int fd, const char* path, mode_t mode, dev_t dev);
|
||||
int stat(const char* __restrict path, struct stat* __restrict buf);
|
||||
mode_t umask(mode_t cmask);
|
||||
int utimensat(int fd, const char* path, const struct timespec times[2], int flag);
|
||||
|
||||
__END_DECLS
|
||||
|
||||
#endif
|
||||
|
||||
37
libc/include/sys/statvfs.h
Normal file
37
libc/include/sys/statvfs.h
Normal file
@@ -0,0 +1,37 @@
|
||||
#ifndef _SYS_STATVFS_H
|
||||
#define _SYS_STATVFS_H 1
|
||||
|
||||
// https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/sys_statvfs.h.html
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
|
||||
__BEGIN_DECLS
|
||||
|
||||
#define __need_fsblkcnt_t
|
||||
#define __need_fsfilcnt_t
|
||||
#include <sys/types.h>
|
||||
|
||||
struct statvfs
|
||||
{
|
||||
unsigned long f_bsize; /* File system block size. */
|
||||
unsigned long f_frsize; /* Fundamental file system block size. */
|
||||
fsblkcnt_t f_blocks; /* Total number of blocks on file system in units of f_frsize. */
|
||||
fsblkcnt_t f_bfree; /* Total number of free blocks. */
|
||||
fsblkcnt_t f_bavail; /* Number of free blocks available to non-privileged process. */
|
||||
fsfilcnt_t f_files; /* Total number of file serial numbers. */
|
||||
fsfilcnt_t f_ffree; /* Total number of free file serial numbers. */
|
||||
fsfilcnt_t f_favail; /* Number of file serial numbers available to non-privileged process. */
|
||||
unsigned long f_fsid; /* File system ID. */
|
||||
unsigned long f_flag; /* Bit mask of f_flag values. */
|
||||
unsigned long f_namemax; /* Maximum filename length. */
|
||||
};
|
||||
|
||||
#define ST_RDONLY 0x01
|
||||
#define ST_NOSUID 0x02
|
||||
|
||||
int fstatvfs(int fildes, struct statvfs* buf);
|
||||
int statvfs(const char* __restrict path, struct statvfs* __restrict buf);
|
||||
|
||||
__END_DECLS
|
||||
|
||||
#endif
|
||||
@@ -1,3 +1,23 @@
|
||||
#pragma once
|
||||
#ifndef _SYS_SYSCALL_H
|
||||
#define _SYS_SYSCALL_H 1
|
||||
|
||||
#include <kernel/Syscall.h>
|
||||
#include <sys/cdefs.h>
|
||||
|
||||
__BEGIN_DECLS
|
||||
|
||||
#define SYS_EXIT 1
|
||||
#define SYS_READ 2
|
||||
#define SYS_WRITE 3
|
||||
#define SYS_TERMID 4
|
||||
#define SYS_CLOSE 5
|
||||
#define SYS_OPEN 6
|
||||
#define SYS_ALLOC 7
|
||||
#define SYS_FREE 8
|
||||
#define SYS_SEEK 9
|
||||
#define SYS_TELL 10
|
||||
#define SYS_GET_TERMIOS 11
|
||||
#define SYS_SET_TERMIOS 12
|
||||
|
||||
__END_DECLS
|
||||
|
||||
#endif
|
||||
|
||||
@@ -1,8 +1,18 @@
|
||||
#pragma once
|
||||
#ifndef _SYS_SYSMACROS_H
|
||||
#define _SYS_SYSMACROS_H 1
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
|
||||
__BEGIN_DECLS
|
||||
|
||||
#define __need_pid_t
|
||||
#include <sys/types.h>
|
||||
|
||||
#define makedev(maj, min) ((dev_t)(maj) << 32 | (dev_t)(min))
|
||||
|
||||
#define major(dev) (((dev) >> 32) & 0xFFFFFFFF)
|
||||
#define minor(dev) ( (dev) & 0xFFFFFFFF)
|
||||
|
||||
__END_DECLS
|
||||
|
||||
#endif
|
||||
40
libc/include/sys/time.h
Normal file
40
libc/include/sys/time.h
Normal file
@@ -0,0 +1,40 @@
|
||||
#ifndef _SYS_TIME_H
|
||||
#define _SYS_TIME_H 1
|
||||
|
||||
// https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/sys_time.h.html
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
|
||||
__BEGIN_DECLS
|
||||
|
||||
#define __need_time_t
|
||||
#define __need_suseconds_t
|
||||
#include <sys/types.h>
|
||||
|
||||
#include <sys/select.h>
|
||||
|
||||
struct timeval
|
||||
{
|
||||
time_t tv_sec; /* Seconds. */
|
||||
suseconds_t tc_usec; /* Microseconds. */
|
||||
};
|
||||
|
||||
struct itimerval
|
||||
{
|
||||
struct timeval it_interval; /* Timer interval. */
|
||||
struct timeval it_value; /* Current value. */
|
||||
};
|
||||
|
||||
#define ITIMER_REAL 0
|
||||
#define ITIMER_VIRTUAL 1
|
||||
#define ITIMER_PROF 2
|
||||
|
||||
int getitimer(int which, struct itimerval* value);
|
||||
int gettimeofday(struct timeval* __restrict tp, void* __restrict tzp);
|
||||
int setitimer(int which, const struct itimerval* __restrict value, struct itimerval* __restrict ovalue);
|
||||
int select(int nfds, fd_set* __restrict readfds, fd_set* __restrict writefds, fd_set* __restrict errorfds, struct timeval* __restrict timeout);
|
||||
int utimes(const char* path, const struct timeval times[2]);
|
||||
|
||||
__END_DECLS
|
||||
|
||||
#endif
|
||||
25
libc/include/sys/times.h
Normal file
25
libc/include/sys/times.h
Normal file
@@ -0,0 +1,25 @@
|
||||
#ifndef _SYS_TIMES_H
|
||||
#define _SYS_TIMES_H 1
|
||||
|
||||
// https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/sys_times.h.html
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
|
||||
__BEGIN_DECLS
|
||||
|
||||
#define __need_clock_t
|
||||
#include <sys/types.h>
|
||||
|
||||
struct tms
|
||||
{
|
||||
clock_t tms_utime; /* User CPU time. */
|
||||
clock_t tms_stime; /* System CPU time. */
|
||||
clock_t tms_cutime; /* User CPU time of terminated child processes. */
|
||||
clock_t tms_cstime; /* System CPU time of terminated child processes. */
|
||||
};
|
||||
|
||||
clock_t times(struct tms* buffer);
|
||||
|
||||
__END_DECLS
|
||||
|
||||
#endif
|
||||
@@ -1,26 +1,196 @@
|
||||
#pragma once
|
||||
#ifndef _SYS_TYPES_H
|
||||
|
||||
// https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/sys_types.h.html
|
||||
|
||||
#include <stddef.h>
|
||||
#include <stdint.h>
|
||||
#include <sys/cdefs.h>
|
||||
|
||||
__BEGIN_DECLS
|
||||
|
||||
typedef int32_t blkcnt_t;
|
||||
typedef int32_t blksize_t;
|
||||
typedef uint64_t clock_t;
|
||||
typedef int32_t clockid_t;
|
||||
typedef uint64_t dev_t;
|
||||
typedef uint32_t ino_t;
|
||||
typedef uint16_t mode_t;
|
||||
typedef uint32_t nlink_t;
|
||||
typedef int64_t off_t;
|
||||
typedef uint64_t time_t;
|
||||
typedef uint64_t timer_t;
|
||||
typedef int32_t id_t;
|
||||
typedef id_t pid_t;
|
||||
typedef id_t uid_t;
|
||||
typedef id_t gid_t;
|
||||
typedef int64_t ssize_t;
|
||||
#if !defined(__need_blkcnt_t) \
|
||||
&& !defined(__need_blksize_t) \
|
||||
&& !defined(__need_clock_t) \
|
||||
&& !defined(__need_clockid_t) \
|
||||
&& !defined(__need_dev_t) \
|
||||
&& !defined(__need_fsblkcnt_t) \
|
||||
&& !defined(__need_fsfilcnt_t) \
|
||||
&& !defined(__need_gid_t) \
|
||||
&& !defined(__need_id_t) \
|
||||
&& !defined(__need_ino_t) \
|
||||
&& !defined(__need_key_t) \
|
||||
&& !defined(__need_mode_t) \
|
||||
&& !defined(__need_nlink_t) \
|
||||
&& !defined(__need_off_t) \
|
||||
&& !defined(__need_pid_t) \
|
||||
&& !defined(__need_pthread_attr_t) \
|
||||
&& !defined(__need_pthread_barrier_t) \
|
||||
&& !defined(__need_pthread_barrierattr_t) \
|
||||
&& !defined(__need_pthread_cond_t) \
|
||||
&& !defined(__need_pthread_condattr_t) \
|
||||
&& !defined(__need_pthread_key_t) \
|
||||
&& !defined(__need_pthread_mutex_t) \
|
||||
&& !defined(__need_pthread_mutexattr_t) \
|
||||
&& !defined(__need_pthread_once_t) \
|
||||
&& !defined(__need_pthread_rwlock_t) \
|
||||
&& !defined(__need_pthread_rwlockattr_t) \
|
||||
&& !defined(__need_pthread_spinlock_t) \
|
||||
&& !defined(__need_pthread_t) \
|
||||
&& !defined(__need_size_t) \
|
||||
&& !defined(__need_ssize_t) \
|
||||
&& !defined(__need_suseconds_t) \
|
||||
&& !defined(__need_time_t) \
|
||||
&& !defined(__need_timer_t) \
|
||||
&& !defined(__need_uid_t)
|
||||
|
||||
__END_DECLS
|
||||
#define __need_all_types
|
||||
#endif
|
||||
|
||||
#ifdef __need_all_types
|
||||
#define _SYS_TYPES_H 1
|
||||
#endif
|
||||
|
||||
#if !defined(__blkcnt_t_defined) && (defined(__need_all_types) || defined(__need_blkcnt_t))
|
||||
#define __blkcnt_defined 1
|
||||
typedef long blkcnt_t;
|
||||
#endif
|
||||
#undef __need_blkcnt_t
|
||||
|
||||
#if !defined(__blksize_t_defined) && (defined(__need_all_types) || defined(__need_blksize_t))
|
||||
#define __blksize_t_defined 1
|
||||
typedef long blksize_t;
|
||||
#endif
|
||||
#undef __need_blksize_t
|
||||
|
||||
#if !defined(__clock_t_defined) && (defined(__need_all_types) || defined(__need_clock_t))
|
||||
#define __clock_t_defined 1
|
||||
typedef long clock_t;
|
||||
#endif
|
||||
#undef __need_clock_t
|
||||
|
||||
#if !defined(__clockid_t_defined) && (defined(__need_all_types) || defined(__need_clockid_t))
|
||||
#define __clockid_t_defined 1
|
||||
typedef int clockid_t;
|
||||
#endif
|
||||
#undef __need_clockid_t
|
||||
|
||||
#if !defined(__dev_t_defined) && (defined(__need_all_types) || defined(__need_dev_t))
|
||||
#define __dev_t_defined 1
|
||||
typedef unsigned long dev_t;
|
||||
#endif
|
||||
#undef __need_dev_t
|
||||
|
||||
#if !defined(__fsblkcnt_t_defined) && (defined(__need_all_types) || defined(__need_fsblkcnt_t))
|
||||
#define __fsblkcnt_t_defined 1
|
||||
typedef unsigned long fsblkcnt_t;
|
||||
#endif
|
||||
#undef __need_fsblkcnt_t
|
||||
|
||||
#if !defined(__fsfilcnt_t_defined) && (defined(__need_all_types) || defined(__need_fsfilcnt_t))
|
||||
#define __fsfilcnt_t_defined 1
|
||||
typedef unsigned long fsfilcnt_t;
|
||||
#endif
|
||||
#undef __need_fsfilcnt_t
|
||||
|
||||
#if !defined(__gid_t_defined) && (defined(__need_all_types) || defined(__need_gid_t))
|
||||
#define __gid_t_defined 1
|
||||
typedef unsigned int gid_t;
|
||||
#endif
|
||||
#undef __need_gid_t
|
||||
|
||||
#if !defined(__id_t_defined) && (defined(__need_all_types) || defined(__need_id_t))
|
||||
#define __id_t_defined 1
|
||||
typedef unsigned int id_t;
|
||||
#endif
|
||||
#undef __need_id_t
|
||||
|
||||
#if !defined(__ino_t_defined) && (defined(__need_all_types) || defined(__need_ino_t))
|
||||
#define __ino_t_defined 1
|
||||
typedef unsigned long ino_t;
|
||||
#endif
|
||||
#undef __need_ino_t
|
||||
|
||||
#if !defined(__key_t_defined) && (defined(__need_all_types) || defined(__need_key_t))
|
||||
#define __key_t_defined 1
|
||||
typedef int key_t;
|
||||
#endif
|
||||
#undef __need_key_t
|
||||
|
||||
#if !defined(__mode_t_defined) && (defined(__need_all_types) || defined(__need_mode_t))
|
||||
#define __mode_t_defined 1
|
||||
typedef unsigned int mode_t;
|
||||
#endif
|
||||
#undef __need_mode_t
|
||||
|
||||
#if !defined(__nlink_t_defined) && (defined(__need_all_types) || defined(__need_nlink_t))
|
||||
#define __nlink_t_defined 1
|
||||
typedef unsigned long nlink_t;
|
||||
#endif
|
||||
#undef __need_nlink_t
|
||||
|
||||
#if !defined(__off_t_defined) && (defined(__need_all_types) || defined(__need_off_t))
|
||||
#define __off_t_defined 1
|
||||
typedef long off_t;
|
||||
#endif
|
||||
#undef __need_off_t
|
||||
|
||||
#if !defined(__pid_t_defined) && (defined(__need_all_types) || defined(__need_pid_t))
|
||||
#define __pid_t_defined 1
|
||||
typedef int pid_t;
|
||||
#endif
|
||||
#undef __need_pid_t
|
||||
|
||||
#include <bits/pthread_types.h>
|
||||
|
||||
#if !defined(__size_t_defined) && (defined(__need_all_types) || defined(__need_size_t))
|
||||
#define __size_t_defined 1
|
||||
#define __need_size_t
|
||||
#include <stddef.h>
|
||||
#endif
|
||||
#undef __need_size_t
|
||||
|
||||
#if !defined(__ssize_t_defined) && (defined(__need_all_types) || defined(__need_ssize_t))
|
||||
#define __ssize_t_defined 1
|
||||
#if __SIZEOF_SIZE_T__ == __SIZEOF_INT__
|
||||
typedef int ssize_t;
|
||||
#elif __SIZEOF_SIZE_T__ == __SIZEOF_LONG__
|
||||
typedef long ssize_t;
|
||||
#elif __SIZEOF_SIZE_T__ == __SIZEOF_LONG_LONG__
|
||||
typedef long long ssize_t;
|
||||
#else
|
||||
#error "unsupported sizeof(size_t)"
|
||||
#endif
|
||||
#endif
|
||||
#undef __need_ssize_t
|
||||
|
||||
#if !defined(__suseconds_t_defined) && (defined(__need_all_types) || defined(__need_suseconds_t))
|
||||
#define __suseconds_t_defined 1
|
||||
typedef long suseconds_t;
|
||||
#endif
|
||||
#undef __need_suseconds_t
|
||||
|
||||
#if !defined(__time_t_defined) && (defined(__need_all_types) || defined(__need_time_t))
|
||||
#define __time_t_defined 1
|
||||
typedef unsigned long long time_t;
|
||||
#endif
|
||||
#undef __need_time_t
|
||||
|
||||
#if !defined(__timer_t_defined) && (defined(__need_all_types) || defined(__need_timer_t))
|
||||
#define __timer_t_defined 1
|
||||
typedef void* timer_t;
|
||||
#endif
|
||||
#undef __need_timer_t
|
||||
|
||||
#if !defined(__uid_t_defined) && (defined(__need_all_types) || defined(__need_uid_t))
|
||||
#define __uid_t_defined 1
|
||||
typedef int uid_t;
|
||||
#endif
|
||||
#undef __need_uid_t
|
||||
|
||||
#ifdef __need_all_types
|
||||
#include <stdint.h>
|
||||
#endif
|
||||
|
||||
#undef __need_all_types
|
||||
|
||||
__END_DECLS
|
||||
|
||||
#endif
|
||||
|
||||
25
libc/include/sys/uio.h
Normal file
25
libc/include/sys/uio.h
Normal file
@@ -0,0 +1,25 @@
|
||||
#ifndef _SYS_UIO_H
|
||||
#define _SYS_UIO_H 1
|
||||
|
||||
// https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/sys_uio.h.html
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
|
||||
__BEGIN_DECLS
|
||||
|
||||
#define __need_size_t
|
||||
#define __need_ssize_t
|
||||
#include <sys/types.h>
|
||||
|
||||
struct iovec
|
||||
{
|
||||
void* iov_base; /* Base address of a memory region for input or output. */
|
||||
size_t iov_len; /* The size of the memory pointed to by iov_base. */
|
||||
};
|
||||
|
||||
ssize_t readv(int fildes, const struct iovec* iov, int iovcnt);
|
||||
ssize_t writev(int fildes, const struct iovec* iov, int iovcnt);
|
||||
|
||||
__END_DECLS
|
||||
|
||||
#endif
|
||||
20
libc/include/sys/un.h
Normal file
20
libc/include/sys/un.h
Normal file
@@ -0,0 +1,20 @@
|
||||
#ifndef _SYS_UN_H
|
||||
#define _SYS_UN_H 1
|
||||
|
||||
// https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/sys_un.h.html
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
|
||||
__BEGIN_DECLS
|
||||
|
||||
#include <bits/types/sa_family_t.h>
|
||||
|
||||
struct sockaddr_un
|
||||
{
|
||||
sa_family_t sun_family; /* Address family. */
|
||||
char sun_path[]; /* Socket pathname. */
|
||||
};
|
||||
|
||||
__END_DECLS
|
||||
|
||||
#endif
|
||||
23
libc/include/sys/utsname.h
Normal file
23
libc/include/sys/utsname.h
Normal file
@@ -0,0 +1,23 @@
|
||||
#ifndef _SYS_UTSNAME_H
|
||||
#define _SYS_UTSNAME_H 1
|
||||
|
||||
// https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/sys_utsname.h.html
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
|
||||
__BEGIN_DECLS
|
||||
|
||||
struct utsname
|
||||
{
|
||||
char sysname[65]; /* Name of this implementation of the operating system. */
|
||||
char nodename[65]; /* Name of this node within the communications network to which this node is attached, if any. */
|
||||
char release[65]; /* Current release level of this implementation. */
|
||||
char version[65]; /* Current version level of this release. */
|
||||
char machine[65]; /* Name of the hardware type on which the system is running. */
|
||||
};
|
||||
|
||||
int uname(struct utsname* name);
|
||||
|
||||
__END_DECLS
|
||||
|
||||
#endif
|
||||
47
libc/include/sys/wait.h
Normal file
47
libc/include/sys/wait.h
Normal file
@@ -0,0 +1,47 @@
|
||||
#ifndef _SYS_WAIT_H
|
||||
#define _SYS_WAIT_H 1
|
||||
|
||||
// https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/sys_wait.h.html
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
|
||||
__BEGIN_DECLS
|
||||
|
||||
#define __need_id_t
|
||||
#define __need_pid_t
|
||||
#include <sys/types.h>
|
||||
|
||||
#include <signal.h>
|
||||
|
||||
#define WCONTINUED 0x01
|
||||
#define WNOHANG 0x02
|
||||
#define WUNTRACED 0x04
|
||||
#define WEXITED 0x08
|
||||
#define WNOWAIT 0x10
|
||||
#define WSTOPPED 0x20
|
||||
|
||||
// FIXME
|
||||
#if 0
|
||||
#define WEXITSTATUS
|
||||
#define WIFCONTINUED
|
||||
#define WIFEXITED
|
||||
#define WIFSIGNALED
|
||||
#define WIFSTOPPED
|
||||
#define WSTOPSIG
|
||||
#define WTERMSIG
|
||||
#endif
|
||||
|
||||
typedef enum
|
||||
{
|
||||
P_ALL,
|
||||
P_PGID,
|
||||
P_PID,
|
||||
} idtype_t;
|
||||
|
||||
pid_t wait(int* stat_loc);
|
||||
int waitid(idtype_t idtype, id_t id, siginfo_t* infop, int options);
|
||||
pid_t waitpid(pid_t pid, int* stat_loc, int options);
|
||||
|
||||
__END_DECLS
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user