hare

The Hare programming language
git clone https://git.torresjrjr.com/hare.git
Log | Files | Refs | README | LICENSE

commit c66756b8e192480a8d837f60fcd4dc9a57aeac79
parent f3bd0a8b6b24d788f5fcd090a937fbb8ebd4b926
Author: Drew DeVault <sir@cmpwn.com>
Date:   Wed, 10 Feb 2021 14:15:27 -0500

all: style fixes

Diffstat:
Mascii/ctype.ha | 40++++++++++++++++++++--------------------
Mbytes/copy.ha | 6+++---
Mbytes/equal.ha | 12++++++------
Mbytes/index.ha | 28++++++++++++++--------------
Mbytes/reverse.ha | 16++++++++--------
Mbytes/tokenize.ha | 30+++++++++++++++---------------
Mencoding/utf8/decode.ha | 36+++++++++++++++---------------------
Mencoding/utf8/encode.ha | 40++++++++++++++++++++--------------------
Mencoding/utf8/rune.ha | 22+++++++++++-----------
Mfmt/fmt.ha | 6+++---
Mio/+test/copy.ha | 28++++++++++++++--------------
Mio/+test/limit.ha | 14+++++++-------
Mio/+test/stream.ha | 2+-
Mio/copy.ha | 2+-
Mio/println.ha | 4++--
Mio/types.ha | 6+++---
Mos/+linux/environ.ha | 9++++-----
Mos/+linux/fdstream.ha | 10+++++-----
Mos/exec/+linux.ha | 10+++++-----
Mrt/+linux/+aarch64.ha | 4++--
Mrt/+linux/+x86_64.ha | 4++--
Mrt/+linux/abort.ha | 2+-
Mrt/+linux/env.ha | 2+-
Mrt/+linux/segmalloc.ha | 2+-
Mrt/+linux/start.ha | 6+++---
Mrt/+linux/stat.ha | 8++++----
Mrt/+linux/syscallno+aarch64.ha | 584++++++++++++++++++++++++++++++++++++++++----------------------------------------
Mrt/+linux/syscallno+x86_64.ha | 692++++++++++++++++++++++++++++++++++++++++----------------------------------------
Mrt/+linux/syscalls.ha | 8++++----
Mrt/+linux/types.ha | 104++++++++++++++++++++++++++++++++++++++++----------------------------------------
Mrt/+test/start.ha | 18+++++++++---------
Mrt/+test/ztos.ha | 30+++++++++++++++---------------
Mrt/ensure.ha | 4++--
Mrt/jmp.ha | 2+-
Mrt/malloc.ha | 42+++++++++++++++++++-----------------------
Mrt/memcpy.ha | 2+-
Mrt/memset.ha | 2+-
Mrt/start.ha | 4++--
Mrt/strcmp.ha | 2+-
Mstrconv/itos.ha | 48++++++++++++++++++++++--------------------------
Mstrconv/stoi.ha | 8++++----
Mstrconv/stou.ha | 23+++++++++++------------
Mstrconv/utos.ha | 37++++++++++++++++---------------------
Mstrings/concat.ha | 10+++++-----
Mstrings/cstrings.ha | 4++--
Mstrings/dup.ha | 6+++---
Mstrings/iter.ha | 12++++++------
Mstrings/sub.ha | 10+++++-----
Mstrings/suffix.ha | 4++--
Mstrings/tokenize.ha | 8++++----
Mtypes/limits.ha | 32++++++++++++++++----------------
51 files changed, 1012 insertions(+), 1033 deletions(-)

