mirror of
https://github.com/jart/cosmopolitan.git
synced 2025-07-26 04:20:30 +00:00
Add epoll and do more release readiness changes
This change also pays off some of the remaining technical debt with stdio, file descriptors, and memory managemnt polyfills.
This commit is contained in:
parent
a9ea949df8
commit
3e4fd4b0ad
271 changed files with 5706 additions and 1365 deletions
|
@ -898,10 +898,11 @@ void SetupDraw(void) {
|
|||
static long Disassemble(void) {
|
||||
long lines, current;
|
||||
lines = pan.disassembly.bottom - pan.disassembly.top * 2;
|
||||
CHECK_NE(-1, Dis(dis, m, GetIp(), m->ip, lines));
|
||||
current = DisFind(dis, GetIp());
|
||||
CHECK_NE(-1, current);
|
||||
return current;
|
||||
if (Dis(dis, m, GetIp(), m->ip, lines) != -1) {
|
||||
return DisFind(dis, GetIp());
|
||||
} else {
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
static long GetDisIndex(void) {
|
||||
|
|
|
@ -1227,7 +1227,11 @@ static int OpGetPpid(struct Machine *m) {
|
|||
}
|
||||
|
||||
static int OpKill(struct Machine *m, int pid, int sig) {
|
||||
return kill(pid, sig);
|
||||
if (pid == getpid()) {
|
||||
ThrowProtectionFault(m);
|
||||
} else {
|
||||
return kill(pid, sig);
|
||||
}
|
||||
}
|
||||
|
||||
static int OpGetUid(struct Machine *m) {
|
||||
|
|
|
@ -17,6 +17,7 @@
|
|||
│ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA │
|
||||
│ 02110-1301 USA │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "ape/relocations.h"
|
||||
#include "libc/alg/arraylist2.internal.h"
|
||||
#include "libc/calls/calls.h"
|
||||
#include "libc/calls/struct/stat.h"
|
||||
|
@ -139,6 +140,9 @@ int main(int argc, char *argv[]) {
|
|||
APPENDSTR("#define IMAGE_BASE_VIRTUAL ");
|
||||
AppendInt(IMAGE_BASE_VIRTUAL);
|
||||
APPENDSTR("\n");
|
||||
APPENDSTR("#define IMAGE_BASE_PHYSICAL ");
|
||||
AppendInt(IMAGE_BASE_PHYSICAL);
|
||||
APPENDSTR("\n");
|
||||
for (i = 1; i < argc; ++i) {
|
||||
Visit(argv[i]);
|
||||
}
|
||||
|
|
1293
tool/net/greenbean.c
Normal file
1293
tool/net/greenbean.c
Normal file
File diff suppressed because it is too large
Load diff
|
@ -73,6 +73,18 @@ o/$(MODE)/tool/net/redbean.com.dbg: \
|
|||
$(APE)
|
||||
@$(APELINK)
|
||||
|
||||
o/$(MODE)/tool/net/greenbean.com.dbg: \
|
||||
$(TOOL_NET_DEPS) \
|
||||
o/$(MODE)/tool/net/greenbean.o \
|
||||
o/$(MODE)/tool/net/redbean.ico.zip.o \
|
||||
o/$(MODE)/tool/net/redbean.png.zip.o \
|
||||
o/$(MODE)/tool/net/redbean.css.zip.o \
|
||||
o/$(MODE)/tool/net/redbean.html.zip.o \
|
||||
o/$(MODE)/tool/net/net.pkg \
|
||||
$(CRT) \
|
||||
$(APE)
|
||||
@$(APELINK)
|
||||
|
||||
# ifeq (,$(MODE))
|
||||
# $(TOOL_NET_OBJS): \
|
||||
# OVERRIDE_CFLAGS += \
|
||||
|
|
|
@ -68,13 +68,12 @@
|
|||
#include "libc/time/time.h"
|
||||
#include "libc/x/x.h"
|
||||
#include "libc/zip.h"
|
||||
#include "libc/zipos/zipos.h"
|
||||
#include "libc/zipos/zipos.internal.h"
|
||||
#include "net/http/http.h"
|
||||
#include "third_party/getopt/getopt.h"
|
||||
#include "third_party/zlib/zlib.h"
|
||||
|
||||
/* TODO(jart): Implement more lenient message framing */
|
||||
/* TODO(jart): Windows IOCP fiber system call support */
|
||||
|
||||
#define USAGE \
|
||||
" [-hvdsm] [-p PORT]\n\
|
||||
|
@ -1116,7 +1115,7 @@ void ProcessRequests(void) {
|
|||
void ProcessConnection(void) {
|
||||
int pid;
|
||||
clientaddrsize = sizeof(clientaddr);
|
||||
client = accept4(server, &clientaddr, &clientaddrsize, 0 /* SOCK_CLOEXEC */);
|
||||
client = accept(server, &clientaddr, &clientaddrsize);
|
||||
if (client != -1) {
|
||||
startconnection = nowl();
|
||||
if ((pid = uniprocess ? -1 : fork()) > 0) {
|
||||
|
|
|
@ -130,24 +130,20 @@ static void DrawSphere(long double k, long double ambient) {
|
|||
int main() {
|
||||
long double ang;
|
||||
struct termios old;
|
||||
if (cancolor()) {
|
||||
WRITE("\e[?25l");
|
||||
if (!setjmp(jb_)) {
|
||||
xsigaction(SIGINT, OnCtrlC, 0, 0, NULL);
|
||||
ang = 0;
|
||||
for (;;) {
|
||||
WRITE("\e[H");
|
||||
light_[1] = cosl(ang * 2);
|
||||
sincosl(ang, &light_[0], &light_[2]);
|
||||
Normalize(light_);
|
||||
ang += .05L;
|
||||
DrawSphere(1.5L, .01L);
|
||||
usleep(1.L / FRAMERATE * 1e6);
|
||||
}
|
||||
WRITE("\e[?25l");
|
||||
if (!setjmp(jb_)) {
|
||||
xsigaction(SIGINT, OnCtrlC, 0, 0, NULL);
|
||||
ang = 0;
|
||||
for (;;) {
|
||||
WRITE("\e[H");
|
||||
light_[1] = cosl(ang * 2);
|
||||
sincosl(ang, &light_[0], &light_[2]);
|
||||
Normalize(light_);
|
||||
ang += .05L;
|
||||
DrawSphere(1.5L, .01L);
|
||||
usleep(1.L / FRAMERATE * 1e6);
|
||||
}
|
||||
WRITE("\e[0m\e[H\e[J\e[?25h");
|
||||
return 0;
|
||||
} else {
|
||||
return 1;
|
||||
}
|
||||
WRITE("\e[0m\e[H\e[J\e[?25h");
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -1387,7 +1387,7 @@ int main(int argc, char *argv[]) {
|
|||
return 1;
|
||||
}
|
||||
}
|
||||
if (IsWindows()) {
|
||||
if (0 && IsWindows()) {
|
||||
Gui();
|
||||
} else {
|
||||
Tui();
|
||||
|
|
|
@ -904,12 +904,12 @@ static int Rebuffer(FILE *f) {
|
|||
f->end = (f->end + got) & (f->size - 1);
|
||||
return got;
|
||||
} else {
|
||||
return fseteof(f);
|
||||
return __fseteof(f);
|
||||
}
|
||||
} else if (errno == EINTR || errno == EAGAIN) {
|
||||
return 0;
|
||||
} else {
|
||||
return fseterrno(f);
|
||||
return __fseterrno(f);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue