os

An operating system
git clone https://erai.gay/code/os/
Log | Files | Refs | README | LICENSE

commit 356c1d0779047abe6a9e409b90691076c9bdd46c
parent f045ba0b24373fd73235e50c374753425a4ee167
Author: erai <erai@omiltem.net>
Date:   Wed, 23 Apr 2025 02:54:20 -0400

fix whitespace

Diffstat:
Mas.om | 20++++++++++----------
Mcc1.om | 42+++++++++++++++++++++---------------------
Mcc4.om | 20++++++++++----------
Mchacha20.om | 8++++----
Med25519.om | 2+-
Mir.om | 8++++----
Mircout.om | 20++++++++++----------
Mkernel.om | 12++++++------
Mlalr.om | 190++++++++++++++++++++++++++++++++++++++++----------------------------------------
Mlexer.om | 4++--
Mpeg.om | 8++++----
Msshd.om | 4++--
12 files changed, 169 insertions(+), 169 deletions(-)

diff --git a/as.om b/as.om @@ -35,22 +35,22 @@ enum { } enum { - CC_O = 0x00, + CC_O = 0x00, CC_NO = 0x01, - CC_B = 0x02, + CC_B = 0x02, CC_AE = 0x03, - CC_E = 0x04, + CC_E = 0x04, CC_NE = 0x05, CC_BE = 0x06, - CC_A = 0x07, - CC_S = 0x08, + CC_A = 0x07, + CC_S = 0x08, CC_NS = 0x09, - CC_P = 0x0a, + CC_P = 0x0a, CC_NP = 0x0b, - CC_L = 0x0c, + CC_L = 0x0c, CC_GE = 0x0d, CC_LE = 0x0e, - CC_G = 0x0f, + CC_G = 0x0f, } enum { @@ -212,7 +212,7 @@ func setup_assembler(a: *alloc): *assembler { c = alloc(a, sizeof(*c)) as *assembler; c.a = a; c.out = nil; - c.at = 160; // elf header + program header + multiboot header + c.at = 160; // elf header + program header + multiboot header c.text = nil; c.text_end = nil; c.bits32 = 0; @@ -463,7 +463,7 @@ func as_blob(c: *assembler, s: *byte, slen: int): *label { return b.label; } else if dir > 0 { link = &b.left; - } else { // dir < 0 + } else { // dir < 0 link = &b.right; } } diff --git a/cc1.om b/cc1.om @@ -1871,31 +1871,31 @@ func emit_builtin(c: *compiler) { add_symbol(c.s, d.name, d.func_label); as_opr(c.s, OP_PUSHR, R_RBP); as_modrr(c.s, OP_MOVE, R_RBP, R_RSP); - // es ds fs gs - as_modrr(c.s, OP_WRSR, R_ES, R_RSI); - as_modrr(c.s, OP_WRSR, R_DS, R_RSI); - as_modrr(c.s, OP_WRSR, R_FS, R_RSI); - as_modrr(c.s, OP_WRSR, R_GS, R_RSI); - // ss - as_opr(c.s, OP_PUSHR, R_RSI); + // es ds fs gs + as_modrr(c.s, OP_WRSR, R_ES, R_RSI); + as_modrr(c.s, OP_WRSR, R_DS, R_RSI); + as_modrr(c.s, OP_WRSR, R_FS, R_RSI); + as_modrr(c.s, OP_WRSR, R_GS, R_RSI); + // ss + as_opr(c.s, OP_PUSHR, R_RSI); // rsp as_opr(c.s, OP_PUSHR, R_RBP); - // flags + // flags as_op(c.s, OP_PUSHF); // cs - as_opr(c.s, OP_PUSHR, R_RDI); + as_opr(c.s, OP_PUSHR, R_RDI); // rip - as_op(c.s, OP_CALL); - as_emit(c.s, 5); - as_emit(c.s, 0); - as_emit(c.s, 0); - as_emit(c.s, 0); - as_op(c.s, OP_JMP); - as_emit(c.s, 2); - as_emit(c.s, 0); - as_emit(c.s, 0); - as_emit(c.s, 0); - as_op(c.s, OP_IRETQ); + as_op(c.s, OP_CALL); + as_emit(c.s, 5); + as_emit(c.s, 0); + as_emit(c.s, 0); + as_emit(c.s, 0); + as_op(c.s, OP_JMP); + as_emit(c.s, 2); + as_emit(c.s, 0); + as_emit(c.s, 0); + as_emit(c.s, 0); + as_op(c.s, OP_IRETQ); as_opr(c.s, OP_POPR, R_RBP); as_op(c.s, OP_RET); } @@ -1970,7 +1970,7 @@ func emit_builtin(c: *compiler) { if (d.func_defined && !d.func_label.fixed) { fixup_label(c.s, d.func_label); add_symbol(c.s, d.name, d.func_label); - emit_isr(c); + emit_isr(c); as_op(c.s, OP_RET); } diff --git a/cc4.om b/cc4.om @@ -64,7 +64,7 @@ lexer { DECIMAL = ["0-9"] (["0-9_"]* ["0-9"])?; STRING = "\"" ("\\" . | ["^\\\x22"])* "\""; CHAR = "'" ("\\" . | ["^\\\x27"])* "'"; - CHARSET = "[\"" (["^\"\\"]|"\\".)* "\"]"; + CHARSET = "[\"" (["^\"\\"] | "\\".)* "\"]"; SPACE = [" \r\n\t"]; COMMENT = "//" ["^\n"]* "\n"; @@ -138,22 +138,22 @@ lalr { l_expr = l_bool_expr; - l_bool_op = AND_THEN|OR_ELSE; + l_bool_op = AND_THEN | OR_ELSE; l_bool_expr = l_bool_expr l_bool_op l_comp_expr | l_comp_expr; - l_comp_op = LE|GE|LT|GT|EQ|NE; + l_comp_op = LE | GE | LT | GT | EQ | NE; l_comp_expr = l_add_expr l_comp_op l_add_expr | l_add_expr; - l_add_op = PLUS|MINUS|PIPE|XOR; + l_add_op = PLUS | MINUS | PIPE | XOR; l_add_expr = l_add_expr l_add_op l_mul_expr | l_mul_expr; - l_mul_op = STAR|SLASH|MOD|AMP; + l_mul_op = STAR | SLASH | MOD | AMP; l_mul_expr = l_mul_expr l_mul_op l_shift_expr | l_shift_expr; - l_shift_op = LEFT_SHIFT|RIGHT_SHIFT; + l_shift_op = LEFT_SHIFT | RIGHT_SHIFT; l_shift_expr = l_shift_expr l_shift_op l_unary_expr | l_unary_expr; - l_unary_op = AMP|STAR|PLUS|MINUS|NOT|BANG; + l_unary_op = AMP | STAR | PLUS | MINUS | NOT | BANG; l_unary_expr = l_unary_op l_unary_expr | l_post_expr; l_index_expr = LEFT_SQUARE l_expr RIGHT_SQUARE; @@ -171,15 +171,15 @@ lalr { l_sizeof_expr = SIZEOF LEFT_PAREN l_expr RIGHT_PAREN; l_lexer_primary = LEFT_PAREN l_lexer_pattern RIGHT_PAREN | DOT | STRING | CHARSET; - l_lexer_op = STAR|PLUS|QMARK; + l_lexer_op = STAR | PLUS | QMARK; l_lexer_suffix = l_lexer_suffix l_lexer_op | l_lexer_primary; - l_lexer_alternative = l_lexer_suffix l_lexer_alternative| l_lexer_suffix; + l_lexer_alternative = l_lexer_suffix l_lexer_alternative | l_lexer_suffix; l_lexer_pattern = l_lexer_alternative PIPE l_lexer_pattern | l_lexer_alternative; l_lexer_rule = IDENT ASSIGN l_lexer_pattern SEMI; l_lexer_rule_list = l_lexer_rule_list l_lexer_rule | l_lexer_rule; l_lexer_grammar = LEX LEFT_BRACE l_lexer_rule_list RIGHT_BRACE; - l_lalr_primary = IDENT | l_compound_stmt; + l_lalr_primary = IDENT {} | l_compound_stmt; l_lalr_alternative = l_lalr_primary l_lalr_alternative | ; l_lalr_pattern = l_lalr_pattern PIPE l_lalr_alternative | l_lalr_alternative; l_lalr_rule = IDENT ASSIGN l_lalr_pattern SEMI; diff --git a/chacha20.om b/chacha20.om @@ -118,14 +118,14 @@ func chacha20_block(block: *byte, key: *byte, counter: int, nonce: *byte) { if i == 10 { break; } - chacha20_qround(&s[0], &s[4], &s[8], &s[12]); - chacha20_qround(&s[1], &s[5], &s[9], &s[13]); + chacha20_qround(&s[0], &s[4], &s[8], &s[12]); + chacha20_qround(&s[1], &s[5], &s[9], &s[13]); chacha20_qround(&s[2], &s[6], &s[10], &s[14]); chacha20_qround(&s[3], &s[7], &s[11], &s[15]); chacha20_qround(&s[0], &s[5], &s[10], &s[15]); chacha20_qround(&s[1], &s[6], &s[11], &s[12]); - chacha20_qround(&s[2], &s[7], &s[8], &s[13]); - chacha20_qround(&s[3], &s[4], &s[9], &s[14]); + chacha20_qround(&s[2], &s[7], &s[8], &s[13]); + chacha20_qround(&s[3], &s[4], &s[9], &s[14]); i = i + 1; } diff --git a/ed25519.om b/ed25519.om @@ -251,7 +251,7 @@ func ed25519_mul(r: *int, a: *int, b: *int) { r[7] = x[7]; } -func ed25519_inv(r: *int, a: *int) { +func ed25519_inv(r: *int, a: *int) { var _x: _ed25519_point; var x: *int; var i: int; diff --git a/ir.om b/ir.om @@ -66,7 +66,7 @@ struct irblock { ops_len: int; ops_cap: int; done: int; - back: **irblock; // WARNING: if the flow graph changes, this is stale. + back: **irblock; // WARNING: if the flow graph changes, this is stale. back_len: int; out: *irblock; alt: *irblock; @@ -321,7 +321,7 @@ func irfind_var(ic: *irfunc, name: *byte): **irvar { return link; } else if dir < 0 { link = &v.left; - } else { // dir > 0 + } else { // dir > 0 link = &v.right; } } @@ -1037,7 +1037,7 @@ func irfind_block(ic: *irfunc, name: *byte, make: int): *irblock { return l.block; } else if dir < 0 { link = &l.left; - } else { // dir > 0 + } else { // dir > 0 link = &l.right; } } @@ -1471,7 +1471,7 @@ func emit_kstart(c: *assembler) { as_jmp(c, OP_JCC + CC_NE, hang); // Setup an initial stack - as_modri(c, OP_MOVI, R_RSP, 0x00300000); // FIXME bss + as_modri(c, OP_MOVI, R_RSP, 0x00300000); // FIXME bss // Align stack to page as_modri(c, OP_ANDI, R_RSP, -0x1000); diff --git a/ircout.om b/ircout.om @@ -315,7 +315,7 @@ func ircblock(c: *compiler, ic: *irfunc, ib: *irblock) { } func ircline(c: *compiler, op: *irop) { - return; // Try to minimize the output, don't output lines. + return; // Try to minimize the output, don't output lines. if !op.filename { return; @@ -404,15 +404,15 @@ func ircop(c: *compiler, ic: *irfunc, ib: *irblock, op: *irop, pri: int) { var mypri: int; // C Operator Precedence - // 1 call() - // 2 ! ~ * - & (cast) - // 3 * / % - // 4 + - - // 5 << >> - // 6 < <= > >= - // 7 == != - // 8 & - // 9 | + // 1 call() + // 2 ! ~ * - & (cast) + // 3 * / % + // 4 + - + // 5 << >> + // 6 < <= > >= + // 7 == != + // 8 & + // 9 | kind = op.kind; if kind == IOP_VAR || kind == IOP_VARREF { mypri = 2; diff --git a/kernel.om b/kernel.om @@ -405,7 +405,7 @@ func find_rsdt(): int { v = ptov(p); if p + 20 >= 0xfffff { - return 0; + return 0; } if !memcmp(v, "RSD PTR ", 8) { @@ -3529,7 +3529,7 @@ struct vfile { } enum { - S_IFMT = 0xf000, + S_IFMT = 0xf000, S_IFDIR = 0x4000, S_IFREG = 0x8000, } @@ -4790,8 +4790,8 @@ func _kstart(mb: int) { var idt_size: int; var gdt: *int; var gdt_size: int; - var rsdt: int; - var mcfg: int; + var rsdt: int; + var mcfg: int; var pcip: int; var pci: *byte; var flag: int; @@ -4980,13 +4980,13 @@ func _kstart(mb: int) { read_rtc(); sti(); - // Find ACPI tables + // Find ACPI tables rsdt = find_rsdt(); if !rsdt { kdie("No rsdt?\n"); } - mcfg = find_acpi(rsdt, "MCFG"); + mcfg = find_acpi(rsdt, "MCFG"); if !mcfg { kdie("No mcfg?\n"); } diff --git a/lalr.om b/lalr.om @@ -1345,33 +1345,33 @@ func lalr_codegen(lc: *lalr_compiler) { } func lalr_compile_get_prod_name(lc: *lalr_compiler) { - var arg1_type: *type; - var args_type: *type; - var ret_type: *type; - var func_type: *type; - var ic: *irfunc; - var o: *irop; - var a: *irop; - var b: *irop; - var this: *irblock; - var next: *irblock; - var ident: *peg_node; - var i: int; + var arg1_type: *type; + var args_type: *type; + var ret_type: *type; + var func_type: *type; + var ic: *irfunc; + var o: *irop; + var a: *irop; + var b: *irop; + var this: *irblock; + var next: *irblock; + var ident: *peg_node; + var i: int; - arg1_type = mktype0(lc.c, TY_INT); - args_type = mktype1(lc.c, TY_ARG, arg1_type); + arg1_type = mktype0(lc.c, TY_INT); + args_type = mktype1(lc.c, TY_ARG, arg1_type); - ret_type = mktype0(lc.c, TY_BYTE); - ret_type = mktype1(lc.c, TY_PTR, ret_type); + ret_type = mktype0(lc.c, TY_BYTE); + ret_type = mktype1(lc.c, TY_PTR, ret_type); - func_type = mktype2(lc.c, TY_FUNC, ret_type, args_type); + func_type = mktype2(lc.c, TY_FUNC, ret_type, args_type); - ic = mkirfunc(lc.c, "get_prod_name"); + ic = mkirfunc(lc.c, "get_prod_name"); - iraddarg(ic, "tag", arg1_type); + iraddarg(ic, "tag", arg1_type); - i = 1; - loop { + i = 1; + loop { if i == lc.prod_len { break; } @@ -1381,67 +1381,67 @@ func lalr_compile_get_prod_name(lc: *lalr_compiler) { continue; } - this = mkirblock(ic); - next = mkirblock(ic); + this = mkirblock(ic); + next = mkirblock(ic); - a = mkirop(ic, IOP_VAR, nil, nil); - a.n = 0; - b = mkirconst(ic, i); - o = mkirop(ic, IOP_EQ, a, b); - irbranch(ic, o, next, this); - o = mkirstr(ic, lc.prod[i].name, strlen(lc.prod[i].name)); - irreturn(ic, o); + a = mkirop(ic, IOP_VAR, nil, nil); + a.n = 0; + b = mkirconst(ic, i); + o = mkirop(ic, IOP_EQ, a, b); + irbranch(ic, o, next, this); + o = mkirstr(ic, lc.prod[i].name, strlen(lc.prod[i].name)); + irreturn(ic, o); - irjump(ic, next, next); + irjump(ic, next, next); - i = i + 1; - } + i = i + 1; + } - o = mkirconst(ic, 0); - irreturn(ic, o); + o = mkirconst(ic, 0); + irreturn(ic, o); - define_ir_func(lc.c, ic, func_type); + define_ir_func(lc.c, ic, func_type); } func lalr_output(lc: *lalr_compiler) { - var ic: *irfunc; - var o: *irop; - var ret_type: *type; - var func_type: *type; + var ic: *irfunc; + var o: *irop; + var ret_type: *type; + var func_type: *type; - ret_type = mktype0(lc.c, TY_INT); - ret_type = mktype1(lc.c, TY_PTR, ret_type); + ret_type = mktype0(lc.c, TY_INT); + ret_type = mktype1(lc.c, TY_PTR, ret_type); - func_type = mktype2(lc.c, TY_FUNC, ret_type, nil); + func_type = mktype2(lc.c, TY_FUNC, ret_type, nil); - ic = mkirfunc(lc.c, "get_act_table"); - o = mkirstr(ic, lc.act_table as *byte, lc.act_table_len); - irreturn(ic, o); - define_ir_func(lc.c, ic, func_type); + ic = mkirfunc(lc.c, "get_act_table"); + o = mkirstr(ic, lc.act_table as *byte, lc.act_table_len); + irreturn(ic, o); + define_ir_func(lc.c, ic, func_type); - ic = mkirfunc(lc.c, "get_goto_table"); - o = mkirstr(ic, lc.goto_table as *byte, lc.goto_table_len); - irreturn(ic, o); - define_ir_func(lc.c, ic, func_type); + ic = mkirfunc(lc.c, "get_goto_table"); + o = mkirstr(ic, lc.goto_table as *byte, lc.goto_table_len); + irreturn(ic, o); + define_ir_func(lc.c, ic, func_type); - ret_type = mktype0(lc.c, TY_INT); + ret_type = mktype0(lc.c, TY_INT); - func_type = mktype2(lc.c, TY_FUNC, ret_type, nil); + func_type = mktype2(lc.c, TY_FUNC, ret_type, nil); - ic = mkirfunc(lc.c, "get_prod_len"); - o = mkirconst(ic, lc.prod_len); - irreturn(ic, o); - define_ir_func(lc.c, ic, func_type); + ic = mkirfunc(lc.c, "get_prod_len"); + o = mkirconst(ic, lc.prod_len); + irreturn(ic, o); + define_ir_func(lc.c, ic, func_type); - ic = mkirfunc(lc.c, "get_term_len"); - o = mkirconst(ic, lc.term_len); - irreturn(ic, o); - define_ir_func(lc.c, ic, func_type); + ic = mkirfunc(lc.c, "get_term_len"); + o = mkirconst(ic, lc.term_len); + irreturn(ic, o); + define_ir_func(lc.c, ic, func_type); - ic = mkirfunc(lc.c, "get_call_len"); - o = mkirconst(ic, lc.action_len); - irreturn(ic, o); - define_ir_func(lc.c, ic, func_type); + ic = mkirfunc(lc.c, "get_call_len"); + o = mkirconst(ic, lc.action_len); + irreturn(ic, o); + define_ir_func(lc.c, ic, func_type); lalr_compile_get_call_table(lc); @@ -1449,36 +1449,36 @@ func lalr_output(lc: *lalr_compiler) { } func lalr_compile_get_call_table(lc: *lalr_compiler) { - var arg1_type: *type; - var args_type: *type; - var ret_type: *type; - var func_type: *type; - var ic: *irfunc; - var o: *irop; - var a: *irop; - var b: *irop; - var this: *irblock; - var next: *irblock; - var ident: *peg_node; - var i: int; + var arg1_type: *type; + var args_type: *type; + var ret_type: *type; + var func_type: *type; + var ic: *irfunc; + var o: *irop; + var a: *irop; + var b: *irop; + var this: *irblock; + var next: *irblock; + var ident: *peg_node; + var i: int; var v: *irvar; - arg1_type = mktype0(lc.c, TY_VOID); - arg1_type = mktype1(lc.c, TY_PTR, arg1_type); - args_type = mktype1(lc.c, TY_ARG, arg1_type); - ret_type = mktype0(lc.c, TY_VOID); - func_type = mktype2(lc.c, TY_FUNC, ret_type, args_type); - arg1_type = mktype1(lc.c, TY_PTR, func_type); - args_type = mktype1(lc.c, TY_ARG, arg1_type); - ret_type = mktype0(lc.c, TY_VOID); - func_type = mktype2(lc.c, TY_FUNC, ret_type, args_type); + arg1_type = mktype0(lc.c, TY_VOID); + arg1_type = mktype1(lc.c, TY_PTR, arg1_type); + args_type = mktype1(lc.c, TY_ARG, arg1_type); + ret_type = mktype0(lc.c, TY_VOID); + func_type = mktype2(lc.c, TY_FUNC, ret_type, args_type); + arg1_type = mktype1(lc.c, TY_PTR, func_type); + args_type = mktype1(lc.c, TY_ARG, arg1_type); + ret_type = mktype0(lc.c, TY_VOID); + func_type = mktype2(lc.c, TY_FUNC, ret_type, args_type); - ic = mkirfunc(lc.c, "get_call_table"); + ic = mkirfunc(lc.c, "get_call_table"); - v = iraddarg(ic, "t", arg1_type); + v = iraddarg(ic, "t", arg1_type); - i = 0; - loop { + i = 0; + loop { if i == lc.action_len { break; } @@ -1491,13 +1491,13 @@ func lalr_compile_get_call_table(lc: *lalr_compiler) { o = mkirop(ic, IOP_STORE, a, b); o.t = arg1_type.val; iraddop(ic, o); - i = i + 1; - } + i = i + 1; + } - o = mkirconst(ic, 0); - irreturn(ic, o); + o = mkirconst(ic, 0); + irreturn(ic, o); - define_ir_func(lc.c, ic, func_type); + define_ir_func(lc.c, ic, func_type); } func get_act_table(): *int; diff --git a/lexer.om b/lexer.om @@ -978,7 +978,7 @@ func dfamin_split(ctx: *dfamin, p: *dfaset, s: *dfaset, ch: int) { d = p.ind[i]; e = d.link[ch]; - if e && ctx.sets[e.mark - 1] == s { + if e && ctx.sets[e.mark - 1] == s { k = k + 1; } @@ -1002,7 +1002,7 @@ func dfamin_split(ctx: *dfamin, p: *dfaset, s: *dfaset, ch: int) { d = p.ind[i]; e = d.link[ch]; - if e && ctx.sets[e.mark - 1] == s { + if e && ctx.sets[e.mark - 1] == s { p.ind[k] = d; k = k + 1; } else { diff --git a/peg.om b/peg.om @@ -364,7 +364,7 @@ func translate_pattern(c: *peg_compiler, ic: *irfunc, fail: *irblock, n: *peg_no var out: *irblock; loop { - if n.tag == P_peg_pattern { // A sequence of alternatives + if n.tag == P_peg_pattern { // A sequence of alternatives d = n.child; if !d.next { translate_pattern(c, ic, fail, d); @@ -412,7 +412,7 @@ func translate_pattern(c: *peg_compiler, ic: *irfunc, fail: *irblock, n: *peg_no a = mkirfuncref(ic, "commit"); ircall(ic, a, 1); } - } else if n.tag == P_peg_alternative { // A sequence of concatenations + } else if n.tag == P_peg_alternative { // A sequence of concatenations d = n.child; translate_pattern(c, ic, fail, d); d = d.next; @@ -425,7 +425,7 @@ func translate_pattern(c: *peg_compiler, ic: *irfunc, fail: *irblock, n: *peg_no d = d.next; } - } else if n.tag == P_peg_lookahead { // An and or a not pattern that does not consume + } else if n.tag == P_peg_lookahead { // An and or a not pattern that does not consume look = decode_look(n); d = n.child; if d.tag == P_peg_lookop { @@ -503,7 +503,7 @@ func translate_pattern(c: *peg_compiler, ic: *irfunc, fail: *irblock, n: *peg_no } else { die("invalid lookop"); } - } else if n.tag == P_peg_suffix { // Repetition operator + } else if n.tag == P_peg_suffix { // Repetition operator count = decode_count(n); if count == ZERO_OR_ONE { // choice(c); diff --git a/sshd.om b/sshd.om @@ -108,7 +108,7 @@ func read_frame(ctx: *sshd_ctx) { nonce = (&_nonce) as *byte; mackey = (&_mackey) as *byte; - mac = (&_mac) as *byte; + mac = (&_mac) as *byte; if read_fill(ctx.fd, ctx.buf, 4) != 0 { die("truncated"); @@ -1356,7 +1356,7 @@ func dosession(ctx: *sshd_ctx) { var scf: ssh_channel_failure; decode_channel_open(&cco, ctx); - if !ssh_streq(&cco.channel_type, "session") || cco.channel != 0 { + if !ssh_streq(&cco.channel_type, "session") || cco.channel != 0 { die("not session"); }