Get MbedTLS and its unit tests passing AARCH64

This commit is contained in:
Justine Tunney 2023-05-11 21:53:15 -07:00
parent 5e2f7f7ced
commit 4edbc98811
No known key found for this signature in database
GPG key ID: BE714B4575D6E328
37 changed files with 632 additions and 725 deletions

View file

@ -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 */

View file

@ -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
////////////////////////////////////////////////////////////////////////////////

View file

@ -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) {

View file

@ -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"))) {

View file

@ -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);
}

View file

@ -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); \

View file

@ -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 \

View file

@ -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 \

View file

@ -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)

View file

@ -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
};

View file

@ -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)

View file

@ -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
};

View file

@ -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)

60
net/http/kescapeip.c Normal file
View file

@ -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
};

View file

@ -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)

60
net/http/kescapeparam.c Normal file
View file

@ -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
};

View file

@ -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)

60
net/http/kescapepath.c Normal file
View file

@ -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
};

View file

@ -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)

60
net/http/kescapesegment.c Normal file
View file

@ -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
};

View file

@ -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)

60
net/http/khostchars.c Normal file
View file

@ -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
};

View file

@ -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 = <any US-ASCII character (octets 0 - 127)>
// SP = <US-ASCII SP, space (32)>
// HT = <US-ASCII HT, horizontal-tab (9)>
// CTL = <any US-ASCII control character
// (octets 0 - 31) and DEL (127)>
// token = 1*<any CHAR except CTLs or separators>
// 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)

72
net/http/khttptoken.c Normal file
View file

@ -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 = <any US-ASCII character (octets 0 - 127)>
// SP = <US-ASCII SP, space (32)>
// HT = <US-ASCII HT, horizontal-tab (9)>
// CTL = <any US-ASCII control character
// (octets 0 - 31) and DEL (127)>
// token = 1*<any CHAR except CTLs or separators>
// separators = "(" | ")" | "<" | ">" | "@"
// | "," | ";" | ":" | "\" | <">
// | "/" | "[" | "]" | "?" | "="
// | "{" | "}" | SP | HT

View file

@ -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\

View file

@ -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 {

View file

@ -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

View file

@ -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 */

View file

@ -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 );
}

View file

@ -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)) {

View file

@ -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 += \

View file

@ -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__ */

View file

@ -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"

View file

@ -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 += \

View file

@ -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; \

View file

@ -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)

View file

@ -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