mirror of
https://github.com/jart/cosmopolitan.git
synced 2025-06-27 23:08:31 +00:00
Make improvements
- Emulator can now test the αcτµαlly pδrταblε εxεcµταblε bootloader - Whipped up a webserver named redbean. It services 150k requests per second on a single core. Bundling assets inside zip enables extremely fast serving for two reasons. The first is that zip central directory lookups go faster than stat() system calls. The second is that both zip and gzip content-encoding use DEFLATE, therefore, compressed responses can be served via the sendfile() system call which does an in-kernel copy directly from the zip executable structure. Also note that red bean zip executables can be deployed easily to all platforms, since these native executables work on Linux, Mac, BSD, and Windows. - Address sanitizer now works very well
This commit is contained in:
parent
7327c345f9
commit
416fd86676
230 changed files with 9835 additions and 5682 deletions
|
@ -34,6 +34,8 @@
|
|||
* @return client fd which needs close(), or -1 w/ errno
|
||||
*/
|
||||
int accept4(int fd, void *out_addr, uint32_t *inout_addrsize, int flags) {
|
||||
if (!out_addr) return efault();
|
||||
if (!inout_addrsize) return efault();
|
||||
if (!IsWindows()) {
|
||||
return accept4$sysv(fd, out_addr, inout_addrsize, flags);
|
||||
} else if (isfdkind(fd, kFdSocket)) {
|
||||
|
|
|
@ -35,6 +35,7 @@
|
|||
* @asyncsignalsafe
|
||||
*/
|
||||
int bind(int fd, const void *addr, uint32_t addrsize) {
|
||||
if (!addr) return efault();
|
||||
if (addrsize == sizeof(struct sockaddr_in)) {
|
||||
if (!IsWindows()) {
|
||||
if (!IsBsd()) {
|
||||
|
|
|
@ -34,6 +34,7 @@
|
|||
* @asyncsignalsafe
|
||||
*/
|
||||
int connect(int fd, const void *addr, uint32_t addrsize) {
|
||||
if (!addr) return efault();
|
||||
if (!IsWindows()) {
|
||||
return connect$sysv(fd, addr, addrsize);
|
||||
} else if (isfdkind(fd, kFdSocket)) {
|
||||
|
|
|
@ -108,7 +108,7 @@ int socket$nt(int, int, int) hidden;
|
|||
size_t iovec2nt(struct iovec$nt[hasatleast 16], const struct iovec *,
|
||||
size_t) hidden;
|
||||
ssize_t sendto$nt(struct Fd *, const struct iovec *, size_t, uint32_t, void *,
|
||||
uint32_t *) hidden;
|
||||
uint32_t) hidden;
|
||||
ssize_t recvfrom$nt(struct Fd *, const struct iovec *, size_t, uint32_t, void *,
|
||||
uint32_t *) hidden;
|
||||
|
||||
|
|
|
@ -18,8 +18,11 @@
|
|||
│ 02110-1301 USA │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/assert.h"
|
||||
#include "libc/calls/calls.h"
|
||||
#include "libc/calls/internal.h"
|
||||
#include "libc/nt/winsock.h"
|
||||
#include "libc/sock/internal.h"
|
||||
#include "libc/sysv/consts/fileno.h"
|
||||
|
||||
/**
|
||||
* Performs send(), sendto(), or writev() on Windows NT.
|
||||
|
@ -29,11 +32,11 @@
|
|||
*/
|
||||
textwindows ssize_t sendto$nt(struct Fd *fd, const struct iovec *iov,
|
||||
size_t iovlen, uint32_t flags, void *opt_in_addr,
|
||||
uint32_t *in_addrsize) {
|
||||
uint32_t in_addrsize) {
|
||||
uint32_t sent;
|
||||
struct iovec$nt iovnt[16];
|
||||
if (WSASendTo(fd->handle, iovnt, iovec2nt(iovnt, iov, iovlen), &sent, flags,
|
||||
opt_in_addr, *in_addrsize, NULL, NULL) != -1) {
|
||||
opt_in_addr, in_addrsize, NULL, NULL) != -1) {
|
||||
return sent;
|
||||
} else {
|
||||
return winsockerr();
|
||||
|
|
|
@ -60,7 +60,7 @@ ssize_t sendto(int fd, const void *buf, size_t size, uint32_t flags,
|
|||
}
|
||||
} else if (isfdkind(fd, kFdSocket)) {
|
||||
return sendto$nt(&g_fds.p[fd], (struct iovec[]){{buf, size}}, 1, flags,
|
||||
opt_addr, &addrsize);
|
||||
opt_addr, addrsize);
|
||||
} else {
|
||||
return ebadf();
|
||||
}
|
||||
|
|
|
@ -51,7 +51,7 @@ static textwindows int setsockopt$nt(struct Fd *fd, int level, int optname,
|
|||
* int yes = 1;
|
||||
* setsockopt(fd, SOL_SOCKET, SO_REUSEPORT, &yes, sizeof(yes));
|
||||
*
|
||||
* @param level can be SOL_SOCKET, IPPROTO_TCP, etc.
|
||||
* @param level can be SOL_SOCKET, SOL_IP, SOL_TCP, etc.
|
||||
* @param optname can be SO_{REUSE{PORT,ADDR},KEEPALIVE,etc.} etc.
|
||||
* @return 0 on success, or -1 w/ errno
|
||||
* @error ENOPROTOOPT for unknown (level,optname)
|
||||
|
@ -60,6 +60,7 @@ static textwindows int setsockopt$nt(struct Fd *fd, int level, int optname,
|
|||
*/
|
||||
int setsockopt(int fd, int level, int optname, const void *optval,
|
||||
uint32_t optlen) {
|
||||
if (!optval) return efault();
|
||||
if (!level || !optname) return enoprotoopt(); /* our sysvconsts definition */
|
||||
if (optname == -1) return 0; /* our sysvconsts definition */
|
||||
if (!IsWindows()) {
|
||||
|
|
|
@ -61,10 +61,10 @@ int inet_pton(int af, const char *, void *);
|
|||
int parseport(const char *);
|
||||
|
||||
int socket(int, int, int) nodiscard;
|
||||
int accept(int, void *, uint32_t *) paramsnonnull() nodiscard;
|
||||
int accept4(int, void *, uint32_t *, int) paramsnonnull() nodiscard;
|
||||
int bind(int, const void *, uint32_t) paramsnonnull();
|
||||
int connect(int, const void *, uint32_t) paramsnonnull();
|
||||
int accept(int, void *, uint32_t *) nodiscard;
|
||||
int accept4(int, void *, uint32_t *, int) nodiscard;
|
||||
int bind(int, const void *, uint32_t);
|
||||
int connect(int, const void *, uint32_t);
|
||||
int socketconnect(const struct addrinfo *, int);
|
||||
int listen(int, int);
|
||||
int shutdown(int, int);
|
||||
|
@ -79,7 +79,7 @@ ssize_t readv(int, const struct iovec *, int);
|
|||
ssize_t writev(int, const struct iovec *, int);
|
||||
ssize_t sendfile(int, int, int64_t *, size_t);
|
||||
int getsockopt(int, int, int, void *, uint32_t *) paramsnonnull((5));
|
||||
int setsockopt(int, int, int, const void *, uint32_t) paramsnonnull();
|
||||
int setsockopt(int, int, int, const void *, uint32_t);
|
||||
int socketpair(int, int, int, int64_t[2]) paramsnonnull();
|
||||
int poll(struct pollfd *, uint64_t, int32_t) paramsnonnull();
|
||||
int ppoll(struct pollfd *, uint64_t, const struct timespec *,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue