mirror of
https://github.com/RGBCube/serenity
synced 2025-07-28 10:57:36 +00:00
Libraries: Create top level directory for libraries.
Things were getting a little crowded in the project root, so this patch moves the Lib*/ directories into Libraries/.
This commit is contained in:
parent
63814ffebf
commit
04b9dc2d30
328 changed files with 36 additions and 36 deletions
24
Libraries/LibC/sys/cdefs.h
Normal file
24
Libraries/LibC/sys/cdefs.h
Normal file
|
@ -0,0 +1,24 @@
|
|||
#pragma once
|
||||
|
||||
#define _POSIX_VERSION 200809L
|
||||
|
||||
#ifndef ALWAYS_INLINE
|
||||
# define ALWAYS_INLINE inline __attribute__((always_inline))
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
# define __BEGIN_DECLS extern "C" {
|
||||
# define __END_DECLS }
|
||||
#else
|
||||
# define __BEGIN_DECLS
|
||||
# define __END_DECLS
|
||||
#endif
|
||||
|
||||
#undef __P
|
||||
#define __P(a) a
|
||||
|
||||
#define offsetof(type, member) __builtin_offsetof(type, member)
|
||||
|
||||
#ifdef __cplusplus
|
||||
//extern "C" int main(int, char**);
|
||||
#endif
|
0
Libraries/LibC/sys/file.h
Normal file
0
Libraries/LibC/sys/file.h
Normal file
15
Libraries/LibC/sys/ioctl.h
Normal file
15
Libraries/LibC/sys/ioctl.h
Normal file
|
@ -0,0 +1,15 @@
|
|||
#pragma once
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
#include <sys/ioctl_numbers.h>
|
||||
|
||||
__BEGIN_DECLS
|
||||
|
||||
struct winsize {
|
||||
unsigned short ws_row;
|
||||
unsigned short ws_col;
|
||||
};
|
||||
|
||||
int ioctl(int fd, unsigned request, ...);
|
||||
|
||||
__END_DECLS
|
14
Libraries/LibC/sys/ioctl_numbers.h
Normal file
14
Libraries/LibC/sys/ioctl_numbers.h
Normal file
|
@ -0,0 +1,14 @@
|
|||
#pragma once
|
||||
|
||||
enum IOCtlNumber {
|
||||
TIOCGPGRP,
|
||||
TIOCSPGRP,
|
||||
TCGETS,
|
||||
TCSETS,
|
||||
TCSETSW,
|
||||
TCSETSF,
|
||||
TIOCGWINSZ,
|
||||
TIOCSCTTY,
|
||||
TIOCNOTTY,
|
||||
TIOCSWINSZ,
|
||||
};
|
1
Libraries/LibC/sys/mman.h
Normal file
1
Libraries/LibC/sys/mman.h
Normal file
|
@ -0,0 +1 @@
|
|||
#include <mman.h>
|
4
Libraries/LibC/sys/param.h
Normal file
4
Libraries/LibC/sys/param.h
Normal file
|
@ -0,0 +1,4 @@
|
|||
#pragma once
|
||||
|
||||
#include <endian.h>
|
||||
#include <limits.h>
|
32
Libraries/LibC/sys/resource.h
Normal file
32
Libraries/LibC/sys/resource.h
Normal file
|
@ -0,0 +1,32 @@
|
|||
#pragma once
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
#include <sys/time.h>
|
||||
|
||||
__BEGIN_DECLS
|
||||
|
||||
struct rusage {
|
||||
struct timeval ru_utime;
|
||||
struct timeval ru_stime;
|
||||
long ru_maxrss;
|
||||
long ru_ixrss;
|
||||
long ru_idrss;
|
||||
long ru_isrss;
|
||||
long ru_minflt;
|
||||
long ru_majflt;
|
||||
long ru_nswap;
|
||||
long ru_inblock;
|
||||
long ru_oublock;
|
||||
long ru_msgsnd;
|
||||
long ru_msgrcv;
|
||||
long ru_nsignals;
|
||||
long ru_nvcsw;
|
||||
long ru_nivcsw;
|
||||
};
|
||||
|
||||
#define RUSAGE_SELF 1
|
||||
#define RUSAGE_CHILDREN 2
|
||||
|
||||
int getrusage(int who, struct rusage* usage);
|
||||
|
||||
__END_DECLS
|
14
Libraries/LibC/sys/select.cpp
Normal file
14
Libraries/LibC/sys/select.cpp
Normal file
|
@ -0,0 +1,14 @@
|
|||
#include <Kernel/Syscall.h>
|
||||
#include <errno.h>
|
||||
#include <stdio.h>
|
||||
#include <sys/select.h>
|
||||
|
||||
extern "C" {
|
||||
|
||||
int select(int nfds, fd_set* readfds, fd_set* writefds, fd_set* exceptfds, struct timeval* timeout)
|
||||
{
|
||||
Syscall::SC_select_params params { nfds, readfds, writefds, exceptfds, timeout };
|
||||
int rc = syscall(SC_select, ¶ms);
|
||||
__RETURN_WITH_ERRNO(rc, rc, -1);
|
||||
}
|
||||
}
|
12
Libraries/LibC/sys/select.h
Normal file
12
Libraries/LibC/sys/select.h
Normal file
|
@ -0,0 +1,12 @@
|
|||
#pragma once
|
||||
|
||||
#include <fd_set.h>
|
||||
#include <string.h>
|
||||
#include <sys/cdefs.h>
|
||||
#include <sys/types.h>
|
||||
|
||||
__BEGIN_DECLS
|
||||
|
||||
int select(int nfds, fd_set* readfds, fd_set* writefds, fd_set* exceptfds, struct timeval* timeout);
|
||||
|
||||
__END_DECLS
|
88
Libraries/LibC/sys/socket.cpp
Normal file
88
Libraries/LibC/sys/socket.cpp
Normal file
|
@ -0,0 +1,88 @@
|
|||
#include <AK/Assertions.h>
|
||||
#include <Kernel/Syscall.h>
|
||||
#include <errno.h>
|
||||
#include <stdio.h>
|
||||
#include <sys/socket.h>
|
||||
|
||||
extern "C" {
|
||||
|
||||
int socket(int domain, int type, int protocol)
|
||||
{
|
||||
int rc = syscall(SC_socket, domain, type, protocol);
|
||||
__RETURN_WITH_ERRNO(rc, rc, -1);
|
||||
}
|
||||
|
||||
int bind(int sockfd, const sockaddr* addr, socklen_t addrlen)
|
||||
{
|
||||
int rc = syscall(SC_bind, sockfd, addr, addrlen);
|
||||
__RETURN_WITH_ERRNO(rc, rc, -1);
|
||||
}
|
||||
|
||||
int listen(int sockfd, int backlog)
|
||||
{
|
||||
int rc = syscall(SC_listen, sockfd, backlog);
|
||||
__RETURN_WITH_ERRNO(rc, rc, -1);
|
||||
}
|
||||
|
||||
int accept(int sockfd, sockaddr* addr, socklen_t* addrlen)
|
||||
{
|
||||
int rc = syscall(SC_accept, sockfd, addr, addrlen);
|
||||
__RETURN_WITH_ERRNO(rc, rc, -1);
|
||||
}
|
||||
|
||||
int connect(int sockfd, const sockaddr* addr, socklen_t addrlen)
|
||||
{
|
||||
int rc = syscall(SC_connect, sockfd, addr, addrlen);
|
||||
__RETURN_WITH_ERRNO(rc, rc, -1);
|
||||
}
|
||||
|
||||
ssize_t sendto(int sockfd, const void* data, size_t data_length, int flags, const struct sockaddr* addr, socklen_t addr_length)
|
||||
{
|
||||
Syscall::SC_sendto_params params { sockfd, data, data_length, flags, addr, addr_length };
|
||||
int rc = syscall(SC_sendto, ¶ms);
|
||||
__RETURN_WITH_ERRNO(rc, rc, -1);
|
||||
}
|
||||
|
||||
ssize_t send(int sockfd, const void* data, size_t data_length, int flags)
|
||||
{
|
||||
return sendto(sockfd, data, data_length, flags, nullptr, 0);
|
||||
}
|
||||
|
||||
ssize_t recvfrom(int sockfd, void* buffer, size_t buffer_length, int flags, struct sockaddr* addr, socklen_t* addr_length)
|
||||
{
|
||||
Syscall::SC_recvfrom_params params { sockfd, buffer, buffer_length, flags, addr, addr_length };
|
||||
int rc = syscall(SC_recvfrom, ¶ms);
|
||||
__RETURN_WITH_ERRNO(rc, rc, -1);
|
||||
}
|
||||
|
||||
ssize_t recv(int sockfd, void* buffer, size_t buffer_length, int flags)
|
||||
{
|
||||
return recvfrom(sockfd, buffer, buffer_length, flags, nullptr, nullptr);
|
||||
}
|
||||
|
||||
int getsockopt(int sockfd, int level, int option, void* value, socklen_t* value_size)
|
||||
{
|
||||
Syscall::SC_getsockopt_params params { sockfd, level, option, value, value_size };
|
||||
int rc = syscall(SC_getsockopt, ¶ms);
|
||||
__RETURN_WITH_ERRNO(rc, rc, -1);
|
||||
}
|
||||
|
||||
int setsockopt(int sockfd, int level, int option, const void* value, socklen_t value_size)
|
||||
{
|
||||
Syscall::SC_setsockopt_params params { sockfd, level, option, value, value_size };
|
||||
int rc = syscall(SC_setsockopt, ¶ms);
|
||||
__RETURN_WITH_ERRNO(rc, rc, -1);
|
||||
}
|
||||
|
||||
int getsockname(int sockfd, struct sockaddr* addr, socklen_t* addrlen)
|
||||
{
|
||||
int rc = syscall(SC_getsockname, sockfd, addr, addrlen);
|
||||
__RETURN_WITH_ERRNO(rc, rc, -1);
|
||||
}
|
||||
|
||||
int getpeername(int sockfd, struct sockaddr* addr, socklen_t* addrlen)
|
||||
{
|
||||
int rc = syscall(SC_getpeername, sockfd, addr, addrlen);
|
||||
__RETURN_WITH_ERRNO(rc, rc, -1);
|
||||
}
|
||||
}
|
70
Libraries/LibC/sys/socket.h
Normal file
70
Libraries/LibC/sys/socket.h
Normal file
|
@ -0,0 +1,70 @@
|
|||
#pragma once
|
||||
|
||||
#include <stdint.h>
|
||||
#include <sys/cdefs.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/un.h>
|
||||
|
||||
__BEGIN_DECLS
|
||||
|
||||
#define AF_MASK 0xff
|
||||
#define AF_UNSPEC 0
|
||||
#define AF_LOCAL 1
|
||||
#define AF_UNIX AF_LOCAL
|
||||
#define AF_INET 2
|
||||
#define PF_LOCAL AF_LOCAL
|
||||
#define PF_UNIX PF_LOCAL
|
||||
#define PF_INET AF_INET
|
||||
|
||||
#define SOCK_TYPE_MASK 0xff
|
||||
#define SOCK_STREAM 1
|
||||
#define SOCK_DGRAM 2
|
||||
#define SOCK_RAW 3
|
||||
#define SOCK_NONBLOCK 04000
|
||||
#define SOCK_CLOEXEC 02000000
|
||||
|
||||
#define IPPROTO_ICMP 1
|
||||
#define IPPROTO_TCP 6
|
||||
#define IPPROTO_UDP 17
|
||||
|
||||
#define MSG_DONTWAIT 0x40
|
||||
|
||||
struct sockaddr {
|
||||
uint16_t sa_family;
|
||||
char sa_data[14];
|
||||
};
|
||||
|
||||
struct in_addr {
|
||||
uint32_t s_addr;
|
||||
};
|
||||
|
||||
struct sockaddr_in {
|
||||
uint16_t sin_family;
|
||||
uint16_t sin_port;
|
||||
struct in_addr sin_addr;
|
||||
char sin_zero[8];
|
||||
};
|
||||
|
||||
#define SOL_SOCKET 1
|
||||
#define SOMAXCONN 128
|
||||
|
||||
#define SO_RCVTIMEO 1
|
||||
#define SO_SNDTIMEO 2
|
||||
#define SO_KEEPALIVE 3
|
||||
#define SO_ERROR 4
|
||||
|
||||
int socket(int domain, int type, int protocol);
|
||||
int bind(int sockfd, const struct sockaddr* addr, socklen_t);
|
||||
int listen(int sockfd, int backlog);
|
||||
int accept(int sockfd, struct sockaddr*, socklen_t*);
|
||||
int connect(int sockfd, const struct sockaddr*, socklen_t);
|
||||
ssize_t send(int sockfd, const void*, size_t, int flags);
|
||||
ssize_t sendto(int sockfd, const void*, size_t, int flags, const struct sockaddr*, socklen_t);
|
||||
ssize_t recv(int sockfd, void*, size_t, int flags);
|
||||
ssize_t recvfrom(int sockfd, void*, size_t, int flags, struct sockaddr*, socklen_t*);
|
||||
int getsockopt(int sockfd, int level, int option, void*, socklen_t*);
|
||||
int setsockopt(int sockfd, int level, int option, const void*, socklen_t);
|
||||
int getsockname(int sockfd, struct sockaddr*, socklen_t*);
|
||||
int getpeername(int sockfd, struct sockaddr*, socklen_t*);
|
||||
|
||||
__END_DECLS
|
26
Libraries/LibC/sys/stat.h
Normal file
26
Libraries/LibC/sys/stat.h
Normal file
|
@ -0,0 +1,26 @@
|
|||
#pragma once
|
||||
|
||||
#include <fcntl.h>
|
||||
#include <sys/cdefs.h>
|
||||
#include <sys/types.h>
|
||||
|
||||
__BEGIN_DECLS
|
||||
|
||||
#define S_ISDIR(m) (((m)&S_IFMT) == S_IFDIR)
|
||||
#define S_ISCHR(m) (((m)&S_IFMT) == S_IFCHR)
|
||||
#define S_ISBLK(m) (((m)&S_IFMT) == S_IFBLK)
|
||||
#define S_ISREG(m) (((m)&S_IFMT) == S_IFREG)
|
||||
#define S_ISFIFO(m) (((m)&S_IFMT) == S_IFIFO)
|
||||
#define S_ISLNK(m) (((m)&S_IFMT) == S_IFLNK)
|
||||
#define S_ISSOCK(m) (((m)&S_IFMT) == S_IFSOCK)
|
||||
|
||||
mode_t umask(mode_t);
|
||||
int chmod(const char* pathname, mode_t);
|
||||
int fchmod(int fd, mode_t);
|
||||
int mkdir(const char* pathname, mode_t);
|
||||
|
||||
inline dev_t makedev(unsigned int major, unsigned int minor) { return (minor & 0xffu) | (major << 8u) | ((minor & ~0xffu) << 12u); }
|
||||
inline unsigned int major(dev_t dev) { return (dev & 0xfff00u) >> 8u; }
|
||||
inline unsigned int minor(dev_t dev) { return (dev & 0xffu) | ((dev >> 12u) & 0xfff00u); }
|
||||
|
||||
__END_DECLS
|
0
Libraries/LibC/sys/sysmacros.h
Normal file
0
Libraries/LibC/sys/sysmacros.h
Normal file
20
Libraries/LibC/sys/time.h
Normal file
20
Libraries/LibC/sys/time.h
Normal file
|
@ -0,0 +1,20 @@
|
|||
#pragma once
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
#include <sys/types.h>
|
||||
|
||||
__BEGIN_DECLS
|
||||
|
||||
struct timeval {
|
||||
time_t tv_sec;
|
||||
suseconds_t tv_usec;
|
||||
};
|
||||
|
||||
struct timezone {
|
||||
int tz_minuteswest;
|
||||
int tz_dsttime;
|
||||
};
|
||||
|
||||
int gettimeofday(struct timeval* __restrict__, void* __restrict__) __attribute__((nonnull(1)));
|
||||
|
||||
__END_DECLS
|
17
Libraries/LibC/sys/times.h
Normal file
17
Libraries/LibC/sys/times.h
Normal file
|
@ -0,0 +1,17 @@
|
|||
#pragma once
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
#include <sys/types.h>
|
||||
|
||||
__BEGIN_DECLS
|
||||
|
||||
struct tms {
|
||||
clock_t tms_utime;
|
||||
clock_t tms_stime;
|
||||
clock_t tms_cutime;
|
||||
clock_t tms_cstime;
|
||||
};
|
||||
|
||||
clock_t times(struct tms*);
|
||||
|
||||
__END_DECLS
|
61
Libraries/LibC/sys/types.h
Normal file
61
Libraries/LibC/sys/types.h
Normal file
|
@ -0,0 +1,61 @@
|
|||
#pragma once
|
||||
|
||||
#include <stddef.h>
|
||||
#include <stdint.h>
|
||||
#include <sys/cdefs.h>
|
||||
|
||||
__BEGIN_DECLS
|
||||
|
||||
typedef unsigned int u_int;
|
||||
typedef unsigned long u_long;
|
||||
|
||||
typedef uint32_t uid_t;
|
||||
typedef uint32_t gid_t;
|
||||
|
||||
typedef int __pid_t;
|
||||
#define pid_t __pid_t
|
||||
|
||||
typedef int __ssize_t;
|
||||
#define ssize_t __ssize_t
|
||||
|
||||
typedef __WINT_TYPE__ wint_t;
|
||||
|
||||
typedef uint32_t ino_t;
|
||||
typedef int32_t off_t;
|
||||
|
||||
typedef uint32_t dev_t;
|
||||
typedef uint16_t mode_t;
|
||||
typedef uint32_t nlink_t;
|
||||
typedef uint32_t blksize_t;
|
||||
typedef uint32_t blkcnt_t;
|
||||
typedef uint32_t time_t;
|
||||
typedef uint32_t useconds_t;
|
||||
typedef int32_t suseconds_t;
|
||||
typedef uint32_t clock_t;
|
||||
|
||||
#define __socklen_t_defined
|
||||
#define __socklen_t uint32_t
|
||||
typedef __socklen_t socklen_t;
|
||||
|
||||
struct stat {
|
||||
dev_t st_dev; /* ID of device containing file */
|
||||
ino_t st_ino; /* inode number */
|
||||
mode_t st_mode; /* protection */
|
||||
nlink_t st_nlink; /* number of hard links */
|
||||
uid_t st_uid; /* user ID of owner */
|
||||
gid_t st_gid; /* group ID of owner */
|
||||
dev_t st_rdev; /* device ID (if special file) */
|
||||
off_t st_size; /* total size, in bytes */
|
||||
blksize_t st_blksize; /* blocksize for file system I/O */
|
||||
blkcnt_t st_blocks; /* number of 512B blocks allocated */
|
||||
time_t st_atime; /* time of last access */
|
||||
time_t st_mtime; /* time of last modification */
|
||||
time_t st_ctime; /* time of last status change */
|
||||
};
|
||||
|
||||
struct utimbuf {
|
||||
time_t actime;
|
||||
time_t modtime;
|
||||
};
|
||||
|
||||
__END_DECLS
|
12
Libraries/LibC/sys/uio.cpp
Normal file
12
Libraries/LibC/sys/uio.cpp
Normal file
|
@ -0,0 +1,12 @@
|
|||
#include <Kernel/Syscall.h>
|
||||
#include <errno.h>
|
||||
#include <sys/uio.h>
|
||||
|
||||
extern "C" {
|
||||
|
||||
ssize_t writev(int fd, const struct iovec* iov, int iov_count)
|
||||
{
|
||||
int rc = syscall(SC_writev, fd, iov, iov_count);
|
||||
__RETURN_WITH_ERRNO(rc, rc, -1);
|
||||
}
|
||||
}
|
15
Libraries/LibC/sys/uio.h
Normal file
15
Libraries/LibC/sys/uio.h
Normal file
|
@ -0,0 +1,15 @@
|
|||
#pragma once
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
#include <sys/types.h>
|
||||
|
||||
__BEGIN_DECLS
|
||||
|
||||
struct iovec {
|
||||
void* iov_base;
|
||||
size_t iov_len;
|
||||
};
|
||||
|
||||
ssize_t writev(int fd, const struct iovec*, int iov_count);
|
||||
|
||||
__END_DECLS
|
13
Libraries/LibC/sys/un.h
Normal file
13
Libraries/LibC/sys/un.h
Normal file
|
@ -0,0 +1,13 @@
|
|||
#pragma once
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
|
||||
__BEGIN_DECLS
|
||||
|
||||
#define UNIX_PATH_MAX 108
|
||||
struct sockaddr_un {
|
||||
uint16_t sun_family;
|
||||
char sun_path[UNIX_PATH_MAX];
|
||||
};
|
||||
|
||||
__END_DECLS
|
19
Libraries/LibC/sys/utsname.h
Normal file
19
Libraries/LibC/sys/utsname.h
Normal file
|
@ -0,0 +1,19 @@
|
|||
#pragma once
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
|
||||
#define UTSNAME_ENTRY_LEN 65
|
||||
|
||||
__BEGIN_DECLS
|
||||
|
||||
struct utsname {
|
||||
char sysname[UTSNAME_ENTRY_LEN];
|
||||
char nodename[UTSNAME_ENTRY_LEN];
|
||||
char release[UTSNAME_ENTRY_LEN];
|
||||
char version[UTSNAME_ENTRY_LEN];
|
||||
char machine[UTSNAME_ENTRY_LEN];
|
||||
};
|
||||
|
||||
int uname(struct utsname*);
|
||||
|
||||
__END_DECLS
|
11
Libraries/LibC/sys/wait.cpp
Normal file
11
Libraries/LibC/sys/wait.cpp
Normal file
|
@ -0,0 +1,11 @@
|
|||
#include <assert.h>
|
||||
#include <sys/wait.h>
|
||||
#include <unistd.h>
|
||||
|
||||
extern "C" {
|
||||
|
||||
pid_t wait(int* wstatus)
|
||||
{
|
||||
return waitpid(-1, wstatus, 0);
|
||||
}
|
||||
}
|
21
Libraries/LibC/sys/wait.h
Normal file
21
Libraries/LibC/sys/wait.h
Normal file
|
@ -0,0 +1,21 @@
|
|||
#pragma once
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
#include <sys/types.h>
|
||||
|
||||
__BEGIN_DECLS
|
||||
|
||||
#define WEXITSTATUS(status) (((status)&0xff00) >> 8)
|
||||
#define WTERMSIG(status) ((status)&0x7f)
|
||||
#define WIFEXITED(status) (WTERMSIG(status) == 0)
|
||||
#define WIFSIGNALED(status) (((char)(((status)&0x7f) + 1) >> 1) > 0)
|
||||
|
||||
#define WNOHANG 1
|
||||
#define WUNTRACED 2
|
||||
#define WSTOPPED WUNTRACED
|
||||
#define WEXITED 4
|
||||
#define WCONTINUED 8
|
||||
|
||||
pid_t wait(int* wstatus);
|
||||
|
||||
__END_DECLS
|
Loading…
Add table
Add a link
Reference in a new issue