diff options
Diffstat (limited to 'src/libc/include/sys')
-rw-r--r-- | src/libc/include/sys/select.h | 13 | ||||
-rw-r--r-- | src/libc/include/sys/socket.h | 38 | ||||
-rw-r--r-- | src/libc/include/sys/stat.h | 11 | ||||
-rw-r--r-- | src/libc/include/sys/time.h | 5 | ||||
-rw-r--r-- | src/libc/include/sys/types.h | 6 |
5 files changed, 67 insertions, 6 deletions
diff --git a/src/libc/include/sys/select.h b/src/libc/include/sys/select.h new file mode 100644 index 0000000..3c1bb90 --- /dev/null +++ b/src/libc/include/sys/select.h @@ -0,0 +1,13 @@ +#pragma once +#include <stdint.h> +#include <sys/time.h> + +typedef uint64_t fd_set; + +#define FD_SETSIZE 64 +void FD_CLR(int fd, fd_set *set); +int FD_ISSET(int fd, fd_set *set); +void FD_SET(int fd, fd_set *set); +void FD_ZERO(fd_set *set); + +int select(int nfds, fd_set *readfds, fd_set *writefds, fd_set *exceptfds, struct timeval *timeout); diff --git a/src/libc/include/sys/socket.h b/src/libc/include/sys/socket.h new file mode 100644 index 0000000..e3a4752 --- /dev/null +++ b/src/libc/include/sys/socket.h @@ -0,0 +1,38 @@ +#pragma once +#include <stdint.h> +#include <unistd.h> // ssize_t + +typedef int socklen_t; +typedef int sa_family_t; +typedef uint32_t in_addr_t; +typedef uint16_t in_port_t; + +#define AF_UNSPEC 0 +#define AF_UNIX 1 +#define AF_INET 4 +#define PF_INET 4 + +struct sockaddr { + sa_family_t sa_family; + char sa_data[]; +}; + +#define SOCK_STREAM 1 +#define SOCK_DGRAM 2 +int socket(int domain, int type, int protocol); +int bind(int sockfd, const struct sockaddr *addr, socklen_t addrlen); +int accept(int sockfd, struct sockaddr *addr, socklen_t *addrlen); +int listen(int sockfd, int backlog); + +int connect(int sockfd, const struct sockaddr *addr, socklen_t addrlen); +ssize_t send(int sockfd, const void *buf, size_t len, int flags); +ssize_t recv(int sockfd, void *buf, size_t len, int flags); + +#define SOL_SOCKET 1 +#define SO_KEEPALIVE 1 +#define SO_REUSEADDR 2 + +int getsockopt(int sockfd, int level, int optname, void *optval, socklen_t *optlen); +int setsockopt(int sockfd, int level, int optname, const void *optval, socklen_t optlen); + +int getsockname(int sockfd, struct sockaddr *addr, socklen_t *addrlen); diff --git a/src/libc/include/sys/stat.h b/src/libc/include/sys/stat.h index b9d0e8b..0d828ec 100644 --- a/src/libc/include/sys/stat.h +++ b/src/libc/include/sys/stat.h @@ -4,6 +4,7 @@ #include <sys/types.h> #include <time.h> // struct timespec #include <errno.h> // only for ENOSYS +#include <fcntl.h> // for R_OK etc. (curl) struct stat { dev_t st_dev; @@ -38,7 +39,15 @@ struct stat { #define S_ISGID 02000 #define S_ISVTX 01000 -#define S_IRUSR 0x400 +#define S_IRUSR 0400 +#define S_IWUSR 0200 +#define S_IXUSR 0100 +#define S_IRGRP 0040 +#define S_IWGRP 0020 +#define S_IXGRP 0010 +#define S_IROTH 0004 +#define S_IWOTH 0002 +#define S_IXOTH 0001 /* inode(7) */ #define S_ISREG(m) ((m & S_IFMT) == S_IFREG) diff --git a/src/libc/include/sys/time.h b/src/libc/include/sys/time.h index 54df6b3..5e00fe9 100644 --- a/src/libc/include/sys/time.h +++ b/src/libc/include/sys/time.h @@ -2,6 +2,11 @@ #include <errno.h> #include <sys/types.h> +typedef long long off_t; +typedef int64_t time_t; +typedef int64_t suseconds_t; +typedef uint64_t clock_t; + struct timeval { time_t tv_sec; suseconds_t tv_usec; diff --git a/src/libc/include/sys/types.h b/src/libc/include/sys/types.h index 2e7f54b..d637fd6 100644 --- a/src/libc/include/sys/types.h +++ b/src/libc/include/sys/types.h @@ -1,11 +1,7 @@ #pragma once #include <stddef.h> #include <stdint.h> - -typedef long long off_t; -typedef int64_t time_t; -typedef int64_t suseconds_t; -typedef uint64_t clock_t; +#include <sys/select.h> typedef int mode_t; typedef int dev_t; |