mirror of
https://github.com/jart/cosmopolitan.git
synced 2025-07-18 00:20:30 +00:00
Get Cosmopolitan into releasable state
A new rollup tool now exists for flattening out the headers in a way that works better for our purposes than cpp. A lot of the API clutter has been removed. APIs that aren't a sure thing in terms of general recommendation are now marked internal. There's now a smoke test for the amalgamation archive and gigantic header file. So we can now guarantee you can use this project on the easiest difficulty setting without the gigantic repository. A website is being created, which is currently a work in progress: https://justine.storage.googleapis.com/cosmopolitan/index.html
This commit is contained in:
parent
dba7552c1e
commit
ea0b5d9d1c
775 changed files with 6864 additions and 3963 deletions
|
@ -17,7 +17,7 @@
|
|||
│ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA │
|
||||
│ 02110-1301 USA │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/bits/safemacros.h"
|
||||
#include "libc/bits/safemacros.internal.h"
|
||||
#include "libc/calls/internal.h"
|
||||
#include "libc/nt/winsock.h"
|
||||
#include "libc/sock/internal.h"
|
||||
|
|
|
@ -1,22 +1,3 @@
|
|||
/*-*- mode:c;indent-tabs-mode:nil;c-basic-offset:2;tab-width:8;coding:utf-8 -*-│
|
||||
│vi: set net ft=c ts=8 sts=2 sw=2 fenc=utf-8 :vi│
|
||||
╞══════════════════════════════════════════════════════════════════════════════╡
|
||||
│ Copyright 2020 Justine Alexandra Roberts Tunney │
|
||||
│ │
|
||||
│ This program is free software; you can redistribute it and/or modify │
|
||||
│ it under the terms of the GNU General Public License as published by │
|
||||
│ the Free Software Foundation; version 2 of the License. │
|
||||
│ │
|
||||
│ This program is distributed in the hope that it will be useful, but │
|
||||
│ WITHOUT ANY WARRANTY; without even the implied warranty of │
|
||||
│ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU │
|
||||
│ General Public License for more details. │
|
||||
│ │
|
||||
│ You should have received a copy of the GNU General Public License │
|
||||
│ along with this program; if not, write to the Free Software │
|
||||
│ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA │
|
||||
│ 02110-1301 USA │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#ifndef COSMOPOLITAN_LIBC_SOCK_INTERNAL_H_
|
||||
#define COSMOPOLITAN_LIBC_SOCK_INTERNAL_H_
|
||||
#ifndef __STRICT_ANSI__
|
||||
|
@ -74,7 +55,6 @@ int32_t __socket$sysv(int32_t, int32_t, int32_t) hidden;
|
|||
int32_t __getsockname$sysv(int32_t, void *, uint32_t *) hidden;
|
||||
int32_t __getpeername$sysv(int32_t, void *, uint32_t *) hidden;
|
||||
|
||||
int32_t select$sysv(int32_t, fd_set *, fd_set *, fd_set *, struct timeval *);
|
||||
int32_t setsockopt$sysv(int32_t, int32_t, int32_t, const void *,
|
||||
uint32_t) hidden;
|
||||
int32_t accept4$sysv(int32_t, void *, uint32_t *, int) nodiscard hidden;
|
||||
|
|
|
@ -18,9 +18,12 @@
|
|||
│ 02110-1301 USA │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/calls/struct/timeval.h"
|
||||
#include "libc/sock/internal.h"
|
||||
#include "libc/sock/select.internal.h"
|
||||
#include "libc/sock/sock.h"
|
||||
|
||||
/**
|
||||
* Does what poll() does except with a complicated bitset API.
|
||||
*/
|
||||
int select(int nfds, fd_set *readfds, fd_set *writefds, fd_set *exceptfds,
|
||||
struct timeval *timeout) {
|
||||
/* TODO(jart): Windows */
|
||||
|
|
24
libc/sock/select.h
Normal file
24
libc/sock/select.h
Normal file
|
@ -0,0 +1,24 @@
|
|||
#ifndef COSMOPOLITAN_LIBC_SOCK_SELECT_H_
|
||||
#define COSMOPOLITAN_LIBC_SOCK_SELECT_H_
|
||||
#include "libc/calls/struct/timeval.h"
|
||||
#include "libc/str/str.h"
|
||||
|
||||
#define FD_SETSIZE 1024 /* it's 64 on windows */
|
||||
|
||||
#if !(__ASSEMBLER__ + __LINKER__ + 0)
|
||||
COSMOPOLITAN_C_START_
|
||||
|
||||
typedef struct fd_set {
|
||||
uint64_t fds_bits[FD_SETSIZE / 64];
|
||||
} fd_set;
|
||||
|
||||
#define FD_ISSET(FD, SET) (((SET)->fds_bits[(FD) >> 6] >> ((FD)&63)) & 1)
|
||||
#define FD_SET(FD, SET) ((SET)->fds_bits[(FD) >> 6] |= 1ull << ((FD)&63))
|
||||
#define FD_CLR(FD, SET) ((SET)->fds_bits[(FD) >> 6] &= ~(1ull << ((FD)&63)))
|
||||
#define FD_ZERO(SET) memset((SET)->fds_bits, 0, sizeof((SET)->fds_bits))
|
||||
|
||||
int select(int, fd_set *, fd_set *, fd_set *, struct timeval *);
|
||||
|
||||
COSMOPOLITAN_C_END_
|
||||
#endif /* !(__ASSEMBLER__ + __LINKER__ + 0) */
|
||||
#endif /* COSMOPOLITAN_LIBC_SOCK_SELECT_H_ */
|
11
libc/sock/select.internal.h
Normal file
11
libc/sock/select.internal.h
Normal file
|
@ -0,0 +1,11 @@
|
|||
#ifndef COSMOPOLITAN_LIBC_SOCK_SELECT_INTERNAL_H_
|
||||
#define COSMOPOLITAN_LIBC_SOCK_SELECT_INTERNAL_H_
|
||||
#include "libc/sock/select.h"
|
||||
#if !(__ASSEMBLER__ + __LINKER__ + 0)
|
||||
COSMOPOLITAN_C_START_
|
||||
|
||||
int32_t select$sysv(int32_t, fd_set *, fd_set *, fd_set *, struct timeval *);
|
||||
|
||||
COSMOPOLITAN_C_END_
|
||||
#endif /* !(__ASSEMBLER__ + __LINKER__ + 0) */
|
||||
#endif /* COSMOPOLITAN_LIBC_SOCK_SELECT_INTERNAL_H_ */
|
|
@ -17,7 +17,7 @@
|
|||
│ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA │
|
||||
│ 02110-1301 USA │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/bits/safemacros.h"
|
||||
#include "libc/bits/safemacros.internal.h"
|
||||
#include "libc/calls/calls.h"
|
||||
#include "libc/calls/internal.h"
|
||||
#include "libc/dce.h"
|
||||
|
|
|
@ -87,13 +87,6 @@ int ppoll(struct pollfd *, uint64_t, const struct timespec *,
|
|||
ssize_t sendto(int, const void *, size_t, uint32_t, const void *, uint32_t)
|
||||
paramsnonnull((2));
|
||||
|
||||
typedef int64_t fd_set;
|
||||
#define FD_CLR(FD, SET) btr(SET, FD)
|
||||
#define FD_ISSET(FD, SET) bt(SET, FD)
|
||||
#define FD_SET(FD, SET) bts(SET, FD)
|
||||
#define FD_ZERO(SET) *(SET) = 0
|
||||
int select(int, fd_set *, fd_set *, fd_set *, struct timeval *);
|
||||
|
||||
COSMOPOLITAN_C_END_
|
||||
#endif /* !(__ASSEMBLER__ + __LINKER__ + 0) */
|
||||
#endif /* COSMOPOLITAN_LIBC_SOCK_SOCK_H_ */
|
||||
|
|
|
@ -35,7 +35,7 @@ char *xinet_ntop(int af, const void *src) {
|
|||
if (inet_ntop(af, src, ip, sizeof(ip)) && (res = strdup(ip))) {
|
||||
return res;
|
||||
} else {
|
||||
if (weaken(die)) weaken(die)();
|
||||
if (weaken(__die)) weaken(__die)();
|
||||
abort();
|
||||
unreachable;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue