Get fork() working on Windows

This is done without using Microsoft's internal APIs. MAP_PRIVATE
mappings are copied to the subprocess via a pipe, since Microsoft
doesn't want us to have proper COW pages. MAP_SHARED mappings are
remapped without needing to do any copying. Global variables need
copying along with the stack and the whole heap of anonymous mem.
This actually improves the reliability of the redbean http server
although one shouldn't expect 10k+ connections on a home computer
that isn't running software built to serve like Linux or FreeBSD.
This commit is contained in:
Justine Tunney 2020-11-13 01:27:49 -08:00
parent aea89fe832
commit db33973e0a
105 changed files with 1476 additions and 912 deletions

View file

@ -1,5 +1,8 @@
#ifndef COSMOPOLITAN_LIBC_NT_PAINT_H_
#define COSMOPOLITAN_LIBC_NT_PAINT_H_
#include "libc/nt/struct/drawtextparams.h"
#include "libc/nt/struct/paintstruct.h"
#include "libc/nt/struct/rect.h"
#if !(__ASSEMBLER__ + __LINKER__ + 0)
COSMOPOLITAN_C_START_
#if 0
@ -8,50 +11,22 @@ COSMOPOLITAN_C_START_
*/
#endif
struct NtSize {
int32_t cx;
int32_t cy;
};
struct NtRectangle {
int32_t left;
int32_t top;
int32_t right;
int32_t bottom;
};
struct NtDrawTextParams {
uint32_t cbSize;
int32_t iTabLength;
int32_t iLeftMargin;
int32_t iRightMargin;
uint32_t uiLengthDrawn;
};
struct NtPaintStruct {
int64_t hdc;
int32_t fErase;
struct NtRectangle rcPaint;
int32_t fRestore;
int32_t fIncUpdate;
unsigned char rgbReserved[32];
};
int64_t BeginPaint(int64_t hWnd, struct NtPaintStruct *lpPaint);
int32_t EndPaint(int64_t hWnd, const struct NtPaintStruct *lpPaint);
int32_t BitBlt(int64_t hdc, int x, int y, int cx, int cy, int64_t hdcSrc,
int x1, int y1, uint32_t rop);
int32_t GetClientRect(int64_t hWnd, struct NtRectangle *lpRect);
int32_t GetWindowRect(int64_t hWnd, struct NtRectangle *lpRect);
int32_t GetClientRect(int64_t hWnd, struct NtRect *lpRect);
int32_t GetWindowRect(int64_t hWnd, struct NtRect *lpRect);
int32_t SetBkMode(int64_t hdc, int mode);
uint32_t SetTextColor(int64_t hdc, uint32_t color);
uint32_t SetTextAlign(int64_t hdc, uint32_t align);
int32_t SetTextJustification(int64_t hdc, int extra, int count);
int32_t DrawText(int64_t hdc, const char16_t *lpchText, int cchText,
struct NtRectangle *lprc, uint32_t format);
struct NtRect *lprc, uint32_t format);
int32_t DrawTextEx(int64_t hdc, char16_t *lpchText, int cchText,
struct NtRectangle *lprc, uint32_t format,
struct NtRect *lprc, uint32_t format,
struct NtDrawTextParams *lpdtp);
int32_t FillRect(int64_t hDC, const struct NtRect *lpRC, int64_t hBrush);
COSMOPOLITAN_C_END_
#endif /* !(__ASSEMBLER__ + __LINKER__ + 0) */