diff --git a/ascii/ctype.ha b/ascii/ctype.ha @@ -1,11 +1,11 @@ -def U: u8 = 0o1u8; -def L: u8 = 0o2u8; -def N: u8 = 0o4u8; -def S: u8 = 0o10u8; -def P: u8 = 0o20u8; -def C: u8 = 0o40u8; -def B: u8 = 0o100u8; -def X: u8 = 0o200u8; +def U: u8 = 0o1; +def L: u8 = 0o2; +def N: u8 = 0o4; +def S: u8 = 0o10; +def P: u8 = 0o20; +def C: u8 = 0o40; +def B: u8 = 0o100; +def X: u8 = 0o200; // LUT of bitfields with character attributes const cclass: []u8 = [ @@ -30,50 +30,50 @@ const cclass: []u8 = [ // True if an ASCII character is a letter export fn isalpha(c: rune) bool = - if (!isascii(c)) false else cclass[c: u32]&(U|L) > 0u8; + if (!isascii(c)) false else cclass[c: u32]&(U|L) > 0; // True if an ASCII character is uppercase export fn isupper(c: rune) bool = - if (!isascii(c)) false else cclass[c: u32]&U > 0u8; + if (!isascii(c)) false else cclass[c: u32]&U > 0; // True if an ASCII character is lowercase export fn islower(c: rune) bool = - if (!isascii(c)) false else cclass[c: u32]&L > 0u8; + if (!isascii(c)) false else cclass[c: u32]&L > 0; // True if an ASCII character is a digit export fn isdigit(c: rune) bool = - if (!isascii(c)) false else cclass[c: u32]&N > 0u8; + if (!isascii(c)) false else cclass[c: u32]&N > 0; // True if an ASCII character is a hexadecimal digit export fn isxdigit(c: rune) bool = - if (!isascii(c)) false else cclass[c: u32]&X > 0u8; + if (!isascii(c)) false else cclass[c: u32]&X > 0; // True if an ASCII character is a space. export fn isspace(c: rune) bool = - if (!isascii(c)) false else cclass[c: u32]&S > 0u8; + if (!isascii(c)) false else cclass[c: u32]&S > 0; // True if an ASCII character is punctuation. export fn ispunct(c: rune) bool = - if (!isascii(c)) false else cclass[c: u32]&P > 0u8; + if (!isascii(c)) false else cclass[c: u32]&P > 0; // True if an ASCII character is alphanumeric. export fn isalnum(c: rune) bool = - if (!isascii(c)) false else cclass[c: u32]&(U|L|N) > 0u8; + if (!isascii(c)) false else cclass[c: u32]&(U|L|N) > 0; // True if an ASCII character is printable. export fn isprint(c: rune) bool = - if (!isascii(c)) false else cclass[c: u32]&(P|U|L|N|B) > 0u8; + if (!isascii(c)) false else cclass[c: u32]&(P|U|L|N|B) > 0; // True if an ASCII character is any printable character other than space. export fn isgraph(c: rune) bool = - if (!isascii(c)) false else cclass[c: u32]&(P|U|L|N) > 0u8; + if (!isascii(c)) false else cclass[c: u32]&(P|U|L|N) > 0; // True if an ASCII character is a control character. export fn iscntrl(c: rune) bool = - if (!isascii(c)) false else cclass[c: u32]&C > 0u8; + if (!isascii(c)) false else cclass[c: u32]&C > 0; // True if a rune is a valid ASCII character. -export fn isascii(c: rune) bool = c: u32 <= 0o177u32; +export fn isascii(c: rune) bool = c: u32 <= 0o177; // Returns the uppercase form of an ASCII character, or the original character // if it was not a lowercase letter. diff --git a/bytes/copy.ha b/bytes/copy.ha @@ -2,14 +2,14 @@ export fn copy(dest: []u8, src: []u8) void = { assert(len(dest) == len(src), "Destination slice must have same length as source slice"); - for (let i = 0z; i < len(dest); i += 1z) { + for (let i = 0z; i < len(dest); i += 1) { dest[i] = src[i]; }; }; @test fn copy() void = { - let a: [4]u8 = [1u8, 3u8, 3u8, 7u8]; - let b: [4]u8 = [0u8...]; + let a: [4]u8 = [1, 3, 3, 7]; + let b: [4]u8 = [0...]; copy(b[..], a[..]); assert(equal(a, b)); }; diff --git a/bytes/equal.ha b/bytes/equal.ha @@ -3,7 +3,7 @@ export fn equal(a: []u8, b: []u8) bool = { if (len(a) != len(b)) { return false; }; - for (let i = 0z; i < len(a); i += 1z) { + for (let i = 0z; i < len(a); i += 1) { if (a[i] != b[i]) { return false; }; @@ -12,11 +12,11 @@ export fn equal(a: []u8, b: []u8) bool = { }; @test fn equal() void = { - let a: []u8 = [1u8, 2u8, 3u8]; - let b: []u8 = [1u8, 2u8, 3u8]; - let c: []u8 = [1u8, 4u8, 5u8]; - let d: []u8 = [1u8, 2u8, 3u8, 4u8]; - let e: []u8 = [1u8, 2u8]; + let a: []u8 = [1, 2, 3]; + let b: []u8 = [1, 2, 3]; + let c: []u8 = [1, 4, 5]; + let d: []u8 = [1, 2, 3, 4]; + let e: []u8 = [1, 2]; assert(equal(a, b)); assert(!equal(a, c)); assert(!equal(a, d)); diff --git a/bytes/index.ha b/bytes/index.ha @@ -8,7 +8,7 @@ export fn index(haystack: []u8, needle: (u8 | []u8)) (size | void) = { }; fn index_byte(haystack: []u8, needle: u8) (size | void) = { - for (let i = 0z; i < len(haystack); i += 1z) { + for (let i = 0z; i < len(haystack); i += 1) { if (haystack[i] == needle) { return i; }; @@ -16,7 +16,7 @@ fn index_byte(haystack: []u8, needle: u8) (size | void) = { }; fn index_slice(haystack: []u8, needle: []u8) (size | void) = { - for (let i = 0z; i + len(needle) <= len(haystack); i += 1z) { + for (let i = 0z; i + len(needle) <= len(haystack); i += 1) { if (equal(haystack[i..i + len(needle)], needle)) { return i; }; @@ -26,37 +26,37 @@ fn index_slice(haystack: []u8, needle: []u8) (size | void) = { @test fn index() void = { // Bytes - const a: [4]u8 = [1u8, 3u8, 3u8, 7u8]; - match (index(a, 7u8)) { - n: size => assert(n == 3z), + const a: [4]u8 = [1, 3, 3, 7]; + match (index(a, 7)) { + n: size => assert(n == 3), void => abort(), }; - match (index(a, 42u8)) { + match (index(a, 42)) { size => abort(), void => void, }; - match (index([], 42u8)) { + match (index([], 42)) { size => abort(), void => void, }; // Slices - match (index(a, [3u8, 3u8])) { - n: size => assert(n == 1z), + match (index(a, [3, 3])) { + n: size => assert(n == 1), void => abort(), }; match (index(a, [])) { - n: size => assert(n == 0z), + n: size => assert(n == 0), void => abort(), }; - match(index(a, [4u8, 2u8])) { + match(index(a, [4, 2])) { size => abort(), void => void, }; - const special: []u8 = [1u8, 1u8, 1u8, 2u8]; - match (index(special, [1u8, 1u8, 2u8])) { - n: size => assert(n == 1z), + const special: []u8 = [1, 1, 1, 2]; + match (index(special, [1, 1, 2])) { + n: size => assert(n == 1), void => abort(), }; }; diff --git a/bytes/reverse.ha b/bytes/reverse.ha @@ -1,24 +1,24 @@ // Reverses a slice of bytes. export fn reverse(b: []u8) void = { - if (len(b) == 0z) { + if (len(b) == 0) { return; }; - for (let s = 0z, e = len(b) - 1z; s < e) { + for (let s = 0z, e = len(b) - 1; s < e) { let x = b[s]; b[s] = b[e]; b[e] = x; - s += 1z; - e -= 1z; + s += 1; + e -= 1; }; }; @test fn reverse() void = { - let a: [4]u8 = [1u8, 3u8, 3u8, 7u8]; + let a: [4]u8 = [1, 3, 3, 7]; reverse(a); - assert(equal(a, [7u8, 3u8, 3u8, 1u8])); - let b: [5]u8 = [1u8, 2u8, 3u8, 4u8, 5u8]; + assert(equal(a, [7, 3, 3, 1])); + let b: [5]u8 = [1, 2, 3, 4, 5]; reverse(b); - assert(equal(b, [5u8, 4u8, 3u8, 2u8, 1u8])); + assert(equal(b, [5, 4, 3, 2, 1])); let c: []u8 = []; reverse(c); assert(equal(c, [])); diff --git a/bytes/tokenize.ha b/bytes/tokenize.ha @@ -12,14 +12,14 @@ export fn tokenize(s: []u8, delim: []u8) tokenizer = tokenizer { // string starts with, or ends with, a token, an empty slice is returned at the // beginning or end of the sequence, respectively. export fn next_token(s: *tokenizer) ([]u8 | void) = { - if (len(s.s) == 0z) { + if (len(s.s) == 0) { return void; }; match (index(s.s, s.d)) { i: size => { let tok = s.s[..i]; - if (len(tok) + len(s.d) == len(s.s) && len(tok) != 0z) { + if (len(tok) + len(s.d) == len(s.s) && len(tok) != 0) { s.s = s.s[i..]; } else { s.s = s.s[i+len(s.d)..]; @@ -42,28 +42,28 @@ export fn remaining_tokens(s: *tokenizer) []u8 = { }; @test fn tokenize() void = { - const input = [1u8, 2u8, 24u8, 42u8, 3u8, 24u8, 24u8, 42u8, 4u8, 5u8]; - let t = tokenize(input, [24u8, 42u8]); + const input: [_]u8 = [1, 2, 24, 42, 3, 24, 24, 42, 4, 5]; + let t = tokenize(input, [24, 42]); match (next_token(&t)) { - b: []u8 => assert(equal([1u8, 2u8], b)), + b: []u8 => assert(equal([1, 2], b)), void => abort(), }; match (next_token(&t)) { - b: []u8 => assert(equal([3u8, 24u8], b)), + b: []u8 => assert(equal([3, 24], b)), void => abort(), }; match (next_token(&t)) { - b: []u8 => assert(equal([4u8, 5u8], b)), + b: []u8 => assert(equal([4, 5], b)), void => abort(), }; assert(next_token(&t) is void); - const input2 = [24u8, 42u8, 1u8, 24u8, 42u8]; - t = tokenize(input2, [24u8, 42u8]); + const input2: [_]u8 = [24, 42, 1, 24, 42]; + t = tokenize(input2, [24, 42]); match (next_token(&t)) { b: []u8 => assert(equal([], b)), @@ -71,7 +71,7 @@ export fn remaining_tokens(s: *tokenizer) []u8 = { }; match (next_token(&t)) { - b: []u8 => assert(equal([1u8], b)), + b: []u8 => assert(equal([1], b)), void => abort(), }; @@ -82,21 +82,21 @@ export fn remaining_tokens(s: *tokenizer) []u8 = { assert(next_token(&t) is void); - const input3 = [1u8, 1u8, 1u8, 2u8, 1u8, 1u8, 2u8, 2u8]; - t = tokenize(input3, [1u8, 2u8]); + const input3: [_]u8 = [1, 1, 1, 2, 1, 1, 2, 2]; + t = tokenize(input3, [1, 2]); match (next_token(&t)) { - b: []u8 => assert(equal([1u8, 1u8], b)), + b: []u8 => assert(equal([1, 1], b)), void => abort(), }; match (next_token(&t)) { - b: []u8 => assert(equal([1u8], b)), + b: []u8 => assert(equal([1], b)), void => abort(), }; match (next_token(&t)) { - b: []u8 => assert(equal([2u8], b)), + b: []u8 => assert(equal([2], b)), void => abort(), }; diff --git a/encoding/utf8/decode.ha b/encoding/utf8/decode.ha @@ -10,14 +10,8 @@ export type decoder = struct { // Initializes a new UTF-8 decoder. export fn decode(src: (str | []u8)) decoder = match (src) { - s: str => decoder { - offs = 0z, - src = to_utf8(s), - }, - b: []u8 => decoder { - offs = 0z, - src = b, - }, + s: str => decoder { src = to_utf8(s), ... }, + b: []u8 => decoder { src = b, ... }, }; // Indicates that more data is needed, i.e. that a partial UTF-8 sequence was @@ -46,28 +40,28 @@ export fn next(d: *decoder) (rune | void | more | invalid) = { d.offs += n; let r = 0u32; - if (bytes[0] < 128u8) { + if (bytes[0] < 128) { // ASCII return bytes[0]: u32: rune; }; - const mask = masks[n - 1z]; + const mask = masks[n - 1]; r = bytes[0] & mask; - for (let i = 1z; i < len(bytes); i += 1z) { - r <<= 6u8; - r |= bytes[i] & 0x3Fu8; + for (let i = 1z; i < len(bytes); i += 1) { + r <<= 6; + r |= bytes[i] & 0x3F; }; return r: rune; }; @test fn decode() void = { - const input = [ - 0xE3u8, 0x81u8, 0x93u8, 0xE3u8, 0x82u8, 0x93u8, 0xE3u8, 0x81u8, - 0xABu8, 0xE3u8, 0x81u8, 0xA1u8, 0xE3u8, 0x81u8, 0xAFu8, 0x00u8, + const input: [_]u8 = [ + 0xE3, 0x81, 0x93, 0xE3, 0x82, 0x93, 0xE3, 0x81, + 0xAB, 0xE3, 0x81, 0xA1, 0xE3, 0x81, 0xAF, 0x00, ]; const expected = ['こ', 'ん', 'に', 'ち', 'は', '\0']; let decoder = decode(input); - for (let i = 0z; i < len(expected); i += 1z) { + for (let i = 0z; i < len(expected); i += 1) { match (next(&decoder)) { r: rune => assert(r == expected[i]), invalid => abort(), @@ -78,11 +72,11 @@ export fn next(d: *decoder) (rune | void | more | invalid) = { assert(next(&decoder) is void); // TODO: Test more invalid sequences - const invalid = [0xA0u8, 0xA1u8]; + const invalid: [_]u8 = [0xA0, 0xA1]; decoder = decode(invalid); assert(next(&decoder) is invalid); - const incomplete = [0xE3u8, 0x81u8]; + const incomplete: [_]u8 = [0xE3, 0x81]; decoder = decode(incomplete); assert(next(&decoder) is more); }; @@ -104,10 +98,10 @@ export fn valid(src: (str | []u8)) bool = { }; fn utf8sz(src: []u8) size = { - assert(len(src) > 0z); + assert(len(src) > 0); let c = src[0]; - for (let i = 0z; i < len(sizes); i += 1z) { + for (let i = 0z; i < len(sizes); i += 1) { if (c & sizes[i].mask == sizes[i].result) { return sizes[i].octets; }; diff --git a/encoding/utf8/encode.ha b/encoding/utf8/encode.ha @@ -2,24 +2,24 @@ // statically allocated; duplicate it if you aren't using it right away. export fn encode_rune(r: rune) []u8 = { let ch = r: u32, n = 0z, first = 0u8; - if (ch < 0x80u32) { - first = 0u8; - n = 1z; - } else if (ch < 0x800u32) { - first = 0xC0u8; - n = 2z; - } else if (ch < 0x10000u32) { - first = 0xE0u8; - n = 3z; + if (ch < 0x80) { + first = 0; + n = 1; + } else if (ch < 0x800) { + first = 0xC0; + n = 2; + } else if (ch < 0x10000) { + first = 0xE0; + n = 3; } else { - first = 0xF0u8; - n = 4z; + first = 0xF0; + n = 4; }; - static let buf: [6]u8 = [0u8...]; - for (let i = n - 1z; i > 0z; i -= 1z) { - buf[i] = ch: u8 & 0x3Fu8 | 0x80u8; - ch >>= 6u32; + static let buf: [6]u8 = [0...]; + for (let i = n - 1; i > 0; i -= 1) { + buf[i] = ch: u8 & 0x3F | 0x80; + ch >>= 6; }; buf[0] = ch: u8 | first; return buf[..n]; @@ -27,14 +27,14 @@ export fn encode_rune(r: rune) []u8 = { @test fn encode() void = { const expected: [_][]u8 = [ - [0u8], - [0x25u8], - [0xE3u8, 0x81u8, 0x93u8], + [0], + [0x25], + [0xE3, 0x81, 0x93], ]; const inputs = ['\0', '%', 'こ']; - for (let i = 0z; i < len(inputs); i += 1z) { + for (let i = 0z; i < len(inputs); i += 1) { const out = encode_rune(inputs[i]); - for (let j = 0z; j < len(expected[i]); j += 1z) { + for (let j = 0z; j < len(expected[i]); j += 1) { assert(out[j] == expected[i][j]); }; }; diff --git a/encoding/utf8/rune.ha b/encoding/utf8/rune.ha @@ -1,6 +1,6 @@ use types; -const masks: [_]u8 = [0x7Fu8, 0x1Fu8, 0x0Fu8, 0x07u8, 0x03u8, 0x01u8]; +const masks: [_]u8 = [0x7F, 0x1F, 0x0F, 0x07, 0x03, 0x01]; type rsize = struct { mask: u8, @@ -9,19 +9,19 @@ type rsize = struct { }; const sizes: [_]rsize = [ - rsize { mask = 0x80u8, result = 0x00u8, octets = 1z }, - rsize { mask = 0xE0u8, result = 0xC0u8, octets = 2z }, - rsize { mask = 0xF0u8, result = 0xE0u8, octets = 3z }, - rsize { mask = 0xF8u8, result = 0xF0u8, octets = 4z }, - rsize { mask = 0xFCu8, result = 0xF8u8, octets = 5z }, - rsize { mask = 0xFEu8, result = 0xF8u8, octets = 6z }, + rsize { mask = 0x80, result = 0x00, octets = 1 }, + rsize { mask = 0xE0, result = 0xC0, octets = 2 }, + rsize { mask = 0xF0, result = 0xE0, octets = 3 }, + rsize { mask = 0xF8, result = 0xF0, octets = 4 }, + rsize { mask = 0xFC, result = 0xF8, octets = 5 }, + rsize { mask = 0xFE, result = 0xF8, octets = 6 }, ]; // Returns the size of a rune, in octets, when encoded as UTF-8. export fn runesz(r: rune) size = { const ch = r: u32; - return if (ch < 0x80u32) 1z - else if (ch < 0x800u32) 2z - else if (ch < 0x10000u32) 3z - else 4z; + return if (ch < 0x80) 1 + else if (ch < 0x800) 2 + else if (ch < 0x10000) 3 + else 4; }; diff --git a/fmt/fmt.ha b/fmt/fmt.ha @@ -131,8 +131,8 @@ export fn fprintf( args[scan_uint(&iter)]; } else { strings::push(&iter, r); - i += 1z; - args[i - 1z]; + i += 1; + args[i - 1]; }; let mod = modifiers { ... }; @@ -213,7 +213,7 @@ fn format( }; fn scan_uint(iter: *strings::iterator) uint = { - let num = alloc([]u8, [], 1z); // TODO: alloc slice w/o cap + let num = alloc([]u8, [], 1); // TODO: alloc slice w/o cap defer free(num); for (true) { let r = match (strings::next(iter)) { diff --git a/io/+test/copy.ha b/io/+test/copy.ha @@ -1,9 +1,9 @@ fn test_copier_read(s: *stream, buf: []u8) (size | EOF | error) = { let stream = s: *test_stream; - if (stream.n == 0z) { - assert(len(buf) > 42z); - stream.n = 42z; - return 42z; + if (stream.n == 0) { + assert(len(buf) > 42); + stream.n = 42; + return 42; } else { return EOF; }; @@ -19,8 +19,8 @@ fn test_copier_copy(a: *stream, b: *stream) (size | error) = { assert(a != b); assert(a.reader == &test_copier_read && b.reader == &test_copier_read); let stream = a: *test_stream; - stream.n = 62893z; - return 1337z; + stream.n = 62893; + return 1337; }; fn test_copy_unsupported(a: *stream, b: *stream) (size | error) = unsupported; @@ -29,9 +29,9 @@ fn test_copy_unsupported(a: *stream, b: *stream) (size | error) = unsupported; let a = test_copier_open(), b = test_copier_open(); match (copy(&b.stream, &a.stream)) { n: size => { - assert(n == 42z); - assert(a.n == 42z); - assert(b.n == 42z); + assert(n == 42); + assert(a.n == 42); + assert(b.n == 42); }, error => abort(), }; @@ -44,8 +44,8 @@ fn test_copy_unsupported(a: *stream, b: *stream) (size | error) = unsupported; b.stream.copier = &test_copier_copy; match (copy(&b.stream, &a.stream)) { n: size => { - assert(n == 1337z); - assert(b.n == 62893z); + assert(n == 1337); + assert(b.n == 62893); }, error => abort(), }; @@ -59,9 +59,9 @@ fn test_copy_unsupported(a: *stream, b: *stream) (size | error) = unsupported; b.stream.copier = &test_copy_unsupported; match (copy(&b.stream, &a.stream)) { n: size => { - assert(n == 42z); - assert(a.n == 42z); - assert(b.n == 42z); + assert(n == 42); + assert(a.n == 42); + assert(b.n == 42); }, error => abort(), }; diff --git a/io/+test/limit.ha b/io/+test/limit.ha @@ -1,34 +1,34 @@ @test fn limit() void = { - let buf: [15z]u8 = [0u8...]; + let buf: [15z]u8 = [0...]; let source_stream = test_stream_open(); defer close(&source_stream.stream); - let r_stream = limit_reader(&source_stream.stream, 20z); + let r_stream = limit_reader(&source_stream.stream, 20); match (write(r_stream, buf)) { unsupported => void, * => abort(), }; match (read(r_stream, buf)) { - n: size => assert(n == 15z), + n: size => assert(n == 15), error => abort(), }; match (read(r_stream, buf)) { - n: size => assert(n == 5z), + n: size => assert(n == 5), error => abort(), }; close(r_stream); - let w_stream = limit_writer(&source_stream.stream, 20z); + let w_stream = limit_writer(&source_stream.stream, 20); match (read(w_stream, buf)) { unsupported => void, * => abort(), }; match (write(w_stream, buf)) { - n: size => assert(n == 15z), + n: size => assert(n == 15), error => abort(), }; match (write(w_stream, buf)) { - n: size => assert(n == 5z), + n: size => assert(n == 5), error => abort(), }; close(w_stream); diff --git a/io/+test/stream.ha b/io/+test/stream.ha @@ -25,7 +25,7 @@ fn test_stream_open() test_stream = test_stream { closer = &test_stream_close, ... }, - n = 0z, + n = 0, }; fn test_stream_close(s: *stream) void = { diff --git a/io/copy.ha b/io/copy.ha @@ -13,7 +13,7 @@ export fn copy(dest: *stream, src: *stream) (error | size) = { }; let w = 0z; - static let buf: [4096]u8 = [0u8...]; + static let buf: [4096]u8 = [0...]; for (true) { match (read(src, buf[..])) { err: error => return err, diff --git a/io/println.ha b/io/println.ha @@ -3,10 +3,10 @@ use rt; // TEMP: This is due to be rewritten to be less shit export fn println(msg: str) void = { rt::write(1, msg: *const char, len(msg)); - rt::write(1, "\n": *const char, 1z); + rt::write(1, "\n": *const char, 1); }; export fn errorln(msg: str) void = { rt::write(2, msg: *const char, len(msg)); - rt::write(2, "\n": *const char, 1z); + rt::write(2, "\n": *const char, 1); }; diff --git a/io/types.ha b/io/types.ha @@ -26,9 +26,9 @@ export fn errstr(err: error) str = { }; export type mode = enum uint { - RDONLY = 0u, - WRONLY = 1u, - RDWR = 2u, + RDONLY = 0, + WRONLY = 1, + RDWR = 2, }; export type whence = enum { diff --git a/os/+linux/environ.ha b/os/+linux/environ.ha @@ -14,12 +14,12 @@ let args_static: [32]str = [""...]; @init fn init_environ() void = { if (rt::argc < len(args_static)) { args = args_static[..rt::argc]; - for (let i = 0z; i < rt::argc; i += 1z) { + for (let i = 0z; i < rt::argc; i += 1) { args[i] = strings::from_c(rt::argv[i]); }; } else { args = alloc([]str, [], rt::argc); - for (let i = 0z; i < rt::argc; i += 1z) { + for (let i = 0z; i < rt::argc; i += 1) { append(args, strings::from_c(rt::argv[i])); }; }; @@ -35,8 +35,7 @@ let args_static: [32]str = [""...]; // Looks up an environment variable and returns its value, or void if unset. export fn getenv(name: const str) (str | void) = { const name_b = strings::to_utf8(name); - // TODO: Type promotion can simplify this null comparison: - for (let i = 0z; rt::envp[i] != null: nullable *char; i += 1z) { + for (let i = 0z; rt::envp[i] != null; i += 1) { const item = rt::envp[i]: *[*]u8; const eq: size = match (bytes::index(item[..], '=': u32: u8)) { void => abort("Environment violates System-V invariants"), @@ -44,7 +43,7 @@ export fn getenv(name: const str) (str | void) = { }; if (bytes::equal(name_b, item[..eq])) { const ln = strings::c_strlen(item: *const char); - return strings::from_utf8(item[eq+1z..ln]); + return strings::from_utf8(item[eq+1..ln]); }; }; }; diff --git a/os/+linux/fdstream.ha b/os/+linux/fdstream.ha @@ -60,8 +60,8 @@ fn fd_read(s: *io::stream, buf: []u8) (size | io::EOF | io::error) = { return match (rt::read(stream.fd, buf: *[*]u8, len(buf))) { err: rt::errno => errno_to_io(err), n: size => switch (n) { - 0z => io::EOF, - * => n, + 0 => io::EOF, + * => n, }, }; }; @@ -101,7 +101,7 @@ fn fd_copy(_to: *io::stream, _from: *io::stream) (size | io::error) = { null, SENDFILE_MAX)) { err: rt::errno => switch (err) { rt::EINVAL => { - if (sum == 0z) { + if (sum == 0) { return io::unsupported; }; return errno_to_io(err); @@ -109,8 +109,8 @@ fn fd_copy(_to: *io::stream, _from: *io::stream) (size | io::error) = { * => return errno_to_io(err), }, n: size => switch (n) { - 0z => return sum, - * => n, + 0 => return sum, + * => n, }, }; sum += n; diff --git a/os/exec/+linux.ha b/os/exec/+linux.ha @@ -55,9 +55,9 @@ fn platform_exec(cmd: *command) os_error = { append(argv, null); let envp: nullable *[*]nullable *const char = null; - if (len(cmd.envp) != 0z) { - let env = alloc([]nullable *const char, [], len(cmd.envp) + 1z); - for (let i = 0z; i < len(cmd.envp); i += 1z) { + if (len(cmd.envp) != 0) { + let env = alloc([]nullable *const char, [], len(cmd.envp) + 1); + for (let i = 0z; i < len(cmd.envp); i += 1) { append(env, cmd.envp[i]: *const char); }; append(env, null); @@ -76,7 +76,7 @@ fn platform_start(cmd: *command) (os_error | void) = { void => void, }; - match (rt::clone(null, 0, null, null, 0u64)) { + match (rt::clone(null, 0, null, null, 0)) { err: rt::errno => return errno_to_os(err), pid: int => { // TODO: Fill in some kind of process structure @@ -87,7 +87,7 @@ fn platform_start(cmd: *command) (os_error | void) = { n: size => switch (n) { size(int) => return errno_to_os(errno), * => abort("Unexpected rt::read result"), - 0z => void, + 0 => void, }, }; return; diff --git a/rt/+linux/+aarch64.ha b/rt/+linux/+aarch64.ha @@ -14,8 +14,8 @@ export fn clone( tls, child_tid: uintptr: u64))) { u: u64 => switch (u) { - 0u64 => void, - * => u: int, + 0 => void, + * => u: int, }, err: errno => err, }; diff --git a/rt/+linux/+x86_64.ha b/rt/+linux/+x86_64.ha @@ -14,8 +14,8 @@ export fn clone( child_tid: uintptr: u64, tls))) { u: u64 => switch (u) { - 0u64 => void, - * => u: int, + 0 => void, + * => u: int, }, err: errno => err, }; diff --git a/rt/+linux/abort.ha b/rt/+linux/abort.ha @@ -2,7 +2,7 @@ export @noreturn @symbol("rt.abort") fn _abort(msg: str) void = { const prefix = "Abort: "; write(2, prefix: *const char, len(prefix)); write(2, msg: *const char, len(msg)); - write(2, "\n": *const char, 1z); + write(2, "\n": *const char, 1); kill(getpid(), SIGABRT); }; diff --git a/rt/+linux/env.ha b/rt/+linux/env.ha @@ -1,3 +1,3 @@ -export let argc: size = 0z; +export let argc: size = 0; export let argv: *[*]*char = null: *[*]*char; export let envp: *[*]nullable *char = null: *[*]nullable *char; diff --git a/rt/+linux/segmalloc.ha b/rt/+linux/segmalloc.ha @@ -2,7 +2,7 @@ fn segmalloc(n: size) nullable *void = { return match(mmap(null, n, PROT_READ | PROT_WRITE, - MAP_PRIVATE | MAP_ANON, -1, 0z)) { + MAP_PRIVATE | MAP_ANON, -1, 0)) { err: errno => { assert(err == ENOMEM: errno); null; diff --git a/rt/+linux/start.ha b/rt/+linux/start.ha @@ -1,7 +1,7 @@ export fn start_linux(iv: *[*]uintptr) void = { // TODO: Find & parse auxv - argc = iv[0z]: size; - argv = &iv[1z]: *[*]*char; - envp = &iv[1z + argc * size(*char) + 1z]: *[*]nullable *char; + argc = iv[0]: size; + argv = &iv[1]: *[*]*char; + envp = &iv[1 + argc * size(*char) + 1]: *[*]nullable *char; start_ha(); }; diff --git a/rt/+linux/stat.ha b/rt/+linux/stat.ha @@ -1,8 +1,8 @@ fn mkdev(major: u32, minor: u32) dev_t = - ((major: u64 & 0xFFFFF000u64) << 32u64) | - ((major: u64 & 0x00000FFFu64) << 8u64) | - ((minor: u64 & 0xFFFFFF00u64) << 12u64) | - (minor: u64 & 0x000000FFu64); + ((major: u64 & 0xFFFFF000) << 32) | + ((major: u64 & 0x00000FFF) << 8) | + ((minor: u64 & 0xFFFFFF00) << 12) | + (minor: u64 & 0x000000FF); fn fstatat_statx( dirfd: int, diff --git a/rt/+linux/syscallno+aarch64.ha b/rt/+linux/syscallno+aarch64.ha @@ -1,292 +1,292 @@ -export def SYS_io_setup: u64 = 0u64; -export def SYS_io_destroy: u64 = 1u64; -export def SYS_io_submit: u64 = 2u64; -export def SYS_io_cancel: u64 = 3u64; -export def SYS_io_getevents: u64 = 4u64; -export def SYS_setxattr: u64 = 5u64; -export def SYS_lsetxattr: u64 = 6u64; -export def SYS_fsetxattr: u64 = 7u64; -export def SYS_getxattr: u64 = 8u64; -export def SYS_lgetxattr: u64 = 9u64; -export def SYS_fgetxattr: u64 = 10u64; -export def SYS_listxattr: u64 = 11u64; -export def SYS_llistxattr: u64 = 12u64; -export def SYS_flistxattr: u64 = 13u64; -export def SYS_removexattr: u64 = 14u64; -export def SYS_lremovexattr: u64 = 15u64; -export def SYS_fremovexattr: u64 = 16u64; -export def SYS_getcwd: u64 = 17u64; -export def SYS_lookup_dcookie: u64 = 18u64; -export def SYS_eventfd2: u64 = 19u64; -export def SYS_epoll_create1: u64 = 20u64; -export def SYS_epoll_ctl: u64 = 21u64; -export def SYS_epoll_pwait: u64 = 22u64; -export def SYS_dup: u64 = 23u64; -export def SYS_dup3: u64 = 24u64; -export def SYS_fcntl: u64 = 25u64; -export def SYS_inotify_init1: u64 = 26u64; -export def SYS_inotify_add_watch: u64 = 27u64; -export def SYS_inotify_rm_watch: u64 = 28u64; -export def SYS_ioctl: u64 = 29u64; -export def SYS_ioprio_set: u64 = 30u64; -export def SYS_ioprio_get: u64 = 31u64; -export def SYS_flock: u64 = 32u64; -export def SYS_mknodat: u64 = 33u64; -export def SYS_mkdirat: u64 = 34u64; -export def SYS_unlinkat: u64 = 35u64; -export def SYS_symlinkat: u64 = 36u64; -export def SYS_linkat: u64 = 37u64; -export def SYS_renameat: u64 = 38u64; -export def SYS_umount2: u64 = 39u64; -export def SYS_mount: u64 = 40u64; -export def SYS_pivot_root: u64 = 41u64; -export def SYS_nfsservctl: u64 = 42u64; -export def SYS_statfs: u64 = 43u64; -export def SYS_fstatfs: u64 = 44u64; -export def SYS_truncate: u64 = 45u64; -export def SYS_ftruncate: u64 = 46u64; -export def SYS_fallocate: u64 = 47u64; -export def SYS_faccessat: u64 = 48u64; -export def SYS_chdir: u64 = 49u64; -export def SYS_fchdir: u64 = 50u64; -export def SYS_chroot: u64 = 51u64; -export def SYS_fchmod: u64 = 52u64; -export def SYS_fchmodat: u64 = 53u64; -export def SYS_fchownat: u64 = 54u64; -export def SYS_fchown: u64 = 55u64; -export def SYS_openat: u64 = 56u64; -export def SYS_close: u64 = 57u64; -export def SYS_vhangup: u64 = 58u64; -export def SYS_pipe2: u64 = 59u64; -export def SYS_quotactl: u64 = 60u64; -export def SYS_getdents64: u64 = 61u64; -export def SYS_lseek: u64 = 62u64; -export def SYS_read: u64 = 63u64; -export def SYS_write: u64 = 64u64; -export def SYS_readv: u64 = 65u64; -export def SYS_writev: u64 = 66u64; -export def SYS_pread64: u64 = 67u64; -export def SYS_pwrite64: u64 = 68u64; -export def SYS_preadv: u64 = 69u64; -export def SYS_pwritev: u64 = 70u64; -export def SYS_sendfile: u64 = 71u64; -export def SYS_pselect6: u64 = 72u64; -export def SYS_ppoll: u64 = 73u64; -export def SYS_signalfd4: u64 = 74u64; -export def SYS_vmsplice: u64 = 75u64; -export def SYS_splice: u64 = 76u64; -export def SYS_tee: u64 = 77u64; -export def SYS_readlinkat: u64 = 78u64; -export def SYS_newfstatat: u64 = 79u64; -export def SYS_fstat: u64 = 80u64; -export def SYS_sync: u64 = 81u64; -export def SYS_fsync: u64 = 82u64; -export def SYS_fdatasync: u64 = 83u64; -export def SYS_sync_file_range: u64 = 84u64; -export def SYS_timerfd_create: u64 = 85u64; -export def SYS_timerfd_settime: u64 = 86u64; -export def SYS_timerfd_gettime: u64 = 87u64; -export def SYS_utimensat: u64 = 88u64; -export def SYS_acct: u64 = 89u64; -export def SYS_capget: u64 = 90u64; -export def SYS_capset: u64 = 91u64; -export def SYS_personality: u64 = 92u64; -export def SYS_exit: u64 = 93u64; -export def SYS_exit_group: u64 = 94u64; -export def SYS_waitid: u64 = 95u64; -export def SYS_set_tid_address: u64 = 96u64; -export def SYS_unshare: u64 = 97u64; -export def SYS_futex: u64 = 98u64; -export def SYS_set_robust_list: u64 = 99u64; -export def SYS_get_robust_list: u64 = 100u64; -export def SYS_nanosleep: u64 = 101u64; -export def SYS_getitimer: u64 = 102u64; -export def SYS_setitimer: u64 = 103u64; -export def SYS_kexec_load: u64 = 104u64; -export def SYS_init_module: u64 = 105u64; -export def SYS_delete_module: u64 = 106u64; -export def SYS_timer_create: u64 = 107u64; -export def SYS_timer_gettime: u64 = 108u64; -export def SYS_timer_getoverrun: u64 = 109u64; -export def SYS_timer_settime: u64 = 110u64; -export def SYS_timer_delete: u64 = 111u64; -export def SYS_clock_settime: u64 = 112u64; -export def SYS_clock_gettime: u64 = 113u64; -export def SYS_clock_getres: u64 = 114u64; -export def SYS_clock_nanosleep: u64 = 115u64; -export def SYS_syslog: u64 = 116u64; -export def SYS_ptrace: u64 = 117u64; -export def SYS_sched_setparam: u64 = 118u64; -export def SYS_sched_setscheduler: u64 = 119u64; -export def SYS_sched_getscheduler: u64 = 120u64; -export def SYS_sched_getparam: u64 = 121u64; -export def SYS_sched_setaffinity: u64 = 122u64; -export def SYS_sched_getaffinity: u64 = 123u64; -export def SYS_sched_yield: u64 = 124u64; -export def SYS_sched_get_priority_max: u64 = 125u64; -export def SYS_sched_get_priority_min: u64 = 126u64; -export def SYS_sched_rr_get_interval: u64 = 127u64; -export def SYS_restart_syscall: u64 = 128u64; -export def SYS_kill: u64 = 129u64; -export def SYS_tkill: u64 = 130u64; -export def SYS_tgkill: u64 = 131u64; -export def SYS_sigaltstack: u64 = 132u64; -export def SYS_rt_sigsuspend: u64 = 133u64; -export def SYS_rt_sigaction: u64 = 134u64; -export def SYS_rt_sigprocmask: u64 = 135u64; -export def SYS_rt_sigpending: u64 = 136u64; -export def SYS_rt_sigtimedwait: u64 = 137u64; -export def SYS_rt_sigqueueinfo: u64 = 138u64; -export def SYS_rt_sigreturn: u64 = 139u64; -export def SYS_setpriority: u64 = 140u64; -export def SYS_getpriority: u64 = 141u64; -export def SYS_reboot: u64 = 142u64; -export def SYS_setregid: u64 = 143u64; -export def SYS_setgid: u64 = 144u64; -export def SYS_setreuid: u64 = 145u64; -export def SYS_setuid: u64 = 146u64; -export def SYS_setresuid: u64 = 147u64; -export def SYS_getresuid: u64 = 148u64; -export def SYS_setresgid: u64 = 149u64; -export def SYS_getresgid: u64 = 150u64; -export def SYS_setfsuid: u64 = 151u64; -export def SYS_setfsgid: u64 = 152u64; -export def SYS_times: u64 = 153u64; -export def SYS_setpgid: u64 = 154u64; -export def SYS_getpgid: u64 = 155u64; -export def SYS_getsid: u64 = 156u64; -export def SYS_setsid: u64 = 157u64; -export def SYS_getgroups: u64 = 158u64; -export def SYS_setgroups: u64 = 159u64; -export def SYS_uname: u64 = 160u64; -export def SYS_sethostname: u64 = 161u64; -export def SYS_setdomainname: u64 = 162u64; -export def SYS_getrlimit: u64 = 163u64; -export def SYS_setrlimit: u64 = 164u64; -export def SYS_getrusage: u64 = 165u64; -export def SYS_umask: u64 = 166u64; -export def SYS_prctl: u64 = 167u64; -export def SYS_getcpu: u64 = 168u64; -export def SYS_gettimeofday: u64 = 169u64; -export def SYS_settimeofday: u64 = 170u64; -export def SYS_adjtimex: u64 = 171u64; -export def SYS_getpid: u64 = 172u64; -export def SYS_getppid: u64 = 173u64; -export def SYS_getuid: u64 = 174u64; -export def SYS_geteuid: u64 = 175u64; -export def SYS_getgid: u64 = 176u64; -export def SYS_getegid: u64 = 177u64; -export def SYS_gettid: u64 = 178u64; -export def SYS_sysinfo: u64 = 179u64; -export def SYS_mq_open: u64 = 180u64; -export def SYS_mq_unlink: u64 = 181u64; -export def SYS_mq_timedsend: u64 = 182u64; -export def SYS_mq_timedreceive: u64 = 183u64; -export def SYS_mq_notify: u64 = 184u64; -export def SYS_mq_getsetattr: u64 = 185u64; -export def SYS_msgget: u64 = 186u64; -export def SYS_msgctl: u64 = 187u64; -export def SYS_msgrcv: u64 = 188u64; -export def SYS_msgsnd: u64 = 189u64; -export def SYS_semget: u64 = 190u64; -export def SYS_semctl: u64 = 191u64; -export def SYS_semtimedop: u64 = 192u64; -export def SYS_semop: u64 = 193u64; -export def SYS_shmget: u64 = 194u64; -export def SYS_shmctl: u64 = 195u64; -export def SYS_shmat: u64 = 196u64; -export def SYS_shmdt: u64 = 197u64; -export def SYS_socket: u64 = 198u64; -export def SYS_socketpair: u64 = 199u64; -export def SYS_bind: u64 = 200u64; -export def SYS_listen: u64 = 201u64; -export def SYS_accept: u64 = 202u64; -export def SYS_connect: u64 = 203u64; -export def SYS_getsockname: u64 = 204u64; -export def SYS_getpeername: u64 = 205u64; -export def SYS_sendto: u64 = 206u64; -export def SYS_recvfrom: u64 = 207u64; -export def SYS_setsockopt: u64 = 208u64; -export def SYS_getsockopt: u64 = 209u64; -export def SYS_shutdown: u64 = 210u64; -export def SYS_sendmsg: u64 = 211u64; -export def SYS_recvmsg: u64 = 212u64; -export def SYS_readahead: u64 = 213u64; -export def SYS_brk: u64 = 214u64; -export def SYS_munmap: u64 = 215u64; -export def SYS_mremap: u64 = 216u64; -export def SYS_add_key: u64 = 217u64; -export def SYS_request_key: u64 = 218u64; -export def SYS_keyctl: u64 = 219u64; -export def SYS_clone: u64 = 220u64; -export def SYS_execve: u64 = 221u64; -export def SYS_mmap: u64 = 222u64; -export def SYS_fadvise64: u64 = 223u64; -export def SYS_swapon: u64 = 224u64; -export def SYS_swapoff: u64 = 225u64; -export def SYS_mprotect: u64 = 226u64; -export def SYS_msync: u64 = 227u64; -export def SYS_mlock: u64 = 228u64; -export def SYS_munlock: u64 = 229u64; -export def SYS_mlockall: u64 = 230u64; -export def SYS_munlockall: u64 = 231u64; -export def SYS_mincore: u64 = 232u64; -export def SYS_madvise: u64 = 233u64; -export def SYS_remap_file_pages: u64 = 234u64; -export def SYS_mbind: u64 = 235u64; -export def SYS_get_mempolicy: u64 = 236u64; -export def SYS_set_mempolicy: u64 = 237u64; -export def SYS_migrate_pages: u64 = 238u64; -export def SYS_move_pages: u64 = 239u64; -export def SYS_rt_tgsigqueueinfo: u64 = 240u64; -export def SYS_perf_event_open: u64 = 241u64; -export def SYS_accept4: u64 = 242u64; -export def SYS_recvmmsg: u64 = 243u64; -export def SYS_wait4: u64 = 260u64; -export def SYS_prlimit64: u64 = 261u64; -export def SYS_fanotify_init: u64 = 262u64; -export def SYS_fanotify_mark: u64 = 263u64; -export def SYS_name_to_handle_at: u64 = 264u64; -export def SYS_open_by_handle_at: u64 = 265u64; -export def SYS_clock_adjtime: u64 = 266u64; -export def SYS_syncfs: u64 = 267u64; -export def SYS_setns: u64 = 268u64; -export def SYS_sendmmsg: u64 = 269u64; -export def SYS_process_vm_readv: u64 = 270u64; -export def SYS_process_vm_writev: u64 = 271u64; -export def SYS_kcmp: u64 = 272u64; -export def SYS_finit_module: u64 = 273u64; -export def SYS_sched_setattr: u64 = 274u64; -export def SYS_sched_getattr: u64 = 275u64; -export def SYS_renameat2: u64 = 276u64; -export def SYS_seccomp: u64 = 277u64; -export def SYS_getrandom: u64 = 278u64; -export def SYS_memfd_create: u64 = 279u64; -export def SYS_bpf: u64 = 280u64; -export def SYS_execveat: u64 = 281u64; -export def SYS_userfaultfd: u64 = 282u64; -export def SYS_membarrier: u64 = 283u64; -export def SYS_mlock2: u64 = 284u64; -export def SYS_copy_file_range: u64 = 285u64; -export def SYS_preadv2: u64 = 286u64; -export def SYS_pwritev2: u64 = 287u64; -export def SYS_pkey_mprotect: u64 = 288u64; -export def SYS_pkey_alloc: u64 = 289u64; -export def SYS_pkey_free: u64 = 290u64; -export def SYS_statx: u64 = 291u64; -export def SYS_io_pgetevents: u64 = 292u64; -export def SYS_rseq: u64 = 293u64; -export def SYS_kexec_file_load: u64 = 294u64; -export def SYS_pidfd_send_signal: u64 = 424u64; -export def SYS_io_uring_setup: u64 = 425u64; -export def SYS_io_uring_enter: u64 = 426u64; -export def SYS_io_uring_register: u64 = 427u64; -export def SYS_open_tree: u64 = 428u64; -export def SYS_move_mount: u64 = 429u64; -export def SYS_fsopen: u64 = 430u64; -export def SYS_fsconfig: u64 = 431u64; -export def SYS_fsmount: u64 = 432u64; -export def SYS_fspick: u64 = 433u64; -export def SYS_pidfd_open: u64 = 434u64; -export def SYS_clone3: u64 = 435u64; -export def SYS_faccessat2: u64 = 439u64; +export def SYS_io_setup: u64 = 0; +export def SYS_io_destroy: u64 = 1; +export def SYS_io_submit: u64 = 2; +export def SYS_io_cancel: u64 = 3; +export def SYS_io_getevents: u64 = 4; +export def SYS_setxattr: u64 = 5; +export def SYS_lsetxattr: u64 = 6; +export def SYS_fsetxattr: u64 = 7; +export def SYS_getxattr: u64 = 8; +export def SYS_lgetxattr: u64 = 9; +export def SYS_fgetxattr: u64 = 10; +export def SYS_listxattr: u64 = 11; +export def SYS_llistxattr: u64 = 12; +export def SYS_flistxattr: u64 = 13; +export def SYS_removexattr: u64 = 14; +export def SYS_lremovexattr: u64 = 15; +export def SYS_fremovexattr: u64 = 16; +export def SYS_getcwd: u64 = 17; +export def SYS_lookup_dcookie: u64 = 18; +export def SYS_eventfd2: u64 = 19; +export def SYS_epoll_create1: u64 = 20; +export def SYS_epoll_ctl: u64 = 21; +export def SYS_epoll_pwait: u64 = 22; +export def SYS_dup: u64 = 23; +export def SYS_dup3: u64 = 24; +export def SYS_fcntl: u64 = 25; +export def SYS_inotify_init1: u64 = 26; +export def SYS_inotify_add_watch: u64 = 27; +export def SYS_inotify_rm_watch: u64 = 28; +export def SYS_ioctl: u64 = 29; +export def SYS_ioprio_set: u64 = 30; +export def SYS_ioprio_get: u64 = 31; +export def SYS_flock: u64 = 32; +export def SYS_mknodat: u64 = 33; +export def SYS_mkdirat: u64 = 34; +export def SYS_unlinkat: u64 = 35; +export def SYS_symlinkat: u64 = 36; +export def SYS_linkat: u64 = 37; +export def SYS_renameat: u64 = 38; +export def SYS_umount2: u64 = 39; +export def SYS_mount: u64 = 40; +export def SYS_pivot_root: u64 = 41; +export def SYS_nfsservctl: u64 = 42; +export def SYS_statfs: u64 = 43; +export def SYS_fstatfs: u64 = 44; +export def SYS_truncate: u64 = 45; +export def SYS_ftruncate: u64 = 46; +export def SYS_fallocate: u64 = 47; +export def SYS_faccessat: u64 = 48; +export def SYS_chdir: u64 = 49; +export def SYS_fchdir: u64 = 50; +export def SYS_chroot: u64 = 51; +export def SYS_fchmod: u64 = 52; +export def SYS_fchmodat: u64 = 53; +export def SYS_fchownat: u64 = 54; +export def SYS_fchown: u64 = 55; +export def SYS_openat: u64 = 56; +export def SYS_close: u64 = 57; +export def SYS_vhangup: u64 = 58; +export def SYS_pipe2: u64 = 59; +export def SYS_quotactl: u64 = 60; +export def SYS_getdents64: u64 = 61; +export def SYS_lseek: u64 = 62; +export def SYS_read: u64 = 63; +export def SYS_write: u64 = 64; +export def SYS_readv: u64 = 65; +export def SYS_writev: u64 = 66; +export def SYS_pread64: u64 = 67; +export def SYS_pwrite64: u64 = 68; +export def SYS_preadv: u64 = 69; +export def SYS_pwritev: u64 = 70; +export def SYS_sendfile: u64 = 71; +export def SYS_pselect6: u64 = 72; +export def SYS_ppoll: u64 = 73; +export def SYS_signalfd4: u64 = 74; +export def SYS_vmsplice: u64 = 75; +export def SYS_splice: u64 = 76; +export def SYS_tee: u64 = 77; +export def SYS_readlinkat: u64 = 78; +export def SYS_newfstatat: u64 = 79; +export def SYS_fstat: u64 = 80; +export def SYS_sync: u64 = 81; +export def SYS_fsync: u64 = 82; +export def SYS_fdatasync: u64 = 83; +export def SYS_sync_file_range: u64 = 84; +export def SYS_timerfd_create: u64 = 85; +export def SYS_timerfd_settime: u64 = 86; +export def SYS_timerfd_gettime: u64 = 87; +export def SYS_utimensat: u64 = 88; +export def SYS_acct: u64 = 89; +export def SYS_capget: u64 = 90; +export def SYS_capset: u64 = 91; +export def SYS_personality: u64 = 92; +export def SYS_exit: u64 = 93; +export def SYS_exit_group: u64 = 94; +export def SYS_waitid: u64 = 95; +export def SYS_set_tid_address: u64 = 96; +export def SYS_unshare: u64 = 97; +export def SYS_futex: u64 = 98; +export def SYS_set_robust_list: u64 = 99; +export def SYS_get_robust_list: u64 = 100; +export def SYS_nanosleep: u64 = 101; +export def SYS_getitimer: u64 = 102; +export def SYS_setitimer: u64 = 103; +export def SYS_kexec_load: u64 = 104; +export def SYS_init_module: u64 = 105; +export def SYS_delete_module: u64 = 106; +export def SYS_timer_create: u64 = 107; +export def SYS_timer_gettime: u64 = 108; +export def SYS_timer_getoverrun: u64 = 109; +export def SYS_timer_settime: u64 = 110; +export def SYS_timer_delete: u64 = 111; +export def SYS_clock_settime: u64 = 112; +export def SYS_clock_gettime: u64 = 113; +export def SYS_clock_getres: u64 = 114; +export def SYS_clock_nanosleep: u64 = 115; +export def SYS_syslog: u64 = 116; +export def SYS_ptrace: u64 = 117; +export def SYS_sched_setparam: u64 = 118; +export def SYS_sched_setscheduler: u64 = 119; +export def SYS_sched_getscheduler: u64 = 120; +export def SYS_sched_getparam: u64 = 121; +export def SYS_sched_setaffinity: u64 = 122; +export def SYS_sched_getaffinity: u64 = 123; +export def SYS_sched_yield: u64 = 124; +export def SYS_sched_get_priority_max: u64 = 125; +export def SYS_sched_get_priority_min: u64 = 126; +export def SYS_sched_rr_get_interval: u64 = 127; +export def SYS_restart_syscall: u64 = 128; +export def SYS_kill: u64 = 129; +export def SYS_tkill: u64 = 130; +export def SYS_tgkill: u64 = 131; +export def SYS_sigaltstack: u64 = 132; +export def SYS_rt_sigsuspend: u64 = 133; +export def SYS_rt_sigaction: u64 = 134; +export def SYS_rt_sigprocmask: u64 = 135; +export def SYS_rt_sigpending: u64 = 136; +export def SYS_rt_sigtimedwait: u64 = 137; +export def SYS_rt_sigqueueinfo: u64 = 138; +export def SYS_rt_sigreturn: u64 = 139; +export def SYS_setpriority: u64 = 140; +export def SYS_getpriority: u64 = 141; +export def SYS_reboot: u64 = 142; +export def SYS_setregid: u64 = 143; +export def SYS_setgid: u64 = 144; +export def SYS_setreuid: u64 = 145; +export def SYS_setuid: u64 = 146; +export def SYS_setresuid: u64 = 147; +export def SYS_getresuid: u64 = 148; +export def SYS_setresgid: u64 = 149; +export def SYS_getresgid: u64 = 150; +export def SYS_setfsuid: u64 = 151; +export def SYS_setfsgid: u64 = 152; +export def SYS_times: u64 = 153; +export def SYS_setpgid: u64 = 154; +export def SYS_getpgid: u64 = 155; +export def SYS_getsid: u64 = 156; +export def SYS_setsid: u64 = 157; +export def SYS_getgroups: u64 = 158; +export def SYS_setgroups: u64 = 159; +export def SYS_uname: u64 = 160; +export def SYS_sethostname: u64 = 161; +export def SYS_setdomainname: u64 = 162; +export def SYS_getrlimit: u64 = 163; +export def SYS_setrlimit: u64 = 164; +export def SYS_getrusage: u64 = 165; +export def SYS_umask: u64 = 166; +export def SYS_prctl: u64 = 167; +export def SYS_getcpu: u64 = 168; +export def SYS_gettimeofday: u64 = 169; +export def SYS_settimeofday: u64 = 170; +export def SYS_adjtimex: u64 = 171; +export def SYS_getpid: u64 = 172; +export def SYS_getppid: u64 = 173; +export def SYS_getuid: u64 = 174; +export def SYS_geteuid: u64 = 175; +export def SYS_getgid: u64 = 176; +export def SYS_getegid: u64 = 177; +export def SYS_gettid: u64 = 178; +export def SYS_sysinfo: u64 = 179; +export def SYS_mq_open: u64 = 180; +export def SYS_mq_unlink: u64 = 181; +export def SYS_mq_timedsend: u64 = 182; +export def SYS_mq_timedreceive: u64 = 183; +export def SYS_mq_notify: u64 = 184; +export def SYS_mq_getsetattr: u64 = 185; +export def SYS_msgget: u64 = 186; +export def SYS_msgctl: u64 = 187; +export def SYS_msgrcv: u64 = 188; +export def SYS_msgsnd: u64 = 189; +export def SYS_semget: u64 = 190; +export def SYS_semctl: u64 = 191; +export def SYS_semtimedop: u64 = 192; +export def SYS_semop: u64 = 193; +export def SYS_shmget: u64 = 194; +export def SYS_shmctl: u64 = 195; +export def SYS_shmat: u64 = 196; +export def SYS_shmdt: u64 = 197; +export def SYS_socket: u64 = 198; +export def SYS_socketpair: u64 = 199; +export def SYS_bind: u64 = 200; +export def SYS_listen: u64 = 201; +export def SYS_accept: u64 = 202; +export def SYS_connect: u64 = 203; +export def SYS_getsockname: u64 = 204; +export def SYS_getpeername: u64 = 205; +export def SYS_sendto: u64 = 206; +export def SYS_recvfrom: u64 = 207; +export def SYS_setsockopt: u64 = 208; +export def SYS_getsockopt: u64 = 209; +export def SYS_shutdown: u64 = 210; +export def SYS_sendmsg: u64 = 211; +export def SYS_recvmsg: u64 = 212; +export def SYS_readahead: u64 = 213; +export def SYS_brk: u64 = 214; +export def SYS_munmap: u64 = 215; +export def SYS_mremap: u64 = 216; +export def SYS_add_key: u64 = 217; +export def SYS_request_key: u64 = 218; +export def SYS_keyctl: u64 = 219; +export def SYS_clone: u64 = 220; +export def SYS_execve: u64 = 221; +export def SYS_mmap: u64 = 222; +export def SYS_fadvise64: u64 = 223; +export def SYS_swapon: u64 = 224; +export def SYS_swapoff: u64 = 225; +export def SYS_mprotect: u64 = 226; +export def SYS_msync: u64 = 227; +export def SYS_mlock: u64 = 228; +export def SYS_munlock: u64 = 229; +export def SYS_mlockall: u64 = 230; +export def SYS_munlockall: u64 = 231; +export def SYS_mincore: u64 = 232; +export def SYS_madvise: u64 = 233; +export def SYS_remap_file_pages: u64 = 234; +export def SYS_mbind: u64 = 235; +export def SYS_get_mempolicy: u64 = 236; +export def SYS_set_mempolicy: u64 = 237; +export def SYS_migrate_pages: u64 = 238; +export def SYS_move_pages: u64 = 239; +export def SYS_rt_tgsigqueueinfo: u64 = 240; +export def SYS_perf_event_open: u64 = 241; +export def SYS_accept4: u64 = 242; +export def SYS_recvmmsg: u64 = 243; +export def SYS_wait4: u64 = 260; +export def SYS_prlimit64: u64 = 261; +export def SYS_fanotify_init: u64 = 262; +export def SYS_fanotify_mark: u64 = 263; +export def SYS_name_to_handle_at: u64 = 264; +export def SYS_open_by_handle_at: u64 = 265; +export def SYS_clock_adjtime: u64 = 266; +export def SYS_syncfs: u64 = 267; +export def SYS_setns: u64 = 268; +export def SYS_sendmmsg: u64 = 269; +export def SYS_process_vm_readv: u64 = 270; +export def SYS_process_vm_writev: u64 = 271; +export def SYS_kcmp: u64 = 272; +export def SYS_finit_module: u64 = 273; +export def SYS_sched_setattr: u64 = 274; +export def SYS_sched_getattr: u64 = 275; +export def SYS_renameat2: u64 = 276; +export def SYS_seccomp: u64 = 277; +export def SYS_getrandom: u64 = 278; +export def SYS_memfd_create: u64 = 279; +export def SYS_bpf: u64 = 280; +export def SYS_execveat: u64 = 281; +export def SYS_userfaultfd: u64 = 282; +export def SYS_membarrier: u64 = 283; +export def SYS_mlock2: u64 = 284; +export def SYS_copy_file_range: u64 = 285; +export def SYS_preadv2: u64 = 286; +export def SYS_pwritev2: u64 = 287; +export def SYS_pkey_mprotect: u64 = 288; +export def SYS_pkey_alloc: u64 = 289; +export def SYS_pkey_free: u64 = 290; +export def SYS_statx: u64 = 291; +export def SYS_io_pgetevents: u64 = 292; +export def SYS_rseq: u64 = 293; +export def SYS_kexec_file_load: u64 = 294; +export def SYS_pidfd_send_signal: u64 = 424; +export def SYS_io_uring_setup: u64 = 425; +export def SYS_io_uring_enter: u64 = 426; +export def SYS_io_uring_register: u64 = 427; +export def SYS_open_tree: u64 = 428; +export def SYS_move_mount: u64 = 429; +export def SYS_fsopen: u64 = 430; +export def SYS_fsconfig: u64 = 431; +export def SYS_fsmount: u64 = 432; +export def SYS_fspick: u64 = 433; +export def SYS_pidfd_open: u64 = 434; +export def SYS_clone3: u64 = 435; +export def SYS_faccessat2: u64 = 439; diff --git a/rt/+linux/syscallno+x86_64.ha b/rt/+linux/syscallno+x86_64.ha @@ -1,346 +1,346 @@ -export def SYS_read: u64 = 0u64; -export def SYS_write: u64 = 1u64; -export def SYS_open: u64 = 2u64; -export def SYS_close: u64 = 3u64; -export def SYS_stat: u64 = 4u64; -export def SYS_fstat: u64 = 5u64; -export def SYS_lstat: u64 = 6u64; -export def SYS_poll: u64 = 7u64; -export def SYS_lseek: u64 = 8u64; -export def SYS_mmap: u64 = 9u64; -export def SYS_mprotect: u64 = 10u64; -export def SYS_munmap: u64 = 11u64; -export def SYS_brk: u64 = 12u64; -export def SYS_rt_sigaction: u64 = 13u64; -export def SYS_rt_sigprocmask: u64 = 14u64; -export def SYS_rt_sigreturn: u64 = 15u64; -export def SYS_ioctl: u64 = 16u64; -export def SYS_pread64: u64 = 17u64; -export def SYS_pwrite64: u64 = 18u64; -export def SYS_readv: u64 = 19u64; -export def SYS_writev: u64 = 20u64; -export def SYS_access: u64 = 21u64; -export def SYS_pipe: u64 = 22u64; -export def SYS_select: u64 = 23u64; -export def SYS_sched_yield: u64 = 24u64; -export def SYS_mremap: u64 = 25u64; -export def SYS_msync: u64 = 26u64; -export def SYS_mincore: u64 = 27u64; -export def SYS_madvise: u64 = 28u64; -export def SYS_shmget: u64 = 29u64; -export def SYS_shmat: u64 = 30u64; -export def SYS_shmctl: u64 = 31u64; -export def SYS_dup: u64 = 32u64; -export def SYS_dup2: u64 = 33u64; -export def SYS_pause: u64 = 34u64; -export def SYS_nanosleep: u64 = 35u64; -export def SYS_getitimer: u64 = 36u64; -export def SYS_alarm: u64 = 37u64; -export def SYS_setitimer: u64 = 38u64; -export def SYS_getpid: u64 = 39u64; -export def SYS_sendfile: u64 = 40u64; -export def SYS_socket: u64 = 41u64; -export def SYS_connect: u64 = 42u64; -export def SYS_accept: u64 = 43u64; -export def SYS_sendto: u64 = 44u64; -export def SYS_recvfrom: u64 = 45u64; -export def SYS_sendmsg: u64 = 46u64; -export def SYS_recvmsg: u64 = 47u64; -export def SYS_shutdown: u64 = 48u64; -export def SYS_bind: u64 = 49u64; -export def SYS_listen: u64 = 50u64; -export def SYS_getsockname: u64 = 51u64; -export def SYS_getpeername: u64 = 52u64; -export def SYS_socketpair: u64 = 53u64; -export def SYS_setsockopt: u64 = 54u64; -export def SYS_getsockopt: u64 = 55u64; -export def SYS_clone: u64 = 56u64; -export def SYS_fork: u64 = 57u64; -export def SYS_vfork: u64 = 58u64; -export def SYS_execve: u64 = 59u64; -export def SYS_exit: u64 = 60u64; -export def SYS_wait4: u64 = 61u64; -export def SYS_kill: u64 = 62u64; -export def SYS_uname: u64 = 63u64; -export def SYS_semget: u64 = 64u64; -export def SYS_semop: u64 = 65u64; -export def SYS_semctl: u64 = 66u64; -export def SYS_shmdt: u64 = 67u64; -export def SYS_msgget: u64 = 68u64; -export def SYS_msgsnd: u64 = 69u64; -export def SYS_msgrcv: u64 = 70u64; -export def SYS_msgctl: u64 = 71u64; -export def SYS_fcntl: u64 = 72u64; -export def SYS_flock: u64 = 73u64; -export def SYS_fsync: u64 = 74u64; -export def SYS_fdatasync: u64 = 75u64; -export def SYS_truncate: u64 = 76u64; -export def SYS_ftruncate: u64 = 77u64; -export def SYS_getdents: u64 = 78u64; -export def SYS_getcwd: u64 = 79u64; -export def SYS_chdir: u64 = 80u64; -export def SYS_fchdir: u64 = 81u64; -export def SYS_rename: u64 = 82u64; -export def SYS_mkdir: u64 = 83u64; -export def SYS_rmdir: u64 = 84u64; -export def SYS_creat: u64 = 85u64; -export def SYS_link: u64 = 86u64; -export def SYS_unlink: u64 = 87u64; -export def SYS_symlink: u64 = 88u64; -export def SYS_readlink: u64 = 89u64; -export def SYS_chmod: u64 = 90u64; -export def SYS_fchmod: u64 = 91u64; -export def SYS_chown: u64 = 92u64; -export def SYS_fchown: u64 = 93u64; -export def SYS_lchown: u64 = 94u64; -export def SYS_umask: u64 = 95u64; -export def SYS_gettimeofday: u64 = 96u64; -export def SYS_getrlimit: u64 = 97u64; -export def SYS_getrusage: u64 = 98u64; -export def SYS_sysinfo: u64 = 99u64; -export def SYS_times: u64 = 100u64; -export def SYS_ptrace: u64 = 101u64; -export def SYS_getuid: u64 = 102u64; -export def SYS_syslog: u64 = 103u64; -export def SYS_getgid: u64 = 104u64; -export def SYS_setuid: u64 = 105u64; -export def SYS_setgid: u64 = 106u64; -export def SYS_geteuid: u64 = 107u64; -export def SYS_getegid: u64 = 108u64; -export def SYS_setpgid: u64 = 109u64; -export def SYS_getppid: u64 = 110u64; -export def SYS_getpgrp: u64 = 111u64; -export def SYS_setsid: u64 = 112u64; -export def SYS_setreuid: u64 = 113u64; -export def SYS_setregid: u64 = 114u64; -export def SYS_getgroups: u64 = 115u64; -export def SYS_setgroups: u64 = 116u64; -export def SYS_setresuid: u64 = 117u64; -export def SYS_getresuid: u64 = 118u64; -export def SYS_setresgid: u64 = 119u64; -export def SYS_getresgid: u64 = 120u64; -export def SYS_getpgid: u64 = 121u64; -export def SYS_setfsuid: u64 = 122u64; -export def SYS_setfsgid: u64 = 123u64; -export def SYS_getsid: u64 = 124u64; -export def SYS_capget: u64 = 125u64; -export def SYS_capset: u64 = 126u64; -export def SYS_rt_sigpending: u64 = 127u64; -export def SYS_rt_sigtimedwait: u64 = 128u64; -export def SYS_rt_sigqueueinfo: u64 = 129u64; -export def SYS_rt_sigsuspend: u64 = 130u64; -export def SYS_sigaltstack: u64 = 131u64; -export def SYS_utime: u64 = 132u64; -export def SYS_mknod: u64 = 133u64; -export def SYS_uselib: u64 = 134u64; -export def SYS_personality: u64 = 135u64; -export def SYS_ustat: u64 = 136u64; -export def SYS_statfs: u64 = 137u64; -export def SYS_fstatfs: u64 = 138u64; -export def SYS_sysfs: u64 = 139u64; -export def SYS_getpriority: u64 = 140u64; -export def SYS_setpriority: u64 = 141u64; -export def SYS_sched_setparam: u64 = 142u64; -export def SYS_sched_getparam: u64 = 143u64; -export def SYS_sched_setscheduler: u64 = 144u64; -export def SYS_sched_getscheduler: u64 = 145u64; -export def SYS_sched_get_priority_max: u64 = 146u64; -export def SYS_sched_get_priority_min: u64 = 147u64; -export def SYS_sched_rr_get_interval: u64 = 148u64; -export def SYS_mlock: u64 = 149u64; -export def SYS_munlock: u64 = 150u64; -export def SYS_mlockall: u64 = 151u64; -export def SYS_munlockall: u64 = 152u64; -export def SYS_vhangup: u64 = 153u64; -export def SYS_modify_ldt: u64 = 154u64; -export def SYS_pivot_root: u64 = 155u64; -export def SYS__sysctl: u64 = 156u64; -export def SYS_prctl: u64 = 157u64; -export def SYS_arch_prctl: u64 = 158u64; -export def SYS_adjtimex: u64 = 159u64; -export def SYS_setrlimit: u64 = 160u64; -export def SYS_chroot: u64 = 161u64; -export def SYS_sync: u64 = 162u64; -export def SYS_acct: u64 = 163u64; -export def SYS_settimeofday: u64 = 164u64; -export def SYS_mount: u64 = 165u64; -export def SYS_umount2: u64 = 166u64; -export def SYS_swapon: u64 = 167u64; -export def SYS_swapoff: u64 = 168u64; -export def SYS_reboot: u64 = 169u64; -export def SYS_sethostname: u64 = 170u64; -export def SYS_setdomainname: u64 = 171u64; -export def SYS_iopl: u64 = 172u64; -export def SYS_ioperm: u64 = 173u64; -export def SYS_create_module: u64 = 174u64; -export def SYS_init_module: u64 = 175u64; -export def SYS_delete_module: u64 = 176u64; -export def SYS_get_kernel_syms: u64 = 177u64; -export def SYS_query_module: u64 = 178u64; -export def SYS_quotactl: u64 = 179u64; -export def SYS_nfsservctl: u64 = 180u64; -export def SYS_getpmsg: u64 = 181u64; -export def SYS_putpmsg: u64 = 182u64; -export def SYS_afs_syscall: u64 = 183u64; -export def SYS_tuxcall: u64 = 184u64; -export def SYS_security: u64 = 185u64; -export def SYS_gettid: u64 = 186u64; -export def SYS_readahead: u64 = 187u64; -export def SYS_setxattr: u64 = 188u64; -export def SYS_lsetxattr: u64 = 189u64; -export def SYS_fsetxattr: u64 = 190u64; -export def SYS_getxattr: u64 = 191u64; -export def SYS_lgetxattr: u64 = 192u64; -export def SYS_fgetxattr: u64 = 193u64; -export def SYS_listxattr: u64 = 194u64; -export def SYS_llistxattr: u64 = 195u64; -export def SYS_flistxattr: u64 = 196u64; -export def SYS_removexattr: u64 = 197u64; -export def SYS_lremovexattr: u64 = 198u64; -export def SYS_fremovexattr: u64 = 199u64; -export def SYS_tkill: u64 = 200u64; -export def SYS_time: u64 = 201u64; -export def SYS_futex: u64 = 202u64; -export def SYS_sched_setaffinity: u64 = 203u64; -export def SYS_sched_getaffinity: u64 = 204u64; -export def SYS_set_thread_area: u64 = 205u64; -export def SYS_io_setup: u64 = 206u64; -export def SYS_io_destroy: u64 = 207u64; -export def SYS_io_getevents: u64 = 208u64; -export def SYS_io_submit: u64 = 209u64; -export def SYS_io_cancel: u64 = 210u64; -export def SYS_get_thread_area: u64 = 211u64; -export def SYS_lookup_dcookie: u64 = 212u64; -export def SYS_epoll_create: u64 = 213u64; -export def SYS_epoll_ctl_old: u64 = 214u64; -export def SYS_epoll_wait_old: u64 = 215u64; -export def SYS_remap_file_pages: u64 = 216u64; -export def SYS_getdents64: u64 = 217u64; -export def SYS_set_tid_address: u64 = 218u64; -export def SYS_restart_syscall: u64 = 219u64; -export def SYS_semtimedop: u64 = 220u64; -export def SYS_fadvise64: u64 = 221u64; -export def SYS_timer_create: u64 = 222u64; -export def SYS_timer_settime: u64 = 223u64; -export def SYS_timer_gettime: u64 = 224u64; -export def SYS_timer_getoverrun: u64 = 225u64; -export def SYS_timer_delete: u64 = 226u64; -export def SYS_clock_settime: u64 = 227u64; -export def SYS_clock_gettime: u64 = 228u64; -export def SYS_clock_getres: u64 = 229u64; -export def SYS_clock_nanosleep: u64 = 230u64; -export def SYS_exit_group: u64 = 231u64; -export def SYS_epoll_wait: u64 = 232u64; -export def SYS_epoll_ctl: u64 = 233u64; -export def SYS_tgkill: u64 = 234u64; -export def SYS_utimes: u64 = 235u64; -export def SYS_vserver: u64 = 236u64; -export def SYS_mbind: u64 = 237u64; -export def SYS_set_mempolicy: u64 = 238u64; -export def SYS_get_mempolicy: u64 = 239u64; -export def SYS_mq_open: u64 = 240u64; -export def SYS_mq_unlink: u64 = 241u64; -export def SYS_mq_timedsend: u64 = 242u64; -export def SYS_mq_timedreceive: u64 = 243u64; -export def SYS_mq_notify: u64 = 244u64; -export def SYS_mq_getsetattr: u64 = 245u64; -export def SYS_kexec_load: u64 = 246u64; -export def SYS_waitid: u64 = 247u64; -export def SYS_add_key: u64 = 248u64; -export def SYS_request_key: u64 = 249u64; -export def SYS_keyctl: u64 = 250u64; -export def SYS_ioprio_set: u64 = 251u64; -export def SYS_ioprio_get: u64 = 252u64; -export def SYS_inotify_init: u64 = 253u64; -export def SYS_inotify_add_watch: u64 = 254u64; -export def SYS_inotify_rm_watch: u64 = 255u64; -export def SYS_migrate_pages: u64 = 256u64; -export def SYS_openat: u64 = 257u64; -export def SYS_mkdirat: u64 = 258u64; -export def SYS_mknodat: u64 = 259u64; -export def SYS_fchownat: u64 = 260u64; -export def SYS_futimesat: u64 = 261u64; -export def SYS_newfstatat: u64 = 262u64; -export def SYS_unlinkat: u64 = 263u64; -export def SYS_renameat: u64 = 264u64; -export def SYS_linkat: u64 = 265u64; -export def SYS_symlinkat: u64 = 266u64; -export def SYS_readlinkat: u64 = 267u64; -export def SYS_fchmodat: u64 = 268u64; -export def SYS_faccessat: u64 = 269u64; -export def SYS_pselect6: u64 = 270u64; -export def SYS_ppoll: u64 = 271u64; -export def SYS_unshare: u64 = 272u64; -export def SYS_set_robust_list: u64 = 273u64; -export def SYS_get_robust_list: u64 = 274u64; -export def SYS_splice: u64 = 275u64; -export def SYS_tee: u64 = 276u64; -export def SYS_sync_file_range: u64 = 277u64; -export def SYS_vmsplice: u64 = 278u64; -export def SYS_move_pages: u64 = 279u64; -export def SYS_utimensat: u64 = 280u64; -export def SYS_epoll_pwait: u64 = 281u64; -export def SYS_signalfd: u64 = 282u64; -export def SYS_timerfd_create: u64 = 283u64; -export def SYS_eventfd: u64 = 284u64; -export def SYS_fallocate: u64 = 285u64; -export def SYS_timerfd_settime: u64 = 286u64; -export def SYS_timerfd_gettime: u64 = 287u64; -export def SYS_accept4: u64 = 288u64; -export def SYS_signalfd4: u64 = 289u64; -export def SYS_eventfd2: u64 = 290u64; -export def SYS_epoll_create1: u64 = 291u64; -export def SYS_dup3: u64 = 292u64; -export def SYS_pipe2: u64 = 293u64; -export def SYS_inotify_init1: u64 = 294u64; -export def SYS_preadv: u64 = 295u64; -export def SYS_pwritev: u64 = 296u64; -export def SYS_rt_tgsigqueueinfo: u64 = 297u64; -export def SYS_perf_event_open: u64 = 298u64; -export def SYS_recvmmsg: u64 = 299u64; -export def SYS_fanotify_init: u64 = 300u64; -export def SYS_fanotify_mark: u64 = 301u64; -export def SYS_prlimit64: u64 = 302u64; -export def SYS_name_to_handle_at: u64 = 303u64; -export def SYS_open_by_handle_at: u64 = 304u64; -export def SYS_clock_adjtime: u64 = 305u64; -export def SYS_syncfs: u64 = 306u64; -export def SYS_sendmmsg: u64 = 307u64; -export def SYS_setns: u64 = 308u64; -export def SYS_getcpu: u64 = 309u64; -export def SYS_process_vm_readv: u64 = 310u64; -export def SYS_process_vm_writev: u64 = 311u64; -export def SYS_kcmp: u64 = 312u64; -export def SYS_finit_module: u64 = 313u64; -export def SYS_sched_setattr: u64 = 314u64; -export def SYS_sched_getattr: u64 = 315u64; -export def SYS_renameat2: u64 = 316u64; -export def SYS_seccomp: u64 = 317u64; -export def SYS_getrandom: u64 = 318u64; -export def SYS_memfd_create: u64 = 319u64; -export def SYS_kexec_file_load: u64 = 320u64; -export def SYS_bpf: u64 = 321u64; -export def SYS_execveat: u64 = 322u64; -export def SYS_userfaultfd: u64 = 323u64; -export def SYS_membarrier: u64 = 324u64; -export def SYS_mlock2: u64 = 325u64; -export def SYS_copy_file_range: u64 = 326u64; -export def SYS_preadv2: u64 = 327u64; -export def SYS_pwritev2: u64 = 328u64; -export def SYS_pkey_mprotect: u64 = 329u64; -export def SYS_pkey_alloc: u64 = 330u64; -export def SYS_pkey_free: u64 = 331u64; -export def SYS_statx: u64 = 332u64; -export def SYS_io_pgetevents: u64 = 333u64; -export def SYS_rseq: u64 = 334u64; -export def SYS_pidfd_send_signal: u64 = 424u64; -export def SYS_io_uring_setup: u64 = 425u64; -export def SYS_io_uring_enter: u64 = 426u64; -export def SYS_io_uring_register: u64 = 427u64; -export def SYS_open_tree: u64 = 428u64; -export def SYS_move_mount: u64 = 429u64; -export def SYS_fsopen: u64 = 430u64; -export def SYS_fsconfig: u64 = 431u64; -export def SYS_fsmount: u64 = 432u64; -export def SYS_fspick: u64 = 433u64; -export def SYS_faccessat2: u64 = 439u64; +export def SYS_read: u64 = 0; +export def SYS_write: u64 = 1; +export def SYS_open: u64 = 2; +export def SYS_close: u64 = 3; +export def SYS_stat: u64 = 4; +export def SYS_fstat: u64 = 5; +export def SYS_lstat: u64 = 6; +export def SYS_poll: u64 = 7; +export def SYS_lseek: u64 = 8; +export def SYS_mmap: u64 = 9; +export def SYS_mprotect: u64 = 10; +export def SYS_munmap: u64 = 11; +export def SYS_brk: u64 = 12; +export def SYS_rt_sigaction: u64 = 13; +export def SYS_rt_sigprocmask: u64 = 14; +export def SYS_rt_sigreturn: u64 = 15; +export def SYS_ioctl: u64 = 16; +export def SYS_pread64: u64 = 17; +export def SYS_pwrite64: u64 = 18; +export def SYS_readv: u64 = 19; +export def SYS_writev: u64 = 20; +export def SYS_access: u64 = 21; +export def SYS_pipe: u64 = 22; +export def SYS_select: u64 = 23; +export def SYS_sched_yield: u64 = 24; +export def SYS_mremap: u64 = 25; +export def SYS_msync: u64 = 26; +export def SYS_mincore: u64 = 27; +export def SYS_madvise: u64 = 28; +export def SYS_shmget: u64 = 29; +export def SYS_shmat: u64 = 30; +export def SYS_shmctl: u64 = 31; +export def SYS_dup: u64 = 32; +export def SYS_dup2: u64 = 33; +export def SYS_pause: u64 = 34; +export def SYS_nanosleep: u64 = 35; +export def SYS_getitimer: u64 = 36; +export def SYS_alarm: u64 = 37; +export def SYS_setitimer: u64 = 38; +export def SYS_getpid: u64 = 39; +export def SYS_sendfile: u64 = 40; +export def SYS_socket: u64 = 41; +export def SYS_connect: u64 = 42; +export def SYS_accept: u64 = 43; +export def SYS_sendto: u64 = 44; +export def SYS_recvfrom: u64 = 45; +export def SYS_sendmsg: u64 = 46; +export def SYS_recvmsg: u64 = 47; +export def SYS_shutdown: u64 = 48; +export def SYS_bind: u64 = 49; +export def SYS_listen: u64 = 50; +export def SYS_getsockname: u64 = 51; +export def SYS_getpeername: u64 = 52; +export def SYS_socketpair: u64 = 53; +export def SYS_setsockopt: u64 = 54; +export def SYS_getsockopt: u64 = 55; +export def SYS_clone: u64 = 56; +export def SYS_fork: u64 = 57; +export def SYS_vfork: u64 = 58; +export def SYS_execve: u64 = 59; +export def SYS_exit: u64 = 60; +export def SYS_wait4: u64 = 61; +export def SYS_kill: u64 = 62; +export def SYS_uname: u64 = 63; +export def SYS_semget: u64 = 64; +export def SYS_semop: u64 = 65; +export def SYS_semctl: u64 = 66; +export def SYS_shmdt: u64 = 67; +export def SYS_msgget: u64 = 68; +export def SYS_msgsnd: u64 = 69; +export def SYS_msgrcv: u64 = 70; +export def SYS_msgctl: u64 = 71; +export def SYS_fcntl: u64 = 72; +export def SYS_flock: u64 = 73; +export def SYS_fsync: u64 = 74; +export def SYS_fdatasync: u64 = 75; +export def SYS_truncate: u64 = 76; +export def SYS_ftruncate: u64 = 77; +export def SYS_getdents: u64 = 78; +export def SYS_getcwd: u64 = 79; +export def SYS_chdir: u64 = 80; +export def SYS_fchdir: u64 = 81; +export def SYS_rename: u64 = 82; +export def SYS_mkdir: u64 = 83; +export def SYS_rmdir: u64 = 84; +export def SYS_creat: u64 = 85; +export def SYS_link: u64 = 86; +export def SYS_unlink: u64 = 87; +export def SYS_symlink: u64 = 88; +export def SYS_readlink: u64 = 89; +export def SYS_chmod: u64 = 90; +export def SYS_fchmod: u64 = 91; +export def SYS_chown: u64 = 92; +export def SYS_fchown: u64 = 93; +export def SYS_lchown: u64 = 94; +export def SYS_umask: u64 = 95; +export def SYS_gettimeofday: u64 = 96; +export def SYS_getrlimit: u64 = 97; +export def SYS_getrusage: u64 = 98; +export def SYS_sysinfo: u64 = 99; +export def SYS_times: u64 = 100; +export def SYS_ptrace: u64 = 101; +export def SYS_getuid: u64 = 102; +export def SYS_syslog: u64 = 103; +export def SYS_getgid: u64 = 104; +export def SYS_setuid: u64 = 105; +export def SYS_setgid: u64 = 106; +export def SYS_geteuid: u64 = 107; +export def SYS_getegid: u64 = 108; +export def SYS_setpgid: u64 = 109; +export def SYS_getppid: u64 = 110; +export def SYS_getpgrp: u64 = 111; +export def SYS_setsid: u64 = 112; +export def SYS_setreuid: u64 = 113; +export def SYS_setregid: u64 = 114; +export def SYS_getgroups: u64 = 115; +export def SYS_setgroups: u64 = 116; +export def SYS_setresuid: u64 = 117; +export def SYS_getresuid: u64 = 118; +export def SYS_setresgid: u64 = 119; +export def SYS_getresgid: u64 = 120; +export def SYS_getpgid: u64 = 121; +export def SYS_setfsuid: u64 = 122; +export def SYS_setfsgid: u64 = 123; +export def SYS_getsid: u64 = 124; +export def SYS_capget: u64 = 125; +export def SYS_capset: u64 = 126; +export def SYS_rt_sigpending: u64 = 127; +export def SYS_rt_sigtimedwait: u64 = 128; +export def SYS_rt_sigqueueinfo: u64 = 129; +export def SYS_rt_sigsuspend: u64 = 130; +export def SYS_sigaltstack: u64 = 131; +export def SYS_utime: u64 = 132; +export def SYS_mknod: u64 = 133; +export def SYS_uselib: u64 = 134; +export def SYS_personality: u64 = 135; +export def SYS_ustat: u64 = 136; +export def SYS_statfs: u64 = 137; +export def SYS_fstatfs: u64 = 138; +export def SYS_sysfs: u64 = 139; +export def SYS_getpriority: u64 = 140; +export def SYS_setpriority: u64 = 141; +export def SYS_sched_setparam: u64 = 142; +export def SYS_sched_getparam: u64 = 143; +export def SYS_sched_setscheduler: u64 = 144; +export def SYS_sched_getscheduler: u64 = 145; +export def SYS_sched_get_priority_max: u64 = 146; +export def SYS_sched_get_priority_min: u64 = 147; +export def SYS_sched_rr_get_interval: u64 = 148; +export def SYS_mlock: u64 = 149; +export def SYS_munlock: u64 = 150; +export def SYS_mlockall: u64 = 151; +export def SYS_munlockall: u64 = 152; +export def SYS_vhangup: u64 = 153; +export def SYS_modify_ldt: u64 = 154; +export def SYS_pivot_root: u64 = 155; +export def SYS__sysctl: u64 = 156; +export def SYS_prctl: u64 = 157; +export def SYS_arch_prctl: u64 = 158; +export def SYS_adjtimex: u64 = 159; +export def SYS_setrlimit: u64 = 160; +export def SYS_chroot: u64 = 161; +export def SYS_sync: u64 = 162; +export def SYS_acct: u64 = 163; +export def SYS_settimeofday: u64 = 164; +export def SYS_mount: u64 = 165; +export def SYS_umount2: u64 = 166; +export def SYS_swapon: u64 = 167; +export def SYS_swapoff: u64 = 168; +export def SYS_reboot: u64 = 169; +export def SYS_sethostname: u64 = 170; +export def SYS_setdomainname: u64 = 171; +export def SYS_iopl: u64 = 172; +export def SYS_ioperm: u64 = 173; +export def SYS_create_module: u64 = 174; +export def SYS_init_module: u64 = 175; +export def SYS_delete_module: u64 = 176; +export def SYS_get_kernel_syms: u64 = 177; +export def SYS_query_module: u64 = 178; +export def SYS_quotactl: u64 = 179; +export def SYS_nfsservctl: u64 = 180; +export def SYS_getpmsg: u64 = 181; +export def SYS_putpmsg: u64 = 182; +export def SYS_afs_syscall: u64 = 183; +export def SYS_tuxcall: u64 = 184; +export def SYS_security: u64 = 185; +export def SYS_gettid: u64 = 186; +export def SYS_readahead: u64 = 187; +export def SYS_setxattr: u64 = 188; +export def SYS_lsetxattr: u64 = 189; +export def SYS_fsetxattr: u64 = 190; +export def SYS_getxattr: u64 = 191; +export def SYS_lgetxattr: u64 = 192; +export def SYS_fgetxattr: u64 = 193; +export def SYS_listxattr: u64 = 194; +export def SYS_llistxattr: u64 = 195; +export def SYS_flistxattr: u64 = 196; +export def SYS_removexattr: u64 = 197; +export def SYS_lremovexattr: u64 = 198; +export def SYS_fremovexattr: u64 = 199; +export def SYS_tkill: u64 = 200; +export def SYS_time: u64 = 201; +export def SYS_futex: u64 = 202; +export def SYS_sched_setaffinity: u64 = 203; +export def SYS_sched_getaffinity: u64 = 204; +export def SYS_set_thread_area: u64 = 205; +export def SYS_io_setup: u64 = 206; +export def SYS_io_destroy: u64 = 207; +export def SYS_io_getevents: u64 = 208; +export def SYS_io_submit: u64 = 209; +export def SYS_io_cancel: u64 = 210; +export def SYS_get_thread_area: u64 = 211; +export def SYS_lookup_dcookie: u64 = 212; +export def SYS_epoll_create: u64 = 213; +export def SYS_epoll_ctl_old: u64 = 214; +export def SYS_epoll_wait_old: u64 = 215; +export def SYS_remap_file_pages: u64 = 216; +export def SYS_getdents64: u64 = 217; +export def SYS_set_tid_address: u64 = 218; +export def SYS_restart_syscall: u64 = 219; +export def SYS_semtimedop: u64 = 220; +export def SYS_fadvise64: u64 = 221; +export def SYS_timer_create: u64 = 222; +export def SYS_timer_settime: u64 = 223; +export def SYS_timer_gettime: u64 = 224; +export def SYS_timer_getoverrun: u64 = 225; +export def SYS_timer_delete: u64 = 226; +export def SYS_clock_settime: u64 = 227; +export def SYS_clock_gettime: u64 = 228; +export def SYS_clock_getres: u64 = 229; +export def SYS_clock_nanosleep: u64 = 230; +export def SYS_exit_group: u64 = 231; +export def SYS_epoll_wait: u64 = 232; +export def SYS_epoll_ctl: u64 = 233; +export def SYS_tgkill: u64 = 234; +export def SYS_utimes: u64 = 235; +export def SYS_vserver: u64 = 236; +export def SYS_mbind: u64 = 237; +export def SYS_set_mempolicy: u64 = 238; +export def SYS_get_mempolicy: u64 = 239; +export def SYS_mq_open: u64 = 240; +export def SYS_mq_unlink: u64 = 241; +export def SYS_mq_timedsend: u64 = 242; +export def SYS_mq_timedreceive: u64 = 243; +export def SYS_mq_notify: u64 = 244; +export def SYS_mq_getsetattr: u64 = 245; +export def SYS_kexec_load: u64 = 246; +export def SYS_waitid: u64 = 247; +export def SYS_add_key: u64 = 248; +export def SYS_request_key: u64 = 249; +export def SYS_keyctl: u64 = 250; +export def SYS_ioprio_set: u64 = 251; +export def SYS_ioprio_get: u64 = 252; +export def SYS_inotify_init: u64 = 253; +export def SYS_inotify_add_watch: u64 = 254; +export def SYS_inotify_rm_watch: u64 = 255; +export def SYS_migrate_pages: u64 = 256; +export def SYS_openat: u64 = 257; +export def SYS_mkdirat: u64 = 258; +export def SYS_mknodat: u64 = 259; +export def SYS_fchownat: u64 = 260; +export def SYS_futimesat: u64 = 261; +export def SYS_newfstatat: u64 = 262; +export def SYS_unlinkat: u64 = 263; +export def SYS_renameat: u64 = 264; +export def SYS_linkat: u64 = 265; +export def SYS_symlinkat: u64 = 266; +export def SYS_readlinkat: u64 = 267; +export def SYS_fchmodat: u64 = 268; +export def SYS_faccessat: u64 = 269; +export def SYS_pselect6: u64 = 270; +export def SYS_ppoll: u64 = 271; +export def SYS_unshare: u64 = 272; +export def SYS_set_robust_list: u64 = 273; +export def SYS_get_robust_list: u64 = 274; +export def SYS_splice: u64 = 275; +export def SYS_tee: u64 = 276; +export def SYS_sync_file_range: u64 = 277; +export def SYS_vmsplice: u64 = 278; +export def SYS_move_pages: u64 = 279; +export def SYS_utimensat: u64 = 280; +export def SYS_epoll_pwait: u64 = 281; +export def SYS_signalfd: u64 = 282; +export def SYS_timerfd_create: u64 = 283; +export def SYS_eventfd: u64 = 284; +export def SYS_fallocate: u64 = 285; +export def SYS_timerfd_settime: u64 = 286; +export def SYS_timerfd_gettime: u64 = 287; +export def SYS_accept4: u64 = 288; +export def SYS_signalfd4: u64 = 289; +export def SYS_eventfd2: u64 = 290; +export def SYS_epoll_create1: u64 = 291; +export def SYS_dup3: u64 = 292; +export def SYS_pipe2: u64 = 293; +export def SYS_inotify_init1: u64 = 294; +export def SYS_preadv: u64 = 295; +export def SYS_pwritev: u64 = 296; +export def SYS_rt_tgsigqueueinfo: u64 = 297; +export def SYS_perf_event_open: u64 = 298; +export def SYS_recvmmsg: u64 = 299; +export def SYS_fanotify_init: u64 = 300; +export def SYS_fanotify_mark: u64 = 301; +export def SYS_prlimit64: u64 = 302; +export def SYS_name_to_handle_at: u64 = 303; +export def SYS_open_by_handle_at: u64 = 304; +export def SYS_clock_adjtime: u64 = 305; +export def SYS_syncfs: u64 = 306; +export def SYS_sendmmsg: u64 = 307; +export def SYS_setns: u64 = 308; +export def SYS_getcpu: u64 = 309; +export def SYS_process_vm_readv: u64 = 310; +export def SYS_process_vm_writev: u64 = 311; +export def SYS_kcmp: u64 = 312; +export def SYS_finit_module: u64 = 313; +export def SYS_sched_setattr: u64 = 314; +export def SYS_sched_getattr: u64 = 315; +export def SYS_renameat2: u64 = 316; +export def SYS_seccomp: u64 = 317; +export def SYS_getrandom: u64 = 318; +export def SYS_memfd_create: u64 = 319; +export def SYS_kexec_file_load: u64 = 320; +export def SYS_bpf: u64 = 321; +export def SYS_execveat: u64 = 322; +export def SYS_userfaultfd: u64 = 323; +export def SYS_membarrier: u64 = 324; +export def SYS_mlock2: u64 = 325; +export def SYS_copy_file_range: u64 = 326; +export def SYS_preadv2: u64 = 327; +export def SYS_pwritev2: u64 = 328; +export def SYS_pkey_mprotect: u64 = 329; +export def SYS_pkey_alloc: u64 = 330; +export def SYS_pkey_free: u64 = 331; +export def SYS_statx: u64 = 332; +export def SYS_io_pgetevents: u64 = 333; +export def SYS_rseq: u64 = 334; +export def SYS_pidfd_send_signal: u64 = 424; +export def SYS_io_uring_setup: u64 = 425; +export def SYS_io_uring_enter: u64 = 426; +export def SYS_io_uring_register: u64 = 427; +export def SYS_open_tree: u64 = 428; +export def SYS_move_mount: u64 = 429; +export def SYS_fsopen: u64 = 430; +export def SYS_fsconfig: u64 = 431; +export def SYS_fsmount: u64 = 432; +export def SYS_fspick: u64 = 433; +export def SYS_faccessat2: u64 = 439; diff --git a/rt/+linux/syscalls.ha b/rt/+linux/syscalls.ha @@ -49,7 +49,7 @@ export fn execveat(dirfd: int, path: *const char, argv: *[*]nullable *const char // Returns the new PID to the parent, void to the child, or errno if something // goes wrong. -export fn fork() (int | void | errno) = clone(null, SIGCHLD, null, null, 0u64); +export fn fork() (int | void | errno) = clone(null, SIGCHLD, null, null, 0); export fn getpid() int = syscall0(SYS_getpid): int; @@ -96,8 +96,8 @@ export fn mmap( // XXX: Type promotion would simplify this return if (r: int == -EPERM && addr: uintptr == null: uintptr - && (flags & MAP_ANON) > 0u - && (flags & MAP_FIXED) == 0u) { + && (flags & MAP_ANON) > 0 + && (flags & MAP_FIXED) == 0) { // Fix up incorrect EPERM from kernel: wrap_errno(ENOMEM); } else err; @@ -145,7 +145,7 @@ export fn faccessat( * => err, }, n: u64 => { - assert(n == 0u64); + assert(n == 0); true; }, }; diff --git a/rt/+linux/types.ha b/rt/+linux/types.ha @@ -84,20 +84,20 @@ export type st = struct { ctime: timespec, }; -def STATX_TYPE: uint = 0x00000001u; -def STATX_MODE: uint = 0x00000002u; -def STATX_NLINK: uint = 0x00000004u; -def STATX_UID: uint = 0x00000008u; -def STATX_GID: uint = 0x00000010u; -def STATX_ATIME: uint = 0x00000020u; -def STATX_MTIME: uint = 0x00000040u; -def STATX_CTIME: uint = 0x00000080u; -def STATX_INO: uint = 0x00000100u; -def STATX_SIZE: uint = 0x00000200u; -def STATX_BLOCKS: uint = 0x00000400u; -def STATX_BASIC_STATS: uint = 0x000007FFu; -def STATX_BTIME: uint = 0x00000800u; -def STATX_MNT_ID: uint = 0x00001000u; +def STATX_TYPE: uint = 0x00000001; +def STATX_MODE: uint = 0x00000002; +def STATX_NLINK: uint = 0x00000004; +def STATX_UID: uint = 0x00000008; +def STATX_GID: uint = 0x00000010; +def STATX_ATIME: uint = 0x00000020; +def STATX_MTIME: uint = 0x00000040; +def STATX_CTIME: uint = 0x00000080; +def STATX_INO: uint = 0x00000100; +def STATX_SIZE: uint = 0x00000200; +def STATX_BLOCKS: uint = 0x00000400; +def STATX_BASIC_STATS: uint = 0x000007FF; +def STATX_BTIME: uint = 0x00000800; +def STATX_MNT_ID: uint = 0x00001000; export def SIGHUP: int = 1; export def SIGINT: int = 2; @@ -132,44 +132,44 @@ export def SIGPOLL: int = 29; export def SIGPWR: int = 30; export def SIGSYS: int = 31; -export def MAP_SHARED: uint = 0x01u; -export def MAP_PRIVATE: uint = 0x02u; -export def MAP_SHARED_VALIDATE: uint = 0x03u; -export def MAP_FIXED: uint = 0x10u; -export def MAP_ANON: uint = 0x20u; -export def MAP_NORESERVE: uint = 0x4000u; -export def MAP_GROWSDOWN: uint = 0x0100u; -export def MAP_DENYWRITE: uint = 0x0800u; -export def MAP_EXECUTABLE: uint = 0x1000u; -export def MAP_LOCKED: uint = 0x2000u; -export def MAP_POPULATE: uint = 0x8000u; -export def MAP_NONBLOCK: uint = 0x10000u; -export def MAP_STACK: uint = 0x20000u; -export def MAP_HUGETLB: uint = 0x40000u; -export def MAP_SYNC: uint = 0x80000u; -export def MAP_FIXED_NOREPLACE: uint = 0x100000u; -export def MAP_FILE: uint = 0u; -export def MAP_HUGE_SHIFT: uint = 26u; -export def MAP_HUGE_MASK: uint = 0x3fu; -export def MAP_HUGE_64KB: uint = 16u << 26u; -export def MAP_HUGE_512KB: uint = 19u << 26u; -export def MAP_HUGE_1MB: uint = 20u << 26u; -export def MAP_HUGE_2MB: uint = 21u << 26u; -export def MAP_HUGE_8MB: uint = 23u << 26u; -export def MAP_HUGE_16MB: uint = 24u << 26u; -export def MAP_HUGE_32MB: uint = 25u << 26u; -export def MAP_HUGE_256MB: uint = 28u << 26u; -export def MAP_HUGE_512MB: uint = 29u << 26u; -export def MAP_HUGE_1GB: uint = 30u << 26u; -export def MAP_HUGE_2GB: uint = 31u << 26u; -export def MAP_HUGE_16GB: uint = 34u << 26u; - -export def PROT_NONE: uint = 0u; -export def PROT_READ: uint = 1u; -export def PROT_WRITE: uint = 2u; -export def PROT_EXEC: uint = 4u; -export def PROT_GROWSDOWN: uint = 0x01000000u; -export def PROT_GROWSUP: uint = 0x02000000u; +export def MAP_SHARED: uint = 0x01; +export def MAP_PRIVATE: uint = 0x02; +export def MAP_SHARED_VALIDATE: uint = 0x03; +export def MAP_FIXED: uint = 0x10; +export def MAP_ANON: uint = 0x20; +export def MAP_NORESERVE: uint = 0x4000; +export def MAP_GROWSDOWN: uint = 0x0100; +export def MAP_DENYWRITE: uint = 0x0800; +export def MAP_EXECUTABLE: uint = 0x1000; +export def MAP_LOCKED: uint = 0x2000; +export def MAP_POPULATE: uint = 0x8000; +export def MAP_NONBLOCK: uint = 0x10000; +export def MAP_STACK: uint = 0x20000; +export def MAP_HUGETLB: uint = 0x40000; +export def MAP_SYNC: uint = 0x80000; +export def MAP_FIXED_NOREPLACE: uint = 0x100000; +export def MAP_FILE: uint = 0; +export def MAP_HUGE_SHIFT: uint = 26; +export def MAP_HUGE_MASK: uint = 0x3F; +export def MAP_HUGE_64KB: uint = 16 << 26; +export def MAP_HUGE_512KB: uint = 19 << 26; +export def MAP_HUGE_1MB: uint = 20 << 26; +export def MAP_HUGE_2MB: uint = 21 << 26; +export def MAP_HUGE_8MB: uint = 23 << 26; +export def MAP_HUGE_16MB: uint = 24 << 26; +export def MAP_HUGE_32MB: uint = 25 << 26; +export def MAP_HUGE_256MB: uint = 28 << 26; +export def MAP_HUGE_512MB: uint = 29 << 26; +export def MAP_HUGE_1GB: uint = 30 << 26; +export def MAP_HUGE_2GB: uint = 31 << 26; +export def MAP_HUGE_16GB: uint = 34 << 26; + +export def PROT_NONE: uint = 0; +export def PROT_READ: uint = 1; +export def PROT_WRITE: uint = 2; +export def PROT_EXEC: uint = 4; +export def PROT_GROWSDOWN: uint = 0x01000000; +export def PROT_GROWSUP: uint = 0x02000000; export def F_OK: int = 0; export def R_OK: int = 4; diff --git a/rt/+test/start.ha b/rt/+test/start.ha @@ -16,13 +16,13 @@ let reason: str = ""; export fn start_ha() void = { const ninit = (&init_end: uintptr - &init_start: uintptr): size / size(*fn() void); - for (let i = 0z; i < ninit; i += 1z) { + for (let i = 0z; i < ninit; i += 1) { init_start[i](); }; const ntest = (&test_end: uintptr - &test_start: uintptr): size / size(test); let maxname = 0z; - for (let i = 0z; i < ntest; i += 1z) { + for (let i = 0z; i < ntest; i += 1) { if (len(test_start[i].name) > maxname) { maxname = len(test_start[i].name); }; @@ -32,13 +32,13 @@ export fn start_ha() void = { print("Running "); print(ztos(ntest)); print(" tests:\n\n"); - for (let i = 0z; i < ntest; i += 1z) { + for (let i = 0z; i < ntest; i += 1) { print(test_start[i].name); - dots(maxname - len(test_start[i].name) + 3z); + dots(maxname - len(test_start[i].name) + 3); print(" "); if (setjmp(&jmp) != 0) { - nfail += 1z; + nfail += 1; print("FAIL: "); print(reason); print("\n"); @@ -46,7 +46,7 @@ export fn start_ha() void = { }; test_start[i].func(); - npass += 1z; + npass += 1; print("OK\n"); }; print("\n"); @@ -59,18 +59,18 @@ export fn start_ha() void = { const nfini = (&fini_end: uintptr - &fini_start: uintptr): size / size(*fn() void); - for (let i = 0z; i < nfini; i += 1z) { + for (let i = 0z; i < nfini; i += 1) { fini_start[i](); }; - exit(if (nfail > 0z) 1 else 0); + exit(if (nfail > 0) 1 else 0); }; fn print(msg: str) void = write(1, msg: *const char, len(msg)); fn dots(n: size) void = { // XXX: this is slow, I guess - for (let i = 0z; i < n; i += 1z) { + for (let i = 0z; i < n; i += 1) { print("."); }; }; diff --git a/rt/+test/ztos.ha b/rt/+test/ztos.ha @@ -1,38 +1,38 @@ fn bytes_reverse(b: []u8) void = { - if (len(b) == 0z) { + if (len(b) == 0) { return; }; - for (let s = 0z, e = len(b) - 1z; s < e) { + for (let s = 0z, e = len(b) - 1; s < e) { let x = b[s]; b[s] = b[e]; b[e] = x; - s += 1z; - e -= 1z; + s += 1; + e -= 1; }; }; fn ztos(u: size) const str = { - static let buf: [21]u8 = [0u8...]; // 20 digits plus NUL - buf = [0u8...]; + static let buf: [21]u8 = [0...]; // 20 digits plus NUL + buf = [0...]; let s = struct { b: *[*]u8 = &buf, - l: size = 0z, - c: size = 0z, + l: size = 0, + c: size = 0, }; - if (u == 0z) { + if (u == 0) { s.b[s.l] = '0': u32: u8; - s.l += 1z; + s.l += 1; }; - for (u > 0z) { - s.b[s.l] = '0': u32: u8 + (u % 10z): u8; - s.l += 1z; - u /= 10z; + for (u > 0) { + s.b[s.l] = '0': u32: u8 + (u % 10): u8; + s.l += 1; + u /= 10; }; bytes_reverse(s.b[..s.l]); - s.b[s.l] = 0u8; + s.b[s.l] = 0; return *(&s: *str); }; diff --git a/rt/ensure.ha b/rt/ensure.ha @@ -7,9 +7,9 @@ export type slice = struct { export fn ensure(s: *slice, membsz: size, length: size) void = { // TODO: make sure length * membsz < SIZE_MAX for (s.capacity < length) { - s.capacity *= 2z; + s.capacity *= 2; }; let data = realloc(s.data, s.capacity * membsz); - assert(data != null: nullable *void); + assert(data != null); s.data = data; }; diff --git a/rt/jmp.ha b/rt/jmp.ha @@ -1,7 +1,7 @@ type jmpbuf = struct { __jb: arch_jmpbuf, __fl: size, - __ss: [128z / size(size)]size, + __ss: [128 / size(size)]size, }; fn setjmp(buf: *jmpbuf) int; diff --git a/rt/malloc.ha b/rt/malloc.ha @@ -30,34 +30,31 @@ // bin to become non-continuous. This has no consequences for performance or // correctness. -// TODO: Type promotion -def ALIGN: size = 2z; +def ALIGN: size = 2; def WORD: size = size(size); def WASTE: size = WORD * ALIGN - WORD; -def BIGBLOCK: size = (2z << 16z) * WORD; +def BIGBLOCK: size = (2 << 16) * WORD; let bins: [50]nullable *void = [null...]; -fn bin2size(b: size) size = ((b + 1z) * ALIGN - 1z) * WORD; +fn bin2size(b: size) size = ((b + 1) * ALIGN - 1) * WORD; fn size2bin(s: size) size = { - assert(s <= bin2size(len(bins) - 1z), "Size exceeds maximum for bin"); - return (s + (WORD * (ALIGN - 1z) - 1z)) / (WORD * ALIGN); + assert(s <= bin2size(len(bins) - 1), "Size exceeds maximum for bin"); + return (s + (WORD * (ALIGN - 1) - 1)) / (WORD * ALIGN); }; // Allocates n bytes of memory and returns a pointer to them, or null if there // is insufficient memory. export fn malloc(n: size) nullable *void = { - assert(n > 0z); - let r: nullable *void = - if (n > bin2size(len(bins) - 1z)) malloc_large(n) + assert(n > 0); + return if (n > bin2size(len(bins) - 1)) malloc_large(n) else malloc_small(n); - return r; }; fn malloc_large(n: size) nullable *void = { let p = segmalloc(n + WASTE + WORD); - if (p == null: nullable *void) { + if (p == null) { return null; }; let bsize = (p: uintptr + WASTE: uintptr): *[1]size; @@ -68,13 +65,13 @@ fn malloc_large(n: size) nullable *void = { fn malloc_small(n: size) nullable *void = { const b = size2bin(n); let p = bins[b]; - if (p == null: nullable *void) { + if (p == null) { p = fill_bin(b); - if (p != null: nullable *void) { + if (p != null) { bins[b] = p; }; }; - return if (p != null: nullable *void) { + return if (p != null) { let q = *(p: **void); bins[b] = q; p; @@ -84,15 +81,14 @@ fn malloc_small(n: size) nullable *void = { fn fill_bin(b: size) nullable *void = { const s = bin2size(b); let p = segmalloc(BIGBLOCK); - return if (p == null: nullable *void) null - else list_from_block(s, p: uintptr); + return if (p == null) null else list_from_block(s, p: uintptr); }; fn list_from_block(s: size, p: uintptr) nullable *void = { const nblocks = (BIGBLOCK - WASTE) / (s + WORD); let q = p + WASTE: uintptr; // align q+WORD - for (let j = 0z; j != nblocks - 1z; j += 1z) { + for (let j = 0z; j != nblocks - 1; j += 1) { let sz = q: *size; let useralloc = q + WORD: uintptr; // aligned let next = (useralloc + s: uintptr + WORD: uintptr): *void; @@ -111,11 +107,11 @@ fn list_from_block(s: size, p: uintptr) nullable *void = { // Frees a pointer previously allocated with [malloc]. export @symbol("rt.free") fn free_(_p: nullable *void) void = { - if (_p != null: nullable *void) { + if (_p != null) { let p = _p: *void; let bsize = (p: uintptr - size(size): uintptr): *[1]size; let s = bsize[0]; - if (s <= bin2size(len(bins) - 1z)) free_small(p, s) + if (s <= bin2size(len(bins) - 1)) free_small(p, s) else free_large(p, s); }; }; @@ -139,8 +135,8 @@ fn free_small(p: *void, s: size) void = { // in-place. Returns null if there is insufficient memory to support the // request. export fn realloc(_p: nullable *void, n: size) nullable *void = { - assert(n > 0z); - if (_p == null: nullable *void) { + assert(n > 0); + if (_p == null) { return malloc(n); }; @@ -151,12 +147,12 @@ export fn realloc(_p: nullable *void, n: size) nullable *void = { return p; }; - if (n < bin2size(len(bins) - 1z) && size2bin(n) == size2bin(s)) { + if (n < bin2size(len(bins) - 1) && size2bin(n) == size2bin(s)) { return p; }; let new = malloc(n); - if (new != null: nullable *void) { + if (new != null) { memcpy(new: *void, p, s); free(p); }; diff --git a/rt/memcpy.ha b/rt/memcpy.ha @@ -1,6 +1,6 @@ export fn memcpy(dest: *void, src: *void, amt: size) void = { let a = dest: *[*]u8, b = src: *[*]u8; - for (let i = 0z; i < amt; i += 1z) { + for (let i = 0z; i < amt; i += 1) { a[i] = b[i]; }; }; diff --git a/rt/memset.ha b/rt/memset.ha @@ -1,6 +1,6 @@ export fn memset(dest: *void, val: u8, amt: size) void = { let a = dest: *[*]u8; - for (let i = 0z; i < amt; i += 1z) { + for (let i = 0z; i < amt; i += 1) { a[i] = val; }; }; diff --git a/rt/start.ha b/rt/start.ha @@ -8,7 +8,7 @@ const @symbol("__fini_array_end") fini_end: [*]*fn() void; export fn start_ha() void = { const ninit = (&init_end: uintptr - &init_start: uintptr): size / size(*fn() void); - for (let i = 0z; i < ninit; i += 1z) { + for (let i = 0z; i < ninit; i += 1) { init_start[i](); }; @@ -16,7 +16,7 @@ export fn start_ha() void = { const nfini = (&fini_end: uintptr - &fini_start: uintptr): size / size(*fn() void); - for (let i = 0z; i < nfini; i += 1z) { + for (let i = 0z; i < nfini; i += 1) { fini_start[i](); }; diff --git a/rt/strcmp.ha b/rt/strcmp.ha @@ -9,7 +9,7 @@ export fn strcmp(_a: str, _b: str) bool = { return false; }; let a = (&_a: *string).data, b = (&_b: *string).data; - for (let i = 0z; i < len(_a); i += 1z) { + for (let i = 0z; i < len(_a); i += 1) { if (a[i] != b[i]) { return false; }; diff --git a/strconv/itos.ha b/strconv/itos.ha @@ -5,40 +5,36 @@ use types; // allocated and will be overwritten on subsequent calls; see [strings::dup] to // duplicate the result. export fn i64tos(i: i64) const str = { - static assert(types::I64_MAX == 9223372036854775807i64); + static assert(types::I64_MAX == 9223372036854775807); if (i == types::I64_MIN) { return "-9223372036854775808"; }; - static let buf: [22]u8 = [0u8...]; // 20 chars plus NUL and - - buf = [0u8...]; + static let buf: [22]u8 = [0...]; // 20 chars plus NUL and - + buf = [0...]; - let s = struct { - b: *[*]u8 = &buf, - l: size = 0z, - c: size = 0z, - }; + let s = types::string { data = &buf, ... }; - const isneg = i < 0i64; + const isneg = i < 0; if (isneg) { - s.b[s.l] = '-': u32: u8; - s.l += 1z; + s.data[s.length] = '-': u32: u8; + s.length += 1; i = -i; - } else if (i == 0i64) { - s.b[s.l] = '0': u32: u8; - s.l += 1z; + } else if (i == 0) { + s.data[s.length] = '0': u32: u8; + s.length += 1; }; - for (i > 0i64) { - s.b[s.l] = '0': u32: u8 + (i % 10i64): u8; - s.l += 1z; - i /= 10i64; + for (i > 0) { + s.data[s.length] = '0': u32: u8 + (i % 10): u8; + s.length += 1; + i /= 10; }; - const x: size = if (isneg) 1z else 0z; - bytes::reverse(s.b[x..s.l]); + const x: size = if (isneg) 1 else 0; + bytes::reverse(s.data[x..s.length]); - s.b[s.l] = 0u8; + s.data[s.length] = 0; return *(&s: *str); }; @@ -63,10 +59,10 @@ export fn i32tos(i: i32) const str = i64tos(i: i64); export fn itos(i: int) const str = i64tos(i: i64); @test fn itos() void = { - const samples = [ - 1234i64, - 4321i64, - -1337i64, + const samples: [_]i64 = [ + 1234, + 4321, + -1337, 0, types::I64_MAX, types::I64_MIN, @@ -80,7 +76,7 @@ export fn itos(i: int) const str = i64tos(i: i64); "-9223372036854775808", ]; - for (let i = 0z; i < len(samples); i += 1z) { + for (let i = 0z; i < len(samples); i += 1) { const s = i64tos(samples[i]); assert(s == expected[i]); }; diff --git a/strconv/stoi.ha b/strconv/stoi.ha @@ -6,15 +6,15 @@ use strings; // [strconv::invalid] is returned. If the number is too large to be represented // by an i64, [strconv::overflow] is returned. export fn stoi64(s: str) (i64 | invalid | overflow) = { - if (len(s) == 0z) return invalid; + if (len(s) == 0) return invalid; let b = strings::to_utf8(s); let sign = 1i64; let max = types::I64_MAX: u64; if (b[0] == '-': u32: u8) { - sign = -1i64; - max += 1u64; + sign = -1; + max += 1; }; - let u = if (sign < 0i64) stou64(strings::from_utf8_unsafe(b[1..])) + let u = if (sign < 0) stou64(strings::from_utf8_unsafe(b[1..])) else stou64(s); match(u) { v: (invalid | overflow) => return v, diff --git a/strconv/stou.ha b/strconv/stou.ha @@ -7,9 +7,9 @@ fn rune_to_integer(r: rune) (u64 | void) = { if (ascii::isdigit(r)) return (r: u32 - '0': u32): u64 else if (ascii::isalpha(r) && ascii::islower(r)) - return (r: u32 - 'a': u32): u64 + 10u64 + return (r: u32 - 'a': u32): u64 + 10 else if (ascii::isalpha(r) && ascii::isupper(r)) - return (r: u32 - 'A': u32): u64 + 10u64; + return (r: u32 - 'A': u32): u64 + 10; return void; }; @@ -19,14 +19,13 @@ fn rune_to_integer(r: rune) (u64 | void) = { // the number is too large to be represented by a u64, [strconv::overflow] is // returned. Supported bases are 2, 8, 10 and 16. export fn stou64b(s: str, base: uint) (u64 | invalid | overflow) = { - assert(base == 2u || base == 8u || base == 10u || base == 16u); + assert(base == 2 || base == 8 || base == 10 || base == 16); - if (len(s) == 0z) { + if (len(s) == 0) { return invalid; }; - let n = 0u64; - + let n = 0z; let iter = strings::iter(s); for (true) { let r: rune = match (strings::next(&iter)) { @@ -135,34 +134,34 @@ export fn stozb(s: str, base: uint) (size | invalid | overflow) = { // non-numeric characters, or if it's empty, [strconv::invalid] is returned. If // the number is too large to be represented by a u64, [strconv::overflow] is // returned. -export fn stou64(s: str) (u64 | invalid | overflow) = stou64b(s, 10u); +export fn stou64(s: str) (u64 | invalid | overflow) = stou64b(s, 10); // Converts a string to a u32 in base 10, If the string contains any // non-numeric characters, or if it's empty, [strconv::invalid] is returned. If // the number is too large to be represented by a u32, [strconv::overflow] is // returned. -export fn stou32(s: str) (u32 | invalid | overflow) = stou32b(s, 10u); +export fn stou32(s: str) (u32 | invalid | overflow) = stou32b(s, 10); // Converts a string to a u16 in base 10, If the string contains any // non-numeric characters, or if it's empty, [strconv::invalid] is returned. If // the number is too large to be represented by a u16, [strconv::overflow] is // returned. -export fn stou16(s: str) (u16 | invalid | overflow) = stou16b(s, 10u); +export fn stou16(s: str) (u16 | invalid | overflow) = stou16b(s, 10); // Converts a string to a u8 in base 10, If the string contains any // non-numeric characters, or if it's empty, [strconv::invalid] is returned. If // the number is too large to be represented by a u8, [strconv::overflow] is // returned. -export fn stou8(s: str) (u8 | invalid | overflow) = stou8b(s, 10u); +export fn stou8(s: str) (u8 | invalid | overflow) = stou8b(s, 10); // Converts a string to a uint in base 10, If the string contains any // non-numeric characters, or if it's empty, [strconv::invalid] is returned. If // the number is too large to be represented by a uint, [strconv::overflow] is // returned. -export fn stou(s: str) (uint | invalid | overflow) = stoub(s, 10u); +export fn stou(s: str) (uint | invalid | overflow) = stoub(s, 10); // Converts a string to a u64 in base 10, If the string contains any // non-numeric characters, or if it's empty, [strconv::invalid] is returned. If // the number is too large to be represented by a u64, [strconv::overflow] is // returned. -export fn stoz(s: str) (size | invalid | overflow) = stozb(s, 10u); +export fn stoz(s: str) (size | invalid | overflow) = stozb(s, 10); diff --git a/strconv/utos.ha b/strconv/utos.ha @@ -5,29 +5,24 @@ use types; // allocated and will be overwritten on subsequent calls; see [strings::dup] to // duplicate the result. export fn u64tos(u: u64) const str = { - static assert(types::U64_MAX == 18446744073709551615u64); - static let buf: [21]u8 = [0u8...]; // 20 digits plus NUL - buf = [0u8...]; + static assert(types::U64_MAX == 18446744073709551615); + static let buf: [21]u8 = [0...]; // 20 digits plus NUL + buf = [0...]; - let s = struct { - b: *[*]u8 = &buf, - l: size = 0z, - c: size = 0z, - }; - - if (u == 0u64) { - s.b[s.l] = '0': u32: u8; - s.l += 1z; + let s = types::string { data = &buf, ... }; + if (u == 0) { + s.data[s.length] = '0': u32: u8; + s.length += 1z; }; for (u > 0u64) { - s.b[s.l] = '0': u32: u8 + (u % 10u64): u8; - s.l += 1z; - u /= 10u64; + s.data[s.length] = '0': u32: u8 + (u % 10): u8; + s.length += 1; + u /= 10; }; - bytes::reverse(s.b[..s.l]); - s.b[s.l] = 0u8; + bytes::reverse(s.data[..s.length]); + s.data[s.length] = 0; return *(&s: *str); }; @@ -62,9 +57,9 @@ export fn ztos(z: size) const str = u64tos(z: u64); export fn uptrtos(uptr: uintptr) const str = u64tos(uptr: u64); @test fn utos() void = { - const samples = [ - 1234u64, - 4321u64, + const samples: [_]u64 = [ + 1234, + 4321, types::U64_MIN, types::U64_MAX, ]; @@ -75,7 +70,7 @@ export fn uptrtos(uptr: uintptr) const str = u64tos(uptr: u64); "18446744073709551615", ]; - for (let i = 0z; i < len(samples); i += 1z) { + for (let i = 0z; i < len(samples); i += 1) { const s = u64tos(samples[i]); assert(s == expected[i]); }; diff --git a/strings/concat.ha b/strings/concat.ha @@ -1,21 +1,21 @@ // Concatenates two or more strings. The caller must free the return value. export fn concat(strs: str...) str = { let z = 0z; - for (let i = 0z; i < len(strs); i += 1z) { + for (let i = 0z; i < len(strs); i += 1) { z += len(strs[i]); }; - let new = alloc([]u8, [], z + 1z); - for (let i = 0z; i < len(strs); i += 1z) { + let new = alloc([]u8, [], z + 1); + for (let i = 0z; i < len(strs); i += 1) { append(new, ...to_utf8(strs[i])); }; - append(new, 0u8); + append(new, 0); return from_utf8_unsafe(new[..z]); }; @test fn concat() void = { let s = concat("hello ", "world"); assert(s == "hello world"); - assert((s: *const char: *[*]u8)[len(s)] == 0u8); + assert((s: *const char: *[*]u8)[len(s)] == 0); free(s); s = concat("hello", " ", "world"); diff --git a/strings/cstrings.ha b/strings/cstrings.ha @@ -6,7 +6,7 @@ use types; export let c_empty: *const char = null: *const char; @init fn init() void = { - static let buf: [1]u8 = [0u8]; + static let buf: [1]u8 = [0]; c_empty = &buf: *[*]u8: *const char; }; @@ -15,7 +15,7 @@ export let c_empty: *const char = null: *const char; export fn c_strlen(cstr: *const char) size = { const ptr = cstr: *[*]u8; let ln = 0z; - for (ptr[ln] != 0u8; ln += 1z) void; + for (ptr[ln] != 0; ln += 1) void; return ln; }; diff --git a/strings/dup.ha b/strings/dup.ha @@ -5,11 +5,11 @@ use types; // Duplicates a string. Aborts on allocation failure. export fn dup(s: const str) str = { let in = &s: *types::string; - let buf: *[*]u8 = match (rt::malloc(in.length + 1z)) { + let buf: *[*]u8 = match (rt::malloc(in.length + 1)) { null => abort("Out of memory"), v: *void => v, }; - bytes::copy(buf[..in.length + 1z], in.data[..in.length + 1z]); + bytes::copy(buf[..in.length + 1z], in.data[..in.length + 1]); let out = types::string { data = buf, length = in.length, @@ -21,7 +21,7 @@ export fn dup(s: const str) str = { // Duplicates every string of a slice in place, returning the same slice with // new strings. export fn dup_all(s: []str) void = { - for (let i = 0z; i < len(s); i += 1z) { + for (let i = 0z; i < len(s); i += 1) { s[i] = strings::dup(s[i]); }; }; diff --git a/strings/iter.ha b/strings/iter.ha @@ -45,18 +45,18 @@ export fn iter_str(iter: *iterator) str = { @test fn iter() void = { let s = iter("こんにちは"); const expected1 = ['こ', 'ん']; - for (let i = 0z; i < len(expected1); i += 1z) { + for (let i = 0z; i < len(expected1); i += 1) { match (next(&s)) { - r: rune => assert(r == expected1[i]), - void => abort(), + r: rune => assert(r == expected1[i]), + void => abort(), }; }; assert(iter_str(&s) == "にちは"); const expected2 = ['に', 'ち', 'は']; - for (let i = 0z; i < len(expected2); i += 1z) { + for (let i = 0z; i < len(expected2); i += 1) { match (next(&s)) { - r: rune => assert(r == expected2[i]), - void => abort(), + r: rune => assert(r == expected2[i]), + void => abort(), }; }; assert(next(&s) is void); diff --git a/strings/sub.ha b/strings/sub.ha @@ -4,7 +4,7 @@ export type end = void; fn utf8_byte_len_bounded(iter: *iterator, end: size) size = { let pos = 0z; - for (let i = 0z; i < end; i += 1z) { + for (let i = 0z; i < end; i += 1) { let r: rune = match (strings::next(iter)) { void => break, r: rune => r, @@ -44,8 +44,8 @@ export fn sub(s: str, start: size, end: (size | end)) str = { }; @test fn sub() void = { - assert(sub("a string", 2z, end) == "string"); - assert(sub("a string", 0z, 1z) == "a"); - assert(sub("a string", 0z, 3z) == "a s"); - assert(sub("a string", 2z, 8z) == "string"); + assert(sub("a string", 2, end) == "string"); + assert(sub("a string", 0, 1) == "a"); + assert(sub("a string", 0, 3) == "a s"); + assert(sub("a string", 2, 8) == "string"); }; diff --git a/strings/suffix.ha b/strings/suffix.ha @@ -4,7 +4,7 @@ export fn has_prefix(in: str, prefix: str) bool = { if (len(a) < len(b)) { return false; }; - for (let i = 0z; i < len(b); i += 1z) { + for (let i = 0z; i < len(b); i += 1) { if (a[i] != b[i]) { return false; }; @@ -28,7 +28,7 @@ export fn has_suffix(in: str, suff: str) bool = { if (len(a) < len(b)) { return false; }; - for (let i = 0z; i < len(b); i += 1z) { + for (let i = 0z; i < len(b); i += 1) { if (a[len(a) - len(b) + i] != b[i]) { return false; }; diff --git a/strings/tokenize.ha b/strings/tokenize.ha @@ -54,9 +54,9 @@ export fn remaining_tokens(s: *tokenizer) str = { // borrowed from 'in', and needn't be freed - but should be [strings::dup_all]'d // if they should outlive 'in'. export fn splitN(in: str, delim: str, n: size) []str = { - let toks = alloc([]str, [], 8z); // TODO: Drop explicit capacity + let toks = alloc([]str, [], 8); // TODO: Drop explicit capacity let tok = tokenize(in, delim); - for (let i = 0z; i < n - 1z; i += 1z) { + for (let i = 0z; i < n - 1z; i += 1) { match (next_token(&tok)) { s: str => { append(toks, s); @@ -78,14 +78,14 @@ export fn split(in: str, delim: str) []str = splitN(in, delim, types::SIZE_MAX); const expected = ["Hello,", "my", "name", "is Drew"]; const actual = splitN("Hello, my name is Drew", " ", 4z); assert(len(expected) == len(actual)); - for (let i = 0z; i < len(expected); i += 1z) { + for (let i = 0z; i < len(expected); i += 1) { assert(expected[i] == actual[i]); }; const expected2 = ["Hello,", "my", "name", "is", "Drew"]; const actual2 = split("Hello, my name is Drew", " "); assert(len(expected2) == len(actual2)); - for (let i = 0z; i < len(expected2); i += 1z) { + for (let i = 0z; i < len(expected2); i += 1) { assert(expected2[i] == actual2[i]); }; }; diff --git a/types/limits.ha b/types/limits.ha @@ -1,48 +1,48 @@ // Minimum value which can be stored in an i8 type. -export def I8_MIN: i8 = -128i8; +export def I8_MIN: i8 = -128; // Maximum value which can be stored in an i8 type. -export def I8_MAX: i8 = 127i8; +export def I8_MAX: i8 = 127; // Minimum value which can be stored in an i16 type. -export def I16_MIN: i16 = -32708i16; +export def I16_MIN: i16 = -32708; // Maximum value which can be stored in an i16 type. -export def I16_MAX: i16 = 32707i16; +export def I16_MAX: i16 = 32707; // Minimum value which can be stored in an i32 type. -export def I32_MIN: i32 = -2147483648i32; +export def I32_MIN: i32 = -2147483648; // Maximum value which can be stored in an i32 type. -export def I32_MAX: i32 = 2147483647i32; +export def I32_MAX: i32 = 2147483647; // Minimum value which can be stored in an i64 type -export def I64_MIN: i64 = -9223372036854775808i64; +export def I64_MIN: i64 = -9223372036854775808; // Maximum value which can be stored in an i64 type. -export def I64_MAX: i64 = 9223372036854775807i64; +export def I64_MAX: i64 = 9223372036854775807; // Minimum value which can be stored in a u8 type. -export def U8_MIN: u8 = 0u8; +export def U8_MIN: u8 = 0; // Maximum value which can be stored in a u8 type. -export def U8_MAX: u8 = 256u8; +export def U8_MAX: u8 = 255; // Minimum value which can be stored in a u16 type -export def U16_MIN: u16 = 0u16; +export def U16_MIN: u16 = 0; // Maximum value which can be stored in a u16 type. -export def U16_MAX: u16 = 65535u16; +export def U16_MAX: u16 = 65535; // Minimum value which can be stored in a u32 type -export def U32_MIN: u32 = 0u32; +export def U32_MIN: u32 = 0; // Maximum value which can be stored in a u32 type. -export def U32_MAX: u32 = 4294967295u32; +export def U32_MAX: u32 = 4294967295; // Minimum value which can be stored in a u64 type -export def U64_MIN: u64 = 0u64; +export def U64_MIN: u64 = 0; // Maximum value which can be stored in a u64 type. -export def U64_MAX: u64 = 18446744073709551615u64; +export def U64_MAX: u64 = 18446744073709551615;