From 4edbc9881114955ee3798a950042899d08565a74 Mon Sep 17 00:00:00 2001 From: Justine Tunney Date: Thu, 11 May 2023 21:53:15 -0700 Subject: [PATCH] Get MbedTLS and its unit tests passing AARCH64 --- ape/ape.lds | 11 +++- libc/crt/crt.S | 25 +++++++- libc/runtime/stack.h | 3 +- libc/runtime/stackuse.c | 1 - libc/testlib/showerror.c | 15 +++++ libc/testlib/testlib.h | 16 +++-- libc/x/x.mk | 12 +--- net/http/http.mk | 8 +-- net/http/kescapeauthority.S | 83 ------------------------ net/http/kescapeauthority.c | 60 ++++++++++++++++++ net/http/kescapefragment.S | 79 ----------------------- net/http/kescapefragment.c | 60 ++++++++++++++++++ net/http/kescapeip.S | 78 ----------------------- net/http/kescapeip.c | 60 ++++++++++++++++++ net/http/kescapeparam.S | 75 ---------------------- net/http/kescapeparam.c | 60 ++++++++++++++++++ net/http/kescapepath.S | 79 ----------------------- net/http/kescapepath.c | 60 ++++++++++++++++++ net/http/kescapesegment.S | 78 ----------------------- net/http/kescapesegment.c | 60 ++++++++++++++++++ net/http/khostchars.S | 70 --------------------- net/http/khostchars.c | 60 ++++++++++++++++++ net/http/khttptoken.S | 90 --------------------------- net/http/khttptoken.c | 72 +++++++++++++++++++++ third_party/mbedtls/aesni.c | 2 +- third_party/mbedtls/bigmul.c | 7 ++- third_party/mbedtls/config.h | 2 +- third_party/mbedtls/des.c | 25 +++++--- third_party/mbedtls/ecp384.c | 15 ++++- third_party/mbedtls/karatsuba.c | 22 ++++++- third_party/mbedtls/mbedtls.mk | 6 +- third_party/mbedtls/shiftright-avx.c | 4 ++ third_party/mbedtls/test/lib.h | 1 - third_party/mbedtls/test/test.mk | 4 +- third_party/python/Include/ceval.h | 20 +++--- tool/emacs/cosmo-stuff.el | 6 +- tool/viz/lib/thunks/expect_matrixeq.S | 28 --------- 37 files changed, 632 insertions(+), 725 deletions(-) delete mode 100644 net/http/kescapeauthority.S create mode 100644 net/http/kescapeauthority.c delete mode 100644 net/http/kescapefragment.S create mode 100644 net/http/kescapefragment.c delete mode 100644 net/http/kescapeip.S create mode 100644 net/http/kescapeip.c delete mode 100644 net/http/kescapeparam.S create mode 100644 net/http/kescapeparam.c delete mode 100644 net/http/kescapepath.S create mode 100644 net/http/kescapepath.c delete mode 100644 net/http/kescapesegment.S create mode 100644 net/http/kescapesegment.c delete mode 100644 net/http/khostchars.S create mode 100644 net/http/khostchars.c delete mode 100644 net/http/khttptoken.S create mode 100644 net/http/khttptoken.c delete mode 100644 tool/viz/lib/thunks/expect_matrixeq.S diff --git a/ape/ape.lds b/ape/ape.lds index 58201ead2..4dd32948e 100644 --- a/ape/ape.lds +++ b/ape/ape.lds @@ -184,12 +184,21 @@ #include "ape/ape.internal.h" #include "libc/zip.h" +/* uncomment if .com.dbg won't execute on your kernel (will break .com file) */ +/* #define APE_FIX_COM_DBG */ + #ifdef __x86__ #define CODE_GRANULE 1 #else #define CODE_GRANULE 4 #endif +#ifdef APE_FIX_COM_DBG +#define SKEW SIZEOF_HEADERS +#else +#define SKEW 0 +#endif + ENTRY(_start) PHDRS { @@ -208,7 +217,7 @@ SECTIONS { /*BEGIN: linux addressability guarantee */ /*BEGIN: bsd addressability guarantee */ - .head SEGMENT_START("text-segment", IMAGE_BASE_VIRTUAL) : AT(IMAGE_BASE_REAL) { + .head SEGMENT_START("text-segment", IMAGE_BASE_VIRTUAL) + SKEW : AT(IMAGE_BASE_REAL) { HIDDEN(_base = .); /* Real Mode */ diff --git a/libc/crt/crt.S b/libc/crt/crt.S index 949dbc267..595a37491 100644 --- a/libc/crt/crt.S +++ b/libc/crt/crt.S @@ -68,7 +68,13 @@ _start: lea 8(%rsp),%rsi // argv lea 16(%rsp,%rbx,8),%rdx // envp mov %rsp,__oldstack(%rip) - and $-16,%rsp + +// setup a stack frame +// align stack to GetStackSize() so GetStackAddr() is fast + .weak ape_stack_memsz + mov $ape_stack_memsz,%r8d + neg %r8 + and %r8,%rsp xor %ebp,%ebp // bofram 9f @@ -107,10 +113,23 @@ _start: //////////////////////////////////////////////////////////////////////////////// #elif defined(__aarch64__) +// save original stack pointer +// this is the first argument to cosmo() below + mov x0,sp + +// setup stack frame mov x29,#0 mov x30,#0 - mov x0,sp - and sp,x0,#-16 + +// align stack to GetStackSize() so GetStackAddr() is fast + mov x1,sp + .weak ape_stack_memsz + ldr x2,=ape_stack_memsz + neg x2,x2 + and x1,x2,x1 + mov sp,x1 + +// switch to c start function b cosmo //////////////////////////////////////////////////////////////////////////////// diff --git a/libc/runtime/stack.h b/libc/runtime/stack.h index 8381f3373..2293c0443 100644 --- a/libc/runtime/stack.h +++ b/libc/runtime/stack.h @@ -125,8 +125,7 @@ extern char ape_stack_align[] __attribute__((__weak__)); * Returns true if at least `n` bytes of stack are available. */ #define HaveStackMemory(n) \ - (IsTiny() || \ - (intptr_t)__builtin_frame_address(0) >= GetStackAddr() + GUARDSIZE + (n)) + ((intptr_t)__builtin_frame_address(0) >= GetStackAddr() + GUARDSIZE + (n)) forceinline void CheckLargeStackAllocation(void *p, ssize_t n) { for (; n > 0; n -= 4096) { diff --git a/libc/runtime/stackuse.c b/libc/runtime/stackuse.c index 651d081d4..2fa51f097 100644 --- a/libc/runtime/stackuse.c +++ b/libc/runtime/stackuse.c @@ -79,7 +79,6 @@ static textexit void LogStackUse(void) { } static textstartup void LogStackUseInit(void) { - if (IsTiny()) return; if (!PLEDGED(WPATH)) return; if (isdirectory("o/" MODE) && getcwd(stacklog, sizeof(stacklog) - strlen("/o/" MODE "/stack.log"))) { diff --git a/libc/testlib/showerror.c b/libc/testlib/showerror.c index 167df6357..45c65e42e 100644 --- a/libc/testlib/showerror.c +++ b/libc/testlib/showerror.c @@ -218,3 +218,18 @@ void testlib_showerror_expect_false(int line, // testlib_showerror_(line, wantcode, gotcode, FREED_want, FREED_got, fmt, va); va_end(va); } + +void testlib_showerror_expect_matrixeq(int line, // + const char *wantcode, // + const char *gotcode, // + char *FREED_want, // + char *FREED_got, // + const char *fmt, // + ...) { + va_list va; + testlib_showerror_macro = "EXPECT_MATRIXEQ"; + testlib_showerror_symbol = "="; + va_start(va, fmt); + testlib_showerror_(line, wantcode, gotcode, FREED_want, FREED_got, fmt, va); + va_end(va); +} diff --git a/libc/testlib/testlib.h b/libc/testlib/testlib.h index 420ce9163..c474340da 100644 --- a/libc/testlib/testlib.h +++ b/libc/testlib/testlib.h @@ -62,11 +62,19 @@ COSMOPOLITAN_C_START_ #define EXPECT_LE(C, X) _TEST2("EXPECT_LE", C, <=, (X), #C, " ≤ ", #X, 0) #define EXPECT_LT(C, X) _TEST2("EXPECT_LT", C, <, (X), #C, " < ", #X, 0) -#define __TEST_ARRAY(S) \ - _Section(".piro.relo.sort.testcase.2." #S ",\"aw\",@init_array #") +#ifdef __aarch64__ +#define _TESTLIB_ASM_COMMENT "//" +#else +#define _TESTLIB_ASM_COMMENT "#" +#endif -#define __BENCH_ARRAY(S) \ - _Section(".piro.relo.sort.bench.2." #S ",\"aw\",@init_array #") +#define __TEST_ARRAY(S) \ + _Section(".piro.relo.sort.testcase.2." #S \ + ",\"aw\",@init_array "_TESTLIB_ASM_COMMENT) + +#define __BENCH_ARRAY(S) \ + _Section(".piro.relo.sort.bench.2." #S \ + ",\"aw\",@init_array "_TESTLIB_ASM_COMMENT) #define __TEST_PROTOTYPE(S, N, A, K) \ void S##_##N(void); \ diff --git a/libc/x/x.mk b/libc/x/x.mk index aba8bbb96..e05fc18fb 100644 --- a/libc/x/x.mk +++ b/libc/x/x.mk @@ -17,16 +17,8 @@ LIBC_X = $(LIBC_X_A_DEPS) $(LIBC_X_A) LIBC_X_A = o/$(MODE)/libc/x/x.a LIBC_X_A_FILES := $(wildcard libc/x/*) LIBC_X_A_HDRS = $(filter %.h,$(LIBC_X_A_FILES)) -LIBC_X_A_SRCS_S = $(filter %.S,$(LIBC_X_A_FILES)) -LIBC_X_A_SRCS_C = $(filter %.c,$(LIBC_X_A_FILES)) - -LIBC_X_A_SRCS = \ - $(LIBC_X_A_SRCS_S) \ - $(LIBC_X_A_SRCS_C) - -LIBC_X_A_OBJS = \ - $(LIBC_X_A_SRCS_S:%.S=o/$(MODE)/%.o) \ - $(LIBC_X_A_SRCS_C:%.c=o/$(MODE)/%.o) +LIBC_X_A_SRCS = $(filter %.c,$(LIBC_X_A_FILES)) +LIBC_X_A_OBJS = $(LIBC_X_A_SRCS:%.c=o/$(MODE)/%.o) LIBC_X_A_CHECKS = \ $(LIBC_X_A).pkg \ diff --git a/net/http/http.mk b/net/http/http.mk index fbe09425c..55c917f96 100644 --- a/net/http/http.mk +++ b/net/http/http.mk @@ -9,12 +9,8 @@ NET_HTTP_A = o/$(MODE)/net/http/http.a NET_HTTP_A_FILES := $(wildcard net/http/*) NET_HTTP_A_HDRS = $(filter %.h,$(NET_HTTP_A_FILES)) NET_HTTP_A_INCS = $(filter %.inc,$(NET_HTTP_A_FILES)) -NET_HTTP_A_SRCS_C = $(filter %.c,$(NET_HTTP_A_FILES)) -NET_HTTP_A_SRCS_S = $(filter %.S,$(NET_HTTP_A_FILES)) -NET_HTTP_A_SRCS = $(NET_HTTP_A_SRCS_S) $(NET_HTTP_A_SRCS_C) -NET_HTTP_A_OBJS_C = $(NET_HTTP_A_SRCS_C:%.c=o/$(MODE)/%.o) -NET_HTTP_A_OBJS_S = $(NET_HTTP_A_SRCS_S:%.S=o/$(MODE)/%.o) -NET_HTTP_A_OBJS = $(NET_HTTP_A_OBJS_S) $(NET_HTTP_A_OBJS_C) +NET_HTTP_A_SRCS = $(filter %.c,$(NET_HTTP_A_FILES)) +NET_HTTP_A_OBJS = $(NET_HTTP_A_SRCS:%.c=o/$(MODE)/%.o) NET_HTTP_A_CHECKS = \ $(NET_HTTP_A).pkg \ diff --git a/net/http/kescapeauthority.S b/net/http/kescapeauthority.S deleted file mode 100644 index 65187b29d..000000000 --- a/net/http/kescapeauthority.S +++ /dev/null @@ -1,83 +0,0 @@ -#include "libc/macros.internal.h" - -// generated by: -// o//tool/build/xlat.com -DUL '_.!~*'"'"'();&=+$,-' -iskEscapeAuthority -// -// present absent -// ──────────────── ──────────────── -// ∅☺☻♥♦♣♠•◘○◙♂♀♪♫☼ 0x00 -// ►◄↕‼¶§▬↨↑↓→←∟↔▲▼ 0x10 -// ␠ “# % / ! $ &‘()*+,-. 0x20 -// : < >⁇ 0123456789 ; = 0x30 -// @ ABCDEFGHIJKLMNO 0x40 -// [⭝]^ PQRSTUVWXYZ _ 0x50 -// ` abcdefghijklmno 0x60 -// {|} ⌂ pqrstuvwxyz ~ 0x70 -// ÇüéâäàåçêëèïîìÄÅ 0x80 -// ÉæÆôöòûùÿÖÜ¢£¥€ƒ 0x90 -// áíóúñѪº¿⌐¬½¼¡«» 0xa0 -// ░▒▓│┤╡╢╖╕╣║╗╝╜╛┐ 0xb0 -// └┴┬├─┼╞╟╚╔╩╦╠═╬╧ 0xc0 -// ╨╤╥╙╘╒╓╫╪┘┌█▄▌▐▀ 0xd0 -// αßΓπΣσμτΦΘΩδ∞φε∩ 0xe0 -// ≡±≥≤⌠⌡÷≈°∙×√ⁿ²■λ 0xf0 -// -// const char kEscapeAuthority[256] = { -// 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 0x00 -// 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 0x10 -// 1, 0, 1, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, // 0x20 -// 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 1, 1, // 0x30 -// 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 0x40 -// 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 0, // 0x50 -// 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 0x60 -// 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 0, 1, // 0x70 -// 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 0x80 -// 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 0x90 -// 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 0xa0 -// 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 0xb0 -// 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 0xc0 -// 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 0xd0 -// 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 0xe0 -// 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 0xf0 -// }; - - .initbss 300,_init_kEscapeAuthority -kEscapeAuthority: - .zero 256 - .endobj kEscapeAuthority,globl - .previous - - .initro 300,_init_kEscapeAuthority -kEscapeAuthority.rom: - .byte 33,1 # 00-20 ∅-␠ - .byte 1,0 # 21-21 !-! - .byte 2,1 # 22-23 “-# - .byte 1,0 # 24-24 §-§ - .byte 1,1 # 25-25 %-% - .byte 9,0 # 26-2e &-. - .byte 1,1 # 2f-2f /-/ - .byte 10,0 # 30-39 0-9 - .byte 1,1 # 3a-3a :-: - .byte 1,0 # 3b-3b ;-; - .byte 1,1 # 3c-3c <-< - .byte 1,0 # 3d-3d =-= - .byte 3,1 # 3e-40 >-@ - .byte 26,0 # 41-5a A-Z - .byte 4,1 # 5b-5e [-^ - .byte 1,0 # 5f-5f _-_ - .byte 1,1 # 60-60 `-` - .byte 26,0 # 61-7a a-z - .byte 3,1 # 7b-7d {-} - .byte 1,0 # 7e-7e ~-~ - .byte 129,1 # 7f-ff ⌂-λ - .byte 0,0 # terminator - .byte 0,0 # padding - .byte 0,0 # padding - .endobj kEscapeAuthority.rom,globl - - .init.start 300,_init_kEscapeAuthority - call rldecode - lodsl - .init.end 300,_init_kEscapeAuthority - -// 54 bytes total (21% original size) diff --git a/net/http/kescapeauthority.c b/net/http/kescapeauthority.c new file mode 100644 index 000000000..d158217dd --- /dev/null +++ b/net/http/kescapeauthority.c @@ -0,0 +1,60 @@ +/*-*- mode:c;indent-tabs-mode:nil;c-basic-offset:2;tab-width:8;coding:utf-8 -*-│ +│vi: set net ft=c ts=2 sts=2 sw=2 fenc=utf-8 :vi│ +╞══════════════════════════════════════════════════════════════════════════════╡ +│ Copyright 2023 Justine Alexandra Roberts Tunney │ +│ │ +│ Permission to use, copy, modify, and/or distribute this software for │ +│ any purpose with or without fee is hereby granted, provided that the │ +│ above copyright notice and this permission notice appear in all copies. │ +│ │ +│ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL │ +│ WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED │ +│ WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE │ +│ AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL │ +│ DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR │ +│ PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER │ +│ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │ +│ PERFORMANCE OF THIS SOFTWARE. │ +╚─────────────────────────────────────────────────────────────────────────────*/ +#include "net/http/escape.h" + +// generated by: +// o//tool/build/xlat.com -DUL '_.!~*'"'"'();&=+$,-' -iskEscapeAuthority +// +// present absent +// ──────────────── ──────────────── +// ∅☺☻♥♦♣♠•◘○◙♂♀♪♫☼ 0x00 +// ►◄↕‼¶§▬↨↑↓→←∟↔▲▼ 0x10 +// ␠ “# % / ! $ &‘()*+,-. 0x20 +// : < >⁇ 0123456789 ; = 0x30 +// @ ABCDEFGHIJKLMNO 0x40 +// [⭝]^ PQRSTUVWXYZ _ 0x50 +// ` abcdefghijklmno 0x60 +// {|} ⌂ pqrstuvwxyz ~ 0x70 +// ÇüéâäàåçêëèïîìÄÅ 0x80 +// ÉæÆôöòûùÿÖÜ¢£¥€ƒ 0x90 +// áíóúñѪº¿⌐¬½¼¡«» 0xa0 +// ░▒▓│┤╡╢╖╕╣║╗╝╜╛┐ 0xb0 +// └┴┬├─┼╞╟╚╔╩╦╠═╬╧ 0xc0 +// ╨╤╥╙╘╒╓╫╪┘┌█▄▌▐▀ 0xd0 +// αßΓπΣσμτΦΘΩδ∞φε∩ 0xe0 +// ≡±≥≤⌠⌡÷≈°∙×√ⁿ²■λ 0xf0 + +const char kEscapeAuthority[256] = { + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 0x00 + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 0x10 + 1, 0, 1, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, // 0x20 + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 1, 1, // 0x30 + 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 0x40 + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 0, // 0x50 + 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 0x60 + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 0, 1, // 0x70 + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 0x80 + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 0x90 + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 0xa0 + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 0xb0 + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 0xc0 + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 0xd0 + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 0xe0 + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 0xf0 +}; diff --git a/net/http/kescapefragment.S b/net/http/kescapefragment.S deleted file mode 100644 index ac7f051e3..000000000 --- a/net/http/kescapefragment.S +++ /dev/null @@ -1,79 +0,0 @@ -#include "libc/macros.internal.h" - -// generated by: -// o//tool/build/xlat.com -DUL '/?.~_@:!$&'"'"'()*+,;=-' -iskEscapeFragment -// -// present absent -// ──────────────── ──────────────── -// ∅☺☻♥♦♣♠•◘○◙♂♀♪♫☼ 0x00 -// ►◄↕‼¶§▬↨↑↓→←∟↔▲▼ 0x10 -// ␠ “# % ! § &‘()*+,-./ 0x20 -// < > 0123456789:; = ⁇ 0x30 -// @ABCDEFGHIJKLMNO 0x40 -// [⭝]^ PQRSTUVWXYZ _ 0x50 -// ` abcdefghijklmno 0x60 -// {|} ⌂ pqrstuvwxyz ~ 0x70 -// ÇüéâäàåçêëèïîìÄÅ 0x80 -// ÉæÆôöòûùÿÖÜ¢£¥€ƒ 0x90 -// áíóúñѪº¿⌐¬½¼¡«» 0xa0 -// ░▒▓│┤╡╢╖╕╣║╗╝╜╛┐ 0xb0 -// └┴┬├─┼╞╟╚╔╩╦╠═╬╧ 0xc0 -// ╨╤╥╙╘╒╓╫╪┘┌█▄▌▐▀ 0xd0 -// αßΓπΣσμτΦΘΩδ∞φε∩ 0xe0 -// ≡±≥≤⌠⌡÷≈°∙×√ⁿ²■λ 0xf0 -// -// const char kEscapeFragment[256] = { -// 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 0x00 -// 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 0x10 -// 1, 0, 1, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 0x20 -// 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0, // 0x30 -// 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 0x40 -// 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 0, // 0x50 -// 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 0x60 -// 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 0, 1, // 0x70 -// 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 0x80 -// 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 0x90 -// 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 0xa0 -// 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 0xb0 -// 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 0xc0 -// 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 0xd0 -// 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 0xe0 -// 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 0xf0 -// }; - - .initbss 300,_init_kEscapeFragment -kEscapeFragment: - .zero 256 - .endobj kEscapeFragment,globl - .previous - - .initro 300,_init_kEscapeFragment -kEscapeFragment.rom: - .byte 33,1 # 00-20 ∅-␠ - .byte 1,0 # 21-21 !-! - .byte 2,1 # 22-23 “-# - .byte 1,0 # 24-24 §-§ - .byte 1,1 # 25-25 %-% - .byte 22,0 # 26-3b &-; - .byte 1,1 # 3c-3c <-< - .byte 1,0 # 3d-3d =-= - .byte 1,1 # 3e-3e >-> - .byte 28,0 # 3f-5a ⁇-Z - .byte 4,1 # 5b-5e [-^ - .byte 1,0 # 5f-5f _-_ - .byte 1,1 # 60-60 `-` - .byte 26,0 # 61-7a a-z - .byte 3,1 # 7b-7d {-} - .byte 1,0 # 7e-7e ~-~ - .byte 129,1 # 7f-ff ⌂-λ - .byte 0,0 # terminator - .byte 0,0 # padding - .byte 0,0 # padding - .endobj kEscapeFragment.rom,globl - - .init.start 300,_init_kEscapeFragment - call rldecode - lodsl - .init.end 300,_init_kEscapeFragment - -// 46 bytes total (18% original size) diff --git a/net/http/kescapefragment.c b/net/http/kescapefragment.c new file mode 100644 index 000000000..d150c7680 --- /dev/null +++ b/net/http/kescapefragment.c @@ -0,0 +1,60 @@ +/*-*- mode:c;indent-tabs-mode:nil;c-basic-offset:2;tab-width:8;coding:utf-8 -*-│ +│vi: set net ft=c ts=2 sts=2 sw=2 fenc=utf-8 :vi│ +╞══════════════════════════════════════════════════════════════════════════════╡ +│ Copyright 2023 Justine Alexandra Roberts Tunney │ +│ │ +│ Permission to use, copy, modify, and/or distribute this software for │ +│ any purpose with or without fee is hereby granted, provided that the │ +│ above copyright notice and this permission notice appear in all copies. │ +│ │ +│ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL │ +│ WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED │ +│ WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE │ +│ AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL │ +│ DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR │ +│ PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER │ +│ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │ +│ PERFORMANCE OF THIS SOFTWARE. │ +╚─────────────────────────────────────────────────────────────────────────────*/ +#include "net/http/escape.h" + +// generated by: +// o//tool/build/xlat.com -DUL '/?.~_@:!$&'"'"'()*+,;=-' -iskEscapeFragment +// +// present absent +// ──────────────── ──────────────── +// ∅☺☻♥♦♣♠•◘○◙♂♀♪♫☼ 0x00 +// ►◄↕‼¶§▬↨↑↓→←∟↔▲▼ 0x10 +// ␠ “# % ! § &‘()*+,-./ 0x20 +// < > 0123456789:; = ⁇ 0x30 +// @ABCDEFGHIJKLMNO 0x40 +// [⭝]^ PQRSTUVWXYZ _ 0x50 +// ` abcdefghijklmno 0x60 +// {|} ⌂ pqrstuvwxyz ~ 0x70 +// ÇüéâäàåçêëèïîìÄÅ 0x80 +// ÉæÆôöòûùÿÖÜ¢£¥€ƒ 0x90 +// áíóúñѪº¿⌐¬½¼¡«» 0xa0 +// ░▒▓│┤╡╢╖╕╣║╗╝╜╛┐ 0xb0 +// └┴┬├─┼╞╟╚╔╩╦╠═╬╧ 0xc0 +// ╨╤╥╙╘╒╓╫╪┘┌█▄▌▐▀ 0xd0 +// αßΓπΣσμτΦΘΩδ∞φε∩ 0xe0 +// ≡±≥≤⌠⌡÷≈°∙×√ⁿ²■λ 0xf0 + +const char kEscapeFragment[256] = { + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 0x00 + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 0x10 + 1, 0, 1, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 0x20 + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0, // 0x30 + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 0x40 + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 0, // 0x50 + 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 0x60 + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 0, 1, // 0x70 + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 0x80 + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 0x90 + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 0xa0 + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 0xb0 + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 0xc0 + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 0xd0 + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 0xe0 + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 0xf0 +}; diff --git a/net/http/kescapeip.S b/net/http/kescapeip.S deleted file mode 100644 index 6870b077f..000000000 --- a/net/http/kescapeip.S +++ /dev/null @@ -1,78 +0,0 @@ -#include "libc/macros.internal.h" - -// generated by: -// o//tool/build/xlat.com -DUL '_-.!~*'"'"'();&=+$,:' -iskEscapeIp -// -// present absent -// ──────────────── ──────────────── -// ∅☺☻♥♦♣♠•◘○◙♂♀♪♫☼ 0x00 -// ►◄↕‼¶§▬↨↑↓→←∟↔▲▼ 0x10 -// ␠ “# % / ! § &‘()*+,-. 0x20 -// < >⁇ 0123456789:; = 0x30 -// @ ABCDEFGHIJKLMNO 0x40 -// [⭝]^ PQRSTUVWXYZ _ 0x50 -// ` abcdefghijklmno 0x60 -// {|} ⌂ pqrstuvwxyz ~ 0x70 -// ÇüéâäàåçêëèïîìÄÅ 0x80 -// ÉæÆôöòûùÿÖÜ¢£¥€ƒ 0x90 -// áíóúñѪº¿⌐¬½¼¡«» 0xa0 -// ░▒▓│┤╡╢╖╕╣║╗╝╜╛┐ 0xb0 -// └┴┬├─┼╞╟╚╔╩╦╠═╬╧ 0xc0 -// ╨╤╥╙╘╒╓╫╪┘┌█▄▌▐▀ 0xd0 -// αßΓπΣσμτΦΘΩδ∞φε∩ 0xe0 -// ≡±≥≤⌠⌡÷≈°∙×√ⁿ²■λ 0xf0 -// -// const char kEscapeIp[256] = { -// 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 0x00 -// 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 0x10 -// 1, 0, 1, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, // 0x20 -// 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 1, // 0x30 -// 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 0x40 -// 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 0, // 0x50 -// 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 0x60 -// 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 0, 1, // 0x70 -// 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 0x80 -// 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 0x90 -// 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 0xa0 -// 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 0xb0 -// 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 0xc0 -// 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 0xd0 -// 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 0xe0 -// 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 0xf0 -// }; - - .initbss 300,_init_kEscapeIp -kEscapeIp: - .zero 256 - .endobj kEscapeIp,globl - .previous - - .initro 300,_init_kEscapeIp -kEscapeIp.rom: - .byte 33,1 # 00-20 ∅-␠ - .byte 1,0 # 21-21 !-! - .byte 2,1 # 22-23 “-# - .byte 1,0 # 24-24 §-§ - .byte 1,1 # 25-25 %-% - .byte 9,0 # 26-2e &-. - .byte 1,1 # 2f-2f /-/ - .byte 12,0 # 30-3b 0-; - .byte 1,1 # 3c-3c <-< - .byte 1,0 # 3d-3d =-= - .byte 3,1 # 3e-40 >-@ - .byte 26,0 # 41-5a A-Z - .byte 4,1 # 5b-5e [-^ - .byte 1,0 # 5f-5f _-_ - .byte 1,1 # 60-60 `-` - .byte 26,0 # 61-7a a-z - .byte 3,1 # 7b-7d {-} - .byte 1,0 # 7e-7e ~-~ - .byte 129,1 # 7f-ff ⌂-λ - .byte 0,0 # terminator - .endobj kEscapeIp.rom,globl - - .init.start 300,_init_kEscapeIp - call rldecode - .init.end 300,_init_kEscapeIp - -// 45 bytes total (18% original size) diff --git a/net/http/kescapeip.c b/net/http/kescapeip.c new file mode 100644 index 000000000..3786cdb17 --- /dev/null +++ b/net/http/kescapeip.c @@ -0,0 +1,60 @@ +/*-*- mode:c;indent-tabs-mode:nil;c-basic-offset:2;tab-width:8;coding:utf-8 -*-│ +│vi: set net ft=c ts=2 sts=2 sw=2 fenc=utf-8 :vi│ +╞══════════════════════════════════════════════════════════════════════════════╡ +│ Copyright 2023 Justine Alexandra Roberts Tunney │ +│ │ +│ Permission to use, copy, modify, and/or distribute this software for │ +│ any purpose with or without fee is hereby granted, provided that the │ +│ above copyright notice and this permission notice appear in all copies. │ +│ │ +│ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL │ +│ WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED │ +│ WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE │ +│ AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL │ +│ DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR │ +│ PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER │ +│ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │ +│ PERFORMANCE OF THIS SOFTWARE. │ +╚─────────────────────────────────────────────────────────────────────────────*/ +#include "net/http/escape.h" + +// generated by: +// o//tool/build/xlat.com -DUL '_-.!~*'"'"'();&=+$,:' -iskEscapeIp +// +// present absent +// ──────────────── ──────────────── +// ∅☺☻♥♦♣♠•◘○◙♂♀♪♫☼ 0x00 +// ►◄↕‼¶§▬↨↑↓→←∟↔▲▼ 0x10 +// ␠ “# % / ! § &‘()*+,-. 0x20 +// < >⁇ 0123456789:; = 0x30 +// @ ABCDEFGHIJKLMNO 0x40 +// [⭝]^ PQRSTUVWXYZ _ 0x50 +// ` abcdefghijklmno 0x60 +// {|} ⌂ pqrstuvwxyz ~ 0x70 +// ÇüéâäàåçêëèïîìÄÅ 0x80 +// ÉæÆôöòûùÿÖÜ¢£¥€ƒ 0x90 +// áíóúñѪº¿⌐¬½¼¡«» 0xa0 +// ░▒▓│┤╡╢╖╕╣║╗╝╜╛┐ 0xb0 +// └┴┬├─┼╞╟╚╔╩╦╠═╬╧ 0xc0 +// ╨╤╥╙╘╒╓╫╪┘┌█▄▌▐▀ 0xd0 +// αßΓπΣσμτΦΘΩδ∞φε∩ 0xe0 +// ≡±≥≤⌠⌡÷≈°∙×√ⁿ²■λ 0xf0 + +const char kEscapeIp[256] = { + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 0x00 + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 0x10 + 1, 0, 1, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, // 0x20 + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 1, // 0x30 + 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 0x40 + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 0, // 0x50 + 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 0x60 + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 0, 1, // 0x70 + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 0x80 + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 0x90 + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 0xa0 + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 0xb0 + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 0xc0 + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 0xd0 + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 0xe0 + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 0xf0 +}; diff --git a/net/http/kescapeparam.S b/net/http/kescapeparam.S deleted file mode 100644 index 882c622bf..000000000 --- a/net/http/kescapeparam.S +++ /dev/null @@ -1,75 +0,0 @@ -#include "libc/macros.internal.h" - -// generated by: -// o//tool/build/xlat.com -DUL '.-*_' -iskEscapeParam -// -// present absent -// ──────────────── ──────────────── -// ∅☺☻♥♦♣♠•◘○◙♂♀♪♫☼ 0x00 -// ►◄↕‼¶§▬↨↑↓→←∟↔▲▼ 0x10 -// ␠!“#§%&‘() +, / * -. 0x20 -// :;<=>⁇ 0123456789 0x30 -// @ ABCDEFGHIJKLMNO 0x40 -// [⭝]^ PQRSTUVWXYZ _ 0x50 -// ` abcdefghijklmno 0x60 -// {|}~⌂ pqrstuvwxyz 0x70 -// ÇüéâäàåçêëèïîìÄÅ 0x80 -// ÉæÆôöòûùÿÖÜ¢£¥€ƒ 0x90 -// áíóúñѪº¿⌐¬½¼¡«» 0xa0 -// ░▒▓│┤╡╢╖╕╣║╗╝╜╛┐ 0xb0 -// └┴┬├─┼╞╟╚╔╩╦╠═╬╧ 0xc0 -// ╨╤╥╙╘╒╓╫╪┘┌█▄▌▐▀ 0xd0 -// αßΓπΣσμτΦΘΩδ∞φε∩ 0xe0 -// ≡±≥≤⌠⌡÷≈°∙×√ⁿ²■λ 0xf0 -// -// const char kEscapeParam[256] = { -// 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 0x00 -// 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 0x10 -// 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 0, 0, 1, // 0x20 -// 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, // 0x30 -// 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 0x40 -// 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 0, // 0x50 -// 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 0x60 -// 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, // 0x70 -// 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 0x80 -// 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 0x90 -// 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 0xa0 -// 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 0xb0 -// 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 0xc0 -// 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 0xd0 -// 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 0xe0 -// 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 0xf0 -// }; - - .initbss 300,_init_kEscapeParam -kEscapeParam: - .zero 256 - .endobj kEscapeParam,globl - .previous - - .initro 300,_init_kEscapeParam -kEscapeParam.rom: - .byte 42,1 # 00-29 ∅-) - .byte 1,0 # 2a-2a *-* - .byte 2,1 # 2b-2c +-, - .byte 2,0 # 2d-2e --. - .byte 1,1 # 2f-2f /-/ - .byte 10,0 # 30-39 0-9 - .byte 7,1 # 3a-40 :-@ - .byte 26,0 # 41-5a A-Z - .byte 4,1 # 5b-5e [-^ - .byte 1,0 # 5f-5f _-_ - .byte 1,1 # 60-60 `-` - .byte 26,0 # 61-7a a-z - .byte 133,1 # 7b-ff {-λ - .byte 0,0 # terminator - .byte 0,0 # padding - .byte 0,0 # padding - .endobj kEscapeParam.rom,globl - - .init.start 300,_init_kEscapeParam - call rldecode - lodsl - .init.end 300,_init_kEscapeParam - -// 38 bytes total (15% original size) diff --git a/net/http/kescapeparam.c b/net/http/kescapeparam.c new file mode 100644 index 000000000..e80a09b27 --- /dev/null +++ b/net/http/kescapeparam.c @@ -0,0 +1,60 @@ +/*-*- mode:c;indent-tabs-mode:nil;c-basic-offset:2;tab-width:8;coding:utf-8 -*-│ +│vi: set net ft=c ts=2 sts=2 sw=2 fenc=utf-8 :vi│ +╞══════════════════════════════════════════════════════════════════════════════╡ +│ Copyright 2023 Justine Alexandra Roberts Tunney │ +│ │ +│ Permission to use, copy, modify, and/or distribute this software for │ +│ any purpose with or without fee is hereby granted, provided that the │ +│ above copyright notice and this permission notice appear in all copies. │ +│ │ +│ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL │ +│ WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED │ +│ WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE │ +│ AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL │ +│ DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR │ +│ PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER │ +│ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │ +│ PERFORMANCE OF THIS SOFTWARE. │ +╚─────────────────────────────────────────────────────────────────────────────*/ +#include "net/http/escape.h" + +// generated by: +// o//tool/build/xlat.com -DUL '.-*_' -iskEscapeParam +// +// present absent +// ──────────────── ──────────────── +// ∅☺☻♥♦♣♠•◘○◙♂♀♪♫☼ 0x00 +// ►◄↕‼¶§▬↨↑↓→←∟↔▲▼ 0x10 +// ␠!“#§%&‘() +, / * -. 0x20 +// :;<=>⁇ 0123456789 0x30 +// @ ABCDEFGHIJKLMNO 0x40 +// [⭝]^ PQRSTUVWXYZ _ 0x50 +// ` abcdefghijklmno 0x60 +// {|}~⌂ pqrstuvwxyz 0x70 +// ÇüéâäàåçêëèïîìÄÅ 0x80 +// ÉæÆôöòûùÿÖÜ¢£¥€ƒ 0x90 +// áíóúñѪº¿⌐¬½¼¡«» 0xa0 +// ░▒▓│┤╡╢╖╕╣║╗╝╜╛┐ 0xb0 +// └┴┬├─┼╞╟╚╔╩╦╠═╬╧ 0xc0 +// ╨╤╥╙╘╒╓╫╪┘┌█▄▌▐▀ 0xd0 +// αßΓπΣσμτΦΘΩδ∞φε∩ 0xe0 +// ≡±≥≤⌠⌡÷≈°∙×√ⁿ²■λ 0xf0 + +const char kEscapeParam[256] = { + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 0x00 + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 0x10 + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 0, 0, 1, // 0x20 + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, // 0x30 + 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 0x40 + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 0, // 0x50 + 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 0x60 + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, // 0x70 + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 0x80 + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 0x90 + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 0xa0 + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 0xb0 + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 0xc0 + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 0xd0 + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 0xe0 + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 0xf0 +}; diff --git a/net/http/kescapepath.S b/net/http/kescapepath.S deleted file mode 100644 index f30a44b6c..000000000 --- a/net/http/kescapepath.S +++ /dev/null @@ -1,79 +0,0 @@ -#include "libc/macros.internal.h" - -// generated by: -// o//tool/build/xlat.com -DUL '.-~_@:!$&'"'"'()*+,;=/' -iskEscapePath -// -// present absent -// ──────────────── ──────────────── -// ∅☺☻♥♦♣♠•◘○◙♂♀♪♫☼ 0x00 -// ►◄↕‼¶§▬↨↑↓→←∟↔▲▼ 0x10 -// ␠ “# % ! § &‘()*+,-./ 0x20 -// < >⁇ 0123456789:; = 0x30 -// @ABCDEFGHIJKLMNO 0x40 -// [⭝]^ PQRSTUVWXYZ _ 0x50 -// ` abcdefghijklmno 0x60 -// {|} ⌂ pqrstuvwxyz ~ 0x70 -// ÇüéâäàåçêëèïîìÄÅ 0x80 -// ÉæÆôöòûùÿÖÜ¢£¥€ƒ 0x90 -// áíóúñѪº¿⌐¬½¼¡«» 0xa0 -// ░▒▓│┤╡╢╖╕╣║╗╝╜╛┐ 0xb0 -// └┴┬├─┼╞╟╚╔╩╦╠═╬╧ 0xc0 -// ╨╤╥╙╘╒╓╫╪┘┌█▄▌▐▀ 0xd0 -// αßΓπΣσμτΦΘΩδ∞φε∩ 0xe0 -// ≡±≥≤⌠⌡÷≈°∙×√ⁿ²■λ 0xf0 -// -// const char kEscapePath[256] = { -// 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 0x00 -// 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 0x10 -// 1, 0, 1, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 0x20 -// 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 1, // 0x30 -// 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 0x40 -// 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 0, // 0x50 -// 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 0x60 -// 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 0, 1, // 0x70 -// 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 0x80 -// 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 0x90 -// 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 0xa0 -// 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 0xb0 -// 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 0xc0 -// 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 0xd0 -// 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 0xe0 -// 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 0xf0 -// }; - - .initbss 300,_init_kEscapePath -kEscapePath: - .zero 256 - .endobj kEscapePath,globl - .previous - - .initro 300,_init_kEscapePath -kEscapePath.rom: - .byte 33,1 # 00-20 ∅-␠ - .byte 1,0 # 21-21 !-! - .byte 2,1 # 22-23 “-# - .byte 1,0 # 24-24 §-§ - .byte 1,1 # 25-25 %-% - .byte 22,0 # 26-3b &-; - .byte 1,1 # 3c-3c <-< - .byte 1,0 # 3d-3d =-= - .byte 2,1 # 3e-3f >-⁇ - .byte 27,0 # 40-5a @-Z - .byte 4,1 # 5b-5e [-^ - .byte 1,0 # 5f-5f _-_ - .byte 1,1 # 60-60 `-` - .byte 26,0 # 61-7a a-z - .byte 3,1 # 7b-7d {-} - .byte 1,0 # 7e-7e ~-~ - .byte 129,1 # 7f-ff ⌂-λ - .byte 0,0 # terminator - .byte 0,0 # padding - .byte 0,0 # padding - .endobj kEscapePath.rom,globl - - .init.start 300,_init_kEscapePath - call rldecode - lodsl - .init.end 300,_init_kEscapePath - -// 46 bytes total (18% original size) diff --git a/net/http/kescapepath.c b/net/http/kescapepath.c new file mode 100644 index 000000000..a5a50c12c --- /dev/null +++ b/net/http/kescapepath.c @@ -0,0 +1,60 @@ +/*-*- mode:c;indent-tabs-mode:nil;c-basic-offset:2;tab-width:8;coding:utf-8 -*-│ +│vi: set net ft=c ts=2 sts=2 sw=2 fenc=utf-8 :vi│ +╞══════════════════════════════════════════════════════════════════════════════╡ +│ Copyright 2023 Justine Alexandra Roberts Tunney │ +│ │ +│ Permission to use, copy, modify, and/or distribute this software for │ +│ any purpose with or without fee is hereby granted, provided that the │ +│ above copyright notice and this permission notice appear in all copies. │ +│ │ +│ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL │ +│ WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED │ +│ WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE │ +│ AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL │ +│ DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR │ +│ PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER │ +│ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │ +│ PERFORMANCE OF THIS SOFTWARE. │ +╚─────────────────────────────────────────────────────────────────────────────*/ +#include "net/http/escape.h" + +// generated by: +// o//tool/build/xlat.com -DUL '.-~_@:!$&'"'"'()*+,;=/' -iskEscapePath +// +// present absent +// ──────────────── ──────────────── +// ∅☺☻♥♦♣♠•◘○◙♂♀♪♫☼ 0x00 +// ►◄↕‼¶§▬↨↑↓→←∟↔▲▼ 0x10 +// ␠ “# % ! § &‘()*+,-./ 0x20 +// < >⁇ 0123456789:; = 0x30 +// @ABCDEFGHIJKLMNO 0x40 +// [⭝]^ PQRSTUVWXYZ _ 0x50 +// ` abcdefghijklmno 0x60 +// {|} ⌂ pqrstuvwxyz ~ 0x70 +// ÇüéâäàåçêëèïîìÄÅ 0x80 +// ÉæÆôöòûùÿÖÜ¢£¥€ƒ 0x90 +// áíóúñѪº¿⌐¬½¼¡«» 0xa0 +// ░▒▓│┤╡╢╖╕╣║╗╝╜╛┐ 0xb0 +// └┴┬├─┼╞╟╚╔╩╦╠═╬╧ 0xc0 +// ╨╤╥╙╘╒╓╫╪┘┌█▄▌▐▀ 0xd0 +// αßΓπΣσμτΦΘΩδ∞φε∩ 0xe0 +// ≡±≥≤⌠⌡÷≈°∙×√ⁿ²■λ 0xf0 + +const char kEscapePath[256] = { + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 0x00 + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 0x10 + 1, 0, 1, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 0x20 + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 1, // 0x30 + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 0x40 + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 0, // 0x50 + 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 0x60 + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 0, 1, // 0x70 + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 0x80 + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 0x90 + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 0xa0 + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 0xb0 + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 0xc0 + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 0xd0 + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 0xe0 + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 0xf0 +}; diff --git a/net/http/kescapesegment.S b/net/http/kescapesegment.S deleted file mode 100644 index 786a8a772..000000000 --- a/net/http/kescapesegment.S +++ /dev/null @@ -1,78 +0,0 @@ -#include "libc/macros.internal.h" - -// generated by: -// o//tool/build/xlat.com -DUL '.-~_@:!$&'"'"'()*+,;=' -iskEscapeSegment -// -// present absent -// ──────────────── ──────────────── -// ∅☺☻♥♦♣♠•◘○◙♂♀♪♫☼ 0x00 -// ►◄↕‼¶§▬↨↑↓→←∟↔▲▼ 0x10 -// ␠ “# % / ! § &‘()*+,-. 0x20 -// < >⁇ 0123456789:; = 0x30 -// @ABCDEFGHIJKLMNO 0x40 -// [⭝]^ PQRSTUVWXYZ _ 0x50 -// ` abcdefghijklmno 0x60 -// {|} ⌂ pqrstuvwxyz ~ 0x70 -// ÇüéâäàåçêëèïîìÄÅ 0x80 -// ÉæÆôöòûùÿÖÜ¢£¥€ƒ 0x90 -// áíóúñѪº¿⌐¬½¼¡«» 0xa0 -// ░▒▓│┤╡╢╖╕╣║╗╝╜╛┐ 0xb0 -// └┴┬├─┼╞╟╚╔╩╦╠═╬╧ 0xc0 -// ╨╤╥╙╘╒╓╫╪┘┌█▄▌▐▀ 0xd0 -// αßΓπΣσμτΦΘΩδ∞φε∩ 0xe0 -// ≡±≥≤⌠⌡÷≈°∙×√ⁿ²■λ 0xf0 -// -// const char kEscapeSegment[256] = { -// 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 0x00 -// 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 0x10 -// 1, 0, 1, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, // 0x20 -// 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 1, // 0x30 -// 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 0x40 -// 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 0, // 0x50 -// 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 0x60 -// 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 0, 1, // 0x70 -// 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 0x80 -// 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 0x90 -// 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 0xa0 -// 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 0xb0 -// 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 0xc0 -// 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 0xd0 -// 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 0xe0 -// 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 0xf0 -// }; - - .initbss 300,_init_kEscapeSegment -kEscapeSegment: - .zero 256 - .endobj kEscapeSegment,globl - .previous - - .initro 300,_init_kEscapeSegment -kEscapeSegment.rom: - .byte 33,1 # 00-20 ∅-␠ - .byte 1,0 # 21-21 !-! - .byte 2,1 # 22-23 “-# - .byte 1,0 # 24-24 §-§ - .byte 1,1 # 25-25 %-% - .byte 9,0 # 26-2e &-. - .byte 1,1 # 2f-2f /-/ - .byte 12,0 # 30-3b 0-; - .byte 1,1 # 3c-3c <-< - .byte 1,0 # 3d-3d =-= - .byte 2,1 # 3e-3f >-⁇ - .byte 27,0 # 40-5a @-Z - .byte 4,1 # 5b-5e [-^ - .byte 1,0 # 5f-5f _-_ - .byte 1,1 # 60-60 `-` - .byte 26,0 # 61-7a a-z - .byte 3,1 # 7b-7d {-} - .byte 1,0 # 7e-7e ~-~ - .byte 129,1 # 7f-ff ⌂-λ - .byte 0,0 # terminator - .endobj kEscapeSegment.rom,globl - - .init.start 300,_init_kEscapeSegment - call rldecode - .init.end 300,_init_kEscapeSegment - -// 45 bytes total (18% original size) diff --git a/net/http/kescapesegment.c b/net/http/kescapesegment.c new file mode 100644 index 000000000..27a97e2d8 --- /dev/null +++ b/net/http/kescapesegment.c @@ -0,0 +1,60 @@ +/*-*- mode:c;indent-tabs-mode:nil;c-basic-offset:2;tab-width:8;coding:utf-8 -*-│ +│vi: set net ft=c ts=2 sts=2 sw=2 fenc=utf-8 :vi│ +╞══════════════════════════════════════════════════════════════════════════════╡ +│ Copyright 2023 Justine Alexandra Roberts Tunney │ +│ │ +│ Permission to use, copy, modify, and/or distribute this software for │ +│ any purpose with or without fee is hereby granted, provided that the │ +│ above copyright notice and this permission notice appear in all copies. │ +│ │ +│ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL │ +│ WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED │ +│ WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE │ +│ AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL │ +│ DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR │ +│ PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER │ +│ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │ +│ PERFORMANCE OF THIS SOFTWARE. │ +╚─────────────────────────────────────────────────────────────────────────────*/ +#include "net/http/escape.h" + +// generated by: +// o//tool/build/xlat.com -DUL '.-~_@:!$&'"'"'()*+,;=' -iskEscapeSegment +// +// present absent +// ──────────────── ──────────────── +// ∅☺☻♥♦♣♠•◘○◙♂♀♪♫☼ 0x00 +// ►◄↕‼¶§▬↨↑↓→←∟↔▲▼ 0x10 +// ␠ “# % / ! § &‘()*+,-. 0x20 +// < >⁇ 0123456789:; = 0x30 +// @ABCDEFGHIJKLMNO 0x40 +// [⭝]^ PQRSTUVWXYZ _ 0x50 +// ` abcdefghijklmno 0x60 +// {|} ⌂ pqrstuvwxyz ~ 0x70 +// ÇüéâäàåçêëèïîìÄÅ 0x80 +// ÉæÆôöòûùÿÖÜ¢£¥€ƒ 0x90 +// áíóúñѪº¿⌐¬½¼¡«» 0xa0 +// ░▒▓│┤╡╢╖╕╣║╗╝╜╛┐ 0xb0 +// └┴┬├─┼╞╟╚╔╩╦╠═╬╧ 0xc0 +// ╨╤╥╙╘╒╓╫╪┘┌█▄▌▐▀ 0xd0 +// αßΓπΣσμτΦΘΩδ∞φε∩ 0xe0 +// ≡±≥≤⌠⌡÷≈°∙×√ⁿ²■λ 0xf0 + +const char kEscapeSegment[256] = { + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 0x00 + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 0x10 + 1, 0, 1, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, // 0x20 + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 1, // 0x30 + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 0x40 + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 0, // 0x50 + 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 0x60 + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 0, 1, // 0x70 + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 0x80 + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 0x90 + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 0xa0 + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 0xb0 + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 0xc0 + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 0xd0 + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 0xe0 + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 0xf0 +}; diff --git a/net/http/khostchars.S b/net/http/khostchars.S deleted file mode 100644 index 371526f01..000000000 --- a/net/http/khostchars.S +++ /dev/null @@ -1,70 +0,0 @@ -#include "libc/macros.internal.h" - -// generated by: -// o//tool/build/xlat.com -DA _- -skHostChars -// -// present absent -// ──────────────── ──────────────── -// ∅☺☻♥♦♣♠•◘○◙♂♀♪♫☼ 0x00 -// ►◄↕‼¶§▬↨↑↓→←∟↔▲▼ 0x10 -// - ␠!“#§%&‘()*+, ./ 0x20 -// 0123456789 :;<=>⁇ 0x30 -// ABCDEFGHIJKLMNO @ 0x40 -// PQRSTUVWXYZ _ [⭝]^ 0x50 -// abcdefghijklmno ` 0x60 -// pqrstuvwxyz {|}~⌂ 0x70 -// ÇüéâäàåçêëèïîìÄÅ 0x80 -// ÉæÆôöòûùÿÖÜ¢£¥€ƒ 0x90 -// áíóúñѪº¿⌐¬½¼¡«» 0xa0 -// ░▒▓│┤╡╢╖╕╣║╗╝╜╛┐ 0xb0 -// └┴┬├─┼╞╟╚╔╩╦╠═╬╧ 0xc0 -// ╨╤╥╙╘╒╓╫╪┘┌█▄▌▐▀ 0xd0 -// αßΓπΣσμτΦΘΩδ∞φε∩ 0xe0 -// ≡±≥≤⌠⌡÷≈°∙×√ⁿ²■λ 0xf0 -// -// const char kHostChars[256] = { -// 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 0x00 -// 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 0x10 -// 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, // 0x20 -// 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, // 0x30 -// 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 0x40 -// 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 1, // 0x50 -// 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 0x60 -// 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, // 0x70 -// 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 0x80 -// 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 0x90 -// 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 0xa0 -// 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 0xb0 -// 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 0xc0 -// 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 0xd0 -// 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 0xe0 -// 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 0xf0 -// }; - - .initbss 300,_init_kHostChars -kHostChars: - .zero 256 - .endobj kHostChars,globl - .previous - - .initro 300,_init_kHostChars -kHostChars.rom: - .byte 45,0 # 00-2c ∅-, - .byte 1,1 # 2d-2d --- - .byte 2,0 # 2e-2f .-/ - .byte 10,1 # 30-39 0-9 - .byte 7,0 # 3a-40 :-@ - .byte 26,1 # 41-5a A-Z - .byte 4,0 # 5b-5e [-^ - .byte 1,1 # 5f-5f _-_ - .byte 1,0 # 60-60 `-` - .byte 26,1 # 61-7a a-z - .byte 133,0 # 7b-ff {-λ - .byte 0,0 # terminator - .endobj kHostChars.rom,globl - - .init.start 300,_init_kHostChars - call rldecode - .init.end 300,_init_kHostChars - -// 29 bytes total (11% original size) diff --git a/net/http/khostchars.c b/net/http/khostchars.c new file mode 100644 index 000000000..02da600ac --- /dev/null +++ b/net/http/khostchars.c @@ -0,0 +1,60 @@ +/*-*- mode:c;indent-tabs-mode:nil;c-basic-offset:2;tab-width:8;coding:utf-8 -*-│ +│vi: set net ft=c ts=2 sts=2 sw=2 fenc=utf-8 :vi│ +╞══════════════════════════════════════════════════════════════════════════════╡ +│ Copyright 2023 Justine Alexandra Roberts Tunney │ +│ │ +│ Permission to use, copy, modify, and/or distribute this software for │ +│ any purpose with or without fee is hereby granted, provided that the │ +│ above copyright notice and this permission notice appear in all copies. │ +│ │ +│ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL │ +│ WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED │ +│ WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE │ +│ AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL │ +│ DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR │ +│ PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER │ +│ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │ +│ PERFORMANCE OF THIS SOFTWARE. │ +╚─────────────────────────────────────────────────────────────────────────────*/ +#include "net/http/escape.h" + +// generated by: +// o//tool/build/xlat.com -DA _- -skHostChars +// +// present absent +// ──────────────── ──────────────── +// ∅☺☻♥♦♣♠•◘○◙♂♀♪♫☼ 0x00 +// ►◄↕‼¶§▬↨↑↓→←∟↔▲▼ 0x10 +// - ␠!“#§%&‘()*+, ./ 0x20 +// 0123456789 :;<=>⁇ 0x30 +// ABCDEFGHIJKLMNO @ 0x40 +// PQRSTUVWXYZ _ [⭝]^ 0x50 +// abcdefghijklmno ` 0x60 +// pqrstuvwxyz {|}~⌂ 0x70 +// ÇüéâäàåçêëèïîìÄÅ 0x80 +// ÉæÆôöòûùÿÖÜ¢£¥€ƒ 0x90 +// áíóúñѪº¿⌐¬½¼¡«» 0xa0 +// ░▒▓│┤╡╢╖╕╣║╗╝╜╛┐ 0xb0 +// └┴┬├─┼╞╟╚╔╩╦╠═╬╧ 0xc0 +// ╨╤╥╙╘╒╓╫╪┘┌█▄▌▐▀ 0xd0 +// αßΓπΣσμτΦΘΩδ∞φε∩ 0xe0 +// ≡±≥≤⌠⌡÷≈°∙×√ⁿ²■λ 0xf0 + +const char kHostChars[256] = { + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 0x00 + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 0x10 + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, // 0x20 + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, // 0x30 + 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 0x40 + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 1, // 0x50 + 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 0x60 + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, // 0x70 + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 0x80 + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 0x90 + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 0xa0 + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 0xb0 + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 0xc0 + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 0xd0 + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 0xe0 + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 0xf0 +}; diff --git a/net/http/khttptoken.S b/net/http/khttptoken.S deleted file mode 100644 index c284f6c45..000000000 --- a/net/http/khttptoken.S +++ /dev/null @@ -1,90 +0,0 @@ -#include "libc/macros.internal.h" - -// generated by: -// o//tool/build/xlat.com -TiC ' ()<>@,;:\"/[]?={}' -iskHttpToken -// -// present absent -// ──────────────── ──────────────── -// ∅☺☻♥♦♣♠•◘○◙♂♀♪♫☼ 0x00 -// ►◄↕‼¶§▬↨↑↓→←∟↔▲▼ 0x10 -// ! #$%&‘ *+ -. ␠ “ () , / 0x20 -// 0123456789 :;<=>⁇ 0x30 -// ABCDEFGHIJKLMNO @ 0x40 -// PQRSTUVWXYZ ^_ [⭝] 0x50 -// `abcdefghijklmno 0x60 -// pqrstuvwxyz | ~ { } ⌂ 0x70 -// ÇüéâäàåçêëèïîìÄÅ 0x80 -// ÉæÆôöòûùÿÖÜ¢£¥€ƒ 0x90 -// áíóúñѪº¿⌐¬½¼¡«» 0xa0 -// ░▒▓│┤╡╢╖╕╣║╗╝╜╛┐ 0xb0 -// └┴┬├─┼╞╟╚╔╩╦╠═╬╧ 0xc0 -// ╨╤╥╙╘╒╓╫╪┘┌█▄▌▐▀ 0xd0 -// αßΓπΣσμτΦΘΩδ∞φε∩ 0xe0 -// ≡±≥≤⌠⌡÷≈°∙×√ⁿ²■λ 0xf0 -// -// const char kHttpToken[256] = { -// 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 0x00 -// 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 0x10 -// 0, 1, 0, 1, 1, 1, 1, 1, 0, 0, 1, 1, 0, 1, 1, 0, // 0x20 -// 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, // 0x30 -// 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 0x40 -// 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 1, 1, // 0x50 -// 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 0x60 -// 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 0, 1, 0, // 0x70 -// 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 0x80 -// 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 0x90 -// 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 0xa0 -// 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 0xb0 -// 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 0xc0 -// 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 0xd0 -// 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 0xe0 -// 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 0xf0 -// }; -// -// @see RFC2616 -// CHAR = -// SP = -// HT = -// CTL = -// token = 1* -// separators = "(" | ")" | "<" | ">" | "@" -// | "," | ";" | ":" | "\" | <"> -// | "/" | "[" | "]" | "?" | "=" -// | "{" | "}" | SP | HT - - .initbss 300,_init_kHttpToken -kHttpToken: - .zero 256 - .endobj kHttpToken,globl - .previous - - .initro 300,_init_kHttpToken -kHttpToken.rom: - .byte 33,0 # 00-20 ∅-␠ - .byte 1,1 # 21-21 !-! - .byte 1,0 # 22-22 “-“ - .byte 5,1 # 23-27 #-‘ - .byte 2,0 # 28-29 (-) - .byte 2,1 # 2a-2b *-+ - .byte 1,0 # 2c-2c ,-, - .byte 2,1 # 2d-2e --. - .byte 1,0 # 2f-2f /-/ - .byte 10,1 # 30-39 0-9 - .byte 7,0 # 3a-40 :-@ - .byte 26,1 # 41-5a A-Z - .byte 3,0 # 5b-5d [-] - .byte 29,1 # 5e-7a ^-z - .byte 1,0 # 7b-7b {-{ - .byte 1,1 # 7c-7c |-| - .byte 1,0 # 7d-7d }-} - .byte 1,1 # 7e-7e ~-~ - .byte 129,0 # 7f-ff ⌂-λ - .byte 0,0 # terminator - .endobj kHttpToken.rom,globl - - .init.start 300,_init_kHttpToken - call rldecode - .init.end 300,_init_kHttpToken - -// 45 bytes total (18% original size) diff --git a/net/http/khttptoken.c b/net/http/khttptoken.c new file mode 100644 index 000000000..bc306d072 --- /dev/null +++ b/net/http/khttptoken.c @@ -0,0 +1,72 @@ +/*-*- mode:c;indent-tabs-mode:nil;c-basic-offset:2;tab-width:8;coding:utf-8 -*-│ +│vi: set net ft=c ts=2 sts=2 sw=2 fenc=utf-8 :vi│ +╞══════════════════════════════════════════════════════════════════════════════╡ +│ Copyright 2023 Justine Alexandra Roberts Tunney │ +│ │ +│ Permission to use, copy, modify, and/or distribute this software for │ +│ any purpose with or without fee is hereby granted, provided that the │ +│ above copyright notice and this permission notice appear in all copies. │ +│ │ +│ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL │ +│ WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED │ +│ WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE │ +│ AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL │ +│ DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR │ +│ PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER │ +│ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │ +│ PERFORMANCE OF THIS SOFTWARE. │ +╚─────────────────────────────────────────────────────────────────────────────*/ +#include "net/http/escape.h" + +// generated by: +// o//tool/build/xlat.com -TiC ' ()<>@,;:\"/[]?={}' -iskHttpToken +// +// present absent +// ──────────────── ──────────────── +// ∅☺☻♥♦♣♠•◘○◙♂♀♪♫☼ 0x00 +// ►◄↕‼¶§▬↨↑↓→←∟↔▲▼ 0x10 +// ! #$%&‘ *+ -. ␠ “ () , / 0x20 +// 0123456789 :;<=>⁇ 0x30 +// ABCDEFGHIJKLMNO @ 0x40 +// PQRSTUVWXYZ ^_ [⭝] 0x50 +// `abcdefghijklmno 0x60 +// pqrstuvwxyz | ~ { } ⌂ 0x70 +// ÇüéâäàåçêëèïîìÄÅ 0x80 +// ÉæÆôöòûùÿÖÜ¢£¥€ƒ 0x90 +// áíóúñѪº¿⌐¬½¼¡«» 0xa0 +// ░▒▓│┤╡╢╖╕╣║╗╝╜╛┐ 0xb0 +// └┴┬├─┼╞╟╚╔╩╦╠═╬╧ 0xc0 +// ╨╤╥╙╘╒╓╫╪┘┌█▄▌▐▀ 0xd0 +// αßΓπΣσμτΦΘΩδ∞φε∩ 0xe0 +// ≡±≥≤⌠⌡÷≈°∙×√ⁿ²■λ 0xf0 + +const char kHttpToken[256] = { + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 0x00 + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 0x10 + 0, 1, 0, 1, 1, 1, 1, 1, 0, 0, 1, 1, 0, 1, 1, 0, // 0x20 + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, // 0x30 + 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 0x40 + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 1, 1, // 0x50 + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 0x60 + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 0, 1, 0, // 0x70 + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 0x80 + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 0x90 + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 0xa0 + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 0xb0 + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 0xc0 + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 0xd0 + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 0xe0 + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 0xf0 +}; + +// @see RFC2616 +// CHAR = +// SP = +// HT = +// CTL = +// token = 1* +// separators = "(" | ")" | "<" | ">" | "@" +// | "," | ";" | ":" | "\" | <"> +// | "/" | "[" | "]" | "?" | "=" +// | "{" | "}" | SP | HT diff --git a/third_party/mbedtls/aesni.c b/third_party/mbedtls/aesni.c index 4acf62a86..d7242773b 100644 --- a/third_party/mbedtls/aesni.c +++ b/third_party/mbedtls/aesni.c @@ -15,9 +15,9 @@ │ See the License for the specific language governing permissions and │ │ limitations under the License. │ ╚─────────────────────────────────────────────────────────────────────────────*/ +#include "third_party/mbedtls/aesni.h" #include "libc/intrin/bits.h" #include "libc/str/str.h" -#include "third_party/mbedtls/aesni.h" #include "third_party/mbedtls/common.h" asm(".ident\t\"\\n\\n\ diff --git a/third_party/mbedtls/bigmul.c b/third_party/mbedtls/bigmul.c index 479241d7e..5ce485c8c 100644 --- a/third_party/mbedtls/bigmul.c +++ b/third_party/mbedtls/bigmul.c @@ -273,6 +273,7 @@ int mbedtls_mpi_mul_mpi(mbedtls_mpi *X, const mbedtls_mpi *A, return 0; } +#ifdef __x86_64__ if (!IsTiny() && i == j) { if (X->n < i * 2) { if ((ret = mbedtls_mpi_grow(X, i * 2))) return ret; @@ -293,6 +294,7 @@ int mbedtls_mpi_mul_mpi(mbedtls_mpi *X, const mbedtls_mpi *A, return 0; } } +#endif /* __x86_64__ */ mbedtls_mpi_init( &TA ); mbedtls_mpi_init( &TB ); @@ -310,9 +312,8 @@ int mbedtls_mpi_mul_mpi(mbedtls_mpi *X, const mbedtls_mpi *A, B = &TB; } if (!IsTiny() && - i >= 16 && i == j && !(i & (i - 1)) && - X86_HAVE(BMI2) && X86_HAVE(ADX) && - (K = malloc(i * 4 * sizeof(*K)))) { + i >= 16 && i == j && !(i & (i - 1)) && + (K = malloc(i * 4 * sizeof(*K)))) { Karatsuba(X->p, A->p, B->p, i, K); free(K); } else { diff --git a/third_party/mbedtls/config.h b/third_party/mbedtls/config.h index f134b956f..c337dfd99 100644 --- a/third_party/mbedtls/config.h +++ b/third_party/mbedtls/config.h @@ -103,7 +103,7 @@ * Hardens against against sbox side channels */ #define MBEDTLS_AESNI_C -#ifndef TINY +#if defined(__x86_64__) && !defined(TINY) #define MBEDTLS_HAVE_X86_64 #define MBEDTLS_HAVE_SSE2 #endif diff --git a/third_party/mbedtls/des.c b/third_party/mbedtls/des.c index 274150156..19775b766 100644 --- a/third_party/mbedtls/des.c +++ b/third_party/mbedtls/des.c @@ -15,12 +15,11 @@ │ See the License for the specific language governing permissions and │ │ limitations under the License. │ ╚─────────────────────────────────────────────────────────────────────────────*/ +#include "third_party/mbedtls/des.h" #include "libc/mem/mem.h" -#include "libc/mem/gc.internal.h" #include "libc/stdio/stdio.h" #include "libc/str/str.h" #include "third_party/mbedtls/common.h" -#include "third_party/mbedtls/des.h" #include "third_party/mbedtls/endian.h" #include "third_party/mbedtls/platform.h" @@ -831,14 +830,11 @@ static const unsigned char des3_test_cbc_enc[3][8] = }; #endif /* MBEDTLS_CIPHER_MODE_CBC */ -/* - * Checkup routine - */ -int mbedtls_des_self_test( int verbose ) +static int mbedtls_des_self_test_impl( int verbose, + mbedtls_des_context *ctx, + mbedtls_des3_context *ctx3 ) { int i, j, u, v, ret = 0; - mbedtls_des_context *ctx = gc(malloc(sizeof(mbedtls_des_context))); - mbedtls_des3_context *ctx3 = gc(malloc(sizeof(mbedtls_des3_context))); unsigned char buf[8]; #if defined(MBEDTLS_CIPHER_MODE_CBC) unsigned char prv[8]; @@ -1023,4 +1019,17 @@ exit: return( ret ); } +int mbedtls_des_self_test( int verbose ) +{ + int rc; + mbedtls_des_context *ctx; + mbedtls_des3_context *ctx3; + ctx = malloc( sizeof( mbedtls_des_context ) ); + ctx3 = malloc( sizeof( mbedtls_des3_context ) ); + rc = mbedtls_des_self_test_impl( verbose, ctx, ctx3 ); + free( ctx3 ); + free( ctx ); + return( rc ); +} + #endif /* MBEDTLS_SELF_TEST */ diff --git a/third_party/mbedtls/ecp384.c b/third_party/mbedtls/ecp384.c index 368c0dceb..fe103408e 100644 --- a/third_party/mbedtls/ecp384.c +++ b/third_party/mbedtls/ecp384.c @@ -17,7 +17,6 @@ │ PERFORMANCE OF THIS SOFTWARE. │ ╚─────────────────────────────────────────────────────────────────────────────*/ #include "libc/intrin/asan.internal.h" -#include "libc/mem/gc.h" #include "libc/nexgen32e/x86feature.h" #include "libc/runtime/runtime.h" #include "libc/str/str.h" @@ -187,10 +186,20 @@ mbedtls_p384_mul( uint64_t X[12], } else { - if( A == X ) A = _gc( memcpy( malloc( 6 * 8 ), A, 6 * 8 ) ); - if( B == X ) B = _gc( memcpy( malloc( 6 * 8 ), B, 6 * 8 ) ); + void *f = 0; + if( A == X ) + { + A = memcpy( malloc( 6 * 8 ), A, 6 * 8 ); + f = A; + } + else if( B == X ) + { + B = memcpy( malloc( 6 * 8 ), B, 6 * 8 ); + f = B; + } Mul( X, A, n, B, m ); mbedtls_platform_zeroize( X + n + m, (12 - n - m) * 8 ); + free( f ); } mbedtls_p384_mod( X ); } diff --git a/third_party/mbedtls/karatsuba.c b/third_party/mbedtls/karatsuba.c index c450ecf75..98b65ec3f 100644 --- a/third_party/mbedtls/karatsuba.c +++ b/third_party/mbedtls/karatsuba.c @@ -16,9 +16,11 @@ │ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │ │ PERFORMANCE OF THIS SOFTWARE. │ ╚─────────────────────────────────────────────────────────────────────────────*/ +#include "libc/nexgen32e/x86feature.h" #include "libc/runtime/runtime.h" #include "libc/str/str.h" #include "third_party/mbedtls/bignum_internal.h" +#include "third_party/mbedtls/math.h" #include "third_party/mbedtls/platform.h" forceinline int Cmp(uint64_t *a, uint64_t *b, size_t n) { @@ -37,6 +39,7 @@ forceinline int Cmp(uint64_t *a, uint64_t *b, size_t n) { forceinline bool Sub(uint64_t *C, uint64_t *A, uint64_t *B, size_t n) { bool cf; uint64_t c, i; +#ifdef __x86_64__ asm volatile("xor\t%1,%1\n\t" ".align\t16\n1:\t" "mov\t(%5,%3,8),%1\n\t" @@ -48,12 +51,18 @@ forceinline bool Sub(uint64_t *C, uint64_t *A, uint64_t *B, size_t n) { : "=@ccb"(cf), "=&r"(c), "+c"(n), "=r"(i) : "r"(C), "r"(A), "r"(B), "3"(0) : "cc", "memory"); +#else + for (cf = false, c = i = 0; i < n; ++i) { + SBB(C[i], A[i], B[i], cf, cf); + } +#endif return cf; } forceinline bool Add(uint64_t *C, uint64_t *A, uint64_t *B, size_t n) { bool cf; uint64_t c, i; +#ifdef __x86_64__ asm volatile("xor\t%1,%1\n\t" ".align\t16\n1:\t" "mov\t(%5,%3,8),%1\n\t" @@ -65,6 +74,11 @@ forceinline bool Add(uint64_t *C, uint64_t *A, uint64_t *B, size_t n) { : "=@ccc"(cf), "=&r"(c), "+c"(n), "=r"(i) : "r"(C), "r"(A), "r"(B), "3"(0) : "cc", "memory"); +#else + for (cf = false, c = i = 0; i < n; ++i) { + ADC(C[i], A[i], B[i], cf, cf); + } +#endif return cf; } @@ -80,7 +94,13 @@ void Karatsuba(uint64_t *C, uint64_t *A, uint64_t *B, size_t n, uint64_t *K) { uint64_t c, t; uint64_t *x, *y; if (n == 8) { - Mul8x8Adx(C, A, B); +#ifdef __x86_64__ + if (X86_HAVE(BMI2) && X86_HAVE(ADX)) { + Mul8x8Adx(C, A, B); + return; + } +#endif + Mul(C, A, 8, B, 8); return; } switch (Cmp(A, A + n / 2, n / 2) * 3 + Cmp(B + n / 2, B, n / 2)) { diff --git a/third_party/mbedtls/mbedtls.mk b/third_party/mbedtls/mbedtls.mk index 66b2c4265..9a900be40 100644 --- a/third_party/mbedtls/mbedtls.mk +++ b/third_party/mbedtls/mbedtls.mk @@ -61,13 +61,11 @@ o/$(MODE)/third_party/mbedtls/bigmul6.o: private \ OVERRIDE_CFLAGS += \ -O2 +ifeq ($(ARCH), x86_64) o/$(MODE)/third_party/mbedtls/shiftright-avx.o: private \ OVERRIDE_CFLAGS += \ -O3 -mavx - -o/$(MODE)/third_party/mbedtls/shiftright2-avx.o: private \ - OVERRIDE_CFLAGS += \ - -O3 -mavx +endif o/$(MODE)/third_party/mbedtls/zeroize.o: private \ OVERRIDE_CFLAGS += \ diff --git a/third_party/mbedtls/shiftright-avx.c b/third_party/mbedtls/shiftright-avx.c index fa0eb4756..03adb2c62 100644 --- a/third_party/mbedtls/shiftright-avx.c +++ b/third_party/mbedtls/shiftright-avx.c @@ -19,6 +19,8 @@ #include "third_party/mbedtls/bignum_internal.h" #include "third_party/mbedtls/platform.h" +#ifdef __x86_64__ + typedef uint64_t xmm_t __attribute__((__vector_size__(16), __aligned__(1))); void ShiftRightAvx(uint64_t *p, size_t n, unsigned char k) { @@ -49,3 +51,5 @@ void ShiftRightAvx(uint64_t *p, size_t n, unsigned char k) { p[0] = p[0] >> k | p1 << (64 - k); } } + +#endif /* __x86_64__ */ diff --git a/third_party/mbedtls/test/lib.h b/third_party/mbedtls/test/lib.h index 9c6e1576a..7c45d48d1 100644 --- a/third_party/mbedtls/test/lib.h +++ b/third_party/mbedtls/test/lib.h @@ -1,6 +1,5 @@ #ifndef COSMOPOLITAN_THIRD_PARTY_MBEDTLS_TEST_LIB_H_ #define COSMOPOLITAN_THIRD_PARTY_MBEDTLS_TEST_LIB_H_ -#include "libc/mem/gc.internal.h" #include "libc/str/str.h" #include "libc/x/x.h" #include "libc/x/xasprintf.h" diff --git a/third_party/mbedtls/test/test.mk b/third_party/mbedtls/test/test.mk index 6bdf465c8..4346f0cbd 100644 --- a/third_party/mbedtls/test/test.mk +++ b/third_party/mbedtls/test/test.mk @@ -131,8 +131,8 @@ o/$(MODE)/third_party/mbedtls/test/%.com.dbg: \ $(APE_NO_MODIFY_SELF) @$(APELINK) -o/$(MODE)/third_party/mbedtls/test/%.com.runs: o/$(MODE)/third_party/mbedtls/test/%.com - @$(COMPILE) -ACHECK -wtT$@ $< $(TESTARGS) +o/$(MODE)/third_party/mbedtls/test/%.com.runs: o/$(MODE)/third_party/mbedtls/test/%.com $(VM) + @$(COMPILE) -ACHECK -wtT$@ $(VM) $< $(TESTARGS) o/$(MODE)/third_party/mbedtls/test/lib.o: private \ OVERRIDE_CFLAGS += \ diff --git a/third_party/python/Include/ceval.h b/third_party/python/Include/ceval.h index 012ad1b4c..bb3ae0872 100644 --- a/third_party/python/Include/ceval.h +++ b/third_party/python/Include/ceval.h @@ -113,17 +113,15 @@ int _Py_CheckRecursiveCall(const char *); ({ \ int rc = 0; \ intptr_t rsp, bot; \ - if (!IsTiny()) { \ - if (IsModeDbg()) { \ - PyThreadState_GET()->recursion_depth++; \ - rc = _Py_CheckRecursiveCall(where); \ - } else { \ - rsp = (intptr_t)__builtin_frame_address(0); \ - bot = GetStackAddr() + 32768; \ - if (UNLIKELY(rsp < bot)) { \ - PyErr_Format(PyExc_MemoryError, "Stack overflow%s", where); \ - rc = -1; \ - } \ + if (IsModeDbg()) { \ + PyThreadState_GET()->recursion_depth++; \ + rc = _Py_CheckRecursiveCall(where); \ + } else { \ + rsp = (intptr_t)__builtin_frame_address(0); \ + bot = GetStackAddr() + 32768; \ + if (UNLIKELY(rsp < bot)) { \ + PyErr_Format(PyExc_MemoryError, "Stack overflow%s", where); \ + rc = -1; \ } \ } \ rc; \ diff --git a/tool/emacs/cosmo-stuff.el b/tool/emacs/cosmo-stuff.el index 2605aeeaf..26c1c5265 100644 --- a/tool/emacs/cosmo-stuff.el +++ b/tool/emacs/cosmo-stuff.el @@ -477,9 +477,9 @@ (cond ((eq arg 9) (cosmo--assembly 1 "V=1 OVERRIDE_COPTS='-w -fverbose-asm -fsanitize=undefined -fno-sanitize=null -fno-sanitize=alignment -fno-sanitize=pointer-overflow'")) - ((not (eq 0 (logand 8 arg))) - (cosmo--assembly (setq arg (logand (lognot 8))) - "V=1 OVERRIDE_COPTS='-w -fverbose-asm -fsanitize=address'")) + ;; ((not (eq 0 (logand 8 arg))) + ;; (cosmo--assembly (setq arg (logand (lognot 8))) + ;; "V=1 OVERRIDE_COPTS='-w -fverbose-asm -fsanitize=address'")) (t (cosmo--assembly arg "V=1 OVERRIDE_COPTS='-w ' CPPFLAGS=''")))) (defun cosmo-assembly-native (arg) diff --git a/tool/viz/lib/thunks/expect_matrixeq.S b/tool/viz/lib/thunks/expect_matrixeq.S deleted file mode 100644 index 1ea6332c2..000000000 --- a/tool/viz/lib/thunks/expect_matrixeq.S +++ /dev/null @@ -1,28 +0,0 @@ -/*-*- mode:unix-assembly; indent-tabs-mode:t; tab-width:8; coding:utf-8 -*-│ -│vi: set et ft=asm ts=8 tw=8 fenc=utf-8 :vi│ -╞══════════════════════════════════════════════════════════════════════════════╡ -│ Copyright 2020 Justine Alexandra Roberts Tunney │ -│ │ -│ Permission to use, copy, modify, and/or distribute this software for │ -│ any purpose with or without fee is hereby granted, provided that the │ -│ above copyright notice and this permission notice appear in all copies. │ -│ │ -│ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL │ -│ WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED │ -│ WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE │ -│ AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL │ -│ DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR │ -│ PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER │ -│ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │ -│ PERFORMANCE OF THIS SOFTWARE. │ -╚─────────────────────────────────────────────────────────────────────────────*/ -#include "libc/macros.internal.h" - - .text.unlikely -testlib_showerror_expect_matrixeq: - push $FALSE - pushstr "EXPECT_MATRIXEQ" - pushstr "=" - jmp testlib_showerror_jump - .endfn testlib_showerror_expect_matrixeq,globl,hidden - .previous